Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/SB/Core/gc/iParMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ struct tagiRenderArrays
struct tagiRenderInput
{
// total size: 0x80
public:
U16* m_index; // offset 0x0, size 0x4
RxObjSpace3DVertex* m_vertex; // offset 0x4, size 0x4
F32* m_vertexTZ; // offset 0x8, size 0x4
Expand Down
1 change: 1 addition & 0 deletions src/SB/Core/x/xDraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "xMath3.h"

void xDrawSetColor(iColor_tag);
void xDrawSetColor(U8 r, U8 g, U8 b, u8 a);
inline void xDrawLine(const xVec3* a, const xVec3* b)
{
}
Expand Down
171 changes: 152 additions & 19 deletions src/SB/Game/zFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "rpworld.h"
#include "rwplcore.h"
#include "xDebug.h"
#include "xDraw.h"
#include "xEnt.h"
#include "xFX.h"
#include "xMath.h"
Expand Down Expand Up @@ -420,13 +421,15 @@ void zFXGooUpdateInstance(zFXGooInstance* goo, F32 dt)
}
}

if(goo_timer_textbox != NULL)
if (goo_timer_textbox != NULL)
{
F32 freeze_time = zFXGooFreezeTimeLeft();

if(freeze_time > 0.0f) {
if (freeze_time > 0.0f)
{
S32 len = freeze_time;
if(len > 0x63) {
if (len > 0x63)
{
len = 0x63;
}

Expand All @@ -435,12 +438,157 @@ void zFXGooUpdateInstance(zFXGooInstance* goo, F32 dt)
goo_timer_textbox->set_text(counter_text);
goo_timer_textbox->activate();
}
else {
else
{
goo_timer_textbox->deactivate();
}
}
}

void zFXGooUpdate(F32 dt)
{
S32 i;
zFXGooInstance* pGoo = &zFXGooInstances[0];

for (i = 0; i < 24; i++)
{
if (pGoo->state != zFXGooStateInactive)
{
zFXGooUpdateInstance(pGoo, dt);
}
pGoo++;
}
}

RpAtomic* zFXGooRenderAtomic(class RpAtomic* atomic)
{
if (g_txtr_gooFrozen == NULL)
{
g_txtr_gooFrozen = xSTFindAsset(0x13401f, NULL);
gAtomicRenderCallBack(atomic);
}

S32 i;
zFXGooInstance* goo = zFXGooInstances;
for (i = 0; i < 24; i++, goo++)
{
if (goo->state == zFXGooStateInactive)
{
continue;
}
if (goo->atomic == atomic)
{
break;
}
}

xDrawSetColor(0xff, 0x80, 0, 0xff);

xVec3 refPos;
if (goo->ref_parentPos != NULL)
{
refPos = *goo->ref_parentPos;
}
else
{
refPos = g_O3;
}

if (i != 24 && goo->state != zFXGooStateInactive && goo->state != zFXGooStateNormal)
{
RwIm3DVertex* vertexBuffer = gRenderBuffer.m_vertex;
U32 numVerts = 0;
if (g_txtr_gooFrozen != NULL)
{
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, ((RwRaster*)g_txtr_gooFrozen)->parent);
}
else
{
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, NULL);
}
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);

RpGeometry* geom = RpAtomicGetGeometry(atomic);
RwRGBA* preLitLum = geom->preLitLum;
RwV3d* verts = geom->morphTarget->verts;
if (xabs(goo->max - goo->min) < 1e-5f)
{
goo->max += 1e-5f;
}

F32 a = (-255.0f * goo->alpha) / (goo->max - goo->min);
F32 b = (255.0f * goo->alpha * goo->min) / (goo->max - goo->min);

U8* bytes = (U8*)xMemPushTemp(geom->numVertices);

for (i = 0; i < geom->numVertices; i++)
{
xVec3 tmp;
xVec3Sub(&tmp, (xVec3*)&verts[i], &goo->center);
F32 c = a * xVec3Length2(&tmp) + b;
c = CLAMP(c, 0.0f, 255.0f);
bytes[i] = (U8)c;
}

RpTriangle* tri = geom->triangles;
for (i = 0; i < geom->numTriangles; i++, tri++)
{
if (numVerts > 0x1dd)
{
if (RwIm3DTransform(vertexBuffer, numVerts, NULL, 0x19) != NULL)
{
RwIm3DRenderPrimitive(rwPRIMTYPETRILIST);
RwIm3DEnd();
}
numVerts = 0;
}

RwIm3DVertex* currentVertBuf = &vertexBuffer[numVerts];
xVec3 a = *(xVec3*)&verts[tri->vertIndex[0]];
xVec3 b = *(xVec3*)&verts[tri->vertIndex[1]];
xVec3 c = *(xVec3*)&verts[tri->vertIndex[2]];

a += refPos;
b += refPos;
c += refPos;
numVerts += 3;

// This part needs to be rewritten somehow, I think it's correct logic though.
RwIm3DVertexSetPos(&currentVertBuf[0], a.x, 0.02f + a.y, a.z);
RwIm3DVertexSetPos(&currentVertBuf[1], b.x, 0.02f + b.y, b.z);
RwIm3DVertexSetPos(&currentVertBuf[2], c.x, 0.02f + c.y, c.z);

RwRGBA* a_color = &preLitLum[tri->vertIndex[0]];
RwIm3DVertexSetRGBA(&currentVertBuf[0], a_color->red, a_color->blue, a_color->red,
bytes[tri->vertIndex[0]]);

RwRGBA* b_color = &preLitLum[tri->vertIndex[1]];
RwIm3DVertexSetRGBA(&currentVertBuf[1], b_color->red, b_color->blue, b_color->red,
bytes[tri->vertIndex[1]]);

RwRGBA* c_color = &preLitLum[tri->vertIndex[2]];
RwIm3DVertexSetRGBA(&currentVertBuf[2], c_color->red, c_color->blue, c_color->red,
bytes[tri->vertIndex[2]]);

currentVertBuf[0].u = goo->orig_uvs[tri->vertIndex[0]].u;
currentVertBuf[1].u = goo->orig_uvs[tri->vertIndex[1]].u;
currentVertBuf[2].u = goo->orig_uvs[tri->vertIndex[2]].u;
currentVertBuf[0].v = goo->orig_uvs[tri->vertIndex[0]].v;
currentVertBuf[1].v = goo->orig_uvs[tri->vertIndex[1]].v;
currentVertBuf[2].v = goo->orig_uvs[tri->vertIndex[2]].v;
}

if (RwIm3DTransform(vertexBuffer, numVerts, NULL, 0x19) != NULL)
{
RwIm3DRenderPrimitive(rwPRIMTYPETRILIST);
RwIm3DEnd();
}
xMemPopTemp(bytes);
}

return atomic;
}

void zFXUpdate(F32 dt)
{
zFXGooUpdate(dt);
Expand Down Expand Up @@ -653,21 +801,6 @@ void reset_poppers()

void zFXGooUpdateInstance(zFXGooInstance*, F32);

void zFXGooUpdate(F32 dt)
{
int i;
zFXGooInstance* pGoo = &zFXGooInstances[0];

for (i = 0; i < 0x18; i++)
{
if (pGoo->state != zFXGooStateInactive)
{
zFXGooUpdateInstance(pGoo, dt);
}
pGoo++;
}
}

xVec3& xVec3::up_normalize()
{
return safe_normalize(xVec3::m_UnitAxisY);
Expand Down
Loading