summaryrefslogtreecommitdiff
path: root/modules/bullet
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-07 12:13:51 +0200
committerGitHub <noreply@github.com>2020-07-07 12:13:51 +0200
commit480cb25961a20b488a035ad936fde9b333b66090 (patch)
tree5d4ceb39036cdff3077cf094a2bdfcf58ae45584 /modules/bullet
parent624eff4633bfb847a08e2354d57db429c51d0900 (diff)
parenta2b5e7971ae7ebfe1a4c9575145936cd40dee120 (diff)
Merge pull request #39735 from AndreaCatania/bullet_phy_add_api
Added BulletPhysics APIs to return internal objects.
Diffstat (limited to 'modules/bullet')
-rw-r--r--modules/bullet/bullet_physics_server.cpp27
-rw-r--r--modules/bullet/bullet_physics_server.h10
-rw-r--r--modules/bullet/space_bullet.cpp2
-rw-r--r--modules/bullet/space_bullet.h9
4 files changed, 33 insertions, 15 deletions
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index f397c53344..bb1678a994 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -561,14 +561,14 @@ void BulletPhysicsServer3D::body_clear_shapes(RID p_body) {
}
void BulletPhysicsServer3D::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
- CollisionObjectBullet *body = get_collisin_object(p_body);
+ CollisionObjectBullet *body = get_collision_object(p_body);
ERR_FAIL_COND(!body);
body->set_instance_id(p_id);
}
ObjectID BulletPhysicsServer3D::body_get_object_instance_id(RID p_body) const {
- CollisionObjectBullet *body = get_collisin_object(p_body);
+ CollisionObjectBullet *body = get_collision_object(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
return body->get_instance_id();
@@ -1567,7 +1567,17 @@ int BulletPhysicsServer3D::get_process_info(ProcessInfo p_info) {
return 0;
}
-CollisionObjectBullet *BulletPhysicsServer3D::get_collisin_object(RID p_object) const {
+SpaceBullet *BulletPhysicsServer3D::get_space(RID p_rid) const {
+ ERR_FAIL_COND_V_MSG(space_owner.owns(p_rid) == false, nullptr, "The RID is not valid.");
+ return space_owner.getornull(p_rid);
+}
+
+ShapeBullet *BulletPhysicsServer3D::get_shape(RID p_rid) const {
+ ERR_FAIL_COND_V_MSG(shape_owner.owns(p_rid) == false, nullptr, "The RID is not valid.");
+ return shape_owner.getornull(p_rid);
+}
+
+CollisionObjectBullet *BulletPhysicsServer3D::get_collision_object(RID p_object) const {
if (rigid_body_owner.owns(p_object)) {
return rigid_body_owner.getornull(p_object);
}
@@ -1577,15 +1587,20 @@ CollisionObjectBullet *BulletPhysicsServer3D::get_collisin_object(RID p_object)
if (soft_body_owner.owns(p_object)) {
return soft_body_owner.getornull(p_object);
}
- return nullptr;
+ ERR_FAIL_V_MSG(nullptr, "The RID is no valid.");
}
-RigidCollisionObjectBullet *BulletPhysicsServer3D::get_rigid_collisin_object(RID p_object) const {
+RigidCollisionObjectBullet *BulletPhysicsServer3D::get_rigid_collision_object(RID p_object) const {
if (rigid_body_owner.owns(p_object)) {
return rigid_body_owner.getornull(p_object);
}
if (area_owner.owns(p_object)) {
return area_owner.getornull(p_object);
}
- return nullptr;
+ ERR_FAIL_V_MSG(nullptr, "The RID is no valid.");
+}
+
+JointBullet *BulletPhysicsServer3D::get_joint(RID p_rid) const {
+ ERR_FAIL_COND_V_MSG(joint_owner.owns(p_rid) == false, nullptr, "The RID is not valid.");
+ return joint_owner.getornull(p_rid);
}
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index 8e8b33a4b8..a8c4f6d0b2 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -405,11 +405,11 @@ public:
virtual int get_process_info(ProcessInfo p_info);
- CollisionObjectBullet *get_collisin_object(RID p_object) const;
- RigidCollisionObjectBullet *get_rigid_collisin_object(RID p_object) const;
-
- /// Internal APIs
-public:
+ SpaceBullet *get_space(RID p_rid) const;
+ ShapeBullet *get_shape(RID p_rid) const;
+ CollisionObjectBullet *get_collision_object(RID p_object) const;
+ RigidCollisionObjectBullet *get_rigid_collision_object(RID p_object) const;
+ JointBullet *get_joint(RID p_rid) const;
};
#endif
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index cfe8cd5322..0cafb30078 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -286,7 +286,7 @@ bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_sh
}
Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const {
- RigidCollisionObjectBullet *rigid_object = space->get_physics_server()->get_rigid_collisin_object(p_object);
+ RigidCollisionObjectBullet *rigid_object = space->get_physics_server()->get_rigid_collision_object(p_object);
ERR_FAIL_COND_V(!rigid_object, Vector3());
btVector3 out_closest_point(0, 0, 0);
diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h
index 5ff421ef52..0b3e48c618 100644
--- a/modules/bullet/space_bullet.h
+++ b/modules/bullet/space_bullet.h
@@ -124,9 +124,12 @@ public:
real_t get_delta_time() { return delta_time; }
void step(real_t p_delta_time);
- _FORCE_INLINE_ btBroadphaseInterface *get_broadphase() { return broadphase; }
- _FORCE_INLINE_ btCollisionDispatcher *get_dispatcher() { return dispatcher; }
- _FORCE_INLINE_ btSoftBodyWorldInfo *get_soft_body_world_info() { return soft_body_world_info; }
+ _FORCE_INLINE_ btBroadphaseInterface *get_broadphase() const { return broadphase; }
+ _FORCE_INLINE_ btDefaultCollisionConfiguration *get_collision_configuration() const { return collisionConfiguration; }
+ _FORCE_INLINE_ btCollisionDispatcher *get_dispatcher() const { return dispatcher; }
+ _FORCE_INLINE_ btConstraintSolver *get_solver() const { return solver; }
+ _FORCE_INLINE_ btDiscreteDynamicsWorld *get_dynamic_world() const { return dynamicsWorld; }
+ _FORCE_INLINE_ btSoftBodyWorldInfo *get_soft_body_world_info() const { return soft_body_world_info; }
_FORCE_INLINE_ bool is_using_soft_world() { return soft_body_world_info; }
/// Used to set some parameters to Bullet world