Debian Codegraph @

scene/3d/visual_instance_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* visual_instance_3d.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 "scene/3d/node_3d.h"
34
35 class TriangleMesh;
36
37 class VisualInstance3D : public Node3D {
38 GDCLASS(VisualInstance3D, Node3D);
39
40 RID base;
41 RID instance;
42 uint32_t layers = 1;
43 float sorting_offset = 0.0;
44 bool sorting_use_aabb_center = true;
45
46 protected:
47 void _update_visibility();
48
49 void set_instance_use_identity_transform(bool p_enable);
50 virtual void fti_update_servers_xform() override;
51
52 void _notification(int p_what);
53 static void _bind_methods();
54
55 GDVIRTUAL0RC(AABB, _get_aabb)
56 public:
57 static constexpr AncestralClass static_ancestral_class = AncestralClass::VISUAL_INSTANCE_3D;
58
59 enum GetFacesFlags {
60 FACES_SOLID = 1, // solid geometry
61 FACES_ENCLOSING = 2,
62 FACES_DYNAMIC = 4 // dynamic object geometry
63
64 };
65
66 RID get_instance() const;
67 virtual AABB get_aabb() const;
68
69 void set_base(const RID &p_base);
70 RID get_base() const;
71
72 void set_layer_mask(uint32_t p_mask);
73 uint32_t get_layer_mask() const;
74
75 void set_layer_mask_value(int p_layer_number, bool p_enable);
76 bool get_layer_mask_value(int p_layer_number) const;
77
78 void set_sorting_offset(float p_offset);
79 float get_sorting_offset() const;
80
81 void set_sorting_use_aabb_center(bool p_enabled);
82 bool is_sorting_use_aabb_center() const;
83
84 VisualInstance3D();
85 ~VisualInstance3D();
86 };
87
88 class GeometryInstance3D : public VisualInstance3D {
89 GDCLASS(GeometryInstance3D, VisualInstance3D);
90
91 public:
92 static constexpr AncestralClass static_ancestral_class = AncestralClass::GEOMETRY_INSTANCE_3D;
93
94 enum ShadowCastingSetting {
95 SHADOW_CASTING_SETTING_OFF = RS::SHADOW_CASTING_SETTING_OFF,
96 SHADOW_CASTING_SETTING_ON = RS::SHADOW_CASTING_SETTING_ON,
97 SHADOW_CASTING_SETTING_DOUBLE_SIDED = RS::SHADOW_CASTING_SETTING_DOUBLE_SIDED,
98 SHADOW_CASTING_SETTING_SHADOWS_ONLY = RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY
99 };
100
101 enum GIMode {
102 GI_MODE_DISABLED,
103 GI_MODE_STATIC,
104 GI_MODE_DYNAMIC
105 };
106
107 enum LightmapScale {
108 LIGHTMAP_SCALE_1X,
109 LIGHTMAP_SCALE_2X,
110 LIGHTMAP_SCALE_4X,
111 LIGHTMAP_SCALE_8X,
112 LIGHTMAP_SCALE_MAX,
113 };
114
115 enum VisibilityRangeFadeMode {
116 VISIBILITY_RANGE_FADE_DISABLED = RS::VISIBILITY_RANGE_FADE_DISABLED,
117 VISIBILITY_RANGE_FADE_SELF = RS::VISIBILITY_RANGE_FADE_SELF,
118 VISIBILITY_RANGE_FADE_DEPENDENCIES = RS::VISIBILITY_RANGE_FADE_DEPENDENCIES,
119 };
120
121 private:
122 ShadowCastingSetting shadow_casting_setting = SHADOW_CASTING_SETTING_ON;
123 Ref<Material> material_override;
124 Ref<Material> material_overlay;
125
126 float visibility_range_begin = 0.0;
127 float visibility_range_end = 0.0;
128 float visibility_range_begin_margin = 0.0;
129 float visibility_range_end_margin = 0.0;
130 VisibilityRangeFadeMode visibility_range_fade_mode = VISIBILITY_RANGE_FADE_DISABLED;
131
132 float transparency = 0.0f;
133
134 float lod_bias = 1.0;
135
136 mutable HashMap<StringName, Variant> instance_shader_parameters;
137 mutable HashMap<StringName, StringName> instance_shader_parameter_property_remap;
138
139 float extra_cull_margin = 0.0;
140 AABB custom_aabb;
141 float lightmap_texel_scale = 1.0f;
142 GIMode gi_mode = GI_MODE_STATIC;
143 bool ignore_occlusion_culling = false;
144
145 const StringName *_instance_uniform_get_remap(const StringName &p_name) const;
146
147 protected:
148 bool _set(const StringName &p_name, const Variant &p_value);
149 bool _get(const StringName &p_name, Variant &r_ret) const;
150 void _get_property_list(List<PropertyInfo> *p_list) const;
151 void _validate_property(PropertyInfo &p_property) const;
152
153 static void _bind_methods();
154
155 public:
156 void set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting);
157 ShadowCastingSetting get_cast_shadows_setting() const;
158
159 void set_transparency(float p_transparency);
160 float get_transparency() const;
161
162 void set_visibility_range_begin(float p_dist);
163 float get_visibility_range_begin() const;
164
165 void set_visibility_range_end(float p_dist);
166 float get_visibility_range_end() const;
167
168 void set_visibility_range_begin_margin(float p_dist);
169 float get_visibility_range_begin_margin() const;
170
171 void set_visibility_range_end_margin(float p_dist);
172 float get_visibility_range_end_margin() const;
173
174 void set_visibility_range_fade_mode(VisibilityRangeFadeMode p_mode);
175 VisibilityRangeFadeMode get_visibility_range_fade_mode() const;
176
177 void set_material_override(const Ref<Material> &p_material);
178 Ref<Material> get_material_override() const;
179
180 void set_material_overlay(const Ref<Material> &p_material);
181 Ref<Material> get_material_overlay() const;
182
183 void set_extra_cull_margin(float p_margin);
184 float get_extra_cull_margin() const;
185
186 void set_lod_bias(float p_bias);
187 float get_lod_bias() const;
188
189 void set_gi_mode(GIMode p_mode);
190 GIMode get_gi_mode() const;
191
192 void set_lightmap_texel_scale(float p_scale);
193 float get_lightmap_texel_scale() const;
194
195 #ifndef DISABLE_DEPRECATED
196 void set_lightmap_scale(GeometryInstance3D::LightmapScale p_scale);
197 LightmapScale get_lightmap_scale() const;
198 #endif // DISABLE_DEPRECATED
199
200 void set_instance_shader_parameter(const StringName &p_name, const Variant &p_value);
201 Variant get_instance_shader_parameter(const StringName &p_name) const;
202
203 void set_custom_aabb(AABB p_aabb);
204 AABB get_custom_aabb() const;
205
206 void set_ignore_occlusion_culling(bool p_enabled);
207 bool is_ignoring_occlusion_culling();
208
209 virtual Ref<TriangleMesh> generate_triangle_mesh() const;
210
211 PackedStringArray get_configuration_warnings() const override;
212 GeometryInstance3D();
213 virtual ~GeometryInstance3D();
214 };
215
216 VARIANT_ENUM_CAST(GeometryInstance3D::ShadowCastingSetting);
217 VARIANT_ENUM_CAST(GeometryInstance3D::GIMode);
218 VARIANT_ENUM_CAST(GeometryInstance3D::LightmapScale);
219 VARIANT_ENUM_CAST(GeometryInstance3D::VisibilityRangeFadeMode);