mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-23 09:28:07 +01:00
Fix newly introduced potential crashes in mesh data resource editor.
This commit is contained in:
parent
a426e173f5
commit
5925b62b2c
@ -64,10 +64,13 @@ String MDIEdPlugin::get_name() const {
|
||||
void MDIEdPlugin::set_gizmo_visible(const bool visible) {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
|
||||
if (g.is_valid()) {
|
||||
g->set_visible(visible);
|
||||
current_mesh_data_instance->set_transform_gizmo_visible(!visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MDIEdPlugin::set_translate() {
|
||||
if (current_mesh_data_instance) {
|
||||
@ -157,18 +160,27 @@ EditorPlugin::AfterGUIInput MDIEdPlugin::forward_spatial_gui_input(Camera *camer
|
||||
void MDIEdPlugin::add_box() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->add_box();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::add_triangle() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->add_triangle();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::add_quad() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->add_quad();
|
||||
}
|
||||
}
|
||||
@ -176,12 +188,18 @@ void MDIEdPlugin::add_quad() {
|
||||
void MDIEdPlugin::add_triangle_at() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->add_triangle_at();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::add_quad_at() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->add_quad_at();
|
||||
}
|
||||
}
|
||||
@ -189,6 +207,9 @@ void MDIEdPlugin::add_quad_at() {
|
||||
void MDIEdPlugin::split() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->split();
|
||||
}
|
||||
}
|
||||
@ -196,6 +217,9 @@ void MDIEdPlugin::split() {
|
||||
void MDIEdPlugin::disconnect_action() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->disconnect_action();
|
||||
}
|
||||
}
|
||||
@ -203,12 +227,18 @@ void MDIEdPlugin::disconnect_action() {
|
||||
void MDIEdPlugin::create_face() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->create_face();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::delete_selected() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->delete_selected();
|
||||
}
|
||||
}
|
||||
@ -216,24 +246,36 @@ void MDIEdPlugin::delete_selected() {
|
||||
void MDIEdPlugin::generate_normals() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->generate_normals();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::remove_doubles() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->remove_doubles();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::merge_optimize() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->merge_optimize();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::generate_tangents() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->generate_tangents();
|
||||
}
|
||||
}
|
||||
@ -241,18 +283,27 @@ void MDIEdPlugin::generate_tangents() {
|
||||
void MDIEdPlugin::connect_to_first_selected() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->connect_to_first_selected();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::connect_to_avg() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->connect_to_avg();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::connect_to_last_selected() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->connect_to_last_selected();
|
||||
}
|
||||
}
|
||||
@ -260,18 +311,27 @@ void MDIEdPlugin::connect_to_last_selected() {
|
||||
void MDIEdPlugin::mark_seam() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->mark_seam();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::unmark_seam() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->unmark_seam();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::apply_seam() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->apply_seam();
|
||||
}
|
||||
}
|
||||
@ -279,6 +339,9 @@ void MDIEdPlugin::apply_seam() {
|
||||
void MDIEdPlugin::uv_unwrap() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->uv_unwrap();
|
||||
}
|
||||
}
|
||||
@ -286,18 +349,27 @@ void MDIEdPlugin::uv_unwrap() {
|
||||
void MDIEdPlugin::set_pivot_averaged() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->set_pivot_averaged();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::set_pivot_mdi_origin() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->set_translate();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::set_pivot_world_origin() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->set_pivot_world_origin();
|
||||
}
|
||||
}
|
||||
@ -305,18 +377,27 @@ void MDIEdPlugin::set_pivot_world_origin() {
|
||||
void MDIEdPlugin::visual_indicator_outline_set(bool on) {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->visual_indicator_outline_set(on);
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::visual_indicator_seam_set(bool on) {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->visual_indicator_seam_set(on);
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::visual_indicator_handle_set(bool on) {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->visual_indicator_handle_set(on);
|
||||
}
|
||||
}
|
||||
@ -324,6 +405,9 @@ void MDIEdPlugin::visual_indicator_handle_set(bool on) {
|
||||
void MDIEdPlugin::select_all() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->select_all();
|
||||
}
|
||||
}
|
||||
@ -331,18 +415,27 @@ void MDIEdPlugin::select_all() {
|
||||
void MDIEdPlugin::handle_selection_type_front() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->handle_selection_type_front();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::handle_selection_type_back() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->handle_selection_type_back();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::handle_selection_type_all() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->handle_selection_type_all();
|
||||
}
|
||||
}
|
||||
@ -350,12 +443,18 @@ void MDIEdPlugin::handle_selection_type_all() {
|
||||
void MDIEdPlugin::extrude() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->extrude();
|
||||
}
|
||||
}
|
||||
void MDIEdPlugin::clean_mesh() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->clean_mesh();
|
||||
}
|
||||
}
|
||||
@ -363,11 +462,18 @@ void MDIEdPlugin::clean_mesh() {
|
||||
void MDIEdPlugin::flip_selected_faces() {
|
||||
if (current_mesh_data_instance) {
|
||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||
if (!g.is_valid()) {
|
||||
return;
|
||||
}
|
||||
g->flip_selected_faces();
|
||||
}
|
||||
}
|
||||
|
||||
Ref<MDIGizmo> MDIEdPlugin::get_gizmo_from(MeshDataInstance *mdi) {
|
||||
if (!mdi) {
|
||||
return Ref<MDIGizmo>();
|
||||
}
|
||||
|
||||
Vector<Ref<SpatialGizmo>> gizmos = mdi->get_gizmos();
|
||||
|
||||
for (int i = 0; i < gizmos.size(); ++i) {
|
||||
@ -378,7 +484,7 @@ Ref<MDIGizmo> MDIEdPlugin::get_gizmo_from(MeshDataInstance *mdi) {
|
||||
}
|
||||
}
|
||||
|
||||
return Ref<SpatialGizmo>();
|
||||
return Ref<MDIGizmo>();
|
||||
}
|
||||
|
||||
MDIEdPlugin::MDIEdPlugin(EditorNode *p_node) {
|
||||
|
Loading…
Reference in New Issue
Block a user