summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreaCatania <info@andreacatania.com>2017-11-19 18:21:36 +0100
committerAndreaCatania <info@andreacatania.com>2017-11-19 18:21:36 +0100
commit0327a51c1237e2956b5b4d3e520e43a958f1bf8e (patch)
tree1e7d986a8100aab389eddfe01fb478ee853e98f9
parentd250ade37b1e74dd11c870be279318ba01a8ba70 (diff)
Added null check in Bullet cast_motion API
-rw-r--r--modules/bullet/space_bullet.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index 6e7289ec91..e4d049b00d 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -175,17 +175,19 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
space->dynamicsWorld->convexSweepTest(bt_convex_shape, bt_xform_from, bt_xform_to, btResult, 0.002);
- if (btResult.hasHit()) {
- if (btCollisionObject::CO_RIGID_BODY == btResult.m_hitCollisionObject->getInternalType()) {
- B_TO_G(static_cast<const btRigidBody *>(btResult.m_hitCollisionObject)->getVelocityInLocalPoint(btResult.m_hitPointWorld), r_info->linear_velocity);
+ if (r_info) {
+ if (btResult.hasHit()) {
+ if (btCollisionObject::CO_RIGID_BODY == btResult.m_hitCollisionObject->getInternalType()) {
+ B_TO_G(static_cast<const btRigidBody *>(btResult.m_hitCollisionObject)->getVelocityInLocalPoint(btResult.m_hitPointWorld), r_info->linear_velocity);
+ }
+ CollisionObjectBullet *collision_object = static_cast<CollisionObjectBullet *>(btResult.m_hitCollisionObject->getUserPointer());
+ p_closest_safe = p_closest_unsafe = btResult.m_closestHitFraction;
+ B_TO_G(btResult.m_hitPointWorld, r_info->point);
+ B_TO_G(btResult.m_hitNormalWorld, r_info->normal);
+ r_info->rid = collision_object->get_self();
+ r_info->collider_id = collision_object->get_instance_id();
+ r_info->shape = btResult.m_shapeId;
}
- CollisionObjectBullet *collision_object = static_cast<CollisionObjectBullet *>(btResult.m_hitCollisionObject->getUserPointer());
- p_closest_safe = p_closest_unsafe = btResult.m_closestHitFraction;
- B_TO_G(btResult.m_hitPointWorld, r_info->point);
- B_TO_G(btResult.m_hitNormalWorld, r_info->normal);
- r_info->rid = collision_object->get_self();
- r_info->collider_id = collision_object->get_instance_id();
- r_info->shape = btResult.m_shapeId;
}
bulletdelete(bt_convex_shape);