wavelength 1.0.0
Loading...
Searching...
No Matches
rndarena.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <list>
5#include <vector>
6
7#include "math/plane.h"
8#include "math/vector3.h"
9#include "os/binstream.h"
10#include "os/mem.h"
11#include "os/prnstream.h"
12#include "rnd/rndanimatable.h"
13#include "rnd/rndcollideable.h"
14#include "rnd/rnddrawable.h"
16#include "rnd/rndview.h"
17
27class RndArena :
28 public RndAnimatable,
29 public RndCollideable,
30 public RndTransformable,
31 public RndDrawable {
32public:
38 struct Section {
41 : mView(nullptr), mFrame(0.0f), mDelta(0.0f), mTeleport(1), mSortStart(1), mLoop(0) {
42 }
43
45 float mFrame;
46 float mDelta;
49 int mLoop;
50 };
51
57 class Sort {
58 public:
60 Sort() : mView(nullptr) {
61 }
62
69 bool operator<(const Sort &other) const {
70 return mSortKey > other.mSortKey;
71 }
72
74 float GetSortKey() const {
75 return mSortKey;
76 }
77
79 void SetSortKey(float fSortKey) {
80 mSortKey = fSortKey;
81 }
82
84 RndView *GetView() const {
85 return mView;
86 }
87
89 void SetView(RndView *pView) {
90 mView = pView;
91 }
92
93 private:
94 RndView *mView;
95 float mSortKey;
96 };
97
105 explicit RndArena(const char *pszName);
106
113 ~RndArena() override;
114
121 void *operator new(size_t nSize) {
122 return PoolMemAlloc(static_cast<int>(nSize), "Arena", 0);
123 }
124
130 void operator delete(void *pBlock) {
131 PoolMemFree(pBlock);
132 }
133
143 int SetFrameSelf(float fFrame) override;
144
154 int UpdateWorldXfm(RndTransformable *pParent, int bForce) override;
155
163 int DrawShowing() override;
164
166
177 void Collide(const Segment &segment, std::list<Collision> &collisions) override;
178
186 void DumpText(PrnStream &stream) override;
187
195 void Save(BinStream &stream) override;
196
208 void Replace(RndObject *pFrom, RndObject *pTo) override;
209
217 const char *ClassName() const override {
218 return sClassName;
219 }
220
229 void Copy(const RndObject *pSource, int nFlags) override;
230
240 void Load(BinStream &stream) override;
241
250 static RndObject *New(const char *pszName) {
251 return new RndArena(pszName);
252 }
253
260 static const char *sClassName;
261
267 static int sRev;
268
274 static int sLoadRev;
275
276protected:
286
296
306 void UpdateSection(Section &section);
307
319 void SetSectionLoop(Section &section, int nLoop);
320
321private:
322 Vector3 mLoopDist;
323 float mLoopFrames;
324 std::vector<Section> mSections;
325 std::list<Sort> mSorts;
326 int mAnimateViews;
327};
328
339
350
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
RndAnimatable()
Construct an animatable at frame 0 without children or filters.
Definition rndanimatable.h:600
float GetSortKey() const
Definition rndarena.h:74
RndView * GetView() const
Definition rndarena.h:84
void SetView(RndView *pView)
Definition rndarena.h:89
void SetSortKey(float fSortKey)
Definition rndarena.h:79
bool operator<(const Sort &other) const
Order the entries farthest along first.
Definition rndarena.h:69
Sort()
Construct an entry without a view.
Definition rndarena.h:60
void DumpText(PrnStream &stream) override
Write a description of the track and its bases.
void Load(BinStream &stream) override
Read what Save() wrote, or an earlier version of it.
int SetFrameSelf(float fFrame) override
Place and show the view of each section for the filtered frame, then sort the drawing order.
void ReleaseRefs()
Drop the references on the views and empty the drawing order.
static int sLoadRev
The version Load() read last.
Definition rndarena.h:274
static RndObject * New(const char *pszName)
Create a track.
Definition rndarena.h:250
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a view with another object.
int DrawShowing() override
Draw the views in the drawing order.
~RndArena() override
Drop the references on the views.
void UpdateSection(Section &section)
Place a section's view for the filtered frame and show it while the frame is in its window.
void Collide(const Segment &segment, std::list< Collision > &collisions) override
Add what each showing view strikes to a list.
const char * ClassName() const override
Report the class name.
Definition rndarena.h:217
int UpdateWorldXfm(RndTransformable *pParent, int bForce) override
Update the world transform, then that of every showing view.
static const char * sClassName
The class name a .rnd file writes, Arena.
Definition rndarena.h:260
void SetSectionLoop(Section &section, int nLoop)
Move a teleporting section's view on by the loop distance for each loop between its loop and a new on...
static int sRev
The format version Save() writes and Load() accepts.
Definition rndarena.h:267
void Save(BinStream &stream) override
Write the track and its bases.
RndArena(const char *pszName)
Construct an empty track that loops every 1000 frames over no distance.
void Copy(const RndObject *pSource, int nFlags) override
Copy another track and its bases.
void AcquireRefs()
Take a reference on each view and give the drawing order one entry per section.
virtual void Collide(const Segment &segment, std::list< Collision > &collisions)
Test a segment against the collideable and add what it strikes to a list.
RndCollideable()
Construct a collideable without children.
Definition rndcollideable.h:34
RndDrawable()
Construct a showing drawable without a highlight or children.
Definition rnddrawable.h:23
RndObject(const char *pszName)
Construct an object and register it under a name.
RndTransformable()
Construct a transformable with identity transforms, no origin offset, and no billboard.
View that shows the children of another view, its children owner, under its own transform and frame.
Definition rndview.h:27
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.
BinStream & operator>>(BinStream &stream, RndArena::Section &section)
Read a section the section writer wrote, or an earlier version of it.
PrnStream & operator<<(PrnStream &stream, const RndArena::Section &section)
Write a section's view, frame, loop, window, and flags.
One view of the track and the window it is shown in.
Definition rndarena.h:38
RndView * mView
Definition rndarena.h:44
int mSortStart
Definition rndarena.h:48
float mDelta
Definition rndarena.h:46
Section()
Construct a section without a view that teleports and sorts by its start.
Definition rndarena.h:40
float mFrame
Definition rndarena.h:45
int mLoop
Definition rndarena.h:49
int mTeleport
Definition rndarena.h:47
Two points that fix a line or a segment.
Definition plane.h:39
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:14