diff options
Diffstat (limited to 'editor/spatial_editor_gizmos.cpp')
-rw-r--r-- | editor/spatial_editor_gizmos.cpp | 291 |
1 files changed, 106 insertions, 185 deletions
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index cfd9ec19d2..40e1be665c 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -41,14 +41,12 @@ #include "scene/3d/light.h" #include "scene/3d/listener.h" #include "scene/3d/mesh_instance.h" -#include "scene/3d/navigation_mesh.h" +#include "scene/3d/navigation_mesh_instance.h" #include "scene/3d/particles.h" #include "scene/3d/physics_joint.h" -#include "scene/3d/portal.h" #include "scene/3d/position_3d.h" #include "scene/3d/ray_cast.h" #include "scene/3d/reflection_probe.h" -#include "scene/3d/room_instance.h" #include "scene/3d/soft_body.h" #include "scene/3d/spring_arm.h" #include "scene/3d/sprite_3d.h" @@ -172,8 +170,9 @@ void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base, bool p_hidde instance = VS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario()); VS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id()); - if (skin_reference.is_valid()) + if (skin_reference.is_valid()) { VS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton()); + } if (extra_margin) VS::get_singleton()->instance_set_extra_visibility_margin(instance, 1); VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, VS::SHADOW_CASTING_SETTING_OFF); @@ -201,7 +200,10 @@ void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard instances.push_back(ins); } -void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard) { +void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard, const Color &p_modulate) { + if (p_lines.empty()) { + return; + } ERR_FAIL_COND(!spatial_node); Instance ins; @@ -212,15 +214,15 @@ void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mat a[Mesh::ARRAY_VERTEX] = p_lines; - PoolVector<Color> color; + Vector<Color> color; color.resize(p_lines.size()); { - PoolVector<Color>::Write w = color.write(); + Color *w = color.ptrw(); for (int i = 0; i < p_lines.size(); i++) { if (is_selected()) - w[i] = Color(1, 1, 1, 0.8); + w[i] = Color(1, 1, 1, 0.8) * p_modulate; else - w[i] = Color(1, 1, 1, 0.2); + w[i] = Color(1, 1, 1, 0.2) * p_modulate; } } @@ -250,13 +252,14 @@ void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mat instances.push_back(ins); } -void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale) { +void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale, const Color &p_modulate) { ERR_FAIL_COND(!spatial_node); Instance ins; Vector<Vector3> vs; Vector<Vector2> uv; + Vector<Color> colors; vs.push_back(Vector3(-p_scale, p_scale, 0)); vs.push_back(Vector3(p_scale, p_scale, 0)); @@ -268,12 +271,26 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, uv.push_back(Vector2(1, 1)); uv.push_back(Vector2(0, 1)); + colors.push_back(p_modulate); + colors.push_back(p_modulate); + colors.push_back(p_modulate); + colors.push_back(p_modulate); + Ref<ArrayMesh> mesh = memnew(ArrayMesh); Array a; a.resize(Mesh::ARRAY_MAX); a[Mesh::ARRAY_VERTEX] = vs; a[Mesh::ARRAY_TEX_UV] = uv; - mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLE_FAN, a); + Vector<int> indices; + indices.push_back(0); + indices.push_back(1); + indices.push_back(2); + indices.push_back(0); + indices.push_back(2); + indices.push_back(3); + a[Mesh::ARRAY_INDEX] = indices; + a[Mesh::ARRAY_COLOR] = colors; + mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a); mesh->surface_set_material(0, p_material); float md = 0; @@ -331,10 +348,10 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref Array a; a.resize(VS::ARRAY_MAX); a[VS::ARRAY_VERTEX] = p_handles; - PoolVector<Color> colors; + Vector<Color> colors; { colors.resize(p_handles.size()); - PoolVector<Color>::Write w = colors.write(); + Color *w = colors.ptrw(); for (int i = 0; i < p_handles.size(); i++) { Color col(1, 1, 1, 1); @@ -393,8 +410,8 @@ void EditorSpatialGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size cubem.set_size(p_size); Array arrays = cubem.surface_get_arrays(0); - PoolVector3Array vertex = arrays[VS::ARRAY_VERTEX]; - PoolVector3Array::Write w = vertex.write(); + PackedVector3Array vertex = arrays[VS::ARRAY_VERTEX]; + Vector3 *w = vertex.ptrw(); for (int i = 0; i < vertex.size(); ++i) { w[i] += p_position; @@ -726,11 +743,11 @@ void EditorSpatialGizmo::set_plugin(EditorSpatialGizmoPlugin *p_plugin) { void EditorSpatialGizmo::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard"), &EditorSpatialGizmo::add_lines, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorSpatialGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorSpatialGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorSpatialGizmo::add_collision_segments); ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorSpatialGizmo::add_collision_triangles); - ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale"), &EditorSpatialGizmo::add_unscaled_billboard, DEFVAL(1)); + ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorSpatialGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "billboard", "secondary"), &EditorSpatialGizmo::add_handles, DEFVAL(false), DEFVAL(false)); ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorSpatialGizmo::_set_spatial_node); ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorSpatialGizmo::get_spatial_node); @@ -781,11 +798,10 @@ Vector3 EditorSpatialGizmo::get_handle_pos(int p_idx) const { LightSpatialGizmoPlugin::LightSpatialGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/light", Color(1, 1, 0.7)); - - create_material("lines_primary", gizmo_color); - create_material("lines_secondary", gizmo_color * Color(1, 1, 1, 0.35)); - create_material("lines_billboard", gizmo_color, true); + // Enable vertex colors for the materials below as the gizmo color depends on the light color. + create_material("lines_primary", Color(1, 1, 1), false, false, true); + create_material("lines_secondary", Color(1, 1, 1, 0.35), false, false, true); + create_material("lines_billboard", Color(1, 1, 1), true, false, true); create_icon_material("light_directional_icon", SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons")); create_icon_material("light_omni_icon", SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons")); @@ -876,7 +892,7 @@ void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); } - if (d < 0) + if (d <= 0) // Equal is here for negative zero. d = 0; light->set_param(Light::PARAM_RANGE, d); @@ -931,6 +947,10 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node()); + Color color = light->get_color(); + // Make the gizmo color as bright as possible for better visibility + color.set_hsv(color.get_h(), color.get_s(), 1); + p_gizmo->clear(); if (Object::cast_to<DirectionalLight>(light)) { @@ -967,8 +987,8 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } } - p_gizmo->add_lines(lines, material); - p_gizmo->add_unscaled_billboard(icon, 0.05); + p_gizmo->add_lines(lines, material, false, color); + p_gizmo->add_unscaled_billboard(icon, 0.05, color); } if (Object::cast_to<OmniLight>(light)) { @@ -1004,9 +1024,9 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { points_billboard.push_back(Vector3(b.x, b.y, 0)); } - p_gizmo->add_lines(points, lines_material, true); - p_gizmo->add_lines(points_billboard, lines_billboard_material, true); - p_gizmo->add_unscaled_billboard(icon, 0.05); + p_gizmo->add_lines(points, lines_material, true, color); + p_gizmo->add_lines(points_billboard, lines_billboard_material, true, color); + p_gizmo->add_unscaled_billboard(icon, 0.05, color); Vector<Vector3> handles; handles.push_back(Vector3(r, 0, 0)); @@ -1048,8 +1068,8 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { points_primary.push_back(Vector3(0, 0, -r)); points_primary.push_back(Vector3()); - p_gizmo->add_lines(points_primary, material_primary); - p_gizmo->add_lines(points_secondary, material_secondary); + p_gizmo->add_lines(points_primary, material_primary, false, color); + p_gizmo->add_lines(points_secondary, material_secondary, false, color); const float ra = 16 * Math_PI * 2.0 / 64.0; const Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w; @@ -1059,7 +1079,7 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { handles.push_back(Vector3(a.x, a.y, -d)); p_gizmo->add_handles(handles, get_material("handles")); - p_gizmo->add_unscaled_billboard(icon, 0.05); + p_gizmo->add_unscaled_billboard(icon, 0.05, color); } } @@ -1218,7 +1238,6 @@ CameraSpatialGizmoPlugin::CameraSpatialGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8)); create_material("camera_material", gizmo_color); - create_icon_material("camera_icon", SpatialEditor::get_singleton()->get_icon("GizmoCamera", "EditorIcons")); create_handle_material("handles"); } @@ -1272,7 +1291,7 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { Transform gt2 = camera->get_global_transform(); float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt2); - camera->set("fov", a * 2.0); + camera->set("fov", CLAMP(a * 2.0, 1, 179)); } else { Vector3 ra, rb; @@ -1282,8 +1301,7 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); } - if (d < 0) - d = 0; + d = CLAMP(d, 0.1, 16384); camera->set("size", d); } @@ -1331,7 +1349,6 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Vector<Vector3> handles; Ref<Material> material = get_material("camera_material", p_gizmo); - Ref<Material> icon = get_material("camera_icon", p_gizmo); #define ADD_TRIANGLE(m_a, m_b, m_c) \ { \ @@ -1426,7 +1443,6 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { #undef ADD_QUAD p_gizmo->add_lines(lines, material); - p_gizmo->add_unscaled_billboard(icon, 0.05); p_gizmo->add_handles(handles, get_material("handles")); ClippedCamera *clipcam = Object::cast_to<ClippedCamera>(camera); @@ -1547,7 +1563,7 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() { pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); cursor_points = Vector<Vector3>(); - PoolVector<Color> cursor_colors; + Vector<Color> cursor_colors; float cs = 0.25; cursor_points.push_back(Vector3(+cs, 0, 0)); cursor_points.push_back(Vector3(-cs, 0, 0)); @@ -1562,12 +1578,12 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() { cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor")); cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor")); - Ref<SpatialMaterial> mat = memnew(SpatialMaterial); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_line_width(3); + Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); + mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + Array d; d.resize(VS::ARRAY_MAX); d[Mesh::ARRAY_VERTEX] = cursor_points; @@ -1939,112 +1955,6 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_lines(points, material); } -// FIXME: Kept as reference for reimplementation in 3.1+ -#if 0 - -void RoomSpatialGizmo::redraw() { - - clear(); - Ref<RoomBounds> roomie = room->get_room(); - if (roomie.is_null()) - return; - PoolVector<Face3> faces = roomie->get_geometry_hint(); - - Vector<Vector3> lines; - int fc = faces.size(); - PoolVector<Face3>::Read r = faces.read(); - - Map<_EdgeKey, Vector3> edge_map; - - for (int i = 0; i < fc; i++) { - - Vector3 fn = r[i].get_plane().normal; - - for (int j = 0; j < 3; j++) { - - _EdgeKey ek; - ek.from = r[i].vertex[j].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON)); - ek.to = r[i].vertex[(j + 1) % 3].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON)); - if (ek.from < ek.to) - SWAP(ek.from, ek.to); - - Map<_EdgeKey, Vector3>::Element *E = edge_map.find(ek); - - if (E) { - - if (E->get().dot(fn) > 0.9) { - - E->get() = Vector3(); - } - - } else { - - edge_map[ek] = fn; - } - } - } - - for (Map<_EdgeKey, Vector3>::Element *E = edge_map.front(); E; E = E->next()) { - - if (E->get() != Vector3()) { - lines.push_back(E->key().from); - lines.push_back(E->key().to); - } - } - - add_lines(lines, EditorSpatialGizmos::singleton->room_material); - add_collision_segments(lines); -} - -RoomSpatialGizmo::RoomSpatialGizmo(Room *p_room) { - - set_spatial_node(p_room); - room = p_room; -} - -///// - -void PortalSpatialGizmo::redraw() { - - clear(); - - Vector<Point2> points = portal->get_shape(); - if (points.size() == 0) { - return; - } - - Vector<Vector3> lines; - - Vector3 center; - for (int i = 0; i < points.size(); i++) { - - Vector3 f; - f.x = points[i].x; - f.y = points[i].y; - Vector3 fn; - fn.x = points[(i + 1) % points.size()].x; - fn.y = points[(i + 1) % points.size()].y; - center += f; - - lines.push_back(f); - lines.push_back(fn); - } - - center /= points.size(); - lines.push_back(center); - lines.push_back(center + Vector3(0, 0, 1)); - - add_lines(lines, EditorSpatialGizmos::singleton->portal_material); - add_collision_segments(lines); -} - -PortalSpatialGizmo::PortalSpatialGizmo(Portal *p_portal) { - - set_spatial_node(p_portal); - portal = p_portal; -} - -#endif ///// RayCastSpatialGizmoPlugin::RayCastSpatialGizmoPlugin() { @@ -2079,7 +1989,7 @@ void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { lines.push_back(Vector3()); lines.push_back(raycast->get_cast_to()); - const Ref<SpatialMaterial> material = + const Ref<StandardMaterial3D> material = get_material(raycast->is_enabled() ? "shape_material" : "shape_material_disabled", p_gizmo); p_gizmo->add_lines(lines, material); @@ -2099,7 +2009,7 @@ void SpringArmSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { lines.push_back(Vector3()); lines.push_back(Vector3(0, 0, 1.0) * spring_arm->get_length()); - Ref<SpatialMaterial> material = get_material("shape_material", p_gizmo); + Ref<StandardMaterial3D> material = get_material("shape_material", p_gizmo); p_gizmo->add_lines(lines, material); p_gizmo->add_collision_segments(lines); @@ -2991,7 +2901,7 @@ void GIProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } //// - +#if 0 BakedIndirectLightGizmoPlugin::BakedIndirectLightGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/baked_indirect_light", Color(0.5, 0.6, 1)); @@ -3120,7 +3030,7 @@ void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_unscaled_billboard(icon, 0.05); p_gizmo->add_handles(handles, get_material("handles")); } - +#endif //// CollisionShapeSpatialGizmoPlugin::CollisionShapeSpatialGizmoPlugin() { @@ -3537,7 +3447,7 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Vector<Vector3> points; - Vector3 d(0, 0, height * 0.5); + Vector3 d(0, height * 0.5, 0); for (int i = 0; i < 360; i++) { float ra = Math::deg2rad((float)i); @@ -3545,24 +3455,24 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius; - points.push_back(Vector3(a.x, a.y, 0) + d); - points.push_back(Vector3(b.x, b.y, 0) + d); + points.push_back(Vector3(a.x, 0, a.y) + d); + points.push_back(Vector3(b.x, 0, b.y) + d); - points.push_back(Vector3(a.x, a.y, 0) - d); - points.push_back(Vector3(b.x, b.y, 0) - d); + points.push_back(Vector3(a.x, 0, a.y) - d); + points.push_back(Vector3(b.x, 0, b.y) - d); if (i % 90 == 0) { - points.push_back(Vector3(a.x, a.y, 0) + d); - points.push_back(Vector3(a.x, a.y, 0) - d); + points.push_back(Vector3(a.x, 0, a.y) + d); + points.push_back(Vector3(a.x, 0, a.y) - d); } Vector3 dud = i < 180 ? d : -d; - points.push_back(Vector3(0, a.y, a.x) + dud); - points.push_back(Vector3(0, b.y, b.x) + dud); - points.push_back(Vector3(a.y, 0, a.x) + dud); - points.push_back(Vector3(b.y, 0, b.x) + dud); + points.push_back(Vector3(0, a.x, a.y) + dud); + points.push_back(Vector3(0, b.x, b.y) + dud); + points.push_back(Vector3(a.y, a.x, 0) + dud); + points.push_back(Vector3(b.y, b.x, 0) + dud); } p_gizmo->add_lines(points, material); @@ -3576,31 +3486,31 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius; - collision_segments.push_back(Vector3(a.x, a.y, 0) + d); - collision_segments.push_back(Vector3(b.x, b.y, 0) + d); + collision_segments.push_back(Vector3(a.x, 0, a.y) + d); + collision_segments.push_back(Vector3(b.x, 0, b.y) + d); - collision_segments.push_back(Vector3(a.x, a.y, 0) - d); - collision_segments.push_back(Vector3(b.x, b.y, 0) - d); + collision_segments.push_back(Vector3(a.x, 0, a.y) - d); + collision_segments.push_back(Vector3(b.x, 0, b.y) - d); if (i % 16 == 0) { - collision_segments.push_back(Vector3(a.x, a.y, 0) + d); - collision_segments.push_back(Vector3(a.x, a.y, 0) - d); + collision_segments.push_back(Vector3(a.x, 0, a.y) + d); + collision_segments.push_back(Vector3(a.x, 0, a.y) - d); } Vector3 dud = i < 32 ? d : -d; - collision_segments.push_back(Vector3(0, a.y, a.x) + dud); - collision_segments.push_back(Vector3(0, b.y, b.x) + dud); - collision_segments.push_back(Vector3(a.y, 0, a.x) + dud); - collision_segments.push_back(Vector3(b.y, 0, b.x) + dud); + collision_segments.push_back(Vector3(0, a.x, a.y) + dud); + collision_segments.push_back(Vector3(0, b.x, b.y) + dud); + collision_segments.push_back(Vector3(a.y, a.x, 0) + dud); + collision_segments.push_back(Vector3(b.y, b.x, 0) + dud); } p_gizmo->add_collision_segments(collision_segments); Vector<Vector3> handles; handles.push_back(Vector3(cs2->get_radius(), 0, 0)); - handles.push_back(Vector3(0, 0, cs2->get_height() * 0.5 + cs2->get_radius())); + handles.push_back(Vector3(0, cs2->get_height() * 0.5 + cs2->get_radius(), 0)); p_gizmo->add_handles(handles, handles_material); } @@ -3698,7 +3608,7 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { if (Object::cast_to<ConvexPolygonShape>(*s)) { - PoolVector<Vector3> points = Object::cast_to<ConvexPolygonShape>(*s)->get_points(); + Vector<Vector3> points = Object::cast_to<ConvexPolygonShape>(*s)->get_points(); if (points.size() > 3) { @@ -3835,8 +3745,8 @@ void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { if (navmeshie.is_null()) return; - PoolVector<Vector3> vertices = navmeshie->get_vertices(); - PoolVector<Vector3>::Read vr = vertices.read(); + Vector<Vector3> vertices = navmeshie->get_vertices(); + const Vector3 *vr = vertices.ptr(); List<Face3> faces; for (int i = 0; i < navmeshie->get_polygon_count(); i++) { Vector<int> p = navmeshie->get_polygon(i); @@ -3855,11 +3765,11 @@ void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { return; Map<_EdgeKey, bool> edge_map; - PoolVector<Vector3> tmeshfaces; + Vector<Vector3> tmeshfaces; tmeshfaces.resize(faces.size() * 3); { - PoolVector<Vector3>::Write tw = tmeshfaces.write(); + Vector3 *tw = tmeshfaces.ptrw(); int tidx = 0; for (List<Face3>::Element *E = faces.front(); E; E = E->next()) { @@ -4190,8 +4100,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); |