3#include "RenderBlock.h"
5#include "ClipmapParameterCalculation.h"
9 static bool intersect(
const Cogs::Geometry::Frustum & frustum,
const BoundingBox & box)
11 return Cogs::Geometry::contains(frustum, box) != 0;
14 static void cullRenderBlocks(
const RenderBlock * blocks,
17 const RenderLevel & renderLevel,
18 const ViewVolume & viewVolume,
19 const Vector3d cullOrigin,
20 const float heightExaggeration,
21 const float worldScaleX,
22 const float worldScaleY)
25 const Vector2 worldScale = Vector2(worldScaleX, worldScaleY);
26 const Vector2 offset = Vector2(
static_cast<float>(cullOrigin.x),
static_cast<float>(cullOrigin.y));
27 const float offsetZ =
static_cast<float>(cullOrigin.z);
29 for (
size_t i = 0; i < count; ++i) {
30 const RenderBlock & block = blocks[i];
32 const Vector2 min = block.min * worldScale + offset;
33 const Vector2 max = block.max * worldScale + offset;
35 const float minZ = offsetZ + (renderLevel.terrainLevel->isHeight ? renderLevel.terrainLevel->minZ * heightExaggeration : -1.0f);
36 const float maxZ = offsetZ + (renderLevel.terrainLevel->isHeight ? renderLevel.terrainLevel->maxZ * heightExaggeration : 1.0f);
38 const BoundingBox bbox = { Vector3(min, minZ), Vector3(max, maxZ) };
41 visible[i] = block.mesh->width == -1 || intersect(viewVolume.frustum, bbox);
Contains all Cogs related functionality.