XLE  v0.02.0
Classes | Public Member Functions | List of all members
SceneEngine::TerrainManager Class Reference

Top-level manager for terrain assets More...

#include <Terrain.h>

Classes

class  IntersectionResult
 

Public Member Functions

void Render (RenderCore::Metal::DeviceContext *context, LightingParserContext &parserContext, unsigned techniqueIndex)
 
unsigned CalculateIntersections (IntersectionResult intersections[], unsigned maxIntersections, std::pair< Float3, Float3 > ray, RenderCore::Metal::DeviceContext *context, LightingParserContext &parserContext)
 Finds an intersection between a ray and the rendered terrain geometry More...
 
HeightsUberSurfaceInterfaceGetHeightsInterface ()
 
CoverageUberSurfaceInterfaceGetCoverageInterface (TerrainCoverageId id)
 
std::shared_ptr< ISurfaceHeightsProviderGetHeightsProvider ()
 
const TerrainCoordinateSystemGetCoords () const
 
const TerrainConfigGetConfig () const
 
const TerrainMaterialConfigGetMaterialConfig () const
 
const std::shared_ptr< ITerrainFormat > & GetFormat () const
 
void SetWorldSpaceOrigin (const Float3 &origin)
 
void Load (const TerrainConfig &cfg, UInt2 cellMin=UInt2(0, 0), UInt2 cellMax=UInt2(~0u,~0u), bool allowModification=false)
 Loads a new terrain, removing the old one More...
 
void LoadMaterial (const TerrainMaterialConfig &matCfg)
 
void LoadUberSurface (const ::Assets::ResChar uberSurfaceDir[])
 
void FlushToDisk (ConsoleRig::IProgress *progress=nullptr)
 Write all changes to disk More...
 
void Reset ()
 Unloads all terrain More...
 
 TerrainManager (std::shared_ptr< ITerrainFormat > ioFormat)
 
 TerrainManager (const TerrainManager &)=delete
 
TerrainManageroperator= (const TerrainManager &)=delete
 

Detailed Description

Top-level manager for terrain assets

Internally, the manager coordinates many class that perform the rendering, streaming, intersection tests and so forth.

Member Function Documentation

unsigned SceneEngine::TerrainManager::CalculateIntersections ( IntersectionResult  intersections[],
unsigned  maxIntersections,
std::pair< Float3, Float3 >  ray,
RenderCore::Metal::DeviceContext *  context,
LightingParserContext parserContext 
)

Finds an intersection between a ray and the rendered terrain geometry

This is an intersection test designed for visual tools and other utilities. It's not designed for physical simulation.

Note that this doesn't test against the highest terrain LOD. It tests against the geometry that's actually rendered from a given viewport. That's important for tools where the user wants to click on some area of the terrain – they get an intersection point that truly matches what they see on screen. However, this would be incorrect for physical simulations – because the results would vary as the camera moves.

Normally the client will only want a single intersection, but we can find and return multiple intersections in cases where a ray enters the terrain multiple times. Note that intersections with back faces won't be returned.

We need to know the globalTransformCB & techniqueContext to calculate intersections, because we're going to be testing the post-LOD geometry. If we were just testing the highest LOD, that wouldn't matter.

void SceneEngine::TerrainManager::FlushToDisk ( ConsoleRig::IProgress progress = nullptr)

Write all changes to disk

Also unloads and reloads the terrain, in the process

void SceneEngine::TerrainManager::Load ( const TerrainConfig cfg,
UInt2  cellMin = UInt2(0,0),
UInt2  cellMax = UInt2(~0u, ~0u),
bool  allowModification = false 
)

Loads a new terrain, removing the old one

We can restrict the amount loaded to a rectangle of cells using cellMin and cellMax. This is especially useful when writing a test-bed app that must startup quickly.

Note that "cellMax" is non-inclusive. That is, Load(cfg, Int2(0,0), Int2(1,1)); will only load a single cell (not 4)

Use the defaults for cellMin and cellMax to load the entire terrain.

The previous terrain (if any) will be removed. However, if any cached textures or data can be retained, they will be.

void SceneEngine::TerrainManager::Reset ( )

Unloads all terrain

Removes all cells and removes the terrain from the world. Note that the rendering resources are not released immediately. They can be reused if another compatible terrain is loaded (using the Load method). To release all resources, destroy the TerrainManager object.


The documentation for this class was generated from the following files: