mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 05:19:50 +01:00
Now in order to edit MeshDataInstance a new edit mode has to be togged from the top bar. While this mode is enabled the edited MeshDatainstace can't be deselected. Also now Mesh Data Editor's sidebar will only be visible in this mode, along with the editor gizmo.
This commit is contained in:
parent
bafd6d1d8d
commit
3220e9c592
@ -27,6 +27,7 @@ SOFTWARE.
|
|||||||
#include "./uv_editor/mdr_uv_rect_editor.h"
|
#include "./uv_editor/mdr_uv_rect_editor.h"
|
||||||
#include "./uv_editor/mdr_uv_rect_editor_popup.h"
|
#include "./uv_editor/mdr_uv_rect_editor_popup.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
|
#include "editor/plugins/spatial_editor_plugin.h"
|
||||||
#include "mdi_ed_plugin.h"
|
#include "mdi_ed_plugin.h"
|
||||||
#include "scene/gui/box_container.h"
|
#include "scene/gui/box_container.h"
|
||||||
#include "scene/gui/button.h"
|
#include "scene/gui/button.h"
|
||||||
@ -34,6 +35,21 @@ SOFTWARE.
|
|||||||
#include "scene/gui/scroll_container.h"
|
#include "scene/gui/scroll_container.h"
|
||||||
#include "scene/gui/separator.h"
|
#include "scene/gui/separator.h"
|
||||||
|
|
||||||
|
bool MDIEd::is_editing() {
|
||||||
|
return _editing;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MDIEd::make_visible(const bool visible) {
|
||||||
|
_edit_mode_button->set_visible(visible);
|
||||||
|
|
||||||
|
if (!visible) {
|
||||||
|
hide();
|
||||||
|
} else {
|
||||||
|
set_visible(_editing);
|
||||||
|
_plugin->set_gizmo_visible(_editing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MDIEd::set_plugin(MDIEdPlugin *plugin) {
|
void MDIEd::set_plugin(MDIEdPlugin *plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
uv_editor->set_plugin(plugin);
|
uv_editor->set_plugin(plugin);
|
||||||
@ -871,11 +887,36 @@ MDIEd::MDIEd() {
|
|||||||
uv_editor->set_resizable(true);
|
uv_editor->set_resizable(true);
|
||||||
uv_editor->hide();
|
uv_editor->hide();
|
||||||
popups_node->add_child(uv_editor);
|
popups_node->add_child(uv_editor);
|
||||||
|
|
||||||
|
_edit_mode_button = memnew(Button);
|
||||||
|
_edit_mode_button->set_flat(true);
|
||||||
|
_edit_mode_button->set_toggle_mode(true);
|
||||||
|
_edit_mode_button->set_focus_mode(BaseButton::FOCUS_NONE);
|
||||||
|
_edit_mode_button->set_text("Edit");
|
||||||
|
_edit_mode_button->set_tooltip(TTR("Edit MeshDataResource."));
|
||||||
|
_edit_mode_button->connect("toggled", this, "_edit_mode_toggled");
|
||||||
|
SpatialEditor::get_singleton()->add_control_to_menu_panel(_edit_mode_button);
|
||||||
|
|
||||||
|
_editing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MDIEd::~MDIEd() {
|
MDIEd::~MDIEd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MDIEd::_notification(int p_what) {
|
||||||
|
switch (p_what) {
|
||||||
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
_edit_mode_button->set_icon(get_theme_icon("MeshInstance", "EditorIcons"));
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MDIEd::_edit_mode_toggled(const bool pressed) {
|
||||||
|
_editing = pressed;
|
||||||
|
|
||||||
|
make_visible(_editing);
|
||||||
|
}
|
||||||
|
|
||||||
void MDIEd::_bind_methods() {
|
void MDIEd::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("on_edit_mode_translate_toggled"), &MDIEd::on_edit_mode_translate_toggled);
|
ClassDB::bind_method(D_METHOD("on_edit_mode_translate_toggled"), &MDIEd::on_edit_mode_translate_toggled);
|
||||||
ClassDB::bind_method(D_METHOD("on_edit_mode_rotate_toggled"), &MDIEd::on_edit_mode_rotate_toggled);
|
ClassDB::bind_method(D_METHOD("on_edit_mode_rotate_toggled"), &MDIEd::on_edit_mode_rotate_toggled);
|
||||||
@ -936,4 +977,6 @@ void MDIEd::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("on_add_box_pressed"), &MDIEd::on_add_box_pressed);
|
ClassDB::bind_method(D_METHOD("on_add_box_pressed"), &MDIEd::on_add_box_pressed);
|
||||||
ClassDB::bind_method(D_METHOD("on_add_triangle_pressed"), &MDIEd::on_add_triangle_pressed);
|
ClassDB::bind_method(D_METHOD("on_add_triangle_pressed"), &MDIEd::on_add_triangle_pressed);
|
||||||
ClassDB::bind_method(D_METHOD("on_add_quad_pressed"), &MDIEd::on_add_quad_pressed);
|
ClassDB::bind_method(D_METHOD("on_add_quad_pressed"), &MDIEd::on_add_quad_pressed);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("_edit_mode_toggled"), &MDIEd::_edit_mode_toggled);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,9 @@ class MDIEd : public PanelContainer {
|
|||||||
GDCLASS(MDIEd, PanelContainer);
|
GDCLASS(MDIEd, PanelContainer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool is_editing();
|
||||||
|
void make_visible(const bool visible);
|
||||||
|
|
||||||
void set_plugin(MDIEdPlugin *plugin);
|
void set_plugin(MDIEdPlugin *plugin);
|
||||||
void set_mesh_data_resource(const Ref<MeshDataResource> &a);
|
void set_mesh_data_resource(const Ref<MeshDataResource> &a);
|
||||||
void set_mesh_data_instance(MeshDataInstance *a);
|
void set_mesh_data_instance(MeshDataInstance *a);
|
||||||
@ -147,8 +150,15 @@ public:
|
|||||||
Button *_selection_mode_edge_button;
|
Button *_selection_mode_edge_button;
|
||||||
Button *_selection_mode_face_button;
|
Button *_selection_mode_face_button;
|
||||||
|
|
||||||
|
Button *_edit_mode_button;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
void _edit_mode_toggled(const bool pressed);
|
||||||
|
|
||||||
|
bool _editing;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,18 +54,20 @@ void MDIEdPlugin::edit(Object *object) {
|
|||||||
current_mesh_data_instance = mdi;
|
current_mesh_data_instance = mdi;
|
||||||
}
|
}
|
||||||
void MDIEdPlugin::make_visible(bool visible) {
|
void MDIEdPlugin::make_visible(bool visible) {
|
||||||
if (visible) {
|
mdi_ed_gui->make_visible(visible);
|
||||||
mdi_ed_gui->show();
|
|
||||||
}
|
|
||||||
//else
|
|
||||||
//mdi_ed_gui.hide()
|
|
||||||
//figure out how to hide it when something else gets selected, don't hide on unselect
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String MDIEdPlugin::get_name() const {
|
String MDIEdPlugin::get_name() const {
|
||||||
return "MeshDataResourceEditor";
|
return "MeshDataResourceEditor";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MDIEdPlugin::set_gizmo_visible(const bool visible) {
|
||||||
|
if (current_mesh_data_instance) {
|
||||||
|
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||||
|
g->set_visible(visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MDIEdPlugin::set_translate() {
|
void MDIEdPlugin::set_translate() {
|
||||||
if (current_mesh_data_instance) {
|
if (current_mesh_data_instance) {
|
||||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||||
@ -137,9 +139,14 @@ EditorPlugin::AfterGUIInput MDIEdPlugin::forward_spatial_gui_input(Camera *camer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (current_mesh_data_instance) {
|
if (current_mesh_data_instance) {
|
||||||
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
if (mdi_ed_gui->is_editing()) {
|
||||||
if (g.is_valid()) {
|
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
|
||||||
return g->forward_spatial_gui_input(camera, p_event);
|
|
||||||
|
if (g.is_valid()) {
|
||||||
|
return g->forward_spatial_gui_input(camera, p_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EditorPlugin::AFTER_GUI_INPUT_NO_DESELECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/input/input_event.h"
|
#include "core/input/input_event.h"
|
||||||
|
|
||||||
//TODO:
|
|
||||||
//Remove gizmo registration, it's not needed anymore
|
|
||||||
|
|
||||||
class Camera;
|
class Camera;
|
||||||
class MDIGizmo;
|
class MDIGizmo;
|
||||||
class MeshDataResource;
|
class MeshDataResource;
|
||||||
@ -47,6 +44,8 @@ public:
|
|||||||
|
|
||||||
String get_name() const;
|
String get_name() const;
|
||||||
|
|
||||||
|
void set_gizmo_visible(const bool visible);
|
||||||
|
|
||||||
void set_translate();
|
void set_translate();
|
||||||
void set_scale();
|
void set_scale();
|
||||||
void set_rotate();
|
void set_rotate();
|
||||||
|
@ -32,6 +32,11 @@ SOFTWARE.
|
|||||||
#include "modules/mesh_utils/mesh_utils.h"
|
#include "modules/mesh_utils/mesh_utils.h"
|
||||||
#include "scene/3d/camera.h"
|
#include "scene/3d/camera.h"
|
||||||
|
|
||||||
|
void MDIGizmo::set_visible(const bool visible) {
|
||||||
|
_visible = visible;
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
void MDIGizmo::setup() {
|
void MDIGizmo::setup() {
|
||||||
MeshDataInstance *mdi = Object::cast_to<MeshDataInstance>(get_spatial_node());
|
MeshDataInstance *mdi = Object::cast_to<MeshDataInstance>(get_spatial_node());
|
||||||
|
|
||||||
@ -151,6 +156,10 @@ void MDIGizmo::set_handle(int index, bool secondary, Camera *camera, const Point
|
|||||||
void MDIGizmo::redraw() {
|
void MDIGizmo::redraw() {
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
|
if (!_visible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_mdr.is_valid()) {
|
if (!_mdr.is_valid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -606,7 +615,7 @@ EditorPlugin::AfterGUIInput MDIGizmo::forward_spatial_gui_input(Camera *camera,
|
|||||||
|
|
||||||
// Dont consume the event here, because the handles will get stuck
|
// Dont consume the event here, because the handles will get stuck
|
||||||
// to the mouse pointer if we return true
|
// to the mouse pointer if we return true
|
||||||
return EditorPlugin::AFTER_GUI_INPUT_PASS;
|
return EditorPlugin::AFTER_GUI_INPUT_NO_DESELECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event_button->is_pressed()) {
|
if (!event_button->is_pressed()) {
|
||||||
@ -625,13 +634,13 @@ EditorPlugin::AfterGUIInput MDIGizmo::forward_spatial_gui_input(Camera *camera,
|
|||||||
if (selection_click(camera, event)) {
|
if (selection_click(camera, event)) {
|
||||||
return EditorPlugin::AFTER_GUI_INPUT_STOP;
|
return EditorPlugin::AFTER_GUI_INPUT_STOP;
|
||||||
} else {
|
} else {
|
||||||
return EditorPlugin::AFTER_GUI_INPUT_PASS;
|
return EditorPlugin::AFTER_GUI_INPUT_NO_DESELECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
selection_drag(camera, event_button);
|
selection_drag(camera, event_button);
|
||||||
// Always return false here, so the drag rect thing disappears in the editor
|
// Always return false here, so the drag rect thing disappears in the editor
|
||||||
return EditorPlugin::AFTER_GUI_INPUT_PASS;
|
return EditorPlugin::AFTER_GUI_INPUT_NO_DESELECT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// event is pressed
|
// event is pressed
|
||||||
@ -641,7 +650,7 @@ EditorPlugin::AfterGUIInput MDIGizmo::forward_spatial_gui_input(Camera *camera,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EditorPlugin::AFTER_GUI_INPUT_PASS;
|
return EditorPlugin::AFTER_GUI_INPUT_NO_DESELECT;
|
||||||
}
|
}
|
||||||
void MDIGizmo::add_to_all_selected(const Vector3 &ofs) {
|
void MDIGizmo::add_to_all_selected(const Vector3 &ofs) {
|
||||||
for (int i = 0; i < _selected_points.size(); ++i) {
|
for (int i = 0; i < _selected_points.size(); ++i) {
|
||||||
@ -2204,6 +2213,8 @@ MDIGizmo::MDIGizmo() {
|
|||||||
|
|
||||||
_editor_plugin = nullptr;
|
_editor_plugin = nullptr;
|
||||||
_undo_redo = nullptr;
|
_undo_redo = nullptr;
|
||||||
|
|
||||||
|
_visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MDIGizmo::~MDIGizmo() {
|
MDIGizmo::~MDIGizmo() {
|
||||||
|
@ -74,6 +74,8 @@ public:
|
|||||||
HANDLE_SELECTION_TYPE_ALL = 2,
|
HANDLE_SELECTION_TYPE_ALL = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void set_visible(const bool visible);
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
void set_editor_plugin(EditorPlugin *editor_plugin);
|
void set_editor_plugin(EditorPlugin *editor_plugin);
|
||||||
|
|
||||||
@ -234,6 +236,8 @@ public:
|
|||||||
EditorPlugin *_editor_plugin;
|
EditorPlugin *_editor_plugin;
|
||||||
UndoRedo *_undo_redo;
|
UndoRedo *_undo_redo;
|
||||||
|
|
||||||
|
bool _visible;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user