CReplay::StorePedAnimation

This commit is contained in:
Nikolay Korolev 2019-06-23 13:58:14 +03:00
parent 3dd57c445e
commit a87f3188e9
2 changed files with 68 additions and 24 deletions

View File

@ -1,11 +1,13 @@
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "AnimBlendAssociation.h"
#include "BulletTraces.h" #include "BulletTraces.h"
#include "Clock.h" #include "Clock.h"
#include "Draw.h" #include "Draw.h"
#include "math/Matrix.h" #include "math/Matrix.h"
#include "ModelIndices.h" #include "ModelIndices.h"
#include "Replay.h" #include "Replay.h"
#include "RpAnimBlend.h"
#include "Pad.h" #include "Pad.h"
#include "Pools.h" #include "Pools.h"
#include "CutsceneMgr.h" #include "CutsceneMgr.h"
@ -45,7 +47,7 @@ bool &CReplay::bDoLoadSceneWhenDone = *(bool*)0x95CD76;
void PrintElementsInPtrList(void) void PrintElementsInPtrList(void)
{ {
for (CPtrNode* node = CWorld::GetBigBuildingList(LEVEL_NONE).first; node; node = node->next) { for (CPtrNode* node = CWorld::GetBigBuildingList(LEVEL_NONE).first; node; node = node->next) {
// Most likely debug print was present here /* Most likely debug print was present here */
} }
} }
@ -231,7 +233,49 @@ void CReplay::StorePedUpdate(CPed *ped, int id)
Record.m_nOffset += sizeof(tPedUpdatePacket); Record.m_nOffset += sizeof(tPedUpdatePacket);
} }
#endif #endif
#if 0
WRAPPER void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) { EAXJMP(0x593670); } WRAPPER void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) { EAXJMP(0x593670); }
#else
void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
{
CAnimBlendAssociation* second;
float blend_amount;
CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount);
if (main){
state->animId = main->animId;
state->time = 255.0f / 4.0f * max(0.0f, min(4.0f, main->currentTime));
state->speed = 255.0f / 3.0f * max(0.0f, min(3.0f, main->speed));
}else{
state->animId = 3;
state->time = 0;
state->speed = 85;
}
if (second) {
state->secAnimId = second->animId;
state->secTime = 255.0f / 4.0f * max(0.0f, min(4.0f, second->currentTime));
state->secSpeed = 255.0f / 3.0f * max(0.0f, min(3.0f, second->speed));
state->blendAmount = 255.0f / 2.0f * max(0.0f, min(2.0f, blend_amount));
}else{
state->secAnimId = 0;
state->secTime = 0;
state->secSpeed = 0;
state->blendAmount = 0;
}
CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject);
if (partial) {
state->partAnimId = partial->animId;
state->partAnimTime = 255.0f / 4.0f * max(0.0f, min(4.0f, partial->currentTime));
state->partAnimSpeed = 255.0f / 3.0f * max(0.0f, min(3.0f, partial->speed));
state->partBlendAmount = 255.0f / 2.0f * max(0.0f, min(2.0f, partial->blendAmount));
}else{
state->partAnimId = 0;
state->partAnimTime = 0;
state->partAnimSpeed = 0;
state->partBlendAmount = 0;
}
}
#endif
WRAPPER void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state) { EAXJMP(0x593BB0); } WRAPPER void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state) { EAXJMP(0x593BB0); }
WRAPPER void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer) { EAXJMP(0x594050); } WRAPPER void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer) { EAXJMP(0x594050); }
WRAPPER void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state) { EAXJMP(0x5942A0); } WRAPPER void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state) { EAXJMP(0x5942A0); }

View File

@ -19,33 +19,33 @@ struct CAddressInReplayBuffer
struct CStoredAnimationState struct CStoredAnimationState
{ {
int8 animId; uint8 animId;
int8 time; uint8 time;
int8 speed; uint8 speed;
int8 secAnimId; uint8 secAnimId;
int8 secTime; uint8 secTime;
int8 secSpeed; uint8 secSpeed;
int8 blendAmount; uint8 blendAmount;
int8 partAnimId; uint8 partAnimId;
int8 partAnimTime; uint8 partAnimTime;
int8 partAnimSpeed; uint8 partAnimSpeed;
int8 partBlendAmount; uint8 partBlendAmount;
}; };
struct CStoredDetailedAnimationState struct CStoredDetailedAnimationState
{ {
int8 m_abAnimId[3]; int8 aAnimId[3];
int8 m_abCurTime[3]; int8 aCurTime[3];
int8 m_abSpeed[3]; int8 aSpeed[3];
int8 m_abBlendAmount[3]; int8 aBlendAmount[3];
int8 m_abFunctionCallbackID[3]; int8 aFunctionCallbackID[3];
int16 m_awFlags[3]; int16 aFlags[3];
int8 m_abAnimId2[6]; int8 aAnimId2[6];
int8 m_abCurTime2[6]; int8 aCurTime2[6];
int8 m_abSpeed2[6]; int8 aSpeed2[6];
int8 m_abBlendAmount2[6]; int8 aBlendAmount2[6];
int8 m_abFunctionCallbackID2[6]; int8 aFunctionCallbackID2[6];
int16 m_awFlags2[6]; int16 aFlags2[6];
}; };
class CReplay class CReplay