Skip to content

Commit c2855c4

Browse files
committed
CParticleSwoosh matches
1 parent 4f23fbf commit c2855c4

1 file changed

Lines changed: 64 additions & 37 deletions

File tree

‎src/Kyoto/Particles/CParticleSwoosh.cpp‎

Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,14 @@ void CParticleSwoosh::Render2SidedNoSplineNoGaps() {
429429
int curIdx = x158_curParticle;
430430
float uvOffset = 0.f;
431431
if (x1c_desc->x3c_TEXR) {
432+
float angle = 0.f;
433+
float cosine = 0.f;
434+
float sine = 0.f;
435+
float leftCos = 0.f;
436+
float leftRadius = 0.f;
437+
float leftSin = 0.f;
438+
float rightRadius = 0.f;
439+
float rightSin = 0.f;
432440
if (x1c_desc->x45_25_ORNT) {
433441
const CTransform4f inverse =
434442
(CTransform4f::Translate(xa4_globalTranslation) * xb0_globalOrientation * xec_scaleXf)
@@ -497,15 +505,17 @@ void CParticleSwoosh::Render2SidedNoSplineNoGaps() {
497505
}
498506
if (swoosh.mActive) {
499507
--particleCount;
500-
float angle = M_PIF * (swoosh.mInitialRot + swoosh.mRotm) / 180.f;
508+
angle = M_PIF * (swoosh.mInitialRot + swoosh.mRotm) / 180.f;
501509
angle = fabs(angle) > M_PIF ? CMath::WrapPi(angle) : angle;
502-
float cosine = fast_cosine(angle);
503-
float sine = fast_sine(angle);
504-
float leftRadius = swoosh.mLeftRad;
505-
float rightRadius = swoosh.mRightRad;
506-
float leftSin = leftRadius;
510+
cosine = fast_cosine(angle);
511+
sine = fast_sine(angle);
512+
leftRadius = swoosh.mLeftRad;
513+
rightRadius = swoosh.mRightRad;
514+
leftSin = leftRadius;
507515
leftSin *= sine;
508-
float rightSin = rightRadius;
516+
leftCos = leftRadius;
517+
leftCos *= cosine;
518+
rightSin = rightRadius;
509519
rightSin *= -sine;
510520
const CVector3f v0 = swoosh.mOrientation * CVector3f(leftRadius * cosine, 0.f, leftSin) +
511521
swoosh.mTranslation + swoosh.mUseOffset;
@@ -537,22 +547,32 @@ void CParticleSwoosh::Render2SidedNoSplineNoGaps() {
537547
}
538548
}
539549
} else {
550+
float angle = 0.f;
551+
float cosine = 0.f;
552+
float sine = 0.f;
553+
float leftCos = 0.f;
554+
float leftSin = 0.f;
555+
float leftRadius = 0.f;
556+
float rightSin = 0.f;
557+
float rightRadius = 0.f;
540558
for (int i = 0; i < x15c_swooshes.size(); ++i) {
541559
const SSwooshData& swoosh = x15c_swooshes.data()[curIdx];
542560
--curIdx;
543561
if (curIdx < 0) {
544562
curIdx = x15c_swooshes.size() - 1;
545563
}
546564
if (swoosh.mActive) {
547-
float angle = M_PIF * (swoosh.mInitialRot + swoosh.mRotm) / 180.f;
565+
angle = M_PIF * (swoosh.mInitialRot + swoosh.mRotm) / 180.f;
548566
angle = fabs(angle) > M_PIF ? CMath::WrapPi(angle) : angle;
549-
float cosine = fast_cosine(angle);
550-
float sine = fast_sine(angle);
551-
float leftRadius = swoosh.mLeftRad;
552-
float rightRadius = swoosh.mRightRad;
553-
float leftSin = leftRadius;
567+
cosine = fast_cosine(angle);
568+
sine = fast_sine(angle);
569+
leftRadius = swoosh.mLeftRad;
570+
rightRadius = swoosh.mRightRad;
571+
leftSin = leftRadius;
554572
leftSin *= sine;
555-
float rightSin = rightRadius;
573+
leftCos = leftRadius;
574+
leftCos *= cosine;
575+
rightSin = rightRadius;
556576
rightSin *= -sine;
557577
const CVector3f v0 = swoosh.mOrientation * CVector3f(leftRadius * cosine, 0.f, leftSin) +
558578
swoosh.mTranslation + swoosh.mUseOffset;
@@ -571,6 +591,14 @@ void CParticleSwoosh::Render2SidedNoSplineGaps() {
571591
int i = 0;
572592
bool streaming = false;
573593
int curIdx = x158_curParticle;
594+
float angle;
595+
float cosine;
596+
float sine;
597+
float leftCos;
598+
float leftSin;
599+
float leftRadius;
600+
float rightSin;
601+
float rightRadius;
574602
for (i = 0; i < x15c_swooshes.size(); ++i) {
575603
const SSwooshData& swoosh = x15c_swooshes[curIdx];
576604
const SSwooshData& next = x15c_swooshes[WrapIndex(curIdx - 1)];
@@ -592,17 +620,17 @@ void CParticleSwoosh::Render2SidedNoSplineGaps() {
592620
streaming = true;
593621
CGraphics::StreamBegin(kP_TriangleStrip);
594622
}
595-
float angle = (swoosh.mInitialRot + swoosh.mRotm) * (M_PIF / 180.f);
623+
angle = (swoosh.mInitialRot + swoosh.mRotm) * (M_PIF / 180.f);
596624
angle = fabs(angle) > M_PIF ? CMath::WrapPi(angle) : angle;
597-
float cosine = fast_cosine(angle);
598-
float sine = fast_sine(angle);
599-
float leftRadius = swoosh.mLeftRad;
600-
float rightRadius = swoosh.mRightRad;
601-
float leftSin = leftRadius;
625+
cosine = fast_cosine(angle);
626+
sine = fast_sine(angle);
627+
leftRadius = swoosh.mLeftRad;
628+
rightRadius = swoosh.mRightRad;
629+
leftSin = leftRadius;
602630
leftSin *= sine;
603-
float leftCos = leftRadius;
631+
leftCos = leftRadius;
604632
leftCos *= cosine;
605-
float rightSin = rightRadius;
633+
rightSin = rightRadius;
606634
rightSin *= -sine;
607635
const CVector3f v0 = swoosh.mOrientation * CVector3f(leftCos, 0.f, leftSin) +
608636
swoosh.mTranslation + swoosh.mUseOffset;
@@ -624,7 +652,6 @@ void CParticleSwoosh::Render2SidedNoSplineGaps() {
624652
CGraphics::StreamEnd();
625653
}
626654
}
627-
628655
void CParticleSwoosh::Render2SidedSpline() { RenderNSidedSpline(); }
629656

630657
void CParticleSwoosh::Render3SidedSolidNoSplineNoGaps() {
@@ -900,10 +927,11 @@ void CParticleSwoosh::RenderNSidedSpline() {
900927
if (x1b8_SIDE < 4 || x1b8_SIDE % 2 != 0) {
901928
cros = false;
902929
}
903-
int faceIdx;
904930
int splineIdx;
905931
int curIdx = x158_curParticle;
906932
for (i = 0; i < x15c_swooshes.size() - 1; ++i) {
933+
int j;
934+
int k;
907935
bool prevActive = x15c_swooshes[WrapIndex(curIdx - 1)].mActive;
908936
bool active = x15c_swooshes[WrapIndex(curIdx)].mActive;
909937
if (active == false || (active == true && prevActive == false)) {
@@ -915,7 +943,7 @@ void CParticleSwoosh::RenderNSidedSpline() {
915943
}
916944
const SSwooshData& refSwoosh = x15c_swooshes.data()[curIdx];
917945
const float sideDiv = 360.f / x1b8_SIDE;
918-
for (int j = 0; j < 4; ++j) {
946+
for (j = 0; j < 4; ++j) {
919947
int refIdx = 0;
920948
if (j == 0) {
921949
refIdx = WrapIndex(curIdx + 1);
@@ -945,7 +973,6 @@ void CParticleSwoosh::RenderNSidedSpline() {
945973
} else if (i == x1ac_particleCount - 2 && j == 3) {
946974
refIdx = 0;
947975
}
948-
int k;
949976
const SSwooshData& swoosh = x15c_swooshes.data()[refIdx];
950977
const CTransform4f& orientation = swoosh.mOrientation;
951978
for (k = 0; k < x1b8_SIDE; ++k) {
@@ -993,18 +1020,18 @@ void CParticleSwoosh::RenderNSidedSpline() {
9931020
faces = x1b8_SIDE / 2;
9941021
}
9951022
x1dc_uMax = x1d4_uMin + segUvSpan;
996-
for (faceIdx = 0; faceIdx < faces; ++faceIdx) {
997-
int other = faceIdx + 1;
1023+
for (k = 0; k < faces; ++k) {
1024+
int other = k + 1;
9981025
if (other >= x1b8_SIDE) {
9991026
other = 0;
10001027
}
10011028
const uint color = CColor::Modulate(refSwoosh.mColor, x20c_moduColor).GetColor_u32();
10021029
if (cros) {
1003-
other = faceIdx + x1b8_SIDE / 2;
1004-
const CVector3f& p00 = x16c_p0[faceIdx];
1005-
const CVector3f& p10 = x17c_p1[faceIdx];
1006-
const CVector3f& p20 = x18c_p2[faceIdx];
1007-
const CVector3f& p30 = x19c_p3[faceIdx];
1030+
other = k + x1b8_SIDE / 2;
1031+
const CVector3f& p00 = x16c_p0[k];
1032+
const CVector3f& p10 = x17c_p1[k];
1033+
const CVector3f& p20 = x18c_p2[k];
1034+
const CVector3f& p30 = x19c_p3[k];
10081035
const CVector3f& p01 = x16c_p0[other];
10091036
const CVector3f& p11 = x17c_p1[other];
10101037
const CVector3f& p21 = x18c_p2[other];
@@ -1024,10 +1051,10 @@ void CParticleSwoosh::RenderNSidedSpline() {
10241051
CGraphics::StreamVertex(v3);
10251052

10261053
} else {
1027-
const CVector3f& p00 = x16c_p0[faceIdx];
1028-
const CVector3f& p10 = x17c_p1[faceIdx];
1029-
const CVector3f& p20 = x18c_p2[faceIdx];
1030-
const CVector3f& p30 = x19c_p3[faceIdx];
1054+
const CVector3f& p00 = x16c_p0[k];
1055+
const CVector3f& p10 = x17c_p1[k];
1056+
const CVector3f& p20 = x18c_p2[k];
1057+
const CVector3f& p30 = x19c_p3[k];
10311058
const CVector3f& p01 = x16c_p0[other];
10321059
const CVector3f& p11 = x17c_p1[other];
10331060
const CVector3f& p21 = x18c_p2[other];

0 commit comments

Comments
 (0)