diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2019-12-05 19:27:57 +0100 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2019-12-05 19:27:57 +0100 |
commit | 06e4a3aa7564cae35bd4ff6338dccd7297fb2f3e (patch) | |
tree | 376dbc8b21acc150d5edf63fdbb9fea0ac9c8143 | |
parent | 6544a0e908601271645c3f57dc830826144ddfc3 (diff) |
Fixed errors in JointSpatialGizmoPlugin when selecting a joint with unset nodes
Fixes #34122
-rw-r--r-- | editor/spatial_editor_gizmos.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index cfd9ec19d2..fd9e44cd5f 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -202,6 +202,9 @@ void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard } void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard) { + if (p_lines.empty()) { + return; + } ERR_FAIL_COND(!spatial_node); Instance ins; @@ -4190,8 +4193,19 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->clear(); - const Spatial *node_body_a = Object::cast_to<Spatial>(joint->get_node(joint->get_node_a())); - const Spatial *node_body_b = Object::cast_to<Spatial>(joint->get_node(joint->get_node_b())); + Spatial *node_body_a = NULL; + if (!joint->get_node_a().is_empty()) { + node_body_a = Object::cast_to<Spatial>(joint->get_node(joint->get_node_a())); + } + + Spatial *node_body_b = NULL; + if (!joint->get_node_b().is_empty()) { + node_body_b = Object::cast_to<Spatial>(joint->get_node(joint->get_node_b())); + } + + if (!node_body_a && !node_body_b) { + return; + } Ref<Material> common_material = get_material("joint_material", p_gizmo); Ref<Material> body_a_material = get_material("joint_body_a_material", p_gizmo); |