Allow any kind of Mesh to be added to an EditorSpatialGizmo

(cherry picked from commit e0729b9c79)
This commit is contained in:
Marcel Admiraal 2021-12-03 08:15:06 +00:00 committed by Rémi Verschelde
parent d3b0436cfb
commit ca3ab75697
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 6 additions and 4 deletions

View File

@ -46,7 +46,7 @@
</method>
<method name="add_mesh">
<return type="void" />
<argument index="0" name="mesh" type="ArrayMesh" />
<argument index="0" name="mesh" type="Mesh" />
<argument index="1" name="billboard" type="bool" default="false" />
<argument index="2" name="skeleton" type="SkinReference" default="null" />
<argument index="3" name="material" type="Material" default="null" />

View File

@ -57,7 +57,7 @@ public:
struct Instance {
RID instance;
Ref<ArrayMesh> mesh;
Ref<Mesh> mesh;
Ref<Material> material;
Ref<SkinReference> skin_reference;
RID skeleton;
@ -103,7 +103,7 @@ protected:
public:
void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1));
void add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1));
void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>(), const Ref<Material> &p_material = Ref<Material>());
void add_mesh(const Ref<Mesh> &p_mesh, bool p_billboard = false, const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>(), const Ref<Material> &p_material = Ref<Material>());
void add_collision_segments(const Vector<Vector3> &p_lines);
void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh);
void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1, const Color &p_modulate = Color(1, 1, 1));

View File

@ -179,8 +179,10 @@ void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base, bool p_hidde
VS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26
}
void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) {
void EditorSpatialGizmo::add_mesh(const Ref<Mesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND_MSG(!p_mesh.is_valid(), "EditorSpatialGizmo.add_mesh() requires a valid Mesh resource.");
Instance ins;
ins.billboard = p_billboard;