diff options
author | George L. Albany <Megacake1234@gmail.com> | 2024-11-27 21:15:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-27 21:15:49 +0000 |
commit | 85d87116e184e7923b8d6804cab2681b61c62d83 (patch) | |
tree | 55ec5bfa061a5c27272b831e697b78ed1b756a70 /scene/resources/3d/cylinder_shape_3d.cpp | |
parent | b06d20bf39d15ec736d08d4e4fcb32e0c3c1ce1e (diff) | |
parent | 721f53fde47c2727d99e3ecccdb789a67df36de0 (diff) | |
download | redot-engine-85d87116e184e7923b8d6804cab2681b61c62d83.tar.gz |
Merge commit godotengine/godot@f128f38
Diffstat (limited to 'scene/resources/3d/cylinder_shape_3d.cpp')
-rw-r--r-- | scene/resources/3d/cylinder_shape_3d.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scene/resources/3d/cylinder_shape_3d.cpp b/scene/resources/3d/cylinder_shape_3d.cpp index 164ab49c77..0f8747e326 100644 --- a/scene/resources/3d/cylinder_shape_3d.cpp +++ b/scene/resources/3d/cylinder_shape_3d.cpp @@ -32,6 +32,7 @@ #include "cylinder_shape_3d.h" +#include "scene/resources/3d/primitive_meshes.h" #include "servers/physics_server_3d.h" Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() const { @@ -62,6 +63,24 @@ Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() const { return points; } +Ref<ArrayMesh> CylinderShape3D::get_debug_arraymesh_faces(const Color &p_modulate) const { + Array cylinder_array; + cylinder_array.resize(RS::ARRAY_MAX); + CylinderMesh::create_mesh_array(cylinder_array, radius, radius, height, 32); + + Vector<Color> colors; + const PackedVector3Array &verts = cylinder_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> cylinder_mesh = memnew(ArrayMesh); + cylinder_array[RS::ARRAY_COLOR] = colors; + cylinder_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, cylinder_array); + return cylinder_mesh; +} + real_t CylinderShape3D::get_enclosing_radius() const { return Vector2(radius, height * 0.5).length(); } |