From bc22e5723c05db62e788a852681d11979949f2db Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 9 Dec 2014 12:55:58 -0800 Subject: [PATCH] bundle the flags that EntitySimulation cares about --- libraries/entities/src/EntitySimulation.h | 13 +++++++++++++ libraries/entities/src/EntityTree.cpp | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntitySimulation.h b/libraries/entities/src/EntitySimulation.h index 506e2ed9d0..c87521e8a3 100644 --- a/libraries/entities/src/EntitySimulation.h +++ b/libraries/entities/src/EntitySimulation.h @@ -16,8 +16,21 @@ #include +#include "EntityItem.h" #include "EntityTree.h" +// the EntitySimulation needs to know when these things change on an entity, +// so it can sort EntityItem or relay its state to the PhysicsEngine. +const int DIRTY_SIMULATION_FLAGS = + EntityItem::DIRTY_POSITION | + EntityItem::DIRTY_VELOCITY | + EntityItem::DIRTY_MASS | + EntityItem::DIRTY_COLLISION_GROUP | + EntityItem::DIRTY_MOTION_TYPE | + EntityItem::DIRTY_SHAPE | + EntityItem::DIRTY_LIFETIME | + EntityItem::DIRTY_UPDATEABLE; + class EntitySimulation { public: EntitySimulation() : _entityTree(NULL) { } diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index d07211f790..f7addeaa8b 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -137,7 +137,7 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro entity->setOldMaximumAACube(entity->getMaximumAACube()); _isDirty = true; - uint32_t newFlags = entity->getDirtyFlags() & ~oldFlags; + uint32_t newFlags = entity->getDirtyFlags() & ~preFlags; if (newFlags) { if (newFlags & EntityItem::DIRTY_SCRIPT) { emit entityScriptChanging(entity->getEntityItemID()); @@ -145,7 +145,7 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro } if (_simulation) { - if (newFlags & ENTITY_SIMULATION_FLAGS) { + if (newFlags & DIRTY_SIMULATION_FLAGS) { _simulation->entityChanged(entity); } } else {