diff --git a/src/SB/Core/gc/iModel.cpp b/src/SB/Core/gc/iModel.cpp index c1a8d4dc8..e8f15677d 100644 --- a/src/SB/Core/gc/iModel.cpp +++ b/src/SB/Core/gc/iModel.cpp @@ -7,18 +7,26 @@ #include "zAssetTypes.h" #include "xMathInlines.h" -extern RwGlobals* RwEngineInstance; -static RpAtomic* sLastMaterial; -static U32 sMaterialFlags; -static U32 sMaterialIdx; -static RwTexture* sMaterialTexture[16]; -static U32 gLastAtomicCount; -static RpAtomic* gLastAtomicList[256]; +#define MAX2(a, b) ((a) >= (b) ? (a) : (b)) +#define MAX3(a, b, c) (MAX2((a), MAX2((b), (c)))) -static RpLight* sEmptyDirectionalLight[4]; -static RpLight* sEmptyAmbientLight; +#define IMODEL_MAX_ATOMICS 256 +#define IMODEL_MAX_DIRECTIONAL_LIGHTS 4 +#define IMODEL_MAX_MATERIALS 16 + +RpWorld* instance_world; +RwCamera* instance_camera; -int iModelHack_DisablePrelight; +static U32 gLastAtomicCount; +static RpAtomic* gLastAtomicList[IMODEL_MAX_ATOMICS]; +static RpLight* sEmptyDirectionalLight[IMODEL_MAX_DIRECTIONAL_LIGHTS]; +static RpLight* sEmptyAmbientLight; +static RwRGBA sMaterialColor[IMODEL_MAX_MATERIALS]; +static RwTexture* sMaterialTexture[IMODEL_MAX_MATERIALS]; +static U8 sMaterialAlpha[IMODEL_MAX_MATERIALS]; +static U32 sMaterialIdx; +static U32 sMaterialFlags; +static RpAtomic* sLastMaterial; RwFrame* GetChildFrameHierarchy(RwFrame* frame, void* data) { @@ -26,7 +34,7 @@ RwFrame* GetChildFrameHierarchy(RwFrame* frame, void* data) if (hierarchy == 0) { RwFrameForAllChildren(frame, &GetChildFrameHierarchy, data); - return frame; + return frame; } else { @@ -49,13 +57,13 @@ void iModelInit() RwRGBAReal black = { 0.0f, 0.0f, 0.0f, 0.0f }; if (sEmptyDirectionalLight[0] == 0) { - for (int i = 0; i < (int)(sizeof(sEmptyDirectionalLight) / sizeof(RpLight*)); i++) - { - sEmptyDirectionalLight[i] = RpLightCreate(rpLIGHTDIRECTIONAL); + for (int i = 0; i < (int)(sizeof(sEmptyDirectionalLight) / sizeof(RpLight*)); i++) + { + sEmptyDirectionalLight[i] = RpLightCreate(rpLIGHTDIRECTIONAL); RpLightSetColor(sEmptyDirectionalLight[i], &black); - RwFrame* frame = RwFrameCreate(); + RwFrame* frame = RwFrameCreate(); _rwObjectHasFrameSetFrame(sEmptyDirectionalLight[i], frame); - } + } sEmptyAmbientLight = RpLightCreate(rpLIGHTAMBIENT); RpLightSetColor(sEmptyAmbientLight, &black); // Redundant sEmptyAmbientLight load here. } @@ -63,18 +71,19 @@ void iModelInit() RpAtomic* FindAndInstanceAtomicCallback(RpAtomic* model, void* data) { - RpHAnimHierarchy* hierarchy = (RpHAnimHierarchy *)GetHierarchy(model); + RpHAnimHierarchy* hierarchy = (RpHAnimHierarchy*)GetHierarchy(model); RpGeometry* geom = model->geometry; RpSkin* skin = RpSkinGeometryGetSkin(geom); if ((skin != NULL) && (hierarchy == NULL)) { - hierarchy = (RpHAnimHierarchy *)RpHAnimHierarchyCreate(RpSkinGetNumBones(skin), 0, 0, rpHANIMHIERARCHYLOCALSPACEMATRICES, 0x24); + hierarchy = (RpHAnimHierarchy*)RpHAnimHierarchyCreate( + RpSkinGetNumBones(skin), 0, 0, rpHANIMHIERARCHYLOCALSPACEMATRICES, 0x24); RpHAnimFrameSetHierarchy((RwFrame*)(model->object).object.parent, hierarchy); } if ((hierarchy != NULL) && (skin != NULL)) { - RpSkinAtomicSetHAnimHierarchy(model,hierarchy); + RpSkinAtomicSetHAnimHierarchy(model, hierarchy); } if (hierarchy != NULL) { @@ -83,32 +92,33 @@ RpAtomic* FindAndInstanceAtomicCallback(RpAtomic* model, void* data) if (gLastAtomicCount < 0x100) { gLastAtomicList[gLastAtomicCount] = model; - gLastAtomicCount++; + gLastAtomicCount++; } RwFrame* root = RwFrameGetRoot((RwFrame*)(model->object).object.parent); - RpMaterialList* matList = &geom->matList; - int numMats = matList->numMaterials; + RpMaterialList* matList = &geom->matList; + int numMats = matList->numMaterials; - for (int i = 0; i < numMats; i++) - { - RpMaterial *pRVar4 = (RpMaterial *)_rpMaterialListGetMaterial(matList, i); + for (int i = 0; i < numMats; i++) + { + RpMaterial* pRVar4 = (RpMaterial*)_rpMaterialListGetMaterial(matList, i); if ((pRVar4 != NULL) && (RpMatFXMaterialGetEffects(pRVar4) != 0)) { RpMatFXAtomicEnableEffects(model); - model->pipeline = (RxPipeline *)RpMatFXGetGameCubePipeline(rpMATFXGAMECUBEATOMICPIPELINE); + model->pipeline = + (RxPipeline*)RpMatFXGetGameCubePipeline(rpMATFXGAMECUBEATOMICPIPELINE); if (RpSkinGeometryGetSkin(geom) != 0) { RpSkinAtomicSetType(model, rpSKINTYPEMATFX); } - break; + break; } - } + } if (gLastAtomicCount < 0x100) { gLastAtomicList[gLastAtomicCount] = model; - gLastAtomicCount++; + gLastAtomicCount++; } return model; @@ -155,14 +165,14 @@ static RpAtomic* NextAtomicCallback(RpAtomic* atomic, void* data) } else if (*(U32*)data == 0) { - *(RpAtomic **)data = atomic; + *(RpAtomic**)data = atomic; } return atomic; } RpAtomic* iModelFile_RWMultiAtomic(RpAtomic* model) { - RpClump* clump; + RpClump* clump; RpAtomic* nextModel; if (model == 0) @@ -171,10 +181,10 @@ RpAtomic* iModelFile_RWMultiAtomic(RpAtomic* model) } else { - clump = model->clump; + clump = model->clump; nextModel = model; RpClumpForAllAtomics(clump, NextAtomicCallback, &nextModel); - return nextModel; + return nextModel; } } @@ -184,6 +194,116 @@ U32 iModelNumBones(RpAtomic* model) return obj != 0 ? (U32)obj->numNodes : 0; } +S32 iModelCull(RpAtomic* model, RwMatrix* mat) +{ + RwCamera* cam = RwCameraGetCurrentCamera(); + RwSphere sph; + + RwV3dTransformPoints(&sph.center, &model->boundingSphere.center, 1, mat); + + RwReal f1 = RwV3dDotProductMacro(&mat->right, &mat->right); + RwReal f3 = RwV3dDotProductMacro(&mat->up, &mat->up); + RwReal f4 = RwV3dDotProductMacro(&mat->at, &mat->at); + + sph.radius = model->boundingSphere.radius * xsqrt(MAX(f1, MAX(f3, f4))); + + model->worldBoundingSphere = sph; + + if (!cam) + { + return 1; + } + + return (RwCameraFrustumTestSphere(cam, &sph) == rwSPHEREOUTSIDE); +} + +S32 iModelSphereCull(xSphere* sphere) +{ + RwCamera* camera = RwCameraGetCurrentCamera(); + RwFrustumTestResult result = RwCameraFrustumTestSphere(camera, (RwSphere*)sphere); + return (result == rwSPHEREOUTSIDE); +} + +// Very nonmatching +S32 iModelCullPlusShadow(RpAtomic* model, RwMatrix* mat, xVec3* shadowVec, S32* shadowOutside) +{ + F32 xScale2, yScale2, zScale2; + RwV3d *right, *up, *at; + RwCamera* cam; + RwSphere worldsph; + const RwFrustumPlane* frustumPlane; + S32 numPlanes; + + cam = RwCameraGetCurrentCamera(); + + RwV3dTransformPoints(&worldsph.center, &model->boundingSphere.center, 1, mat); + + right = &mat->right; + up = &mat->up; + at = &mat->at; + xScale2 = SQR(right->x) + SQR(right->y) + SQR(right->z); + yScale2 = SQR(up->x) + SQR(up->y) + SQR(up->z); + zScale2 = SQR(at->x) + SQR(at->y) + SQR(at->z); + worldsph.radius = model->boundingSphere.radius * xsqrt(MAX3(xScale2, yScale2, zScale2)); + model->worldBoundingSphere = worldsph; + + numPlanes = 6; + frustumPlane = cam->frustumPlanes; + while (numPlanes--) + { + F32 nDot = worldsph.center.x * frustumPlane->plane.normal.x + + worldsph.center.y * frustumPlane->plane.normal.y + + worldsph.center.z * frustumPlane->plane.normal.z; + nDot -= frustumPlane->plane.distance; + + if (nDot > worldsph.radius) + { + F32 nDot; + + F32 sDot = shadowVec->x * frustumPlane->plane.normal.x + + shadowVec->y * frustumPlane->plane.normal.y + + shadowVec->z * frustumPlane->plane.normal.z; + sDot -= frustumPlane->plane.distance; + + if (sDot > worldsph.radius) + { + *shadowOutside = 1; + return 1; + } + + frustumPlane++; + while (numPlanes--) + { + nDot = worldsph.center.x * frustumPlane->plane.normal.x + + worldsph.center.y * frustumPlane->plane.normal.y + + worldsph.center.z * frustumPlane->plane.normal.z; + nDot -= frustumPlane->plane.distance; + + sDot = shadowVec->x * frustumPlane->plane.normal.x + + shadowVec->y * frustumPlane->plane.normal.y + + shadowVec->z * frustumPlane->plane.normal.z; + sDot -= frustumPlane->plane.distance; + + if (nDot > worldsph.radius && sDot > worldsph.radius) + { + *shadowOutside = 1; + return 1; + } + + frustumPlane++; + } + + *shadowOutside = 0; + return 1; + } + + frustumPlane++; + } + + *shadowOutside = 0; + return 0; +} + void iModelQuatToMat(xQuat* q, xVec3* a, RwMatrixTag* t) { q->s = -q->s; @@ -199,17 +319,17 @@ void iModelAnimMatrices(RpAtomic* model, xQuat* quat, xVec3* tran, RwMatrixTag* { RwMatrixTag* pMatrixArray; RpHAnimNodeInfo* iVar1; - RwMatrixTag matrixStack [33]; + RwMatrixTag matrixStack[33]; U32 pCurrentFrameFlags; RpHAnimNodeInfo* pCurrentFrame; int numFrames; RwMatrixTag* pMatrixStackTop; - pCurrentFrame = (RpHAnimNodeInfo *)GetHierarchy(model); + pCurrentFrame = (RpHAnimNodeInfo*)GetHierarchy(model); if (pCurrentFrame != NULL) { - pMatrixStackTop = &matrixStack[0]; + pMatrixStackTop = &matrixStack[0]; pMatrixStackTop->at.z = 1.0; matrixStack[0].up.y = 1.0; @@ -225,48 +345,48 @@ void iModelAnimMatrices(RpAtomic* model, xQuat* quat, xVec3* tran, RwMatrixTag* matrixStack[0].pos.x = 0.0; matrixStack[0].flags |= 0x20003; - matrixStack[1] = matrixStack[0]; + matrixStack[1] = matrixStack[0]; numFrames = pCurrentFrame->nodeIndex; pMatrixArray = (&matrixStack[1]); - iVar1 = (RpHAnimNodeInfo *)pCurrentFrame[1].nodeID; + iVar1 = (RpHAnimNodeInfo*)pCurrentFrame[1].nodeID; - pMatrixArray++; - for (int i = 0; i < numFrames; i++) - { - pCurrentFrameFlags = iVar1->flags; + pMatrixArray++; + for (int i = 0; i < numFrames; i++) + { + pCurrentFrameFlags = iVar1->flags; if ((pCurrentFrameFlags & 2) != 0) { - *pMatrixArray++ = matrixStack[0]; + *pMatrixArray++ = matrixStack[0]; } - RwMatrixTag afStack_8e8; + RwMatrixTag afStack_8e8; iModelQuatToMat(quat, tran, &afStack_8e8); - RwMatrixTag auStack_8a8; - xMat4x3Mul((xMat4x3*)&auStack_8a8,(xMat4x3*)&afStack_8e8, (xMat4x3*)&matrixStack[0]); + RwMatrixTag auStack_8a8; + xMat4x3Mul((xMat4x3*)&auStack_8a8, (xMat4x3*)&afStack_8e8, (xMat4x3*)&matrixStack[0]); - *mat = auStack_8a8; + *mat = auStack_8a8; if ((pCurrentFrameFlags & 1) != 0) { - pMatrixArray = &pMatrixArray[-1]; + pMatrixArray = &pMatrixArray[-1]; pMatrixStackTop = pMatrixArray; } else { - pMatrixStackTop = (RwMatrixTag *)&auStack_8a8; + pMatrixStackTop = (RwMatrixTag*)&auStack_8a8; } matrixStack[0] = *pMatrixStackTop; mat++; quat++; tran++; iVar1++; - } + } } } RpAtomic* iModelCacheAtomic(RpAtomic* model) { - return model; + return model; } void iModelRender(RpAtomic* model, RwMatrixTag* mat) @@ -278,7 +398,7 @@ void iModelRender(RpAtomic* model, RwMatrixTag* mat) hierarchy = (RpHAnimHierarchy*)GetHierarchy(model); - static S32 draw_all = 1; + static S32 draw_all = 1; if (hierarchy != NULL) { @@ -305,14 +425,478 @@ void iModelRender(RpAtomic* model, RwMatrixTag* mat) S32 iModelSphereCull(const xSphere* sphere) { - return RwCameraFrustumTestSphere((const RwCamera*)RwEngineInstance->curCamera, (const RwSphere*)sphere) == 0; + return RwCameraFrustumTestSphere((const RwCamera*)RwEngineInstance->curCamera, + (const RwSphere*)sphere) == 0; } -U32 iModelVertCount(RpAtomic *model) +U32 iModelVertCount(RpAtomic* model) { return model->geometry->numVertices; } +static inline void SkinXform(xVec3* dest, const xVec3* vert, RwMatrix* mat, const RwMatrix* skinmat, + const F32* wt, const U32* idx, U32 count) +{ + U32 catMatFlags[2] = { 0, 0 }; + RwMatrix* catmat = (RwMatrix*)giAnimScratch; + RwMatrix* rootmat = mat; + mat++; + + while (count != 0) + { + for (U32 i = 0; i < 4; i++) + { + U32 r18 = ((*idx >> (i << 3)) >> 5) & 0x7; + U32 r29 = 1 << ((*idx >> (i << 3)) & 0x1F); + U32 midx = (*idx >> (i << 3)) & 0xFF; + if (!(r29 & catMatFlags[r18])) + { + xMat4x3Mul((xMat4x3*)(catmat + midx), (const xMat4x3*)(skinmat + midx), + (const xMat4x3*)(mat + midx)); + catMatFlags[r18] |= r29; + } + } + + xVec3 accumV; + accumV.x = accumV.y = accumV.z = 0.0f; + + RwMatrix* pMatrix; + const F32* fwt = wt; + U32 wtidx = *idx; + U32 maxwt = 4; + + while (*fwt != 0.0f && maxwt) + { + pMatrix = catmat + (wtidx & 0xFF); + + accumV.x += *fwt * (pMatrix->right.x * vert->x + pMatrix->up.x * vert->y + + pMatrix->at.x * vert->z + pMatrix->pos.x); + accumV.y += *fwt * (pMatrix->right.y * vert->x + pMatrix->up.y * vert->y + + pMatrix->at.y * vert->z + pMatrix->pos.y); + accumV.z += *fwt * (pMatrix->right.z * vert->x + pMatrix->up.z * vert->y + + pMatrix->at.z * vert->z + pMatrix->pos.z); + + fwt++; + wtidx >>= 8; + maxwt--; + } + + dest->x = rootmat->right.x * accumV.x + rootmat->up.x * accumV.y + + rootmat->at.x * accumV.z + rootmat->pos.x; + dest->y = rootmat->right.y * accumV.x + rootmat->up.y * accumV.y + + rootmat->at.y * accumV.z + rootmat->pos.y; + dest->z = rootmat->right.z * accumV.x + rootmat->up.z * accumV.y + + rootmat->at.z * accumV.z + rootmat->pos.z; + + vert++; + idx++; + wt += 4; + count--; + dest++; + } +} + +// TODO: uncomment all code after RW gets implemented + +U32 iModelVertEval(RpAtomic* model, U32 index, U32 count, RwMatrix* mat, xVec3* vert, xVec3* dest) +{ + // RpGeometry* geom = RpAtomicGetGeometry(model); + + // if (!vert) + // { + // U32 numV = RpGeometryGetNumVertices(geom); + // if (index >= numV || count == 0) + // { + // return 0; + // } + // count = xmin(count, numV - index); + // vert = (xVec3*)RpMorphTargetGetVertices(RpGeometryGetMorphTarget(geom, 0)); + // vert += index; + // } + + // RpSkin* skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(model)); + // if (skin) + // { + // SkinXform(dest, vert, mat, RpSkinGetSkinToBoneMatrices(skin), + // (F32*)(RpSkinGetVertexBoneWeights(skin) + index), + // RpSkinGetVertexBoneIndices(skin) + index, count); + // } + // else + // { + // RwV3dTransformPoints((RwV3d*)dest, (const RwV3d*)vert, count, mat); + // } + + // return count; + return 0; +} + +static inline void SkinNormals(xVec3* dest, const xVec3* normal, const RwMatrix* mat, + const RwMatrix* skinmat, const F32* wt, const U32* idx, U32 count) +{ + U32 catMatFlags[2] = { 0, 0 }; + RwMatrix* catmat = (RwMatrix*)giAnimScratch; + const RwMatrix* rootmat = mat; + mat++; + + RwV3d right; + right.x = rootmat->right.x; + right.y = rootmat->right.y; + right.z = rootmat->right.z; + + RwV3d up; + up.x = rootmat->up.x; + up.y = rootmat->up.y; + up.z = rootmat->up.z; + + RwV3d at; + at.x = rootmat->at.x; + at.y = rootmat->at.y; + at.z = rootmat->at.z; + + while (count != 0) + { + for (U32 i = 0; i < 4; i++) + { + U32 r18 = ((*idx >> (i << 3)) >> 5) & 0x7; + U32 r29 = 1 << ((*idx >> (i << 3)) & 0x1F); + U32 midx = (*idx >> (i << 3)) & 0xFF; + if (!(r29 & catMatFlags[r18])) + { + xMat3x3Mul((xMat3x3*)(catmat + midx), (const xMat3x3*)(skinmat + midx), + (const xMat3x3*)(mat + midx)); + xMat3x3Normalize((xMat3x3*)(catmat + midx), (xMat3x3*)(catmat + midx)); + catMatFlags[r18] |= r29; + } + } + + xVec3 accumV; + accumV.x = accumV.y = accumV.z = 0.0f; + + RwMatrix* pMatrix; + const F32* fwt = wt; + U32 wtidx = *idx; + U32 maxwt = 4; + + while (*fwt != 0.0f && maxwt) + { + pMatrix = catmat + (wtidx & 0xFF); + + accumV.x += *fwt * (pMatrix->right.x * normal->x + pMatrix->up.x * normal->y + + pMatrix->at.x * normal->z); + accumV.y += *fwt * (pMatrix->right.y * normal->x + pMatrix->up.y * normal->y + + pMatrix->at.y * normal->z); + accumV.z += *fwt * (pMatrix->right.z * normal->x + pMatrix->up.z * normal->y + + pMatrix->at.z * normal->z); + + fwt++; + wtidx >>= 8; + maxwt--; + } + + dest->x = right.x * accumV.x + up.x * accumV.y + at.x * accumV.z; + dest->y = right.y * accumV.x + up.y * accumV.y + at.y * accumV.z; + dest->z = right.z * accumV.x + up.z * accumV.y + at.z * accumV.z; + + normal++; + idx++; + wt += 4; + count--; + dest++; + } +} + +// TODO: Fix the below 3 functions after RW gets implemented + +U32 iModelNormalEval(xVec3* out, const RpAtomic& m, const RwMatrix* mat, size_t index, S32 size, + const xVec3* in) +{ + // RpGeometry* geom = RpAtomicGetGeometry(&m); + + // if (!in) + // { + // S32 numV = RpGeometryGetNumVertices(geom); + // S32 max_size = numV - index; + // if (size < 0 || size > max_size) + // { + // size = max_size; + // } + // in = (const xVec3*)RpMorphTargetGetVertexNormals(RpGeometryGetMorphTarget(geom, 0)); + // } + + // if (size <= 0) + // return 0; + + // in += index; + + // RpSkin* skin = RpSkinGeometryGetSkin(geom); + // if (skin) + // { + // const RwMatrix* skin_mats = RpSkinGetSkinToBoneMatrices(skin); + // const F32* bone_weights = (F32*)RpSkinGetVertexBoneWeights(skin) + index; + // const U32* bone_indices = RpSkinGetVertexBoneIndices(skin) + index; + // SkinNormals(out, in, mat, skin_mats, bone_weights, bone_indices, size); + // } + // else + // { + // xMat4x3 nmat; + // xMat3x3Normalize( + // &nmat, (xMat3x3*)&mat); // BUG: mat is already a pointer, nmat will have garbage data!!! + // nmat.pos.assign(0.0f, 0.0f, 0.0f); + // RwV3dTransformPoints((RwV3d*)out, (RwV3d*)in, size, (RwMatrix*)&nmat); + // } + + // return size; + return 0; +} + +static U32 iModelTagUserData(xModelTag* tag, RpAtomic* model, F32 x, F32 y, F32 z, S32 closeV) +{ + // S32 i, count; + // RpUserDataArray *array, *testarray; + // F32 distSqr, closeDistSqr; + // S32 numTags, t; + // xModelTag* tagList; + + // count = RpGeometryGetUserDataArrayCount(model->geometry); + // array = NULL; + + // for (i = 0; i < count; i++) + // { + // testarray = RpGeometryGetUserDataArray(model->geometry, i); + // if (strcmp(testarray->name, "HI_Tags") == 0) + // { + // array = testarray; + // break; + // } + // } + + // if (!array) + // { + // memset(tag, 0, sizeof(xModelTag)); + // return 0; + // } + + // numTags = *(S32*)array->data; + // closeDistSqr = 1.0e9f; + // tagList = (xModelTag*)((S32*)array->data + 1); + + // if (closeV < 0 || closeV > numTags) + // { + // closeV = 0; + // for (t = 0; t < numTags; t++) + // { + // distSqr = + // xsqr(tagList[t].v.x - x) + xsqr(tagList[t].v.y - y) + xsqr(tagList[t].v.z - z); + // if (distSqr < closeDistSqr) + // { + // closeV = t; + // closeDistSqr = distSqr; + // } + // } + // if (tag) + // { + // *tag = tagList[closeV]; + // } + // } + // else + // { + // if (tag) + // { + // *tag = tagList[closeV]; + // } + // } + + // return closeV; + return 0; +} + +static U32 iModelTagInternal(xModelTag* tag, RpAtomic* model, F32 x, F32 y, F32 z, S32 closeV) + +{ + // RpGeometry* geom; + // RwV3d* vert; + // S32 v, numV; + // F32 distSqr, closeDistSqr; + // RpSkin* skin; + // const RwMatrixWeights* wt; + + // geom = RpAtomicGetGeometry(model); + // vert = RpMorphTargetGetVertices(RpGeometryGetMorphTarget(geom, 0)); + + // if (!vert) + // { + // return iModelTagUserData(tag, model, x, y, z, closeV); + // } + + // numV = RpGeometryGetNumVertices(geom); + // closeDistSqr = 1.0e9f; + + // if (closeV < 0 || closeV > numV) + // { + // closeV = 0; + // for (v = 0; v < numV; v++) + // { + // distSqr = xsqr(vert[v].x - x) + xsqr(vert[v].y - y) + xsqr(vert[v].z - z); + // if (distSqr < closeDistSqr) + // { + // closeV = v; + // closeDistSqr = distSqr; + // } + // } + // if (tag) + // { + // tag->v.x = x; + // tag->v.y = y; + // tag->v.z = z; + // } + // } + // else + // { + // if (tag) + // { + // tag->v.x = vert[closeV].x; + // tag->v.y = vert[closeV].y; + // tag->v.z = vert[closeV].z; + // } + // } + + // if (tag) + // { + // skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(model)); + // if (skin) + // { + // wt = RpSkinGetVertexBoneWeights(skin) + closeV; + // tag->matidx = RpSkinGetVertexBoneIndices(skin)[closeV]; + // tag->wt[0] = wt->w0; + // tag->wt[1] = wt->w1; + // tag->wt[2] = wt->w2; + // tag->wt[3] = wt->w3; + // } + // else + // { + // tag->matidx = 0; + // tag->wt[0] = 0.0f; + // tag->wt[1] = 0.0f; + // tag->wt[2] = 0.0f; + // tag->wt[3] = 0.0f; + // } + // } + + // return closeV; + return 0; +} + +U32 iModelTagSetup(xModelTag* tag, RpAtomic* model, F32 x, F32 y, F32 z) +{ + return iModelTagInternal(tag, model, x, y, z, -1); +} + +U32 iModelTagSetup(xModelTagWithNormal* tag, RpAtomic* model, F32 x, F32 y, F32 z) +{ + U32 index = iModelTagInternal(tag, model, x, y, z, -1); + xVec3* normals = (xVec3*)model->geometry->morphTarget[0].normals; + tag->normal = normals[index]; + return index; +} + +void iModelTagEval(RpAtomic* model, const xModelTag* tag, RwMatrix* mat, xVec3* dest) +{ + if (tag->wt[0]) + { + RpGeometry* geom = RpAtomicGetGeometry(model); + RpSkin* skin = RpSkinGeometryGetSkin(geom); + const RwMatrix* skinmat = RpSkinGetSkinToBoneMatrices(skin); + SkinXform(dest, &tag->v, mat, skinmat, tag->wt, &tag->matidx, 1); + } + else + { + RwV3dTransformPoints((RwV3d*)dest, (RwV3d*)&tag->v, 1, mat); + } +} + +void iModelTagEval(RpAtomic* model, const xModelTagWithNormal* tag, RwMatrix* mat, xVec3* dest, + xVec3* normal) +{ + iModelTagEval(model, tag, mat, dest); + if (tag->wt[0]) + { + RpGeometry* geom = RpAtomicGetGeometry(model); + RpSkin* skin = RpSkinGeometryGetSkin(geom); + const RwMatrix* skinmat = RpSkinGetSkinToBoneMatrices(skin); + SkinNormals(normal, &tag->normal, mat, skinmat, tag->wt, &tag->matidx, 1); + } + else + { + RwV3dTransformPoints((RwV3d*)normal, (RwV3d*)&tag->normal, 1, mat); + } +} + +static RpMaterial* iModelSetMaterialAlphaCB(RpMaterial* material, void* data) +{ + const RwRGBA* col = RpMaterialGetColor(material); + sMaterialAlpha[sMaterialIdx++] = col->alpha; + + RwRGBA new_col = *col; + new_col.alpha = *(U8*)data; + + RpMaterialSetColor(material, &new_col); + + return material; +} + +// TODO: another thing that needs fixed after RW gets implemented +void iModelSetMaterialAlpha(RpAtomic* model, U8 alpha) +{ + // RpGeometry* geom = RpAtomicGetGeometry(model); + + // if (model != sLastMaterial) + // { + // sMaterialFlags = 0; + // } + + // RpGeometrySetFlags(geom, RpGeometryGetFlags(geom) | rpGEOMETRYMODULATEMATERIALCOLOR); + + // sMaterialIdx = 0; + + // RpGeometryForAllMaterials(geom, iModelSetMaterialAlphaCB, &alpha); + + // sMaterialFlags |= 0x1; + // sLastMaterial = model; +} + +static RpMaterial* iModelResetMaterialCB(RpMaterial* material, void* data) +{ + if ((sMaterialFlags & 0x3) == 0x3) + { + RwRGBA newColor = sMaterialColor[sMaterialIdx]; + newColor.alpha = sMaterialAlpha[sMaterialIdx]; + RpMaterialSetColor(material, &newColor); + } + else + { + if (sMaterialFlags & 0x2) + { + RwRGBA newColor = sMaterialColor[sMaterialIdx]; + newColor.alpha = RpMaterialGetColor(material)->alpha; + RpMaterialSetColor(material, &newColor); + } + if (sMaterialFlags & 0x1) + { + RwRGBA newColor = *RpMaterialGetColor(material); + newColor.alpha = sMaterialAlpha[sMaterialIdx]; + RpMaterialSetColor(material, &newColor); + } + } + + if (sMaterialFlags & 0x4) + { + RpMaterialSetTexture(material, sMaterialTexture[sMaterialIdx]); + } + + sMaterialIdx++; + return material; +} + void iModelResetMaterial(RpAtomic* model) { RpAtomic* material = sLastMaterial; // r2 @@ -323,7 +907,7 @@ void iModelResetMaterial(RpAtomic* model) sMaterialFlags = 0; } - geom = model->geometry; + geom = model->geometry; sMaterialIdx = 0; RpGeometryForAllMaterials(geom, iModelResetMaterialCB, 0); @@ -333,7 +917,7 @@ void iModelResetMaterial(RpAtomic* model) RpMaterial* iModelSetMaterialTextureCB(RpMaterial* material, void* data) { int i = sMaterialIdx; - RwTexture* texture = material->texture; + RwTexture* texture = material->texture; sMaterialIdx++; sMaterialTexture[i] = texture; RpMaterialSetTexture(material, (RwTexture*)data); @@ -342,14 +926,70 @@ RpMaterial* iModelSetMaterialTextureCB(RpMaterial* material, void* data) void iModelSetMaterialTexture(RpAtomic* model, void* texture) { - RpGeometry* geom; + RpGeometry* geom; if (model != sLastMaterial) { sMaterialFlags = 0; } - geom = model->geometry; + geom = model->geometry; sMaterialIdx = 0; RpGeometryForAllMaterials(geom, iModelSetMaterialTextureCB, texture); sMaterialFlags |= 4; sLastMaterial = model; -} \ No newline at end of file +} + +namespace +{ + inline void U8_COLOR_CLAMP(U8& destu8, F32 srcf32) + { + if (srcf32 < 0.0f) + srcf32 = 0.0f; + else if (srcf32 > 255.0f) + srcf32 = 255.0f; + destu8 = (U8)srcf32; + } +} // namespace + +static RpMaterial* iModelMaterialMulCB(RpMaterial* material, void* data) +{ + const RwRGBA* rw_col = RpMaterialGetColor(material); + RwRGBA col = sMaterialColor[sMaterialIdx++] = *rw_col; + F32 tmp; + F32* mods = (F32*)data; + + tmp = col.red * mods[0]; + U8_COLOR_CLAMP(col.red, tmp); + + tmp = col.green * mods[1]; + U8_COLOR_CLAMP(col.green, tmp); + + tmp = col.blue * mods[2]; + U8_COLOR_CLAMP(col.blue, tmp); + + RpMaterialSetColor(material, &col); + + return material; +} + +// TODO: once again, fix after RW implementation +void iModelMaterialMul(RpAtomic* model, F32 rm, F32 gm, F32 bm) +{ + // RpGeometry* geom = RpAtomicGetGeometry(model); + + // if (model != sLastMaterial) + // { + // sMaterialFlags = 0; + // } + + // RpGeometrySetFlags(geom, RpGeometryGetFlags(geom) | rpGEOMETRYMODULATEMATERIALCOLOR); + + // F32 cols[3]; + // cols[0] = rm; + // cols[1] = gm; + // cols[2] = bm; + + // RpGeometryForAllMaterials(geom, iModelMaterialMulCB, cols); + + // sLastMaterial = model; + // sMaterialFlags |= 0x2; +} diff --git a/src/SB/Core/gc/iModel.h b/src/SB/Core/gc/iModel.h index f472549b2..ff4a7e0b2 100644 --- a/src/SB/Core/gc/iModel.h +++ b/src/SB/Core/gc/iModel.h @@ -11,7 +11,7 @@ void iModelInit(); static RpAtomic* FindAndInstanceAtomicCallback(RpAtomic* model, void* data); static RpAtomic* iModelCacheAtomic(RpAtomic*); -RpMaterial* iModelResetMaterialCB(RpMaterial*, void*); +static RpMaterial* iModelResetMaterialCB(RpMaterial*, void*); static void* GetHierarchy(RpAtomic* frame); static RwFrame* GetChildFrameHierarchy(RwFrame* frame, void* data); U32 iModelNumBones(RpAtomic* model); @@ -29,7 +29,8 @@ void iModelTagEval(RpAtomic* model, const xModelTag* tag, RwMatrixTag* mat, xVec U32 iModelTagSetup(xModelTag* tag, RpAtomic* model, F32 x, F32 y, F32 z); void iModelSetMaterialAlpha(RpAtomic* model, U8 alpha); U32 iModelVertCount(RpAtomic* model); -U32 iModelVertEval(RpAtomic* model, U32 index, U32 count, RwMatrixTag* mat, xVec3* vert, xVec3* dest); +U32 iModelVertEval(RpAtomic* model, U32 index, U32 count, RwMatrixTag* mat, xVec3* vert, + xVec3* dest); void iModelMaterialMul(RpAtomic* model, F32 rm, F32 gm, F32 bm); RpAtomic* iModelFileNew(void* buffer, U32 size); void iModelRender(RpAtomic* model, RwMatrix* mat); diff --git a/src/SB/Core/x/xCollide.cpp b/src/SB/Core/x/xCollide.cpp index df4a9496a..a14ea1f09 100644 --- a/src/SB/Core/x/xCollide.cpp +++ b/src/SB/Core/x/xCollide.cpp @@ -263,7 +263,6 @@ U32 xSphereHitsBox(const xSphere* a, const xBox* b, xCollis* coll) } U32 xSphereHitsOBB_nu(const xSphere* s, const xBox* b, const xMat4x3* m, xCollis* coll) -//NONMATCH("https://decomp.me/scratch/YoEeE") { xSphere xfs; xVec3 scale; @@ -325,7 +324,6 @@ static RpCollisionTriangle* sphereHitsModelCB(RpIntersection* isx, RpCollisionTr } U32 xSphereHitsModel(const xSphere* b, const xModelInstance* m, xCollis* coll) -// NONMATCH("https://decomp.me/scratch/XU6BL") { RpIntersection isx; @@ -556,7 +554,6 @@ static S32 xParabolaEnvCB(xClumpCollBSPTriangle* triangles, void* data) } S32 xParabolaHitsEnv(xParabola* p, const xEnv* env, xCollis* colls) -//NONMATCH("https://decomp.me/scratch/Hli1c") { RwBBox xb; F32 tmp; @@ -1286,7 +1283,6 @@ RpCollBSPTree* _rpCollBSPTreeForAllCapsuleLeafNodeIntersections( } void xSweptSpherePrepare(xSweptSphere* sws, xVec3* start, xVec3* end, F32 radius) -//NONMATCH("https://decomp.me/scratch/5VJcM") { sws->start = *start; sws->end = *end; @@ -1393,7 +1389,6 @@ void xSweptSphereGetResults(xSweptSphere* sws) } S32 xSweptSphereToTriangle(xSweptSphere* sws, xVec3* v0, xVec3* v1, xVec3* v2) -//NONMATCH("https://decomp.me/scratch/MJ9KD") { S32 i; @@ -1652,7 +1647,6 @@ S32 xSweptSphereToSphere(xSweptSphere* sws, xSphere* sph) } S32 xSweptSphereToBox(xSweptSphere* sws, xBox* box, xMat4x3* mat) -//NONMATCH("https://decomp.me/scratch/97pAl") { S32 i; xMat4x3 tmpmat; @@ -2036,7 +2030,6 @@ S32 xSweptSphereToEnv(xSweptSphere* sws, xEnv* env) } static S32 SweptSphereModelCB(S32 numTriangles, S32 triOffset, void* data) -// NONMATCH("https://decomp.me/scratch/XMJhx") { SweptSphereCollParam* isData = (SweptSphereCollParam*)data; RpGeometry* geometry = isData->geometry; @@ -2066,7 +2059,6 @@ static S32 SweptSphereModelCB(S32 numTriangles, S32 triOffset, void* data) } S32 xSweptSphereToModel(xSweptSphere* sws, RpAtomic* model, RwMatrix* mat) -//NONMATCH("https://decomp.me/scratch/3R1PB") { if (!sws->dist) return 0; diff --git a/src/SB/Core/x/xEntBoulder.cpp b/src/SB/Core/x/xEntBoulder.cpp index 4f3672200..8c99ff420 100644 --- a/src/SB/Core/x/xEntBoulder.cpp +++ b/src/SB/Core/x/xEntBoulder.cpp @@ -1,7 +1,9 @@ #include "xCollide.h" #include "xEntBoulder.h" #include "xFX.h" +#include "xGroup.h" #include "xMarkerAsset.h" +#include "xMathInlines.h" #include "xMath3.h" #include "xNPCBasic.h" #include "xShadow.h" @@ -26,9 +28,11 @@ static xEntCollis sBoulderCollis; void xShadowManager_Add(xEnt* ent); S32 xEntBoulder_KilledBySurface(xEntBoulder* ent); S32 xEntBoulder_KilledBySurface(xEntBoulder* ent, xScene* sc, F32 dt); -S32 xBoulderGenerator_EventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, xBase* toParamWidget); +S32 xBoulderGenerator_EventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, + xBase* toParamWidget); void xBoulderGenerator_Reset(xBoulderGenerator* gen); -S32 RecurseLinks(xLinkAsset*, S32, xEntBoulder**); +static S32 RecurseLinks(xLinkAsset*, S32, xEntBoulder**); +static void RecurseChild(xBase* child, xEntBoulder** boulList, S32& currBoul); void xEntBoulder_FitToModel(xEntBoulder* ent) { @@ -49,43 +53,43 @@ void xEntBoulder_Render(xEnt* ent) { switch (model->Flags & 0x400) { - case 0: - if (ent->flags & 0x40) + case 0: + if (ent->flags & 0x40) + { + if (!iModelCull(model->Data, model->Mat)) { - if (!iModelCull(model->Data, model->Mat)) - { - xModelRender(model); - } + xModelRender(model); } - else + } + else + { + shadVec.x = model->Mat->pos.x; + shadVec.y = model->Mat->pos.y - 10.0f; + shadVec.z = model->Mat->pos.z; + + if (!iModelCullPlusShadow(model->Data, model->Mat, &shadVec, &shadowResult)) { - shadVec.x = model->Mat->pos.x; - shadVec.y = model->Mat->pos.y - 10.0f; - shadVec.z = model->Mat->pos.z; + xModelRender(model); + } - if (!iModelCullPlusShadow(model->Data, model->Mat, &shadVec, &shadowResult)) + if (!shadowResult) + { + if (ent->flags & 0x10) { - xModelRender(model); + xShadowManager_Add(ent); } - - if (!shadowResult) + else { - if (ent->flags & 0x10) - { - xShadowManager_Add(ent); - } - else + radius = ent->model->Data->boundingSphere.radius; + if (radius > 0.75f) { - radius = ent->model->Data->boundingSphere.radius; - if (radius > 0.75f) - { - radius = 0.75f; - } - xShadowSimple_Add(ent->simpShadow,ent, 2.0f * radius, 1.0f); + radius = 0.75f; } + xShadowSimple_Add(ent->simpShadow, ent, 2.0f * radius, 1.0f); } } - break; + } + break; } } } @@ -96,8 +100,8 @@ void xEntBoulder_Init(void* ent, void* asset) } S32 xEntBoulderEventCB(xBase*, xBase*, U32, const F32*, xBase*); -void xEntBoulder_BUpdate(xEnt *, xVec3 *); -void xEntBoulder_Update(xEntBoulder *, xScene *, F32); +void xEntBoulder_BUpdate(xEnt*, xVec3*); +void xEntBoulder_Update(xEntBoulder*, xScene*, F32); void xEntBoulder_Init(xEntBoulder* ent, xEntAsset* asset) { @@ -112,7 +116,7 @@ void xEntBoulder_Init(xEntBoulder* ent, xEntAsset* asset) xEntInitShadow(*ent, ent->entShadow_embedded); ent->simpShadow = &ent->simpShadow_embedded; xShadowSimple_CacheInit(ent->simpShadow, ent, 0x50); - ent->frame = (xEntFrame *)xMemAlloc(gActiveHeap, sizeof(xEntFrame), 0); + ent->frame = (xEntFrame*)xMemAlloc(gActiveHeap, sizeof(xEntFrame), 0); memset(ent->frame, 0, sizeof(xEntFrame)); basset = (xEntBoulderAsset*)(&asset[1]); ent->collis = NULL; @@ -124,7 +128,7 @@ void xEntBoulder_Init(xEntBoulder* ent, xEntAsset* asset) if (ent->linkCount != 0) { - ent->link = (xLinkAsset *)(&ent->asset[1]); + ent->link = (xLinkAsset*)(&ent->asset[1]); } else { @@ -176,10 +180,10 @@ void xEntBoulder_ApplyForces(xEntCollis* collis) xBase* obj = (xBase*)(coll->optr); if ((obj != NULL) && (obj->baseType == eBaseTypeBoulder)) { - xEntBoulder* boul = ((xEntBoulder *)(coll->optr)); + xEntBoulder* boul = ((xEntBoulder*)(coll->optr)); xVec3 vec; xVec3SMul(&vec, &collis->colls[i].norm, -5.0f); - if ((boul == globals.player.drv.odriver) || (boul == globals.player.drv.driver)) + if ((boul == globals.player.drv.odriver) || (boul == globals.player.drv.driver)) { if (collis->colls[i].norm.y > 0.5f) { @@ -224,7 +228,7 @@ void xEntBoulder_RealBUpdate(xEnt* ent, xVec3* pos) xVec3 vec; xEntBoulder* boul = (xEntBoulder*)ent; - xMat3x3RMulVec(&vec, (xMat3x3 *)boul->model->Mat, (xVec3 *)&boul->localCenter); + xMat3x3RMulVec(&vec, (xMat3x3*)boul->model->Mat, (xVec3*)&boul->localCenter); xVec3Add(&boul->bound.sph.center, pos, &vec); xBoundUpdate(&boul->bound); zGridUpdateEnt(boul); @@ -268,16 +272,11 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) zEntEvent(ent, eEventKill); return; } - else if - ( - (ent == globals.player.bubblebowl) && - ( - dx__ = (globals.player.ent.bound.sph.center.x - ent->model->Mat->pos.x), - dy__ = (globals.player.ent.bound.sph.center.y - ent->model->Mat->pos.y), - dz__ = (globals.player.ent.bound.sph.center.z - ent->model->Mat->pos.z), - (dx__ * dx__) + (dy__ * dy__) + (dz__ * dz__) > 3600.0f - ) - ) + else if ((ent == globals.player.bubblebowl) && + (dx__ = (globals.player.ent.bound.sph.center.x - ent->model->Mat->pos.x), + dy__ = (globals.player.ent.bound.sph.center.y - ent->model->Mat->pos.y), + dz__ = (globals.player.ent.bound.sph.center.z - ent->model->Mat->pos.z), + (dx__ * dx__) + (dy__ * dy__) + (dz__ * dz__) > 3600.0f)) { zEntEvent(ent, eEventKill); return; @@ -285,14 +284,14 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) if (ent->collis == NULL) { - ent->collis = (xEntCollis *)&sBoulderCollis; + ent->collis = (xEntCollis*)&sBoulderCollis; } ent->collis->chk = ent->collis_chk; ent->collis->pen = ent->collis_pen; ent->collis->post = NULL; ent->collis->depenq = NULL; - xMat3x3RMulVec(&newRotVec, (xMat3x3 *)ent->model->Mat, &ent->localCenter); + xMat3x3RMulVec(&newRotVec, (xMat3x3*)ent->model->Mat, &ent->localCenter); xVec3Add(&ent->bound.sph.center, (xVec3*)&ent->model->Mat->pos, &newRotVec); if ((sBubbleStreakID != 0xDEAD) && (globals.player.bubblebowl == ent)) @@ -350,13 +349,10 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) numDepens = 0; xVec3Init(&tmp, 0.0f, 0.0f, 0.0f); // Let's initialize a vector for no reason. - if - ( - (ent->collis->env_eidx > ent->collis->env_sidx) || - (ent->collis->dyn_eidx > ent->collis->dyn_sidx) || - (ent->collis->npc_eidx > ent->collis->npc_sidx) || - (ent->collis->stat_eidx > ent->collis->stat_sidx) - ) + if ((ent->collis->env_eidx > ent->collis->env_sidx) || + (ent->collis->dyn_eidx > ent->collis->dyn_sidx) || + (ent->collis->npc_eidx > ent->collis->npc_sidx) || + (ent->collis->stat_eidx > ent->collis->stat_sidx)) { xVec3Init(&depen, 0.0f, 0.0f, 0.0f); @@ -365,18 +361,15 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) { if (ent->basset->flags & 1) { - xVec3AddTo(&depen, (xVec3 *)(&ent->collis->colls[i].depen)); + xVec3AddTo(&depen, (xVec3*)(&ent->collis->colls[i].depen)); } else { uVar19 = xVec3Dot(&ent->collis->colls[i].norm, &ent->collis->colls[i].depen); - if - ( - (ent == globals.player.bubblebowl) && - (xVec3Dot(&ent->collis->colls[i].norm, &velNorm) < -0.70710676f) && - (ent->timeToLive > 0.05f) - ) + if ((ent == globals.player.bubblebowl) && + (xVec3Dot(&ent->collis->colls[i].norm, &velNorm) < -0.70710676f) && + (ent->timeToLive > 0.05f)) { ent->timeToLive = 0.05f; } @@ -391,22 +384,24 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) { if (ent->basset->flags & 1) { - xVec3AddTo(&depen, (xVec3 *)(&ent->collis->colls[i].depen)); + xVec3AddTo(&depen, (xVec3*)(&ent->collis->colls[i].depen)); } else { - xVec3AddScaled(&depen, &ent->collis->colls[i].norm, xVec3Dot(&ent->collis->colls[i].norm, &ent->collis->colls[i].depen)); + xVec3AddScaled(&depen, &ent->collis->colls[i].norm, + xVec3Dot(&ent->collis->colls[i].norm, &ent->collis->colls[i].depen)); } - xEntBoulder* boul = ((xEntBoulder *)(ent->collis->colls[i].optr)); + xEntBoulder* boul = ((xEntBoulder*)(ent->collis->colls[i].optr)); if (boul->baseType == eBaseTypeBoulder) { - xVec3Normalize(&depenNorm0, (xVec3 *)(&ent->collis->colls[i].depen)); + xVec3Normalize(&depenNorm0, (xVec3*)(&ent->collis->colls[i].depen)); dVar18 = xVec3Dot(&ent->vel, &depenNorm0); dVar16 = xVec3Dot(&boul->vel, &depenNorm0); F32 collMass = boul->basset->mass; F32 boulMass = ent->basset->mass; - xVec3SMulBy(&depenNorm0, ((2.0f * boulMass) * collMass * (dVar16 - dVar18)) / (boulMass + collMass)); + xVec3SMulBy(&depenNorm0, ((2.0f * boulMass) * collMass * (dVar16 - dVar18)) / + (boulMass + collMass)); xVec3SMul(&force, &depenNorm0, ent->basset->bounce); xEntBoulder_AddInstantForce(ent, &force); xVec3SMul(&force, &depenNorm0, -boul->basset->bounce); @@ -425,15 +420,13 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) } zPlatform* plat = ((zPlatform*)(boul)); - if - ( - (ent == globals.player.bubblebowl) && - (plat->moreFlags & 0x10) && + if ((ent == globals.player.bubblebowl) && (plat->moreFlags & 0x10) && (plat->baseType == eBaseTypePlatform) && - (plat->subType == ZPLATFORM_SUBTYPE_PADDLE && (plat->passet->paddle.paddleFlags & 0x10)) - ) + (plat->subType == ZPLATFORM_SUBTYPE_PADDLE && + (plat->passet->paddle.paddleFlags & 0x10))) { - zPlatform_PaddleCollide(&ent->collis->colls[i], (xVec3 *)(&ent->model->Mat->pos), &ent->vel, 1); + zPlatform_PaddleCollide(&ent->collis->colls[i], (xVec3*)(&ent->model->Mat->pos), + &ent->vel, 1); } numDepens++; @@ -444,42 +437,32 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) { if (ent->basset->flags & 1) { - xVec3AddTo(&depen, (xVec3 *)(&ent->collis->colls[i].depen)); + xVec3AddTo(&depen, (xVec3*)(&ent->collis->colls[i].depen)); } else { uVar19 = xVec3Dot(&ent->collis->colls[i].norm, &ent->collis->colls[i].depen); - if - ( - (ent == globals.player.bubblebowl) && + if ((ent == globals.player.bubblebowl) && (xVec3Dot(&ent->collis->colls[i].norm, &velNorm) < -0.70710676f) && - (ent->timeToLive > 0.05f) - ) + (ent->timeToLive > 0.05f)) { ent->timeToLive = 0.05f; } xVec3AddScaled(&depen, &ent->collis->colls[i].norm, uVar19); } - boul = (xEntBoulder *)(ent->collis->colls[i].optr); + boul = (xEntBoulder*)(ent->collis->colls[i].optr); if ((ent->basset->flags & 4) && (boul->baseType == eBaseTypeDestructObj)) { - if - ( - (zEntDestructObj_GetHit((zEntDestructObj*)boul, 0x8000)) && - (ent == globals.player.bubblebowl) && - (ent->timeToLive > 0.05f)) + if ((zEntDestructObj_GetHit((zEntDestructObj*)boul, 0x8000)) && + (ent == globals.player.bubblebowl) && (ent->timeToLive > 0.05f)) { ent->timeToLive = 0.05f; } zEntDestructObj_Hit((zEntDestructObj*)boul, 0x8000); } - else if - ( - (ent == globals.player.bubblebowl) && - (boul->moreFlags & 0x10) && - (boul->baseType != eBaseTypeBoulder || (boul->basset->flags & 0x100)) - ) + else if ((ent == globals.player.bubblebowl) && (boul->moreFlags & 0x10) && + (boul->baseType != eBaseTypeBoulder || (boul->basset->flags & 0x100))) { zEntEvent(ent, boul, eEventHit_BubbleBowl); zEntEvent(ent, boul, eEventHit); @@ -498,16 +481,13 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) npc = (zNPCCommon*)(ent->collis->colls[iter_npc].optr); if (ent->basset->flags & 1) { - xVec3AddTo(&depen, (xVec3 *)(&ent->collis->colls[iter_npc].depen)); + xVec3AddTo(&depen, (xVec3*)(&ent->collis->colls[iter_npc].depen)); } else { - uVar19 = xVec3Dot(&ent->collis->colls[iter_npc].norm, &ent->collis->colls[iter_npc].depen); - if - ( - (ent != globals.player.bubblebowl) || - (npc->SelfType() & ~0xFF) != 'NTT\0' - ) + uVar19 = xVec3Dot(&ent->collis->colls[iter_npc].norm, + &ent->collis->colls[iter_npc].depen); + if ((ent != globals.player.bubblebowl) || (npc->SelfType() & ~0xFF) != 'NTT\0') { xVec3AddScaled(&depen, &ent->collis->colls[iter_npc].norm, uVar19); } @@ -516,17 +496,16 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) if (ent->basset->flags & 8) { zEntEvent(ent, npc, eEventHit, 0); - zEntPlayer_SNDPlayStreamRandom(0x00, 0x10, ePlayerStreamSnd_BowlComment1, ePlayerStreamSnd_BowlComment3, 0.1f); - zEntPlayer_SNDPlayStreamRandom(0x10, 0x23, ePlayerStreamSnd_BowlComment1, ePlayerStreamSnd_BowlComment4, 0.1f); - zEntPlayer_SNDPlayStreamRandom(0x24, 0x64, ePlayerStreamSnd_BowlComment1, ePlayerStreamSnd_BowlComment5, 0.1f); - if - ( - (ent == globals.player.bubblebowl) && - ( - ((npc->SelfType() & ~0xFF) != 'NTT\0') || - (npc->SelfType() == NPC_TYPE_TIKI_STONE)) && - (ent->timeToLive > 0.05f) - ) + zEntPlayer_SNDPlayStreamRandom(0x00, 0x10, ePlayerStreamSnd_BowlComment1, + ePlayerStreamSnd_BowlComment3, 0.1f); + zEntPlayer_SNDPlayStreamRandom(0x10, 0x23, ePlayerStreamSnd_BowlComment1, + ePlayerStreamSnd_BowlComment4, 0.1f); + zEntPlayer_SNDPlayStreamRandom(0x24, 0x64, ePlayerStreamSnd_BowlComment1, + ePlayerStreamSnd_BowlComment5, 0.1f); + if ((ent == globals.player.bubblebowl) && + (((npc->SelfType() & ~0xFF) != 'NTT\0') || + (npc->SelfType() == NPC_TYPE_TIKI_STONE)) && + (ent->timeToLive > 0.05f)) { ent->timeToLive = 0.05f; } @@ -599,7 +578,8 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) else { F32 div = xVec3Length(&ent->vel) / ent->bound.sph.r; - ent->angVel = ((1.0f - ent->basset->stickiness) * ent->angVel) + (ent->basset->stickiness * div); + ent->angVel = + ((1.0f - ent->basset->stickiness) * ent->angVel) + (ent->basset->stickiness * div); } } @@ -617,7 +597,7 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) xMat3x3Mul((xMat3x3*)ent->model->Mat, (xMat3x3*)ent->model->Mat, &rotM); } - xMat3x3RMulVec(&newRotVec, (xMat3x3 *)(ent->model->Mat), &ent->localCenter); + xMat3x3RMulVec(&newRotVec, (xMat3x3*)(ent->model->Mat), &ent->localCenter); xVec3Sub((xVec3*)&ent->model->Mat->pos, &ent->bound.sph.center, &newRotVec); if ((ent->basset->soundID != 0) && (numDepens != 0) && (ent->lastRolling > 0.25f)) { @@ -635,19 +615,8 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) vol *= (ent->basset->volume * 0.77f); - xSndPlay3D - ( - ent->basset->soundID, - vol, - 0.0f, - 0, - 0, - (xVec3*)&ent->model->Mat->pos, - ent->basset->innerRadius, - ent->basset->outerRadius, - SND_CAT_GAME, - 0.0f - ); + xSndPlay3D(ent->basset->soundID, vol, 0.0f, 0, 0, (xVec3*)&ent->model->Mat->pos, + ent->basset->innerRadius, ent->basset->outerRadius, SND_CAT_GAME, 0.0f); } } @@ -655,18 +624,8 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt) { vol = 0.77f; - xSndPlay3D - ( - ent->rollingID, - vol, - 0.0f, - 0, - 0, - (xVec3 *)(&ent->model->Mat->pos), - 20.0f, - SND_CAT_GAME, - 0.0f - ); + xSndPlay3D(ent->rollingID, vol, 0.0f, 0, 0, (xVec3*)(&ent->model->Mat->pos), 20.0f, + SND_CAT_GAME, 0.0f); } if (numDepens != 0) @@ -706,9 +665,11 @@ S32 xEntBoulder_KilledBySurface(xEntBoulder* ent, xScene* sc, F32 dt) continue; } - if ((ent->basset->flags & 0x40) && (coll->optr != NULL) && (zGooIs((xEnt*)coll->optr, temp, 0))) + if ((ent->basset->flags & 0x40) && (coll->optr != NULL) && + (zGooIs((xEnt*)coll->optr, temp, 0))) { - xVec3AddScaled(&ent->vel, &coll->norm, -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm)); + xVec3AddScaled(&ent->vel, &coll->norm, + -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm)); zEntEvent(ent, eEventKill); return 1; } @@ -729,32 +690,36 @@ S32 xEntBoulder_KilledBySurface(xEntBoulder* ent, xScene* sc, F32 dt) { switch (prop->asset->game_damage_type) { - case 0: - break; - case 1: - case 2: - case 3: - case 4: - case 6: - ent->hitpoints--; - if (ent->hitpoints <= 0) - { - xVec3AddScaled(&ent->vel, &coll->norm, -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm)); - zEntEvent(ent, eEventKill); - return 1; - } - break; - case 5: - xVec3AddScaled(&ent->vel, &coll->norm, -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm)); - zEntEvent((xBase *)ent, eEventKill); + case 0: + break; + case 1: + case 2: + case 3: + case 4: + case 6: + ent->hitpoints--; + if (ent->hitpoints <= 0) + { + xVec3AddScaled(&ent->vel, &coll->norm, + -(ent->basset->bounce + 1.0f) * + xVec3Dot(&ent->vel, &coll->norm)); + zEntEvent(ent, eEventKill); return 1; + } + break; + case 5: + xVec3AddScaled(&ent->vel, &coll->norm, + -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm)); + zEntEvent((xBase*)ent, eEventKill); + return 1; } } if ((ent->basset->flags & 0x20) && (prop->asset->phys_flags & 0x10)) { - xVec3AddScaled(&ent->vel, &coll->norm, -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm)); - zEntEvent((xBase *)ent, eEventKill); + xVec3AddScaled(&ent->vel, &coll->norm, + -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm)); + zEntEvent((xBase*)ent, eEventKill); return 1; } } @@ -804,19 +769,25 @@ void xEntBoulder_BubbleBowl(F32 multiplier) } xVec3Copy((xVec3*)&ent->model->Mat->pos, (xVec3*)&globals.player.ent.model->Mat->pos); - xVec3AddScaled((xVec3*)&ent->model->Mat->pos, (xVec3*)&globals.player.ent.model->Mat->right, globals.player.g.BubbleBowlLaunchPosLeft); - xVec3AddScaled((xVec3*)&ent->model->Mat->pos, (xVec3*)&globals.player.ent.model->Mat->up, globals.player.g.BubbleBowlLaunchPosUp); - xVec3AddScaled((xVec3*)&ent->model->Mat->pos, (xVec3*)&globals.player.ent.model->Mat->at, globals.player.g.BubbleBowlLaunchPosAt); + xVec3AddScaled((xVec3*)&ent->model->Mat->pos, (xVec3*)&globals.player.ent.model->Mat->right, + globals.player.g.BubbleBowlLaunchPosLeft); + xVec3AddScaled((xVec3*)&ent->model->Mat->pos, (xVec3*)&globals.player.ent.model->Mat->up, + globals.player.g.BubbleBowlLaunchPosUp); + xVec3AddScaled((xVec3*)&ent->model->Mat->pos, (xVec3*)&globals.player.ent.model->Mat->at, + globals.player.g.BubbleBowlLaunchPosAt); xVec3Copy(&ent->bound.sph.center, (xVec3*)&ent->model->Mat->pos); xVec3Copy(&ent->frame->mat.pos, (xVec3*)&ent->model->Mat->pos); - xVec3SMul(&ent->vel, (xVec3 *)&globals.player.ent.model->Mat->right, globals.player.g.BubbleBowlLaunchVelLeft); - xVec3AddScaled(&ent->vel, (xVec3 *)&globals.player.ent.model->Mat->up, globals.player.g.BubbleBowlLaunchVelUp); - xVec3AddScaled(&ent->vel, (xVec3 *)&globals.player.ent.model->Mat->at, globals.player.g.BubbleBowlLaunchVelAt); + xVec3SMul(&ent->vel, (xVec3*)&globals.player.ent.model->Mat->right, + globals.player.g.BubbleBowlLaunchVelLeft); + xVec3AddScaled(&ent->vel, (xVec3*)&globals.player.ent.model->Mat->up, + globals.player.g.BubbleBowlLaunchVelUp); + xVec3AddScaled(&ent->vel, (xVec3*)&globals.player.ent.model->Mat->at, + globals.player.g.BubbleBowlLaunchVelAt); xVec3SMulBy(&ent->vel, multiplier); - xVec3Copy(&ent->rotVec, (xVec3 *)globals.player.ent.model->Mat); + xVec3Copy(&ent->rotVec, (xVec3*)globals.player.ent.model->Mat); ent->angVel = (multiplier * 10.0f); - xVec3Copy(&ray.origin, (xVec3 *)&globals.player.ent.bound.sph.center); - xVec3Sub(&ray.dir, (xVec3 *)&ent->model->Mat->pos, &ray.origin); + xVec3Copy(&ray.origin, (xVec3*)&globals.player.ent.bound.sph.center); + xVec3Sub(&ray.dir, (xVec3*)&ent->model->Mat->pos, &ray.origin); ray.max_t = xVec3Normalize(&ray.dir, &ray.dir); ray.min_t = 0.01f + globals.player.ent.bound.box.box.upper.x; ray.flags = 0xc00; @@ -825,13 +796,11 @@ void xEntBoulder_BubbleBowl(F32 multiplier) if (rayCollis.flags & 1) { optr = (xEnt*)(rayCollis.optr); - if - ((optr == NULL) || - ((((optr->baseType == eBaseTypeDestructObj) && (zEntDestructObj_GetHit((zEntDestructObj*)optr, 0x8000) == 0)) || - !(optr->moreFlags & 0x10) || (optr->baseType == eBaseTypeStatic)) - ) && - (optr->baseType != eBaseTypeNPC) - ) + if ((optr == NULL) || + ((((optr->baseType == eBaseTypeDestructObj) && + (zEntDestructObj_GetHit((zEntDestructObj*)optr, 0x8000) == 0)) || + !(optr->moreFlags & 0x10) || (optr->baseType == eBaseTypeStatic))) && + (optr->baseType != eBaseTypeNPC)) { if ((optr != NULL) && (optr->collLev == 5)) { @@ -885,10 +854,10 @@ void xEntBoulder_Reset(xEntBoulder* boul, xScene* sc) boul->flags |= 0x10; } - xVec3Init(&boul->force, 0.0f, 0.0f, 0.0f); + xVec3Init(&boul->force, 0.0f, 0.0f, 0.0f); xVec3Init(&boul->instForce, 0.0f, 0.0f, 0.0f); - xVec3Init(&boul->vel, 0.0f, 0.0f, 0.0f); - xVec3Init(&boul->rotVec, 1.0f, 0.0f, 0.0f); + xVec3Init(&boul->vel, 0.0f, 0.0f, 0.0f); + xVec3Init(&boul->rotVec, 1.0f, 0.0f, 0.0f); boul->angVel = 0.0f; @@ -902,7 +871,7 @@ void xEntBoulder_Reset(xEntBoulder* boul, xScene* sc) } boul->hitpoints = boul->basset->hitpoints; - xEntBoulder_RealBUpdate(boul, (xVec3 *)&boul->model->Mat->pos); + xEntBoulder_RealBUpdate(boul, (xVec3*)&boul->model->Mat->pos); if ((globals.sceneCur->sceneID == 'BC04') && (boul->id == xStrHash("BALL_BOULDER"))) { @@ -910,6 +879,177 @@ void xEntBoulder_Reset(xEntBoulder* boul, xScene* sc) } } +S32 xEntBoulderEventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, + xBase* toParamWidget) +{ + xEntBoulder* s = (xEntBoulder*)to; + + switch (toEvent) + { + case eEventVisible: + case eEventFastVisible: + xEntShow(s); + if (toParam && (S32)(0.5f + toParam[0]) == 77) + { + zFXPopOn(*s, toParam[1], toParam[2]); + } + break; + case eEventInvisible: + case eEventFastInvisible: + xEntHide(s); + if (toParam && (S32)(0.5f + toParam[0]) == 77) + { + zFXPopOff(*s, toParam[1], toParam[2]); + } + break; + case eEventCollisionOn: + s->chkby |= XENT_COLLTYPE_PLYR; + break; + case eEventCollisionOff: + s->chkby &= (U8)~XENT_COLLTYPE_PLYR; + break; + case eEventCollision_Visible_On: + s->chkby |= XENT_COLLTYPE_PLYR; + xEntShow(s); + if (toParam && (S32)(0.5f + toParam[0]) == 77) + { + zFXPopOn(*s, toParam[1], toParam[2]); + } + break; + case eEventCollision_Visible_Off: + s->chkby &= (U8)~XENT_COLLTYPE_PLYR; + xEntHide(s); + if (toParam && (S32)(0.5f + toParam[0]) == 77) + { + zFXPopOff(*s, toParam[1], toParam[2]); + } + break; + case eEventCameraCollideOn: + zCollGeom_CamEnable(s); + break; + case eEventCameraCollideOff: + zCollGeom_CamDisable(s); + break; + case eEventReset: + xEntBoulder_Reset(s, globals.sceneCur); + if (xEntIsVisible(s)) + { + s->update = (xEntUpdateCallback)xEntBoulder_Update; + } + break; + case eEventHit: + if (s->update) + { + s->hitpoints--; + if (s->hitpoints <= 0) + { + zEntEvent(s, eEventKill); + } + } + break; + case eEventKill: + xEntBoulder_Kill(s); + if (s == globals.player.bubblebowl) + { + zFX_SpawnBubbleHit(&s->bound.sph.center, xrand() % 64 + 36); + } + break; + case eEventSetUpdateDistance: + if (globals.updateMgr) + { + if (toParam[0] <= 0.0f) + { + xUpdateCull_SetCB(globals.updateMgr, s, xUpdateCull_AlwaysTrueCB, NULL); + } + else + { + FloatAndVoid dist; + dist.f = SQR(toParam[0]); + xUpdateCull_SetCB(globals.updateMgr, s, xUpdateCull_DistanceSquaredCB, dist.v); + } + } + break; + case eEventLaunchShrapnel: + if (toParamWidget) + { + zShrapnelAsset* shrap = (zShrapnelAsset*)toParamWidget; + if (shrap->initCB) + { + shrap->initCB(shrap, s->model, &s->vel, NULL); + } + } + break; + case eEventSetLightKit: + s->lightKit = (xLightKit*)toParamWidget; + break; + } + + return 1; +} + +static S32 RecurseLinks(xLinkAsset* link, S32 count, xEntBoulder** boulList) +{ + S32 i; + S32 numInList = 0; + + for (i = 0; i < count; i++) + { + xLinkAsset* currLink = &link[i]; + if (currLink->dstEvent == eEventConnectToChild) + { + xBase* mychild = zSceneFindObject(currLink->dstAssetID); + if (mychild) + { + RecurseChild(mychild, boulList, numInList); + } + } + } + + return numInList; +} + +static void RecurseChild(xBase* child, xEntBoulder** boulList, S32& currBoul) +{ + switch (child->baseType) + { + case eBaseTypeBoulder: + if (boulList) + { + boulList[currBoul] = (xEntBoulder*)child; + } + currBoul++; + break; + case eBaseTypeGroup: + { + S32 i, cnt; + xGroup* grp = (xGroup*)child; + + cnt = xGroupGetCount(grp); + for (i = 0; i < cnt; i++) + { + xBase* grpitem = xGroupGetItemPtr(grp, i); + if (grpitem) + { + if (grpitem->baseType == eBaseTypeBoulder) + { + if (boulList) + { + boulList[currBoul] = (xEntBoulder*)grpitem; + } + currBoul++; + } + else if (grpitem->baseType == eBaseTypeGroup) + { + RecurseChild(grpitem, boulList, currBoul); + } + } + } + + break; + } + } +} + void xBoulderGenerator_Init(xBase& data, xDynAsset& asset, unsigned long) { xBoulderGenerator_Init((xBoulderGenerator*)&data, (xBoulderGeneratorAsset*)&asset); @@ -943,12 +1083,14 @@ void xBoulderGenerator_Init(xBoulderGenerator* bg, xBoulderGeneratorAsset* asset else { bg->isMarker = 0; - bg->objectPtr = (void *)zSceneFindObject(asset->object); + bg->objectPtr = (void*)zSceneFindObject(asset->object); } bg->numBoulders = RecurseLinks(bg->link, bg->linkCount, 0); bg->nextBoulder = bg->numBoulders; - bg->boulderList = (xEntBoulder **)xMemAlloc(gActiveHeap, (bg->numBoulders * sizeof(xEntBoulder*)) + (bg->numBoulders * sizeof(xEntBoulder*)), 0); + bg->boulderList = (xEntBoulder**)xMemAlloc( + gActiveHeap, + (bg->numBoulders * sizeof(xEntBoulder*)) + (bg->numBoulders * sizeof(xEntBoulder*)), 0); bg->boulderAges = (S32*)(&bg->boulderList[bg->numBoulders]); RecurseLinks(bg->link, bg->linkCount, bg->boulderList); @@ -1018,12 +1160,14 @@ static S32 GetBoulderForGenerating(xBoulderGenerator* bg) } else if (bg->boulderList[oldestCulled]->isCulled) { - if (bg->boulderList[j]->isCulled && (bg->boulderAges[oldestCulled] < bg->boulderAges[j])) + if (bg->boulderList[j]->isCulled && + (bg->boulderAges[oldestCulled] < bg->boulderAges[j])) { oldestCulled = j; } } - else if (bg->boulderList[j]->isCulled || (bg->boulderAges[oldestCulled] < bg->boulderAges[j])) + else if (bg->boulderList[j]->isCulled || + (bg->boulderAges[oldestCulled] < bg->boulderAges[j])) { oldestCulled = j; } @@ -1067,13 +1211,14 @@ void xBoulderGenerator_Launch(xBoulderGenerator* bg, xVec3* pnt, F32 t) b->update = (xEntUpdateCallback)xEntBoulder_Update; if (bg->isMarker) { - xVec3Copy((xVec3 *)(&b->model->Mat->pos), &((xMarkerAsset *)(bg->objectPtr))->pos); + xVec3Copy((xVec3*)(&b->model->Mat->pos), &((xMarkerAsset*)(bg->objectPtr))->pos); } else { - xVec3Copy((xVec3 *)(&b->model->Mat->pos), (xVec3 *)(&((xEnt *)(bg->objectPtr))->model->Mat->pos)); + xVec3Copy((xVec3*)(&b->model->Mat->pos), + (xVec3*)(&((xEnt*)(bg->objectPtr))->model->Mat->pos)); } - xVec3AddTo((xVec3 *)(&b->model->Mat->pos), &bg->bgasset->offset); + xVec3AddTo((xVec3*)(&b->model->Mat->pos), &bg->bgasset->offset); xVec3Copy(&b->rotVec, &bg->bgasset->initaxis); b->angVel = bg->bgasset->angvel; } @@ -1087,125 +1232,78 @@ void xBoulderGenerator_Launch(xBoulderGenerator* bg, xVec3* pnt, F32 t) void xBoulderGenerator_GenBoulder(xBoulderGenerator*); -S32 xBoulderGenerator_EventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, xBase* toParamWidget) +S32 xBoulderGenerator_EventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, + xBase* toParamWidget) { xVec3 pnt; switch (toEvent) { - case eEventGenerateBoulder: - xBoulderGenerator_GenBoulder((xBoulderGenerator*)to); - break; - case eEventLaunchBoulderAtWidget: - switch(toParamWidget->baseType) - { - case eBaseTypeVillain: - case eBaseTypePlayer: - case eBaseTypePickup: - case eBaseTypePlatform: - case eBaseTypeDoor: - case eBaseTypeStatic: - case eBaseTypeDynamic: - case eBaseTypePendulum: - case eBaseTypeHangable: - case eBaseTypeButton: - case eBaseTypeDestructObj: - case eBaseTypeNPC: - case eBaseTypeBoulder: - { - xVec3Copy(&pnt, (xVec3 *)xEntGetPos((xEnt*)toParamWidget)); - - F32 f0 = 0.0f; - F32 f1 = toParam[1]; - F32 f2; - F32 f3; + case eEventGenerateBoulder: + xBoulderGenerator_GenBoulder((xBoulderGenerator*)to); + break; + case eEventLaunchBoulderAtWidget: + switch (toParamWidget->baseType) + { + case eBaseTypeVillain: + case eBaseTypePlayer: + case eBaseTypePickup: + case eBaseTypePlatform: + case eBaseTypeDoor: + case eBaseTypeStatic: + case eBaseTypeDynamic: + case eBaseTypePendulum: + case eBaseTypeHangable: + case eBaseTypeButton: + case eBaseTypeDestructObj: + case eBaseTypeNPC: + case eBaseTypeBoulder: + { + xVec3Copy(&pnt, (xVec3*)xEntGetPos((xEnt*)toParamWidget)); - if (f1 != f0) - { - f1 = xurand(); - f0 = 0.5f; - f2 = 2.0f; - f3 = f1 - f0; - f1 = toParam[1]; - f0 = pnt.x; - f2 *= f3; - pnt.x = (f1 * f2) + f0; - - f1 = xurand(); - f0 = 0.5f; - f2 = 2.0f; - f3 = f1 - f0; - f1 = toParam[1]; - f2 *= f3; - pnt.y = (f1 * f2) + pnt.y; - - f1 = xurand(); - f0 = 0.5f; - f2 = 2.0f; - f3 = f1 - f0; - f1 = toParam[1]; - f0 = pnt.z; - f2 *= f3; - pnt.z = (f1 * f2) + f0; - } + F32 f0 = 0.0f; + F32 f1 = toParam[1]; + F32 f2; + F32 f3; - xBoulderGenerator_Launch((xBoulderGenerator*)to, &pnt, *toParam); - break; - } - case eBaseTypeMovePoint: - { - xVec3Copy(&pnt, (xVec3 *)zMovePointGetPos((zMovePoint*)toParamWidget)); + if (f1 != f0) + { + f1 = xurand(); + f0 = 0.5f; + f2 = 2.0f; + f3 = f1 - f0; + f1 = toParam[1]; + f0 = pnt.x; + f2 *= f3; + pnt.x = (f1 * f2) + f0; - F32 f0 = 0.0f; - F32 f1 = toParam[1]; - F32 f2; - F32 f3; + f1 = xurand(); + f0 = 0.5f; + f2 = 2.0f; + f3 = f1 - f0; + f1 = toParam[1]; + f2 *= f3; + pnt.y = (f1 * f2) + pnt.y; - if (f1 != f0) - { - f1 = xurand(); - f2 = 2.0f; - f3 = f1 - 0.5f; - f1 = toParam[1]; - f0 = pnt.x; - f2 *= f3; - pnt.x = (f1 * f2) + f0; - - f1 = xurand(); - f0 = 0.5f; - f2 = 2.0f; - f3 = f1 - f0; - f1 = toParam[1]; - f2 *= f3; - pnt.y = (f1 * f2) + pnt.y; - - f1 = xurand(); - f0 = 0.5f; - f2 = 2.0f; - f3 = f1 - f0; - f1 = toParam[1]; - f0 = pnt.z; - f2 *= f3; - pnt.z = (f1 * f2) + f0; - } - xBoulderGenerator_Launch((xBoulderGenerator*)to, &pnt, *toParam); - break; - } + f1 = xurand(); + f0 = 0.5f; + f2 = 2.0f; + f3 = f1 - f0; + f1 = toParam[1]; + f0 = pnt.z; + f2 *= f3; + pnt.z = (f1 * f2) + f0; } + + xBoulderGenerator_Launch((xBoulderGenerator*)to, &pnt, *toParam); break; - case eEventLaunchBoulderAtPoint: - pnt.x = toParam[0]; - pnt.y = toParam[1]; - pnt.z = toParam[2]; - xBoulderGenerator_Launch((xBoulderGenerator*)to, &pnt, toParam[3]); - break; - case eEventLaunchBoulderAtPlayer: + } + case eBaseTypeMovePoint: { - xVec3Copy(&pnt, (xVec3 *)&(globals.player.ent.model)->Mat->pos); - xVec3AddScaled(&pnt, &globals.player.ent.frame->dpos, ((*toParam * toParam[1]) / globals.update_dt)); + xVec3Copy(&pnt, (xVec3*)zMovePointGetPos((zMovePoint*)toParamWidget)); F32 f0 = 0.0f; - F32 f1 = toParam[2]; + F32 f1 = toParam[1]; F32 f2; F32 f3; @@ -1214,30 +1312,186 @@ S32 xBoulderGenerator_EventCB(xBase* from, xBase* to, U32 toEvent, const F32* to f1 = xurand(); f2 = 2.0f; f3 = f1 - 0.5f; - f1 = toParam[2]; + f1 = toParam[1]; + f0 = pnt.x; f2 *= f3; - pnt.x = (f1 * f2) + pnt.x; + pnt.x = (f1 * f2) + f0; f1 = xurand(); + f0 = 0.5f; f2 = 2.0f; - f3 = f1 - 0.5f; + f3 = f1 - f0; + f1 = toParam[1]; f2 *= f3; - pnt.y = (toParam[2] * f2) + pnt.y; + pnt.y = (f1 * f2) + pnt.y; f1 = xurand(); + f0 = 0.5f; f2 = 2.0f; - f3 = f1 - 0.5f; - f1 = toParam[2]; + f3 = f1 - f0; + f1 = toParam[1]; + f0 = pnt.z; f2 *= f3; - pnt.z += (f1 * f2); + pnt.z = (f1 * f2) + f0; } - xBoulderGenerator_Launch((xBoulderGenerator*)to, &pnt, *toParam); break; } - case eEventReset: - xBoulderGenerator_Reset((xBoulderGenerator*)to); - break; + } + break; + case eEventLaunchBoulderAtPoint: + pnt.x = toParam[0]; + pnt.y = toParam[1]; + pnt.z = toParam[2]; + xBoulderGenerator_Launch((xBoulderGenerator*)to, &pnt, toParam[3]); + break; + case eEventLaunchBoulderAtPlayer: + { + xVec3Copy(&pnt, (xVec3*)&(globals.player.ent.model)->Mat->pos); + xVec3AddScaled(&pnt, &globals.player.ent.frame->dpos, + ((*toParam * toParam[1]) / globals.update_dt)); + + F32 f0 = 0.0f; + F32 f1 = toParam[2]; + F32 f2; + F32 f3; + + if (f1 != f0) + { + f1 = xurand(); + f2 = 2.0f; + f3 = f1 - 0.5f; + f1 = toParam[2]; + f2 *= f3; + pnt.x = (f1 * f2) + pnt.x; + + f1 = xurand(); + f2 = 2.0f; + f3 = f1 - 0.5f; + f2 *= f3; + pnt.y = (toParam[2] * f2) + pnt.y; + + f1 = xurand(); + f2 = 2.0f; + f3 = f1 - 0.5f; + f1 = toParam[2]; + f2 *= f3; + pnt.z += (f1 * f2); + } + + xBoulderGenerator_Launch((xBoulderGenerator*)to, &pnt, *toParam); + break; + } + case eEventReset: + xBoulderGenerator_Reset((xBoulderGenerator*)to); + break; } return 1; -} \ No newline at end of file +} + +void xBoulderGenerator_GenBoulder(xBoulderGenerator* bg) +{ + S32 i = GetBoulderForGenerating(bg); + xEntBoulder* b = bg->boulderList[i]; + + if (bg->objectPtr == globals.player.bubblebowl) + { + xEntBoulder_Reset(b, globals.sceneCur); + zEntEvent(b, eEventBorn); + + b->update = (xEntUpdateCallback)xEntBoulder_Update; + + xEntBoulder* bb = globals.player.bubblebowl; + + xVec3Copy((xVec3*)&b->model->Mat->pos, (xVec3*)&bb->model->Mat->pos); + xVec3Copy(&b->rotVec, &bb->rotVec); + b->angVel = bb->angVel; + xVec3Copy(&b->vel, &bb->vel); + + xEntBoulder_Kill(bb); + } + else + { + if (b != bg->objectPtr || !xEntIsVisible(b)) + { + xEntBoulder_Reset(b, globals.sceneCur); + zEntEvent(b, eEventBorn); + + b->update = (xEntUpdateCallback)xEntBoulder_Update; + + if (bg->isMarker) + { + xVec3Copy((xVec3*)&b->model->Mat->pos, &((xMarkerAsset*)bg->objectPtr)->pos); + } + else + { + xVec3Copy((xVec3*)&b->model->Mat->pos, + (xVec3*)&((xEnt*)bg->objectPtr)->model->Mat->pos); + } + + xVec3AddTo((xVec3*)&b->model->Mat->pos, &bg->bgasset->offset); + + if (bg->bgasset->offsetRand) + { + b->model->Mat->pos.x += 2.0f * (xurand() - 0.5f) * bg->bgasset->offsetRand; + b->model->Mat->pos.y += 2.0f * (xurand() - 0.5f) * bg->bgasset->offsetRand; + b->model->Mat->pos.z += 2.0f * (xurand() - 0.5f) * bg->bgasset->offsetRand; + } + + xVec3Copy(&b->rotVec, &bg->bgasset->initaxis); + + b->angVel = bg->bgasset->angvel; + } + + if (bg->lengthOfInitVel > 0.00001f && bg->bgasset->velAngleRand > 0.00001f) + { + F32 p1c = xurand() - 0.5f; + F32 p2c = xurand() - 0.5f; + F32 nf = 1.0f / xsqrt(SQR(p1c) + SQR(p2c)); + if (nf < 0.00001f) + { + p1c = 1.0f; + p2c = 0.0f; + } + else + { + p1c *= nf; + p2c *= nf; + } + + xVec3 perpRand; + xVec3SMul(&perpRand, &bg->perp1, p1c); + xVec3AddScaled(&perpRand, &bg->perp2, p2c); + + F32 randAng = bg->bgasset->velAngleRand * (xurand() - 0.5f); + randAng = DEG2RAD(randAng); + + p1c = icos(randAng); + p2c = isin(randAng); + + xVec3SMul(&b->vel, &bg->bgasset->initvel, p1c); + xVec3AddScaled(&b->vel, &perpRand, p2c); + } + else + { + xVec3Copy(&b->vel, &bg->bgasset->initvel); + } + + if (bg->bgasset->velMagRand > 0.00001f) + { + if (bg->lengthOfInitVel > 0.00001f) + { + F32 sclMag = bg->bgasset->velMagRand * xurand() + 1.0f; + xVec3SMulBy(&b->vel, sclMag); + } + else + { + b->vel.x = 2.0f * (xurand() - 0.5f) * bg->bgasset->velMagRand; + b->vel.y = 2.0f * (xurand() - 0.5f) * bg->bgasset->velMagRand; + b->vel.z = 2.0f * (xurand() - 0.5f) * bg->bgasset->velMagRand; + } + } + } + + BoulderGen_GiveBirth(bg, i); +} diff --git a/src/SB/Core/x/xEntMotion.cpp b/src/SB/Core/x/xEntMotion.cpp index 1a2ddecf3..ecd0cbe31 100644 --- a/src/SB/Core/x/xEntMotion.cpp +++ b/src/SB/Core/x/xEntMotion.cpp @@ -1242,7 +1242,6 @@ static void xEntMotionDebugWrite(const xEntMotion* xem) } static void xEntMotionDebugDraw(const xEntMotion* xem) -//NONMATCH("https://decomp.me/scratch/j2sCX") { if (xem->owner && xem->target) { diff --git a/src/SB/Core/x/xGrid.cpp b/src/SB/Core/x/xGrid.cpp index 9ff56f898..b83196b29 100644 --- a/src/SB/Core/x/xGrid.cpp +++ b/src/SB/Core/x/xGrid.cpp @@ -125,7 +125,6 @@ void xGridAdd(xGrid* grid, xGridBound* bound, S32 x, S32 z) } S32 xGridAdd(xGrid* grid, xEnt* ent) -//NONMATCH("https://decomp.me/scratch/5R7FZ") { xBound* bound; xVec3* center; diff --git a/src/SB/Core/x/xGrid.h b/src/SB/Core/x/xGrid.h index 0f0c543f9..ae8da34e0 100644 --- a/src/SB/Core/x/xGrid.h +++ b/src/SB/Core/x/xGrid.h @@ -185,8 +185,6 @@ struct grid_index }; inline grid_index get_grid_index(const xGrid& grid, F32 x, F32 z) - -//NONMATCH("https://decomp.me/scratch/pMa66") { grid_index index = { range_limit((U16)((x - grid.minx) * grid.inv_csizex), 0, grid.nx - 1), range_limit((U16)((z - grid.minz) * grid.inv_csizez), 0, diff --git a/src/SB/Core/x/xScene.cpp b/src/SB/Core/x/xScene.cpp index 785551bec..206f9c85c 100644 --- a/src/SB/Core/x/xScene.cpp +++ b/src/SB/Core/x/xScene.cpp @@ -179,7 +179,6 @@ void xSceneForAllNPCs(xScene* sc, xSceneEntCallback func, void* data) void xRayHitsGrid(xGrid* grid, xScene* sc, xRay3* r, xRayEntCallback rentcb, xQCData* qcr, void* data) -//NONMATCH("https://decomp.me/scratch/2kH6a") { xLine3 ln; xGridIterator it; @@ -658,7 +657,6 @@ cb_ray_hits_ent::cb_ray_hits_ent(const xRay3& ray, xCollis& coll, U8 chkby, U8 c } void xRayHitsSceneFlags(xScene* sc, xRay3* r, xCollis* coll, U8 collType, U8 chk) -//NONMATCH("https://decomp.me/scratch/ZJEEb") { coll->dist = HUGE; coll->flags = (coll->flags & ~k_HIT_IT) | k_HIT_0x100; @@ -745,7 +743,6 @@ void ProjectBox(xVec3* param_1, xBox* param_2, float* param_3, float* param_4) } static U32 Mgc_TriBoxTest(xVec3* apkTri, xBox* rkBox) -// NONMATCH("https://decomp.me/scratch/xYaVl") { F32 fMin0, fMax0, fMin1, fMax1; xVec3 kD, akE[3], baxis; @@ -840,7 +837,6 @@ static U32 Mgc_TriBoxTest(xVec3* apkTri, xBox* rkBox) static RpCollisionTriangle* nearestFloorCB(RpIntersection*, RpCollisionTriangle* collTriangle, RwReal, void* data) -//NONMATCH("https://decomp.me/scratch/0VY4M") { xNearFloorPoly* nfpoly = (xNearFloorPoly*)data; F32 currnear = nfpoly->neardist; @@ -1064,7 +1060,6 @@ static S32 gridNearestFloorCB(xEnt* ent, void* cbdata) } U32 xSceneNearestFloorPoly(xScene* sc, xNearFloorPoly* nfpoly, U8 collType, U8 chk) -//NONMATCH("https://decomp.me/scratch/yCzQV") { sNearestBound.type = XBOUND_TYPE_BOX; sNearestBound.box.box = nfpoly->box; diff --git a/src/SB/Core/x/xserializer.cpp b/src/SB/Core/x/xserializer.cpp index caa12a767..3fbe8d8d6 100644 --- a/src/SB/Core/x/xserializer.cpp +++ b/src/SB/Core/x/xserializer.cpp @@ -323,7 +323,6 @@ static void xSER_init_tables() } static void xSER_init_buffers(S32 count, st_SERIAL_PERCID_SIZE* sizeinfo) -//NONMATCH("https://decomp.me/scratch/uex0C") { st_XSERIAL_DATA_PRIV* xsd = &g_xserdata; S32 i = 0; diff --git a/src/SB/Game/zNPCSupport.cpp b/src/SB/Game/zNPCSupport.cpp index 5d4cc5c14..c40601158 100644 --- a/src/SB/Game/zNPCSupport.cpp +++ b/src/SB/Game/zNPCSupport.cpp @@ -253,7 +253,6 @@ void NPCTarget::TargetClear() } S32 NPCTarget::FindNearest(S32 flg_consider, xBase* skipme, xVec3* from, F32 dst_max) -//NONMATCH("https://decomp.me/scratch/wWBRW") { S32 found = 0; st_XORDEREDARRAY* npclist; @@ -378,7 +377,6 @@ S32 NPCTarget::IsDead() } // void NPCLaser::Render(xVec3* pos_src, xVec3* pos_tgt) -// //NONMATCH("https://decomp.me/scratch/lNgTd") // { // xVec3 var_70; // xVec3Copy(&var_70, pos_src); @@ -494,7 +492,6 @@ S32 NPCTarget::IsDead() // } // void NPCCone::RenderCone(xVec3* pos_tiptop, xVec3* pos_botcenter) -// //NONMATCH("https://decomp.me/scratch/G9pbs") // { // RwRGBA rgba_top = this->rgba_top; // RwRGBA rgba_bot = this->rgba_bot; @@ -645,7 +642,7 @@ void Firework::Update(F32 dt) this->tmr_remain = MAX(-1.0f, this->tmr_remain - dt); } -void Firework::FlyFlyFly(F32 dt) //NONMATCH("https://decomp.me/scratch/6hPC3") +void Firework::FlyFlyFly(F32 dt) { F32 pam_life = 1.0f - CLAMP(this->tmr_remain / this->tym_lifespan, 0.0f, 1.0f); if (pam_life < 0.75f) @@ -684,7 +681,7 @@ void NPCC_aimMiss(xVec3* dir_aim, xVec3* pos_src, xVec3* pos_tgt, F32 dst_miss, } F32 NPCC_aimVary(xVec3* dir_aim, xVec3* pos_src, xVec3* pos_tgt, F32 dst_vary, S32 flg_vary, - xVec3* pos_aimPoint) //NONMATCH("https://decomp.me/scratch/D1gIj") + xVec3* pos_aimPoint) { F32 dst_toFake = 0.0f; xVec3 dir_left = {}; @@ -769,8 +766,7 @@ F32 NPCC_aimVary(xVec3* dir_aim, xVec3* pos_src, xVec3* pos_tgt, F32 dst_vary, S return (flg_vary & 0x4) ? f31 : mag_vary; } -S32 NPCC_chk_hitEnt(xEnt* tgt, xBound* bnd, - xCollis* collide) //NONMATCH("https://decomp.me/scratch/Bf1rk") +S32 NPCC_chk_hitEnt(xEnt* tgt, xBound* bnd, xCollis* collide) { S32 hittgt = 0; xCollis* colrec; @@ -881,8 +877,7 @@ RwRaster* NPCC_FindRWRaster(RwTexture* txtr) return NULL; } -void NPCC_GenSmooth(xVec3** pos_base, - xVec3** pos_mid) //WIP NONMATCH("https://decomp.me/scratch/1MplX") +void NPCC_GenSmooth(xVec3** pos_base, xVec3** pos_mid) { static F32 prepute[4][4]; static const F32 yews[4] = { 0.25f, 0.5f, 0.75f, 1.0f }; @@ -916,7 +911,7 @@ void NPCC_GenSmooth(xVec3** pos_base, } } -void zNPC_SNDInit() //NONMATCH("https://decomp.me/scratch/VlDh8") +void zNPC_SNDInit() { sNPCSndID[eNPCSnd_GloveAttack] = 0; sNPCSndID[eNPCSnd_SleepyAttack] = 0; @@ -1111,7 +1106,6 @@ void NPCC_xBoundBack(xBound* bnd) void NPCC_DstSq(const xVec3*, const xVec3*, xVec3*); S32 NPCC_HaveLOSToPos(xVec3* pos_src, xVec3* pos_tgt, F32 dst_max, xBase* tgt, xCollis* colCallers) -//NONMATCH("https://decomp.me/scratch/LyDtk") { S32 result; xRay3 ray = {}; diff --git a/src/SB/Game/zNPCTypeCommon.cpp b/src/SB/Game/zNPCTypeCommon.cpp index 39cabea94..0a8d65148 100644 --- a/src/SB/Game/zNPCTypeCommon.cpp +++ b/src/SB/Game/zNPCTypeCommon.cpp @@ -232,7 +232,7 @@ void zNPCCommon::Init(xEntAsset* entass) this->InitBounds(); } -void zNPCCommon::InitBounds() //NONMATCH("https://decomp.me/scratch/JPhdS") +void zNPCCommon::InitBounds() { NPCConfig* cfg = this->cfg_npc; xVec3 half = {}; @@ -422,7 +422,7 @@ void zNPCCommon::Setup() } } -void zNPCCommon::Reset() //NONMATCH("https://decomp.me/scratch/cl84A") +void zNPCCommon::Reset() { xSceneID2Name(globals.sceneCur, this->id); @@ -748,7 +748,7 @@ S32 zNPCCommon::NPCMessage(NPCMsg* mail) void zNPCCommon::Move(xScene* xscn, F32 dt, xEntFrame* frm) { bool retval = false; - if ((npcset.useNavSplines) && ((flg_move) & 8)) + if ((npcset.useNavSplines) && ((flg_move)&8)) if (this->drv_data && (this->drv_data->driver || this->drv_data->odriver)) { retval = true; @@ -783,7 +783,7 @@ void zNPCCommon::Process(xScene* xscn, F32 dt) xNPCBasic::Process(xscn, dt); } -void zNPCCommon::BUpdate(xVec3* pos) //NONMATCH("https://decomp.me/scratch/zpv2r") +void zNPCCommon::BUpdate(xVec3* pos) { NPCConfig* cfg = this->cfg_npc; @@ -816,7 +816,7 @@ void zNPCCommon::BUpdate(xVec3* pos) //NONMATCH("https://decomp.me/scratch/zpv2r zGridUpdateEnt(this); } -F32 zNPCCommon::BoundAsRadius(S32 useCfg) const //NONMATCH("https://decomp.me/scratch/rCFqE") +F32 zNPCCommon::BoundAsRadius(S32 useCfg) const { F32 rad = 1.0f; @@ -1329,7 +1329,7 @@ void zNPCCommon::ConvertHitEvent(xBase* from, xBase* to, U32 toEvent, const F32* this->Damage(what, from, vec_hit); } -void zNPCCommon::VelStop() //NONMATCH("https://decomp.me/scratch/YizcX") +void zNPCCommon::VelStop() { this->spd_throttle = 0.0f; this->frame->dvel.x = 0.0f; @@ -1434,7 +1434,6 @@ F32 zNPCCommon::ThrottleApply(F32 dt, const xVec3* dir, S32 force3D) } F32 zNPCCommon::TurnToFace(F32 dt, const xVec3* dir_want, F32 useTurnRate) -//NONMATCH("https://decomp.me/scratch/KRonE") { F32 f29 = (useTurnRate < 0.0f) ? (dt * this->cfg_npc->spd_turnMax) : (dt * useTurnRate); F32 f30 = NPCC_dir_toXZAng(dir_want); @@ -1951,7 +1950,7 @@ void zNPCCommon::PlayerKiltMe() } } -void zNPCCommon::ISeePlayer() //NONMATCH("https://decomp.me/scratch/M08oY") +void zNPCCommon::ISeePlayer() { en_xEventTags ven = eEventUnknown; @@ -2153,7 +2152,7 @@ void zNPCCommon::GetParm(en_npcparm pid, zMovePoint** val) this->GetParm(pid, (void*)val); } -void zNPCCommon::GetParm(en_npcparm pid, void* val) //NONMATCH("https://decomp.me/scratch/dg7eV") +void zNPCCommon::GetParm(en_npcparm pid, void* val) { char** names = g_strz_params; xModelAssetParam* pmdata = this->parmdata; @@ -2266,7 +2265,6 @@ void zNPCCommon::GetParm(en_npcparm pid, void* val) //NONMATCH("https://decomp.m } void zNPCCommon::GetParmDefault(en_npcparm pid, void* val) -//NONMATCH("https://decomp.me/scratch/mNHLS") { // Should be a S32? S32 result = 1; @@ -2429,7 +2427,7 @@ void zNPCCommon_WonderReset() U32 zNPCCommon::CanDoSplines() { bool retval = false; - if ((npcset.useNavSplines) && ((flg_move) & 8)) + if ((npcset.useNavSplines) && ((flg_move)&8)) { retval = true; } @@ -2443,7 +2441,7 @@ zMovePoint* zNPCCommon::FirstAssigned() return nav_first; } -void zNPCCommon::MvptReset(zMovePoint* nav_goto) //NONMATCH("https://decomp.me/scratch/lhUW9") +void zNPCCommon::MvptReset(zMovePoint* nav_goto) { if (nav_goto) { @@ -2462,7 +2460,7 @@ void zNPCCommon::MvptReset(zMovePoint* nav_goto) //NONMATCH("https://decomp.me/s this->dst_curspline = 0.0f; } -S32 zNPCCommon::MvptCycle() //NONMATCH("https://decomp.me/scratch/CGooj") +S32 zNPCCommon::MvptCycle() { zMovePoint* nav_tmp = NULL; @@ -2517,7 +2515,6 @@ S32 zNPCCommon::MvptCycle() //NONMATCH("https://decomp.me/scratch/CGooj") } S32 zNPCCommon::HaveLOSToPos(xVec3* pos, F32 dist, xScene* xscn, xBase* tgt, xCollis* colCallers) -//NONMATCH("https://decomp.me/scratch/wxm2S") { S32 result; xRay3 ray = {}; @@ -2762,7 +2759,7 @@ zNPCSettings* zNPCSettings_Find(U32 id) return set; } -void zNPCCommon::Vibrate(F32 ds2_cur, F32 ds2_max) //NONMATCH("https://decomp.me/scratch/A5HIP") +void zNPCCommon::Vibrate(F32 ds2_cur, F32 ds2_max) { F32 rat = ds2_cur / MAX(ds2_max, 1.0f); @@ -2857,7 +2854,7 @@ F32 zNPCCommon::AnimTimeCurrent() return model->Anim->Single->Time; } -void zNPCSettings_MakeDummy() //NONMATCH("https://decomp.me/scratch/amPtL") +void zNPCSettings_MakeDummy() { static zNPCSettings dum; dum.id = 0xFEEDCAFE;