resonance 1.0.1
Loading...
Searching...
No Matches
Rnd::LodMesh Class Reference

Chain of generated meshes, one per level of detail, that deletes its meshes with itself. More...

#include <lodmesh.h>

Inheritance diagram for Rnd::LodMesh:
Collaboration diagram for Rnd::LodMesh:

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~LodMesh()

Rnd::LodMesh::~LodMesh ( )
inline

Delete every mesh of the chain.

Ghidra address:
NTSC-U/C: 0x00476a80
Ghidra address:
PAL: 0x004b46f8

Member Function Documentation

◆ DeleteMeshes()

void Rnd::LodMesh::DeleteMeshes ( )

Delete every mesh through its virtual destructor and empty the chain.

A null entry is skipped.

Ghidra address:
NTSC-U/C: 0x00476b28
Ghidra address:
PAL: 0x004b47a0

◆ Build()

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.

Parameters
nameThe base title.
nCountThe number of levels.
bInternalWhether the meshes are marked Rnd::Object::mInternal.
Ghidra address:
NTSC-U/C: 0x004694a0
Ghidra address:
PAL: 0x004a6f60

◆ SetTransOwner()

void Rnd::LodMesh::SetTransOwner ( Mesh * pOwner)

Point the transform owner of every mesh at one mesh.

Parameters
pOwnerThe mesh whose transform every level draws with, which may be null.
Ghidra address:
NTSC-U/C: 0x00476e48
Ghidra address:
PAL: 0x004b4ac0

◆ CopyScreenSizes()

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.

Parameters
sourceThe chain to copy from.
Ghidra address:
NTSC-U/C: 0x00469820
Ghidra address:
PAL: 0x004a7318

◆ SetScreenSizes()

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.

Parameters
screenSizesThe thresholds, finest level first.
Ghidra address:
NTSC-U/C: 0x00476c50
Ghidra address:
PAL: 0x004b48c8

◆ ShareFaces()

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.

Parameters
templatesThe chain whose triangles to share, at least as long as this one.
Ghidra address:
NTSC-U/C: 0x00476d28
Ghidra address:
PAL: 0x004b49a0

◆ Sync()

void Rnd::LodMesh::Sync ( )

Call Mesh::Sync() on every level.

The out-of-line copy has no callers.

Ghidra address:
NTSC-U/C: 0x00476de8
Ghidra address:
PAL: 0x004b4a60

◆ FindCollisions()

void Rnd::LodMesh::FindCollisions ( const Segment & ray,
std::list< Collideable::Collision > & collisions )

Test a ray against every level of the chain.

Parameters
rayThe segment to test along.
collisionsThe list to append intersections to.
Ghidra address:
NTSC-U/C: 0x00476ec0
Ghidra address:
PAL: 0x004b4b38

◆ SetVertexCount()

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.

Parameters
nCountThe vertex count.
Ghidra address:
NTSC-U/C: 0x004698e8
Ghidra address:
PAL: 0x004a73e0

◆ Draw()

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.

Parameters
flScreenSizeThe projected screen size.
Ghidra address:
NTSC-U/C: 0x00476bc8
Ghidra address:
PAL: 0x004b4840

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