resonance 1.0.1
Loading...
Searching...
No Matches
psmesh.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <vector>
5
6#include "rnd/mesh.h"
7
8class HxStr;
9
10namespace Rnd {
11
68class PsMesh : public Mesh {
69public:
79 PsMesh(const HxStr &name);
80
85 virtual ~PsMesh();
86
101 static void SelectDepthRegsForPass(const Mesh &mesh, int nPass);
102
122
123protected:
139 virtual int DrawShowing();
140
157 virtual void Sync();
158
165 virtual void AddRefObjects();
166
167private:
182 class DrawRun {
183 public:
185 unsigned short *mIndices = {};
187 int mIndexCount = {};
189 std::vector<unsigned short> mVertIndices;
190
196 ~DrawRun() {
197 if (mIndices != nullptr) {
198 delete[] mIndices;
199 }
200 mIndices = nullptr;
201 mIndexCount = 0;
202 }
203
216 void ReserveIndices(int nIndexCount);
217 };
218
219 // Sync() builds both. Every reader takes them off mFacesOwner rather than off this mesh, so a
220 // mesh that shares its geometry shares the batches built from it. No class derives from
221 // Rnd::PsMesh, so both are private.
222 std::list<DrawRun> mFaceRuns; // +0x150
223 std::list<DrawRun> mEdgeRuns; // +0x154
224
225 // Close one run, moving the two scratch index lists into a new node of runs. The compiler
226 // inlined this at both of its call sites in Sync(), which is the only reason no address
227 // belongs to it.
228 static void AppendRun(std::list<DrawRun> &runs,
229 const std::vector<unsigned short> &vertIndices,
230 const std::vector<unsigned short> &primIndices);
231
248 void DrawFacesVU1(const float *pXfm, int nClip);
249
264 void DrawEdgesVU1(const float *pXfm);
265
272 void DrawFacesSoftware(int nClip);
273
280 void DrawEdgesSoftware(int nClip);
281};
282
293Mesh *NewPsMesh(const HxStr &name);
294
295} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Indexed triangle mesh with one material.
Definition mesh.h:46
Mesh(const HxStr &name)
Construct an empty mesh that owns its own geometry.
static void SelectDepthRegsForPass(const Mesh &mesh, int nPass)
Write the GS depth mask and depth test a mesh needs for one material pass.
PsMesh(const HxStr &name)
Construct an empty PlayStation 2 mesh.
virtual ~PsMesh()
virtual int DrawShowing()
Draw the mesh.
virtual void AddRefObjects()
Restore the references, resynchronise, and clamp every vertex colour to the unit range.
virtual void Sync()
Rebuild the draw runs from the face and the edge vectors.
int EmitMultiMeshFaceRun()
Upload the first face run of mFacesOwner to VU1 once, for Rnd::PsMultiMesh to draw per instance.
The rendering engine.
Definition animhelper.h:3
Mesh * NewPsMesh(const HxStr &name)
Allocate and construct a PlayStation 2 mesh.