Fixing the overlay renderItem access issue

This commit is contained in:
samcake 2016-03-10 14:09:34 -08:00
parent f97c7b00de
commit ad7d567932
2 changed files with 18 additions and 14 deletions

View file

@ -13,6 +13,7 @@
#include <RegisteredMetaTypes.h>
#include <SharedUtil.h>
#include "Application.h"
const float DEFAULT_LINE_WIDTH = 1.0f;
@ -38,15 +39,17 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
_drawInFront(base3DOverlay->_drawInFront)
{
}
void Base3DOverlay::setProperties(const QVariantMap& properties) {
Overlay::setProperties(properties);
bool needRenderItemUpdate = false;
auto drawInFront = properties["drawInFront"];
if (drawInFront.isValid()) {
bool value = drawInFront.toBool();
setDrawInFront(value);
needRenderItemUpdate = true;
}
auto position = properties["position"];
@ -60,16 +63,19 @@ void Base3DOverlay::setProperties(const QVariantMap& properties) {
}
if (position.isValid()) {
setPosition(vec3FromVariant(position));
needRenderItemUpdate = true;
}
if (properties["lineWidth"].isValid()) {
setLineWidth(properties["lineWidth"].toFloat());
needRenderItemUpdate = true;
}
auto rotation = properties["rotation"];
if (rotation.isValid()) {
setRotation(quatFromVariant(rotation));
needRenderItemUpdate = true;
}
if (properties["isSolid"].isValid()) {
@ -100,6 +106,17 @@ void Base3DOverlay::setProperties(const QVariantMap& properties) {
if (properties["ignoreRayIntersection"].isValid()) {
setIgnoreRayIntersection(properties["ignoreRayIntersection"].toBool());
}
// Communicate changes to the renderItem if needed
if (needRenderItemUpdate) {
auto itemID = getRenderItemID();
if (render::Item::isValidID(itemID)) {
render::ScenePointer scene = qApp->getMain3DScene();
render::PendingChanges pendingChanges;
pendingChanges.updateItem(itemID);
scene->enqueuePendingChanges(pendingChanges);
}
}
}
QVariant Base3DOverlay::getProperty(const QString& property) {

View file

@ -233,19 +233,6 @@ bool Overlays::editOverlay(unsigned int id, const QVariant& properties) {
if (thisOverlay) {
thisOverlay->setProperties(properties.toMap());
if (thisOverlay->is3D()) {
auto itemID = thisOverlay->getRenderItemID();
if (render::Item::isValidID(itemID)) {
render::ScenePointer scene = qApp->getMain3DScene();
const render::Item& item = scene->getItem(itemID);
if (item.getKey() != render::payloadGetKey(thisOverlay)) {
render::PendingChanges pendingChanges;
pendingChanges.updateItem(itemID);
scene->enqueuePendingChanges(pendingChanges);
}
}
}
return true;
}
return false;