Submit cached terrain patch draws by pointer
TerrainHeightmap::AppendCulledDrawRefs references the cached, shared- geometry patch commands for the visible quadtree patches (writing the background light into the cache) instead of copying them into a new vector each frame. BuildCulledDraws keeps its copying behaviour on top of it for existing callers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
df87bc64eb
commit
dcd301a080
+7
-12
@@ -2038,8 +2038,13 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
// 2. Game phase: render outdoor terrain with quadtree culling & multi-texture patches
|
||||
auto terrain_draws = outdoor_terrain.BuildCulledDraws(renderer3d->GetViewMatrix(), renderer3d->GetProjMatrix(), 8000.0f);
|
||||
if (terrain_draws.empty()) {
|
||||
const float terrain_light_dir[3] = {current_env.dir_light.direction[0], current_env.dir_light.direction[1], current_env.dir_light.direction[2]};
|
||||
const float terrain_light_ambient[3] = {std::max(0.35f, current_env.dir_light.bg_ambient[0]),
|
||||
std::max(0.35f, current_env.dir_light.bg_ambient[1]), std::max(0.38f, current_env.dir_light.bg_ambient[2])};
|
||||
const size_t terrain_ref_count = draw_refs.size();
|
||||
outdoor_terrain.AppendCulledDrawRefs(renderer3d->GetViewMatrix(), renderer3d->GetProjMatrix(), 8000.0f, draws.size(), draw_refs,
|
||||
terrain_light_dir, terrain_light_ambient);
|
||||
if (draw_refs.size() == terrain_ref_count) {
|
||||
auto td = outdoor_terrain.BuildDrawCommand(nullptr, 2);
|
||||
td.light_direction[0] = current_env.dir_light.direction[0];
|
||||
td.light_direction[1] = current_env.dir_light.direction[1];
|
||||
@@ -2048,16 +2053,6 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
td.light_ambient[1] = std::max(0.35f, current_env.dir_light.bg_ambient[1]);
|
||||
td.light_ambient[2] = std::max(0.38f, current_env.dir_light.bg_ambient[2]);
|
||||
draws.push_back(std::move(td));
|
||||
} else {
|
||||
for (auto& td : terrain_draws) {
|
||||
td.light_direction[0] = current_env.dir_light.direction[0];
|
||||
td.light_direction[1] = current_env.dir_light.direction[1];
|
||||
td.light_direction[2] = current_env.dir_light.direction[2];
|
||||
td.light_ambient[0] = std::max(0.35f, current_env.dir_light.bg_ambient[0]);
|
||||
td.light_ambient[1] = std::max(0.35f, current_env.dir_light.bg_ambient[1]);
|
||||
td.light_ambient[2] = std::max(0.38f, current_env.dir_light.bg_ambient[2]);
|
||||
draws.push_back(std::move(td));
|
||||
}
|
||||
}
|
||||
|
||||
// Add water surface (translucent, animated)
|
||||
|
||||
Reference in New Issue
Block a user