Debian Codegraph @

servers/rendering/renderer_geometry_instance.h

raw symbols SCIP
1 /**************************************************************************/
2 /* renderer_geometry_instance.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 "core/math/rect2.h"
34 #include "core/math/transform_3d.h"
35 #include "core/templates/rid.h"
36 #include "storage/utilities.h"
37
38 // API definition for our RenderGeometryInstance class so we can expose this through GDExtension in the near future
39 class RenderGeometryInstance {
40 public:
41 virtual ~RenderGeometryInstance() {}
42
43 virtual void _mark_dirty() = 0;
44
45 virtual void set_skeleton(RID p_skeleton) = 0;
46 virtual void set_material_override(RID p_override) = 0;
47 virtual void set_material_overlay(RID p_overlay) = 0;
48 virtual void set_surface_materials(const Vector<RID> &p_materials) = 0;
49 virtual void set_mesh_instance(RID p_mesh_instance) = 0;
50 virtual void set_transform(const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabb) = 0;
51 virtual void set_pivot_data(float p_sorting_offset, bool p_use_aabb_center) = 0;
52 virtual void set_lod_bias(float p_lod_bias) = 0;
53 virtual void set_layer_mask(uint32_t p_layer_mask) = 0;
54 virtual void set_fade_range(bool p_enable_near, float p_near_begin, float p_near_end, bool p_enable_far, float p_far_begin, float p_far_end) = 0;
55 virtual void set_parent_fade_alpha(float p_alpha) = 0;
56 virtual void set_transparency(float p_transparency) = 0;
57 virtual void set_use_baked_light(bool p_enable) = 0;
58 virtual void set_use_dynamic_gi(bool p_enable) = 0;
59 virtual void set_use_lightmap(RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) = 0;
60 virtual void set_lightmap_capture(const Color *p_sh9) = 0;
61 virtual void set_instance_shader_uniforms_offset(int32_t p_offset) = 0;
62 virtual void set_cast_double_sided_shadows(bool p_enable) = 0;
63
64 virtual void reset_motion_vectors() = 0;
65
66 virtual Transform3D get_transform() = 0;
67 virtual AABB get_aabb() = 0;
68
69 virtual void clear_light_instances() = 0;
70 virtual void pair_light_instance(const RID p_light_instance, RS::LightType light_type, uint32_t placement_idx) = 0;
71 virtual void pair_reflection_probe_instances(const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) = 0;
72 virtual void pair_decal_instances(const RID *p_decal_instances, uint32_t p_decal_instance_count) = 0;
73 virtual void pair_voxel_gi_instances(const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) = 0;
74
75 virtual void set_softshadow_projector_pairing(bool p_softshadow, bool p_projector) = 0;
76 };
77
78 // Base implementation of RenderGeometryInstance shared by internal renderers.
79 class RenderGeometryInstanceBase : public RenderGeometryInstance {
80 public:
81 // setup
82 uint32_t base_flags = 0;
83 uint32_t flags_cache = 0;
84
85 // used during rendering
86 float depth = 0;
87
88 RID mesh_instance;
89
90 Transform3D transform;
91 bool mirror = false;
92 AABB transformed_aabb;
93 bool non_uniform_scale = false;
94 float lod_model_scale = 1.0;
95 float lod_bias = 0.0;
96 float sorting_offset = 0.0;
97 bool use_aabb_center = true;
98
99 uint32_t layer_mask = 1;
100
101 bool fade_near = false;
102 float fade_near_begin = 0;
103 float fade_near_end = 0;
104 bool fade_far = false;
105 float fade_far_begin = 0;
106 float fade_far_end = 0;
107
108 float parent_fade_alpha = 1.0;
109 float force_alpha = 1.0;
110
111 int32_t shader_uniforms_offset = -1;
112
113 struct Data {
114 //data used less often goes into regular heap
115 RID base;
116 RS::InstanceType base_type;
117
118 RID skeleton;
119 Vector<RID> surface_materials;
120 RID material_override;
121 RID material_overlay;
122 AABB aabb;
123
124 bool use_baked_light = false;
125 bool use_dynamic_gi = false;
126 bool cast_double_sided_shadows = false;
127 bool dirty_dependencies = false;
128
129 DependencyTracker dependency_tracker;
130 };
131
132 Data *data = nullptr;
133
134 virtual void set_skeleton(RID p_skeleton) override;
135 virtual void set_material_override(RID p_override) override;
136 virtual void set_material_overlay(RID p_overlay) override;
137 virtual void set_surface_materials(const Vector<RID> &p_materials) override;
138 virtual void set_mesh_instance(RID p_mesh_instance) override;
139 virtual void set_transform(const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabb) override;
140 virtual void set_pivot_data(float p_sorting_offset, bool p_use_aabb_center) override;
141 virtual void set_lod_bias(float p_lod_bias) override;
142 virtual void set_layer_mask(uint32_t p_layer_mask) override;
143 virtual void set_fade_range(bool p_enable_near, float p_near_begin, float p_near_end, bool p_enable_far, float p_far_begin, float p_far_end) override;
144 virtual void set_parent_fade_alpha(float p_alpha) override;
145 virtual void set_transparency(float p_transparency) override;
146 virtual void set_use_baked_light(bool p_enable) override;
147 virtual void set_use_dynamic_gi(bool p_enable) override;
148 virtual void set_instance_shader_uniforms_offset(int32_t p_offset) override;
149 virtual void set_cast_double_sided_shadows(bool p_enable) override;
150
151 virtual void reset_motion_vectors() override;
152
153 virtual Transform3D get_transform() override;
154 virtual AABB get_aabb() override;
155 };