Skip to content

Commit df2b117

Browse files
committed
Merge pull request godotengine#100317 from TCROC/fix-collision-shape-debug-color-breaks-gdextension
Fix collision shape debug color breaking GDExtension
2 parents e9cebfa + f0c077d commit df2b117

File tree

6 files changed

+11
-24
lines changed

6 files changed

+11
-24
lines changed

scene/2d/physics/collision_shape_2d.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ real_t CollisionShape2D::get_one_way_collision_margin() const {
227227
return one_way_collision_margin;
228228
}
229229

230-
#ifdef DEBUG_ENABLED
231-
232230
Color CollisionShape2D::_get_default_debug_color() const {
233231
const SceneTree *st = SceneTree::get_singleton();
234232
return st ? st->get_debug_collisions_color() : Color(0.0, 0.0, 0.0, 0.0);
@@ -247,6 +245,8 @@ Color CollisionShape2D::get_debug_color() const {
247245
return debug_color;
248246
}
249247

248+
#ifdef DEBUG_ENABLED
249+
250250
bool CollisionShape2D::_property_can_revert(const StringName &p_name) const {
251251
if (p_name == "debug_color") {
252252
return true;
@@ -289,20 +289,16 @@ void CollisionShape2D::_bind_methods() {
289289
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_way_collision"), "set_one_way_collision", "is_one_way_collision_enabled");
290290
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "one_way_collision_margin", PROPERTY_HINT_RANGE, "0,128,0.1,suffix:px"), "set_one_way_collision_margin", "get_one_way_collision_margin");
291291

292-
#ifdef DEBUG_ENABLED
293292
ClassDB::bind_method(D_METHOD("set_debug_color", "color"), &CollisionShape2D::set_debug_color);
294293
ClassDB::bind_method(D_METHOD("get_debug_color"), &CollisionShape2D::get_debug_color);
295294

296295
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_color"), "set_debug_color", "get_debug_color");
297296
// Default value depends on a project setting, override for doc generation purposes.
298297
ADD_PROPERTY_DEFAULT("debug_color", Color(0.0, 0.0, 0.0, 0.0));
299-
#endif // DEBUG_ENABLED
300298
}
301299

302300
CollisionShape2D::CollisionShape2D() {
303301
set_notify_local_transform(true);
304302
set_hide_clip_children(true);
305-
#ifdef DEBUG_ENABLED
306303
debug_color = _get_default_debug_color();
307-
#endif // DEBUG_ENABLED
308304
}

scene/2d/physics/collision_shape_2d.h

-4
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ class CollisionShape2D : public Node2D {
5252
// Not wrapped in `#ifdef DEBUG_ENABLED` as it is used for rendering.
5353
Color debug_color = Color(0.0, 0.0, 0.0, 0.0);
5454

55-
#ifdef DEBUG_ENABLED
5655
Color _get_default_debug_color() const;
57-
#endif // DEBUG_ENABLED
5856

5957
protected:
6058
void _notification(int p_what);
@@ -86,10 +84,8 @@ class CollisionShape2D : public Node2D {
8684
void set_one_way_collision_margin(real_t p_margin);
8785
real_t get_one_way_collision_margin() const;
8886

89-
#ifdef DEBUG_ENABLED
9087
void set_debug_color(const Color &p_color);
9188
Color get_debug_color() const;
92-
#endif // DEBUG_ENABLED
9389

9490
PackedStringArray get_configuration_warnings() const override;
9591

scene/3d/physics/collision_shape_3d.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ void CollisionShape3D::_bind_methods() {
173173
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape3D"), "set_shape", "get_shape");
174174
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
175175

176-
#ifdef DEBUG_ENABLED
177176
ClassDB::bind_method(D_METHOD("set_debug_color", "color"), &CollisionShape3D::set_debug_color);
178177
ClassDB::bind_method(D_METHOD("get_debug_color"), &CollisionShape3D::get_debug_color);
179178

@@ -185,7 +184,6 @@ void CollisionShape3D::_bind_methods() {
185184
ADD_PROPERTY_DEFAULT("debug_color", Color(0.0, 0.0, 0.0, 0.0));
186185

187186
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_fill"), "set_enable_debug_fill", "get_enable_debug_fill");
188-
#endif // DEBUG_ENABLED
189187
}
190188

191189
void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
@@ -246,8 +244,6 @@ bool CollisionShape3D::is_disabled() const {
246244
return disabled;
247245
}
248246

249-
#ifdef DEBUG_ENABLED
250-
251247
Color CollisionShape3D::_get_default_debug_color() const {
252248
const SceneTree *st = SceneTree::get_singleton();
253249
return st ? st->get_debug_collisions_color() : Color(0.0, 0.0, 0.0, 0.0);
@@ -285,6 +281,8 @@ bool CollisionShape3D::get_debug_fill_enabled() const {
285281
return debug_fill;
286282
}
287283

284+
#ifdef DEBUG_ENABLED
285+
288286
bool CollisionShape3D::_property_can_revert(const StringName &p_name) const {
289287
if (p_name == "debug_color") {
290288
return true;
@@ -324,9 +322,7 @@ void CollisionShape3D::_shape_changed() {
324322
CollisionShape3D::CollisionShape3D() {
325323
//indicator = RenderingServer::get_singleton()->mesh_create();
326324
set_notify_local_transform(true);
327-
#ifdef DEBUG_ENABLED
328325
debug_color = _get_default_debug_color();
329-
#endif // DEBUG_ENABLED
330326
}
331327

332328
CollisionShape3D::~CollisionShape3D() {

scene/3d/physics/collision_shape_3d.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ class CollisionShape3D : public Node3D {
4343
uint32_t owner_id = 0;
4444
CollisionObject3D *collision_object = nullptr;
4545

46-
#ifdef DEBUG_ENABLED
4746
Color debug_color;
4847
bool debug_fill = true;
4948

5049
Color _get_default_debug_color() const;
50+
51+
#ifdef DEBUG_ENABLED
5152
void _shape_changed();
5253
#endif // DEBUG_ENABLED
5354

@@ -78,13 +79,11 @@ class CollisionShape3D : public Node3D {
7879
void set_disabled(bool p_disabled);
7980
bool is_disabled() const;
8081

81-
#ifdef DEBUG_ENABLED
8282
void set_debug_color(const Color &p_color);
8383
Color get_debug_color() const;
8484

8585
void set_debug_fill_enabled(bool p_enable);
8686
bool get_debug_fill_enabled() const;
87-
#endif // DEBUG_ENABLED
8887

8988
PackedStringArray get_configuration_warnings() const override;
9089

scene/resources/3d/shape_3d.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ void Shape3D::set_margin(real_t p_margin) {
6565
PhysicsServer3D::get_singleton()->shape_set_margin(shape, margin);
6666
}
6767

68-
#ifdef DEBUG_ENABLED
69-
7068
void Shape3D::set_debug_color(const Color &p_color) {
7169
if (p_color == debug_color) {
7270
return;
7371
}
7472

7573
debug_color = p_color;
74+
#ifdef DEBUG_ENABLED
7675
debug_properties_edited = true;
76+
#endif // DEBUG_ENABLED
7777
_update_shape();
7878
}
7979

@@ -87,16 +87,16 @@ void Shape3D::set_debug_fill(bool p_fill) {
8787
}
8888

8989
debug_fill = p_fill;
90+
#ifdef DEBUG_ENABLED
9091
debug_properties_edited = true;
92+
#endif // DEBUG_ENABLED
9193
_update_shape();
9294
}
9395

9496
bool Shape3D::get_debug_fill() const {
9597
return debug_fill;
9698
}
9799

98-
#endif // DEBUG_ENABLED
99-
100100
Ref<ArrayMesh> Shape3D::get_debug_mesh() {
101101
if (debug_mesh_cache.is_valid()) {
102102
return debug_mesh_cache;

scene/resources/3d/shape_3d.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ class Shape3D : public Resource {
8181
real_t get_margin() const;
8282
void set_margin(real_t p_margin);
8383

84-
#ifdef DEBUG_ENABLED
8584
void set_debug_color(const Color &p_color);
8685
Color get_debug_color() const;
8786

8887
void set_debug_fill(bool p_fill);
8988
bool get_debug_fill() const;
9089

90+
#ifdef DEBUG_ENABLED
9191
_FORCE_INLINE_ bool are_debug_properties_edited() const { return debug_properties_edited; }
9292
#endif // DEBUG_ENABLED
9393

0 commit comments

Comments
 (0)