3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 16:55:31 +02:00

restore script change detection to what it was

This commit is contained in:
Andrew Meadows 2014-12-30 11:56:39 -08:00
parent ba873deb49
commit da551a0a76
4 changed files with 13 additions and 18 deletions

View file

@ -522,7 +522,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY_SETTER(PROP_GRAVITY, glm::vec3, updateGravity);
READ_ENTITY_PROPERTY(PROP_DAMPING, float, _damping);
READ_ENTITY_PROPERTY_SETTER(PROP_LIFETIME, float, updateLifetime);
READ_ENTITY_PROPERTY_STRING(PROP_SCRIPT, updateScript);
READ_ENTITY_PROPERTY_STRING(PROP_SCRIPT, setScript);
READ_ENTITY_PROPERTY(PROP_REGISTRATION_POINT, glm::vec3, _registrationPoint);
READ_ENTITY_PROPERTY_SETTER(PROP_ANGULAR_VELOCITY, glm::vec3, updateAngularVelocity);
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, _angularDamping);
@ -806,7 +806,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(gravity, updateGravityInMeters);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(damping, setDamping);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lifetime, updateLifetime);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(script, updateScript);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(script, setScript);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(registrationPoint, setRegistrationPoint);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularVelocity, updateAngularVelocity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularDamping, setAngularDamping);
@ -1124,10 +1124,3 @@ void EntityItem::updateLifetime(float value) {
}
}
void EntityItem::updateScript(const QString& value) {
if (_script != value) {
_script = value;
_dirtyFlags |= EntityItem::DIRTY_SCRIPT;
}
}

View file

@ -51,9 +51,6 @@ public:
DIRTY_SHAPE = 0x0020,
DIRTY_LIFETIME = 0x0040,
DIRTY_UPDATEABLE = 0x0080,
// add new simulation-relevant flags above
// all other flags below
DIRTY_SCRIPT = 0x8000
};
DONT_ALLOW_INSTANTIATION // This class can not be instantiated directly
@ -294,7 +291,6 @@ public:
void updateIgnoreForCollisions(bool value);
void updateCollisionsWillMove(bool value);
void updateLifetime(float value);
void updateScript(const QString& value);
uint32_t getDirtyFlags() const { return _dirtyFlags; }
void clearDirtyFlags(uint32_t mask = 0xffff) { _dirtyFlags &= ~mask; }

View file

@ -139,11 +139,6 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro
uint32_t newFlags = entity->getDirtyFlags() & ~preFlags;
if (newFlags) {
if (newFlags & EntityItem::DIRTY_SCRIPT) {
emit entityScriptChanging(entity->getEntityItemID());
entity->clearDirtyFlags(EntityItem::DIRTY_SCRIPT);
}
if (_simulation) {
if (newFlags & DIRTY_SIMULATION_FLAGS) {
_simulation->entityChanged(entity);
@ -224,6 +219,10 @@ void EntityTree::trackDeletedEntity(EntityItem* entity) {
}
}
void EntityTree::emitEntityScriptChanging(const EntityItemID& entityItemID) {
emit entityScriptChanging(entityItemID);
}
void EntityTree::setSimulation(EntitySimulation* simulation) {
if (simulation) {
// assert that the simulation's backpointer has already been properly connected

View file

@ -760,6 +760,7 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
// TODO: Do we need to also do this?
// 3) remember the old cube for the entity so we can mark it as dirty
if (entityItem) {
QString entityScriptBefore = entityItem->getScript();
bool bestFitBefore = bestFitEntityBounds(entityItem);
EntityTreeElement* currentContainingElement = _myTree->getContainingElement(entityItemID);
@ -780,6 +781,12 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
}
}
}
QString entityScriptAfter = entityItem->getScript();
if (entityScriptBefore != entityScriptAfter) {
_myTree->emitEntityScriptChanging(entityItemID); // the entity script has changed
}
} else {
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
if (entityItem) {