wavelength 1.0.0
Loading...
Searching...
No Matches
rndcollideable.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
5#include "math/plane.h"
6#include "math/vector2.h"
7#include "os/binstream.h"
8#include "os/prnstream.h"
9#include "rnd/rndobject.h"
10
17class RndCollideable : public virtual RndObject {
18public:
28
36
43 ~RndCollideable() override;
44
55 virtual void Collide(const Segment &segment, std::list<Collision> &collisions);
56
67 virtual void Collide(const Vector2 &point, std::list<Collision> &collisions);
68
78 void DumpText(PrnStream &stream) override;
79
87 void Save(BinStream &stream) override;
88
99 void Replace(RndObject *pFrom, RndObject *pTo) override;
100
109 void Copy(const RndObject *pSource, int nFlags) override;
110
118 void Load(BinStream &stream) override;
119
128
139 bool AddCollide(RndCollideable *pCollide);
140
149
164 static void CollectChildren(std::list<RndObject *> &objects, RndCollideable *pCollideable) {
165 if (pCollideable == nullptr) {
166 return;
167 }
168 for (RndCollideable *pChild : pCollideable->mCollides) {
169 objects.push_back(pChild);
170 CollectChildren(objects, pChild);
171 }
172 }
173
180 static int sRev;
181
182protected:
192
202
203private:
204 std::list<RndCollideable *> mCollides;
205};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
void AcquireCollideRefs()
Take a reference on every child.
void Save(BinStream &stream) override
Write the names of the children.
void Load(BinStream &stream) override
Read what Save() wrote.
virtual void Collide(const Segment &segment, std::list< Collision > &collisions)
Test a segment against the collideable and add what it strikes to a list.
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a child with another object.
bool AddCollide(RndCollideable *pCollide)
Append a child.
static void CollectChildren(std::list< RndObject * > &objects, RndCollideable *pCollideable)
Append every collision descendant of a collideable, depth first, each before its descendants.
Definition rndcollideable.h:164
void Copy(const RndObject *pSource, int nFlags) override
Copy the children when the flags request them.
void RemoveCollide(RndCollideable *pCollide)
Remove a child.
void ReleaseCollideRefs()
Drop the reference on every child without emptying the list.
RndCollideable * Parent()
Find the collideable whose children include this one.
static int sRev
The format version Save() writes and Load() accepts.
Definition rndcollideable.h:180
void DumpText(PrnStream &stream) override
Write a description of the collideable.
virtual void Collide(const Vector2 &point, std::list< Collision > &collisions)
Test a screen point against the collideable and add what it strikes to a list.
~RndCollideable() override
Drop the references on the children.
RndCollideable()
Construct a collideable without children.
Definition rndcollideable.h:34
RndObject(const char *pszName)
Construct an object and register it under a name.
One recorded intersection.
Definition rndcollideable.h:24
float mDistance
Definition rndcollideable.h:26
RndCollideable * mObject
Definition rndcollideable.h:25
Two points that fix a line or a segment.
Definition plane.h:39
Two-component vector, used for texture coordinates.
Definition vector2.h:12