Rename slips_on_slope to slide_on_slope

Also added some precision to the documentation.
This commit is contained in:
PouleyKetchoupp 2021-08-19 11:02:40 -07:00
parent d9720d4395
commit aa4791735d
14 changed files with 48 additions and 46 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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() :

View file

@ -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;

View file

@ -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() :

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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; }

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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 *************/

View file

@ -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; }

View file

@ -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;
}
}