Merge pull request #39735 from AndreaCatania/bullet_phy_add_api
Added BulletPhysics APIs to return internal objects.
This commit is contained in:
commit
480cb25961
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user