MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / SkinNormals

Function SkinNormals

src/SB/Core/gc/iModel.cpp:533–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531}
532
533static inline void SkinXform(xVec3* dest, const xVec3* vert, RwMatrix* mat, const RwMatrix* skinmat,
534 const F32* wt, const U32* idx, U32 count)
535{
536 U32 catMatFlags[2] = { 0, 0 };
537 RwMatrix* catmat = (RwMatrix*)giAnimScratch;
538 RwMatrix* rootmat = mat;
539 mat++;
540
541 while (count != 0)
542 {
543 for (U32 i = 0; i < 4; i++)
544 {
545 U32 r18 = ((*idx >> (i << 3)) >> 5) & 0x7;
546 U32 r29 = 1 << ((*idx >> (i << 3)) & 0x1F);
547 U32 midx = (*idx >> (i << 3)) & 0xFF;
548 if (!(r29 & catMatFlags[r18]))
549 {
550 xMat4x3Mul((xMat4x3*)(catmat + midx), (const xMat4x3*)(skinmat + midx),
551 (const xMat4x3*)(mat + midx));
552 catMatFlags[r18] |= r29;
553 }
554 }
555
556 xVec3 accumV;
557 accumV.x = accumV.y = accumV.z = 0.0f;
558
559 RwMatrix* pMatrix;
560 const F32* fwt = wt;
561 U32 wtidx = *idx;
562 U32 maxwt = 4;
563
564 while (*fwt != 0.0f && maxwt)
565 {
566 pMatrix = catmat + (wtidx & 0xFF);
567
568 accumV.x += *fwt * (pMatrix->right.x * vert->x + pMatrix->up.x * vert->y +
569 pMatrix->at.x * vert->z + pMatrix->pos.x);
570 accumV.y += *fwt * (pMatrix->right.y * vert->x + pMatrix->up.y * vert->y +
571 pMatrix->at.y * vert->z + pMatrix->pos.y);
572 accumV.z += *fwt * (pMatrix->right.z * vert->x + pMatrix->up.z * vert->y +
573 pMatrix->at.z * vert->z + pMatrix->pos.z);
574
575 fwt++;
576 wtidx >>= 8;
577 maxwt--;
578 }
579
580 dest->x = rootmat->right.x * accumV.x + rootmat->up.x * accumV.y +
581 rootmat->at.x * accumV.z + rootmat->pos.x;
582 dest->y = rootmat->right.y * accumV.x + rootmat->up.y * accumV.y +
583 rootmat->at.y * accumV.z + rootmat->pos.y;
584 dest->z = rootmat->right.z * accumV.x + rootmat->up.z * accumV.y +
585 rootmat->at.z * accumV.z + rootmat->pos.z;
586
587 vert++;
588 idx++;
589 wt += 4;
590 count--;

Callers 1

iModelTagEvalFunction · 0.85

Calls 2

xMat3x3NormalizeFunction · 0.85
xMat3x3MulFunction · 0.50

Tested by

no test coverage detected