cleaning up

This commit is contained in:
SamGondelman 2017-08-07 18:37:55 -07:00
parent 42147640e2
commit 6d253fcc5f
5 changed files with 21 additions and 21 deletions

View file

@ -38,27 +38,12 @@ LaserPointer::LaserPointer(const QVariantMap& rayProps, const QHash<QString, Ren
LaserPointer::~LaserPointer() {
DependencyManager::get<RayPickManager>()->removeRayPick(_rayPickUID);
for (RenderState& renderState : _renderStates) {
if (!renderState.getStartID().isNull()) {
qApp->getOverlays().deleteOverlay(renderState.getStartID());
}
if (!renderState.getPathID().isNull()) {
qApp->getOverlays().deleteOverlay(renderState.getPathID());
}
if (!renderState.getEndID().isNull()) {
qApp->getOverlays().deleteOverlay(renderState.getEndID());
}
renderState.deleteOverlays();
}
for (QPair<float, RenderState>& renderState : _defaultRenderStates) {
if (!renderState.second.getStartID().isNull()) {
qApp->getOverlays().deleteOverlay(renderState.second.getStartID());
}
if (!renderState.second.getPathID().isNull()) {
qApp->getOverlays().deleteOverlay(renderState.second.getPathID());
}
if (!renderState.second.getEndID().isNull()) {
qApp->getOverlays().deleteOverlay(renderState.second.getEndID());
}
renderState.second.deleteOverlays();
}
}
@ -229,4 +214,16 @@ RenderState::RenderState(const OverlayID& startID, const OverlayID& pathID, cons
if (!_endID.isNull()) {
_endIgnoreRays = qApp->getOverlays().getOverlay(_endID)->getProperty("ignoreRayIntersection").toBool();
}
}
void RenderState::deleteOverlays() {
if (!_startID.isNull()) {
qApp->getOverlays().deleteOverlay(_startID);
}
if (!_pathID.isNull()) {
qApp->getOverlays().deleteOverlay(_pathID);
}
if (!_endID.isNull()) {
qApp->getOverlays().deleteOverlay(_endID);
}
}

View file

@ -36,6 +36,8 @@ public:
const bool& doesPathIgnoreRays() const { return _pathIgnoreRays; }
const bool& doesEndIgnoreRays() const { return _endIgnoreRays; }
void deleteOverlays();
private:
OverlayID _startID;
OverlayID _pathID;

View file

@ -9,13 +9,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "LaserPointerManager.h"
#include "LaserPointer.h"
#include "RayPick.h"
QUuid LaserPointerManager::createLaserPointer(const QVariantMap& rayProps, const QHash<QString, RenderState>& renderStates, QHash<QString, QPair<float, RenderState>>& defaultRenderStates,
const bool faceAvatar, const bool centerEndY, const bool lockEnd, const bool enabled) {
std::shared_ptr<LaserPointer> laserPointer = std::make_shared<LaserPointer>(rayProps, renderStates, defaultRenderStates, faceAvatar, centerEndY, lockEnd, enabled);
if (laserPointer->getRayUID() != 0) {
if (!laserPointer->getRayUID().isNull()) {
QWriteLocker lock(&_addLock);
QUuid id = QUuid::createUuid();
_laserPointersToAdd.enqueue(QPair<QUuid, std::shared_ptr<LaserPointer>>(id, laserPointer));

View file

@ -194,7 +194,7 @@ QUuid RayPickManager::createRayPick(const QVariantMap& rayProps) {
return id;
}
return 0;
return QUuid();
}
void RayPickManager::removeRayPick(const QUuid uid) {

View file

@ -30,11 +30,13 @@ enum RayPickMask {
PICK_AVATARS = 1 << 2,
PICK_HUD = 1 << 3,
// NOT YET IMPLEMENTED
PICK_BOUNDING_BOX = 1 << 4, // if not set, picks again physics mesh (can't pick against graphics mesh, yet)
PICK_INCLUDE_INVISIBLE = 1 << 5, // if not set, will not intersect invisible elements, otherwise, intersects both visible and invisible elements
PICK_INCLUDE_NONCOLLIDABLE = 1 << 6, // if not set, will not intersect noncollidable elements, otherwise, intersects both collidable and noncollidable elements
// NOT YET IMPLEMENTED
PICK_ALL_INTERSECTIONS = 1 << 7 // if not set, returns closest intersection, otherwise, returns list of all intersections
};