MCPcopy Create free account
hub / github.com/crownengine/crown / sync_cullable_sets

Method sync_cullable_sets

src/world/render_world.cpp:1065–1175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1063}
1064
1065void RenderWorld::sync_cullable_sets()
1066{
1067 ENTER_PROFILE_SCOPE(__func__);
1068
1069 if (_mesh_manager._dirty) {
1070 _mesh_manager._dirty = false;
1071 MeshManager::MeshInstanceData &idata = _mesh_manager._data;
1072
1073 for (u32 i = 0; i < idata.size; ++i) {
1074 if ((idata.flags[i] & RenderableFlags::DIRTY) == 0)
1075 continue;
1076 idata.flags[i] &= ~RenderableFlags::DIRTY;
1077
1078 u32 changed = idata.flags[i] ^ idata.prev_flags[i];
1079
1080 if ((idata.flags[i] & RenderableFlags::LOD_LEVEL) != 0) {
1081 idata.prev_flags[i] = idata.flags[i];
1082 culling_set::remove(_cullable_objects, CullableType::MESH, i);
1083 culling_set::remove(_cullable_shadow_casters, CullableType::MESH, i);
1084 continue;
1085 }
1086
1087 if (changed) {
1088 idata.prev_flags[i] = idata.flags[i];
1089
1090 if ((changed &RenderableFlags::VISIBLE) != 0) {
1091 if ((idata.flags[i] & RenderableFlags::VISIBLE) != 0)
1092 culling_set::add(_cullable_objects, { idata.world[i], idata.sphere[i], i, CullableType::MESH });
1093 else
1094 culling_set::remove(_cullable_objects, CullableType::MESH, i);
1095 }
1096
1097 if ((changed &RenderableFlags::SHADOW_CASTER) != 0) {
1098 if ((idata.flags[i] & RenderableFlags::SHADOW_CASTER) != 0) {
1099 culling_set::add(_cullable_shadow_casters, { idata.world[i], idata.sphere[i], i, CullableType::MESH });
1100 } else {
1101 culling_set::remove(_cullable_shadow_casters, CullableType::MESH, i);
1102 }
1103 }
1104 } else {
1105 if ((idata.flags[i] & RenderableFlags::VISIBLE) != 0)
1106 culling_set::update(_cullable_objects, CullableType::MESH, i, idata.sphere[i], idata.world[i]);
1107 if ((idata.flags[i] & RenderableFlags::SHADOW_CASTER) != 0)
1108 culling_set::update(_cullable_shadow_casters, CullableType::MESH, i, idata.sphere[i], idata.world[i]);
1109 }
1110 }
1111 }
1112
1113 if (_sprite_manager._dirty) {
1114 _sprite_manager._dirty = false;
1115 SpriteManager::SpriteInstanceData &idata = _sprite_manager._data;
1116
1117 for (u32 i = 0; i < idata.size; ++i) {
1118 if ((idata.flags[i] & RenderableFlags::DIRTY) == 0)
1119 continue;
1120 idata.flags[i] &= ~RenderableFlags::DIRTY;
1121
1122 u32 changed = idata.flags[i] ^ idata.prev_flags[i];

Callers

nothing calls this directly

Calls 6

from_translationFunction · 0.85
local_sphereFunction · 0.85
find_objectFunction · 0.85
removeFunction · 0.70
addFunction · 0.70
updateFunction · 0.70

Tested by

no test coverage detected