efxBase.cpp progress

This commit is contained in:
HeartPiece 2024-04-18 18:21:05 +10:00
parent 597a51c3c4
commit 3c9ca9812b
8 changed files with 222 additions and 259 deletions

View File

@ -65,7 +65,7 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/efx2dEffect.cpp">efx2dEffect.cpp</a> | 10340 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/ebi2DCallBack.cpp">ebi2DCallBack.cpp</a> | 10457 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/efxObject.cpp">efxObject.cpp</a> | 11240 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/particleMgr.cpp">particleMgr.cpp</a> | 12851 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/ebiP2Title.cpp">ebiP2Title.cpp</a> | 23731 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/efxPikmin.cpp">efxPikmin.cpp</a> | 33209 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/efxBase.cpp">efxBase.cpp</a> | 35235 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/efxEnemy.cpp">efxEnemy.cpp</a> | 39166 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/efxBase.cpp">efxBase.cpp</a> | 33997 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/efxEnemy.cpp">efxEnemy.cpp</a> | 39166 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectEbisawaU/ebiScreenMemoryCard.cpp">ebiScreenMemoryCard.cpp</a> | 48588 | | |
### <section id="plugProjectHikinoU">plugProjectHikinoU</section>
@ -84,7 +84,7 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemHoney.cpp">itemHoney.cpp</a> | 12289 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/aiBreakGate.cpp">aiBreakGate.cpp</a> | 13962 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/texCaster.cpp">texCaster.cpp</a> | 16071 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameCaveInfo.cpp">gameCaveInfo.cpp</a> | 16103 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_CaveResult.cpp">singleGS_CaveResult.cpp</a> | 19624 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemCave.cpp">itemCave.cpp</a> | 20160 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pathfinder.cpp">pathfinder.cpp</a> | 20316 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/dynCreature.cpp">dynCreature.cpp</a> | 21624 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pathfinder.cpp">pathfinder.cpp</a> | 20318 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/dynCreature.cpp">dynCreature.cpp</a> | 21624 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameDynamics.cpp">gameDynamics.cpp</a> | 24672 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameCPlate.cpp">gameCPlate.cpp</a> | 26452 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemPikihead.cpp">itemPikihead.cpp</a> | 26530 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/vsCardMgr.cpp">vsCardMgr.cpp</a> | 30652 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_MainGame.cpp">singleGS_MainGame.cpp</a> | 31879 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemBridge.cpp">itemBridge.cpp</a> | 32134 |

View File

@ -240,6 +240,10 @@ struct Vector3 {
this->normalise();
}
static inline f32 distance(Vector3& a, Vector3& b) { return (a - b).length(); }
inline void sub(Vector3& a, Vector3& b) { set(a.x - b.x, a.y - b.y, a.z - b.z); }
/**
* Sets the flat direction from one vector to another.
* The resulting vector will have a zero y-component.
@ -438,12 +442,6 @@ inline f32 _lengthXZ(Vector3f& vec)
return _sqrtf(a.x * a.x + a.z * a.z);
}
inline f32 _distanceBetween(Vector3f& me, Vector3f& them)
{
Vector3f sep = me - them;
return _length(sep);
}
inline f32 _normalise2(Vector3f& diff)
{
f32 dist = _length(diff);

View File

@ -13,8 +13,8 @@ namespace efx {
struct TSyncGroup##N : TBase { \
/* VTABLE */ \
virtual bool create(Arg* arg); \
virtual void forceKill(); \
virtual void fade(); \
virtual void forceKill(); \
virtual void startDemoDrawOff(); \
virtual void endDemoDrawOn(); \
/* VTABLE END */ \
@ -35,42 +35,6 @@ DEF_SYNC_GROUP(4);
DEF_SYNC_GROUP(5);
DEF_SYNC_GROUP(6);
/*
virtual bool create(Arg* arg)
{
for (u32 i = 0; i < N; i++) {
if (!mItems[i].create(arg)) {
return false;
}
}
return true;
}
virtual void forceKill()
{
for (u32 i = 0; i < N; i++) {
mItems[i].forceKill();
}
}
virtual void fade()
{
for (u32 i = 0; i < N; i++) {
mItems[i].fade();
}
}
virtual void startDemoDrawOff()
{
for (u32 i = 0; i < N; i++) {
mItems[i].startDemoDrawOff();
}
}
virtual void endDemoDrawOn()
{
for (u32 i = 0; i < N; i++) {
mItems[i].endDemoDrawOn();
}
}
*/
} // namespace efx
#endif

View File

@ -12,6 +12,7 @@
#include "efx/TSyncGroup.h"
namespace efx {
TCallBack_StaticClipping TBase::mCallBack_StaticClipping;
/**
@ -581,24 +582,32 @@ void TChasePosPos::doExecuteEmitterOperation(JPABaseEmitter* emitter)
* @note Address: 0x803AFC80
* @note Size: 0xF8
*/
#pragma dont_inline on
void makeMtxZAxisAlongPosPos(Mtx mtx, Vector3f& p2, Vector3f& p3)
{
Vector3f diff = p3 - p2;
diff.normalise();
// some cross product/outer product to generate Mtx
mtx[0][0] = diff.x;
mtx[0][1] = diff.y;
mtx[0][2] = diff.z;
mtx[0][3] = diff.x;
mtx[1][0] = diff.x;
mtx[1][1] = diff.x;
mtx[1][2] = diff.x;
mtx[1][3] = diff.x;
mtx[2][0] = diff.x;
mtx[2][1] = diff.x;
mtx[2][2] = diff.x;
mtx[2][3] = diff.x;
Vector3f zVec(p3.x - p2.x, p3.y - p2.y, p3.z - p2.z);
Vector3f midPt(p2.x + p3.x, p2.y + p3.y, p2.z + p3.z);
midPt *= 0.5f;
zVec.normalise();
Vector3f yAxis(0.0f, 1.0f, 0.0f);
Vector3f xVec = cross(yAxis, zVec);
Vector3f yVec = cross(zVec, xVec);
mtx[0][0] = xVec.x;
mtx[0][1] = yVec.x;
mtx[0][2] = zVec.x;
mtx[0][3] = midPt.x;
mtx[1][0] = xVec.y;
mtx[1][1] = yVec.y;
mtx[1][2] = zVec.y;
mtx[1][3] = midPt.y;
mtx[2][0] = xVec.z;
mtx[2][1] = yVec.z;
mtx[2][2] = zVec.z;
mtx[2][3] = midPt.z;
/*
lfs f0, 4(r4)
@ -671,7 +680,6 @@ lbl_803AFD10:
blr
*/
}
#pragma dont_inline reset
/**
* doExecuteEmitterOperation__Q23efx23TChasePosPosLocalZScaleFP14JPABaseEmitter
@ -686,103 +694,10 @@ void TChasePosPosLocalZScale::doExecuteEmitterOperation(JPABaseEmitter* emitter)
Vector3f vec1 = *mPosPtrA;
Vector3f vec2 = *mPosPtrB;
makeMtxZAxisAlongPosPos(mtxZ, vec1, vec2);
f32 dist = _distanceBetween(vec2, vec1);
f32 dist = Vector3f::distance(vec2, vec1);
emitter->setGlobalRTMatrix(mtxZ);
emitter->mLocalScl.z = dist / _18;
/*
stwu r1, -0x70(r1)
mflr r0
stw r0, 0x74(r1)
stfd f31, 0x60(r1)
psq_st f31, 104(r1), 0, qr0
stw r31, 0x5c(r1)
stw r30, 0x58(r1)
mr r30, r3
mr r31, r4
lwz r0, 0x10(r3)
cmplwi r0, 0
bne lbl_803AFDC4
lis r3, lbl_80495880@ha
lis r5, lbl_8049588C@ha
addi r3, r3, lbl_80495880@l
li r4, 0x350
addi r5, r5, lbl_8049588C@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_803AFDC4:
lwz r0, 0x14(r30)
cmplwi r0, 0
bne lbl_803AFDEC
lis r3, lbl_80495880@ha
lis r5, lbl_8049588C@ha
addi r3, r3, lbl_80495880@l
li r4, 0x351
addi r5, r5, lbl_8049588C@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_803AFDEC:
lwz r6, 0x10(r30)
addi r3, r1, 0x20
addi r4, r1, 0x14
addi r5, r1, 8
lfs f0, 0(r6)
stfs f0, 0x14(r1)
lfs f0, 4(r6)
stfs f0, 0x18(r1)
lfs f0, 8(r6)
stfs f0, 0x1c(r1)
lwz r6, 0x14(r30)
lfs f0, 0(r6)
stfs f0, 8(r1)
lfs f0, 4(r6)
stfs f0, 0xc(r1)
lfs f0, 8(r6)
stfs f0, 0x10(r1)
bl "makeMtxZAxisAlongPosPos__3efxFPA4_fR10Vector3<f>R10Vector3<f>"
lfs f1, 0xc(r1)
lfs f0, 0x18(r1)
lfs f3, 0x10(r1)
fsubs f4, f1, f0
lfs f2, 0x1c(r1)
lfs f1, 8(r1)
lfs f0, 0x14(r1)
fsubs f2, f3, f2
fmuls f3, f4, f4
fsubs f1, f1, f0
lfs f0, lbl_8051F614@sda21(r2)
fmuls f2, f2, f2
fmadds f1, f1, f1, f3
fadds f31, f2, f1
fcmpo cr0, f31, f0
ble lbl_803AFE84
ble lbl_803AFE88
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_803AFE88
lbl_803AFE84:
fmr f31, f0
lbl_803AFE88:
addi r3, r1, 0x20
addi r4, r31, 0x68
addi r5, r31, 0xa4
bl "JPASetRMtxTVecfromMtx__FPA4_CfPA4_fPQ29JGeometry8TVec3<f>"
lfs f0, 0x18(r30)
fdivs f2, f31, f0
stfs f2, 8(r31)
psq_l f31, 104(r1), 0, qr0
lwz r0, 0x74(r1)
lfd f31, 0x60(r1)
lwz r31, 0x5c(r1)
lwz r30, 0x58(r1)
mtlr r0
addi r1, r1, 0x70
blr
*/
dist /= _18;
emitter->mLocalScl.set(emitter->mLocalScl.x, emitter->mLocalScl.y, dist);
}
/**
@ -792,108 +707,17 @@ lbl_803AFE88:
*/
void TChasePosPosLocalYScale::doExecuteEmitterOperation(JPABaseEmitter* emitter)
{
f32 newY;
P2ASSERTLINE(880, _10);
P2ASSERTLINE(881, _14);
Mtx mtxZ;
Vector3f vec1 = *_10;
Vector3f vec2 = *_14;
makeMtxZAxisAlongPosPos(mtxZ, vec1, vec2);
f32 dist = _distanceBetween(vec2, vec1);
f32 dist = Vector3f::distance(vec2, vec1);
emitter->setGlobalRTMatrix(mtxZ);
emitter->mLocalScl.y = dist / _18;
/*
stwu r1, -0x70(r1)
mflr r0
stw r0, 0x74(r1)
stfd f31, 0x60(r1)
psq_st f31, 104(r1), 0, qr0
stw r31, 0x5c(r1)
stw r30, 0x58(r1)
mr r30, r3
mr r31, r4
lwz r0, 0x10(r3)
cmplwi r0, 0
bne lbl_803AFF10
lis r3, lbl_80495880@ha
lis r5, lbl_8049588C@ha
addi r3, r3, lbl_80495880@l
li r4, 0x370
addi r5, r5, lbl_8049588C@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_803AFF10:
lwz r0, 0x14(r30)
cmplwi r0, 0
bne lbl_803AFF38
lis r3, lbl_80495880@ha
lis r5, lbl_8049588C@ha
addi r3, r3, lbl_80495880@l
li r4, 0x371
addi r5, r5, lbl_8049588C@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_803AFF38:
lwz r6, 0x10(r30)
addi r3, r1, 0x20
addi r4, r1, 0x14
addi r5, r1, 8
lfs f0, 0(r6)
stfs f0, 0x14(r1)
lfs f0, 4(r6)
stfs f0, 0x18(r1)
lfs f0, 8(r6)
stfs f0, 0x1c(r1)
lwz r6, 0x14(r30)
lfs f0, 0(r6)
stfs f0, 8(r1)
lfs f0, 4(r6)
stfs f0, 0xc(r1)
lfs f0, 8(r6)
stfs f0, 0x10(r1)
bl "makeMtxZAxisAlongPosPos__3efxFPA4_fR10Vector3<f>R10Vector3<f>"
lfs f1, 0xc(r1)
lfs f0, 0x18(r1)
lfs f3, 0x10(r1)
fsubs f4, f1, f0
lfs f2, 0x1c(r1)
lfs f1, 8(r1)
lfs f0, 0x14(r1)
fsubs f2, f3, f2
fmuls f3, f4, f4
fsubs f1, f1, f0
lfs f0, lbl_8051F614@sda21(r2)
fmuls f2, f2, f2
fmadds f1, f1, f1, f3
fadds f31, f2, f1
fcmpo cr0, f31, f0
ble lbl_803AFFD0
ble lbl_803AFFD4
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_803AFFD4
lbl_803AFFD0:
fmr f31, f0
lbl_803AFFD4:
addi r3, r1, 0x20
addi r4, r31, 0x68
addi r5, r31, 0xa4
bl "JPASetRMtxTVecfromMtx__FPA4_CfPA4_fPQ29JGeometry8TVec3<f>"
lfs f0, 0x18(r30)
fdivs f2, f31, f0
stfs f2, 4(r31)
psq_l f31, 104(r1), 0, qr0
lwz r0, 0x74(r1)
lfd f31, 0x60(r1)
lwz r31, 0x5c(r1)
lwz r30, 0x58(r1)
mtlr r0
addi r1, r1, 0x70
blr
*/
dist /= _18;
emitter->mLocalScl.set(emitter->mLocalScl.x, dist, emitter->mLocalScl.z);
}
/**
@ -1478,4 +1302,181 @@ void TChasePosPosLocalZScale3::setPosptr(Vector3f* p1, Vector3f* p2)
}
}
///////// TSYNCGROUP DEFINITIONS /////////
// N = 2
template <typename T>
bool TSyncGroup2<T>::create(Arg* arg)
{
for (u32 i = 0; i < 2; i++) {
if (!mItems[i].create(arg)) {
return false;
}
}
return true;
}
template <typename T>
void TSyncGroup2<T>::fade()
{
for (u32 i = 0; i < 2; i++) {
mItems[i].fade();
}
}
template <typename T>
void TSyncGroup2<T>::forceKill()
{
for (u32 i = 0; i < 2; i++) {
mItems[i].forceKill();
}
}
template <typename T>
void TSyncGroup2<T>::startDemoDrawOff()
{
for (u32 i = 0; i < 2; i++) {
mItems[i].startDemoDrawOff();
}
}
template <typename T>
void TSyncGroup2<T>::endDemoDrawOn()
{
for (u32 i = 0; i < 2; i++) {
mItems[i].endDemoDrawOn();
}
}
// N = 3
template <typename T>
bool TSyncGroup3<T>::create(Arg* arg)
{
for (u32 i = 0; i < 3; i++) {
if (!mItems[i].create(arg)) {
return false;
}
}
return true;
}
template <typename T>
void TSyncGroup3<T>::fade()
{
for (u32 i = 0; i < 3; i++) {
mItems[i].fade();
}
}
template <typename T>
void TSyncGroup3<T>::forceKill()
{
for (u32 i = 0; i < 3; i++) {
mItems[i].forceKill();
}
}
template <typename T>
void TSyncGroup3<T>::startDemoDrawOff()
{
for (u32 i = 0; i < 3; i++) {
mItems[i].startDemoDrawOff();
}
}
template <typename T>
void TSyncGroup3<T>::endDemoDrawOn()
{
for (u32 i = 0; i < 3; i++) {
mItems[i].endDemoDrawOn();
}
}
// N = 4
template <typename T>
bool TSyncGroup4<T>::create(Arg* arg)
{
for (u32 i = 0; i < 4; i++) {
if (!mItems[i].create(arg)) {
return false;
}
}
return true;
}
template <typename T>
void TSyncGroup4<T>::fade()
{
for (u32 i = 0; i < 4; i++) {
mItems[i].fade();
}
}
template <typename T>
void TSyncGroup4<T>::forceKill()
{
for (u32 i = 0; i < 4; i++) {
mItems[i].forceKill();
}
}
template <typename T>
void TSyncGroup4<T>::startDemoDrawOff()
{
for (u32 i = 0; i < 4; i++) {
mItems[i].startDemoDrawOff();
}
}
template <typename T>
void TSyncGroup4<T>::endDemoDrawOn()
{
for (u32 i = 0; i < 4; i++) {
mItems[i].endDemoDrawOn();
}
}
// N = 6
template <typename T>
bool TSyncGroup6<T>::create(Arg* arg)
{
for (u32 i = 0; i < 6; i++) {
if (!mItems[i].create(arg)) {
return false;
}
}
return true;
}
template <typename T>
void TSyncGroup6<T>::fade()
{
for (u32 i = 0; i < 6; i++) {
mItems[i].fade();
}
}
template <typename T>
void TSyncGroup6<T>::forceKill()
{
for (u32 i = 0; i < 6; i++) {
mItems[i].forceKill();
}
}
template <typename T>
void TSyncGroup6<T>::startDemoDrawOff()
{
for (u32 i = 0; i < 6; i++) {
mItems[i].startDemoDrawOff();
}
}
template <typename T>
void TSyncGroup6<T>::endDemoDrawOn()
{
for (u32 i = 0; i < 6; i++) {
mItems[i].endDemoDrawOn();
}
}
} // namespace efx

View File

@ -208,7 +208,7 @@ bool TOootaBombLeg::create(Arg* arg)
if (TSimple1::create(arg)) {
Matrixf mtx;
makeMtxZAxisAlongPosPos(mtx.mMatrix.mtxView, pos1, pos2);
f32 dist = _distanceBetween(pos2, pos1);
f32 dist = Vector3f::distance(pos2, pos1);
dist /= 100.0f;
mEmitters[0]->setGlobalRTMatrix(mtx.mMatrix.mtxView);
mEmitters[0]->mLocalScl.y *= dist;
@ -922,7 +922,7 @@ bool THdamaDeadHahen1::create(efx::Arg* arg)
if (TSimple1::create(arg)) {
Matrixf mtx;
makeMtxZAxisAlongPosPos(mtx.mMatrix.mtxView, pos1, pos2);
f32 dist = _distanceBetween(pos2, pos1);
f32 dist = Vector3f::distance(pos2, pos1);
dist /= 100.0f;
mEmitters[0]->setGlobalRTMatrix(mtx.mMatrix.mtxView);
mEmitters[0]->mLocalScl.y *= dist;
@ -1054,7 +1054,7 @@ bool THdamaDeadHahen2::create(efx::Arg* arg)
if (TSimple2::create(arg)) {
Matrixf mtx;
makeMtxZAxisAlongPosPos(mtx.mMatrix.mtxView, pos1, pos2);
f32 dist = _distanceBetween(pos2, pos1);
f32 dist = Vector3f::distance(pos2, pos1);
dist /= 100.0f;
for (int i = 0; i < 2; i++) {
mEmitters[i]->setGlobalRTMatrix(mtx.mMatrix.mtxView);

View File

@ -50,7 +50,7 @@ void Footmarks::add(Footmark& mark)
int adjIndex = ((mCurrentIndex + mCount) - 1) % mCount; // (_04 + (mCount - 1) % mCount);
Footmark* currMark = &mMarks[adjIndex];
f32 dist = _distanceBetween(currMark->mPosition, mark.mPosition);
f32 dist = Vector3f::distance(currMark->mPosition, mark.mPosition);
if (dist < 20.0f) {
return;
}

View File

@ -272,7 +272,7 @@ bool Item::getVectorField(Sys::Sphere& bounds, Vector3f& pos)
*/
f32 Item::getWorkDistance(Sys::Sphere& bounds)
{
f32 dist = _distanceBetween(mPosition, bounds.mPosition);
f32 dist = Vector3f::distance(mPosition, bounds.mPosition);
return dist - getWorkRadius();
}

View File

@ -961,7 +961,7 @@ f32 AStarPathfinder::estimate(s16 wpID1, s16 wpID2)
Vector3f pos1 = wp1->getPosition();
Vector3f pos2 = wp2->getPosition();
return _distanceBetween(pos1, pos2);
return Vector3f::distance(pos1, pos2);
}
/**