resonance 1.0.1
Loading...
Searching...
No Matches
collideable.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
5#include "math/vector2.h"
6#include "rnd/object.h"
7
8namespace Rnd {
9class Dbg;
10class Stream;
11} // namespace Rnd
12
13namespace Rnd {
14
22struct Segment {
23 float mStart[4];
24 float mEnd[4];
25};
26
49class Collideable : public virtual Object {
50 // CollectChildren() in rnd/collectchildren.h walks mCollides directly, and the image has no
51 // accessor for it.
52 friend void CollectChildren(std::list<Object *> &objects, Collideable *pCollideable);
53
54public:
66
77
84 virtual ~Collideable();
85
98
110 void AddCollide(Collideable *pCollide);
111
122 void RemoveCollide(Collideable *pCollide);
123
136 virtual void FindCollisions(const Segment &ray, std::list<Collision> &collisions);
137
151 virtual void FindCollisions(const Vector2 &point, std::list<Collision> &collisions);
152
164 virtual void DumpText(Dbg &sink);
165
173 virtual void Save(Stream &stream);
174
183 virtual void Replace(Object *pFrom, Object *pTo);
184
196 virtual void Copy(const Object *pSource, unsigned nFlags);
197
208 virtual void Load(Stream &stream);
209
210protected:
221
222private:
229 void AcquireCollidesRefs();
230
231 // The collideables this one hit-tests after itself, each of which registers this object as a
232 // referrer.
233 std::list<Collideable *> mCollides; // +0x04
234};
235
236} // namespace Rnd
virtual void Replace(Object *pFrom, Object *pTo)
Retarget every mCollides entry equal to pFrom at pTo.
virtual void FindCollisions(const Vector2 &point, std::list< Collision > &collisions)
Test a screen point against this object and append what it strikes to collisions.
void ReleaseCollidesRefs()
Drop this object's reference on every mCollides entry without emptying the list.
Collideable * Parent()
Report the collideable that hit-tests this one.
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy the child list of pSource when nFlags requests it.
virtual void FindCollisions(const Segment &ray, std::list< Collision > &collisions)
Test a segment against this object and append what it strikes to collisions.
virtual ~Collideable()
Drop this object's references on its children.
virtual void Save(Stream &stream)
Write the revision and the mCollides list to stream.
virtual void Load(Stream &stream)
Replace the child list from stream.
void RemoveCollide(Collideable *pCollide)
Erase pCollide from mCollides.
void AddCollide(Collideable *pCollide)
Append pCollide to mCollides.
friend void CollectChildren(std::list< Object * > &objects, Collideable *pCollideable)
Append every collision descendant of a collideable.
Definition collectchildren.h:47
virtual void DumpText(Dbg &sink)
Write a description of this object to sink.
Collideable()
Construct a collideable with no children.
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
Object()
Construct an unnamed object.
Byte stream that every renderer object serialises itself through.
Definition stream.h:31
The rendering engine.
Definition animhelper.h:3
One recorded intersection.
Definition collideable.h:62
Collideable * mObject
Definition collideable.h:63
float mDistance
Definition collideable.h:64
Line segment a collision query is run along.
Definition collideable.h:22
float mStart[4]
Definition collideable.h:23
float mEnd[4]
Definition collideable.h:24
Two-component vector, used for texture coordinates.
Definition vector2.h:10