diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 5e40c93c5..b1a232e9b 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -6594,7 +6594,6 @@ void SpatialEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(SoftBodySpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Sprite3DSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Label3DSpatialGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(SkeletonSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Position3DSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(RayCastSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SpringArmSpatialGizmoPlugin))); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index e847d405c..f7e443adb 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -1719,161 +1719,6 @@ void Position3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_collision_segments(cursor_points); } -///// - -SkeletonSpatialGizmoPlugin::SkeletonSpatialGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/skeleton", Color(1, 0.8, 0.4)); - create_material("skeleton_material", gizmo_color); -} - -bool SkeletonSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to(p_spatial) != nullptr; -} - -String SkeletonSpatialGizmoPlugin::get_name() const { - return "Skeleton"; -} - -int SkeletonSpatialGizmoPlugin::get_priority() const { - return -1; -} - -void SkeletonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { - Skeleton *skel = Object::cast_to(p_gizmo->get_spatial_node()); - - p_gizmo->clear(); - - Ref material = get_material("skeleton_material", p_gizmo); - - Ref surface_tool(memnew(SurfaceTool)); - - surface_tool->begin(Mesh::PRIMITIVE_LINES); - surface_tool->set_material(material); - Vector grests; - grests.resize(skel->get_bone_count()); - - Vector bones; - Vector weights; - bones.resize(4); - weights.resize(4); - - for (int i = 0; i < 4; i++) { - bones.write[i] = 0; - weights.write[i] = 0; - } - - weights.write[0] = 1; - - AABB aabb; - - //Color bonecolor = Color(1.0, 0.4, 0.4, 0.3); - //Color rootcolor = Color(0.4, 1.0, 0.4, 0.1); -/* - for (int i_bone = 0; i_bone < skel->get_bone_count(); i_bone++) { - int i = skel->get_process_order(i_bone); - - int parent = skel->get_bone_parent(i); - - if (parent >= 0) { - grests.write[i] = grests[parent] * skel->get_bone_rest(i); - - Vector3 v0 = grests[parent].origin; - Vector3 v1 = grests[i].origin; - Vector3 d = (v1 - v0).normalized(); - float dist = v0.distance_to(v1); - - //find closest axis - int closest = -1; - float closest_d = 0.0; - - for (int j = 0; j < 3; j++) { - float dp = Math::abs(grests[parent].basis[j].normalized().dot(d)); - if (j == 0 || dp > closest_d) { - closest = j; - } - } - - //find closest other - Vector3 first; - Vector3 points[4]; - int pointidx = 0; - for (int j = 0; j < 3; j++) { - bones.write[0] = parent; - surface_tool->add_bones(bones); - surface_tool->add_weights(weights); - surface_tool->add_color(rootcolor); - surface_tool->add_vertex(v0 - grests[parent].basis[j].normalized() * dist * 0.05); - surface_tool->add_bones(bones); - surface_tool->add_weights(weights); - surface_tool->add_color(rootcolor); - surface_tool->add_vertex(v0 + grests[parent].basis[j].normalized() * dist * 0.05); - - if (j == closest) { - continue; - } - - Vector3 axis; - if (first == Vector3()) { - axis = d.cross(d.cross(grests[parent].basis[j])).normalized(); - first = axis; - } else { - axis = d.cross(first).normalized(); - } - - for (int k = 0; k < 2; k++) { - if (k == 1) { - axis = -axis; - } - Vector3 point = v0 + d * dist * 0.2; - point += axis * dist * 0.1; - - bones.write[0] = parent; - surface_tool->add_bones(bones); - surface_tool->add_weights(weights); - surface_tool->add_color(bonecolor); - surface_tool->add_vertex(v0); - surface_tool->add_bones(bones); - surface_tool->add_weights(weights); - surface_tool->add_color(bonecolor); - surface_tool->add_vertex(point); - - bones.write[0] = parent; - surface_tool->add_bones(bones); - surface_tool->add_weights(weights); - surface_tool->add_color(bonecolor); - surface_tool->add_vertex(point); - bones.write[0] = i; - surface_tool->add_bones(bones); - surface_tool->add_weights(weights); - surface_tool->add_color(bonecolor); - surface_tool->add_vertex(v1); - points[pointidx++] = point; - } - } - - SWAP(points[1], points[2]); - for (int j = 0; j < 4; j++) { - bones.write[0] = parent; - surface_tool->add_bones(bones); - surface_tool->add_weights(weights); - surface_tool->add_color(bonecolor); - surface_tool->add_vertex(points[j]); - surface_tool->add_bones(bones); - surface_tool->add_weights(weights); - surface_tool->add_color(bonecolor); - surface_tool->add_vertex(points[(j + 1) % 4]); - } - } else { - grests.write[i] = skel->get_bone_rest(i); - bones.write[0] = i; - } - } - */ - - Ref m = surface_tool->commit(); - p_gizmo->add_mesh(m, false, skel->register_skin(Ref())); -} - //// PhysicalBoneSpatialGizmoPlugin::PhysicalBoneSpatialGizmoPlugin() { diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index aa245fd46..687e6ff80 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -170,18 +170,6 @@ public: Position3DSpatialGizmoPlugin(); }; -class SkeletonSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - GDCLASS(SkeletonSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - SkeletonSpatialGizmoPlugin(); -}; - class PhysicalBoneSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { GDCLASS(PhysicalBoneSpatialGizmoPlugin, EditorSpatialGizmoPlugin); diff --git a/modules/skeleton_editor/skeleton_editor_module_plugin.cpp b/modules/skeleton_editor/skeleton_editor_module_plugin.cpp index 7ad7c7319..78d017a33 100644 --- a/modules/skeleton_editor/skeleton_editor_module_plugin.cpp +++ b/modules/skeleton_editor/skeleton_editor_module_plugin.cpp @@ -31,14 +31,5 @@ SkeletonEditorModulePlugin::SkeletonEditorModulePlugin(EditorNode *p_node) { void SkeletonEditorModulePlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { add_spatial_gizmo_plugin(Ref(memnew(ModuleSkeletonSpatialGizmoPlugin))); - } else if (p_what == NOTIFICATION_POST_ENTER_TREE) { - //Removing the built in SkeletonSpatialGizmoPlugin - //it is allocated in SpatialEditor's NOTIFICATION_ENTER_TREE, that's why we are in NOTIFICATION_POST_ENTER_TREE - Ref original_plugin = SpatialEditor::get_singleton()->get_gizmo_plugin("Skeleton"); - - if (original_plugin.is_valid()) { - //note this is safe to do, as this gizmo is allocated by the SpatialEditor itself. - SpatialEditor::get_singleton()->remove_gizmo_plugin(original_plugin); - } } }