summaryrefslogtreecommitdiff
path: root/servers/rendering/rendering_server_scene.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 13:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch)
treea27e497da7104dd0a64f98a04fa3067668735e91 /servers/rendering/rendering_server_scene.cpp
parent710b34b70227becdc652b4ae027fe0ac47409642 (diff)
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
Diffstat (limited to 'servers/rendering/rendering_server_scene.cpp')
-rw-r--r--servers/rendering/rendering_server_scene.cpp191
1 files changed, 0 insertions, 191 deletions
diff --git a/servers/rendering/rendering_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp
index 95334ee102..0f8c4b6935 100644
--- a/servers/rendering/rendering_server_scene.cpp
+++ b/servers/rendering/rendering_server_scene.cpp
@@ -39,13 +39,11 @@
/* CAMERA API */
RID RenderingServerScene::camera_create() {
-
Camera *camera = memnew(Camera);
return camera_owner.make_rid(camera);
}
void RenderingServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::PERSPECTIVE;
@@ -55,7 +53,6 @@ void RenderingServerScene::camera_set_perspective(RID p_camera, float p_fovy_deg
}
void RenderingServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::ORTHOGONAL;
@@ -75,14 +72,12 @@ void RenderingServerScene::camera_set_frustum(RID p_camera, float p_size, Vector
}
void RenderingServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->transform = p_transform.orthonormalized();
}
void RenderingServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
@@ -90,21 +85,18 @@ void RenderingServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers)
}
void RenderingServerScene::camera_set_environment(RID p_camera, RID p_env) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->env = p_env;
}
void RenderingServerScene::camera_set_camera_effects(RID p_camera, RID p_fx) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->effects = p_fx;
}
void RenderingServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->vaspect = p_enable;
@@ -113,7 +105,6 @@ void RenderingServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_e
/* SCENARIO API */
void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int) {
-
//RenderingServerScene *self = (RenderingServerScene*)p_self;
Instance *A = p_A;
Instance *B = p_B;
@@ -124,7 +115,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
}
if (B->base_type == RS::INSTANCE_LIGHT && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -135,14 +125,12 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
List<InstanceLightData::PairInfo>::Element *E = light->geometries.push_back(pinfo);
if (geom->can_cast_shadows) {
-
light->shadow_dirty = true;
}
geom->lighting_dirty = true;
return E; //this element should make freeing faster
} else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -156,7 +144,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
return E; //this element should make freeing faster
} else if (B->base_type == RS::INSTANCE_DECAL && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -170,7 +157,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
return E; //this element should make freeing faster
} else if (B->base_type == RS::INSTANCE_LIGHTMAP && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -186,7 +172,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
}
} else if (B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -206,7 +191,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
return E; //this element should make freeing faster
} else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
return gi_probe->lights.insert(A);
}
@@ -214,7 +198,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
return nullptr;
}
void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) {
-
//RenderingServerScene *self = (RenderingServerScene*)p_self;
Instance *A = p_A;
Instance *B = p_B;
@@ -225,7 +208,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
}
if (B->base_type == RS::INSTANCE_LIGHT && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -240,7 +222,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
geom->lighting_dirty = true;
} else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -251,7 +232,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
geom->reflection_dirty = true;
} else if (B->base_type == RS::INSTANCE_DECAL && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -262,7 +242,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
geom->decal_dirty = true;
} else if (B->base_type == RS::INSTANCE_LIGHTMAP && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
if (udata) { //only for dynamic geometries
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -275,7 +254,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
}
} else if (B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -291,7 +269,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
geom->gi_probes_dirty = true;
} else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
Set<Instance *>::Element *E = reinterpret_cast<Set<Instance *>::Element *>(udata);
@@ -300,7 +277,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
}
RID RenderingServerScene::scenario_create() {
-
Scenario *scenario = memnew(Scenario);
ERR_FAIL_COND_V(!scenario, RID());
RID scenario_rid = scenario_owner.make_rid(scenario);
@@ -319,35 +295,30 @@ RID RenderingServerScene::scenario_create() {
}
void RenderingServerScene::scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->debug = p_debug_mode;
}
void RenderingServerScene::scenario_set_environment(RID p_scenario, RID p_environment) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->environment = p_environment;
}
void RenderingServerScene::scenario_set_camera_effects(RID p_scenario, RID p_camera_effects) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->camera_effects = p_camera_effects;
}
void RenderingServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->fallback_environment = p_environment;
}
void RenderingServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
RSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count);
@@ -356,7 +327,6 @@ void RenderingServerScene::scenario_set_reflection_atlas_size(RID p_scenario, in
/* INSTANCING API */
void RenderingServerScene::_instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies) {
-
if (p_update_aabb)
p_instance->update_aabb = true;
if (p_update_dependencies)
@@ -369,7 +339,6 @@ void RenderingServerScene::_instance_queue_update(Instance *p_instance, bool p_u
}
RID RenderingServerScene::instance_create() {
-
Instance *instance = memnew(Instance);
ERR_FAIL_COND_V(!instance, RID());
@@ -380,7 +349,6 @@ RID RenderingServerScene::instance_create() {
}
void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -396,7 +364,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
switch (instance->base_type) {
case RS::INSTANCE_LIGHT: {
-
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
#ifdef DEBUG_ENABLED
if (light->geometries.size()) {
@@ -410,7 +377,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
RSG::scene_render->free(light->instance);
} break;
case RS::INSTANCE_REFLECTION_PROBE: {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data);
RSG::scene_render->free(reflection_probe->instance);
if (reflection_probe->update_list.in_list()) {
@@ -418,13 +384,11 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
}
} break;
case RS::INSTANCE_DECAL: {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(instance->base_data);
RSG::scene_render->free(decal->instance);
} break;
case RS::INSTANCE_LIGHTMAP: {
-
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(instance->base_data);
//erase dependencies, since no longer a lightmap
while (lightmap_data->users.front()) {
@@ -432,7 +396,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
}
} break;
case RS::INSTANCE_GI_PROBE: {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
#ifdef DEBUG_ENABLED
if (gi_probe->geometries.size()) {
@@ -468,13 +431,11 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
instance->base = RID();
if (p_base.is_valid()) {
-
instance->base_type = RSG::storage->get_base_type(p_base);
ERR_FAIL_COND(instance->base_type == RS::INSTANCE_NONE);
switch (instance->base_type) {
case RS::INSTANCE_LIGHT: {
-
InstanceLightData *light = memnew(InstanceLightData);
if (scenario && RSG::storage->light_get_type(p_base) == RS::LIGHT_DIRECTIONAL) {
@@ -489,7 +450,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
case RS::INSTANCE_MULTIMESH:
case RS::INSTANCE_IMMEDIATE:
case RS::INSTANCE_PARTICLES: {
-
InstanceGeometryData *geom = memnew(InstanceGeometryData);
instance->base_data = geom;
if (instance->base_type == RS::INSTANCE_MESH) {
@@ -497,7 +457,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
}
} break;
case RS::INSTANCE_REFLECTION_PROBE: {
-
InstanceReflectionProbeData *reflection_probe = memnew(InstanceReflectionProbeData);
reflection_probe->owner = instance;
instance->base_data = reflection_probe;
@@ -505,7 +464,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
reflection_probe->instance = RSG::scene_render->reflection_probe_instance_create(p_base);
} break;
case RS::INSTANCE_DECAL: {
-
InstanceDecalData *decal = memnew(InstanceDecalData);
decal->owner = instance;
instance->base_data = decal;
@@ -513,13 +471,11 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
decal->instance = RSG::scene_render->decal_instance_create(p_base);
} break;
case RS::INSTANCE_LIGHTMAP: {
-
InstanceLightmapData *lightmap_data = memnew(InstanceLightmapData);
instance->base_data = lightmap_data;
//lightmap_data->instance = RSG::scene_render->lightmap_data_instance_create(p_base);
} break;
case RS::INSTANCE_GI_PROBE: {
-
InstanceGIProbeData *gi_probe = memnew(InstanceGIProbeData);
instance->base_data = gi_probe;
gi_probe->owner = instance;
@@ -544,12 +500,10 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
_instance_queue_update(instance, true, true);
}
void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
if (instance->scenario) {
-
instance->scenario->instances.remove(&instance->scenario_item);
if (instance->octree_id) {
@@ -558,9 +512,7 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
}
switch (instance->base_type) {
-
case RS::INSTANCE_LIGHT: {
-
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
#ifdef DEBUG_ENABLED
if (light->geometries.size()) {
@@ -578,7 +530,6 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
} break;
case RS::INSTANCE_GI_PROBE: {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
#ifdef DEBUG_ENABLED
@@ -604,7 +555,6 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
}
if (p_scenario.is_valid()) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
@@ -613,9 +563,7 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
scenario->instances.add(&instance->scenario_item);
switch (instance->base_type) {
-
case RS::INSTANCE_LIGHT: {
-
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
if (RSG::storage->light_get_type(instance->base) == RS::LIGHT_DIRECTIONAL) {
@@ -623,7 +571,6 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
}
} break;
case RS::INSTANCE_GI_PROBE: {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
if (!gi_probe->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element);
@@ -637,14 +584,12 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
}
}
void RenderingServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
instance->layer_mask = p_mask;
}
void RenderingServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -668,14 +613,12 @@ void RenderingServerScene::instance_set_transform(RID p_instance, const Transfor
_instance_queue_update(instance, true);
}
void RenderingServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
instance->object_id = p_id;
}
void RenderingServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -688,7 +631,6 @@ void RenderingServerScene::instance_set_blend_shape_weight(RID p_instance, int p
}
void RenderingServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -705,7 +647,6 @@ void RenderingServerScene::instance_set_surface_material(RID p_instance, int p_s
}
void RenderingServerScene::instance_set_visible(RID p_instance, bool p_visible) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -754,20 +695,17 @@ inline bool is_geometry_instance(RenderingServer::InstanceType p_type) {
}
void RenderingServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
ERR_FAIL_COND(!is_geometry_instance(instance->base_type));
if (p_aabb != AABB()) {
-
// Set custom AABB
if (instance->custom_aabb == nullptr)
instance->custom_aabb = memnew(AABB);
*instance->custom_aabb = p_aabb;
} else {
-
// Clear custom AABB
if (instance->custom_aabb != nullptr) {
memdelete(instance->custom_aabb);
@@ -780,7 +718,6 @@ void RenderingServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb)
}
void RenderingServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -808,7 +745,6 @@ void RenderingServerScene::instance_set_extra_visibility_margin(RID p_instance,
}
Vector<ObjectID> RenderingServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
-
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
@@ -820,7 +756,6 @@ Vector<ObjectID> RenderingServerScene::instances_cull_aabb(const AABB &p_aabb, R
culled = scenario->octree.cull_aabb(p_aabb, cull, 1024);
for (int i = 0; i < culled; i++) {
-
Instance *instance = cull[i];
ERR_CONTINUE(!instance);
if (instance->object_id.is_null())
@@ -832,7 +767,6 @@ Vector<ObjectID> RenderingServerScene::instances_cull_aabb(const AABB &p_aabb, R
return instances;
}
Vector<ObjectID> RenderingServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
-
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
@@ -854,7 +788,6 @@ Vector<ObjectID> RenderingServerScene::instances_cull_ray(const Vector3 &p_from,
return instances;
}
Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
-
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
@@ -866,7 +799,6 @@ Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane>
culled = scenario->octree.cull_convex(p_convex, cull, 1024);
for (int i = 0; i < culled; i++) {
-
Instance *instance = cull[i];
ERR_CONTINUE(!instance);
if (instance->object_id.is_null())
@@ -879,21 +811,17 @@ Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane>
}
void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
//ERR_FAIL_COND(((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK));
switch (p_flags) {
-
case RS::INSTANCE_FLAG_USE_BAKED_LIGHT: {
-
instance->baked_light = p_enabled;
} break;
case RS::INSTANCE_FLAG_USE_DYNAMIC_GI: {
-
if (p_enabled == instance->dynamic_gi) {
//bye, redundant
return;
@@ -911,7 +839,6 @@ void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::Instan
} break;
case RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE: {
-
instance->redraw_if_visible = p_enabled;
} break;
@@ -920,7 +847,6 @@ void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::Instan
}
}
void RenderingServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -928,7 +854,6 @@ void RenderingServerScene::instance_geometry_set_cast_shadows_setting(RID p_inst
_instance_queue_update(instance, false, true);
}
void RenderingServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -942,7 +867,6 @@ void RenderingServerScene::instance_geometry_set_as_instance_lod(RID p_instance,
}
void RenderingServerScene::instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -965,7 +889,6 @@ void RenderingServerScene::instance_geometry_set_lightmap(RID p_instance, RID p_
}
void RenderingServerScene::instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -987,7 +910,6 @@ void RenderingServerScene::instance_geometry_set_shader_parameter(RID p_instance
}
Variant RenderingServerScene::instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const {
-
const Instance *instance = const_cast<RenderingServerScene *>(this)->instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!instance, Variant());
@@ -998,7 +920,6 @@ Variant RenderingServerScene::instance_geometry_get_shader_parameter(RID p_insta
}
Variant RenderingServerScene::instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const {
-
const Instance *instance = const_cast<RenderingServerScene *>(this)->instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!instance, Variant());
@@ -1026,11 +947,9 @@ void RenderingServerScene::instance_geometry_get_shader_parameter_list(RID p_ins
}
void RenderingServerScene::_update_instance(Instance *p_instance) {
-
p_instance->version++;
if (p_instance->base_type == RS::INSTANCE_LIGHT) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
RSG::scene_render->light_instance_set_transform(light->instance, p_instance->transform);
@@ -1038,7 +957,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
if (p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
RSG::scene_render->reflection_probe_instance_set_transform(reflection_probe->instance, p_instance->transform);
@@ -1046,21 +964,18 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
if (p_instance->base_type == RS::INSTANCE_DECAL) {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(p_instance->base_data);
RSG::scene_render->decal_instance_set_transform(decal->instance, p_instance->transform);
}
if (p_instance->base_type == RS::INSTANCE_GI_PROBE) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(p_instance->base_data);
RSG::scene_render->gi_probe_instance_set_transform_to_data(gi_probe->probe_instance, p_instance->transform);
}
if (p_instance->base_type == RS::INSTANCE_PARTICLES) {
-
RSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform);
}
@@ -1069,7 +984,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
-
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
//make sure lights are updated if it casts shadow
@@ -1092,7 +1006,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
if (p_instance->base_type == RS::INSTANCE_LIGHTMAP) {
-
//if this moved, update the captured objects
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(p_instance->base_data);
//erase dependencies, since no longer a lightmap
@@ -1112,18 +1025,15 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
p_instance->transformed_aabb = new_aabb;
if (!p_instance->scenario) {
-
return;
}
if (p_instance->octree_id == 0) {
-
uint32_t base_type = 1 << p_instance->base_type;
uint32_t pairable_mask = 0;
bool pairable = false;
if (p_instance->base_type == RS::INSTANCE_LIGHT || p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE || p_instance->base_type == RS::INSTANCE_DECAL || p_instance->base_type == RS::INSTANCE_LIGHTMAP) {
-
pairable_mask = p_instance->visible ? RS::INSTANCE_GEOMETRY_MASK : 0;
pairable = true;
}
@@ -1138,7 +1048,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
p_instance->octree_id = p_instance->scenario->octree.create(p_instance, new_aabb, 0, pairable, base_type, pairable_mask);
} else {
-
/*
if (new_aabb==p_instance->data.transformed_aabb)
return;
@@ -1149,18 +1058,15 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
-
AABB new_aabb;
ERR_FAIL_COND(p_instance->base_type != RS::INSTANCE_NONE && !p_instance->base.is_valid());
switch (p_instance->base_type) {
case RenderingServer::INSTANCE_NONE: {
-
// do nothing
} break;
case RenderingServer::INSTANCE_MESH: {
-
if (p_instance->custom_aabb)
new_aabb = *p_instance->custom_aabb;
else
@@ -1169,7 +1075,6 @@ void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
} break;
case RenderingServer::INSTANCE_MULTIMESH: {
-
if (p_instance->custom_aabb)
new_aabb = *p_instance->custom_aabb;
else
@@ -1177,7 +1082,6 @@ void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
} break;
case RenderingServer::INSTANCE_IMMEDIATE: {
-
if (p_instance->custom_aabb)
new_aabb = *p_instance->custom_aabb;
else
@@ -1185,7 +1089,6 @@ void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
} break;
case RenderingServer::INSTANCE_PARTICLES: {
-
if (p_instance->custom_aabb)
new_aabb = *p_instance->custom_aabb;
else
@@ -1193,27 +1096,22 @@ void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
} break;
case RenderingServer::INSTANCE_LIGHT: {
-
new_aabb = RSG::storage->light_get_aabb(p_instance->base);
} break;
case RenderingServer::INSTANCE_REFLECTION_PROBE: {
-
new_aabb = RSG::storage->reflection_probe_get_aabb(p_instance->base);
} break;
case RenderingServer::INSTANCE_DECAL: {
-
new_aabb = RSG::storage->decal_get_aabb(p_instance->base);
} break;
case RenderingServer::INSTANCE_GI_PROBE: {
-
new_aabb = RSG::storage->gi_probe_get_bounds(p_instance->base);
} break;
case RenderingServer::INSTANCE_LIGHTMAP: {
-
new_aabb = RSG::storage->lightmap_get_aabb(p_instance->base);
} break;
@@ -1229,7 +1127,6 @@ void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
}
void RenderingServerScene::_update_instance_lightmap_captures(Instance *p_instance) {
-
bool first_set = p_instance->lightmap_sh.size() == 0;
p_instance->lightmap_sh.resize(9); //using SH
p_instance->lightmap_target_sh.resize(9); //using SH
@@ -1299,7 +1196,6 @@ void RenderingServerScene::_update_instance_lightmap_captures(Instance *p_instan
if (accum_blend > 0.0) {
for (int j = 0; j < 9; j++) {
-
instance_sh[j] = accum_sh[j] / accum_blend;
if (first_set) {
p_instance->lightmap_sh.write[j] = instance_sh[j];
@@ -1309,7 +1205,6 @@ void RenderingServerScene::_update_instance_lightmap_captures(Instance *p_instan
}
bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, bool p_cam_vaspect, RID p_shadow_atlas, Scenario *p_scenario) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
Transform light_transform = p_instance->transform;
@@ -1318,9 +1213,7 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
bool animated_material_found = false;
switch (RSG::storage->light_get_type(p_instance->base)) {
-
case RS::LIGHT_DIRECTIONAL: {
-
real_t max_distance = p_cam_projection.get_z_far();
real_t shadow_max = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE);
if (shadow_max > 0 && !p_cam_orthogonal) { //its impractical (and leads to unwanted behaviors) to set max distance in orthogonal camera
@@ -1345,7 +1238,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t z_min = 1e20;
for (int i = 0; i < cull_count; i++) {
-
Instance *instance = instance_shadow_cull_result[i];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
continue;
@@ -1408,7 +1300,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t min_distance_bias_scale = pancake_size > 0 ? distances[1] / 10.0 : 0;
for (int i = 0; i < splits; i++) {
-
RENDER_TIMESTAMP("Culling Directional Light split" + itos(i));
// setup a camera matrix for that range!
@@ -1417,12 +1308,10 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t aspect = p_cam_projection.get_aspect();
if (p_cam_orthogonal) {
-
Vector2 vp_he = p_cam_projection.get_viewport_half_extents();
camera_matrix.set_orthogonal(vp_he.y * 2.0, aspect, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], false);
} else {
-
real_t fov = p_cam_projection.get_fov(); //this is actually yfov, because set aspect tries to keep it
camera_matrix.set_perspective(fov, aspect, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], true);
}
@@ -1459,7 +1348,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
//used for culling
for (int j = 0; j < 8; j++) {
-
real_t d_x = x_vec.dot(endpoints[j]);
real_t d_y = y_vec.dot(endpoints[j]);
real_t d_z = z_vec.dot(endpoints[j]);
@@ -1488,7 +1376,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
//camera viewport stuff
for (int j = 0; j < 8; j++) {
-
center += endpoints[j];
}
center /= 8.0;
@@ -1496,7 +1383,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
//center=x_vec*(x_max-x_min)*0.5 + y_vec*(y_max-y_min)*0.5 + z_vec*(z_max-z_min)*0.5;
for (int j = 0; j < 8; j++) {
-
real_t d = center.distance_to(endpoints[j]);
if (d > radius)
radius = d;
@@ -1513,11 +1399,9 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
z_min_cam = z_vec.dot(center) - radius;
{
-
float soft_shadow_angle = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SIZE);
if (soft_shadow_angle > 0.0 && pancake_size > 0.0) {
-
float z_range = (z_vec.dot(center) + radius + pancake_size) - z_min_cam;
soft_shadow_expand = Math::tan(Math::deg2rad(soft_shadow_angle)) * z_range;
@@ -1570,7 +1454,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t cull_max = 0;
for (int j = 0; j < cull_count; j++) {
-
real_t min, max;
Instance *instance = instance_shadow_cull_result[j];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
@@ -1597,14 +1480,12 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
}
if (aspect != 1.0) {
-
// if the aspect is different, then the radius will become larger.
// if this happens, then bias needs to be adjusted too, as depth will increase
// to do this, compare the depth of one that would have resulted from a square frustum
CameraMatrix camera_matrix_square;
if (p_cam_orthogonal) {
-
Vector2 vp_he = camera_matrix.get_viewport_half_extents();
if (p_cam_vaspect) {
camera_matrix_square.set_orthogonal(vp_he.x * 2.0, 1.0, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], true);
@@ -1627,7 +1508,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t z_max_square = 0;
for (int j = 0; j < 8; j++) {
-
center_square += endpoints_square[j];
real_t d_z = z_vec.dot(endpoints_square[j]);
@@ -1645,7 +1525,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t radius_square = 0;
for (int j = 0; j < 8; j++) {
-
real_t d = center_square.distance_to(endpoints_square[j]);
if (d > radius_square)
radius_square = d;
@@ -1667,7 +1546,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
}
{
-
CameraMatrix ortho_camera;
real_t half_x = (x_max_cam - x_min_cam) * 0.5;
real_t half_y = (y_max_cam - y_min_cam) * 0.5;
@@ -1694,13 +1572,10 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
} break;
case RS::LIGHT_OMNI: {
-
RS::LightOmniShadowMode shadow_mode = RSG::storage->light_omni_get_shadow_mode(p_instance->base);
if (shadow_mode == RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID || !RSG::scene_render->light_instances_can_render_shadow_cube()) {
-
for (int i = 0; i < 2; i++) {
-
//using this one ensures that raster deferred will have it
RENDER_TIMESTAMP("Culling Shadow Paraboloid" + itos(i));
@@ -1720,7 +1595,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
Plane near_plane(light_transform.origin, light_transform.basis.get_axis(2) * z);
for (int j = 0; j < cull_count; j++) {
-
Instance *instance = instance_shadow_cull_result[j];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
@@ -1746,7 +1620,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
cm.set_perspective(90, 1, 0.01, radius);
for (int i = 0; i < 6; i++) {
-
RENDER_TIMESTAMP("Culling Shadow Cube side" + itos(i));
//using this one ensures that raster deferred will have it
@@ -1775,7 +1648,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
Plane near_plane(xform.origin, -xform.basis.get_axis(2));
for (int j = 0; j < cull_count; j++) {
-
Instance *instance = instance_shadow_cull_result[j];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
@@ -1800,7 +1672,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
} break;
case RS::LIGHT_SPOT: {
-
RENDER_TIMESTAMP("Culling Spot Light");
real_t radius = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE);
@@ -1814,7 +1685,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
Plane near_plane(light_transform.origin, -light_transform.basis.get_axis(2));
for (int j = 0; j < cull_count; j++) {
-
Instance *instance = instance_shadow_cull_result[j];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
@@ -1851,7 +1721,6 @@ void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID
switch (camera->type) {
case Camera::ORTHOGONAL: {
-
camera_matrix.set_orthogonal(
camera->size,
p_viewport_size.width / (float)p_viewport_size.height,
@@ -1861,7 +1730,6 @@ void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID
ortho = true;
} break;
case Camera::PERSPECTIVE: {
-
camera_matrix.set_perspective(
camera->fov,
p_viewport_size.width / (float)p_viewport_size.height,
@@ -1872,7 +1740,6 @@ void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID
} break;
case Camera::FRUSTUM: {
-
camera_matrix.set_frustum(
camera->size,
p_viewport_size.width / (float)p_viewport_size.height,
@@ -2018,7 +1885,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
float lightmap_probe_update_speed = RSG::storage->lightmap_get_probe_capture_update_speed() * RSG::rasterizer->get_frame_delta_time();
for (int i = 0; i < instance_cull_count; i++) {
-
Instance *ins = instance_cull_result[i];
bool keep = false;
@@ -2026,9 +1892,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
if ((camera_layer_mask & ins->layer_mask) == 0) {
//failure
} else if (ins->base_type == RS::INSTANCE_LIGHT && ins->visible) {
-
if (light_cull_count < MAX_LIGHTS_CULLED) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
if (!light->geometries.empty()) {
@@ -2043,9 +1907,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
}
}
} else if (ins->base_type == RS::INSTANCE_REFLECTION_PROBE && ins->visible) {
-
if (reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(ins->base_data);
if (p_reflection_probe != reflection_probe->instance) {
@@ -2071,9 +1933,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
}
}
} else if (ins->base_type == RS::INSTANCE_DECAL && ins->visible) {
-
if (decal_cull_count < MAX_DECALS_CULLED) {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(ins->base_data);
if (!decal->geometries.empty()) {
@@ -2084,7 +1944,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
}
} else if (ins->base_type == RS::INSTANCE_GI_PROBE && ins->visible) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(ins->base_data);
if (!gi_probe->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element);
@@ -2095,14 +1954,12 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
gi_probe_cull_count++;
}
} else if (ins->base_type == RS::INSTANCE_LIGHTMAP && ins->visible) {
-
if (lightmap_cull_count < MAX_LIGHTMAPS_CULLED) {
lightmap_cull_result[lightmap_cull_count] = ins;
lightmap_cull_count++;
}
} else if (((1 << ins->base_type) & RS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
-
keep = true;
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data);
@@ -2129,7 +1986,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
ins->light_instances.resize(geom->lighting.size());
for (List<Instance *>::Element *E = geom->lighting.front(); E; E = E->next()) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
ins->light_instances.write[l++] = light->instance;
@@ -2144,7 +2000,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
ins->reflection_probe_instances.resize(geom->reflection_probes.size());
for (List<Instance *>::Element *E = geom->reflection_probes.front(); E; E = E->next()) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(E->get()->base_data);
ins->reflection_probe_instances.write[l++] = reflection_probe->instance;
@@ -2159,7 +2014,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
ins->gi_probe_instances.resize(geom->gi_probes.size());
for (List<Instance *>::Element *E = geom->gi_probes.front(); E; E = E->next()) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(E->get()->base_data);
ins->gi_probe_instances.write[l++] = gi_probe->probe_instance;
@@ -2187,7 +2041,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
i--;
ins->last_render_pass = 0; // make invalid
} else {
-
ins->last_render_pass = render_pass;
}
ins->last_frame_pass = frame_number;
@@ -2200,12 +2053,10 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
// directional lights
{
-
Instance **lights_with_shadow = (Instance **)alloca(sizeof(Instance *) * scenario->directional_lights.size());
int directional_shadow_count = 0;
for (List<Instance *>::Element *E = scenario->directional_lights.front(); E; E = E->next()) {
-
if (light_cull_count + directional_light_count >= MAX_LIGHTS_CULLED) {
break;
}
@@ -2229,7 +2080,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
RSG::scene_render->set_directional_shadow_count(directional_shadow_count);
for (int i = 0; i < directional_shadow_count; i++) {
-
RENDER_TIMESTAMP(">Rendering Directional Light " + itos(i));
_light_instance_update_shadow(lights_with_shadow[i], p_cam_transform, p_cam_projection, p_cam_orthogonal, p_cam_vaspect, p_shadow_atlas, scenario);
@@ -2243,7 +2093,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
//SortArray<Instance*,_InstanceLightsort> sorter;
//sorter.sort(light_cull_result,light_cull_count);
for (int i = 0; i < light_cull_count; i++) {
-
Instance *ins = light_cull_result[i];
if (!p_shadow_atlas.is_valid() || !RSG::storage->light_has_shadow(ins->base))
@@ -2263,9 +2112,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
Vector2 vp_half_extents = p_cam_projection.get_viewport_half_extents();
switch (RSG::storage->light_get_type(ins->base)) {
-
case RS::LIGHT_OMNI: {
-
float radius = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_RANGE);
//get two points parallel to near plane
@@ -2289,7 +2136,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
coverage = screen_diameter / (vp_half_extents.x + vp_half_extents.y);
} break;
case RS::LIGHT_SPOT: {
-
float radius = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_RANGE);
float angle = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_SPOT_ANGLE);
@@ -2342,7 +2188,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
}
void RenderingServerScene::_render_scene(RID p_render_buffers, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
/* ENVIRONMENT */
@@ -2368,7 +2213,6 @@ void RenderingServerScene::_render_scene(RID p_render_buffers, const Transform p
}
void RenderingServerScene::render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) {
-
#ifndef _3D_DISABLED
Scenario *scenario = scenario_owner.getornull(p_scenario);
@@ -2384,7 +2228,6 @@ void RenderingServerScene::render_empty_scene(RID p_render_buffers, RID p_scenar
}
bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, int p_step) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
Scenario *scenario = p_instance->scenario;
ERR_FAIL_COND_V(!scenario, true);
@@ -2392,14 +2235,12 @@ bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, i
RenderingServerRaster::redraw_request(); //update, so it updates in editor
if (p_step == 0) {
-
if (!RSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance, scenario->reflection_atlas)) {
return true; //all full
}
}
if (p_step >= 0 && p_step < 6) {
-
static const Vector3 view_normals[6] = {
Vector3(+1, 0, 0),
Vector3(-1, 0, 0),
@@ -2439,7 +2280,6 @@ bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, i
bool use_shadows = RSG::storage->reflection_probe_renders_shadows(p_instance->base);
if (use_shadows) {
-
shadow_atlas = scenario->reflection_probe_shadow_atlas;
}
@@ -2457,7 +2297,6 @@ bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, i
}
void RenderingServerScene::render_probes() {
-
/* REFLECTION PROBES */
SelfList<InstanceReflectionProbeData> *ref_probe = reflection_probe_render_list.first();
@@ -2465,12 +2304,10 @@ void RenderingServerScene::render_probes() {
bool busy = false;
while (ref_probe) {
-
SelfList<InstanceReflectionProbeData> *next = ref_probe->next();
RID base = ref_probe->self()->owner->base;
switch (RSG::storage->reflection_probe_get_update_mode(base)) {
-
case RS::REFLECTION_PROBE_UPDATE_ONCE: {
if (busy) //already rendering something
break;
@@ -2485,7 +2322,6 @@ void RenderingServerScene::render_probes() {
busy = true; //do not render another one of this kind
} break;
case RS::REFLECTION_PROBE_UPDATE_ALWAYS: {
-
int step = 0;
bool done = false;
while (!done) {
@@ -2509,7 +2345,6 @@ void RenderingServerScene::render_probes() {
}
while (gi_probe) {
-
SelfList<InstanceGIProbeData> *next = gi_probe->next();
InstanceGIProbeData *probe = gi_probe->self();
@@ -2520,7 +2355,6 @@ void RenderingServerScene::render_probes() {
bool cache_dirty = false;
int cache_count = 0;
{
-
int light_cache_size = probe->light_cache.size();
const InstanceGIProbeData::LightCache *caches = probe->light_cache.ptr();
const RID *instance_caches = probe->light_instances.ptr();
@@ -2537,7 +2371,6 @@ void RenderingServerScene::render_probes() {
} else if (idx >= light_cache_size) {
cache_dirty = true;
} else {
-
const InstanceGIProbeData::LightCache *cache = &caches[idx];
if (
@@ -2560,7 +2393,6 @@ void RenderingServerScene::render_probes() {
}
for (List<Instance *>::Element *E = probe->owner->scenario->directional_lights.front(); E; E = E->next()) {
-
Instance *instance = E->get();
InstanceLightData *instance_light = (InstanceLightData *)instance->base_data;
if (!instance->visible) {
@@ -2571,7 +2403,6 @@ void RenderingServerScene::render_probes() {
} else if (idx >= light_cache_size) {
cache_dirty = true;
} else {
-
const InstanceGIProbeData::LightCache *cache = &caches[idx];
if (
@@ -2678,7 +2509,6 @@ void RenderingServerScene::render_probes() {
ins->gi_probe_instances.resize(geom->gi_probes.size());
for (List<Instance *>::Element *F = geom->gi_probes.front(); F; F = F->next()) {
-
InstanceGIProbeData *gi_probe2 = static_cast<InstanceGIProbeData *>(F->get()->base_data);
ins->gi_probe_instances.write[l++] = gi_probe2->probe_instance;
@@ -2700,7 +2530,6 @@ void RenderingServerScene::render_probes() {
}
void RenderingServerScene::_update_instance_shader_parameters_from_material(Map<StringName, RasterizerScene::InstanceBase::InstanceShaderParameter> &isparams, const Map<StringName, RasterizerScene::InstanceBase::InstanceShaderParameter> &existing_isparams, RID p_material) {
-
List<RasterizerStorage::InstanceShaderParam> plist;
RSG::storage->material_get_instance_shader_parameters(p_material, &plist);
for (List<RasterizerStorage::InstanceShaderParam>::Element *E = plist.front(); E; E = E->next()) {
@@ -2729,13 +2558,11 @@ void RenderingServerScene::_update_instance_shader_parameters_from_material(Map<
}
void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
-
if (p_instance->update_aabb) {
_update_instance_aabb(p_instance);
}
if (p_instance->update_dependencies) {
-
p_instance->instance_increase_version();
if (p_instance->base.is_valid()) {
@@ -2762,7 +2589,6 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
}
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
-
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
bool can_cast_shadows = true;
@@ -2780,7 +2606,6 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
is_animated = RSG::storage->material_is_animated(p_instance->material_override);
_update_instance_shader_parameters_from_material(isparams, p_instance->instance_shader_parameters, p_instance->material_override);
} else {
-
if (p_instance->base_type == RS::INSTANCE_MESH) {
RID mesh = p_instance->base;
@@ -2788,13 +2613,11 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
bool cast_shadows = false;
for (int i = 0; i < p_instance->materials.size(); i++) {
-
RID mat = p_instance->materials[i].is_valid() ? p_instance->materials[i] : RSG::storage->mesh_surface_get_material(mesh, i);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
-
if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
@@ -2817,19 +2640,16 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
} else if (p_instance->base_type == RS::INSTANCE_MULTIMESH) {
RID mesh = RSG::storage->multimesh_get_mesh(p_instance->base);
if (mesh.is_valid()) {
-
bool cast_shadows = false;
int sc = RSG::storage->mesh_get_surface_count(mesh);
for (int i = 0; i < sc; i++) {
-
RID mat = RSG::storage->mesh_surface_get_material(mesh, i);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
-
if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
@@ -2850,7 +2670,6 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
RSG::storage->base_update_dependency(mesh, p_instance);
}
} else if (p_instance->base_type == RS::INSTANCE_IMMEDIATE) {
-
RID mat = RSG::storage->immediate_get_material(p_instance->base);
if (!(!mat.is_valid() || RSG::storage->material_casts_shadows(mat))) {
@@ -2870,26 +2689,22 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
}
} else if (p_instance->base_type == RS::INSTANCE_PARTICLES) {
-
bool cast_shadows = false;
int dp = RSG::storage->particles_get_draw_passes(p_instance->base);
for (int i = 0; i < dp; i++) {
-
RID mesh = RSG::storage->particles_get_draw_pass_mesh(p_instance->base, i);
if (!mesh.is_valid())
continue;
int sc = RSG::storage->mesh_get_surface_count(mesh);
for (int j = 0; j < sc; j++) {
-
RID mat = RSG::storage->mesh_surface_get_material(mesh, j);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
-
if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
@@ -2956,26 +2771,21 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
}
void RenderingServerScene::update_dirty_instances() {
-
RSG::storage->update_dirty_resources();
while (_instance_update_list.first()) {
-
_update_dirty_instance(_instance_update_list.first()->self());
}
}
bool RenderingServerScene::free(RID p_rid) {
-
if (camera_owner.owns(p_rid)) {
-
Camera *camera = camera_owner.getornull(p_rid);
camera_owner.free(p_rid);
memdelete(camera);
} else if (scenario_owner.owns(p_rid)) {
-
Scenario *scenario = scenario_owner.getornull(p_rid);
while (scenario->instances.first()) {
@@ -3021,7 +2831,6 @@ TypedArray<Image> RenderingServerScene::bake_render_uv2(RID p_base, const Vector
RenderingServerScene *RenderingServerScene::singleton = nullptr;
RenderingServerScene::RenderingServerScene() {
-
render_pass = 1;
singleton = this;
}