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