wavelength 1.0.0
Loading...
Searching...
No Matches
psmesh.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <memory>
5
6#include "math/transform.h"
7#include "os/mem.h"
8#include "os/memhandle.h"
9#include "rnd/rndmesh.h"
10
21class PsMesh : public RndMesh {
22public:
24 static constexpr int kVertexCacheSize = 256;
25
32 struct alignas(16) SkinVert {
33 float mPos[3];
34 float mWeight1;
35 float mNorm[3];
36 float mWeight2;
37 };
38
46 explicit PsMesh(const char *pszName);
47
54 ~PsMesh() override;
55
62 void *operator new(size_t nSize) {
63 return PoolAlloc(static_cast<int>(nSize), sizeof(PsMesh), "PsMesh", 0);
64 }
65
71 void operator delete(void *pBlock) {
72 PoolFree(sizeof(PsMesh), pBlock);
73 }
74
85 void Copy(const RndObject *pSource, int nFlags) override;
86
98 void Sync(int nFlags) override;
99
107 int DrawShowing() override;
108
118
128
139 void SetZTest(int nPass);
140
150 void DrawFaces(const Transform &xfm);
151
161 void DrawEdges(const Transform &xfm);
162
174
186 void FacesPacket(MemHandle *&pPacket, int &nSetupQwords, int &nVuEnd) const;
187
196 static void Init();
197
206 static RndObject *New(const char *pszName) {
207 return new PsMesh(pszName);
208 }
209
210 std::unique_ptr<SkinVert[]> mSkinVerts;
211
213 unsigned short GetNumFaces() const {
214 return mNumFaces;
215 }
216
217private:
218 MemHandle *mFacesPacket;
219 MemHandle *mEdgesPacket;
220 unsigned short mFacesQwords;
221 unsigned short mEdgesQwords;
222 unsigned short mNumFaces;
223 unsigned short mNumEdges;
224 unsigned short mFacesSetupQwords;
225 unsigned short mFacesVuEnd;
226};
227
234
240extern unsigned short g_vertexCache[PsMesh::kVertexCacheSize];
Movable block of a handle heap, reached through a handle the block points back to.
Definition memhandle.h:21
~PsMesh() override
Release the packets after the frame and the bind pose.
static RndObject * New(const char *pszName)
Create a mesh.
Definition psmesh.h:206
void DrawEdges(const Transform &xfm)
Send the settings of the edge microprogram and the edge packet of the mesh with the geometry.
void Sync(int nFlags) override
Rebuild the bind pose, the face packet, and the edge packet a set of flags covers,...
void BuildFacesPacket()
Build the face packet from the faces and the vertices.
PsMesh(const char *pszName)
Construct a mesh without packets.
void FacesPacket(MemHandle *&pPacket, int &nSetupQwords, int &nVuEnd) const
Report the face packet of the mesh with the geometry and how the first batch is laid out.
void SetZTest(int nPass)
Set the GS depth test and depth write of a pass from the depth mode and comparison.
void DrawFaces(const Transform &xfm)
Send the settings of the face microprogram and the face packet of the mesh with the geometry.
unsigned short GetNumFaces() const
Definition psmesh.h:213
void BuildEdgesPacket()
Build the edge packet from the edges and the vertices.
static constexpr int kVertexCacheSize
The number of entries of g_vertexCache.
Definition psmesh.h:24
const Transform & SkinXfm()
Report the transform to draw the mesh with, skinning its vertices first when it has bones.
int DrawShowing() override
Draw each pass of the faces, then the edges, when the level of detail selects the mesh.
std::unique_ptr< SkinVert[]> mSkinVerts
Definition psmesh.h:210
static void Init()
Install the mesh factory for the class Mesh of a .rnd file, and set g_identityXfm.
void Copy(const RndObject *pSource, int nFlags) override
Copy another mesh, then copy each of its packets this mesh does not have.
RndMesh(const char *pszName)
Construct an empty mesh that draws with a Z depth test and write, passing when nearer.
RndObject(const char *pszName)
Construct an object and register it under a name.
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.
unsigned short g_vertexCache[PsMesh::kVertexCacheSize]
The vertex indices of the batch being built, in the order the batch unpacks them.
Transform g_identityXfm
The identity transform a skinned mesh draws with.
The bind pose of a skinned vertex, with the weight of each bone in the fourth word.
Definition psmesh.h:32
float mWeight1
Definition psmesh.h:34
float mPos[3]
Definition psmesh.h:33
float mWeight2
Definition psmesh.h:36
float mNorm[3]
Definition psmesh.h:35
Affine transform stored as three basis rows and a translation row.
Definition transform.h:18