|
resonance 1.0.1
|
Mix-in for an object that can be hit-tested. More...
#include <collideable.h>


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 |
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
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.
| 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.
|
virtual |
Drop this object's references on its children.
| 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.
| 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.
| pCollide | The collideable to add. |
| 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.
| pCollide | The collideable to remove. |
|
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.
| ray | The segment to test along. |
| collisions | The list to append intersections to. |
Reimplemented in Rnd::Arena, Rnd::Mesh, Rnd::String, Rnd::Text, and Rnd::Tunnel.
|
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.
| point | The screen point. |
| collisions | The list to append intersections to. |
Reimplemented in Rnd::Cam.
|
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.
| sink | The diagnostic sink to write to. |
Reimplemented from Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.
|
virtual |
Write the revision and the mCollides list to stream.
| stream | The stream to write to. |
Implements Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.
Retarget every mCollides entry equal to pFrom at pTo.
| pFrom | The object being replaced. |
| pTo | The replacement, or null. |
Implements Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.
|
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.
| pSource | The object to copy from. |
| nFlags | The set of fields to copy; see kCopyChildLists. |
Implements Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.
|
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.
| stream | The stream to read from. |
Implements Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Mesh, Rnd::String, Rnd::Text, Rnd::Tunnel, and Rnd::View.
|
protected |
|
friend |
Append every collision descendant of a collideable.
| objects | The list to append to. |
| pCollideable | The collideable to start from, or null. |