Make entity properties return undefined value after entity is deleted

This commit is contained in:
David Rowe 2016-01-23 22:00:51 +13:00
parent c812798314
commit d020114e59
3 changed files with 15 additions and 2 deletions

View file

@ -47,7 +47,9 @@ _localRenderAlphaChanged(false),
_defaultSettings(true),
_naturalDimensions(1.0f, 1.0f, 1.0f),
_naturalPosition(0.0f, 0.0f, 0.0f),
_desiredProperties(desiredProperties)
_desiredProperties(desiredProperties),
_entityFound(false)
{
}
@ -321,6 +323,11 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
QScriptValue properties = engine->newObject();
EntityItemProperties defaultEntityProperties;
if (!_entityFound) {
// Return without setting any default property values so that properties are reported in JavaScript as undefined.
return properties;
}
if (_idSet) {
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_ALWAYS(id, _id.toString());
}

View file

@ -272,6 +272,8 @@ public:
void setJointRotationsDirty() { _jointRotationsSetChanged = true; _jointRotationsChanged = true; }
void setJointTranslationsDirty() { _jointTranslationsSetChanged = true; _jointTranslationsChanged = true; }
void setEntityFound() { _entityFound = true; }
protected:
QString getCollisionMaskAsString() const;
void setCollisionMaskFromString(const QString& maskString);
@ -283,6 +285,8 @@ private:
EntityTypes::EntityType _type;
void setType(const QString& typeName) { _type = EntityTypes::getEntityTypeFromName(typeName); }
bool _entityFound;
float _glowLevel;
float _localRenderAlpha;
bool _glowLevelChanged;

View file

@ -202,11 +202,13 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit
}
}
results = convertLocationToScriptSemantics(results);
results.setEntityFound();
}
});
}
return convertLocationToScriptSemantics(results);
return results;
}
QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& scriptSideProperties) {