only add to physics simulation that when necessary

This commit is contained in:
Andrew Meadows 2018-04-06 15:26:33 -07:00
parent 39fcb762a7
commit 2cfb835b56

View file

@ -48,7 +48,9 @@ void PhysicalEntitySimulation::addEntityInternal(EntityItemPointer entity) {
QMutexLocker lock(&_mutex);
assert(entity);
assert(!entity->isDead());
if (entity->shouldBePhysical()) {
uint8_t region = _space->getRegion(entity->getSpaceIndex());
bool shouldBePhysical = region < workload::Region::R3 && entity->shouldBePhysical();
if (shouldBePhysical) {
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
if (!motionState) {
_entitiesToAddToPhysics.insert(entity);