resonance 1.0.1
Loading...
Searching...
No Matches
arena.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/vector3.h"
8#include "os/hxstr.h"
9#include "rnd/animatable.h"
10#include "rnd/collideable.h"
11#include "rnd/drawable.h"
12#include "rnd/raytest.h"
13#include "rnd/transformable.h"
14
15namespace Rnd {
16class Dbg;
17class Object;
18class Stream;
19class View;
20} // namespace Rnd
21
22namespace Rnd {
23
59class Arena : public Animatable, public Collideable, public Transformable, public Drawable {
60public:
69 void *operator new(size_t nSize);
70
78 void operator delete(void *pBlock);
79
87 struct Section {
94 : mView(nullptr), mFrame(0.0f), mDelta(0.0f), mTeleport(1), mSortStart(1), mLoop(0) {
95 }
96
98 float mFrame;
99 float mDelta;
102 int mLoop;
103 };
104
114 class DrawEntry {
115 public:
122 DrawEntry() : mView(nullptr) {
123 }
124
135 bool operator<(const DrawEntry &other) const {
136 return mSortKey > other.mSortKey;
137 }
138
140 float mSortKey;
141 };
142
154 explicit Arena(const HxStr &name);
155
165 virtual ~Arena();
166
177 virtual void DumpText(Dbg &sink);
178
189 virtual void Save(Stream &stream);
190
202 virtual void Replace(Object *pFrom, Object *pTo);
203
211 virtual const HxStr &ClassName() const;
212
225 virtual void Copy(const Object *pSource, unsigned nFlags);
226
237 virtual void Load(Stream &stream);
238
250
259 static void Init();
260
271
281
294 void SetLoopDist(const Vector3 &loopDist);
295
308 void SetLoopFrames(float flLoopFrames);
309
322 void SetSectionCount(unsigned int nCount);
323
336 void SetSectionView(int nIndex, View *pView);
337
351 void SetSectionRange(int nIndex, float flStartFrame, float flEndFrame);
352
366 void SetSectionTeleport(int nIndex, int nTeleport);
367
368protected:
378 virtual int DrawShowing();
379
392 virtual int UpdateWorldXfm(Transformable *pParent, int nForce);
393
404 virtual void FindCollisions(const Segment &ray, std::list<Collision> &collisions);
405
418 virtual void SetFrameSelf(float flFrame);
419
420private:
432 void SetSectionLoop(Section &section, int nLoop);
433
445 void UpdateSection(Section &section);
446
447 // No class derives from Rnd::Arena and nothing outside it accesses a member directly. Every
448 // member is therefore private. The order below is the recovered offset order.
449
451 Vector3 mLoopDist;
452 float mLoopFrames; // +0x110
453 std::vector<Section> mSections; // +0x114
454 // +0x120 The sections' views in drawing order. The two hit-list helpers resize it to the
455 // section count and empty it again, SetFrameSelf() refills and sorts it, DrawShowing() walks
456 // it, and Replace() clears an entry rather than repointing it. Neither dump writes it and the
457 // serialiser does not touch it, so the title is inferred.
458 std::list<DrawEntry> mDrawOrder;
459};
460
472Arena *NewArena(const HxStr &name);
473
486
499
507
517extern int g_nRndArenaLoadRevision;
518
528extern Arena *(*g_pfnNewArena)(const HxStr &name);
529
530} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Animatable()
Construct an animatable with no children, no filters, and a zero frame.
bool operator<(const DrawEntry &other) const
Order entries by descending sort key.
Definition arena.h:135
DrawEntry()
Construct an entry with no view.
Definition arena.h:122
float mSortKey
Definition arena.h:140
View * mView
Definition arena.h:139
Loop of views the renderer walks as one continuous space.
Definition arena.h:59
Vector3 & LoopDist()
Report the loop displacement.
void SetSectionRange(int nIndex, float flStartFrame, float flEndFrame)
Set the frames one section is shown for.
virtual ~Arena()
Release the section views and every referrer.
virtual void Replace(Object *pFrom, Object *pTo)
Replace one object reference with another.
void SetLoopDist(const Vector3 &loopDist)
Set the displacement one trip round the loop applies.
virtual int UpdateWorldXfm(Transformable *pParent, int nForce)
Recompute the world transform, and then that of every showing section view.
void RemoveInstancesFromHitList()
Drop this loop's registration on every section view and empty mDrawOrder.
void SetSectionTeleport(int nIndex, int nTeleport)
Set whether one section moves its view as the loop advances.
static void Init()
Install the creator hook and register the class with Rnd::TheManager under the key "Arena".
virtual void SetFrameSelf(float flFrame)
Place every section and rebuild the draw order.
virtual const HxStr & ClassName() const
Return the registered class name, "Arena".
void SetSectionCount(unsigned int nCount)
Resize the loop to a number of sections.
Arena(const HxStr &name)
Construct an empty loop.
virtual void Load(Stream &stream)
Read the loop from stream.
void SetLoopFrames(float flLoopFrames)
Set the number of frames one trip round the loop takes.
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy another loop over this one.
void AddInstancesToHitList()
Register this loop as a referrer of every section view and resize mDrawOrder.
void SetSectionView(int nIndex, View *pView)
Point one section at a view.
virtual void FindCollisions(const Segment &ray, std::list< Collision > &collisions)
Test a ray against the loop and append what it strikes to sink.
virtual void Save(Stream &stream)
Write revision 4 of the loop to stream.
virtual void DumpText(Dbg &sink)
Write the loop to the engine text sink.
virtual int DrawShowing()
Draw the section views in mDrawOrder.
Collideable()
Construct a collideable with no children.
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
Drawable()
Construct a visible drawable with no children.
Base of every object the renderer can load, resolve by name, and serialise.
Definition object.h:43
Byte stream that every renderer object serialises itself through.
Definition stream.h:31
Transformable()
Construct a dirty transformable with identity transforms and no children.
Root of a loadable scene.
Definition view.h:47
The rendering engine.
Definition animhelper.h:3
int g_nRndArenaLoadRevision
Revision word Load() has most recently consumed.
Arena * NewArena(const HxStr &name)
Allocate and construct a loop.
Object * CreateRegisteredArena(const HxStr &name)
Build a loop for the registered "Arena" class.
HxStr g_arenaClassName
Registered class name of Rnd::Arena, the string "Arena".
Arena * NewArenaThroughHook(const HxStr &name)
Build a loop through g_pfnNewArena, without the narrowing CreateRegisteredArena() performs.
One view in the loop.
Definition arena.h:87
int mSortStart
Definition arena.h:101
Section()
Construct a section with no view.
Definition arena.h:93
float mFrame
Definition arena.h:98
int mTeleport
Definition arena.h:100
View * mView
Definition arena.h:97
int mLoop
Definition arena.h:102
float mDelta
Definition arena.h:99
Line segment a collision query is run along.
Definition collideable.h:22
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:12