summaryrefslogtreecommitdiff
path: root/modules/bullet
diff options
context:
space:
mode:
Diffstat (limited to 'modules/bullet')
-rw-r--r--modules/bullet/btRayShape.h2
-rw-r--r--modules/bullet/collision_object_bullet.h12
-rw-r--r--modules/bullet/rigid_body_bullet.cpp18
-rw-r--r--modules/bullet/rigid_body_bullet.h4
-rw-r--r--modules/bullet/space_bullet.cpp21
5 files changed, 36 insertions, 21 deletions
diff --git a/modules/bullet/btRayShape.h b/modules/bullet/btRayShape.h
index 7f3229b3e8..09c1f6c241 100644
--- a/modules/bullet/btRayShape.h
+++ b/modules/bullet/btRayShape.h
@@ -62,7 +62,7 @@ public:
virtual void setMargin(btScalar margin);
- void setSlipsOnSlope(bool p_slipOnSlope);
+ void setSlipsOnSlope(bool p_slipsOnSlope);
bool getSlipsOnSlope() const { return slipsOnSlope; }
const btTransform &getSupportPoint() const { return m_cacheSupportPoint; }
diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h
index c9430bec18..04231b0814 100644
--- a/modules/bullet/collision_object_bullet.h
+++ b/modules/bullet/collision_object_bullet.h
@@ -167,14 +167,18 @@ public:
_FORCE_INLINE_ const VSet<RID> &get_exceptions() const { return exceptions; }
_FORCE_INLINE_ void set_collision_layer(uint32_t p_layer) {
- collisionLayer = p_layer;
- on_collision_filters_change();
+ if (collisionLayer != p_layer) {
+ collisionLayer = p_layer;
+ on_collision_filters_change();
+ }
}
_FORCE_INLINE_ uint32_t get_collision_layer() const { return collisionLayer; }
_FORCE_INLINE_ void set_collision_mask(uint32_t p_mask) {
- collisionMask = p_mask;
- on_collision_filters_change();
+ if (collisionMask != p_mask) {
+ collisionMask = p_mask;
+ on_collision_filters_change();
+ }
}
_FORCE_INLINE_ uint32_t get_collision_mask() const { return collisionMask; }
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 8d21b25b20..d611810bfa 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -126,16 +126,16 @@ void BulletPhysicsDirectBodyState::add_torque(const Vector3 &p_torque) {
body->apply_torque(p_torque);
}
-void BulletPhysicsDirectBodyState::apply_central_impulse(const Vector3 &p_j) {
- body->apply_central_impulse(p_j);
+void BulletPhysicsDirectBodyState::apply_central_impulse(const Vector3 &p_impulse) {
+ body->apply_central_impulse(p_impulse);
}
-void BulletPhysicsDirectBodyState::apply_impulse(const Vector3 &p_pos, const Vector3 &p_j) {
- body->apply_impulse(p_pos, p_j);
+void BulletPhysicsDirectBodyState::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
+ body->apply_impulse(p_pos, p_impulse);
}
-void BulletPhysicsDirectBodyState::apply_torque_impulse(const Vector3 &p_j) {
- body->apply_torque_impulse(p_j);
+void BulletPhysicsDirectBodyState::apply_torque_impulse(const Vector3 &p_impulse) {
+ body->apply_torque_impulse(p_impulse);
}
void BulletPhysicsDirectBodyState::set_sleep_state(bool p_enable) {
@@ -411,6 +411,8 @@ void RigidBodyBullet::on_collision_filters_change() {
if (space) {
space->reload_collision_filters(this);
}
+
+ set_activation_state(true);
}
void RigidBodyBullet::on_collision_checker_start() {
@@ -471,7 +473,7 @@ void RigidBodyBullet::assert_no_constraints() {
void RigidBodyBullet::set_activation_state(bool p_active) {
if (p_active) {
- btBody->setActivationState(ACTIVE_TAG);
+ btBody->activate();
} else {
btBody->setActivationState(WANTS_DEACTIVATION);
}
@@ -918,7 +920,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
currentArea = areasWhereIam[i];
- if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) {
+ if (!currentArea || PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) {
continue;
}
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index f63148092f..0b6dc997db 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -114,8 +114,8 @@ public:
virtual void add_force(const Vector3 &p_force, const Vector3 &p_pos);
virtual void add_torque(const Vector3 &p_torque);
virtual void apply_central_impulse(const Vector3 &p_impulse);
- virtual void apply_impulse(const Vector3 &p_pos, const Vector3 &p_j);
- virtual void apply_torque_impulse(const Vector3 &p_j);
+ virtual void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
+ virtual void apply_torque_impulse(const Vector3 &p_impulse);
virtual void set_sleep_state(bool p_enable);
virtual bool is_sleeping() const;
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index d2b16b0fd1..e74c29769f 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -42,6 +42,7 @@
#include "servers/physics_server.h"
#include "soft_body_bullet.h"
+#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h>
@@ -459,9 +460,13 @@ void SpaceBullet::remove_area(AreaBullet *p_area) {
}
void SpaceBullet::reload_collision_filters(AreaBullet *p_area) {
- // This is necessary to change collision filter
- dynamicsWorld->removeCollisionObject(p_area->get_bt_ghost());
- dynamicsWorld->addCollisionObject(p_area->get_bt_ghost(), p_area->get_collision_layer(), p_area->get_collision_mask());
+ btGhostObject *ghost_object = p_area->get_bt_ghost();
+
+ btBroadphaseProxy *ghost_proxy = ghost_object->getBroadphaseHandle();
+ ghost_proxy->m_collisionFilterGroup = p_area->get_collision_layer();
+ ghost_proxy->m_collisionFilterMask = p_area->get_collision_mask();
+
+ dynamicsWorld->refreshBroadphaseProxy(ghost_object);
}
void SpaceBullet::add_rigid_body(RigidBodyBullet *p_body) {
@@ -482,9 +487,13 @@ void SpaceBullet::remove_rigid_body(RigidBodyBullet *p_body) {
}
void SpaceBullet::reload_collision_filters(RigidBodyBullet *p_body) {
- // This is necessary to change collision filter
- remove_rigid_body(p_body);
- add_rigid_body(p_body);
+ btRigidBody *rigid_body = p_body->get_bt_rigid_body();
+
+ btBroadphaseProxy *body_proxy = rigid_body->getBroadphaseProxy();
+ body_proxy->m_collisionFilterGroup = p_body->get_collision_layer();
+ body_proxy->m_collisionFilterMask = p_body->get_collision_mask();
+
+ dynamicsWorld->refreshBroadphaseProxy(rigid_body);
}
void SpaceBullet::add_soft_body(SoftBodyBullet *p_body) {