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

Mix-in for an object that can be hit-tested. More...

#include <collideable.h>

Inheritance diagram for Rnd::Collideable:
Collaboration diagram for Rnd::Collideable:

Classes

struct  Collision
 One recorded intersection. More...

Public Member Functions

 Collideable ()
 Construct a collideable with no children.
virtual ~Collideable ()
 Drop this object's references on its children.
Collideable * Parent ()
 Report the collideable that hit-tests this one.
void AddCollide (Collideable *pCollide)
 Append pCollide to mCollides.
void RemoveCollide (Collideable *pCollide)
 Erase pCollide from mCollides.
virtual void FindCollisions (const Segment &ray, std::list< Collision > &collisions)
 Test a segment against this object and append what it strikes to collisions.
virtual void FindCollisions (const Vector2 &point, std::list< Collision > &collisions)
 Test a screen point against this object and append what it strikes to collisions.
virtual void DumpText (Dbg &sink)
 Write a description of this object to sink.
virtual void Save (Stream &stream)
 Write the revision and the mCollides list to stream.
virtual void Replace (Object *pFrom, Object *pTo)
 Retarget every mCollides entry equal to pFrom at pTo.
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy the child list of pSource when nFlags requests it.
virtual void Load (Stream &stream)
 Replace the child list from stream.
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().
virtual const HxStr & ClassName () const =0
 Report the name of this object's most derived class.

Protected Member Functions

void ReleaseCollidesRefs ()
 Drop this object's reference on every mCollides entry without emptying the list.
Protected Member Functions inherited from Rnd::Object
void ReleaseAllRefs ()
 Tell every referrer to drop its pointer to this object.

Friends

void CollectChildren (std::list< Object * > &objects, Collideable *pCollideable)
 Append every collision descendant of a collideable.

Additional Inherited Members

Public Attributes inherited from Rnd::Object
HxStr mName
int mInternal
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs

Detailed Description

Mix-in for an object that can be hit-tested.

Its RTTI descriptor is at 0x008ef440. It has Rnd::Object as a public virtual base at offset

  1. The subobject is 0xc bytes. The compiler places the virtual-base pointer at +0x00 and, following the g++ 2.x layout for a class with no non-virtual base, the vptr at +0x08. The one declared member therefore sits at +0x04. For a standalone Collideable the Rnd::Object subobject sits at +0x0c. The -0xc adjustment on every entry of the second vtable confirms that placement.

Two vtables belong to the class. The three-entry table at 0x008250d8 is addressed by the vptr at +0x08 and stores the two virtuals declared here. The nine-entry table at 0x008250f8 is addressed by the Rnd::Object subobject vptr and stores the overrides of the Rnd::Object virtuals, each with a -0xc adjustment back to the Collideable subobject. Slot 5 of the second table still addresses the pure-virtual stub at 0x005381a8. ClassName() is therefore unimplemented here and the class remains abstract.

Every entry of mCollides registers this object as a referrer through Rnd::Object::AddRef(). A collideable that goes away is therefore removed from its parents' lists by Replace() rather than remaining as a stale pointer. The arrangement is the collision counterpart of Rnd::Drawable and its mDraws list.

Constructor & Destructor Documentation

◆ Collideable()

Rnd::Collideable::Collideable ( )

Construct a collideable with no children.

The constructor writes the two vtable pointers and allocates the mCollides sentinel. It therefore has no written body of its own.

Ghidra address:
NTSC-U/C: 0x00502668
Ghidra address:
PAL: 0x00541470

◆ ~Collideable()

virtual Rnd::Collideable::~Collideable ( )
virtual

Drop this object's references on its children.

Ghidra address:
NTSC-U/C: 0x00502518
Ghidra address:
PAL: 0x00541320

Member Function Documentation

◆ Parent()

Collideable * Rnd::Collideable::Parent ( )

Report the collideable that hit-tests this one.

Walks the referrer list of the Rnd::Object subobject, casts each referrer to Collideable and returns the first whose own mCollides list includes this object. The result is therefore the parent in the collision hierarchy rather than a plain cast.

Returns
The parent collideable, or null when no referrer hit-tests this one.
Ghidra address:
NTSC-U/C: 0x00500348
Ghidra address:
PAL: 0x0053f0f8

◆ AddCollide()

void Rnd::Collideable::AddCollide ( Collideable * pCollide)

Append pCollide to mCollides.

Registers this object as a referrer of pCollide. A pCollide already in mCollides produces the report "%s already in %s" and no insertion. Rnd::Manager::Read invokes this while linking a loaded scene.

Parameters
pCollideThe collideable to add.
Ghidra address:
NTSC-U/C: 0x00500858
Ghidra address:
PAL: 0x0053f608

◆ RemoveCollide()

void Rnd::Collideable::RemoveCollide ( Collideable * pCollide)

Erase pCollide from mCollides.

Drops this object's reference on pCollide first. A pCollide absent from mCollides does nothing.

Parameters
pCollideThe collideable to remove.
Ghidra address:
NTSC-U/C: 0x005009d8
Ghidra address:
PAL: 0x0053f788

◆ FindCollisions() [1/2]

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

Test a segment against this object and append what it strikes to collisions.

Vtable slot 1. The base implementation tests nothing of its own and forwards the pair to every mCollides entry. Rnd::Mesh::FindCollisions at 0x0047f950 ends by chaining here so that its children are tested after its own faces.

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

Reimplemented in Rnd::Arena, Rnd::Mesh, Rnd::String, Rnd::Text, and Rnd::Tunnel.

◆ FindCollisions() [2/2]

virtual void Rnd::Collideable::FindCollisions ( const Vector2 & point,
std::list< Collision > & collisions )
virtual

Test a screen point against this object and append what it strikes to collisions.

Vtable slot 2. The base implementation forwards the pair to every mCollides entry. Slot 1 is overridden by Rnd::Mesh, Rnd::Tunnel, and Rnd::Arena. Every derived table examined so far stores this base implementation in slot 2, with one exception. Rnd::Cam overrides it at 0x004ad820 with a routine that tests the point against its screen rectangle.

Parameters
pointThe screen point.
collisionsThe list to append intersections to.
Ghidra address:
NTSC-U/C: 0x00502ab8
Ghidra address:
PAL: 0x005418c8

Reimplemented in Rnd::Cam.

◆ DumpText()

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

Write a description of this object to sink.

Writes the mCollides list, and produces nothing at all when the dump level of sink is not positive. Dbg::Print() discards its text in the shipped build. The routine therefore produces no output on this target in any case.

Parameters
sinkThe diagnostic sink to write to.
Ghidra address:
NTSC-U/C: 0x00502880
Ghidra address:
PAL: 0x00541690

Reimplemented from Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.

◆ Save()

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

Write the revision and the mCollides list to stream.

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

Implements Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.

◆ Replace()

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

Retarget every mCollides entry equal to pFrom at pTo.

Parameters
pFromThe object being replaced.
pToThe replacement, or null.
Ghidra address:
NTSC-U/C: 0x00500410
Ghidra address:
PAL: 0x0053f1c0

Implements Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.

◆ Copy()

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

Copy the child list of pSource when nFlags requests it.

Unlike Rnd::Drawable::Copy(), this routine reads no scalar field of the source. The class declares none.

Parameters
pSourceThe object to copy from.
nFlagsThe set of fields to copy; see kCopyChildLists.
Ghidra address:
NTSC-U/C: 0x00500730
Ghidra address:
PAL: 0x0053f4e0

Implements Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.

◆ Load()

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

Replace the child list from stream.

A revision above the one this build writes produces the report "Can't load new Collideable" followed by the abort handler of Rnd::TheDbg.

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

Implements Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.

◆ ReleaseCollidesRefs()

void Rnd::Collideable::ReleaseCollidesRefs ( )
protected

Drop this object's reference on every mCollides entry without emptying the list.

Every derived destructor invokes this before its own teardown, Rnd::Mesh and Rnd::View among them.

Ghidra address:
NTSC-U/C: 0x00502948
Ghidra address:
PAL: 0x00541758

◆ CollectChildren

void CollectChildren ( std::list< Object * > & objects,
Collideable * pCollideable )
friend

Append every collision descendant of a collideable.

Parameters
objectsThe list to append to.
pCollideableThe collideable to start from, or null.
Ghidra address:
NTSC-U/C: 0x0051a0e0
Ghidra address:
PAL: 0x0055a4d8

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