Fix some things, decompile a lot more of LiveActor, etc

This commit is contained in:
shibbo 2019-08-27 22:20:21 -04:00
parent f8aff363e9
commit f95d63a756
10 changed files with 164 additions and 6 deletions

View File

@ -12,6 +12,7 @@
#include "Actor/Sensor/HitSensor.h"
#include "Actor/Sensor/HitSensorKeeper.h"
#include "Actor/Shadow/ShadowController.h"
#include "Actor/Sound/AudAnmSoundObject.h"
#include "Actor/StarPointer/StarPointerTarget.h"
#include "Actor/Switch/StageSwitch.h"
#include "Collision/Binder.h"
@ -82,7 +83,7 @@ public:
Binder* mBinder; // _58
RailRider* mRailRider; // _5C
EffectKeeper* mEffectKeeper; // _60
u32* _64; // AudSoundObject*
AudAnmSoundObject* mSoundObj; // _64
LiveActorFlag mFlags; // _68
ShadowControllerList* mShadowController; // _74
u32* _78; // CollisionParts*

View File

@ -0,0 +1,15 @@
#ifndef AUDANMSOUNDOBJECT_H
#define AUDANMSOUNDOBJECT_H
#include "Actor/Sound/AudSoundObject.h"
#include "JKR/JKRHeap.h"
class AudAnmSoundObject : public AudSoundObject
{
public:
AudAnmSoundObject(JGeometry::TVec3<f32>*, u8, JKRHeap *);
u8 _48[0x74-0x48];
};
#endif // AUDANMSOUNDOBJECT_H

View File

@ -0,0 +1,12 @@
#ifndef AUDSOUNDOBJECT_H
#define AUDSOUNDOBJECT_H
#include "Actor/Sound/JAUSoundObject.h"
class AudSoundObject : public JAUSoundObject
{
public:
u8 _18[0x48-0x18];
};
#endif // AUDSOUNDOBJECT_H

View File

@ -0,0 +1,18 @@
#ifndef JAUSOUNDOBJECT_H
#define JAUSOUNDOBJECT_H
#include "JGeometry/TVec3.h"
#include "types.h"
class JAUSoundObject
{
public:
u32 _0;
u32 _4;
u32 _8;
u32 _C;
u32 _10;
JGeometry::TVec3<f32>* _14;
};
#endif // JAUSOUNDOBJECT_H

View File

@ -2,9 +2,12 @@
#define MEMORYUTIL_H
#include "types.h"
#include "JKR/JKRHeap.h"
namespace MR
{
JKRHeap* getCurrentHeap();
void zeroMemory(void *, u32);
s32 calcCheckSum(const void *, u32);
};

View File

@ -6,8 +6,14 @@
namespace MR
{
void updateModelManager(LiveActor *);
void calcAnimModelManager(LiveActor *);
J3DModel* getJ3DModel(const LiveActor *);
void calcJ3DModel(LiveActor *);
ResourceHolder* getResourceHolder(const LiveActor *);
ResourceHolder* getModelResourceHolder(const LiveActor *);
const char* getModelResName(const LiveActor *);
}
#endif // MODELUTIL_H

View File

@ -28,7 +28,9 @@ public:
void initMaterialAnm();
ResourceHolder* getResourceHolder() const;
ResourceHolder* getModelResourceHolder() const;
J3DModel* getJ3DModel() const;
J3DModelData* getJ3DModelData() const;
BtkPlayer* mBTKPlayer; // _0
BrkPlayer* mBRKPlayer; // _4

View File

@ -9,6 +9,7 @@ class ResourceHolder
public:
ResourceHolder(JKRArchive &);
const char* getResName(u32) const;
bool isExistMaterialAnim();
ResTable* mResourceTable; // _0

View File

@ -7,6 +7,7 @@
#include "MR/actor/ActorMovementUtil.h"
#include "MR/actor/ActorSensorUtil.h"
#include "MR/actor/LiveActorUtil.h"
#include "MR/MemoryUtil.h"
#include "MR/ModelUtil.h"
#include "MR/SoundUtil.h"
@ -43,7 +44,7 @@ LiveActor::LiveActor(const char *name) : NameObj(name)
this->mBinder = 0;
this->mRailRider = 0;
this->mEffectKeeper = 0;
this->_64 = 0;
this->mSoundObj = 0;
LiveActorFlag flags;
this->mFlags = flags;
@ -55,13 +56,16 @@ LiveActor::LiveActor(const char *name) : NameObj(name)
this->mLightCtrl = 0;
this->mCameraCtrl = 0;
// register our actor to the "live" actor group, since each actor, when spawned, is technically "alive"
AllLiveActorGroup* group = MR::getAllLiveActorGroup();
group->registerActor(this);
// register our actor to the clipping director for drawing
ClippingDirector* director = MR::getClippingDirector();
director->registerActor(this);
}
// nullsub
void LiveActor::init(const JMapInfoIter &iter)
{
return;
@ -74,16 +78,19 @@ void LiveActor::appear()
void LiveActor::makeActorAppeared()
{
// if there is a sensor keeper, validate it for use
if (this->mSensorKeeper != 0)
{
this->mSensorKeeper->validateBySystem();
}
// if the actor is currently clipped, end it
if (MR::isClipped(this))
{
this->endClipped();
}
// validate our collision parts, and mark our actor as alive
u32* colParts = this->_78;
this->mFlags.mIsDead = 0;
@ -92,13 +99,16 @@ void LiveActor::makeActorAppeared()
MR::validateCollisionParts(this);
}
// reset to default position
MR::resetPosition(this);
// reset the light control
if (this->mLightCtrl != 0)
{
this->mLightCtrl->reset();
}
// update hit sensors to our new position, add to clipping targets, and connect to the scene
MR::tryUpdateHitSensorsAll(this);
MR::addToClippingTarget(this);
MR::connectToSceneTemporarily(this);
@ -122,8 +132,10 @@ void LiveActor::makeActorDead()
this->mVelocity.y = zero;
this->mVelocity.x = zero;
// clear all of our hit sensors
MR::clearHitSensors(this);
// invalidate our sensor, binder, and effect keepers
if (this->mSensorKeeper != 0)
this->mSensorKeeper->invalidateBySystem();
@ -133,13 +145,17 @@ void LiveActor::makeActorDead()
if (this->mEffectKeeper != 0)
this->mEffectKeeper->clear();
// remove collision
if (this->_78 != 0)
{
MR::invalidateCollisionParts(this);
}
// mark our actor as dead
this->mFlags.mIsDead = 1;
// remove from clipping targets, and remove from the scene
// we don't remove this fully as the game can spawn the actor again
MR::removeFromClippingTarget(this);
MR::disconnectToSceneTemporarily(this);
MR::disconnectToDrawTemporarily(this);
@ -147,6 +163,7 @@ void LiveActor::makeActorDead()
void LiveActor::movement()
{
// if we have a model manager, update our model and the animation keeper
if (this->mModelManager != 0)
{
if (this->mFlags.mIsNotReleasedAnimFrame)
@ -158,6 +175,7 @@ void LiveActor::movement()
}
}
// if we need to calculate the new gravity, do so
if (MR::isCalcGravity(this))
MR::calcGravity(this);
@ -235,6 +253,7 @@ s32 LiveActor::receiveMessage(u32 msg, HitSensor *taking, HitSensor *taken)
if (msg == 0x29)
return this->receiveMsgPush(taking, taken);
// this flag is used to describe certain messages
s32 flag = 0;
if (msg != 0)
@ -298,6 +317,7 @@ Mtx* LiveActor::getTakingMtx() const
void LiveActor::setNerve(const Nerve *nerve)
{
// set the current nerve for the actor state
this->mSpine->setNerve(nerve);
}
@ -323,7 +343,15 @@ HitSensor* LiveActor::getSensor(const char *sensorName) const
return 0;
}
// LiveActor::getBaseMtx()
Mtx* LiveActor::getBaseMtx() const
{
if (MR::getJ3DModel(this) != 0)
{
return &MR::getJ3DModel(this)->_24;
}
return 0;
}
void LiveActor::startClipped()
{
@ -364,11 +392,11 @@ void LiveActor::endClipped()
MR::connectToDrawTemporarily(this);
}
void LiveActor::initModelManagerWithAnm(const char *a1, const char *a2, bool a3)
void LiveActor::initModelManagerWithAnm(const char *modelName, const char *a2, bool a3)
{
ModelManager* manager = new ModelManager();
this->mModelManager = manager;
mModelManager->init(a1, a2, a3);
mModelManager->init(modelName, a2, a3);
J3DModel* model = MR::getJ3DModel(this);
model->setBaseScale((Vec&)this->mScale);
@ -420,7 +448,19 @@ void LiveActor::initEffectKeeper(s32 effectCount, const char *resName, bool enab
this->mEffectKeeper->setBinder(this->mBinder);
}
// LiveActor::initSound()
void LiveActor::initSound(s32 a1, bool ignoreActorPosition)
{
if (ignoreActorPosition != 0)
{
AudAnmSoundObject* soundObj = new AudAnmSoundObject(&this->mTranslation, ignoreActorPosition, MR::getCurrentHeap());
this->mSoundObj = soundObj;
}
else
{
AudAnmSoundObject* soundObj = new AudAnmSoundObject(0, ignoreActorPosition, MR::getCurrentHeap());
this->mSoundObj = soundObj;
}
}
void LiveActor::initShadowControllerList(u32 listNum)
{

60
source/MR/ModelUtil.cpp Normal file
View File

@ -0,0 +1,60 @@
#include "MR/ModelUtil.h"
namespace MR
{
void updateModelManager(LiveActor *actor)
{
actor->mModelManager->update();
}
void calcAnimModelManager(LiveActor *actor)
{
actor->mModelManager->calcAnim();
}
J3DModel* getJ3DModel(const LiveActor *actor)
{
if (actor->mModelManager == 0)
{
return 0;
}
return actor->mModelManager->getJ3DModel();
}
J3DModelData* getJ3DModelData(const LiveActor* actor)
{
if (actor->mModelManager == 0)
{
return 0;
}
return actor->mModelManager->getJ3DModelData();
}
ResourceHolder* getResourceHolder(const LiveActor *actor)
{
if (actor->mModelManager != 0)
{
return actor->mModelManager->getResourceHolder();
}
return 0;
}
ResourceHolder* getModelResourceHolder(const LiveActor *actor)
{
if (actor->mModelManager != 0)
{
return actor->mModelManager->getModelResourceHolder();
}
return 0;
}
const char* getModelResName(const LiveActor *actor)
{
ResourceHolder* holder = MR::getModelResourceHolder(actor);
return holder->getResName(0);
}
};