mirror of https://github.com/godotengine/godot
Merge pull request #100317 from TCROC/fix-collision-shape-debug-color-breaks-gdextension
Fix collision shape debug color breaking GDExtension
This commit is contained in:
commit
df2b117ec2
|
|
@ -227,8 +227,6 @@ real_t CollisionShape2D::get_one_way_collision_margin() const {
|
||||||
return one_way_collision_margin;
|
return one_way_collision_margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
|
|
||||||
Color CollisionShape2D::_get_default_debug_color() const {
|
Color CollisionShape2D::_get_default_debug_color() const {
|
||||||
const SceneTree *st = SceneTree::get_singleton();
|
const SceneTree *st = SceneTree::get_singleton();
|
||||||
return st ? st->get_debug_collisions_color() : Color(0.0, 0.0, 0.0, 0.0);
|
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 {
|
||||||
return debug_color;
|
return debug_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
||||||
bool CollisionShape2D::_property_can_revert(const StringName &p_name) const {
|
bool CollisionShape2D::_property_can_revert(const StringName &p_name) const {
|
||||||
if (p_name == "debug_color") {
|
if (p_name == "debug_color") {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -289,20 +289,16 @@ void CollisionShape2D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_way_collision"), "set_one_way_collision", "is_one_way_collision_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_way_collision"), "set_one_way_collision", "is_one_way_collision_enabled");
|
||||||
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");
|
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");
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
ClassDB::bind_method(D_METHOD("set_debug_color", "color"), &CollisionShape2D::set_debug_color);
|
ClassDB::bind_method(D_METHOD("set_debug_color", "color"), &CollisionShape2D::set_debug_color);
|
||||||
ClassDB::bind_method(D_METHOD("get_debug_color"), &CollisionShape2D::get_debug_color);
|
ClassDB::bind_method(D_METHOD("get_debug_color"), &CollisionShape2D::get_debug_color);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_color"), "set_debug_color", "get_debug_color");
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_color"), "set_debug_color", "get_debug_color");
|
||||||
// Default value depends on a project setting, override for doc generation purposes.
|
// Default value depends on a project setting, override for doc generation purposes.
|
||||||
ADD_PROPERTY_DEFAULT("debug_color", Color(0.0, 0.0, 0.0, 0.0));
|
ADD_PROPERTY_DEFAULT("debug_color", Color(0.0, 0.0, 0.0, 0.0));
|
||||||
#endif // DEBUG_ENABLED
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CollisionShape2D::CollisionShape2D() {
|
CollisionShape2D::CollisionShape2D() {
|
||||||
set_notify_local_transform(true);
|
set_notify_local_transform(true);
|
||||||
set_hide_clip_children(true);
|
set_hide_clip_children(true);
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
debug_color = _get_default_debug_color();
|
debug_color = _get_default_debug_color();
|
||||||
#endif // DEBUG_ENABLED
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,7 @@ class CollisionShape2D : public Node2D {
|
||||||
// Not wrapped in `#ifdef DEBUG_ENABLED` as it is used for rendering.
|
// Not wrapped in `#ifdef DEBUG_ENABLED` as it is used for rendering.
|
||||||
Color debug_color = Color(0.0, 0.0, 0.0, 0.0);
|
Color debug_color = Color(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
Color _get_default_debug_color() const;
|
Color _get_default_debug_color() const;
|
||||||
#endif // DEBUG_ENABLED
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
@ -86,10 +84,8 @@ public:
|
||||||
void set_one_way_collision_margin(real_t p_margin);
|
void set_one_way_collision_margin(real_t p_margin);
|
||||||
real_t get_one_way_collision_margin() const;
|
real_t get_one_way_collision_margin() const;
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
void set_debug_color(const Color &p_color);
|
void set_debug_color(const Color &p_color);
|
||||||
Color get_debug_color() const;
|
Color get_debug_color() const;
|
||||||
#endif // DEBUG_ENABLED
|
|
||||||
|
|
||||||
PackedStringArray get_configuration_warnings() const override;
|
PackedStringArray get_configuration_warnings() const override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,6 @@ void CollisionShape3D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape3D"), "set_shape", "get_shape");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape3D"), "set_shape", "get_shape");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
ClassDB::bind_method(D_METHOD("set_debug_color", "color"), &CollisionShape3D::set_debug_color);
|
ClassDB::bind_method(D_METHOD("set_debug_color", "color"), &CollisionShape3D::set_debug_color);
|
||||||
ClassDB::bind_method(D_METHOD("get_debug_color"), &CollisionShape3D::get_debug_color);
|
ClassDB::bind_method(D_METHOD("get_debug_color"), &CollisionShape3D::get_debug_color);
|
||||||
|
|
||||||
|
|
@ -185,7 +184,6 @@ void CollisionShape3D::_bind_methods() {
|
||||||
ADD_PROPERTY_DEFAULT("debug_color", Color(0.0, 0.0, 0.0, 0.0));
|
ADD_PROPERTY_DEFAULT("debug_color", Color(0.0, 0.0, 0.0, 0.0));
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_fill"), "set_enable_debug_fill", "get_enable_debug_fill");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_fill"), "set_enable_debug_fill", "get_enable_debug_fill");
|
||||||
#endif // DEBUG_ENABLED
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
|
void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
|
||||||
|
|
@ -246,8 +244,6 @@ bool CollisionShape3D::is_disabled() const {
|
||||||
return disabled;
|
return disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
|
|
||||||
Color CollisionShape3D::_get_default_debug_color() const {
|
Color CollisionShape3D::_get_default_debug_color() const {
|
||||||
const SceneTree *st = SceneTree::get_singleton();
|
const SceneTree *st = SceneTree::get_singleton();
|
||||||
return st ? st->get_debug_collisions_color() : Color(0.0, 0.0, 0.0, 0.0);
|
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 {
|
||||||
return debug_fill;
|
return debug_fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
||||||
bool CollisionShape3D::_property_can_revert(const StringName &p_name) const {
|
bool CollisionShape3D::_property_can_revert(const StringName &p_name) const {
|
||||||
if (p_name == "debug_color") {
|
if (p_name == "debug_color") {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -324,9 +322,7 @@ void CollisionShape3D::_shape_changed() {
|
||||||
CollisionShape3D::CollisionShape3D() {
|
CollisionShape3D::CollisionShape3D() {
|
||||||
//indicator = RenderingServer::get_singleton()->mesh_create();
|
//indicator = RenderingServer::get_singleton()->mesh_create();
|
||||||
set_notify_local_transform(true);
|
set_notify_local_transform(true);
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
debug_color = _get_default_debug_color();
|
debug_color = _get_default_debug_color();
|
||||||
#endif // DEBUG_ENABLED
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CollisionShape3D::~CollisionShape3D() {
|
CollisionShape3D::~CollisionShape3D() {
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,12 @@ class CollisionShape3D : public Node3D {
|
||||||
uint32_t owner_id = 0;
|
uint32_t owner_id = 0;
|
||||||
CollisionObject3D *collision_object = nullptr;
|
CollisionObject3D *collision_object = nullptr;
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
Color debug_color;
|
Color debug_color;
|
||||||
bool debug_fill = true;
|
bool debug_fill = true;
|
||||||
|
|
||||||
Color _get_default_debug_color() const;
|
Color _get_default_debug_color() const;
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
void _shape_changed();
|
void _shape_changed();
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
|
|
@ -78,13 +79,11 @@ public:
|
||||||
void set_disabled(bool p_disabled);
|
void set_disabled(bool p_disabled);
|
||||||
bool is_disabled() const;
|
bool is_disabled() const;
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
void set_debug_color(const Color &p_color);
|
void set_debug_color(const Color &p_color);
|
||||||
Color get_debug_color() const;
|
Color get_debug_color() const;
|
||||||
|
|
||||||
void set_debug_fill_enabled(bool p_enable);
|
void set_debug_fill_enabled(bool p_enable);
|
||||||
bool get_debug_fill_enabled() const;
|
bool get_debug_fill_enabled() const;
|
||||||
#endif // DEBUG_ENABLED
|
|
||||||
|
|
||||||
PackedStringArray get_configuration_warnings() const override;
|
PackedStringArray get_configuration_warnings() const override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,15 +65,15 @@ void Shape3D::set_margin(real_t p_margin) {
|
||||||
PhysicsServer3D::get_singleton()->shape_set_margin(shape, margin);
|
PhysicsServer3D::get_singleton()->shape_set_margin(shape, margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
|
|
||||||
void Shape3D::set_debug_color(const Color &p_color) {
|
void Shape3D::set_debug_color(const Color &p_color) {
|
||||||
if (p_color == debug_color) {
|
if (p_color == debug_color) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_color = p_color;
|
debug_color = p_color;
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
debug_properties_edited = true;
|
debug_properties_edited = true;
|
||||||
|
#endif // DEBUG_ENABLED
|
||||||
_update_shape();
|
_update_shape();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +87,9 @@ void Shape3D::set_debug_fill(bool p_fill) {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_fill = p_fill;
|
debug_fill = p_fill;
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
debug_properties_edited = true;
|
debug_properties_edited = true;
|
||||||
|
#endif // DEBUG_ENABLED
|
||||||
_update_shape();
|
_update_shape();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,8 +97,6 @@ bool Shape3D::get_debug_fill() const {
|
||||||
return debug_fill;
|
return debug_fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DEBUG_ENABLED
|
|
||||||
|
|
||||||
Ref<ArrayMesh> Shape3D::get_debug_mesh() {
|
Ref<ArrayMesh> Shape3D::get_debug_mesh() {
|
||||||
if (debug_mesh_cache.is_valid()) {
|
if (debug_mesh_cache.is_valid()) {
|
||||||
return debug_mesh_cache;
|
return debug_mesh_cache;
|
||||||
|
|
|
||||||
|
|
@ -81,13 +81,13 @@ public:
|
||||||
real_t get_margin() const;
|
real_t get_margin() const;
|
||||||
void set_margin(real_t p_margin);
|
void set_margin(real_t p_margin);
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
void set_debug_color(const Color &p_color);
|
void set_debug_color(const Color &p_color);
|
||||||
Color get_debug_color() const;
|
Color get_debug_color() const;
|
||||||
|
|
||||||
void set_debug_fill(bool p_fill);
|
void set_debug_fill(bool p_fill);
|
||||||
bool get_debug_fill() const;
|
bool get_debug_fill() const;
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
_FORCE_INLINE_ bool are_debug_properties_edited() const { return debug_properties_edited; }
|
_FORCE_INLINE_ bool are_debug_properties_edited() const { return debug_properties_edited; }
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue