mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 14:54:29 +02:00
Fixing the overlay renderItem access issue
This commit is contained in:
parent
f97c7b00de
commit
ad7d567932
2 changed files with 18 additions and 14 deletions
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <RegisteredMetaTypes.h>
|
#include <RegisteredMetaTypes.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
|
||||||
const float DEFAULT_LINE_WIDTH = 1.0f;
|
const float DEFAULT_LINE_WIDTH = 1.0f;
|
||||||
|
@ -38,15 +39,17 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
|
||||||
_drawInFront(base3DOverlay->_drawInFront)
|
_drawInFront(base3DOverlay->_drawInFront)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Base3DOverlay::setProperties(const QVariantMap& properties) {
|
void Base3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
Overlay::setProperties(properties);
|
Overlay::setProperties(properties);
|
||||||
|
|
||||||
|
bool needRenderItemUpdate = false;
|
||||||
|
|
||||||
auto drawInFront = properties["drawInFront"];
|
auto drawInFront = properties["drawInFront"];
|
||||||
|
|
||||||
if (drawInFront.isValid()) {
|
if (drawInFront.isValid()) {
|
||||||
bool value = drawInFront.toBool();
|
bool value = drawInFront.toBool();
|
||||||
setDrawInFront(value);
|
setDrawInFront(value);
|
||||||
|
needRenderItemUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto position = properties["position"];
|
auto position = properties["position"];
|
||||||
|
@ -60,16 +63,19 @@ void Base3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
}
|
}
|
||||||
if (position.isValid()) {
|
if (position.isValid()) {
|
||||||
setPosition(vec3FromVariant(position));
|
setPosition(vec3FromVariant(position));
|
||||||
|
needRenderItemUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties["lineWidth"].isValid()) {
|
if (properties["lineWidth"].isValid()) {
|
||||||
setLineWidth(properties["lineWidth"].toFloat());
|
setLineWidth(properties["lineWidth"].toFloat());
|
||||||
|
needRenderItemUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rotation = properties["rotation"];
|
auto rotation = properties["rotation"];
|
||||||
|
|
||||||
if (rotation.isValid()) {
|
if (rotation.isValid()) {
|
||||||
setRotation(quatFromVariant(rotation));
|
setRotation(quatFromVariant(rotation));
|
||||||
|
needRenderItemUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties["isSolid"].isValid()) {
|
if (properties["isSolid"].isValid()) {
|
||||||
|
@ -100,6 +106,17 @@ void Base3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
if (properties["ignoreRayIntersection"].isValid()) {
|
if (properties["ignoreRayIntersection"].isValid()) {
|
||||||
setIgnoreRayIntersection(properties["ignoreRayIntersection"].toBool());
|
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) {
|
QVariant Base3DOverlay::getProperty(const QString& property) {
|
||||||
|
|
|
@ -233,19 +233,6 @@ bool Overlays::editOverlay(unsigned int id, const QVariant& properties) {
|
||||||
if (thisOverlay) {
|
if (thisOverlay) {
|
||||||
thisOverlay->setProperties(properties.toMap());
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue