diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-11-27 13:52:25 -0500 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-11-27 13:52:25 -0500 |
commit | 721f53fde47c2727d99e3ecccdb789a67df36de0 (patch) | |
tree | 55ec5bfa061a5c27272b831e697b78ed1b756a70 /scene/resources/3d/box_shape_3d.cpp | |
parent | b06d20bf39d15ec736d08d4e4fcb32e0c3c1ce1e (diff) | |
parent | f128f383e892865379cb8b14e7bcc9858efe2973 (diff) | |
download | redot-engine-721f53fde47c2727d99e3ecccdb789a67df36de0.tar.gz |
Merge commit godotengine/godot@f128f383e892865379cb8b14e7bcc9858efe2973
Diffstat (limited to 'scene/resources/3d/box_shape_3d.cpp')
-rw-r--r-- | scene/resources/3d/box_shape_3d.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scene/resources/3d/box_shape_3d.cpp b/scene/resources/3d/box_shape_3d.cpp index ef604f67b9..e4c02894b2 100644 --- a/scene/resources/3d/box_shape_3d.cpp +++ b/scene/resources/3d/box_shape_3d.cpp @@ -31,6 +31,8 @@ /**************************************************************************/ #include "box_shape_3d.h" + +#include "scene/resources/3d/primitive_meshes.h" #include "servers/physics_server_3d.h" Vector<Vector3> BoxShape3D::get_debug_mesh_lines() const { @@ -49,6 +51,24 @@ Vector<Vector3> BoxShape3D::get_debug_mesh_lines() const { return lines; } +Ref<ArrayMesh> BoxShape3D::get_debug_arraymesh_faces(const Color &p_modulate) const { + Array box_array; + box_array.resize(RS::ARRAY_MAX); + BoxMesh::create_mesh_array(box_array, size); + + Vector<Color> colors; + const PackedVector3Array &verts = box_array[RS::ARRAY_VERTEX]; + const int32_t verts_size = verts.size(); + for (int i = 0; i < verts_size; i++) { + colors.append(p_modulate); + } + + Ref<ArrayMesh> box_mesh = memnew(ArrayMesh); + box_array[RS::ARRAY_COLOR] = colors; + box_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, box_array); + return box_mesh; +} + real_t BoxShape3D::get_enclosing_radius() const { return size.length() / 2; } |