summaryrefslogtreecommitdiff
path: root/servers/physics
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-02-26 20:10:54 +0100
committerGitHub <noreply@github.com>2017-02-26 20:10:54 +0100
commitf13e87e25799aafa4462779650c7d6222c782b31 (patch)
treeb28e5eed3cba37a72eabcf6eb849852275624a48 /servers/physics
parenta23e062c281292b75083c71a0a1deb03cb57c788 (diff)
parenteae94ba1c87718c95768f90cda95cf665c77a362 (diff)
Merge pull request #7802 from tagcup/physics_64bit
Use real_t as floating point type in physics code.
Diffstat (limited to 'servers/physics')
-rw-r--r--servers/physics/area_pair_sw.cpp8
-rw-r--r--servers/physics/area_pair_sw.h8
-rw-r--r--servers/physics/area_sw.h30
-rw-r--r--servers/physics/body_pair_sw.cpp18
-rw-r--r--servers/physics/body_pair_sw.h6
-rw-r--r--servers/physics/body_sw.cpp20
-rw-r--r--servers/physics/body_sw.h22
-rw-r--r--servers/physics/collision_solver_sat.cpp42
-rw-r--r--servers/physics/collision_solver_sat.h2
-rw-r--r--servers/physics/collision_solver_sw.cpp18
-rw-r--r--servers/physics/collision_solver_sw.h4
-rw-r--r--servers/physics/constraint_sw.h4
-rw-r--r--servers/physics/joints/cone_twist_joint_sw.cpp6
-rw-r--r--servers/physics/joints/cone_twist_joint_sw.h8
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.cpp56
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.h8
-rw-r--r--servers/physics/joints/hinge_joint_sw.cpp8
-rw-r--r--servers/physics/joints/hinge_joint_sw.h8
-rw-r--r--servers/physics/joints/pin_joint_sw.cpp8
-rw-r--r--servers/physics/joints/pin_joint_sw.h8
-rw-r--r--servers/physics/joints/slider_joint_sw.cpp6
-rw-r--r--servers/physics/joints/slider_joint_sw.h8
-rw-r--r--servers/physics/physics_server_sw.cpp36
-rw-r--r--servers/physics/physics_server_sw.h30
-rw-r--r--servers/physics/shape_sw.cpp106
-rw-r--r--servers/physics/shape_sw.h38
-rw-r--r--servers/physics/space_sw.cpp22
-rw-r--r--servers/physics/space_sw.h16
-rw-r--r--servers/physics/step_sw.cpp8
-rw-r--r--servers/physics/step_sw.h8
30 files changed, 261 insertions, 309 deletions
diff --git a/servers/physics/area_pair_sw.cpp b/servers/physics/area_pair_sw.cpp
index e95c85d751..3aa0816b06 100644
--- a/servers/physics/area_pair_sw.cpp
+++ b/servers/physics/area_pair_sw.cpp
@@ -30,7 +30,7 @@
#include "collision_solver_sw.h"
-bool AreaPairSW::setup(float p_step) {
+bool AreaPairSW::setup(real_t p_step) {
if (!area->test_collision_mask(body)) {
colliding = false;
@@ -64,7 +64,7 @@ bool AreaPairSW::setup(float p_step) {
return false; //never do any post solving
}
-void AreaPairSW::solve(float p_step) {
+void AreaPairSW::solve(real_t p_step) {
}
@@ -103,7 +103,7 @@ AreaPairSW::~AreaPairSW() {
-bool Area2PairSW::setup(float p_step) {
+bool Area2PairSW::setup(real_t p_step) {
if (!area_a->test_collision_mask(area_b)) {
colliding = false;
@@ -139,7 +139,7 @@ bool Area2PairSW::setup(float p_step) {
return false; //never do any post solving
}
-void Area2PairSW::solve(float p_step) {
+void Area2PairSW::solve(real_t p_step) {
}
diff --git a/servers/physics/area_pair_sw.h b/servers/physics/area_pair_sw.h
index 17477dcbd2..637976a095 100644
--- a/servers/physics/area_pair_sw.h
+++ b/servers/physics/area_pair_sw.h
@@ -42,8 +42,8 @@ class AreaPairSW : public ConstraintSW {
bool colliding;
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
AreaPairSW(BodySW *p_body,int p_body_shape, AreaSW *p_area,int p_area_shape);
~AreaPairSW();
@@ -59,8 +59,8 @@ class Area2PairSW : public ConstraintSW {
bool colliding;
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
Area2PairSW(AreaSW *p_area_a,int p_shape_a, AreaSW *p_area_b,int p_shape_b);
~Area2PairSW();
diff --git a/servers/physics/area_sw.h b/servers/physics/area_sw.h
index 5ac6985409..4e6f1c5a51 100644
--- a/servers/physics/area_sw.h
+++ b/servers/physics/area_sw.h
@@ -42,13 +42,13 @@ class AreaSW : public CollisionObjectSW{
PhysicsServer::AreaSpaceOverrideMode space_override_mode;
- float gravity;
+ real_t gravity;
Vector3 gravity_vector;
bool gravity_is_point;
- float gravity_distance_scale;
- float point_attenuation;
- float linear_damp;
- float angular_damp;
+ real_t gravity_distance_scale;
+ real_t point_attenuation;
+ real_t linear_damp;
+ real_t angular_damp;
int priority;
bool monitorable;
@@ -131,8 +131,8 @@ public:
void set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode);
PhysicsServer::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
- _FORCE_INLINE_ void set_gravity(float p_gravity) { gravity=p_gravity; }
- _FORCE_INLINE_ float get_gravity() const { return gravity; }
+ _FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity=p_gravity; }
+ _FORCE_INLINE_ real_t get_gravity() const { return gravity; }
_FORCE_INLINE_ void set_gravity_vector(const Vector3& p_gravity) { gravity_vector=p_gravity; }
_FORCE_INLINE_ Vector3 get_gravity_vector() const { return gravity_vector; }
@@ -140,17 +140,17 @@ public:
_FORCE_INLINE_ void set_gravity_as_point(bool p_enable) { gravity_is_point=p_enable; }
_FORCE_INLINE_ bool is_gravity_point() const { return gravity_is_point; }
- _FORCE_INLINE_ void set_gravity_distance_scale(float scale) { gravity_distance_scale=scale; }
- _FORCE_INLINE_ float get_gravity_distance_scale() const { return gravity_distance_scale; }
+ _FORCE_INLINE_ void set_gravity_distance_scale(real_t scale) { gravity_distance_scale=scale; }
+ _FORCE_INLINE_ real_t get_gravity_distance_scale() const { return gravity_distance_scale; }
- _FORCE_INLINE_ void set_point_attenuation(float p_point_attenuation) { point_attenuation=p_point_attenuation; }
- _FORCE_INLINE_ float get_point_attenuation() const { return point_attenuation; }
+ _FORCE_INLINE_ void set_point_attenuation(real_t p_point_attenuation) { point_attenuation=p_point_attenuation; }
+ _FORCE_INLINE_ real_t get_point_attenuation() const { return point_attenuation; }
- _FORCE_INLINE_ void set_linear_damp(float p_linear_damp) { linear_damp=p_linear_damp; }
- _FORCE_INLINE_ float get_linear_damp() const { return linear_damp; }
+ _FORCE_INLINE_ void set_linear_damp(real_t p_linear_damp) { linear_damp=p_linear_damp; }
+ _FORCE_INLINE_ real_t get_linear_damp() const { return linear_damp; }
- _FORCE_INLINE_ void set_angular_damp(float p_angular_damp) { angular_damp=p_angular_damp; }
- _FORCE_INLINE_ float get_angular_damp() const { return angular_damp; }
+ _FORCE_INLINE_ void set_angular_damp(real_t p_angular_damp) { angular_damp=p_angular_damp; }
+ _FORCE_INLINE_ real_t get_angular_damp() const { return angular_damp; }
_FORCE_INLINE_ void set_priority(int p_priority) { priority=p_priority; }
_FORCE_INLINE_ int get_priority() const { return priority; }
diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp
index 7defa87bb1..7fb3def387 100644
--- a/servers/physics/body_pair_sw.cpp
+++ b/servers/physics/body_pair_sw.cpp
@@ -105,7 +105,7 @@ void BodyPairSW::contact_added_callback(const Vector3& p_point_A,const Vector3&
// remove the contact with the minimum depth
int least_deep=-1;
- float min_depth=1e10;
+ real_t min_depth=1e10;
for (int i=0;i<=contact_count;i++) {
@@ -114,7 +114,7 @@ void BodyPairSW::contact_added_callback(const Vector3& p_point_A,const Vector3&
Vector3 global_B = B->get_transform().basis.xform(c.local_B)+offset_B;
Vector3 axis = global_A - global_B;
- float depth = axis.dot( c.normal );
+ real_t depth = axis.dot( c.normal );
if (depth<min_depth) {
@@ -154,7 +154,7 @@ void BodyPairSW::validate_contacts() {
Vector3 global_A = A->get_transform().basis.xform(c.local_A);
Vector3 global_B = B->get_transform().basis.xform(c.local_B)+offset_B;
Vector3 axis = global_A - global_B;
- float depth = axis.dot( c.normal );
+ real_t depth = axis.dot( c.normal );
if (depth < -contact_max_separation || (global_B + c.normal * depth - global_A).length() > contact_max_separation) {
// contact no longer needed, remove
@@ -173,7 +173,7 @@ void BodyPairSW::validate_contacts() {
}
-bool BodyPairSW::_test_ccd(float p_step,BodySW *p_A, int p_shape_A,const Transform& p_xform_A,BodySW *p_B, int p_shape_B,const Transform& p_xform_B) {
+bool BodyPairSW::_test_ccd(real_t p_step,BodySW *p_A, int p_shape_A,const Transform& p_xform_A,BodySW *p_B, int p_shape_B,const Transform& p_xform_B) {
@@ -211,14 +211,14 @@ bool BodyPairSW::_test_ccd(float p_step,BodySW *p_A, int p_shape_A,const Transfo
//shorten the linear velocity so it does not hit, but gets close enough, next frame will hit softly or soft enough
Vector3 hitpos = p_xform_B.xform(rpos);
- float newlen = hitpos.distance_to(from)-(max-min)*0.01;
+ real_t newlen = hitpos.distance_to(from)-(max-min)*0.01;
p_A->set_linear_velocity((mnormal*newlen)/p_step);
return true;
}
-bool BodyPairSW::setup(float p_step) {
+bool BodyPairSW::setup(real_t p_step) {
//cannot collide
if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode()<=PhysicsServer::BODY_MODE_KINEMATIC && B->get_mode()<=PhysicsServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported()==0 && B->get_max_contacts_reported()==0)) {
@@ -264,7 +264,7 @@ bool BodyPairSW::setup(float p_step) {
real_t max_penetration = space->get_contact_max_allowed_penetration();
- float bias = 0.3f;
+ real_t bias = (real_t)0.3;
if (shape_A_ptr->get_custom_bias() || shape_B_ptr->get_custom_bias()) {
@@ -356,7 +356,7 @@ bool BodyPairSW::setup(float p_step) {
if (depth > max_penetration) {
c.bias = (depth - max_penetration) * (1.0/(p_step*(1.0/RELAXATION_TIMESTEPS)));
} else {
- float approach = -0.1f * (depth - max_penetration) / (CMP_EPSILON + max_penetration);
+ real_t approach = -0.1 * (depth - max_penetration) / (CMP_EPSILON + max_penetration);
approach = CLAMP( approach, CMP_EPSILON, 1.0 );
c.bias = approach * (depth - max_penetration) * (1.0/p_step);
}
@@ -387,7 +387,7 @@ bool BodyPairSW::setup(float p_step) {
return true;
}
-void BodyPairSW::solve(float p_step) {
+void BodyPairSW::solve(real_t p_step) {
if (!collided)
return;
diff --git a/servers/physics/body_pair_sw.h b/servers/physics/body_pair_sw.h
index a37f75d13c..f282a56b9e 100644
--- a/servers/physics/body_pair_sw.h
+++ b/servers/physics/body_pair_sw.h
@@ -82,14 +82,14 @@ class BodyPairSW : public ConstraintSW {
void contact_added_callback(const Vector3& p_point_A,const Vector3& p_point_B);
void validate_contacts();
- bool _test_ccd(float p_step,BodySW *p_A, int p_shape_A,const Transform& p_xform_A,BodySW *p_B, int p_shape_B,const Transform& p_xform_B);
+ bool _test_ccd(real_t p_step,BodySW *p_A, int p_shape_A,const Transform& p_xform_A,BodySW *p_B, int p_shape_B,const Transform& p_xform_B);
SpaceSW *space;
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
BodyPairSW(BodySW *p_A, int p_shape_A,BodySW *p_B, int p_shape_B);
~BodyPairSW();
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index a67dda3a01..7fcd767268 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -59,7 +59,7 @@ void BodySW::update_inertias() {
case PhysicsServer::BODY_MODE_RIGID: {
//update tensor for all shapes, not the best way but should be somehow OK. (inspired from bullet)
- float total_area=0;
+ real_t total_area=0;
for (int i=0;i<get_shape_count();i++) {
@@ -70,9 +70,9 @@ void BodySW::update_inertias() {
center_of_mass_local.zero();
for (int i=0; i<get_shape_count(); i++) {
- float area=get_shape_area(i);
+ real_t area=get_shape_area(i);
- float mass = area * this->mass / total_area;
+ real_t mass = area * this->mass / total_area;
// NOTE: we assume that the shape origin is also its center of mass
center_of_mass_local += mass * get_shape_transform(i).origin;
@@ -88,9 +88,9 @@ void BodySW::update_inertias() {
const ShapeSW* shape=get_shape(i);
- float area=get_shape_area(i);
+ real_t area=get_shape_area(i);
- float mass = area * this->mass / total_area;
+ real_t mass = area * this->mass / total_area;
Basis shape_inertia_tensor=shape->get_moment_of_inertia(mass).to_diagonal_matrix();
Transform shape_transform=get_shape_transform(i);
@@ -170,7 +170,7 @@ void BodySW::set_active(bool p_active) {
-void BodySW::set_param(PhysicsServer::BodyParameter p_param, float p_value) {
+void BodySW::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) {
switch(p_param) {
case PhysicsServer::BODY_PARAM_BOUNCE: {
@@ -202,7 +202,7 @@ void BodySW::set_param(PhysicsServer::BodyParameter p_param, float p_value) {
}
}
-float BodySW::get_param(PhysicsServer::BodyParameter p_param) const {
+real_t BodySW::get_param(PhysicsServer::BodyParameter p_param) const {
switch(p_param) {
case PhysicsServer::BODY_PARAM_BOUNCE: {
@@ -511,7 +511,7 @@ void BodySW::integrate_forces(real_t p_step) {
//compute a FAKE angular velocity, not so easy
Basis rot=new_transform.basis.orthonormalized().transposed() * get_transform().basis.orthonormalized();
Vector3 axis;
- float angle;
+ real_t angle;
rot.get_axis_and_angle(axis,angle);
axis.normalize();
@@ -615,7 +615,7 @@ void BodySW::integrate_velocities(real_t p_step) {
- float ang_vel = total_angular_velocity.length();
+ real_t ang_vel = total_angular_velocity.length();
Transform transform = get_transform();
@@ -666,7 +666,7 @@ void BodySW::simulate_motion(const Transform& p_xform,real_t p_step) {
//compute a FAKE angular velocity, not so easy
Matrix3 rot=get_transform().basis.orthonormalized().transposed() * p_xform.basis.orthonormalized();
Vector3 axis;
- float angle;
+ real_t angle;
rot.get_axis_and_angle(axis,angle);
axis.normalize();
diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h
index e6ed3e75e5..2383d2d688 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics/body_sw.h
@@ -75,8 +75,8 @@ class BodySW : public CollisionObjectSW {
Vector3 applied_force;
Vector3 applied_torque;
- float area_angular_damp;
- float area_linear_damp;
+ real_t area_angular_damp;
+ real_t area_linear_damp;
SelfList<BodySW> active_list;
@@ -115,7 +115,7 @@ class BodySW : public CollisionObjectSW {
Vector3 local_pos;
Vector3 local_normal;
- float depth;
+ real_t depth;
int local_shape;
Vector3 collider_pos;
int collider_shape;
@@ -174,7 +174,7 @@ public:
_FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); }
_FORCE_INLINE_ bool can_report_contacts() const { return !contacts.empty(); }
- _FORCE_INLINE_ void add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, float p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos);
+ _FORCE_INLINE_ void add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, real_t p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos);
_FORCE_INLINE_ void add_exception(const RID& p_exception) { exceptions.insert(p_exception);}
@@ -248,8 +248,8 @@ public:
set_active(true);
}
- void set_param(PhysicsServer::BodyParameter p_param, float);
- float get_param(PhysicsServer::BodyParameter p_param) const;
+ void set_param(PhysicsServer::BodyParameter p_param, real_t);
+ real_t get_param(PhysicsServer::BodyParameter p_param) const;
void set_mode(PhysicsServer::BodyMode p_mode);
PhysicsServer::BodyMode get_mode() const;
@@ -319,7 +319,7 @@ public:
//add contact inline
-void BodySW::add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, float p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos) {
+void BodySW::add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, real_t p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos) {
int c_max=contacts.size();
@@ -335,7 +335,7 @@ void BodySW::add_contact(const Vector3& p_local_pos,const Vector3& p_local_norma
idx=contact_count++;
} else {
- float least_depth=1e20;
+ real_t least_depth=1e20;
int least_deep=-1;
for(int i=0;i<c_max;i++) {
@@ -377,13 +377,13 @@ public:
real_t step;
virtual Vector3 get_total_gravity() const { return body->gravity; } // get gravity vector working on this body space/area
- virtual float get_total_angular_damp() const { return body->area_angular_damp; } // get density of this body space/area
- virtual float get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area
+ virtual real_t get_total_angular_damp() const { return body->area_angular_damp; } // get density of this body space/area
+ virtual real_t get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area
virtual Vector3 get_center_of_mass() const { return body->get_center_of_mass(); }
virtual Basis get_principal_inertia_axes() const { return body->get_principal_inertia_axes(); }
- virtual float get_inverse_mass() const { return body->get_inv_mass(); } // get the mass
+ virtual real_t get_inverse_mass() const { return body->get_inv_mass(); } // get the mass
virtual Vector3 get_inverse_inertia() const { return body->get_inv_inertia(); } // get density of this body space
virtual Basis get_inverse_inertia_tensor() const { return body->get_inv_inertia_tensor(); } // get density of this body space
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index d41012caa4..9d3e1db47b 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -122,9 +122,9 @@ static void _generate_contacts_edge_edge(const Vector3 * p_points_A,int p_point_
Vector3 base_B = p_points_B[0] - axis * axis.dot(p_points_B[0]);
//sort all 4 points in axis
- float dvec[4]={ axis.dot(p_points_A[0]), axis.dot(p_points_A[1]), axis.dot(p_points_B[0]), axis.dot(p_points_B[1]) };
+ real_t dvec[4]={ axis.dot(p_points_A[0]), axis.dot(p_points_A[1]), axis.dot(p_points_B[0]), axis.dot(p_points_B[1]) };
- SortArray<float> sa;
+ SortArray<real_t> sa;
sa.sort(dvec,4);
//use the middle ones as contacts
@@ -234,7 +234,7 @@ static void _generate_contacts_face_face(const Vector3 * p_points_A,int p_point_
for (int i=0;i<clipbuf_len;i++) {
- float d = plane_B.distance_to(clipbuf_src[i]);
+ real_t d = plane_B.distance_to(clipbuf_src[i]);
/*
if (d>CMP_EPSILON)
continue;
@@ -476,11 +476,11 @@ public:
/****** SAT TESTS *******/
-typedef void (*CollisionFunc)(const ShapeSW*,const Transform&,const ShapeSW*,const Transform&,_CollectorCallback *p_callback,float,float);
+typedef void (*CollisionFunc)(const ShapeSW*,const Transform&,const ShapeSW*,const Transform&,_CollectorCallback *p_callback,real_t,real_t);
template<bool withMargin>
-static void _collision_sphere_sphere(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_sphere(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
@@ -500,7 +500,7 @@ static void _collision_sphere_sphere(const ShapeSW *p_a,const Transform &p_trans
}
template<bool withMargin>
-static void _collision_sphere_box(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_box(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
@@ -555,7 +555,7 @@ static void _collision_sphere_box(const ShapeSW *p_a,const Transform &p_transfor
}
template<bool withMargin>
-static void _collision_sphere_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW*>(p_b);
@@ -595,7 +595,7 @@ static void _collision_sphere_capsule(const ShapeSW *p_a,const Transform &p_tran
}
template<bool withMargin>
-static void _collision_sphere_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
@@ -666,7 +666,7 @@ static void _collision_sphere_convex_polygon(const ShapeSW *p_a,const Transform
}
template<bool withMargin>
-static void _collision_sphere_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
const FaceShapeSW *face_B = static_cast<const FaceShapeSW*>(p_b);
@@ -710,7 +710,7 @@ static void _collision_sphere_face(const ShapeSW *p_a,const Transform &p_transfo
template<bool withMargin>
-static void _collision_box_box(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_box_box(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const BoxShapeSW *box_A = static_cast<const BoxShapeSW*>(p_a);
@@ -818,7 +818,7 @@ static void _collision_box_box(const ShapeSW *p_a,const Transform &p_transform_a
}
template<bool withMargin>
-static void _collision_box_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_box_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const BoxShapeSW *box_A = static_cast<const BoxShapeSW*>(p_a);
const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW*>(p_b);
@@ -918,7 +918,7 @@ static void _collision_box_capsule(const ShapeSW *p_a,const Transform &p_transfo
}
template<bool withMargin>
-static void _collision_box_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_box_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
@@ -1046,7 +1046,7 @@ static void _collision_box_convex_polygon(const ShapeSW *p_a,const Transform &p_
template<bool withMargin>
-static void _collision_box_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_box_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const BoxShapeSW *box_A = static_cast<const BoxShapeSW*>(p_a);
@@ -1158,7 +1158,7 @@ static void _collision_box_face(const ShapeSW *p_a,const Transform &p_transform_
template<bool withMargin>
-static void _collision_capsule_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_capsule_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW*>(p_a);
const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW*>(p_b);
@@ -1216,7 +1216,7 @@ static void _collision_capsule_capsule(const ShapeSW *p_a,const Transform &p_tra
}
template<bool withMargin>
-static void _collision_capsule_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_capsule_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW*>(p_a);
@@ -1287,7 +1287,7 @@ static void _collision_capsule_convex_polygon(const ShapeSW *p_a,const Transform
template<bool withMargin>
-static void _collision_capsule_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_capsule_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW*>(p_a);
const FaceShapeSW *face_B = static_cast<const FaceShapeSW*>(p_b);
@@ -1350,7 +1350,7 @@ static void _collision_capsule_face(const ShapeSW *p_a,const Transform &p_transf
template<bool withMargin>
-static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const ConvexPolygonShapeSW *convex_polygon_A = static_cast<const ConvexPolygonShapeSW*>(p_a);
@@ -1474,7 +1474,7 @@ static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a,const Tr
template<bool withMargin>
-static void _collision_convex_polygon_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_convex_polygon_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const ConvexPolygonShapeSW *convex_polygon_A = static_cast<const ConvexPolygonShapeSW*>(p_a);
@@ -1585,7 +1585,7 @@ static void _collision_convex_polygon_face(const ShapeSW *p_a,const Transform &p
}
-bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_transform_A, const ShapeSW *p_shape_B, const Transform& p_transform_B, CollisionSolverSW::CallbackResult p_result_callback,void *p_userdata,bool p_swap,Vector3* r_prev_axis,float p_margin_a,float p_margin_b) {
+bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_transform_A, const ShapeSW *p_shape_B, const Transform& p_transform_B, CollisionSolverSW::CallbackResult p_result_callback,void *p_userdata,bool p_swap,Vector3* r_prev_axis,real_t p_margin_a,real_t p_margin_b) {
PhysicsServer::ShapeType type_A=p_shape_A->get_type();
@@ -1667,8 +1667,8 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_tran
const ShapeSW *B=p_shape_B;
const Transform *transform_A=&p_transform_A;
const Transform *transform_B=&p_transform_B;
- float margin_A=p_margin_a;
- float margin_B=p_margin_b;
+ real_t margin_A=p_margin_a;
+ real_t margin_B=p_margin_b;
if (type_A > type_B) {
SWAP(A,B);
diff --git a/servers/physics/collision_solver_sat.h b/servers/physics/collision_solver_sat.h
index 60387a978d..15fe7dc34a 100644
--- a/servers/physics/collision_solver_sat.h
+++ b/servers/physics/collision_solver_sat.h
@@ -32,6 +32,6 @@
#include "collision_solver_sw.h"
-bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_transform_A, const ShapeSW *p_shape_B, const Transform& p_transform_B, CollisionSolverSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap=false,Vector3* r_prev_axis=NULL,float p_margin_a=0,float p_margin_b=0);
+bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_transform_A, const ShapeSW *p_shape_B, const Transform& p_transform_B, CollisionSolverSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap=false,Vector3* r_prev_axis=NULL,real_t p_margin_a=0,real_t p_margin_b=0);
#endif // COLLISION_SOLVER_SAT_H
diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp
index 3399849ab7..f0ddde3a76 100644
--- a/servers/physics/collision_solver_sw.cpp
+++ b/servers/physics/collision_solver_sw.cpp
@@ -115,8 +115,8 @@ struct _ConcaveCollisionInfo {
int aabb_tests;
int collisions;
bool tested;
- float margin_A;
- float margin_B;
+ real_t margin_A;
+ real_t margin_B;
Vector3 close_A,close_B;
};
@@ -136,7 +136,7 @@ void CollisionSolverSW::concave_callback(void *p_userdata, ShapeSW *p_convex) {
}
-bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,float p_margin_A,float p_margin_B) {
+bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,real_t p_margin_A,real_t p_margin_B) {
const ConcaveShapeSW *concave_B=static_cast<const ConcaveShapeSW*>(p_shape_B);
@@ -164,10 +164,10 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform&
for(int i=0;i<3;i++) {
Vector3 axis( p_transform_B.basis.get_axis(i) );
- float axis_scale = 1.0/axis.length();
+ real_t axis_scale = 1.0/axis.length();
axis*=axis_scale;
- float smin,smax;
+ real_t smin,smax;
p_shape_A->project_range(axis,rel_transform,smin,smax);
smin-=p_margin_A;
smax+=p_margin_A;
@@ -186,7 +186,7 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform&
}
-bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis,float p_margin_A,float p_margin_B) {
+bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis,real_t p_margin_A,real_t p_margin_B) {
PhysicsServer::ShapeType type_A=p_shape_A->get_type();
@@ -291,7 +291,7 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A,const Tran
bool collided=false;
Vector3 closest;
- float closest_d;
+ real_t closest_d;
for(int i=0;i<support_count;i++) {
@@ -362,10 +362,10 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A,const Transform&
for(int i=0;i<3;i++) {
Vector3 axis( p_transform_B.basis.get_axis(i) );
- float axis_scale = 1.0/axis.length();
+ real_t axis_scale = ((real_t)1.0)/axis.length();
axis*=axis_scale;
- float smin,smax;
+ real_t smin,smax;
if (use_cc_hint) {
cc_hint_aabb.project_range_in_plane(Plane(axis,0),smin,smax);
diff --git a/servers/physics/collision_solver_sw.h b/servers/physics/collision_solver_sw.h
index 16d2b92d70..b8d37a8a96 100644
--- a/servers/physics/collision_solver_sw.h
+++ b/servers/physics/collision_solver_sw.h
@@ -40,14 +40,14 @@ private:
static void concave_callback(void *p_userdata, ShapeSW *p_convex);
static bool solve_static_plane(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result);
static bool solve_ray(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result);
- static bool solve_concave(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,float p_margin_A=0,float p_margin_B=0);
+ static bool solve_concave(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,real_t p_margin_A=0,real_t p_margin_B=0);
static void concave_distance_callback(void *p_userdata, ShapeSW *p_convex);
static bool solve_distance_plane(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,Vector3& r_point_A,Vector3& r_point_B);
public:
- static bool solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis=NULL,float p_margin_A=0,float p_margin_B=0);
+ static bool solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis=NULL,real_t p_margin_A=0,real_t p_margin_B=0);
static bool solve_distance(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,Vector3& r_point_A,Vector3& r_point_B,const Rect3& p_concave_hint,Vector3 *r_sep_axis=NULL);
};
diff --git a/servers/physics/constraint_sw.h b/servers/physics/constraint_sw.h
index adc17cb753..f5bbe4bbd0 100644
--- a/servers/physics/constraint_sw.h
+++ b/servers/physics/constraint_sw.h
@@ -67,8 +67,8 @@ public:
_FORCE_INLINE_ int get_priority() const { return priority; }
- virtual bool setup(float p_step)=0;
- virtual void solve(float p_step)=0;
+ virtual bool setup(real_t p_step)=0;
+ virtual void solve(real_t p_step)=0;
virtual ~ConstraintSW() {}
};
diff --git a/servers/physics/joints/cone_twist_joint_sw.cpp b/servers/physics/joints/cone_twist_joint_sw.cpp
index cbf444f1e8..d78bcbd16d 100644
--- a/servers/physics/joints/cone_twist_joint_sw.cpp
+++ b/servers/physics/joints/cone_twist_joint_sw.cpp
@@ -96,7 +96,7 @@ ConeTwistJointSW::ConeTwistJointSW(BodySW* rbA,BodySW* rbB,const Transform& rbAF
}
-bool ConeTwistJointSW::setup(float p_step) {
+bool ConeTwistJointSW::setup(real_t p_step) {
m_appliedImpulse = real_t(0.);
//set bias, sign, clear accumulator
@@ -318,7 +318,7 @@ void ConeTwistJointSW::solve(real_t timeStep)
}
-void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, float p_value) {
+void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value) {
switch(p_param) {
case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: {
@@ -345,7 +345,7 @@ void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, flo
}
}
-float ConeTwistJointSW::get_param(PhysicsServer::ConeTwistJointParam p_param) const{
+real_t ConeTwistJointSW::get_param(PhysicsServer::ConeTwistJointParam p_param) const{
switch(p_param) {
case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: {
diff --git a/servers/physics/joints/cone_twist_joint_sw.h b/servers/physics/joints/cone_twist_joint_sw.h
index 0d64d67443..eb7a5cd1b1 100644
--- a/servers/physics/joints/cone_twist_joint_sw.h
+++ b/servers/physics/joints/cone_twist_joint_sw.h
@@ -109,8 +109,8 @@ public:
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_CONE_TWIST; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
ConeTwistJointSW(BodySW* rbA,BodySW* rbB,const Transform& rbAFrame, const Transform& rbBFrame);
@@ -146,8 +146,8 @@ public:
return m_twistLimitSign;
}
- void set_param(PhysicsServer::ConeTwistJointParam p_param, float p_value);
- float get_param(PhysicsServer::ConeTwistJointParam p_param) const;
+ void set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer::ConeTwistJointParam p_param) const;
};
diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp
index 8d3fc4721a..bd07f3122a 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.cpp
+++ b/servers/physics/joints/generic_6dof_joint_sw.cpp
@@ -38,54 +38,6 @@ See corresponding header file for licensing info.
#define GENERIC_D6_DISABLE_WARMSTARTING 1
-real_t btGetMatrixElem(const Basis& mat, int index);
-real_t btGetMatrixElem(const Basis& mat, int index)
-{
- int i = index%3;
- int j = index/3;
- return mat[i][j];
-}
-
-///MatrixToEulerXYZ from http://www.geometrictools.com/LibFoundation/Mathematics/Wm4Matrix3.inl.html
-bool matrixToEulerXYZ(const Basis& mat,Vector3& xyz);
-bool matrixToEulerXYZ(const Basis& mat,Vector3& xyz)
-{
- // rot = cy*cz -cy*sz sy
- // cz*sx*sy+cx*sz cx*cz-sx*sy*sz -cy*sx
- // -cx*cz*sy+sx*sz cz*sx+cx*sy*sz cx*cy
-
- if (btGetMatrixElem(mat,2) < real_t(1.0))
- {
- if (btGetMatrixElem(mat,2) > real_t(-1.0))
- {
- xyz[0] = Math::atan2(-btGetMatrixElem(mat,5),btGetMatrixElem(mat,8));
- xyz[1] = Math::asin(btGetMatrixElem(mat,2));
- xyz[2] = Math::atan2(-btGetMatrixElem(mat,1),btGetMatrixElem(mat,0));
- return true;
- }
- else
- {
- // WARNING. Not unique. XA - ZA = -atan2(r10,r11)
- xyz[0] = -Math::atan2(btGetMatrixElem(mat,3),btGetMatrixElem(mat,4));
- xyz[1] = -Math_PI*0.5;
- xyz[2] = real_t(0.0);
- return false;
- }
- }
- else
- {
- // WARNING. Not unique. XAngle + ZAngle = atan2(r10,r11)
- xyz[0] = Math::atan2(btGetMatrixElem(mat,3),btGetMatrixElem(mat,4));
- xyz[1] = Math_PI*0.5;
- xyz[2] = 0.0;
-
- }
-
-
- return false;
-}
-
-
//////////////////////////// G6DOFRotationalLimitMotorSW ////////////////////////////////////
@@ -297,7 +249,7 @@ void Generic6DOFJointSW::calculateAngleInfo()
{
Basis relative_frame = m_calculatedTransformA.basis.inverse()*m_calculatedTransformB.basis;
- matrixToEulerXYZ(relative_frame,m_calculatedAxisAngleDiff);
+ m_calculatedAxisAngleDiff = relative_frame.get_euler();
@@ -385,7 +337,7 @@ bool Generic6DOFJointSW::testAngularLimitMotor(int axis_index)
return m_angularLimits[axis_index].needApplyTorques();
}
-bool Generic6DOFJointSW::setup(float p_step) {
+bool Generic6DOFJointSW::setup(real_t p_step) {
// Clear accumulated impulses for the next simulation step
m_linearLimits.m_accumulatedImpulse=Vector3(real_t(0.), real_t(0.), real_t(0.));
@@ -531,7 +483,7 @@ void Generic6DOFJointSW::calcAnchorPos(void)
} // Generic6DOFJointSW::calcAnchorPos()
-void Generic6DOFJointSW::set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param, float p_value) {
+void Generic6DOFJointSW::set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) {
ERR_FAIL_INDEX(p_axis,3);
switch(p_param) {
@@ -607,7 +559,7 @@ void Generic6DOFJointSW::set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJoin
}
}
-float Generic6DOFJointSW::get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param) const{
+real_t Generic6DOFJointSW::get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param) const{
ERR_FAIL_INDEX_V(p_axis,3,0);
switch(p_param) {
case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
diff --git a/servers/physics/joints/generic_6dof_joint_sw.h b/servers/physics/joints/generic_6dof_joint_sw.h
index 4ac727c124..207ae85a45 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.h
+++ b/servers/physics/joints/generic_6dof_joint_sw.h
@@ -295,8 +295,8 @@ public:
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_6DOF; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
//! Calcs global transform of the offsets
@@ -449,8 +449,8 @@ public:
virtual void calcAnchorPos(void); // overridable
- void set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param, float p_value);
- float get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param) const;
+ void set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value);
+ real_t get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param) const;
void set_flag(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value);
bool get_flag(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisFlag p_flag) const;
diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp
index d50d5a1a73..9617eb8794 100644
--- a/servers/physics/joints/hinge_joint_sw.cpp
+++ b/servers/physics/joints/hinge_joint_sw.cpp
@@ -148,7 +148,7 @@ HingeJointSW::HingeJointSW(BodySW* rbA,BodySW* rbB, const Vector3& pivotInA,cons
-bool HingeJointSW::setup(float p_step) {
+bool HingeJointSW::setup(real_t p_step) {
m_appliedImpulse = real_t(0.);
@@ -262,7 +262,7 @@ bool HingeJointSW::setup(float p_step) {
return true;
}
-void HingeJointSW::solve(float p_step) {
+void HingeJointSW::solve(real_t p_step) {
Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin);
Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin);
@@ -418,7 +418,7 @@ real_t HingeJointSW::get_hinge_angle() {
}
-void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, float p_value) {
+void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) {
switch (p_param) {
@@ -434,7 +434,7 @@ void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, float p_val
}
}
-float HingeJointSW::get_param(PhysicsServer::HingeJointParam p_param) const{
+real_t HingeJointSW::get_param(PhysicsServer::HingeJointParam p_param) const{
switch (p_param) {
diff --git a/servers/physics/joints/hinge_joint_sw.h b/servers/physics/joints/hinge_joint_sw.h
index 60203e3cc4..8469fd1ca0 100644
--- a/servers/physics/joints/hinge_joint_sw.h
+++ b/servers/physics/joints/hinge_joint_sw.h
@@ -103,13 +103,13 @@ public:
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_HINGE; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
real_t get_hinge_angle();
- void set_param(PhysicsServer::HingeJointParam p_param, float p_value);
- float get_param(PhysicsServer::HingeJointParam p_param) const;
+ void set_param(PhysicsServer::HingeJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer::HingeJointParam p_param) const;
void set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value);
bool get_flag(PhysicsServer::HingeJointFlag p_flag) const;
diff --git a/servers/physics/joints/pin_joint_sw.cpp b/servers/physics/joints/pin_joint_sw.cpp
index 9c7fe65684..b545ae630b 100644
--- a/servers/physics/joints/pin_joint_sw.cpp
+++ b/servers/physics/joints/pin_joint_sw.cpp
@@ -34,7 +34,7 @@ See corresponding header file for licensing info.
#include "pin_joint_sw.h"
-bool PinJointSW::setup(float p_step) {
+bool PinJointSW::setup(real_t p_step) {
m_appliedImpulse = real_t(0.);
@@ -59,7 +59,7 @@ bool PinJointSW::setup(float p_step) {
return true;
}
-void PinJointSW::solve(float p_step){
+void PinJointSW::solve(real_t p_step){
Vector3 pivotAInW = A->get_transform().xform(m_pivotInA);
Vector3 pivotBInW = B->get_transform().xform(m_pivotInB);
@@ -116,7 +116,7 @@ void PinJointSW::solve(float p_step){
}
}
-void PinJointSW::set_param(PhysicsServer::PinJointParam p_param,float p_value) {
+void PinJointSW::set_param(PhysicsServer::PinJointParam p_param,real_t p_value) {
switch(p_param) {
case PhysicsServer::PIN_JOINT_BIAS: m_tau=p_value; break;
@@ -125,7 +125,7 @@ void PinJointSW::set_param(PhysicsServer::PinJointParam p_param,float p_value) {
}
}
-float PinJointSW::get_param(PhysicsServer::PinJointParam p_param) const{
+real_t PinJointSW::get_param(PhysicsServer::PinJointParam p_param) const{
switch(p_param) {
case PhysicsServer::PIN_JOINT_BIAS: return m_tau;
diff --git a/servers/physics/joints/pin_joint_sw.h b/servers/physics/joints/pin_joint_sw.h
index 6797972496..b72b21219d 100644
--- a/servers/physics/joints/pin_joint_sw.h
+++ b/servers/physics/joints/pin_joint_sw.h
@@ -79,11 +79,11 @@ public:
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_PIN; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
- void set_param(PhysicsServer::PinJointParam p_param,float p_value);
- float get_param(PhysicsServer::PinJointParam p_param) const;
+ void set_param(PhysicsServer::PinJointParam p_param,real_t p_value);
+ real_t get_param(PhysicsServer::PinJointParam p_param) const;
void set_pos_A(const Vector3& p_pos) { m_pivotInA=p_pos; }
void set_pos_B(const Vector3& p_pos) { m_pivotInB=p_pos; }
diff --git a/servers/physics/joints/slider_joint_sw.cpp b/servers/physics/joints/slider_joint_sw.cpp
index bdcae08ca4..fc728ed0ba 100644
--- a/servers/physics/joints/slider_joint_sw.cpp
+++ b/servers/physics/joints/slider_joint_sw.cpp
@@ -112,7 +112,7 @@ SliderJointSW::SliderJointSW(BodySW* rbA, BodySW* rbB, const Transform& frameInA
//-----------------------------------------------------------------------------
-bool SliderJointSW::setup(float p_step)
+bool SliderJointSW::setup(real_t p_step)
{
//calculate transforms
@@ -406,7 +406,7 @@ Vector3 SliderJointSW::getAncorInB(void)
return ancorInB;
} // SliderJointSW::getAncorInB();
-void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, float p_value) {
+void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, real_t p_value) {
switch(p_param) {
case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: m_upperLinLimit=p_value; break;
@@ -437,7 +437,7 @@ void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, float p_v
}
-float SliderJointSW::get_param(PhysicsServer::SliderJointParam p_param) const {
+real_t SliderJointSW::get_param(PhysicsServer::SliderJointParam p_param) const {
switch(p_param) {
case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return m_upperLinLimit;
diff --git a/servers/physics/joints/slider_joint_sw.h b/servers/physics/joints/slider_joint_sw.h
index 4e697e6f64..d01038df59 100644
--- a/servers/physics/joints/slider_joint_sw.h
+++ b/servers/physics/joints/slider_joint_sw.h
@@ -237,11 +237,11 @@ public:
Vector3 getAncorInA(void);
Vector3 getAncorInB(void);
- void set_param(PhysicsServer::SliderJointParam p_param, float p_value);
- float get_param(PhysicsServer::SliderJointParam p_param) const;
+ void set_param(PhysicsServer::SliderJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer::SliderJointParam p_param) const;
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_SLIDER; }
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index b71eae54b0..67e3b27852 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -727,7 +727,7 @@ uint32_t PhysicsServerSW::body_get_user_flags(RID p_body, uint32_t p_flags) cons
return 0;
};
-void PhysicsServerSW::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
+void PhysicsServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
@@ -735,7 +735,7 @@ void PhysicsServerSW::body_set_param(RID p_body, BodyParameter p_param, float p_
body->set_param(p_param,p_value);
};
-float PhysicsServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
+real_t PhysicsServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -879,14 +879,14 @@ void PhysicsServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exc
};
-void PhysicsServerSW::body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold) {
+void PhysicsServerSW::body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
};
-float PhysicsServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const {
+real_t PhysicsServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -971,7 +971,7 @@ RID PhysicsServerSW::joint_create_pin(RID p_body_A,const Vector3& p_local_A,RID
return rid;
}
-void PhysicsServerSW::pin_joint_set_param(RID p_joint,PinJointParam p_param, float p_value){
+void PhysicsServerSW::pin_joint_set_param(RID p_joint,PinJointParam p_param, real_t p_value){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -980,7 +980,7 @@ void PhysicsServerSW::pin_joint_set_param(RID p_joint,PinJointParam p_param, flo
pin_joint->set_param(p_param,p_value);
}
-float PhysicsServerSW::pin_joint_get_param(RID p_joint,PinJointParam p_param) const{
+real_t PhysicsServerSW::pin_joint_get_param(RID p_joint,PinJointParam p_param) const{
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1074,7 +1074,7 @@ RID PhysicsServerSW::joint_create_hinge_simple(RID p_body_A,const Vector3& p_piv
}
-void PhysicsServerSW::hinge_joint_set_param(RID p_joint,HingeJointParam p_param, float p_value){
+void PhysicsServerSW::hinge_joint_set_param(RID p_joint,HingeJointParam p_param, real_t p_value){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -1083,7 +1083,7 @@ void PhysicsServerSW::hinge_joint_set_param(RID p_joint,HingeJointParam p_param,
hinge_joint->set_param(p_param,p_value);
}
-float PhysicsServerSW::hinge_joint_get_param(RID p_joint,HingeJointParam p_param) const{
+real_t PhysicsServerSW::hinge_joint_get_param(RID p_joint,HingeJointParam p_param) const{
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1154,7 +1154,7 @@ RID PhysicsServerSW::joint_create_slider(RID p_body_A,const Transform& p_local_f
return rid;
}
-void PhysicsServerSW::slider_joint_set_param(RID p_joint,SliderJointParam p_param, float p_value){
+void PhysicsServerSW::slider_joint_set_param(RID p_joint,SliderJointParam p_param, real_t p_value){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -1162,7 +1162,7 @@ void PhysicsServerSW::slider_joint_set_param(RID p_joint,SliderJointParam p_para
SliderJointSW *slider_joint = static_cast<SliderJointSW*>(joint);
slider_joint->set_param(p_param,p_value);
}
-float PhysicsServerSW::slider_joint_get_param(RID p_joint,SliderJointParam p_param) const{
+real_t PhysicsServerSW::slider_joint_get_param(RID p_joint,SliderJointParam p_param) const{
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1193,7 +1193,7 @@ RID PhysicsServerSW::joint_create_cone_twist(RID p_body_A,const Transform& p_loc
return rid;
}
-void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, float p_value) {
+void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, real_t p_value) {
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -1201,7 +1201,7 @@ void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam
ConeTwistJointSW *cone_twist_joint = static_cast<ConeTwistJointSW*>(joint);
cone_twist_joint->set_param(p_param,p_value);
}
-float PhysicsServerSW::cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const {
+real_t PhysicsServerSW::cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const {
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1232,7 +1232,7 @@ RID PhysicsServerSW::joint_create_generic_6dof(RID p_body_A,const Transform& p_l
return rid;
}
-void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param, float p_value){
+void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param, real_t p_value){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -1240,7 +1240,7 @@ void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint,Vector3::Axis p_a
Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW*>(joint);
generic_6dof_joint->set_param(p_axis,p_param,p_value);
}
-float PhysicsServerSW::generic_6dof_joint_get_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param){
+real_t PhysicsServerSW::generic_6dof_joint_get_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1488,7 +1488,7 @@ void PhysicsServerSW::init() {
};
-void PhysicsServerSW::step(float p_step) {
+void PhysicsServerSW::step(real_t p_step) {
if (!active)
@@ -1611,11 +1611,11 @@ void PhysicsServerSW::_shape_col_cbk(const Vector3& p_point_A,const Vector3& p_p
if (cbk->amount == cbk->max) {
//find least deep
- float min_depth=1e20;
+ real_t min_depth=1e20;
int min_depth_idx=0;
for(int i=0;i<cbk->amount;i++) {
- float d = cbk->ptr[i*2+0].distance_squared_to(cbk->ptr[i*2+1]);
+ real_t d = cbk->ptr[i*2+0].distance_squared_to(cbk->ptr[i*2+1]);
if (d<min_depth) {
min_depth=d;
min_depth_idx=i;
@@ -1623,7 +1623,7 @@ void PhysicsServerSW::_shape_col_cbk(const Vector3& p_point_A,const Vector3& p_p
}
- float d = p_point_A.distance_squared_to(p_point_B);
+ real_t d = p_point_A.distance_squared_to(p_point_B);
if (d<min_depth)
return;
cbk->ptr[min_depth_idx*2+0]=p_point_A;
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index 72b133c4b9..6e20474350 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -180,8 +180,8 @@ public:
virtual void body_set_user_flags(RID p_body, uint32_t p_flags);
virtual uint32_t body_get_user_flags(RID p_body, uint32_t p_flags) const;
- virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value);
- virtual float body_get_param(RID p_body, BodyParameter p_param) const;
+ virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value);
+ virtual real_t body_get_param(RID p_body, BodyParameter p_param) const;
virtual void body_set_state(RID p_body, BodyState p_state, const Variant& p_variant);
virtual Variant body_get_state(RID p_body, BodyState p_state) const;
@@ -203,8 +203,8 @@ public:
virtual void body_remove_collision_exception(RID p_body, RID p_body_b);
virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions);
- virtual void body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold);
- virtual float body_get_contacts_reported_depth_treshold(RID p_body) const;
+ virtual void body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold);
+ virtual real_t body_get_contacts_reported_depth_treshold(RID p_body) const;
virtual void body_set_omit_force_integration(RID p_body,bool p_omit);
virtual bool body_is_omitting_force_integration(RID p_body) const;
@@ -221,8 +221,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);
- virtual void pin_joint_set_param(RID p_joint,PinJointParam p_param, float p_value);
- virtual float pin_joint_get_param(RID p_joint,PinJointParam p_param) const;
+ virtual void pin_joint_set_param(RID p_joint,PinJointParam p_param, real_t p_value);
+ virtual real_t pin_joint_get_param(RID p_joint,PinJointParam p_param) const;
virtual void pin_joint_set_local_A(RID p_joint, const Vector3& p_A);
virtual Vector3 pin_joint_get_local_A(RID p_joint) const;
@@ -233,8 +233,8 @@ public:
virtual RID joint_create_hinge(RID p_body_A,const Transform& p_frame_A,RID p_body_B,const Transform& p_frame_B);
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);
- virtual void hinge_joint_set_param(RID p_joint,HingeJointParam p_param, float p_value);
- virtual float hinge_joint_get_param(RID p_joint,HingeJointParam p_param) const;
+ virtual void hinge_joint_set_param(RID p_joint,HingeJointParam p_param, real_t p_value);
+ virtual real_t hinge_joint_get_param(RID p_joint,HingeJointParam p_param) const;
virtual void hinge_joint_set_flag(RID p_joint,HingeJointFlag p_flag, bool p_value);
virtual bool hinge_joint_get_flag(RID p_joint,HingeJointFlag p_flag) const;
@@ -242,18 +242,18 @@ 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); //reference frame is A
- virtual void slider_joint_set_param(RID p_joint,SliderJointParam p_param, float p_value);
- virtual float slider_joint_get_param(RID p_joint,SliderJointParam p_param) const;
+ virtual void slider_joint_set_param(RID p_joint,SliderJointParam p_param, real_t p_value);
+ virtual real_t slider_joint_get_param(RID p_joint,SliderJointParam p_param) const;
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); //reference frame is A
- virtual void cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, float p_value);
- virtual float cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const;
+ virtual void cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, real_t p_value);
+ virtual real_t cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const;
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); //reference frame is A
- virtual void generic_6dof_joint_set_param(RID p_joint,Vector3::Axis,G6DOFJointAxisParam p_param, float p_value);
- virtual float generic_6dof_joint_get_param(RID p_joint,Vector3::Axis,G6DOFJointAxisParam p_param);
+ virtual void generic_6dof_joint_set_param(RID p_joint,Vector3::Axis,G6DOFJointAxisParam p_param, real_t p_value);
+ virtual real_t generic_6dof_joint_get_param(RID p_joint,Vector3::Axis,G6DOFJointAxisParam p_param);
virtual void generic_6dof_joint_set_flag(RID p_joint,Vector3::Axis,G6DOFJointAxisFlag p_flag, bool p_enable);
virtual bool generic_6dof_joint_get_flag(RID p_joint,Vector3::Axis,G6DOFJointAxisFlag p_flag);
@@ -281,7 +281,7 @@ public:
virtual void set_active(bool p_active);
virtual void init();
- virtual void step(float p_step);
+ virtual void step(real_t p_step);
virtual void sync();
virtual void flush_queries();
virtual void finish();
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index 4114980b82..10500a306f 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -125,7 +125,7 @@ bool PlaneShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end
return inters;
}
-Vector3 PlaneShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 PlaneShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(); //wtf
}
@@ -154,7 +154,7 @@ PlaneShapeSW::PlaneShapeSW() {
//
-float RayShapeSW::get_length() const {
+real_t RayShapeSW::get_length() const {
return length;
}
@@ -196,12 +196,12 @@ bool RayShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,V
return false; //simply not possible
}
-Vector3 RayShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 RayShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3();
}
-void RayShapeSW::_setup(float p_length) {
+void RayShapeSW::_setup(real_t p_length) {
length=p_length;
configure(Rect3(Vector3(0,0,0),Vector3(0.1,0.1,length)));
@@ -234,11 +234,11 @@ real_t SphereShapeSW::get_radius() const {
void SphereShapeSW::project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const {
- float d = p_normal.dot( p_transform.origin );
+ real_t d = p_normal.dot( p_transform.origin );
// figure out scale at point
Vector3 local_normal = p_transform.basis.xform_inv(p_normal);
- float scale = local_normal.length();
+ real_t scale = local_normal.length();
r_min = d - (radius) * scale;
r_max = d + (radius) * scale;
@@ -261,9 +261,9 @@ bool SphereShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_en
return Geometry::segment_intersects_sphere(p_begin,p_end,Vector3(),radius,&r_result,&r_normal);
}
-Vector3 SphereShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 SphereShapeSW::get_moment_of_inertia(real_t p_mass) const {
- float s = 0.4 * p_mass * radius * radius;
+ real_t s = 0.4 * p_mass * radius * radius;
return Vector3(s,s,s);
}
@@ -299,8 +299,8 @@ void BoxShapeSW::project_range(const Vector3& p_normal, const Transform& p_trans
// no matter the angle, the box is mirrored anyway
Vector3 local_normal=p_transform.basis.xform_inv(p_normal);
- float length = local_normal.abs().dot(half_extents);
- float distance = p_normal.dot( p_transform.origin );
+ real_t length = local_normal.abs().dot(half_extents);
+ real_t distance = p_normal.dot( p_transform.origin );
r_min = distance - length;
r_max = distance + length;
@@ -329,7 +329,7 @@ void BoxShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_suppo
Vector3 axis;
axis[i]=1.0;
- float dot = p_normal.dot( axis );
+ real_t dot = p_normal.dot( axis );
if ( Math::abs( dot ) > _FACE_IS_VALID_SUPPORT_TRESHOLD ) {
//Vector3 axis_b;
@@ -343,7 +343,7 @@ void BoxShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_suppo
int i_n=next[i];
int i_n2=next2[i];
- static const float sign[4][2]={
+ static const real_t sign[4][2]={
{-1.0, 1.0},
{ 1.0, 1.0},
@@ -418,11 +418,11 @@ bool BoxShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,V
}
-Vector3 BoxShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 BoxShapeSW::get_moment_of_inertia(real_t p_mass) const {
- float lx=half_extents.x;
- float ly=half_extents.y;
- float lz=half_extents.z;
+ real_t lx=half_extents.x;
+ real_t ly=half_extents.y;
+ real_t lz=half_extents.z;
return Vector3( (p_mass/3.0) * (ly*ly + lz*lz), (p_mass/3.0) * (lx*lx + lz*lz), (p_mass/3.0) * (lx*lx + ly*ly) );
@@ -460,7 +460,7 @@ BoxShapeSW::BoxShapeSW() {
void CapsuleShapeSW::project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const {
Vector3 n=p_transform.basis.xform_inv(p_normal).normalized();
- float h = (n.z > 0) ? height : -height;
+ real_t h = (n.z > 0) ? height : -height;
n *= radius;
n.z += h * 0.5;
@@ -471,8 +471,8 @@ void CapsuleShapeSW::project_range(const Vector3& p_normal, const Transform& p_t
n = p_transform.basis.xform(n);
- float distance = p_normal.dot( p_transform.origin );
- float length = Math::abs(p_normal.dot(n));
+ real_t distance = p_normal.dot( p_transform.origin );
+ real_t length = Math::abs(p_normal.dot(n));
r_min = distance - length;
r_max = distance + length;
@@ -484,7 +484,7 @@ Vector3 CapsuleShapeSW::get_support(const Vector3& p_normal) const {
Vector3 n=p_normal;
- float h = (n.z > 0) ? height : -height;
+ real_t h = (n.z > 0) ? height : -height;
n*=radius;
n.z += h*0.5;
@@ -496,7 +496,7 @@ void CapsuleShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_s
Vector3 n=p_normal;
- float d = n.z;
+ real_t d = n.z;
if (Math::abs( d )<_EDGE_IS_VALID_SUPPORT_TRESHOLD ) {
@@ -513,7 +513,7 @@ void CapsuleShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_s
} else {
- float h = (d > 0) ? height : -height;
+ real_t h = (d > 0) ? height : -height;
n*=radius;
n.z += h*0.5;
@@ -528,7 +528,7 @@ void CapsuleShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_s
bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const {
Vector3 norm=(p_end-p_begin).normalized();
- float min_d=1e20;
+ real_t min_d=1e20;
Vector3 res,n;
@@ -542,7 +542,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_e
collided = Geometry::segment_intersects_cylinder(p_begin,p_end,height,radius,&auxres,&auxn);
if (collided) {
- float d=norm.dot(auxres);
+ real_t d=norm.dot(auxres);
if (d<min_d) {
min_d=d;
res=auxres;
@@ -554,7 +554,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_e
collided = Geometry::segment_intersects_sphere(p_begin,p_end,Vector3(0,0,height*0.5),radius,&auxres,&auxn);
if (collided) {
- float d=norm.dot(auxres);
+ real_t d=norm.dot(auxres);
if (d<min_d) {
min_d=d;
res=auxres;
@@ -566,7 +566,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_e
collided = Geometry::segment_intersects_sphere(p_begin,p_end,Vector3(0,0,height*-0.5),radius,&auxres,&auxn);
if (collided) {
- float d=norm.dot(auxres);
+ real_t d=norm.dot(auxres);
if (d<min_d) {
min_d=d;
@@ -584,7 +584,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_e
return collision;
}
-Vector3 CapsuleShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 CapsuleShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
Vector3 extents=get_aabb().size*0.5;
@@ -647,7 +647,7 @@ void ConvexPolygonShapeSW::project_range(const Vector3& p_normal, const Transfor
for (int i=0;i<vertex_count;i++) {
- float d=p_normal.dot( p_transform.xform( vrts[i] ) );
+ real_t d=p_normal.dot( p_transform.xform( vrts[i] ) );
if (i==0 || d > r_max)
r_max=d;
@@ -661,7 +661,7 @@ Vector3 ConvexPolygonShapeSW::get_support(const Vector3& p_normal) const {
Vector3 n=p_normal;
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
int vertex_count=mesh.vertices.size();
if (vertex_count==0)
@@ -671,7 +671,7 @@ Vector3 ConvexPolygonShapeSW::get_support(const Vector3& p_normal) const {
for (int i=0;i<vertex_count;i++) {
- float d=n.dot(vrts[i]);
+ real_t d=n.dot(vrts[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -702,7 +702,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector
for (int i=0;i<vc;i++) {
- float d=p_normal.dot(vertices[i]);
+ real_t d=p_normal.dot(vertices[i]);
if (i==0 || d > max) {
max=d;
@@ -742,7 +742,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector
for(int i=0;i<ec;i++) {
- float dot=(vertices[edges[i].a]-vertices[edges[i].b]).normalized().dot(p_normal);
+ real_t dot=(vertices[edges[i].a]-vertices[edges[i].b]).normalized().dot(p_normal);
dot=ABS(dot);
if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD && (edges[i].a==vtx || edges[i].b==vtx)) {
@@ -768,7 +768,7 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vector
const Vector3 *vertices = mesh.vertices.ptr();
Vector3 n = p_end-p_begin;
- float min = 1e20;
+ real_t min = 1e20;
bool col=false;
for(int i=0;i<fc;i++) {
@@ -784,7 +784,7 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vector
Face3 f(vertices[ind[0]],vertices[ind[j]],vertices[ind[j+1]]);
Vector3 result;
if (f.intersects_segment(p_begin,p_end,&result)) {
- float d = n.dot(result);
+ real_t d = n.dot(result);
if (d<min) {
min=d;
r_result=result;
@@ -802,7 +802,7 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vector
}
-Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
Vector3 extents=get_aabb().size*0.5;
@@ -859,7 +859,7 @@ void FaceShapeSW::project_range(const Vector3& p_normal, const Transform& p_tran
for (int i=0;i<3;i++) {
Vector3 v=p_transform.xform(vertex[i]);
- float d=p_normal.dot(v);
+ real_t d=p_normal.dot(v);
if (i==0 || d > r_max)
r_max=d;
@@ -873,11 +873,11 @@ Vector3 FaceShapeSW::get_support(const Vector3& p_normal) const {
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
for (int i=0;i<3;i++) {
- float d=p_normal.dot(vertex[i]);
+ real_t d=p_normal.dot(vertex[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -907,11 +907,11 @@ void FaceShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supp
/** FIND SUPPORT VERTEX **/
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
for (int i=0;i<3;i++) {
- float d=n.dot(vertex[i]);
+ real_t d=n.dot(vertex[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -928,7 +928,7 @@ void FaceShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supp
continue;
// check if edge is valid as a support
- float dot=(vertex[i]-vertex[nx]).normalized().dot(n);
+ real_t dot=(vertex[i]-vertex[nx]).normalized().dot(n);
dot=ABS(dot);
if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD) {
@@ -957,7 +957,7 @@ bool FaceShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,
return c;
}
-Vector3 FaceShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 FaceShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(); // Sorry, but i don't think anyone cares, FaceShape!
@@ -1003,7 +1003,7 @@ void ConcavePolygonShapeSW::project_range(const Vector3& p_normal, const Transfo
for (int i=0;i<count;i++) {
- float d=p_normal.dot( p_transform.xform( vptr[i] ) );
+ real_t d=p_normal.dot( p_transform.xform( vptr[i] ) );
if (i==0 || d > r_max)
r_max=d;
@@ -1026,11 +1026,11 @@ Vector3 ConcavePolygonShapeSW::get_support(const Vector3& p_normal) const {
Vector3 n=p_normal;
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
for (int i=0;i<count;i++) {
- float d=n.dot(vptr[i]);
+ real_t d=n.dot(vptr[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -1080,7 +1080,7 @@ void ConcavePolygonShapeSW::_cull_segment(int p_idx,_SegmentCullParams *p_params
&res)) {
- float d=p_params->dir.dot(res) - p_params->dir.dot(p_params->from);
+ real_t d=p_params->dir.dot(res) - p_params->dir.dot(p_params->from);
//TODO, seems segmen/triangle intersection is broken :(
if (d>0 && d<p_params->min_d) {
@@ -1206,7 +1206,7 @@ void ConcavePolygonShapeSW::cull(const Rect3& p_local_aabb,Callback p_callback,v
}
-Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
Vector3 extents=get_aabb().size*0.5;
@@ -1555,7 +1555,7 @@ ConcavePolygonShapeSW::ConcavePolygonShapeSW() {
/* HEIGHT MAP SHAPE */
-PoolVector<float> HeightMapShapeSW::get_heights() const {
+PoolVector<real_t> HeightMapShapeSW::get_heights() const {
return heights;
}
@@ -1567,7 +1567,7 @@ int HeightMapShapeSW::get_depth() const {
return depth;
}
-float HeightMapShapeSW::get_cell_size() const {
+real_t HeightMapShapeSW::get_cell_size() const {
return cell_size;
}
@@ -1602,7 +1602,7 @@ void HeightMapShapeSW::cull(const Rect3& p_local_aabb,Callback p_callback,void*
}
-Vector3 HeightMapShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
@@ -1631,7 +1631,7 @@ void HeightMapShapeSW::_setup(PoolVector<real_t> p_heights,int p_width,int p_dep
for(int j=0;j<width;j++) {
- float h = r[i*width+j];
+ real_t h = r[i*width+j];
Vector3 pos( j*cell_size, h, i*cell_size );
if (i==0 || j==0)
@@ -1657,8 +1657,8 @@ void HeightMapShapeSW::set_data(const Variant& p_data) {
int width=d["width"];
int depth=d["depth"];
- float cell_size=d["cell_size"];
- PoolVector<float> heights=d["heights"];
+ real_t cell_size=d["cell_size"];
+ PoolVector<real_t> heights=d["heights"];
ERR_FAIL_COND( width<= 0);
ERR_FAIL_COND( depth<= 0);
diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h
index 919c681105..c8194ad755 100644
--- a/servers/physics/shape_sw.h
+++ b/servers/physics/shape_sw.h
@@ -35,8 +35,8 @@
/*
SHAPE_LINE, ///< plane:"plane"
-SHAPE_SEGMENT, ///< float:"length"
-SHAPE_CIRCLE, ///< float:"radius"
+SHAPE_SEGMENT, ///< real_t:"length"
+SHAPE_CIRCLE, ///< real_t:"radius"
SHAPE_RECTANGLE, ///< vec3:"extents"
SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
SHAPE_CONCAVE_POLYGON, ///< Vector3 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector3 array)
@@ -90,7 +90,7 @@ public:
virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const=0;
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_point, Vector3 &r_normal) const=0;
- virtual Vector3 get_moment_of_inertia(float p_mass) const=0;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const=0;
virtual void set_data(const Variant& p_data)=0;
virtual Variant get_data() const=0;
@@ -138,7 +138,7 @@ public:
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -148,12 +148,12 @@ public:
class RayShapeSW : public ShapeSW {
- float length;
+ real_t length;
- void _setup(float p_length);
+ void _setup(real_t p_length);
public:
- float get_length() const;
+ real_t get_length() const;
virtual real_t get_area() const { return 0.0; }
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_RAY; }
@@ -163,7 +163,7 @@ public:
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -189,7 +189,7 @@ public:
virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const;
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -213,7 +213,7 @@ public:
virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const;
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -242,7 +242,7 @@ public:
virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const;
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -266,7 +266,7 @@ public:
virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const;
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -349,7 +349,7 @@ public:
virtual void cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -364,18 +364,18 @@ struct HeightMapShapeSW : public ConcaveShapeSW {
PoolVector<real_t> heights;
int width;
int depth;
- float cell_size;
+ real_t cell_size;
//void _cull_segment(int p_idx,_SegmentCullParams *p_params) const;
//void _cull(int p_idx,_CullParams *p_params) const;
- void _setup(PoolVector<float> p_heights,int p_width,int p_depth,float p_cell_size);
+ void _setup(PoolVector<real_t> p_heights,int p_width,int p_depth,real_t p_cell_size);
public:
PoolVector<real_t> get_heights() const;
int get_width() const;
int get_depth() const;
- float get_cell_size() const;
+ real_t get_cell_size() const;
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_HEIGHTMAP; }
@@ -385,7 +385,7 @@ public:
virtual void cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -409,7 +409,7 @@ struct FaceShapeSW : public ShapeSW {
virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const;
bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- Vector3 get_moment_of_inertia(float p_mass) const;
+ Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data) {}
virtual Variant get_data() const { return Variant(); }
@@ -450,7 +450,7 @@ struct MotionShapeSW : public ShapeSW {
virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const { r_amount=0; }
bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const { return false; }
- Vector3 get_moment_of_inertia(float p_mass) const { return Vector3(); }
+ Vector3 get_moment_of_inertia(real_t p_mass) const { return Vector3(); }
virtual void set_data(const Variant& p_data) {}
virtual Variant get_data() const { return Variant(); }
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index 04b8f5b68d..0bc11041de 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -138,7 +138,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3& p_from, const Vecto
}
-int PhysicsDirectSpaceStateSW::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_layer_mask,uint32_t p_object_type_mask) {
+int PhysicsDirectSpaceStateSW::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_layer_mask,uint32_t p_object_type_mask) {
if (p_result_max<=0)
return 0;
@@ -193,7 +193,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Transfo
}
-bool PhysicsDirectSpaceStateSW::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,uint32_t p_layer_mask,uint32_t p_object_type_mask,ShapeRestInfo *r_info) {
+bool PhysicsDirectSpaceStateSW::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,uint32_t p_layer_mask,uint32_t p_object_type_mask,ShapeRestInfo *r_info) {
@@ -211,8 +211,8 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform&
int amount = space->broadphase->cull_aabb(aabb,space->intersection_query_results,SpaceSW::INTERSECTION_QUERY_MAX,space->intersection_query_subindex_results);
- float best_safe=1;
- float best_unsafe=1;
+ real_t best_safe=1;
+ real_t best_unsafe=1;
Transform xform_inv = p_xform.affine_inverse();
MotionShapeSW mshape;
@@ -264,13 +264,13 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform&
//just do kinematic solving
- float low=0;
- float hi=1;
+ real_t low=0;
+ real_t hi=1;
Vector3 mnormal=p_motion.normalized();
for(int i=0;i<8;i++) { //steps should be customizable..
- float ofs = (low+hi)*0.5;
+ real_t ofs = (low+hi)*0.5;
Vector3 sep=mnormal; //important optimization for this to work fast enough
@@ -323,7 +323,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform&
return true;
}
-bool PhysicsDirectSpaceStateSW::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_layer_mask,uint32_t p_object_type_mask){
+bool PhysicsDirectSpaceStateSW::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_layer_mask,uint32_t p_object_type_mask){
if (p_result_max<=0)
return 0;
@@ -388,7 +388,7 @@ struct _RestCallbackData {
int best_shape;
Vector3 best_contact;
Vector3 best_normal;
- float best_len;
+ real_t best_len;
};
static void _rest_cbk_result(const Vector3& p_point_A,const Vector3& p_point_B,void *p_userdata) {
@@ -397,7 +397,7 @@ static void _rest_cbk_result(const Vector3& p_point_A,const Vector3& p_point_B,v
_RestCallbackData *rd=(_RestCallbackData*)p_userdata;
Vector3 contact_rel = p_point_B - p_point_A;
- float len = contact_rel.length();
+ real_t len = contact_rel.length();
if (len <= rd->best_len)
return;
@@ -408,7 +408,7 @@ static void _rest_cbk_result(const Vector3& p_point_A,const Vector3& p_point_B,v
rd->best_shape=rd->shape;
}
-bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform& p_shape_xform,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
+bool PhysicsDirectSpaceStateSW::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_layer_mask,uint32_t p_object_type_mask) {
ShapeSW *shape = static_cast<PhysicsServerSW*>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h
index 3ec01c9205..208831914f 100644
--- a/servers/physics/space_sw.h
+++ b/servers/physics/space_sw.h
@@ -48,10 +48,10 @@ public:
SpaceSW *space;
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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION,bool p_pick_ray=false);
- 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
- 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION,ShapeRestInfo *r_info=NULL);
- 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
- 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
+ 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
+ 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION,ShapeRestInfo *r_info=NULL);
+ 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
+ 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
PhysicsDirectSpaceStateSW();
};
@@ -105,10 +105,10 @@ private:
CollisionObjectSW *intersection_query_results[INTERSECTION_QUERY_MAX];
int intersection_query_subindex_results[INTERSECTION_QUERY_MAX];
- float body_linear_velocity_sleep_threshold;
- float body_angular_velocity_sleep_threshold;
- float body_time_to_sleep;
- float body_angular_velocity_damp_ratio;
+ real_t body_linear_velocity_sleep_threshold;
+ real_t body_angular_velocity_sleep_threshold;
+ real_t body_time_to_sleep;
+ real_t body_angular_velocity_damp_ratio;
bool locked;
diff --git a/servers/physics/step_sw.cpp b/servers/physics/step_sw.cpp
index 30ee33a7de..0bd5a874ea 100644
--- a/servers/physics/step_sw.cpp
+++ b/servers/physics/step_sw.cpp
@@ -58,7 +58,7 @@ void StepSW::_populate_island(BodySW* p_body,BodySW** p_island,ConstraintSW **p_
}
}
-void StepSW::_setup_island(ConstraintSW *p_island,float p_delta) {
+void StepSW::_setup_island(ConstraintSW *p_island,real_t p_delta) {
ConstraintSW *ci=p_island;
while(ci) {
@@ -68,7 +68,7 @@ void StepSW::_setup_island(ConstraintSW *p_island,float p_delta) {
}
}
-void StepSW::_solve_island(ConstraintSW *p_island,int p_iterations,float p_delta){
+void StepSW::_solve_island(ConstraintSW *p_island,int p_iterations,real_t p_delta){
int at_priority=1;
@@ -107,7 +107,7 @@ void StepSW::_solve_island(ConstraintSW *p_island,int p_iterations,float p_delta
}
-void StepSW::_check_suspend(BodySW *p_island,float p_delta) {
+void StepSW::_check_suspend(BodySW *p_island,real_t p_delta) {
bool can_sleep=true;
@@ -145,7 +145,7 @@ void StepSW::_check_suspend(BodySW *p_island,float p_delta) {
}
}
-void StepSW::step(SpaceSW* p_space,float p_delta,int p_iterations) {
+void StepSW::step(SpaceSW* p_space,real_t p_delta,int p_iterations) {
p_space->lock(); // can't access space during this
diff --git a/servers/physics/step_sw.h b/servers/physics/step_sw.h
index 2f67b3c8df..7048a76937 100644
--- a/servers/physics/step_sw.h
+++ b/servers/physics/step_sw.h
@@ -36,12 +36,12 @@ class StepSW {
uint64_t _step;
void _populate_island(BodySW* p_body,BodySW** p_island,ConstraintSW **p_constraint_island);
- void _setup_island(ConstraintSW *p_island,float p_delta);
- void _solve_island(ConstraintSW *p_island,int p_iterations,float p_delta);
- void _check_suspend(BodySW *p_island,float p_delta);
+ void _setup_island(ConstraintSW *p_island,real_t p_delta);
+ void _solve_island(ConstraintSW *p_island,int p_iterations,real_t p_delta);
+ void _check_suspend(BodySW *p_island,real_t p_delta);
public:
- void step(SpaceSW* p_space,float p_delta,int p_iterations);
+ void step(SpaceSW* p_space,real_t p_delta,int p_iterations);
StepSW();
};