Debian Codegraph @

modules/navigation_3d/editor/navigation_obstacle_3d_editor_plugin.h

raw symbols SCIP
1 /**************************************************************************/
2 /* navigation_obstacle_3d_editor_plugin.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
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 };