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

Draws one mesh many times, once per recorded instance transform. More...

#include <multimesh.h>

Inheritance diagram for Rnd::MultiMesh:
Collaboration diagram for Rnd::MultiMesh:

Public Types

enum  { kSerialVersion = 0 }
 Serial version this build writes, and the highest version it loads. More...

Public Member Functions

 MultiMesh (const HxStr &name)
 Construct an empty multi-mesh.
virtual ~MultiMesh ()
virtual void DumpText (Dbg &sink)
 Write the multi-mesh to the engine text sink.
virtual void Save (Stream &stream)
 Serialise the multi-mesh.
virtual void Replace (Object *pFrom, Object *pTo)
 Replace one object reference with another.
virtual const HxStr & ClassName () const
 Return the registered class name, "MultiMesh".
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy another multi-mesh over this one.
virtual void Load (Stream &stream)
 Load the multi-mesh.
void AcquireMeshRef ()
 Take a reference on the instanced mesh.
void ReleaseMeshRef ()
 Release the reference on the instanced mesh.
std::list< Transform > & GetTransforms ()
 Report the instance transforms.
Mesh * GetMesh () const
 Report the mesh every instance draws.
Transform & GetTransform (int nIndex)
 Report one instance transform by position.
void RemoveTransform (int nIndex)
 Remove one instance by position.
void SetMesh (Mesh *pMesh)
 Replace the mesh every instance draws, moving this object's reference to the new mesh.
Public Member Functions inherited from Rnd::Drawable
 Drawable ()
 Construct a visible drawable with no children.
virtual ~Drawable ()
 Drop this object's references on its children.
void Draw ()
 Draw this object followed by each of its children.
Drawable * Parent ()
 Report the drawable that draws this one.
void AddDraw (Drawable *pDraw, Drawable *pBefore)
 Insert pDraw into mDraws in front of pBefore.
void AddDraw (Drawable *pDraw)
 Insert pDraw at the front of mDraws.
void RemoveDraw (Drawable *pDraw)
 Erase pDraw from mDraws.
void RemoveAllDraws ()
 Empty mDraws, dropping this object's reference on every entry.
void MoveDraw (Drawable *pDraw, int nSteps)
 Move pDraw nSteps places later in mDraws, or earlier for a negative count.
virtual void SetShowing (int nShowing)
 Set whether this object draws at all.
void SetShowingRecursive (int nShowing)
 Set whether this object and every drawable beneath it in mDraws draw at all.
virtual void SetHighlight (int nHighlight)
 Set whether this object draws with its highlight treatment.
int GetHighlight () const
 Report the highlight flag.
int GetShowing () const
 Report the showing flag.
std::list< Drawable * > & GetDraws ()
 Report the child list.
Public Member Functions inherited from Rnd::Object
 Object ()
 Construct an unnamed object.
 Object (const HxStr &name)
 Construct an object and register it under name.
virtual ~Object ()
 Erase the registry entry and release the name buffer.
void SetName (const HxStr &name)
 Re-register this object under a different name.
void AddRef (Object *pReferrer)
 Register pReferrer as a store of a pointer to this object.
void RemoveRef (Object *pReferrer)
 Drop one registration made by AddRef().

Protected Member Functions

virtual int DrawShowing ()
 Draw the mesh once per instance.
Protected Member Functions inherited from Rnd::Drawable
void ReleaseDrawsRefs ()
 Drop this object's reference on every mDraws entry without emptying the list.
Protected Member Functions inherited from Rnd::Object
void ReleaseAllRefs ()
 Tell every referrer to drop its pointer to this object.

Protected Attributes

Mesh * mMesh
std::list< Transform > mTransforms
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs

Additional Inherited Members

Static Public Member Functions inherited from Rnd::Drawable
static Drawable * Find (const HxStr &name)
 Resolve a registry key to a drawable.
Public Attributes inherited from Rnd::Drawable
int mShowing
Public Attributes inherited from Rnd::Object
HxStr mName
int mInternal

Detailed Description

Draws one mesh many times, once per recorded instance transform.

Its RTTI descriptor is at 0x008ef150. It has Rnd::Drawable as its one public base at offset

  1. The Drawable subobject is 0x14 bytes and the shared Rnd::Object subobject sits at +0x1c. The Object sub-vtable at 0x00823e70 pins the offset from outside by recording a this adjustment of -0x1c in every entry. The creator allocates 0x38 bytes, and the 0x1c of Rnd::Object accounts for the remainder exactly. The Object sub-vtable has eight entries and the Drawable sub-vtable at 0x00823eb8 has four, each followed by an all-zero terminator.

An instance is a bare Rnd::Transform of 0x40 bytes, and 0x50 is the size of the list node rather than of the record. The constructor at 0x004e8a98 gives the node pool an element size of 0x40 and then allocates a 0x50-byte node, which places the payload at node + 0x10 rather than at the node + 0x08 a four-byte payload would use. The reader at 0x004eb6a0 confirms the layout from the other side by building a 0x40-byte prototype whose four padding words it sets to 1.0 and then reading three floats into each of the four rows.

The hardware submission path belongs to Rnd::PsMultiMesh, and DrawShowing() below is the portable implementation it replaces.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Serial version this build writes, and the highest version it loads.

Enumerator
kSerialVersion 

Constructor & Destructor Documentation

◆ MultiMesh()

Rnd::MultiMesh::MultiMesh ( const HxStr & name)

Construct an empty multi-mesh.

Parameters
nameThe object name, passed to the Rnd::Object constructor.
Ghidra address:
NTSC-U/C: 0x004e8830
Ghidra address:
PAL: 0x00527368

◆ ~MultiMesh()

virtual Rnd::MultiMesh::~MultiMesh ( )
virtual
Ghidra address:
NTSC-U/C: 0x004e85c0
Ghidra address:
PAL: 0x005270f8

Member Function Documentation

◆ DumpText()

virtual void Rnd::MultiMesh::DumpText ( Dbg & sink)
virtual

Write the multi-mesh to the engine text sink.

Emits the Rnd::Object and Rnd::Drawable dumps, then the "[MultiMesh]" block. The block is suppressed while the dump level of the sink is zero or negative.

Parameters
sinkThe text sink.
Ghidra address:
NTSC-U/C: 0x004e81a0
Ghidra address:
PAL: 0x00526ca8

Reimplemented from Rnd::Drawable.

◆ Save()

virtual void Rnd::MultiMesh::Save ( Stream & stream)
virtual

Serialise the multi-mesh.

Writes kSerialVersion, the Rnd::Drawable subobject, the mesh reference as a name, and the transform list.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x004ebd10
Ghidra address:
PAL: 0x0052a880

Reimplemented from Rnd::Drawable.

◆ Replace()

virtual void Rnd::MultiMesh::Replace ( Object * pFrom,
Object * pTo )
virtual

Replace one object reference with another.

Forwards to Rnd::Drawable, then swaps the instanced mesh when its current value is the old object.

Parameters
pFromThe object being replaced.
pToThe object to point at, which may be null.
Ghidra address:
NTSC-U/C: 0x004ebe40
Ghidra address:
PAL: 0x0052a9b0

Reimplemented from Rnd::Drawable.

◆ ClassName()

virtual const HxStr & Rnd::MultiMesh::ClassName ( ) const
virtual

Return the registered class name, "MultiMesh".

Returns
The class name.
Ghidra address:
NTSC-U/C: 0x004eba80
Ghidra address:
PAL: 0x0052a5f0

Implements Rnd::Object.

◆ Copy()

virtual void Rnd::MultiMesh::Copy ( const Object * pSource,
unsigned nFlags )
virtual

Copy another multi-mesh over this one.

Takes the source's mesh reference and its whole transform list. No copy flag alters either, so an instanced mesh is always shared rather than duplicated.

Parameters
pSourceThe source object, which has to be a multi-mesh for the copy to have any effect.
nFlagsThe copy flags, forwarded to Rnd::Drawable.
Ghidra address:
NTSC-U/C: 0x004ebc60
Ghidra address:
PAL: 0x0052a7d0

Reimplemented from Rnd::Drawable.

◆ Load()

virtual void Rnd::MultiMesh::Load ( Stream & stream)
virtual

Load the multi-mesh.

Reports "Can't load new MultiMesh" through the failure sink when the file version exceeds kSerialVersion. The mesh reference arrives as a name and resolves through Rnd::TheManager with a checked cast.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x004e8288
Ghidra address:
PAL: 0x00526d90

Reimplemented from Rnd::Drawable.

◆ AcquireMeshRef()

void Rnd::MultiMesh::AcquireMeshRef ( )

Take a reference on the instanced mesh.

Does nothing when mMesh is null.

Ghidra address:
NTSC-U/C: 0x004ebde0
Ghidra address:
PAL: 0x0052a950

◆ ReleaseMeshRef()

void Rnd::MultiMesh::ReleaseMeshRef ( )

Release the reference on the instanced mesh.

The mirror of AcquireMeshRef().

Ghidra address:
NTSC-U/C: 0x004ebe10
Ghidra address:
PAL: 0x0052a980

◆ GetTransforms()

std::list< Transform > & Rnd::MultiMesh::GetTransforms ( )
inline

Report the instance transforms.

The out-of-line copy has no callers. Rnd::Generator::DrawShowing() inlines it to walk the list from outside this hierarchy.

Returns
The transform list.
Ghidra address:
NTSC-U/C: 0x004eba98
Ghidra address:
PAL: 0x0052a608

◆ GetMesh()

Mesh * Rnd::MultiMesh::GetMesh ( ) const
inline

Report the mesh every instance draws.

The out-of-line copy has no callers. TnlGemMeshKind's constructor inlines it.

Returns
The mesh, or null.
Ghidra address:
NTSC-U/C: 0x004eba90
Ghidra address:
PAL: 0x0052a600

◆ GetTransform()

Transform & Rnd::MultiMesh::GetTransform ( int nIndex)

Report one instance transform by position.

The index is not checked. The routine has no caller in the shipped build. The name is inferred.

Parameters
nIndexThe position of the instance.
Returns
The instance transform.
Ghidra address:
NTSC-U/C: 0x004ebaa0
Ghidra address:
PAL: 0x0052a610

◆ RemoveTransform()

void Rnd::MultiMesh::RemoveTransform ( int nIndex)

Remove one instance by position.

The index is not checked. The routine has no caller in the shipped build. The name is inferred.

Parameters
nIndexThe position of the instance.
Ghidra address:
NTSC-U/C: 0x004ebae8
Ghidra address:
PAL: 0x0052a658

◆ SetMesh()

void Rnd::MultiMesh::SetMesh ( Mesh * pMesh)

Replace the mesh every instance draws, moving this object's reference to the new mesh.

The routine has no caller in the shipped build. The name is inferred.

Parameters
pMeshThe new mesh, or null.
Ghidra address:
NTSC-U/C: 0x004ebf18
Ghidra address:
PAL: 0x0052aa88

◆ DrawShowing()

virtual int Rnd::MultiMesh::DrawShowing ( )
protectedvirtual

Draw the mesh once per instance.

Rnd::Drawable vtable slot 3. Borrows the instanced mesh: the level of detail threshold and both transforms are saved, each instance transform is installed as the mesh's local transform in turn, and the mesh draws itself at each one. The saved state is then restored.

Returns
Non-zero, always, so the children are drawn as well.
Ghidra address:
NTSC-U/C: 0x004e83d0
Ghidra address:
PAL: 0x00526f08

Reimplemented from Rnd::Drawable.

Reimplemented in Rnd::PsMultiMesh.

Member Data Documentation

◆ mMesh

Mesh* Rnd::MultiMesh::mMesh
protected

◆ mTransforms

std::list<Transform> Rnd::MultiMesh::mTransforms
protected

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