adding the notification for keyLight changes modifying the KeyLIghtPayoad

This commit is contained in:
samcake 2017-05-04 18:28:12 -07:00
parent 855d35eb1b
commit df2c5b8c23
6 changed files with 86 additions and 21 deletions

View file

@ -337,7 +337,7 @@ public:
// Don't actually crash in debug builds, in case this apparent deadlock is simply from
// the developer actively debugging code
#ifdef NDEBUG
deadlockDetectionCrash();
// deadlockDetectionCrash();
#endif
}
}

View file

@ -68,8 +68,17 @@ bool RenderableZoneEntityItem::setProperties(const EntityItemProperties& propert
void RenderableZoneEntityItem::somethingChangedNotification() {
DependencyManager::get<EntityTreeRenderer>()->updateZone(_id);
// A new way:
if (_keyLightPropertiesChanged || _backgroundPropertiesChanged) {
notifyChangedRenderItem();
}
// Poopagate back to parent
ZoneEntityItem::somethingChangedNotification();
}
int RenderableZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
ReadBitstreamToTreeParams& args,
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
@ -290,6 +299,7 @@ void RenderableZoneEntityItem::removeFromScene(EntityItemPointer self, const ren
}
void RenderableZoneEntityItem::notifyBoundChanged() {
if (!render::Item::isValidID(_myMetaItem)) {
return;
@ -337,3 +347,24 @@ void RenderableZoneEntityItem::updateKeyLightItemFromEntity(KeyLightPayload& key
light->setType(model::Light::SUN);
}
void RenderableZoneEntityItem::sceneUpdateRenderItemFromEntity(render::Transaction& transaction) {
if (!render::Item::isValidID(_myKeyLightItem)) {
return;
}
transaction.updateItem<KeyLightPayload>(_myKeyLightItem, [&](KeyLightPayload& data) {
updateKeyLightItemFromEntity(data);
});
}
void RenderableZoneEntityItem::notifyChangedRenderItem() {
if (!render::Item::isValidID(_myKeyLightItem)) {
return;
}
render::Transaction transaction;
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
sceneUpdateRenderItemFromEntity(transaction);
scene->enqueueTransaction(transaction);
}

View file

@ -56,7 +56,8 @@ private:
template<typename Lambda>
void changeProperties(Lambda functor);
void notifyChangedRenderItem();
void sceneUpdateRenderItemFromEntity(render::Transaction& transaction);
void updateKeyLightItemFromEntity(KeyLightPayload& keylightPayload);

View file

@ -71,8 +71,26 @@ bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) {
bool somethingChanged = false;
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
bool somethingChangedInKeyLight = _keyLightProperties.setProperties(properties);
if (somethingChanged) {
bool wantDebug = false;
if (wantDebug) {
uint64_t now = usecTimestampNow();
int elapsed = now - getLastEdited();
qCDebug(entities) << "ZoneEntityItem::setProperties() AFTER update... edited AGO=" << elapsed <<
"now=" << now << " getLastEdited()=" << getLastEdited();
}
setLastEdited(properties._lastEdited);
}
return somethingChanged;
}
bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& properties) {
bool somethingChanged = EntityItem::setSubClassProperties(properties); // set the properties in our base class
_keyLightPropertiesChanged = _keyLightProperties.setProperties(properties);
bool somethingChangedInStage = _stageProperties.setProperties(properties);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType);
@ -85,18 +103,8 @@ bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) {
bool somethingChangedInSkybox = _skyboxProperties.setProperties(properties);
somethingChanged = somethingChanged || somethingChangedInKeyLight || somethingChangedInStage || somethingChangedInSkybox;
somethingChanged = somethingChanged || _keyLightPropertiesChanged || somethingChangedInStage || somethingChangedInSkybox;
if (somethingChanged) {
bool wantDebug = false;
if (wantDebug) {
uint64_t now = usecTimestampNow();
int elapsed = now - getLastEdited();
qCDebug(entities) << "ZoneEntityItem::setProperties() AFTER update... edited AGO=" << elapsed <<
"now=" << now << " getLastEdited()=" << getLastEdited();
}
setLastEdited(properties._lastEdited);
}
return somethingChanged;
}
@ -185,6 +193,14 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
APPEND_ENTITY_PROPERTY(PROP_FILTER_URL, getFilterURL());
}
void ZoneEntityItem::somethingChangedNotification() {
EntityItem::somethingChangedNotification();
withWriteLock([&] {
_keyLightPropertiesChanged = false;
_backgroundPropertiesChanged = false;
});
}
void ZoneEntityItem::debugDump() const {
quint64 now = usecTimestampNow();
qCDebug(entities) << " ZoneEntityItem id:" << getEntityItemID() << "---------------------------------------------";

View file

@ -29,10 +29,16 @@ public:
// methods for getting/setting all properties of an entity
virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const override;
virtual bool setProperties(const EntityItemProperties& properties) override;
virtual bool setSubClassProperties(const EntityItemProperties& properties) override;
// TODO: eventually only include properties changed since the params.nodeData->getLastTimeBagEmpty() time
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
/// Override this in your derived class if you'd like to be informed when something about the state of the entity
/// has changed. This will be called with properties change or when new data is loaded from a stream
/// Overriding this function to capture the information that a keylight / Ambient / skybox properties has changed
virtual void somethingChangedNotification() override;
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
EntityPropertyFlags& requestedProperties,
@ -106,6 +112,13 @@ protected:
bool _ghostingAllowed { DEFAULT_GHOSTING_ALLOWED };
QString _filterURL { DEFAULT_FILTER_URL };
// Dirty flags turn true when either keylight properties is changing values.
// This gets back to false in the somethingChangedNotification() call
// Which is called after a setProperties() or a readEntitySubClassFromBUfferCall on the entity.
bool _keyLightPropertiesChanged { false };
bool _backgroundPropertiesChanged { false };
static bool _drawZoneBoundaries;
static bool _zonesArePickable;
};

View file

@ -162,13 +162,9 @@ Column {
}
}
Row {
Column {
id: metas
CheckBox {
text: "Metas"
checked: Render.getConfig("DrawMetaBounds")["enabled"]
onCheckedChanged: { Render.getConfig("DrawMetaBounds")["enabled"] = checked }
}
CheckBox {
text: "Opaques"
checked: Render.getConfig("DrawOpaqueBounds")["enabled"]
@ -189,6 +185,13 @@ Column {
checked: Render.getConfig("DrawOverlayTransparentBounds")["enabled"]
onCheckedChanged: { Render.getConfig("DrawOverlayTransparentBounds")["enabled"] = checked }
}
}
Column {
CheckBox {
text: "Metas"
checked: Render.getConfig("DrawMetaBounds")["enabled"]
onCheckedChanged: { Render.getConfig("DrawMetaBounds")["enabled"] = checked }
}
CheckBox {
text: "Lights"
checked: Render.getConfig("DrawLightBounds")["enabled"]
@ -200,5 +203,6 @@ Column {
onCheckedChanged: { Render.getConfig("ZoneRenderer")["enabled"] = checked; Render.getConfig("DrawZones")["enabled"] = checked; }
}
}
}
}