diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-08-14 09:36:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-14 09:36:16 +0200 |
commit | 59879447a395adc4ced2ee7e88b0ef1bcc32c82d (patch) | |
tree | a17c5dc4fddebd4379d57c3de0ba88a01638b87d /scene/resources | |
parent | f32c042f3e14a2de2f2d416ff35b0a3c80785e33 (diff) | |
parent | 8e3f71d75060c70745f541d5cab509f7bea690df (diff) |
Merge pull request #51636 from Calinou/rename-lineshape2d
Rename LineShape2D to WorldMarginShape2D
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/world_margin_shape_2d.cpp (renamed from scene/resources/line_shape_2d.cpp) | 36 | ||||
-rw-r--r-- | scene/resources/world_margin_shape_2d.h (renamed from scene/resources/line_shape_2d.h) | 16 |
2 files changed, 26 insertions, 26 deletions
diff --git a/scene/resources/line_shape_2d.cpp b/scene/resources/world_margin_shape_2d.cpp index d206f12287..3b43681528 100644 --- a/scene/resources/line_shape_2d.cpp +++ b/scene/resources/world_margin_shape_2d.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* line_shape_2d.cpp */ +/* world_margin_shape_2d.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "line_shape_2d.h" +#include "world_margin_shape_2d.h" #include "core/math/geometry_2d.h" #include "servers/physics_server_2d.h" #include "servers/rendering_server.h" -bool LineShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { +bool WorldMarginShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { Vector2 point = get_distance() * get_normal(); Vector2 l[2][2] = { { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 }, { point, point + get_normal() * 30 } }; @@ -48,7 +48,7 @@ bool LineShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tol return false; } -void LineShape2D::_update_shape() { +void WorldMarginShape2D::_update_shape() { Array arr; arr.push_back(normal); arr.push_back(distance); @@ -56,25 +56,25 @@ void LineShape2D::_update_shape() { emit_changed(); } -void LineShape2D::set_normal(const Vector2 &p_normal) { +void WorldMarginShape2D::set_normal(const Vector2 &p_normal) { normal = p_normal; _update_shape(); } -void LineShape2D::set_distance(real_t p_distance) { +void WorldMarginShape2D::set_distance(real_t p_distance) { distance = p_distance; _update_shape(); } -Vector2 LineShape2D::get_normal() const { +Vector2 WorldMarginShape2D::get_normal() const { return normal; } -real_t LineShape2D::get_distance() const { +real_t WorldMarginShape2D::get_distance() const { return distance; } -void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) { +void WorldMarginShape2D::draw(const RID &p_to_rid, const Color &p_color) { Vector2 point = get_distance() * get_normal(); Vector2 l1[2] = { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 }; @@ -83,7 +83,7 @@ void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) { RS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3); } -Rect2 LineShape2D::get_rect() const { +Rect2 WorldMarginShape2D::get_rect() const { Vector2 point = get_distance() * get_normal(); Vector2 l1[2] = { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 }; @@ -96,22 +96,22 @@ Rect2 LineShape2D::get_rect() const { return rect; } -real_t LineShape2D::get_enclosing_radius() const { +real_t WorldMarginShape2D::get_enclosing_radius() const { return distance; } -void LineShape2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_normal", "normal"), &LineShape2D::set_normal); - ClassDB::bind_method(D_METHOD("get_normal"), &LineShape2D::get_normal); +void WorldMarginShape2D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_normal", "normal"), &WorldMarginShape2D::set_normal); + ClassDB::bind_method(D_METHOD("get_normal"), &WorldMarginShape2D::get_normal); - ClassDB::bind_method(D_METHOD("set_distance", "distance"), &LineShape2D::set_distance); - ClassDB::bind_method(D_METHOD("get_distance"), &LineShape2D::get_distance); + ClassDB::bind_method(D_METHOD("set_distance", "distance"), &WorldMarginShape2D::set_distance); + ClassDB::bind_method(D_METHOD("get_distance"), &WorldMarginShape2D::get_distance); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "set_normal", "get_normal"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "distance"), "set_distance", "get_distance"); } -LineShape2D::LineShape2D() : - Shape2D(PhysicsServer2D::get_singleton()->line_shape_create()) { +WorldMarginShape2D::WorldMarginShape2D() : + Shape2D(PhysicsServer2D::get_singleton()->world_margin_shape_create()) { _update_shape(); } diff --git a/scene/resources/line_shape_2d.h b/scene/resources/world_margin_shape_2d.h index 210a1aa9e6..3c1d593ffe 100644 --- a/scene/resources/line_shape_2d.h +++ b/scene/resources/world_margin_shape_2d.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* line_shape_2d.h */ +/* world_margin_shape_2d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,15 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef LINE_SHAPE_2D_H -#define LINE_SHAPE_2D_H +#ifndef WORLD_MARGIN_SHAPE_2D_H +#define WORLD_MARGIN_SHAPE_2D_H #include "scene/resources/shape_2d.h" -class LineShape2D : public Shape2D { - GDCLASS(LineShape2D, Shape2D); +class WorldMarginShape2D : public Shape2D { + GDCLASS(WorldMarginShape2D, Shape2D); - // LineShape2D is often used for one-way platforms, where the normal pointing up makes sense. + // WorldMarginShape2D is often used for one-way platforms, where the normal pointing up makes sense. Vector2 normal = Vector2(0, -1); real_t distance = 0.0; @@ -58,7 +58,7 @@ public: virtual Rect2 get_rect() const override; virtual real_t get_enclosing_radius() const override; - LineShape2D(); + WorldMarginShape2D(); }; -#endif // LINE_SHAPE_2D_H +#endif // WORLD_MARGIN_SHAPE_2D_H |