Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a way to set the color of Shape3D debug mesh #100328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Zylann
Copy link
Contributor

@Zylann Zylann commented Dec 12, 2024

This allows scripts and extensions that don't use nodes to still obtain a colored mesh using get_debug_mesh, so they can keep drawing them when the debug option is enabled.

Since #90644, debug shapes of my voxel terrain plugin stopped showing. I found out it's because now Shape3D has customizable colors, but they default to transparent black, which is invisible (I assume it is exploited to mean "null" in some places).
Shape3D.get_debug_mesh is where that color is used. So the only way to make it generate with the right color is to expose set_debug_color. This is also the way CollisionShape3D nodes are working.

An alternative would be to pass these options directly to get_debug_mesh, but that would break compatibility.

@Zylann Zylann requested a review from a team as a code owner December 12, 2024 17:16
@AThousandShips AThousandShips added this to the 4.4 milestone Dec 12, 2024
@Zylann Zylann force-pushed the shape_debug_mesh_color branch from e1e20a1 to f27a64d Compare December 12, 2024 18:53
@Zylann Zylann requested a review from a team as a code owner December 12, 2024 18:53
@dsnopek
Copy link
Contributor

dsnopek commented Dec 12, 2024

This seems to have the same goal as PR #100317?

@Zylann
Copy link
Contributor Author

Zylann commented Dec 14, 2024

It looks similar, however #100317 does not expose methods of Shape3D, which is necessary when nodes are not used.

@Bromeon
Copy link
Contributor

Bromeon commented Dec 19, 2024

Is there already consensus on moving forward with either this or #100317? The absence of Shape3D::set_debug_color() breaks some GDExtension codegen in Release mode 🙂

@Zylann
Copy link
Contributor Author

Zylann commented Dec 20, 2024

Actually there is no "either", both PRs can be done. They each do different things but they are not conflicting (even though there might need to be some code merging).

@dalexeev
Copy link
Member

If you are interested, could you also update the following methods?

Color CollisionShape2D::_get_default_debug_color() const {
const SceneTree *st = SceneTree::get_singleton();
return st ? st->get_debug_collisions_color() : Color(0.0, 0.0, 0.0, 0.0);
}

Color CollisionShape3D::_get_default_debug_color() const {
const SceneTree *st = SceneTree::get_singleton();
return st ? st->get_debug_collisions_color() : Color(0.0, 0.0, 0.0, 0.0);
}

const SceneTree *st = SceneTree::get_singleton();
return st ? st->get_debug_collisions_color() : GLOBAL_GET("debug/shapes/collision/shape_color");

@Zylann Zylann force-pushed the shape_debug_mesh_color branch from f27a64d to 36cca5c Compare January 8, 2025 01:06
@Zylann Zylann force-pushed the shape_debug_mesh_color branch from 36cca5c to 59ece42 Compare January 8, 2025 01:38
@Zylann Zylann requested review from a team as code owners January 8, 2025 01:38
@Zylann
Copy link
Contributor Author

Zylann commented Jan 8, 2025

@dalexeev added.

@Repiteo Repiteo modified the milestones: 4.4, 4.5 Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants