mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-06 08:43:09 +02:00
fix crash bugs (don't reference NULL pointers)
This commit is contained in:
parent
0932682c2a
commit
066e36c3e7
3 changed files with 17 additions and 9 deletions
|
@ -375,8 +375,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
|||
}
|
||||
|
||||
uint32_t EntityMotionState::getIncomingDirtyFlags() const {
|
||||
return _entity->getDirtyFlags();
|
||||
/* TODO: reimplement this motion-type adjustment
|
||||
uint32_t dirtyFlags = _entity->getDirtyFlags();
|
||||
if (_body) {
|
||||
// we add DIRTY_MOTION_TYPE if the body's motion type disagrees with entity velocity settings
|
||||
int bodyFlags = _body->getCollisionFlags();
|
||||
|
@ -387,7 +386,6 @@ uint32_t EntityMotionState::getIncomingDirtyFlags() const {
|
|||
}
|
||||
}
|
||||
return dirtyFlags;
|
||||
*/
|
||||
}
|
||||
|
||||
// virtual
|
||||
|
@ -397,7 +395,11 @@ void EntityMotionState::bump() {
|
|||
|
||||
void EntityMotionState::resetMeasuredBodyAcceleration() {
|
||||
_lastMeasureStep = ObjectMotionState::getWorldSimulationStep();
|
||||
_lastVelocity = bulletToGLM(_body->getLinearVelocity());
|
||||
if (_body) {
|
||||
_lastVelocity = bulletToGLM(_body->getLinearVelocity());
|
||||
} else {
|
||||
_lastVelocity = glm::vec3(0.0f);
|
||||
}
|
||||
_measuredAcceleration = glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ void PhysicalEntitySimulation::clearEntitiesInternal() {
|
|||
EntityMotionState* motionState = static_cast<EntityMotionState*>(&(*stateItr));
|
||||
EntityItem* entity = motionState->getEntity();
|
||||
entity->setPhysicsInfo(nullptr);
|
||||
clearEntitySimulation(entity);
|
||||
}
|
||||
|
||||
// then delete the objects (aka MotionStates)
|
||||
|
@ -113,6 +114,7 @@ VectorOfMotionStates& PhysicalEntitySimulation::getObjectsToDelete() {
|
|||
entity->setPhysicsInfo(nullptr);
|
||||
_tempVector.push_back(motionState);
|
||||
}
|
||||
clearEntitySimulation(entity);
|
||||
}
|
||||
_pendingRemoves.clear();
|
||||
return _tempVector;
|
||||
|
@ -161,7 +163,7 @@ void PhysicalEntitySimulation::handleOutgoingChanges(VectorOfMotionStates& motio
|
|||
// walk the motionStates looking for those that correspond to entities
|
||||
for (auto stateItr : motionStates) {
|
||||
ObjectMotionState* state = &(*stateItr);
|
||||
if (state->getType() == MOTION_STATE_TYPE_ENTITY) {
|
||||
if (state && state->getType() == MOTION_STATE_TYPE_ENTITY) {
|
||||
EntityMotionState* entityState = static_cast<EntityMotionState*>(state);
|
||||
_outgoingChanges.insert(entityState);
|
||||
_entitiesToSort.insert(entityState->getEntity());
|
||||
|
|
|
@ -95,8 +95,10 @@ void ThreadSafeDynamicsWorld::synchronizeMotionStates() {
|
|||
btCollisionObject* colObj = m_collisionObjects[i];
|
||||
btRigidBody* body = btRigidBody::upcast(colObj);
|
||||
if (body) {
|
||||
synchronizeSingleMotionState(body);
|
||||
_changedMotionStates.push_back(static_cast<ObjectMotionState*>(body->getMotionState()));
|
||||
if (body->getMotionState()) {
|
||||
synchronizeSingleMotionState(body);
|
||||
_changedMotionStates.push_back(static_cast<ObjectMotionState*>(body->getMotionState()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -104,8 +106,10 @@ void ThreadSafeDynamicsWorld::synchronizeMotionStates() {
|
|||
for (int i=0;i<m_nonStaticRigidBodies.size();i++) {
|
||||
btRigidBody* body = m_nonStaticRigidBodies[i];
|
||||
if (body->isActive()) {
|
||||
synchronizeSingleMotionState(body);
|
||||
_changedMotionStates.push_back(static_cast<ObjectMotionState*>(body->getMotionState()));
|
||||
if (body->getMotionState()) {
|
||||
synchronizeSingleMotionState(body);
|
||||
_changedMotionStates.push_back(static_cast<ObjectMotionState*>(body->getMotionState()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue