| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "editor/plugins/editor_plugin.h" |
| 34 |
#include "editor/scene/3d/node_3d_editor_gizmos.h" |
| 35 |
#include "scene/gui/box_container.h" |
| 36 |
|
| 37 |
class Button; |
| 38 |
class ConfirmationDialog; |
| 39 |
class NavigationObstacle3D; |
| 40 |
|
| 41 |
class NavigationObstacle3DGizmoPlugin : public EditorNode3DGizmoPlugin { |
| 42 |
GDCLASS(NavigationObstacle3DGizmoPlugin, EditorNode3DGizmoPlugin); |
| 43 |
|
| 44 |
public: |
| 45 |
virtual bool has_gizmo(Node3D *p_spatial) override; |
| 46 |
virtual String get_gizmo_name() const override; |
| 47 |
|
| 48 |
virtual void redraw(EditorNode3DGizmo *p_gizmo) override; |
| 49 |
|
| 50 |
bool can_be_hidden() const override; |
| 51 |
int get_priority() const override; |
| 52 |
|
| 53 |
virtual int subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const override; |
| 54 |
virtual Vector<int> subgizmos_intersect_frustum(const EditorNode3DGizmo *p_gizmo, const Camera3D *p_camera, const Vector<Plane> &p_frustum) const override; |
| 55 |
virtual Transform3D get_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id) const override; |
| 56 |
virtual void set_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id, Transform3D p_transform) override; |
| 57 |
virtual void commit_subgizmos(const EditorNode3DGizmo *p_gizmo, const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel = false) override; |
| 58 |
|
| 59 |
NavigationObstacle3DGizmoPlugin(); |
| 60 |
}; |
| 61 |
|
| 62 |
class NavigationObstacle3DEditorPlugin : public EditorPlugin { |
| 63 |
GDCLASS(NavigationObstacle3DEditorPlugin, EditorPlugin); |
| 64 |
|
| 65 |
Ref<NavigationObstacle3DGizmoPlugin> obstacle_3d_gizmo_plugin; |
| 66 |
|
| 67 |
NavigationObstacle3D *obstacle_node = nullptr; |
| 68 |
|
| 69 |
Ref<StandardMaterial3D> line_material; |
| 70 |
Ref<StandardMaterial3D> handle_material; |
| 71 |
|
| 72 |
RID point_lines_mesh_rid; |
| 73 |
RID point_lines_instance_rid; |
| 74 |
RID point_handle_mesh_rid; |
| 75 |
RID point_handles_instance_rid; |
| 76 |
|
| 77 |
public: |
| 78 |
enum Mode { |
| 79 |
MODE_CREATE = 0, |
| 80 |
MODE_EDIT, |
| 81 |
MODE_DELETE, |
| 82 |
ACTION_FLIP, |
| 83 |
ACTION_CLEAR, |
| 84 |
}; |
| 85 |
|
| 86 |
private: |
| 87 |
int mode = MODE_EDIT; |
| 88 |
|
| 89 |
int edited_point = 0; |
| 90 |
Vector3 edited_point_pos; |
| 91 |
Vector<Vector3> pre_move_edit; |
| 92 |
Vector<Vector3> wip_vertices; |
| 93 |
bool wip_active = false; |
| 94 |
bool snap_ignore = false; |
| 95 |
|
| 96 |
void _wip_close(); |
| 97 |
void _wip_cancel(); |
| 98 |
void _update_theme(); |
| 99 |
|
| 100 |
Button *button_create = nullptr; |
| 101 |
Button *button_edit = nullptr; |
| 102 |
Button *button_delete = nullptr; |
| 103 |
Button *button_flip = nullptr; |
| 104 |
Button *button_clear = nullptr; |
| 105 |
|
| 106 |
ConfirmationDialog *button_clear_dialog = nullptr; |
| 107 |
|
| 108 |
protected: |
| 109 |
void _notification(int p_what); |
| 110 |
void _node_removed(Node *p_node); |
| 111 |
|
| 112 |
public: |
| 113 |
HBoxContainer *obstacle_editor = nullptr; |
| 114 |
static NavigationObstacle3DEditorPlugin *singleton; |
| 115 |
|
| 116 |
void redraw(); |
| 117 |
|
| 118 |
void set_mode(int p_mode); |
| 119 |
int get_mode() { return mode; } |
| 120 |
|
| 121 |
void action_flip_vertices(); |
| 122 |
void action_clear_vertices(); |
| 123 |
|
| 124 |
virtual EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override; |
| 125 |
|
| 126 |
virtual String get_plugin_name() const override { return "NavigationObstacle3DEditor"; } |
| 127 |
bool has_main_screen() const override { return false; } |
| 128 |
virtual void edit(Object *p_object) override; |
| 129 |
virtual bool handles(Object *p_object) const override; |
| 130 |
virtual void make_visible(bool p_visible) override; |
| 131 |
|
| 132 |
NavigationObstacle3DEditorPlugin(); |
| 133 |
~NavigationObstacle3DEditorPlugin(); |
| 134 |
}; |