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

Added debug color and draw faces properties for CollisionShape3D #78273

Closed

Conversation

Big-Burden
Copy link

Partially closes godotengine/godot-proposals/issues/906

Currently does not support drawing faces for HeightMap, Concave or Convex Shapes
Editor

Demo

Game

@Big-Burden Big-Burden requested review from a team as code owners June 15, 2023 13:39
@Zireael07

This comment was marked as off-topic.

@Rubonnek
Copy link
Member

@Big-Burden Could you rebase your changes against the master branch?

@Big-Burden Big-Burden requested review from a team as code owners November 23, 2023 11:49
@AThousandShips AThousandShips removed request for a team November 23, 2023 12:17
@@ -152,10 +172,16 @@ void CollisionShape3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_disabled", "enable"), &CollisionShape3D::set_disabled);
ClassDB::bind_method(D_METHOD("is_disabled"), &CollisionShape3D::is_disabled);
ClassDB::bind_method(D_METHOD("make_convex_from_siblings"), &CollisionShape3D::make_convex_from_siblings);
ClassDB::bind_method(D_METHOD("set_debug_color", "color"), &CollisionShape3D::set_debug_colour);
ClassDB::bind_method(D_METHOD("get_debug_color"), &CollisionShape3D::get_debug_color);
ClassDB::bind_method(D_METHOD("set_debug_draw_faces", "bool"), &CollisionShape3D::set_debug_draw_faces);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ClassDB::bind_method(D_METHOD("set_debug_draw_faces", "bool"), &CollisionShape3D::set_debug_draw_faces);
ClassDB::bind_method(D_METHOD("set_debug_draw_faces", "debug_draw_faces"), &CollisionShape3D::set_debug_draw_faces);

Match the argument

@@ -29,6 +29,8 @@
/**************************************************************************/

#include "box_shape_3d.h"

#include "primitive_meshes.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "primitive_meshes.h"
#include "scene/resources/primitive_meshes.h"

Full paths are used here

Ref<ArrayMesh> Shape3D::get_debug_mesh() {
if (debug_mesh_cache.is_valid()) {
return debug_mesh_cache;
Ref<ArrayMesh> Shape3D::get_debug_mesh(const Color& p_debug_color, const bool p_with_shape_faces) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ref<ArrayMesh> Shape3D::get_debug_mesh(const Color& p_debug_color, const bool p_with_shape_faces) {
Ref<ArrayMesh> Shape3D::get_debug_mesh(const Color& p_debug_color, bool p_with_shape_faces) {

No const for simple types, and match header

virtual Vector<Vector3> get_debug_mesh_lines() const = 0; // { return Vector<Vector3>(); }
virtual Ref<ArrayMesh> get_debug_face_mesh(const Color p_vertex_color) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
virtual Ref<ArrayMesh> get_debug_face_mesh(const Color p_vertex_color) const;
virtual Ref<ArrayMesh> get_debug_face_mesh(const Color &p_vertex_color) const;

Pass by reference

@@ -30,6 +30,7 @@

#include "sphere_shape_3d.h"

#include "primitive_meshes.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "primitive_meshes.h"
#include "scene/resources/primitive_meshes.h"

@@ -30,6 +30,7 @@

#include "world_boundary_shape_3d.h"

#include "mesh.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "mesh.h"
#include "scene/resources/mesh.h"

@@ -46,6 +46,7 @@ class WorldBoundaryShape3D : public Shape3D {
const Plane &get_plane() const;

virtual Vector<Vector3> get_debug_mesh_lines() const override;
virtual Ref<ArrayMesh> get_debug_face_mesh(const Color p_vertex_color) const override;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
virtual Ref<ArrayMesh> get_debug_face_mesh(const Color p_vertex_color) const override;
virtual Ref<ArrayMesh> get_debug_face_mesh(const Color &p_vertex_color) const override;

@Big-Burden Big-Burden force-pushed the collisionshape3d-color branch from 6272ee1 to 3ce21a5 Compare November 23, 2023 15:14
@BattyBovine
Copy link
Contributor

I actually spent this past week adding this very feature with the intention of creating a pull request, without realising this already exists. No idea how I didn't find this when I searched for it. In any case, I'm just going to link my branch here instead of opening a pull request for the moment. It includes support for all Shape3D resources, including height maps, convex, and concave collision surfaces. If @Big-Burden wants to use any of that to add to this, feel free. I am currently using this branch for my own game, so I'll be continuing to maintain it for the foreseeable future.

@fire
Copy link
Member

fire commented Apr 7, 2024

Feel free to post a pull request so we can check its merits.

@badsectoracula
Copy link
Contributor

Since #90644 was merged in, perhaps this should be closed?

@aaronfranke
Copy link
Member

Superseded by #90644

@aaronfranke aaronfranke removed this from the 4.x milestone Nov 29, 2024
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.

More configurable/custom colors for visible collision shapes debug option (already implemented in 2D)
10 participants