From 06e4a3aa7564cae35bd4ff6338dccd7297fb2f3e Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Thu, 5 Dec 2019 19:27:57 +0100 Subject: Fixed errors in JointSpatialGizmoPlugin when selecting a joint with unset nodes Fixes #34122 --- editor/spatial_editor_gizmos.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'editor') 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 &p_mesh, bool p_billboard } void EditorSpatialGizmo::add_lines(const Vector &p_lines, const Ref &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(joint->get_node(joint->get_node_a())); - const Spatial *node_body_b = Object::cast_to(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(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(joint->get_node(joint->get_node_b())); + } + + if (!node_body_a && !node_body_b) { + return; + } Ref common_material = get_material("joint_material", p_gizmo); Ref body_a_material = get_material("joint_body_a_material", p_gizmo); -- cgit v1.2.3