wavelength 1.0.0
Loading...
Searching...
No Matches
rndview.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <list>
5
6#include "math/vector2.h"
7#include "os/binstream.h"
8#include "os/mem.h"
9#include "os/prnstream.h"
10#include "rnd/rndanimatable.h"
11#include "rnd/rndcollideable.h"
12#include "rnd/rnddrawable.h"
14
23class RndView :
24 public RndAnimatable,
25 public RndDrawable,
26 public RndTransformable,
27 public RndCollideable {
28public:
30 static constexpr int kCopyShareChildren = 0x20;
31
39 explicit RndView(const char *pszName);
40
47 ~RndView() override;
48
55 void *operator new(size_t nSize) {
56 return PoolAlloc(static_cast<int>(nSize), sizeof(RndView), "RndView", 0);
57 }
58
64 void operator delete(void *pBlock) {
65 PoolFree(sizeof(RndView), pBlock);
66 }
67
78 int SetFrameSelf(float fFrame) override;
79
91 void ListDrawables(std::list<RndDrawable *> &drawables) override;
92
100 int DrawShowing() override;
101
111 int UpdateWorldXfm(RndTransformable *pParent, int bForce) override;
112
120 void DumpText(PrnStream &stream) override;
121
129 void Save(BinStream &stream) override;
130
141 void Replace(RndObject *pFrom, RndObject *pTo) override;
142
150 const char *ClassName() const override {
151 return sClassName;
152 }
153
165 void Copy(const RndObject *pSource, int nFlags) override;
166
174 void Load(BinStream &stream) override;
175
186 void SetVisibleRange(float fStart, float fEnd);
187
197 void SetInRange(int nInRange);
198
207 static RndObject *New(const char *pszName) {
208 return new RndView(pszName);
209 }
210
217 static const char *sClassName;
218
225 static int sRev;
226
228 const Vector2 &GetVisibleRange() const {
229 return mVisibleRange;
230 }
231
232protected:
242
252
261
262private:
263 RndView *mChildrenOwner;
264 Vector2 mVisibleRange;
265 int mInRange;
266};
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
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.
const char * ClassName() const override
Report the class name.
Definition rndview.h:150
int DrawShowing() override
Draw the children owner's children at this view's frame and transform, when in range.
void ReleaseRefs()
Drop the reference on the children owner.
int SetFrameSelf(float fFrame) override
Record whether the unfiltered frame is in a non-empty mVisibleRange.
static int sRev
The format version Save() writes and Load() accepts.
Definition rndview.h:225
static RndObject * New(const char *pszName)
Create a view.
Definition rndview.h:207
int UpdateWorldXfm(RndTransformable *pParent, int bForce) override
Update the world transform when in range.
static constexpr int kCopyShareChildren
The bit of the Copy() flags that shares the source's children owner.
Definition rndview.h:30
void Load(BinStream &stream) override
Read what Save() wrote, or an earlier version of it.
void DumpText(PrnStream &stream) override
Write a description of the view and its bases.
void SyncChildren()
Bring the children owner's animations to this view's frame and its transforms under this view's trans...
~RndView() override
Drop the reference on the children owner.
RndView(const char *pszName)
Construct a view that owns its children and is in range.
void AcquireRefs()
Take a reference on the children owner, and put the view in range.
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a referenced object with another.
static const char * sClassName
The class name a .rnd file writes, View.
Definition rndview.h:217
void Copy(const RndObject *pSource, int nFlags) override
Copy another view and its bases.
void Save(BinStream &stream) override
Write the view and its bases.
void SetVisibleRange(float fStart, float fEnd)
Set the range of frames the view shows in, and put the view in range.
void SetInRange(int nInRange)
Put the view in or out of range.
const Vector2 & GetVisibleRange() const
Definition rndview.h:228
void ListDrawables(std::list< RndDrawable * > &drawables) override
Add the view, when the children owner's children have something to draw, then the view's children,...
void * PoolAlloc(int nSize, int nBlockSize, const char *pszTag, int nUnused)
Allocate a block from the small-block pool and bill it to a tag.
void PoolFree(int nSize, void *pBlock)
Return a block to the small-block pool.
Two-component vector, used for texture coordinates.
Definition vector2.h:12