From 5d500af08aa31054533e2b20ded49740d755f746 Mon Sep 17 00:00:00 2001 From: Michael0933 Date: Sat, 2 Dec 2023 19:26:37 +0100 Subject: [PATCH] [PIPE3D]: Implement PIPE3D_HalvePlaneGetRingPoints --- KAIN2/Game/PIPE3D.C | 86 ++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/KAIN2/Game/PIPE3D.C b/KAIN2/Game/PIPE3D.C index 6265b5764..34a3f6a8c 100644 --- a/KAIN2/Game/PIPE3D.C +++ b/KAIN2/Game/PIPE3D.C @@ -5,6 +5,7 @@ #include "MATH3D.H" #include "STREAM.H" #include "LIGHT3D.H" +#include "DRAW.H" #include "PSX/COLLIDES.H" #include "G2/MAING2.H" #include "G2/QUATG2.H" @@ -824,37 +825,64 @@ void PIPE3D_HalvePlaneInstanceTransformAndDraw(struct _Instance* instance, MATRI } } -// autogenerated function stub: -// void /*$ra*/ PIPE3D_HalvePlaneGetRingPoints(struct _Instance *instance /*$a0*/, MATRIX *wcTransform /*$fp*/, struct _VertexPool *vertexPool /*$s6*/, struct _PrimPool *primPool /*$s7*/, unsigned long **ot /*stack 16*/, struct _FXHalvePlane *ring /*stack 20*/) -void PIPE3D_HalvePlaneGetRingPoints(struct _Instance *instance, MATRIX *wcTransform, struct _VertexPool *vertexPool, struct _PrimPool *primPool, unsigned long **ot, struct _FXHalvePlane *ring) -{ // line 2220, offset 0x8003c048 - /* begin block 1 */ - // Start line: 2221 - // Start offset: 0x8003C048 - // Variables: - struct Object *object; // $v1 - struct _Model *model; // $s1 - MATRIX *matrixPool; // $s3 - //MATRIX wpTransform; // stack offset -152 - //MATRIX pwTransform; // stack offset -120 - //MATRIX pcTransform; // stack offset -88 - struct _MVertex *vertexList; // $s4 - struct _PVertex *poolVertex; // $s5 - struct _SVector normalX; // stack offset -56 - struct _SVector *normal; // $a1 - struct _SVector translation; // stack offset -48 - struct _PlaneConstants *halvePlane; // $a0 - /* end block 1 */ - // End offset: 0x8003C1E8 - // End Line: 2278 +void PIPE3D_HalvePlaneGetRingPoints(struct _Instance* instance, MATRIX* wcTransform, struct _VertexPool* vertexPool, _PrimPool* primPool, unsigned long** ot, struct _FXHalvePlane* ring) // Matching - 99.96% +{ + struct Object* object; + struct _Model* model; + MATRIX* matrixPool; + MATRIX wpTransform; + MATRIX pwTransform; + MATRIX pcTransform; + struct _MVertex* vertexList; + struct _PVertex* poolVertex; + _SVector normalX; + _SVector* normal; + _SVector translation; + struct _PlaneConstants* halvePlane; - /* begin block 2 */ - // Start line: 4440 - /* end block 2 */ - // End Line: 4441 - UNIMPLEMENTED(); -} + poolVertex = (struct _PVertex*)vertexPool; + object = instance->object; + normal = &normalX; + + matrixPool = instance->matrix; + model = object->modelList[instance->currentModel]; + vertexList = model->vertexList; + + if (ring->type == 0) + { + halvePlane = &ring->ringPlane; + } + else + { + halvePlane = &instance->halvePlane; + } + + normal->x = halvePlane->a; + normal->y = halvePlane->b; + normal->z = halvePlane->c; + translation.x = (short)-((normal->x * halvePlane->d) >> 12); + translation.y = (short)-((normal->y * halvePlane->d) >> 12); + translation.z = (short)-((normal->z * halvePlane->d) >> 12); + + PIPE3D_CalcWorldToSplitPlaneTransform(&wpTransform, normal, &translation); + PIPE3D_InvertTransform(&pwTransform, &wpTransform); + if (ring->type == 2) + { + PIPE3D_InvertTransform(&pcTransform, &wpTransform); + } + else + { + CompMatrix(wcTransform, &pwTransform, &pcTransform); + } + + if (matrixPool != 0) + { + PIPE3D_TransformSplitInstanceVertices(vertexList, poolVertex, model, &wpTransform, matrixPool, 0); + draw_belowSplit = 0; + primPool->nextPrim = (unsigned int*)DRAW_DrawRingPoints(model, vertexPool, &pcTransform, primPool, ot, ring->currentColor, ring->type); + } +} // autogenerated function stub: // void /*$ra*/ PIPE3D_DoGlow(struct _Instance *instance /*$s2*/, MATRIX *wcTransform /*$a1*/, struct _VertexPool *vertexPool /*$a2*/, struct _PrimPool *primPool /*$s3*/, unsigned long **ot /*stack 16*/, struct _FXGlowEffect *glow /*stack 20*/)