mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 12:26:59 +01:00
Removed the built in SkeletonSpatialGizmoPlugin. (The skeleton editor module used to remove it anyway.)
This commit is contained in:
parent
07fa703645
commit
7e451e0f30
@ -6594,7 +6594,6 @@ void SpatialEditor::_register_all_gizmos() {
|
||||
add_gizmo_plugin(Ref<SoftBodySpatialGizmoPlugin>(memnew(SoftBodySpatialGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Sprite3DSpatialGizmoPlugin>(memnew(Sprite3DSpatialGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Label3DSpatialGizmoPlugin>(memnew(Label3DSpatialGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<SkeletonSpatialGizmoPlugin>(memnew(SkeletonSpatialGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Position3DSpatialGizmoPlugin>(memnew(Position3DSpatialGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<RayCastSpatialGizmoPlugin>(memnew(RayCastSpatialGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<SpringArmSpatialGizmoPlugin>(memnew(SpringArmSpatialGizmoPlugin)));
|
||||
|
@ -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<Skeleton>(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<Skeleton>(p_gizmo->get_spatial_node());
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
Ref<Material> material = get_material("skeleton_material", p_gizmo);
|
||||
|
||||
Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
|
||||
|
||||
surface_tool->begin(Mesh::PRIMITIVE_LINES);
|
||||
surface_tool->set_material(material);
|
||||
Vector<Transform> grests;
|
||||
grests.resize(skel->get_bone_count());
|
||||
|
||||
Vector<int> bones;
|
||||
Vector<float> 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<ArrayMesh> m = surface_tool->commit();
|
||||
p_gizmo->add_mesh(m, false, skel->register_skin(Ref<Skin>()));
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
PhysicalBoneSpatialGizmoPlugin::PhysicalBoneSpatialGizmoPlugin() {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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<ModuleSkeletonSpatialGizmoPlugin>(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<EditorSpatialGizmoPlugin> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user