diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 364b0085f7e..6256b8b0553 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -60,6 +60,7 @@ public: RID instance; Ref mesh; + Ref material; RID skeleton; bool billboard; bool unscaled; @@ -103,7 +104,7 @@ protected: public: void add_lines(const Vector &p_lines, const Ref &p_material, bool p_billboard = false); - void add_mesh(const Ref &p_mesh, bool p_billboard = false, const RID &p_skeleton = RID()); + void add_mesh(const Ref &p_mesh, bool p_billboard = false, const RID &p_skeleton = RID(), const Ref &p_material = Ref()); void add_collision_segments(const Vector &p_lines); void add_collision_triangles(const Ref &p_tmesh); void add_unscaled_billboard(const Ref &p_material, float p_scale = 1); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 7a4b7d091f6..f54066a609f 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -179,7 +179,7 @@ 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 &p_mesh, bool p_billboard, const RID &p_skeleton) { +void EditorSpatialGizmo::add_mesh(const Ref &p_mesh, bool p_billboard, const RID &p_skeleton, const Ref &p_material) { ERR_FAIL_COND(!spatial_node); Instance ins; @@ -187,9 +187,13 @@ void EditorSpatialGizmo::add_mesh(const Ref &p_mesh, bool p_billboard ins.billboard = p_billboard; ins.mesh = p_mesh; ins.skeleton = p_skeleton; + ins.material = p_material; if (valid) { ins.create_instance(spatial_node, hidden); VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + if (ins.material.is_valid()) { + VS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid()); + } } instances.push_back(ins); @@ -3519,9 +3523,8 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { if (Object::cast_to(*s)) { Ref cs2 = s; - Ref mesh = cs2->get_debug_mesh()->duplicate(); - mesh->surface_set_material(0, material); - p_gizmo->add_mesh(mesh); + Ref mesh = cs2->get_debug_mesh(); + p_gizmo->add_mesh(mesh, false, RID(), material); } if (Object::cast_to(*s)) { diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp index 9005b6b566a..190967d76c9 100644 --- a/scene/3d/path.cpp +++ b/scene/3d/path.cpp @@ -107,6 +107,9 @@ void PathFollow::_update_transform() { } float bl = c->get_baked_length(); + if (bl == 0.0) { + return; + } float bi = c->get_bake_interval(); float o = offset; float o_next = offset + bi;