summaryrefslogtreecommitdiff
path: root/modules/bullet/collision_object_bullet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/bullet/collision_object_bullet.cpp')
-rw-r--r--modules/bullet/collision_object_bullet.cpp43
1 files changed, 16 insertions, 27 deletions
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 1b72c2f577..a3158a15e5 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -80,27 +80,17 @@ btTransform CollisionObjectBullet::ShapeWrapper::get_adjusted_transform() const
void CollisionObjectBullet::ShapeWrapper::claim_bt_shape(const btVector3 &body_scale) {
if (!bt_shape) {
- if (active)
+ if (active) {
bt_shape = shape->create_bt_shape(scale * body_scale);
- else
+ } else {
bt_shape = ShapeBullet::create_shape_empty();
+ }
}
}
CollisionObjectBullet::CollisionObjectBullet(Type p_type) :
RIDBullet(),
- type(p_type),
- instance_id(ObjectID()),
- collisionLayer(0),
- collisionMask(0),
- collisionsEnabled(true),
- m_isStatic(false),
- ray_pickable(false),
- bt_collision_object(nullptr),
- body_scale(1., 1., 1.),
- force_shape_reset(false),
- space(nullptr),
- isTransformChanged(false) {}
+ type(p_type) {}
CollisionObjectBullet::~CollisionObjectBullet() {
// Remove all overlapping, notify is not required since godot take care of it
@@ -147,18 +137,21 @@ void CollisionObjectBullet::setupBulletCollisionObject(btCollisionObject *p_coll
void CollisionObjectBullet::add_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject) {
exceptions.insert(p_ignoreCollisionObject->get_self());
- if (!bt_collision_object)
+ if (!bt_collision_object) {
return;
+ }
bt_collision_object->setIgnoreCollisionCheck(p_ignoreCollisionObject->bt_collision_object, true);
- if (space)
+ if (space) {
space->get_broadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bt_collision_object->getBroadphaseHandle(), space->get_dispatcher());
+ }
}
void CollisionObjectBullet::remove_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject) {
exceptions.erase(p_ignoreCollisionObject->get_self());
bt_collision_object->setIgnoreCollisionCheck(p_ignoreCollisionObject->bt_collision_object, false);
- if (space)
+ if (space) {
space->get_broadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bt_collision_object->getBroadphaseHandle(), space->get_dispatcher());
+ }
}
bool CollisionObjectBullet::has_collision_exception(const CollisionObjectBullet *p_otherCollisionObject) const {
@@ -195,7 +188,6 @@ int CollisionObjectBullet::get_godot_object_flags() const {
}
void CollisionObjectBullet::set_transform(const Transform &p_global_transform) {
-
set_body_scale(p_global_transform.basis.get_scale_abs());
btTransform bt_transform;
@@ -225,11 +217,6 @@ void CollisionObjectBullet::notify_transform_changed() {
isTransformChanged = true;
}
-RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) :
- CollisionObjectBullet(p_type),
- mainShape(nullptr) {
-}
-
RigidCollisionObjectBullet::~RigidCollisionObjectBullet() {
remove_all_shapes(true, true);
if (mainShape && mainShape->isCompound()) {
@@ -266,8 +253,9 @@ btCollisionShape *RigidCollisionObjectBullet::get_bt_shape(int p_index) const {
int RigidCollisionObjectBullet::find_shape(ShapeBullet *p_shape) const {
const int size = shapes.size();
for (int i = 0; i < size; ++i) {
- if (shapes[i].shape == p_shape)
+ if (shapes[i].shape == p_shape) {
return i;
+ }
}
return -1;
}
@@ -297,8 +285,9 @@ void RigidCollisionObjectBullet::remove_all_shapes(bool p_permanentlyFromThisBod
internal_shape_destroy(i, p_permanentlyFromThisBody);
}
shapes.clear();
- if (!p_force_not_reload)
+ if (!p_force_not_reload) {
reload_shapes();
+ }
}
void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transform &p_transform) {
@@ -319,8 +308,9 @@ Transform RigidCollisionObjectBullet::get_shape_transform(int p_index) const {
}
void RigidCollisionObjectBullet::set_shape_disabled(int p_index, bool p_disabled) {
- if (shapes[p_index].active != p_disabled)
+ if (shapes[p_index].active != p_disabled) {
return;
+ }
shapes.write[p_index].active = !p_disabled;
shape_changed(p_index);
}
@@ -339,7 +329,6 @@ void RigidCollisionObjectBullet::shape_changed(int p_shape_index) {
}
void RigidCollisionObjectBullet::reload_shapes() {
-
if (mainShape && mainShape->isCompound()) {
// Destroy compound
bulletdelete(mainShape);