Skip to content

Commit

Permalink
Compile certain CanvasItem._edit_*() functions with DEBUG_ENABLED
Browse files Browse the repository at this point in the history
  • Loading branch information
YeldhamDev committed Nov 2, 2024
1 parent c6c464c commit 58e79bf
Show file tree
Hide file tree
Showing 41 changed files with 155 additions and 121 deletions.
6 changes: 4 additions & 2 deletions scene/2d/animated_sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Point2 AnimatedSprite2D::_edit_get_pivot() const {
bool AnimatedSprite2D::_edit_use_pivot() const {
return true;
}
#endif // TOOLS_ENABLED

#ifdef DEBUG_ENABLED
Rect2 AnimatedSprite2D::_edit_get_rect() const {
return _get_rect();
}
Expand All @@ -75,7 +77,7 @@ bool AnimatedSprite2D::_edit_use_rect() const {
}
return t.is_valid();
}
#endif
#endif // DEBUG_ENABLED

Rect2 AnimatedSprite2D::get_anchorable_rect() const {
return _get_rect();
Expand Down Expand Up @@ -593,7 +595,7 @@ void AnimatedSprite2D::get_argument_options(const StringName &p_function, int p_
}
Node2D::get_argument_options(p_function, p_idx, r_options);
}
#endif
#endif // TOOLS_ENABLED

#ifndef DISABLE_DEPRECATED
bool AnimatedSprite2D::_set(const StringName &p_name, const Variant &p_value) {
Expand Down
9 changes: 6 additions & 3 deletions scene/2d/animated_sprite_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class AnimatedSprite2D : public Node2D {
protected:
#ifndef DISABLE_DEPRECATED
bool _set(const StringName &p_name, const Variant &p_value);
#endif
#endif // DISABLE_DEPRECATED
static void _bind_methods();
void _notification(int p_what);
void _validate_property(PropertyInfo &p_property) const;
Expand All @@ -79,9 +79,12 @@ class AnimatedSprite2D : public Node2D {
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
virtual Point2 _edit_get_pivot() const override;
virtual bool _edit_use_pivot() const override;
#endif // TOOLS_ENABLED

#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED

virtual Rect2 get_anchorable_rect() const override;

Expand Down Expand Up @@ -129,7 +132,7 @@ class AnimatedSprite2D : public Node2D {

#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
#endif // TOOLS_ENABLED

AnimatedSprite2D();
};
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/back_buffer_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ void BackBufferCopy::_update_copy_mode() {
}
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 BackBufferCopy::_edit_get_rect() const {
return rect;
}

bool BackBufferCopy::_edit_use_rect() const {
return true;
}
#endif
#endif // DEBUG_ENABLED

Rect2 BackBufferCopy::get_anchorable_rect() const {
return rect;
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/back_buffer_copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class BackBufferCopy : public Node2D {
void _validate_property(PropertyInfo &p_property) const;

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED

void set_rect(const Rect2 &p_rect);
Rect2 get_rect() const;
Expand Down
7 changes: 4 additions & 3 deletions scene/2d/light_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void Light2D::_update_light_visibility() {
if (editor_only) {
editor_ok = false;
}
#endif
#endif // TOOLS_ENABLED

RS::get_singleton()->canvas_light_set_enabled(canvas_light, enabled && is_visible_in_tree() && editor_ok);
}
Expand Down Expand Up @@ -343,7 +343,6 @@ Light2D::~Light2D() {
//////////////////////////////

#ifdef TOOLS_ENABLED

Dictionary PointLight2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = get_texture_offset();
Expand All @@ -367,7 +366,9 @@ Point2 PointLight2D::_edit_get_pivot() const {
bool PointLight2D::_edit_use_pivot() const {
return true;
}
#endif // TOOLS_ENABLED

#ifdef DEBUG_ENABLED
Rect2 PointLight2D::_edit_get_rect() const {
if (texture.is_null()) {
return Rect2();
Expand All @@ -380,7 +381,7 @@ Rect2 PointLight2D::_edit_get_rect() const {
bool PointLight2D::_edit_use_rect() const {
return !texture.is_null();
}
#endif
#endif // DEBUG_ENABLED

Rect2 PointLight2D::get_anchorable_rect() const {
if (texture.is_null()) {
Expand Down
5 changes: 4 additions & 1 deletion scene/2d/light_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ class PointLight2D : public Light2D {
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
virtual Point2 _edit_get_pivot() const override;
virtual bool _edit_use_pivot() const override;
#endif // TOOLS_ENABLED

#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED

virtual Rect2 get_anchorable_rect() const override;

Expand Down
14 changes: 7 additions & 7 deletions scene/2d/light_occluder_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#define LINE_GRAB_WIDTH 8

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 OccluderPolygon2D::_edit_get_rect() const {
if (rect_cache_dirty) {
if (closed) {
Expand Down Expand Up @@ -83,7 +83,7 @@ bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double
return false;
}
}
#endif
#endif // DEBUG_ENABLED

void OccluderPolygon2D::set_polygon(const Vector<Vector2> &p_polygon) {
polygon = p_polygon;
Expand Down Expand Up @@ -156,7 +156,7 @@ OccluderPolygon2D::~OccluderPolygon2D() {
void LightOccluder2D::_poly_changed() {
#ifdef DEBUG_ENABLED
queue_redraw();
#endif
#endif // DEBUG_ENABLED
}

void LightOccluder2D::_physics_interpolated_changed() {
Expand Down Expand Up @@ -218,22 +218,22 @@ void LightOccluder2D::_notification(int p_what) {
}
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 LightOccluder2D::_edit_get_rect() const {
return occluder_polygon.is_valid() ? occluder_polygon->_edit_get_rect() : Rect2();
}

bool LightOccluder2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return occluder_polygon.is_valid() ? occluder_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
#endif
#endif // DEBUG_ENABLED

void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon) {
#ifdef DEBUG_ENABLED
if (occluder_polygon.is_valid()) {
occluder_polygon->disconnect_changed(callable_mp(this, &LightOccluder2D::_poly_changed));
}
#endif
#endif // DEBUG_ENABLED
occluder_polygon = p_polygon;

if (occluder_polygon.is_valid()) {
Expand All @@ -247,7 +247,7 @@ void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polyg
occluder_polygon->connect_changed(callable_mp(this, &LightOccluder2D::_poly_changed));
}
queue_redraw();
#endif
#endif // DEBUG_ENABLED
}

Ref<OccluderPolygon2D> LightOccluder2D::get_occluder_polygon() const {
Expand Down
9 changes: 4 additions & 5 deletions scene/2d/light_occluder_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ class OccluderPolygon2D : public Resource {
static void _bind_methods();

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif

#endif // DEBUG_ENABLED
void set_polygon(const Vector<Vector2> &p_polygon);
Vector<Vector2> get_polygon() const;

Expand Down Expand Up @@ -93,10 +92,10 @@ class LightOccluder2D : public Node2D {
static void _bind_methods();

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#endif
#endif // DEBUG_ENABLED

void set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon);
Ref<OccluderPolygon2D> get_occluder_polygon() const;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/line_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Line2D::Line2D() {
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 Line2D::_edit_get_rect() const {
if (_points.size() == 0) {
return Rect2(0, 0, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/line_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Line2D : public Node2D {
LINE_TEXTURE_STRETCH
};

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/marker_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Marker2D::_draw_cross() {
draw_multiline_colors(points, colors);
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 Marker2D::_edit_get_rect() const {
real_t extents = get_gizmo_extents();
return Rect2(Point2(-extents, -extents), Size2(extents * 2, extents * 2));
Expand All @@ -70,7 +70,7 @@ Rect2 Marker2D::_edit_get_rect() const {
bool Marker2D::_edit_use_rect() const {
return false;
}
#endif
#endif // DEBUG_ENABLED

void Marker2D::_notification(int p_what) {
switch (p_what) {
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/marker_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class Marker2D : public Node2D {
static void _bind_methods();

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED

void set_gizmo_extents(real_t p_extents);
real_t get_gizmo_extents() const;
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/mesh_instance_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Ref<Texture2D> MeshInstance2D::get_texture() const {
return texture;
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 MeshInstance2D::_edit_get_rect() const {
if (mesh.is_valid()) {
AABB aabb = mesh->get_aabb();
Expand All @@ -101,7 +101,7 @@ Rect2 MeshInstance2D::_edit_get_rect() const {
bool MeshInstance2D::_edit_use_rect() const {
return mesh.is_valid();
}
#endif
#endif // DEBUG_ENABLED

MeshInstance2D::MeshInstance2D() {
}
4 changes: 2 additions & 2 deletions scene/2d/mesh_instance_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class MeshInstance2D : public Node2D {
static void _bind_methods();

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED

void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/multimesh_instance_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Ref<Texture2D> MultiMeshInstance2D::get_texture() const {
return texture;
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 MultiMeshInstance2D::_edit_get_rect() const {
if (multimesh.is_valid()) {
AABB aabb = multimesh->get_aabb();
Expand All @@ -93,7 +93,7 @@ Rect2 MultiMeshInstance2D::_edit_get_rect() const {

return Node2D::_edit_get_rect();
}
#endif
#endif // DEBUG_ENABLED

MultiMeshInstance2D::MultiMeshInstance2D() {
}
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/multimesh_instance_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class MultiMeshInstance2D : public Node2D {
static void _bind_methods();

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
#endif
#endif // DEBUG_ENABLED

void set_multimesh(const Ref<MultiMesh> &p_multimesh);
Ref<MultiMesh> get_multimesh() const;
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/navigation_link_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void NavigationLink2D::_notification(int p_what) {
}
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 NavigationLink2D::_edit_get_rect() const {
if (!is_inside_tree()) {
return Rect2();
Expand All @@ -152,7 +152,7 @@ bool NavigationLink2D::_edit_is_selected_on_click(const Point2 &p_point, double
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, segment);
return p_point.distance_to(closest_point) < p_tolerance;
}
#endif // TOOLS_ENABLED
#endif // DEBUG_ENABLED

RID NavigationLink2D::get_rid() const {
return link;
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/navigation_link_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class NavigationLink2D : public Node2D {
#endif // DISABLE_DEPRECATED

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#endif
#endif // DEBUG_ENABLED
RID get_rid() const;

void set_enabled(bool p_enabled);
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/navigation_region_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ RID NavigationRegion2D::get_region_rid() const {
return get_rid();
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 NavigationRegion2D::_edit_get_rect() const {
return navigation_polygon.is_valid() ? navigation_polygon->_edit_get_rect() : Rect2();
}

bool NavigationRegion2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return navigation_polygon.is_valid() ? navigation_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
#endif
#endif // DEBUG_ENABLED

void NavigationRegion2D::_notification(int p_what) {
switch (p_what) {
Expand Down
Loading

0 comments on commit 58e79bf

Please sign in to comment.