summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/collision_object_2d.cpp4
-rw-r--r--scene/2d/collision_object_2d.h6
-rw-r--r--scene/2d/collision_polygon_2d.cpp6
-rw-r--r--scene/2d/collision_polygon_2d.h6
-rw-r--r--scene/2d/collision_shape_2d.cpp6
-rw-r--r--scene/2d/collision_shape_2d.h6
-rw-r--r--scene/2d/physics_body_2d.cpp24
-rw-r--r--scene/2d/physics_body_2d.h20
8 files changed, 39 insertions, 39 deletions
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index f0b007f843..c83ed36917 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -165,7 +165,7 @@ bool CollisionObject2D::is_shape_owner_one_way_collision_enabled(uint32_t p_owne
return shapes[p_owner].one_way_collision;
}
-void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owner, float p_margin) {
+void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owner, real_t p_margin) {
if (area) {
return; //not for areas
}
@@ -179,7 +179,7 @@ void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owne
}
}
-float CollisionObject2D::get_shape_owner_one_way_collision_margin(uint32_t p_owner) const {
+real_t CollisionObject2D::get_shape_owner_one_way_collision_margin(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), 0);
return shapes[p_owner].one_way_collision_margin;
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index a2112c27f4..1cfaeaf649 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -52,7 +52,7 @@ class CollisionObject2D : public Node2D {
Vector<Shape> shapes;
bool disabled;
bool one_way_collision;
- float one_way_collision_margin;
+ real_t one_way_collision_margin;
ShapeData() {
disabled = false;
@@ -97,8 +97,8 @@ public:
void shape_owner_set_one_way_collision(uint32_t p_owner, bool p_enable);
bool is_shape_owner_one_way_collision_enabled(uint32_t p_owner) const;
- void shape_owner_set_one_way_collision_margin(uint32_t p_owner, float p_margin);
- float get_shape_owner_one_way_collision_margin(uint32_t p_owner) const;
+ void shape_owner_set_one_way_collision_margin(uint32_t p_owner, real_t p_margin);
+ real_t get_shape_owner_one_way_collision_margin(uint32_t p_owner) const;
void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape);
int shape_owner_get_shape_count(uint32_t p_owner) const;
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 851e40cda6..505c0beb45 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -158,7 +158,7 @@ void CollisionPolygon2D::_notification(int p_what) {
Vector2 line_to(0, 20);
draw_line(Vector2(), line_to, dcol, 3);
Vector<Vector2> pts;
- float tsize = 8;
+ real_t tsize = 8;
pts.push_back(line_to + (Vector2(0, tsize)));
pts.push_back(line_to + (Vector2(Math_SQRT12 * tsize, 0)));
pts.push_back(line_to + (Vector2(-Math_SQRT12 * tsize, 0)));
@@ -275,14 +275,14 @@ bool CollisionPolygon2D::is_one_way_collision_enabled() const {
return one_way_collision;
}
-void CollisionPolygon2D::set_one_way_collision_margin(float p_margin) {
+void CollisionPolygon2D::set_one_way_collision_margin(real_t p_margin) {
one_way_collision_margin = p_margin;
if (parent) {
parent->shape_owner_set_one_way_collision_margin(owner_id, one_way_collision_margin);
}
}
-float CollisionPolygon2D::get_one_way_collision_margin() const {
+real_t CollisionPolygon2D::get_one_way_collision_margin() const {
return one_way_collision_margin;
}
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index caa5b2c3ec..9c9e6f8f62 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -53,7 +53,7 @@ protected:
CollisionObject2D *parent;
bool disabled;
bool one_way_collision;
- float one_way_collision_margin;
+ real_t one_way_collision_margin;
Vector<Vector<Vector2>> _decompose_in_convex();
@@ -86,8 +86,8 @@ public:
void set_one_way_collision(bool p_enable);
bool is_one_way_collision_enabled() const;
- void set_one_way_collision_margin(float p_margin);
- float get_one_way_collision_margin() const;
+ void set_one_way_collision_margin(real_t p_margin);
+ real_t get_one_way_collision_margin() const;
CollisionPolygon2D();
};
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index 37bed577ac..381c2ad29a 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -125,7 +125,7 @@ void CollisionShape2D::_notification(int p_what) {
Vector2 line_to(0, 20);
draw_line(Vector2(), line_to, draw_col, 2);
Vector<Vector2> pts;
- float tsize = 8;
+ real_t tsize = 8;
pts.push_back(line_to + (Vector2(0, tsize)));
pts.push_back(line_to + (Vector2(Math_SQRT12 * tsize, 0)));
pts.push_back(line_to + (Vector2(-Math_SQRT12 * tsize, 0)));
@@ -215,14 +215,14 @@ bool CollisionShape2D::is_one_way_collision_enabled() const {
return one_way_collision;
}
-void CollisionShape2D::set_one_way_collision_margin(float p_margin) {
+void CollisionShape2D::set_one_way_collision_margin(real_t p_margin) {
one_way_collision_margin = p_margin;
if (parent) {
parent->shape_owner_set_one_way_collision_margin(owner_id, one_way_collision_margin);
}
}
-float CollisionShape2D::get_one_way_collision_margin() const {
+real_t CollisionShape2D::get_one_way_collision_margin() const {
return one_way_collision_margin;
}
diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h
index 8a4d885393..17cc4187c9 100644
--- a/scene/2d/collision_shape_2d.h
+++ b/scene/2d/collision_shape_2d.h
@@ -45,7 +45,7 @@ class CollisionShape2D : public Node2D {
void _shape_changed();
bool disabled;
bool one_way_collision;
- float one_way_collision_margin;
+ real_t one_way_collision_margin;
void _update_in_shape_owner(bool p_xform_only = false);
@@ -69,8 +69,8 @@ public:
void set_one_way_collision(bool p_enable);
bool is_one_way_collision_enabled() const;
- void set_one_way_collision_margin(float p_margin);
- float get_one_way_collision_margin() const;
+ void set_one_way_collision_margin(real_t p_margin);
+ real_t get_one_way_collision_margin() const;
virtual String get_configuration_warning() const override;
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index a65009d072..ee625fb6f9 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -324,7 +324,7 @@ struct _RigidBody2DInOut {
int local_shape;
};
-bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
+bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
PhysicsServer2D::MotionResult *r = nullptr;
if (p_result.is_valid()) {
r = p_result->get_result_ptr();
@@ -611,7 +611,7 @@ void RigidBody2D::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_posit
PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_impulse, p_position);
}
-void RigidBody2D::apply_torque_impulse(float p_torque) {
+void RigidBody2D::apply_torque_impulse(real_t p_torque) {
PhysicsServer2D::get_singleton()->body_apply_torque_impulse(get_rid(), p_torque);
}
@@ -623,11 +623,11 @@ Vector2 RigidBody2D::get_applied_force() const {
return PhysicsServer2D::get_singleton()->body_get_applied_force(get_rid());
};
-void RigidBody2D::set_applied_torque(const float p_torque) {
+void RigidBody2D::set_applied_torque(const real_t p_torque) {
PhysicsServer2D::get_singleton()->body_set_applied_torque(get_rid(), p_torque);
};
-float RigidBody2D::get_applied_torque() const {
+real_t RigidBody2D::get_applied_torque() const {
return PhysicsServer2D::get_singleton()->body_get_applied_torque(get_rid());
};
@@ -639,7 +639,7 @@ void RigidBody2D::add_force(const Vector2 &p_force, const Vector2 &p_position) {
PhysicsServer2D::get_singleton()->body_add_force(get_rid(), p_force, p_position);
}
-void RigidBody2D::add_torque(const float p_torque) {
+void RigidBody2D::add_torque(const real_t p_torque) {
PhysicsServer2D::get_singleton()->body_add_torque(get_rid(), p_torque);
}
@@ -906,7 +906,7 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision
Vector2 recover;
int hits = PhysicsServer2D::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin);
int deepest = -1;
- float deepest_depth;
+ real_t deepest_depth;
for (int i = 0; i < hits; i++) {
if (deepest == -1 || sep_res[i].collision_depth > deepest_depth) {
deepest = i;
@@ -966,7 +966,7 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_
//so, if you pass 45 as limit, avoid numerical precision errors when angle is 45.
#define FLOOR_ANGLE_THRESHOLD 0.01
-Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, real_t p_floor_max_angle, bool p_infinite_inertia) {
Vector2 body_velocity = p_linear_velocity;
Vector2 body_velocity_normal = body_velocity.normalized();
Vector2 up_direction = p_up_direction.normalized();
@@ -1057,7 +1057,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
return body_velocity;
}
-Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, real_t p_floor_max_angle, bool p_infinite_inertia) {
Vector2 up_direction = p_up_direction.normalized();
bool was_on_floor = on_floor;
@@ -1123,11 +1123,11 @@ bool KinematicBody2D::test_move(const Transform2D &p_from, const Vector2 &p_moti
return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia, margin);
}
-void KinematicBody2D::set_safe_margin(float p_margin) {
+void KinematicBody2D::set_safe_margin(real_t p_margin) {
margin = p_margin;
}
-float KinematicBody2D::get_safe_margin() const {
+real_t KinematicBody2D::get_safe_margin() const {
return margin;
}
@@ -1219,8 +1219,8 @@ void KinematicBody2D::_notification(int p_what) {
void KinematicBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody2D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((real_t)45.0)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((real_t)45.0)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody2D::test_move, DEFVAL(true));
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 159f73b269..b2a4aed019 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -176,7 +176,7 @@ private:
void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape);
void _direct_state_changed(Object *p_state);
- bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
+ bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, real_t p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
protected:
void _notification(int p_what);
@@ -232,17 +232,17 @@ public:
void apply_central_impulse(const Vector2 &p_impulse);
void apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position = Vector2());
- void apply_torque_impulse(float p_torque);
+ void apply_torque_impulse(real_t p_torque);
void set_applied_force(const Vector2 &p_force);
Vector2 get_applied_force() const;
- void set_applied_torque(const float p_torque);
- float get_applied_torque() const;
+ void set_applied_torque(const real_t p_torque);
+ real_t get_applied_torque() const;
void add_central_force(const Vector2 &p_force);
void add_force(const Vector2 &p_force, const Vector2 &p_position = Vector2());
- void add_torque(float p_torque);
+ void add_torque(real_t p_torque);
TypedArray<Node2D> get_colliding_bodies() const; //function for script
@@ -276,7 +276,7 @@ public:
};
private:
- float margin;
+ real_t margin;
Vector2 floor_normal;
Vector2 floor_velocity;
@@ -309,11 +309,11 @@ public:
bool separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision);
- void set_safe_margin(float p_margin);
- float get_safe_margin() const;
+ void set_safe_margin(real_t p_margin);
+ real_t get_safe_margin() const;
- Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
- Vector2 move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45), bool p_infinite_inertia = true);
+ Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, real_t p_floor_max_angle = Math::deg2rad((real_t)45.0), bool p_infinite_inertia = true);
+ Vector2 move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction = Vector2(0, 0), bool p_stop_on_slope = false, int p_max_slides = 4, real_t p_floor_max_angle = Math::deg2rad((real_t)45.0), bool p_infinite_inertia = true);
bool is_on_floor() const;
bool is_on_wall() const;
bool is_on_ceiling() const;