Use real_t in physics code
This commit is contained in:
parent
329d4796ae
commit
cb9fc117d1
23 changed files with 170 additions and 154 deletions
|
@ -625,14 +625,14 @@ uint32_t BulletPhysicsServer3D::body_get_user_flags(RID p_body) const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
|
||||
void BulletPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
|
||||
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
|
||||
body->set_param(p_param, p_value);
|
||||
}
|
||||
|
||||
float BulletPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const {
|
||||
real_t BulletPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const {
|
||||
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0);
|
||||
|
||||
|
@ -807,11 +807,11 @@ int BulletPhysicsServer3D::body_get_max_contacts_reported(RID p_body) const {
|
|||
return body->get_max_collisions_detection();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) {
|
||||
void BulletPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
|
||||
// Not supported by bullet and even Godot
|
||||
}
|
||||
|
||||
float BulletPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const {
|
||||
real_t BulletPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const {
|
||||
// Not supported by bullet and even Godot
|
||||
return 0.;
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform &p_from
|
|||
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, r_result, p_exclude_raycast_shapes);
|
||||
}
|
||||
|
||||
int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
|
||||
int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin) {
|
||||
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0);
|
||||
ERR_FAIL_COND_V(!body->get_space(), 0);
|
||||
|
@ -1221,7 +1221,7 @@ RID BulletPhysicsServer3D::joint_create_pin(RID p_body_A, const Vector3 &p_local
|
|||
CreateThenReturnRID(joint_owner, joint);
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) {
|
||||
void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND(!joint);
|
||||
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
|
||||
|
@ -1229,7 +1229,7 @@ void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_par
|
|||
pin_joint->set_param(p_param, p_value);
|
||||
}
|
||||
|
||||
float BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
|
||||
real_t BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, 0);
|
||||
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0);
|
||||
|
@ -1309,7 +1309,7 @@ RID BulletPhysicsServer3D::joint_create_hinge_simple(RID p_body_A, const Vector3
|
|||
CreateThenReturnRID(joint_owner, joint);
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) {
|
||||
void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND(!joint);
|
||||
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
|
||||
|
@ -1317,7 +1317,7 @@ void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p
|
|||
hinge_joint->set_param(p_param, p_value);
|
||||
}
|
||||
|
||||
float BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
|
||||
real_t BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, 0);
|
||||
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0);
|
||||
|
@ -1361,7 +1361,7 @@ RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform &p_
|
|||
CreateThenReturnRID(joint_owner, joint);
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) {
|
||||
void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND(!joint);
|
||||
ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER);
|
||||
|
@ -1369,7 +1369,7 @@ void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam
|
|||
slider_joint->set_param(p_param, p_value);
|
||||
}
|
||||
|
||||
float BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
|
||||
real_t BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, 0);
|
||||
ERR_FAIL_COND_V(joint->get_type() != JOINT_SLIDER, 0);
|
||||
|
@ -1395,7 +1395,7 @@ RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform
|
|||
CreateThenReturnRID(joint_owner, joint);
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) {
|
||||
void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND(!joint);
|
||||
ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST);
|
||||
|
@ -1403,7 +1403,7 @@ void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJoi
|
|||
coneTwist_joint->set_param(p_param, p_value);
|
||||
}
|
||||
|
||||
float BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
|
||||
real_t BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, 0.);
|
||||
ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0.);
|
||||
|
@ -1431,7 +1431,7 @@ RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transfo
|
|||
CreateThenReturnRID(joint_owner, joint);
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) {
|
||||
void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND(!joint);
|
||||
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
|
||||
|
@ -1439,7 +1439,7 @@ void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::A
|
|||
generic_6dof_joint->set_param(p_axis, p_param, p_value);
|
||||
}
|
||||
|
||||
float BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
|
||||
real_t BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
|
||||
JointBullet *joint = joint_owner.getornull(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, 0);
|
||||
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
|
||||
|
@ -1525,7 +1525,7 @@ void BulletPhysicsServer3D::init() {
|
|||
BulletPhysicsDirectBodyState3D::initSingleton();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::step(float p_deltaTime) {
|
||||
void BulletPhysicsServer3D::step(real_t p_deltaTime) {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -207,8 +207,8 @@ public:
|
|||
/// This is not supported by physics server
|
||||
virtual uint32_t body_get_user_flags(RID p_body) const override;
|
||||
|
||||
virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value) override;
|
||||
virtual float body_get_param(RID p_body, BodyParameter p_param) const override;
|
||||
virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value) override;
|
||||
virtual real_t body_get_param(RID p_body, BodyParameter p_param) const override;
|
||||
|
||||
virtual void body_set_kinematic_safe_margin(RID p_body, real_t p_margin) override;
|
||||
virtual real_t body_get_kinematic_safe_margin(RID p_body) const override;
|
||||
|
@ -241,8 +241,8 @@ public:
|
|||
virtual void body_set_max_contacts_reported(RID p_body, int p_contacts) override;
|
||||
virtual int body_get_max_contacts_reported(RID p_body) const override;
|
||||
|
||||
virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) override;
|
||||
virtual float body_get_contacts_reported_depth_threshold(RID p_body) const override;
|
||||
virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) override;
|
||||
virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const override;
|
||||
|
||||
virtual void body_set_omit_force_integration(RID p_body, bool p_omit) override;
|
||||
virtual bool body_is_omitting_force_integration(RID p_body) const override;
|
||||
|
@ -256,7 +256,7 @@ public:
|
|||
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override;
|
||||
|
||||
virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) override;
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001) override;
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) override;
|
||||
|
||||
/* SOFT BODY API */
|
||||
|
||||
|
@ -337,8 +337,8 @@ public:
|
|||
|
||||
virtual RID joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) override;
|
||||
|
||||
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) override;
|
||||
virtual float pin_joint_get_param(RID p_joint, PinJointParam p_param) const override;
|
||||
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) override;
|
||||
virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const override;
|
||||
|
||||
virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) override;
|
||||
virtual Vector3 pin_joint_get_local_a(RID p_joint) const override;
|
||||
|
@ -349,8 +349,8 @@ public:
|
|||
virtual RID joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) override;
|
||||
virtual RID joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) override;
|
||||
|
||||
virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) override;
|
||||
virtual float hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const override;
|
||||
virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) override;
|
||||
virtual real_t hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const override;
|
||||
|
||||
virtual void hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) override;
|
||||
virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const override;
|
||||
|
@ -358,20 +358,20 @@ public:
|
|||
/// Reference frame is A
|
||||
virtual RID joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override;
|
||||
|
||||
virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) override;
|
||||
virtual float slider_joint_get_param(RID p_joint, SliderJointParam p_param) const override;
|
||||
virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) override;
|
||||
virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const override;
|
||||
|
||||
/// Reference frame is A
|
||||
virtual RID joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override;
|
||||
|
||||
virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) override;
|
||||
virtual float cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const override;
|
||||
virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) override;
|
||||
virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const override;
|
||||
|
||||
/// Reference frame is A
|
||||
virtual RID joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override;
|
||||
|
||||
virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) override;
|
||||
virtual float generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) override;
|
||||
virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) override;
|
||||
virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) override;
|
||||
|
||||
virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) override;
|
||||
virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) override;
|
||||
|
@ -393,7 +393,7 @@ public:
|
|||
}
|
||||
|
||||
virtual void init() override;
|
||||
virtual void step(float p_deltaTime) override;
|
||||
virtual void step(real_t p_deltaTime) override;
|
||||
virtual void flush_queries() override;
|
||||
virtual void finish() override;
|
||||
|
||||
|
|
|
@ -56,11 +56,11 @@ Vector3 BulletPhysicsDirectBodyState3D::get_total_gravity() const {
|
|||
return gVec;
|
||||
}
|
||||
|
||||
float BulletPhysicsDirectBodyState3D::get_total_angular_damp() const {
|
||||
real_t BulletPhysicsDirectBodyState3D::get_total_angular_damp() const {
|
||||
return body->btBody->getAngularDamping();
|
||||
}
|
||||
|
||||
float BulletPhysicsDirectBodyState3D::get_total_linear_damp() const {
|
||||
real_t BulletPhysicsDirectBodyState3D::get_total_linear_damp() const {
|
||||
return body->btBody->getLinearDamping();
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ Basis BulletPhysicsDirectBodyState3D::get_principal_inertia_axes() const {
|
|||
return Basis();
|
||||
}
|
||||
|
||||
float BulletPhysicsDirectBodyState3D::get_inverse_mass() const {
|
||||
real_t BulletPhysicsDirectBodyState3D::get_inverse_mass() const {
|
||||
return body->btBody->getInvMass();
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ Vector3 BulletPhysicsDirectBodyState3D::get_contact_local_normal(int p_contact_i
|
|||
return body->collisions[p_contact_idx].hitNormal;
|
||||
}
|
||||
|
||||
float BulletPhysicsDirectBodyState3D::get_contact_impulse(int p_contact_idx) const {
|
||||
real_t BulletPhysicsDirectBodyState3D::get_contact_impulse(int p_contact_idx) const {
|
||||
return body->collisions[p_contact_idx].appliedImpulse;
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ void RigidBodyBullet::on_collision_checker_end() {
|
|||
isTransformChanged = btBody->isActive() && !btBody->isStaticOrKinematicObject();
|
||||
}
|
||||
|
||||
bool RigidBodyBullet::add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const float &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index) {
|
||||
bool RigidBodyBullet::add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const real_t &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index) {
|
||||
if (collisionsCount >= maxCollisionsDetection) {
|
||||
return false;
|
||||
}
|
||||
|
@ -710,12 +710,12 @@ bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
|
|||
}
|
||||
|
||||
void RigidBodyBullet::reload_axis_lock() {
|
||||
btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z))));
|
||||
btBody->setLinearFactor(btVector3(btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z))));
|
||||
if (PhysicsServer3D::BODY_MODE_CHARACTER == mode) {
|
||||
/// When character angular is always locked
|
||||
btBody->setAngularFactor(btVector3(0., 0., 0.));
|
||||
} else {
|
||||
btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z))));
|
||||
btBody->setAngularFactor(btVector3(btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,13 +89,13 @@ private:
|
|||
|
||||
public:
|
||||
virtual Vector3 get_total_gravity() const override;
|
||||
virtual float get_total_angular_damp() const override;
|
||||
virtual float get_total_linear_damp() const override;
|
||||
virtual real_t get_total_angular_damp() const override;
|
||||
virtual real_t get_total_linear_damp() const override;
|
||||
|
||||
virtual Vector3 get_center_of_mass() const override;
|
||||
virtual Basis get_principal_inertia_axes() const override;
|
||||
// get the mass
|
||||
virtual float get_inverse_mass() const override;
|
||||
virtual real_t get_inverse_mass() const override;
|
||||
// get density of this body space
|
||||
virtual Vector3 get_inverse_inertia() const override;
|
||||
// get density of this body space
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
|
||||
virtual Vector3 get_contact_local_position(int p_contact_idx) const override;
|
||||
virtual Vector3 get_contact_local_normal(int p_contact_idx) const override;
|
||||
virtual float get_contact_impulse(int p_contact_idx) const override;
|
||||
virtual real_t get_contact_impulse(int p_contact_idx) const override;
|
||||
virtual int get_contact_local_shape(int p_contact_idx) const override;
|
||||
|
||||
virtual RID get_contact_collider(int p_contact_idx) const override;
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
Vector3 hitLocalLocation;
|
||||
Vector3 hitWorldLocation;
|
||||
Vector3 hitNormal;
|
||||
float appliedImpulse;
|
||||
real_t appliedImpulse;
|
||||
};
|
||||
|
||||
struct ForceIntegrationCallback {
|
||||
|
@ -264,7 +264,7 @@ public:
|
|||
}
|
||||
|
||||
bool can_add_collision() { return collisionsCount < maxCollisionsDetection; }
|
||||
bool add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const float &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index);
|
||||
bool add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const real_t &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index);
|
||||
bool was_colliding(RigidBodyBullet *p_other_object);
|
||||
|
||||
void set_activation_state(bool p_active);
|
||||
|
|
|
@ -480,7 +480,11 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
|
|||
Vector<real_t> l_heights;
|
||||
Variant l_heights_v = d["heights"];
|
||||
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
if (l_heights_v.get_type() == Variant::PACKED_FLOAT64_ARRAY) {
|
||||
#else
|
||||
if (l_heights_v.get_type() == Variant::PACKED_FLOAT32_ARRAY) {
|
||||
#endif
|
||||
// Ready-to-use heights can be passed
|
||||
|
||||
l_heights = l_heights_v;
|
||||
|
@ -503,7 +507,7 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
|
|||
|
||||
real_t *w = l_heights.ptrw();
|
||||
const uint8_t *r = im_data.ptr();
|
||||
float *rp = (float *)r;
|
||||
real_t *rp = (real_t *)r;
|
||||
// At this point, `rp` could be used directly for Bullet, but I don't know how safe it would be.
|
||||
|
||||
for (int i = 0; i < l_heights.size(); ++i) {
|
||||
|
@ -511,7 +515,11 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
|
|||
}
|
||||
|
||||
} else {
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
ERR_FAIL_MSG("Expected PackedFloat64Array or float Image.");
|
||||
#else
|
||||
ERR_FAIL_MSG("Expected PackedFloat32Array or float Image.");
|
||||
#endif
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(l_width <= 0);
|
||||
|
|
|
@ -117,7 +117,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V
|
|||
}
|
||||
}
|
||||
|
||||
int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
if (p_result_max <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
|
|||
return btQuery.m_count;
|
||||
}
|
||||
|
||||
bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
|
||||
bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &r_closest_safe, real_t &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
|
||||
r_closest_safe = 0.0f;
|
||||
r_closest_unsafe = 0.0f;
|
||||
btVector3 bt_motion;
|
||||
|
@ -214,7 +214,7 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
|
|||
}
|
||||
|
||||
/// Returns the list of contacts pairs in this order: Local contact, other body contact
|
||||
bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
if (p_result_max <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
|
|||
return btQuery.m_count;
|
||||
}
|
||||
|
||||
bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
|
||||
ERR_FAIL_COND_V(!shape, false);
|
||||
|
||||
|
@ -841,7 +841,7 @@ void SpaceBullet::check_body_collision() {
|
|||
Vector3 collisionWorldPosition;
|
||||
Vector3 collisionLocalPosition;
|
||||
Vector3 normalOnB;
|
||||
float appliedImpulse = pt.m_appliedImpulse;
|
||||
real_t appliedImpulse = pt.m_appliedImpulse;
|
||||
B_TO_G(pt.m_normalWorldOnB, normalOnB);
|
||||
|
||||
// The pt.m_index only contains the shape index when more than one collision shape is used
|
||||
|
@ -1062,7 +1062,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
|
|||
return has_penetration;
|
||||
}
|
||||
|
||||
int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin) {
|
||||
int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin) {
|
||||
btTransform body_transform;
|
||||
G_TO_B(p_transform, body_transform);
|
||||
UNSCALE_BT_BASIS(body_transform);
|
||||
|
|
|
@ -78,11 +78,11 @@ public:
|
|||
|
||||
virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
|
||||
virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false) override;
|
||||
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
|
||||
virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) override;
|
||||
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
|
||||
virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &r_closest_safe, real_t &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) override;
|
||||
/// Returns the list of contacts pairs in this order: Local contact, other body contact
|
||||
virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
|
||||
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
|
||||
virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
|
||||
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override;
|
||||
virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const override;
|
||||
};
|
||||
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
real_t get_angular_damp() const { return angular_damp; }
|
||||
|
||||
bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes);
|
||||
int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin);
|
||||
int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin);
|
||||
|
||||
private:
|
||||
void create_empty_world(bool p_create_soft_world);
|
||||
|
|
|
@ -61,7 +61,7 @@ private:
|
|||
Variant metadata;
|
||||
bool disabled;
|
||||
bool one_way_collision;
|
||||
float one_way_collision_margin;
|
||||
real_t one_way_collision_margin;
|
||||
Shape() {
|
||||
disabled = false;
|
||||
one_way_collision = false;
|
||||
|
@ -153,7 +153,7 @@ public:
|
|||
return shapes[p_idx].disabled;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_shape_as_one_way_collision(int p_idx, bool p_one_way_collision, float p_margin) {
|
||||
_FORCE_INLINE_ void set_shape_as_one_way_collision(int p_idx, bool p_one_way_collision, real_t p_margin) {
|
||||
CRASH_BAD_INDEX(p_idx, shapes.size());
|
||||
shapes.write[p_idx].one_way_collision = p_one_way_collision;
|
||||
shapes.write[p_idx].one_way_collision_margin = p_margin;
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
return shapes[p_idx].one_way_collision;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ float get_shape_one_way_collision_margin(int p_idx) const {
|
||||
_FORCE_INLINE_ real_t get_shape_one_way_collision_margin(int p_idx) const {
|
||||
CRASH_BAD_INDEX(p_idx, shapes.size());
|
||||
return shapes[p_idx].one_way_collision_margin;
|
||||
}
|
||||
|
|
|
@ -667,7 +667,7 @@ void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
|
|||
body->set_shape_as_disabled(p_shape_idx, p_disabled);
|
||||
}
|
||||
|
||||
void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) {
|
||||
void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, real_t p_margin) {
|
||||
Body2DSW *body = body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
|
||||
|
@ -958,7 +958,7 @@ bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from,
|
|||
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes);
|
||||
}
|
||||
|
||||
int PhysicsServer2DSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
|
||||
int PhysicsServer2DSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin) {
|
||||
Body2DSW *body = body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, false);
|
||||
ERR_FAIL_COND_V(!body->get_space(), false);
|
||||
|
|
|
@ -191,7 +191,7 @@ public:
|
|||
virtual void body_clear_shapes(RID p_body) override;
|
||||
|
||||
virtual void body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) override;
|
||||
virtual void body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) override;
|
||||
virtual void body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, real_t p_margin) override;
|
||||
|
||||
virtual void body_attach_object_instance_id(RID p_body, ObjectID p_id) override;
|
||||
virtual ObjectID body_get_object_instance_id(RID p_body) const override;
|
||||
|
@ -248,7 +248,7 @@ public:
|
|||
virtual void body_set_pickable(RID p_body, bool p_pickable) override;
|
||||
|
||||
virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.001, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) override;
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001) override;
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) override;
|
||||
|
||||
// this function only works on physics process, errors and returns null otherwise
|
||||
virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) override;
|
||||
|
|
|
@ -189,7 +189,7 @@ public:
|
|||
FUNC2RC(RID, body_get_shape, RID, int);
|
||||
|
||||
FUNC3(body_set_shape_disabled, RID, int, bool);
|
||||
FUNC4(body_set_shape_as_one_way_collision, RID, int, bool, float);
|
||||
FUNC4(body_set_shape_as_one_way_collision, RID, int, bool, real_t);
|
||||
|
||||
FUNC2(body_remove_shape, RID, int);
|
||||
FUNC1(body_clear_shapes, RID);
|
||||
|
@ -255,7 +255,7 @@ public:
|
|||
return physics_2d_server->body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes);
|
||||
}
|
||||
|
||||
int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001) {
|
||||
int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) {
|
||||
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
|
||||
return physics_2d_server->body_test_ray_separation(p_body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin);
|
||||
}
|
||||
|
|
|
@ -339,10 +339,10 @@ void RectangleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_suppor
|
|||
}
|
||||
|
||||
bool RectangleShape2DSW::contains_point(const Vector2 &p_point) const {
|
||||
float x = p_point.x;
|
||||
float y = p_point.y;
|
||||
float edge_x = half_extents.x;
|
||||
float edge_y = half_extents.y;
|
||||
real_t x = p_point.x;
|
||||
real_t y = p_point.y;
|
||||
real_t edge_x = half_extents.x;
|
||||
real_t edge_y = half_extents.y;
|
||||
return (x >= -edge_x) && (x < edge_x) && (y >= -edge_y) && (y < edge_y);
|
||||
}
|
||||
|
||||
|
@ -590,7 +590,11 @@ real_t ConvexPolygonShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2
|
|||
}
|
||||
|
||||
void ConvexPolygonShape2DSW::set_data(const Variant &p_data) {
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT64_ARRAY);
|
||||
#else
|
||||
ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT32_ARRAY);
|
||||
#endif
|
||||
|
||||
if (points) {
|
||||
memdelete_arr(points);
|
||||
|
@ -829,7 +833,11 @@ int ConcavePolygonShape2DSW::_generate_bvh(BVH *p_bvh, int p_len, int p_depth) {
|
|||
}
|
||||
|
||||
void ConcavePolygonShape2DSW::set_data(const Variant &p_data) {
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT64_ARRAY);
|
||||
#else
|
||||
ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT32_ARRAY);
|
||||
#endif
|
||||
|
||||
Rect2 aabb;
|
||||
|
||||
|
|
|
@ -644,7 +644,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
|
|||
|
||||
recover_motion += (b - a) / cbk.amount;
|
||||
|
||||
float depth = a.distance_to(b);
|
||||
real_t depth = a.distance_to(b);
|
||||
if (depth > result.collision_depth) {
|
||||
result.collision_depth = depth;
|
||||
result.collision_point = b;
|
||||
|
@ -739,7 +739,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
|
|||
ExcludedShapeSW excluded_shape_pairs[max_excluded_shape_pairs];
|
||||
int excluded_shape_pair_count = 0;
|
||||
|
||||
float separation_margin = MIN(p_margin, MAX(0.0, p_motion.length() - CMP_EPSILON)); //don't separate by more than the intended motion
|
||||
real_t separation_margin = MIN(p_margin, MAX(0.0, p_motion.length() - CMP_EPSILON)); //don't separate by more than the intended motion
|
||||
|
||||
Transform2D body_transform = p_from;
|
||||
|
||||
|
@ -793,7 +793,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
|
|||
if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) {
|
||||
cbk.valid_dir = col_obj_shape_xform.get_axis(1).normalized();
|
||||
|
||||
float owc_margin = col_obj->get_shape_one_way_collision_margin(shape_idx);
|
||||
real_t owc_margin = col_obj->get_shape_one_way_collision_margin(shape_idx);
|
||||
cbk.valid_depth = MAX(owc_margin, p_margin); //user specified, but never less than actual margin or it won't work
|
||||
cbk.invalid_by_dir = 0;
|
||||
|
||||
|
@ -804,7 +804,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
|
|||
Vector2 lv = b->get_linear_velocity();
|
||||
//compute displacement from linear velocity
|
||||
Vector2 motion = lv * PhysicsDirectBodyState2DSW::singleton->step;
|
||||
float motion_len = motion.length();
|
||||
real_t motion_len = motion.length();
|
||||
motion.normalize();
|
||||
cbk.valid_depth += motion_len * MAX(motion.dot(-cbk.valid_dir), 0.0);
|
||||
}
|
||||
|
|
|
@ -426,7 +426,7 @@ public:
|
|||
ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Vector3());
|
||||
return body->contacts[p_contact_idx].local_normal;
|
||||
}
|
||||
virtual float get_contact_impulse(int p_contact_idx) const override {
|
||||
virtual real_t get_contact_impulse(int p_contact_idx) const override {
|
||||
return 0.0f; // Only implemented for bullet
|
||||
}
|
||||
virtual int get_contact_local_shape(int p_contact_idx) const override {
|
||||
|
|
|
@ -874,7 +874,7 @@ bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform &p_from, co
|
|||
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, body->get_kinematic_margin(), r_result, p_exclude_raycast_shapes);
|
||||
}
|
||||
|
||||
int PhysicsServer3DSW::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
|
||||
int PhysicsServer3DSW::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin) {
|
||||
Body3DSW *body = body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, false);
|
||||
ERR_FAIL_COND_V(!body->get_space(), false);
|
||||
|
|
|
@ -235,7 +235,7 @@ public:
|
|||
virtual bool body_is_ray_pickable(RID p_body) const override;
|
||||
|
||||
virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) override;
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001) override;
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) override;
|
||||
|
||||
// this function only works on physics process, errors and returns null otherwise
|
||||
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override;
|
||||
|
|
|
@ -261,7 +261,7 @@ bool SphereShape3DSW::intersect_point(const Vector3 &p_point) const {
|
|||
|
||||
Vector3 SphereShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
|
||||
Vector3 p = p_point;
|
||||
float l = p.length();
|
||||
real_t l = p.length();
|
||||
if (l < radius) {
|
||||
return p_point;
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
|
|||
}
|
||||
|
||||
//check segments
|
||||
float min_distance = 1e20;
|
||||
real_t min_distance = 1e20;
|
||||
Vector3 closest_vertex = half_extents * p_point.sign();
|
||||
Vector3 s[2] = {
|
||||
closest_vertex,
|
||||
|
@ -442,7 +442,7 @@ Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
|
|||
|
||||
Vector3 closest_edge = Geometry3D::get_closest_point_to_segment(p_point, s);
|
||||
|
||||
float d = p_point.distance_to(closest_edge);
|
||||
real_t d = p_point.distance_to(closest_edge);
|
||||
if (d < min_distance) {
|
||||
min_point = closest_edge;
|
||||
min_distance = d;
|
||||
|
@ -839,7 +839,7 @@ Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) con
|
|||
return p_point;
|
||||
}
|
||||
|
||||
float min_distance = 1e20;
|
||||
real_t min_distance = 1e20;
|
||||
Vector3 min_point;
|
||||
|
||||
//check edges
|
||||
|
@ -852,7 +852,7 @@ Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) con
|
|||
};
|
||||
|
||||
Vector3 closest = Geometry3D::get_closest_point_to_segment(p_point, s);
|
||||
float d = closest.distance_to(p_point);
|
||||
real_t d = closest.distance_to(p_point);
|
||||
if (d < min_distance) {
|
||||
min_distance = d;
|
||||
min_point = closest;
|
||||
|
|
|
@ -476,7 +476,7 @@ Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_ob
|
|||
|
||||
ERR_FAIL_COND_V(obj->get_space() != space, Vector3());
|
||||
|
||||
float min_distance = 1e20;
|
||||
real_t min_distance = 1e20;
|
||||
Vector3 min_point;
|
||||
|
||||
bool shapes_found = false;
|
||||
|
@ -492,7 +492,7 @@ Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_ob
|
|||
Vector3 point = shape->get_closest_point_to(shape_xform.affine_inverse().xform(p_point));
|
||||
point = shape_xform.xform(point);
|
||||
|
||||
float dist = point.distance_to(p_point);
|
||||
real_t dist = point.distance_to(p_point);
|
||||
if (dist < min_distance) {
|
||||
min_distance = dist;
|
||||
min_point = point;
|
||||
|
@ -651,7 +651,7 @@ int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_tra
|
|||
|
||||
recover_motion += (b - a) / cbk.amount;
|
||||
|
||||
float depth = a.distance_to(b);
|
||||
real_t depth = a.distance_to(b);
|
||||
if (depth > result.collision_depth) {
|
||||
result.collision_depth = depth;
|
||||
result.collision_point = b;
|
||||
|
|
|
@ -42,7 +42,7 @@ void PhysicsDirectBodyState2D::integrate_forces() {
|
|||
|
||||
real_t av = get_angular_velocity();
|
||||
|
||||
float damp = 1.0 - step * get_total_linear_damp();
|
||||
real_t damp = 1.0 - step * get_total_linear_damp();
|
||||
|
||||
if (damp < 0) { // reached zero in the given time
|
||||
damp = 0;
|
||||
|
@ -168,11 +168,11 @@ Vector2 PhysicsShapeQueryParameters2D::get_motion() const {
|
|||
return motion;
|
||||
}
|
||||
|
||||
void PhysicsShapeQueryParameters2D::set_margin(float p_margin) {
|
||||
void PhysicsShapeQueryParameters2D::set_margin(real_t p_margin) {
|
||||
margin = p_margin;
|
||||
}
|
||||
|
||||
float PhysicsShapeQueryParameters2D::get_margin() const {
|
||||
real_t PhysicsShapeQueryParameters2D::get_margin() const {
|
||||
return margin;
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryPar
|
|||
Array PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
|
||||
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
|
||||
|
||||
float closest_safe, closest_unsafe;
|
||||
real_t closest_safe, closest_unsafe;
|
||||
bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
|
||||
if (!res) {
|
||||
return Array();
|
||||
|
@ -517,7 +517,7 @@ PhysicsTestMotionResult2D::PhysicsTestMotionResult2D() {
|
|||
|
||||
///////////////////////////////////////
|
||||
|
||||
bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
|
||||
bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
|
||||
MotionResult *r = nullptr;
|
||||
if (p_result.is_valid()) {
|
||||
r = p_result->get_result_ptr();
|
||||
|
|
|
@ -45,10 +45,10 @@ protected:
|
|||
|
||||
public:
|
||||
virtual Vector2 get_total_gravity() const = 0; // get gravity vector working on this body space/area
|
||||
virtual float get_total_linear_damp() const = 0; // get density of this body space/area
|
||||
virtual float get_total_angular_damp() const = 0; // get density of this body space/area
|
||||
virtual real_t get_total_linear_damp() const = 0; // get density of this body space/area
|
||||
virtual real_t get_total_angular_damp() const = 0; // get density of this body space/area
|
||||
|
||||
virtual float get_inverse_mass() const = 0; // get the mass
|
||||
virtual real_t get_inverse_mass() const = 0; // get the mass
|
||||
virtual real_t get_inverse_inertia() const = 0; // get density of this body space
|
||||
|
||||
virtual void set_linear_velocity(const Vector2 &p_velocity) = 0;
|
||||
|
@ -103,7 +103,7 @@ class PhysicsShapeQueryParameters2D : public Reference {
|
|||
RID shape;
|
||||
Transform2D transform;
|
||||
Vector2 motion;
|
||||
float margin;
|
||||
real_t margin;
|
||||
Set<RID> exclude;
|
||||
uint32_t collision_mask;
|
||||
|
||||
|
@ -125,8 +125,8 @@ public:
|
|||
void set_motion(const Vector2 &p_motion);
|
||||
Vector2 get_motion() const;
|
||||
|
||||
void set_margin(float p_margin);
|
||||
float get_margin() const;
|
||||
void set_margin(real_t p_margin);
|
||||
real_t get_margin() const;
|
||||
|
||||
void set_collision_mask(int p_collision_mask);
|
||||
int get_collision_mask() const;
|
||||
|
@ -182,11 +182,11 @@ public:
|
|||
virtual int intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_point = false) = 0;
|
||||
virtual int intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_instance_id, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_point = false) = 0;
|
||||
|
||||
virtual int intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
virtual int intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
|
||||
virtual bool cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, float p_margin, float &p_closest_safe, float &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
virtual bool cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
|
||||
virtual bool collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, float p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
virtual bool collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
|
||||
struct ShapeRestInfo {
|
||||
Vector2 point;
|
||||
|
@ -198,7 +198,7 @@ public:
|
|||
Variant metadata;
|
||||
};
|
||||
|
||||
virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
|
||||
PhysicsDirectSpaceState2D();
|
||||
};
|
||||
|
@ -230,7 +230,7 @@ class PhysicsServer2D : public Object {
|
|||
|
||||
static PhysicsServer2D *singleton;
|
||||
|
||||
virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
|
||||
virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -393,7 +393,7 @@ public:
|
|||
virtual Variant body_get_shape_metadata(RID p_body, int p_shape_idx) const = 0;
|
||||
|
||||
virtual void body_set_shape_disabled(RID p_body, int p_shape, bool p_disabled) = 0;
|
||||
virtual void body_set_shape_as_one_way_collision(RID p_body, int p_shape, bool p_enabled, float p_margin = 0) = 0;
|
||||
virtual void body_set_shape_as_one_way_collision(RID p_body, int p_shape, bool p_enabled, real_t p_margin = 0) = 0;
|
||||
|
||||
virtual void body_remove_shape(RID p_body, int p_shape_idx) = 0;
|
||||
virtual void body_clear_shapes(RID p_body) = 0;
|
||||
|
@ -431,8 +431,8 @@ public:
|
|||
BODY_PARAM_MAX,
|
||||
};
|
||||
|
||||
virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value) = 0;
|
||||
virtual float body_get_param(RID p_body, BodyParameter p_param) const = 0;
|
||||
virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value) = 0;
|
||||
virtual real_t body_get_param(RID p_body, BodyParameter p_param) const = 0;
|
||||
|
||||
//state
|
||||
enum BodyState {
|
||||
|
@ -450,15 +450,15 @@ public:
|
|||
virtual void body_set_applied_force(RID p_body, const Vector2 &p_force) = 0;
|
||||
virtual Vector2 body_get_applied_force(RID p_body) const = 0;
|
||||
|
||||
virtual void body_set_applied_torque(RID p_body, float p_torque) = 0;
|
||||
virtual float body_get_applied_torque(RID p_body) const = 0;
|
||||
virtual void body_set_applied_torque(RID p_body, real_t p_torque) = 0;
|
||||
virtual real_t body_get_applied_torque(RID p_body) const = 0;
|
||||
|
||||
virtual void body_add_central_force(RID p_body, const Vector2 &p_force) = 0;
|
||||
virtual void body_add_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position = Vector2()) = 0;
|
||||
virtual void body_add_torque(RID p_body, float p_torque) = 0;
|
||||
virtual void body_add_torque(RID p_body, real_t p_torque) = 0;
|
||||
|
||||
virtual void body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) = 0;
|
||||
virtual void body_apply_torque_impulse(RID p_body, float p_torque) = 0;
|
||||
virtual void body_apply_torque_impulse(RID p_body, real_t p_torque) = 0;
|
||||
virtual void body_apply_impulse(RID p_body, const Vector2 &p_impulse, const Vector2 &p_position = Vector2()) = 0;
|
||||
virtual void body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) = 0;
|
||||
|
||||
|
@ -471,8 +471,8 @@ public:
|
|||
virtual int body_get_max_contacts_reported(RID p_body) const = 0;
|
||||
|
||||
//missing remove
|
||||
virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) = 0;
|
||||
virtual float body_get_contacts_reported_depth_threshold(RID p_body) const = 0;
|
||||
virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) = 0;
|
||||
virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const = 0;
|
||||
|
||||
virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0;
|
||||
virtual bool body_is_omitting_force_integration(RID p_body) const = 0;
|
||||
|
@ -506,10 +506,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.001, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) = 0;
|
||||
virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.001, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) = 0;
|
||||
|
||||
struct SeparationResult {
|
||||
float collision_depth;
|
||||
real_t collision_depth;
|
||||
Vector2 collision_point;
|
||||
Vector2 collision_normal;
|
||||
Vector2 collider_velocity;
|
||||
|
@ -520,7 +520,7 @@ public:
|
|||
Variant collider_metadata;
|
||||
};
|
||||
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001) = 0;
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) = 0;
|
||||
|
||||
/* JOINT API */
|
||||
|
||||
|
@ -576,7 +576,7 @@ public:
|
|||
|
||||
virtual void set_active(bool p_active) = 0;
|
||||
virtual void init() = 0;
|
||||
virtual void step(float p_step) = 0;
|
||||
virtual void step(real_t p_step) = 0;
|
||||
virtual void sync() = 0;
|
||||
virtual void flush_queries() = 0;
|
||||
virtual void end_sync() = 0;
|
||||
|
|
|
@ -42,13 +42,13 @@ void PhysicsDirectBodyState3D::integrate_forces() {
|
|||
|
||||
Vector3 av = get_angular_velocity();
|
||||
|
||||
float linear_damp = 1.0 - step * get_total_linear_damp();
|
||||
real_t linear_damp = 1.0 - step * get_total_linear_damp();
|
||||
|
||||
if (linear_damp < 0) { // reached zero in the given time
|
||||
linear_damp = 0;
|
||||
}
|
||||
|
||||
float angular_damp = 1.0 - step * get_total_angular_damp();
|
||||
real_t angular_damp = 1.0 - step * get_total_angular_damp();
|
||||
|
||||
if (angular_damp < 0) { // reached zero in the given time
|
||||
angular_damp = 0;
|
||||
|
@ -164,11 +164,11 @@ Transform PhysicsShapeQueryParameters3D::get_transform() const {
|
|||
return transform;
|
||||
}
|
||||
|
||||
void PhysicsShapeQueryParameters3D::set_margin(float p_margin) {
|
||||
void PhysicsShapeQueryParameters3D::set_margin(real_t p_margin) {
|
||||
margin = p_margin;
|
||||
}
|
||||
|
||||
float PhysicsShapeQueryParameters3D::get_margin() const {
|
||||
real_t PhysicsShapeQueryParameters3D::get_margin() const {
|
||||
return margin;
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryPar
|
|||
Array PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, const Vector3 &p_motion) {
|
||||
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
|
||||
|
||||
float closest_safe = 1.0f, closest_unsafe = 1.0f;
|
||||
real_t closest_safe = 1.0f, closest_unsafe = 1.0f;
|
||||
bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
|
||||
if (!res) {
|
||||
return Array();
|
||||
|
|
|
@ -44,12 +44,12 @@ protected:
|
|||
|
||||
public:
|
||||
virtual Vector3 get_total_gravity() const = 0;
|
||||
virtual float get_total_angular_damp() const = 0;
|
||||
virtual float get_total_linear_damp() const = 0;
|
||||
virtual real_t get_total_angular_damp() const = 0;
|
||||
virtual real_t get_total_linear_damp() const = 0;
|
||||
|
||||
virtual Vector3 get_center_of_mass() const = 0;
|
||||
virtual Basis get_principal_inertia_axes() const = 0;
|
||||
virtual float get_inverse_mass() const = 0; // get the mass
|
||||
virtual real_t get_inverse_mass() const = 0; // get the mass
|
||||
virtual Vector3 get_inverse_inertia() const = 0; // get density of this body space
|
||||
virtual Basis get_inverse_inertia_tensor() const = 0; // get density of this body space
|
||||
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
virtual Vector3 get_contact_local_position(int p_contact_idx) const = 0;
|
||||
virtual Vector3 get_contact_local_normal(int p_contact_idx) const = 0;
|
||||
virtual float get_contact_impulse(int p_contact_idx) const = 0;
|
||||
virtual real_t get_contact_impulse(int p_contact_idx) const = 0;
|
||||
virtual int get_contact_local_shape(int p_contact_idx) const = 0;
|
||||
|
||||
virtual RID get_contact_collider(int p_contact_idx) const = 0;
|
||||
|
@ -103,7 +103,7 @@ class PhysicsShapeQueryParameters3D : public Reference {
|
|||
RES shape_ref;
|
||||
RID shape;
|
||||
Transform transform;
|
||||
float margin;
|
||||
real_t margin;
|
||||
Set<RID> exclude;
|
||||
uint32_t collision_mask;
|
||||
|
||||
|
@ -122,8 +122,8 @@ public:
|
|||
void set_transform(const Transform &p_transform);
|
||||
Transform get_transform() const;
|
||||
|
||||
void set_margin(float p_margin);
|
||||
float get_margin() const;
|
||||
void set_margin(real_t p_margin);
|
||||
real_t get_margin() const;
|
||||
|
||||
void set_collision_mask(int p_collision_mask);
|
||||
int get_collision_mask() const;
|
||||
|
@ -174,7 +174,7 @@ public:
|
|||
|
||||
virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false) = 0;
|
||||
|
||||
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
|
||||
struct ShapeRestInfo {
|
||||
Vector3 point;
|
||||
|
@ -185,11 +185,11 @@ public:
|
|||
Vector3 linear_velocity; //velocity at contact point
|
||||
};
|
||||
|
||||
virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &p_closest_safe, float &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) = 0;
|
||||
virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) = 0;
|
||||
|
||||
virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
|
||||
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
|
||||
|
||||
virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const = 0;
|
||||
|
||||
|
@ -404,8 +404,8 @@ public:
|
|||
BODY_PARAM_MAX,
|
||||
};
|
||||
|
||||
virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value) = 0;
|
||||
virtual float body_get_param(RID p_body, BodyParameter p_param) const = 0;
|
||||
virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value) = 0;
|
||||
virtual real_t body_get_param(RID p_body, BodyParameter p_param) const = 0;
|
||||
|
||||
virtual void body_set_kinematic_safe_margin(RID p_body, real_t p_margin) = 0;
|
||||
virtual real_t body_get_kinematic_safe_margin(RID p_body) const = 0;
|
||||
|
@ -459,8 +459,8 @@ public:
|
|||
virtual int body_get_max_contacts_reported(RID p_body) const = 0;
|
||||
|
||||
//missing remove
|
||||
virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) = 0;
|
||||
virtual float body_get_contacts_reported_depth_threshold(RID p_body) const = 0;
|
||||
virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) = 0;
|
||||
virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const = 0;
|
||||
|
||||
virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0;
|
||||
virtual bool body_is_omitting_force_integration(RID p_body) const = 0;
|
||||
|
@ -495,7 +495,7 @@ public:
|
|||
virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) = 0;
|
||||
|
||||
struct SeparationResult {
|
||||
float collision_depth;
|
||||
real_t collision_depth;
|
||||
Vector3 collision_point;
|
||||
Vector3 collision_normal;
|
||||
Vector3 collider_velocity;
|
||||
|
@ -506,7 +506,7 @@ public:
|
|||
Variant collider_metadata;
|
||||
};
|
||||
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001) = 0;
|
||||
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) = 0;
|
||||
|
||||
/* SOFT BODY */
|
||||
|
||||
|
@ -601,8 +601,8 @@ public:
|
|||
PIN_JOINT_IMPULSE_CLAMP
|
||||
};
|
||||
|
||||
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) = 0;
|
||||
virtual float pin_joint_get_param(RID p_joint, PinJointParam p_param) const = 0;
|
||||
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) = 0;
|
||||
virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const = 0;
|
||||
|
||||
virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) = 0;
|
||||
virtual Vector3 pin_joint_get_local_a(RID p_joint) const = 0;
|
||||
|
@ -631,8 +631,8 @@ public:
|
|||
virtual RID joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) = 0;
|
||||
virtual RID joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) = 0;
|
||||
|
||||
virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) = 0;
|
||||
virtual float hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const = 0;
|
||||
virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) = 0;
|
||||
virtual real_t hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const = 0;
|
||||
|
||||
virtual void hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) = 0;
|
||||
virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const = 0;
|
||||
|
@ -667,8 +667,8 @@ public:
|
|||
|
||||
virtual RID joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) = 0; //reference frame is A
|
||||
|
||||
virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) = 0;
|
||||
virtual float slider_joint_get_param(RID p_joint, SliderJointParam p_param) const = 0;
|
||||
virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) = 0;
|
||||
virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const = 0;
|
||||
|
||||
enum ConeTwistJointParam {
|
||||
CONE_TWIST_JOINT_SWING_SPAN,
|
||||
|
@ -681,8 +681,8 @@ public:
|
|||
|
||||
virtual RID joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) = 0; //reference frame is A
|
||||
|
||||
virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) = 0;
|
||||
virtual float cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const = 0;
|
||||
virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) = 0;
|
||||
virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const = 0;
|
||||
|
||||
enum G6DOFJointAxisParam {
|
||||
G6DOF_JOINT_LINEAR_LOWER_LIMIT,
|
||||
|
@ -722,8 +722,8 @@ public:
|
|||
|
||||
virtual RID joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) = 0; //reference frame is A
|
||||
|
||||
virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param, float p_value) = 0;
|
||||
virtual float generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param) = 0;
|
||||
virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param, real_t p_value) = 0;
|
||||
virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param) = 0;
|
||||
|
||||
virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag, bool p_enable) = 0;
|
||||
virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag) = 0;
|
||||
|
@ -741,7 +741,7 @@ public:
|
|||
|
||||
virtual void set_active(bool p_active) = 0;
|
||||
virtual void init() = 0;
|
||||
virtual void step(float p_step) = 0;
|
||||
virtual void step(real_t p_step) = 0;
|
||||
virtual void flush_queries() = 0;
|
||||
virtual void finish() = 0;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class TestPhysics3DMainLoop : public MainLoop {
|
|||
|
||||
RID character;
|
||||
|
||||
float ofs_x, ofs_y;
|
||||
real_t ofs_x, ofs_y;
|
||||
|
||||
Point2 joy_direction;
|
||||
|
||||
|
@ -115,7 +115,7 @@ protected:
|
|||
return b;
|
||||
}
|
||||
|
||||
void configure_body(RID p_body, float p_mass, float p_friction, float p_bounce) {
|
||||
void configure_body(RID p_body, real_t p_mass, real_t p_friction, real_t p_bounce) {
|
||||
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
|
||||
ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_MASS, p_mass);
|
||||
ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_FRICTION, p_friction);
|
||||
|
@ -211,8 +211,8 @@ protected:
|
|||
vs->instance_set_transform(triins, tritrans);
|
||||
}
|
||||
|
||||
void make_grid(int p_width, int p_height, float p_cellsize, float p_cellheight, const Transform &p_xform = Transform()) {
|
||||
Vector<Vector<float>> grid;
|
||||
void make_grid(int p_width, int p_height, real_t p_cellsize, real_t p_cellheight, const Transform &p_xform = Transform()) {
|
||||
Vector<Vector<real_t>> grid;
|
||||
|
||||
grid.resize(p_width);
|
||||
|
||||
|
@ -253,8 +253,8 @@ public:
|
|||
}
|
||||
|
||||
if (mm.is_valid() && mm->get_button_mask() & 1) {
|
||||
float y = -mm->get_relative().y / 20.0;
|
||||
float x = mm->get_relative().x / 20.0;
|
||||
real_t y = -mm->get_relative().y / 20.0;
|
||||
real_t x = mm->get_relative().x / 20.0;
|
||||
|
||||
if (mover.is_valid()) {
|
||||
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
|
||||
|
@ -312,7 +312,7 @@ public:
|
|||
}
|
||||
virtual bool physics_process(float p_time) override {
|
||||
if (mover.is_valid()) {
|
||||
static float joy_speed = 10;
|
||||
static real_t joy_speed = 10;
|
||||
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
|
||||
Transform t = ps->body_get_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM);
|
||||
t.origin += Vector3(joy_speed * joy_direction.x * p_time, -joy_speed * joy_direction.y * p_time, 0);
|
||||
|
|
Loading…
Reference in a new issue