Debian Codegraph @

servers/rendering/renderer_geometry_instance.cpp

raw symbols SCIP
1 /**************************************************************************/
2 /* renderer_geometry_instance.cpp */
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 #include "servers/rendering/renderer_geometry_instance.h"
32
33 void RenderGeometryInstanceBase::set_skeleton(RID p_skeleton) {
34 data->skeleton = p_skeleton;
35
36 _mark_dirty();
37 data->dirty_dependencies = true;
38 }
39
40 void RenderGeometryInstanceBase::set_material_override(RID p_override) {
41 data->material_override = p_override;
42
43 _mark_dirty();
44 data->dirty_dependencies = true;
45 }
46
47 void RenderGeometryInstanceBase::set_material_overlay(RID p_overlay) {
48 data->material_overlay = p_overlay;
49
50 _mark_dirty();
51 data->dirty_dependencies = true;
52 }
53
54 void RenderGeometryInstanceBase::set_surface_materials(const Vector<RID> &p_materials) {
55 data->surface_materials = p_materials;
56
57 _mark_dirty();
58 data->dirty_dependencies = true;
59 }
60
61 void RenderGeometryInstanceBase::set_mesh_instance(RID p_mesh_instance) {
62 mesh_instance = p_mesh_instance;
63
64 _mark_dirty();
65 }
66
67 void RenderGeometryInstanceBase::set_transform(const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabb) {
68 transform = p_transform;
69 mirror = p_transform.basis.determinant() < 0;
70 data->aabb = p_aabb;
71 transformed_aabb = p_transformed_aabb;
72
73 Vector3 model_scale_vec = p_transform.basis.get_scale_abs();
74 // handle non uniform scale here
75
76 float max_scale = MAX(model_scale_vec.x, MAX(model_scale_vec.y, model_scale_vec.z));
77 float min_scale = MIN(model_scale_vec.x, MIN(model_scale_vec.y, model_scale_vec.z));
78 non_uniform_scale = max_scale >= 0.0 && (min_scale / max_scale) < 0.9;
79
80 lod_model_scale = max_scale;
81 }
82
83 void RenderGeometryInstanceBase::set_pivot_data(float p_sorting_offset, bool p_use_aabb_center) {
84 sorting_offset = p_sorting_offset;
85 use_aabb_center = p_use_aabb_center;
86 }
87
88 void RenderGeometryInstanceBase::set_lod_bias(float p_lod_bias) {
89 lod_bias = p_lod_bias;
90 }
91
92 void RenderGeometryInstanceBase::set_layer_mask(uint32_t p_layer_mask) {
93 layer_mask = p_layer_mask;
94 }
95
96 void RenderGeometryInstanceBase::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) {
97 fade_near = p_enable_near;
98 fade_near_begin = p_near_begin;
99 fade_near_end = p_near_end;
100 fade_far = p_enable_far;
101 fade_far_begin = p_far_begin;
102 fade_far_end = p_far_end;
103 }
104
105 void RenderGeometryInstanceBase::set_parent_fade_alpha(float p_alpha) {
106 parent_fade_alpha = p_alpha;
107 }
108
109 void RenderGeometryInstanceBase::set_transparency(float p_transparency) {
110 force_alpha = CLAMP(1.0 - p_transparency, 0, 1);
111 }
112
113 void RenderGeometryInstanceBase::set_use_baked_light(bool p_enable) {
114 data->use_baked_light = p_enable;
115
116 _mark_dirty();
117 }
118
119 void RenderGeometryInstanceBase::set_use_dynamic_gi(bool p_enable) {
120 data->use_dynamic_gi = p_enable;
121
122 _mark_dirty();
123 }
124
125 void RenderGeometryInstanceBase::set_instance_shader_uniforms_offset(int32_t p_offset) {
126 shader_uniforms_offset = p_offset;
127
128 _mark_dirty();
129 }
130
131 void RenderGeometryInstanceBase::set_cast_double_sided_shadows(bool p_enable) {
132 data->cast_double_sided_shadows = p_enable;
133
134 _mark_dirty();
135 }
136
137 void RenderGeometryInstanceBase::reset_motion_vectors() {
138 }
139
140 Transform3D RenderGeometryInstanceBase::get_transform() {
141 return transform;
142 }
143
144 AABB RenderGeometryInstanceBase::get_aabb() {
145 return data->aabb;
146 }