summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-09-10 08:20:15 +0200
committerGitHub <noreply@github.com>2018-09-10 08:20:15 +0200
commitd9a96878f2e9251ca55a60e886559e975cdfdd51 (patch)
tree9c0152ee4d55c97c48a8e8cbb03c964c7095dc35 /modules
parent0b5041a627b2aaad04c2c0f023ea391a9c316d26 (diff)
parentb252e66414c2dc70f5e36045e4f0144dd29147cc (diff)
Merge pull request #21921 from AndreaCatania/bugfix2
Fix bullet crashes
Diffstat (limited to 'modules')
-rw-r--r--modules/bullet/area_bullet.cpp7
-rw-r--r--modules/bullet/bullet_physics_server.h2
-rw-r--r--modules/bullet/rigid_body_bullet.cpp7
3 files changed, 12 insertions, 4 deletions
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index f1da454e2e..3200b4a214 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -30,6 +30,7 @@
#include "area_bullet.h"
+#include "bullet_physics_server.h"
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "collision_object_bullet.h"
@@ -57,6 +58,7 @@ AreaBullet::AreaBullet() :
spOv_priority(0) {
btGhost = bulletnew(btGhostObject);
+ btGhost->setCollisionShape(BulletPhysicsServer::get_empty_shape());
setupBulletCollisionObject(btGhost);
/// Collision objects with a callback still have collision response with dynamic rigid bodies.
/// In order to use collision objects as trigger, you have to disable the collision response.
@@ -162,7 +164,10 @@ bool AreaBullet::is_monitoring() const {
}
void AreaBullet::main_shape_resetted() {
- btGhost->setCollisionShape(get_main_shape());
+ if (get_main_shape())
+ btGhost->setCollisionShape(get_main_shape());
+ else
+ btGhost->setCollisionShape(BulletPhysicsServer::get_empty_shape());
}
void AreaBullet::reload_body() {
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index e9c568d605..87719383f8 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -61,7 +61,7 @@ class BulletPhysicsServer : public PhysicsServer {
mutable RID_Owner<JointBullet> joint_owner;
private:
- /// This is used when a collision shape is not active, so the bullet compound shapes index are always sync with godot index
+ /// This is used as replacement of collision shape inside a compound or main shape
static btEmptyShape *emptyShape;
public:
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 73f0393684..2d0e74eb6f 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -279,7 +279,7 @@ RigidBodyBullet::RigidBodyBullet() :
// Initial properties
const btVector3 localInertia(0, 0, 0);
- btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, NULL, localInertia);
+ btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, BulletPhysicsServer::get_empty_shape(), localInertia);
btBody = bulletnew(btRigidBody(cInfo));
setupBulletCollisionObject(btBody);
@@ -315,7 +315,10 @@ void RigidBodyBullet::destroy_kinematic_utilities() {
}
void RigidBodyBullet::main_shape_resetted() {
- btBody->setCollisionShape(get_main_shape());
+ if (get_main_shape())
+ btBody->setCollisionShape(get_main_shape());
+ else
+ btBody->setCollisionShape(BulletPhysicsServer::get_empty_shape());
set_continuous_collision_detection(is_continuous_collision_detection_enabled()); // Reset
}