summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-08-19 11:02:40 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-08-24 17:34:55 -0700
commitaa4791735d2fe92d747a39529aebb410f96cf38f (patch)
tree8052f9cb555e0ebd4bd1dde05c6130b58c58c768
parentd9720d439545792bd742645f3c6e3f7c29327aa8 (diff)
Rename slips_on_slope to slide_on_slope
Also added some precision to the documentation.
-rw-r--r--doc/classes/RayShape2D.xml5
-rw-r--r--doc/classes/RayShape3D.xml5
-rw-r--r--scene/resources/ray_shape_2d.cpp16
-rw-r--r--scene/resources/ray_shape_2d.h6
-rw-r--r--scene/resources/ray_shape_3d.cpp16
-rw-r--r--scene/resources/ray_shape_3d.h6
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.cpp2
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp4
-rw-r--r--servers/physics_2d/shape_2d_sw.h4
-rw-r--r--servers/physics_2d/space_2d_sw.cpp4
-rw-r--r--servers/physics_3d/collision_solver_3d_sw.cpp2
-rw-r--r--servers/physics_3d/shape_3d_sw.cpp14
-rw-r--r--servers/physics_3d/shape_3d_sw.h6
-rw-r--r--servers/physics_3d/space_3d_sw.cpp4
14 files changed, 48 insertions, 46 deletions
diff --git a/doc/classes/RayShape2D.xml b/doc/classes/RayShape2D.xml
index 432c650074..50b89a0922 100644
--- a/doc/classes/RayShape2D.xml
+++ b/doc/classes/RayShape2D.xml
@@ -14,8 +14,9 @@
<member name="length" type="float" setter="set_length" getter="get_length" default="20.0">
The ray's length.
</member>
- <member name="slips_on_slope" type="bool" setter="set_slips_on_slope" getter="get_slips_on_slope" default="false">
- If [code]true[/code], allow the shape to return the correct normal.
+ <member name="slide_on_slope" type="bool" setter="set_slide_on_slope" getter="get_slide_on_slope" default="false">
+ If [code]false[/code] (default), the shape always separates and returns a normal along its own direction.
+ If [code]true[/code], the shape can return the correct normal and separate in any direction, allowing sliding motion on slopes.
</member>
</members>
<constants>
diff --git a/doc/classes/RayShape3D.xml b/doc/classes/RayShape3D.xml
index 9839044c30..e0b19e1a44 100644
--- a/doc/classes/RayShape3D.xml
+++ b/doc/classes/RayShape3D.xml
@@ -14,8 +14,9 @@
<member name="length" type="float" setter="set_length" getter="get_length" default="1.0">
The ray's length.
</member>
- <member name="slips_on_slope" type="bool" setter="set_slips_on_slope" getter="get_slips_on_slope" default="false">
- If [code]true[/code], allow the shape to return the correct normal.
+ <member name="slide_on_slope" type="bool" setter="set_slide_on_slope" getter="get_slide_on_slope" default="false">
+ If [code]false[/code] (default), the shape always separates and returns a normal along its own direction.
+ If [code]true[/code], the shape can return the correct normal and separate in any direction, allowing sliding motion on slopes.
</member>
</members>
<constants>
diff --git a/scene/resources/ray_shape_2d.cpp b/scene/resources/ray_shape_2d.cpp
index fb8f4b9985..2390a13bfa 100644
--- a/scene/resources/ray_shape_2d.cpp
+++ b/scene/resources/ray_shape_2d.cpp
@@ -36,7 +36,7 @@
void RayShape2D::_update_shape() {
Dictionary d;
d["length"] = length;
- d["slips_on_slope"] = slips_on_slope;
+ d["slide_on_slope"] = slide_on_slope;
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), d);
emit_changed();
}
@@ -88,11 +88,11 @@ void RayShape2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape2D::set_length);
ClassDB::bind_method(D_METHOD("get_length"), &RayShape2D::get_length);
- ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape2D::set_slips_on_slope);
- ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape2D::get_slips_on_slope);
+ ClassDB::bind_method(D_METHOD("set_slide_on_slope", "active"), &RayShape2D::set_slide_on_slope);
+ ClassDB::bind_method(D_METHOD("get_slide_on_slope"), &RayShape2D::get_slide_on_slope);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length"), "set_length", "get_length");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slide_on_slope"), "set_slide_on_slope", "get_slide_on_slope");
}
void RayShape2D::set_length(real_t p_length) {
@@ -104,13 +104,13 @@ real_t RayShape2D::get_length() const {
return length;
}
-void RayShape2D::set_slips_on_slope(bool p_active) {
- slips_on_slope = p_active;
+void RayShape2D::set_slide_on_slope(bool p_active) {
+ slide_on_slope = p_active;
_update_shape();
}
-bool RayShape2D::get_slips_on_slope() const {
- return slips_on_slope;
+bool RayShape2D::get_slide_on_slope() const {
+ return slide_on_slope;
}
RayShape2D::RayShape2D() :
diff --git a/scene/resources/ray_shape_2d.h b/scene/resources/ray_shape_2d.h
index 56ecfa2722..0895605ddf 100644
--- a/scene/resources/ray_shape_2d.h
+++ b/scene/resources/ray_shape_2d.h
@@ -37,7 +37,7 @@ class RayShape2D : public Shape2D {
GDCLASS(RayShape2D, Shape2D);
real_t length = 20.0;
- bool slips_on_slope = false;
+ bool slide_on_slope = false;
void _update_shape();
@@ -48,8 +48,8 @@ public:
void set_length(real_t p_length);
real_t get_length() const;
- void set_slips_on_slope(bool p_active);
- bool get_slips_on_slope() const;
+ void set_slide_on_slope(bool p_active);
+ bool get_slide_on_slope() const;
virtual void draw(const RID &p_to_rid, const Color &p_color) override;
virtual Rect2 get_rect() const override;
diff --git a/scene/resources/ray_shape_3d.cpp b/scene/resources/ray_shape_3d.cpp
index 5446b4daab..5d73fb8d80 100644
--- a/scene/resources/ray_shape_3d.cpp
+++ b/scene/resources/ray_shape_3d.cpp
@@ -47,7 +47,7 @@ real_t RayShape3D::get_enclosing_radius() const {
void RayShape3D::_update_shape() {
Dictionary d;
d["length"] = length;
- d["slips_on_slope"] = slips_on_slope;
+ d["slide_on_slope"] = slide_on_slope;
PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d);
Shape3D::_update_shape();
}
@@ -62,25 +62,25 @@ float RayShape3D::get_length() const {
return length;
}
-void RayShape3D::set_slips_on_slope(bool p_active) {
- slips_on_slope = p_active;
+void RayShape3D::set_slide_on_slope(bool p_active) {
+ slide_on_slope = p_active;
_update_shape();
notify_change_to_owners();
}
-bool RayShape3D::get_slips_on_slope() const {
- return slips_on_slope;
+bool RayShape3D::get_slide_on_slope() const {
+ return slide_on_slope;
}
void RayShape3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape3D::set_length);
ClassDB::bind_method(D_METHOD("get_length"), &RayShape3D::get_length);
- ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape3D::set_slips_on_slope);
- ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape3D::get_slips_on_slope);
+ ClassDB::bind_method(D_METHOD("set_slide_on_slope", "active"), &RayShape3D::set_slide_on_slope);
+ ClassDB::bind_method(D_METHOD("get_slide_on_slope"), &RayShape3D::get_slide_on_slope);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length", PROPERTY_HINT_RANGE, "0,4096,0.001"), "set_length", "get_length");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slide_on_slope"), "set_slide_on_slope", "get_slide_on_slope");
}
RayShape3D::RayShape3D() :
diff --git a/scene/resources/ray_shape_3d.h b/scene/resources/ray_shape_3d.h
index 2da6311321..5369408185 100644
--- a/scene/resources/ray_shape_3d.h
+++ b/scene/resources/ray_shape_3d.h
@@ -35,7 +35,7 @@
class RayShape3D : public Shape3D {
GDCLASS(RayShape3D, Shape3D);
float length = 1.0;
- bool slips_on_slope = false;
+ bool slide_on_slope = false;
protected:
static void _bind_methods();
@@ -45,8 +45,8 @@ public:
void set_length(float p_length);
float get_length() const;
- void set_slips_on_slope(bool p_active);
- bool get_slips_on_slope() const;
+ void set_slide_on_slope(bool p_active);
+ bool get_slide_on_slope() const;
virtual Vector<Vector3> get_debug_mesh_lines() const override;
virtual real_t get_enclosing_radius() const override;
diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp
index 34c94150e2..5337c8af56 100644
--- a/servers/physics_2d/collision_solver_2d_sw.cpp
+++ b/servers/physics_2d/collision_solver_2d_sw.cpp
@@ -117,7 +117,7 @@ bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A, const Vector
}
Vector2 support_B = p_transform_B.xform(p);
- if (ray->get_slips_on_slope()) {
+ if (ray->get_slide_on_slope()) {
Vector2 global_n = invb.basis_xform_inv(n).normalized();
support_B = support_A + (support_B - support_A).length() * global_n;
}
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index a82f0c2e6f..dae5669488 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -168,14 +168,14 @@ real_t RayShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale)
void RayShape2DSW::set_data(const Variant &p_data) {
Dictionary d = p_data;
length = d["length"];
- slips_on_slope = d["slips_on_slope"];
+ slide_on_slope = d["slide_on_slope"];
configure(Rect2(0, 0, 0.001, length));
}
Variant RayShape2DSW::get_data() const {
Dictionary d;
d["length"] = length;
- d["slips_on_slope"] = slips_on_slope;
+ d["slide_on_slope"] = slide_on_slope;
return d;
}
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index 6813e25a0b..541d35dae9 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -181,11 +181,11 @@ public:
class RayShape2DSW : public Shape2DSW {
real_t length;
- bool slips_on_slope;
+ bool slide_on_slope;
public:
_FORCE_INLINE_ real_t get_length() const { return length; }
- _FORCE_INLINE_ bool get_slips_on_slope() const { return slips_on_slope; }
+ _FORCE_INLINE_ bool get_slide_on_slope() const { return slide_on_slope; }
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_RAY; }
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 169c419b3b..92b87cea23 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -730,8 +730,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
// Colliding separation rays allows to properly snap to the ground,
// otherwise it's not needed in regular motion.
if (!p_collide_separation_ray && (body_shape->get_type() == PhysicsServer2D::SHAPE_RAY)) {
- // When slips on slope is on, separation ray shape acts like a regular shape.
- if (!static_cast<RayShape2DSW *>(body_shape)->get_slips_on_slope()) {
+ // When slide on slope is on, separation ray shape acts like a regular shape.
+ if (!static_cast<RayShape2DSW *>(body_shape)->get_slide_on_slope()) {
continue;
}
}
diff --git a/servers/physics_3d/collision_solver_3d_sw.cpp b/servers/physics_3d/collision_solver_3d_sw.cpp
index 8803b355d4..4a6a07534b 100644
--- a/servers/physics_3d/collision_solver_3d_sw.cpp
+++ b/servers/physics_3d/collision_solver_3d_sw.cpp
@@ -117,7 +117,7 @@ bool CollisionSolver3DSW::solve_ray(const Shape3DSW *p_shape_A, const Transform3
}
Vector3 support_B = p_transform_B.xform(p);
- if (ray->get_slips_on_slope()) {
+ if (ray->get_slide_on_slope()) {
Vector3 global_n = ai.basis.xform_inv(n).normalized();
support_B = support_A + (support_B - support_A).length() * global_n;
}
diff --git a/servers/physics_3d/shape_3d_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp
index 42a0fb32b2..fcc97f56a3 100644
--- a/servers/physics_3d/shape_3d_sw.cpp
+++ b/servers/physics_3d/shape_3d_sw.cpp
@@ -170,8 +170,8 @@ real_t RayShape3DSW::get_length() const {
return length;
}
-bool RayShape3DSW::get_slips_on_slope() const {
- return slips_on_slope;
+bool RayShape3DSW::get_slide_on_slope() const {
+ return slide_on_slope;
}
void RayShape3DSW::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {
@@ -226,27 +226,27 @@ Vector3 RayShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3();
}
-void RayShape3DSW::_setup(real_t p_length, bool p_slips_on_slope) {
+void RayShape3DSW::_setup(real_t p_length, bool p_slide_on_slope) {
length = p_length;
- slips_on_slope = p_slips_on_slope;
+ slide_on_slope = p_slide_on_slope;
configure(AABB(Vector3(0, 0, 0), Vector3(0.1, 0.1, length)));
}
void RayShape3DSW::set_data(const Variant &p_data) {
Dictionary d = p_data;
- _setup(d["length"], d["slips_on_slope"]);
+ _setup(d["length"], d["slide_on_slope"]);
}
Variant RayShape3DSW::get_data() const {
Dictionary d;
d["length"] = length;
- d["slips_on_slope"] = slips_on_slope;
+ d["slide_on_slope"] = slide_on_slope;
return d;
}
RayShape3DSW::RayShape3DSW() {
length = 1;
- slips_on_slope = false;
+ slide_on_slope = false;
}
/********** SPHERE *************/
diff --git a/servers/physics_3d/shape_3d_sw.h b/servers/physics_3d/shape_3d_sw.h
index 9f18b83f07..a693288f7e 100644
--- a/servers/physics_3d/shape_3d_sw.h
+++ b/servers/physics_3d/shape_3d_sw.h
@@ -136,13 +136,13 @@ public:
class RayShape3DSW : public Shape3DSW {
real_t length;
- bool slips_on_slope;
+ bool slide_on_slope;
- void _setup(real_t p_length, bool p_slips_on_slope);
+ void _setup(real_t p_length, bool p_slide_on_slope);
public:
real_t get_length() const;
- bool get_slips_on_slope() const;
+ bool get_slide_on_slope() const;
virtual real_t get_area() const { return 0.0; }
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_RAY; }
diff --git a/servers/physics_3d/space_3d_sw.cpp b/servers/physics_3d/space_3d_sw.cpp
index 7ed17d6284..4ec03529cf 100644
--- a/servers/physics_3d/space_3d_sw.cpp
+++ b/servers/physics_3d/space_3d_sw.cpp
@@ -719,8 +719,8 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co
// Colliding separation rays allows to properly snap to the ground,
// otherwise it's not needed in regular motion.
if (!p_collide_separation_ray && (body_shape->get_type() == PhysicsServer3D::SHAPE_RAY)) {
- // When slips on slope is on, separation ray shape acts like a regular shape.
- if (!static_cast<RayShape3DSW *>(body_shape)->get_slips_on_slope()) {
+ // When slide on slope is on, separation ray shape acts like a regular shape.
+ if (!static_cast<RayShape3DSW *>(body_shape)->get_slide_on_slope()) {
continue;
}
}