SimpleEntitySimulation abides to new API

This commit is contained in:
Andrew Meadows 2015-04-28 16:28:03 -07:00
parent 14b6ee608a
commit 2f9306ee77
2 changed files with 19 additions and 6 deletions

View file

@ -19,7 +19,7 @@ const quint64 AUTO_REMOVE_SIMULATION_OWNER_USEC = 2 * USECS_PER_SECOND;
void SimpleEntitySimulation::updateEntitiesInternal(const quint64& now) {
// now is usecTimestampNow()
QSet<EntityItem*>::iterator itemItr = _movingEntities.begin();
SetOfEntities::iterator itemItr = _movingEntities.begin();
while (itemItr != _movingEntities.end()) {
EntityItem* entity = *itemItr;
if (!entity->isMoving()) {
@ -65,11 +65,23 @@ void SimpleEntitySimulation::removeEntityInternal(EntityItem* entity) {
_movingEntities.remove(entity);
_movableButStoppedEntities.remove(entity);
_hasSimulationOwnerEntities.remove(entity);
entity->_simulation = nullptr;
}
void SimpleEntitySimulation::deleteEntityInternal(EntityItem* entity) {
_movingEntities.remove(entity);
_movableButStoppedEntities.remove(entity);
_hasSimulationOwnerEntities.remove(entity);
entity->_simulation = nullptr;
if (!entity->_tree) {
// we held the last reference to this entity, so delete it
delete entity;
}
}
const int SIMPLE_SIMULATION_DIRTY_FLAGS = EntityItem::DIRTY_VELOCITY | EntityItem::DIRTY_MOTION_TYPE;
void SimpleEntitySimulation::entityChangedInternal(EntityItem* entity) {
void SimpleEntitySimulation::changeEntityInternal(EntityItem* entity) {
int dirtyFlags = entity->getDirtyFlags();
if (dirtyFlags & SIMPLE_SIMULATION_DIRTY_FLAGS) {
if (entity->isMoving()) {

View file

@ -25,12 +25,13 @@ protected:
virtual void updateEntitiesInternal(const quint64& now);
virtual void addEntityInternal(EntityItem* entity);
virtual void removeEntityInternal(EntityItem* entity);
virtual void entityChangedInternal(EntityItem* entity);
virtual void deleteEntityInternal(EntityItem* entity);
virtual void changeEntityInternal(EntityItem* entity);
virtual void clearEntitiesInternal();
QSet<EntityItem*> _movingEntities;
QSet<EntityItem*> _movableButStoppedEntities;
QSet<EntityItem*> _hasSimulationOwnerEntities;
SetOfEntities _movingEntities;
SetOfEntities _movableButStoppedEntities;
SetOfEntities _hasSimulationOwnerEntities;
};
#endif // hifi_SimpleEntitySimulation_h