|
resonance 1.0.1
|
Chain of generated meshes, one per level of detail, that deletes its meshes with itself. More...
#include <lodmesh.h>


Public Member Functions | |
| ~LodMesh () | |
| Delete every mesh of the chain. | |
| void | DeleteMeshes () |
| Delete every mesh through its virtual destructor and empty the chain. | |
| void | Build (const HxStr &name, int nCount, bool bInternal) |
| Replace the chain with nCount newly created meshes. | |
| void | SetTransOwner (Mesh *pOwner) |
| Point the transform owner of every mesh at one mesh. | |
| void | CopyScreenSizes (const LodMesh &source) |
| Copy the screen size threshold of each level from another chain. | |
| void | SetScreenSizes (const std::vector< float > &screenSizes) |
| Give each level the screen size threshold of the same index. | |
| void | ShareFaces (const LodMesh &templates) |
| Point each level at the triangles of the same level of another chain, then Sync() it. | |
| void | Sync () |
| Call Mesh::Sync() on every level. | |
| void | FindCollisions (const Segment &ray, std::list< Collideable::Collision > &collisions) |
| Test a ray against every level of the chain. | |
| void | SetVertexCount (unsigned nCount) |
| Resize the vertices of the finest level, which every level draws. | |
| void | Draw (float flScreenSize) |
| Draw the level of detail a screen size selects. | |
Chain of generated meshes, one per level of detail, that deletes its meshes with itself.
The class is not polymorphic and has no RTTI. Its name comes from the debugging symbols of the North American demo release. Rnd::Tunnel stores one per grid cell and one per slice, and Rnd::TunnelSeekSection stores one per section. Its routines sit inside the Rnd::Tunnel translation unit.
The class is a std::vector<Mesh *> with a destructor. That destructor, at 0x00476a80, is what the vector of chains runs for each element it destroys. It calls DeleteMeshes() before the vector storage is released. Emptying Rnd::Tunnel::mCellChains therefore deletes every mesh.
Element zero is the finest level. Build() links each mesh to the next coarser one through Mesh::mNext and points every level at element zero for its vertices and its transform.
|
inline |
Delete every mesh of the chain.
| void Rnd::LodMesh::DeleteMeshes | ( | ) |
Delete every mesh through its virtual destructor and empty the chain.
A null entry is skipped.
| void Rnd::LodMesh::Build | ( | const HxStr & | name, |
| int | nCount, | ||
| bool | bInternal ) |
Replace the chain with nCount newly created meshes.
The existing meshes are deleted first. The meshes are created from the last level down, each through Mesh::sNew(), called "[<name>.<level>]" when bInternal is set and "<name>.<level>" otherwise, and each one takes the previously created mesh as its mNext. Every mesh draws with kZModeZReadWrite and kZFuncLess, and every mesh with a coarser link has its screen size threshold cleared. Every level after the first then takes element zero as its vertex owner, and every level takes element zero as its transform owner.
| name | The base title. |
| nCount | The number of levels. |
| bInternal | Whether the meshes are marked Rnd::Object::mInternal. |
| void Rnd::LodMesh::SetTransOwner | ( | Mesh * | pOwner | ) |
Point the transform owner of every mesh at one mesh.
| pOwner | The mesh whose transform every level draws with, which may be null. |
| void Rnd::LodMesh::CopyScreenSizes | ( | const LodMesh & | source | ) |
Copy the screen size threshold of each level from another chain.
Walks this chain and reads the same index of source, which has to be at least as long. Each level passes its own mNext back to Mesh::SetNext() with the copied threshold, which drops and retakes the same reference.
| source | The chain to copy from. |
| void Rnd::LodMesh::SetScreenSizes | ( | const std::vector< float > & | screenSizes | ) |
Give each level the screen size threshold of the same index.
A level past the end of screenSizes is skipped. Each level passes its own mNext back to Mesh::SetNext() with its threshold. The out-of-line copy has no callers, and Rnd::Tunnel inlines the body.
| screenSizes | The thresholds, finest level first. |
| void Rnd::LodMesh::ShareFaces | ( | const LodMesh & | templates | ) |
Point each level at the triangles of the same level of another chain, then Sync() it.
The out-of-line copy has no callers, and Rnd::TunnelSeekSection::Build() inlines the body.
| templates | The chain whose triangles to share, at least as long as this one. |
| void Rnd::LodMesh::Sync | ( | ) |
Call Mesh::Sync() on every level.
The out-of-line copy has no callers.
| void Rnd::LodMesh::FindCollisions | ( | const Segment & | ray, |
| std::list< Collideable::Collision > & | collisions ) |
Test a ray against every level of the chain.
| ray | The segment to test along. |
| collisions | The list to append intersections to. |
| void Rnd::LodMesh::SetVertexCount | ( | unsigned | nCount | ) |
Resize the vertices of the finest level, which every level draws.
A new vertex sits at the origin with a zero normal, a white colour, and zero texture coordinates.
| nCount | The vertex count. |
| void Rnd::LodMesh::Draw | ( | float | flScreenSize | ) |
Draw the level of detail a screen size selects.
Draws nothing when the chain is empty or its finest mesh is not showing. Otherwise the walk starts at the finest level and moves to the next while that level is not the last and its Mesh::mMinScreen is below flScreenSize, and the level it stops on is drawn.
| flScreenSize | The projected screen size. |