Debian Codegraph @

editor/scene/3d/mesh_instance_3d_editor_plugin.h

raw symbols SCIP
1 /**************************************************************************/
2 /* mesh_instance_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 "scene/3d/mesh_instance_3d.h"
35 #include "scene/gui/option_button.h"
36
37 class AcceptDialog;
38 class AspectRatioContainer;
39 class ConfirmationDialog;
40 class MenuButton;
41 class SpinBox;
42
43 class MeshInstance3DEditor : public Control {
44 GDCLASS(MeshInstance3DEditor, Control);
45
46 enum Menu {
47 MENU_OPTION_CREATE_COLLISION_SHAPE,
48 MENU_OPTION_CREATE_NAVMESH,
49 MENU_OPTION_CREATE_OUTLINE_MESH,
50 MENU_OPTION_CREATE_DEBUG_TANGENTS,
51 MENU_OPTION_CREATE_UV2,
52 MENU_OPTION_DEBUG_UV1,
53 MENU_OPTION_DEBUG_UV2,
54 };
55
56 enum ShapePlacement {
57 SHAPE_PLACEMENT_SIBLING,
58 SHAPE_PLACEMENT_STATIC_BODY_CHILD,
59 };
60
61 enum ShapeType {
62 SHAPE_TYPE_TRIMESH,
63 SHAPE_TYPE_SINGLE_CONVEX,
64 SHAPE_TYPE_SIMPLIFIED_CONVEX,
65 SHAPE_TYPE_MULTIPLE_CONVEX,
66 SHAPE_TYPE_BOUNDING_BOX,
67 SHAPE_TYPE_CAPSULE,
68 SHAPE_TYPE_CYLINDER,
69 SHAPE_TYPE_SPHERE,
70 SHAPE_TYPE_PRIMITIVE,
71 };
72
73 enum ShapeAxis {
74 SHAPE_AXIS_X,
75 SHAPE_AXIS_Y,
76 SHAPE_AXIS_Z,
77 SHAPE_AXIS_LONGEST,
78 };
79
80 MeshInstance3D *node = nullptr;
81
82 MenuButton *options = nullptr;
83
84 ConfirmationDialog *outline_dialog = nullptr;
85 SpinBox *outline_size = nullptr;
86
87 ConfirmationDialog *shape_dialog = nullptr;
88 OptionButton *shape_type = nullptr;
89 OptionButton *shape_placement = nullptr;
90 Label *shape_axis_label = nullptr;
91 OptionButton *shape_axis = nullptr;
92 Transform3D shape_offset_transform;
93
94 AcceptDialog *err_dialog = nullptr;
95
96 AcceptDialog *debug_uv_dialog = nullptr;
97 AspectRatioContainer *debug_uv_arc = nullptr;
98 Control *debug_uv = nullptr;
99 Vector<Vector2> uv_lines;
100
101 ConfirmationDialog *navigation_mesh_dialog = nullptr;
102
103 void _shape_dialog_about_to_popup();
104 void _shape_type_selected(int p_option);
105 void _create_collision_shape();
106 Vector<Ref<Shape3D>> create_shape_from_mesh(Ref<Mesh> p_mesh, int p_option, bool p_verbose);
107 void _menu_option(int p_option);
108 void _create_outline_mesh();
109 void _create_navigation_mesh();
110
111 void _create_uv_lines(int p_layer);
112 friend class MeshInstance3DEditorPlugin;
113
114 void _debug_uv_draw();
115
116 protected:
117 void _node_removed(Node *p_node);
118
119 void _notification(int p_what);
120
121 public:
122 void edit(MeshInstance3D *p_mesh);
123 MeshInstance3DEditor();
124 };
125
126 class MeshInstance3DEditorPlugin : public EditorPlugin {
127 GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin);
128
129 MeshInstance3DEditor *mesh_editor = nullptr;
130
131 public:
132 virtual String get_plugin_name() const override { return "MeshInstance3D"; }
133 bool has_main_screen() const override { return false; }
134 virtual void edit(Object *p_object) override;
135 virtual bool handles(Object *p_object) const override;
136 virtual void make_visible(bool p_visible) override;
137
138 MeshInstance3DEditorPlugin();
139 };