Files
tp/include/JSystem/J3DGraphBase/J3DDrawBuffer.h
T

99 lines
2.3 KiB
C++
Raw Normal View History

2021-03-28 22:49:05 +02:00
#ifndef J3DDRAWBUFFER_H
#define J3DDRAWBUFFER_H
2021-05-10 08:54:07 -07:00
#include "JSystem/J3DGraphBase/J3DSys.h"
2021-03-28 22:49:05 +02:00
// matches debug
inline f32 J3DCalcZValue(register MtxP m, register Vec v) {
register f32 temp_f4;
register f32 out;
register f32 temp_f0;
register f32 temp_f2;
register f32 temp_f1 = 1.0f;
// clang-format off
asm {
psq_l temp_f0, 0(v), 0, 0 /* qr0 */
lfs temp_f2, 8(v)
psq_l temp_f4, 32(m), 0, 0 /* qr0 */
psq_l out, 40(m), 0, 0 /* qr0 */
ps_merge00 temp_f2, temp_f2, temp_f1
ps_mul temp_f4, temp_f0, temp_f4
ps_madd out, temp_f2, out, temp_f4
ps_sum0 out, out, out, out
}
// clang-format on
return out;
}
2021-05-10 08:54:07 -07:00
class J3DDrawBuffer;
class J3DPacket;
class J3DDrawPacket;
class J3DMatPacket;
class J3DShapePacket;
2022-10-04 17:29:53 -07:00
typedef int (J3DDrawBuffer::*sortFunc)(J3DMatPacket*);
typedef void (J3DDrawBuffer::*drawFunc)() const;
2021-05-10 08:54:07 -07:00
2024-04-12 00:10:30 -06:00
/**
* @ingroup jsystem-j3d
*
*/
2021-05-10 08:54:07 -07:00
class J3DDrawBuffer {
public:
2022-10-04 17:29:53 -07:00
enum EDrawType {
DRAW_HEAD,
DRAW_TAIL,
};
enum ESortType {
SORT_MAT,
SORT_MAT_ANM,
SORT_Z,
SORT_MODEL,
SORT_INVALID,
SORT_NON,
};
J3DDrawBuffer() { initialize(); }
2021-05-10 08:54:07 -07:00
~J3DDrawBuffer();
void initialize();
J3DError allocBuffer(u32);
void frameInit();
2022-10-04 17:29:53 -07:00
int entryMatSort(J3DMatPacket*);
int entryMatAnmSort(J3DMatPacket*);
int entryZSort(J3DMatPacket*);
int entryModelSort(J3DMatPacket*);
int entryInvalidSort(J3DMatPacket*);
int entryNonSort(J3DMatPacket*);
int entryImm(J3DPacket* pPacket, u16 index);
2021-05-10 08:54:07 -07:00
void draw() const;
void drawHead() const;
void drawTail() const;
u32 getEntryTableSize() { return mBufSize; }
2021-05-10 08:54:07 -07:00
inline void calcZRatio();
void setNonSort() { mSortType = 5; }
void setZSort() { mSortType = 2; }
2023-05-09 10:41:27 +03:00
void setZMtx(MtxP mtx) { mpZMtx = mtx; }
2021-05-10 08:54:07 -07:00
public:
/* 0x00 */ J3DPacket** mpBuf;
/* 0x04 */ u32 mBufSize;
/* 0x08 */ u32 mDrawType;
/* 0x0C */ u32 mSortType;
/* 0x10 */ f32 mZNear;
/* 0x14 */ f32 mZFar;
/* 0x18 */ f32 mZRatio;
2022-10-04 17:29:53 -07:00
/* 0x1C */ MtxP mpZMtx;
/* 0x20 */ J3DPacket* mpCallBackPacket;
2021-05-10 08:54:07 -07:00
2022-10-04 17:29:53 -07:00
static sortFunc sortFuncTable[6];
static drawFunc drawFuncTable[2];
static int entryNum;
2021-05-10 08:54:07 -07:00
};
2021-03-28 22:49:05 +02:00
#endif /* J3DDRAWBUFFER_H */