summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/plugins/spatial_editor_plugin.h3
-rw-r--r--editor/spatial_editor_gizmos.cpp11
-rw-r--r--scene/3d/path.cpp3
3 files changed, 12 insertions, 5 deletions
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 364b0085f7..6256b8b055 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -60,6 +60,7 @@ public:
RID instance;
Ref<ArrayMesh> mesh;
+ Ref<Material> material;
RID skeleton;
bool billboard;
bool unscaled;
@@ -103,7 +104,7 @@ protected:
public:
void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false);
- void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const RID &p_skeleton = RID());
+ void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const RID &p_skeleton = RID(), 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);
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 7a4b7d091f..f54066a609 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<ArrayMesh> &p_mesh, bool p_billboard, const RID &p_skeleton) {
+void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const RID &p_skeleton, const Ref<Material> &p_material) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
@@ -187,9 +187,13 @@ void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &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<ConcavePolygonShape>(*s)) {
Ref<ConcavePolygonShape> cs2 = s;
- Ref<ArrayMesh> mesh = cs2->get_debug_mesh()->duplicate();
- mesh->surface_set_material(0, material);
- p_gizmo->add_mesh(mesh);
+ Ref<ArrayMesh> mesh = cs2->get_debug_mesh();
+ p_gizmo->add_mesh(mesh, false, RID(), material);
}
if (Object::cast_to<RayShape>(*s)) {
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index 9005b6b566..190967d76c 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;