Merge remote-tracking branch 'upstream/miami' into miami

This commit is contained in:
Nikolay Korolev 2020-05-11 01:00:50 +03:00
commit 2f085ea5f5
17 changed files with 183 additions and 93 deletions

View File

@ -7,7 +7,7 @@
#include "AnimBlendAssociation.h" #include "AnimBlendAssociation.h"
#include "RwHelper.h" #include "RwHelper.h"
//--MIAMI: file done except for one TODO //--MIAMI: file done
CAnimBlendAssociation::CAnimBlendAssociation(void) CAnimBlendAssociation::CAnimBlendAssociation(void)
{ {
@ -160,6 +160,13 @@ CAnimBlendAssociation::Start(float time)
SetCurrentTime(time); SetCurrentTime(time);
} }
void
CAnimBlendAssociation::UpdateTimeStep(float timeDelta, float relSpeed)
{
if(IsRunning())
timeStep = (flags & ASSOC_MOVEMENT ? relSpeed*hierarchy->totalLength : speed) * timeDelta;
}
bool bool
CAnimBlendAssociation::UpdateTime(float timeDelta, float relSpeed) CAnimBlendAssociation::UpdateTime(float timeDelta, float relSpeed)
{ {
@ -170,10 +177,6 @@ CAnimBlendAssociation::UpdateTime(float timeDelta, float relSpeed)
return true; return true;
} }
// TODO(MIAMI): we still need this for some reason
#ifndef NOT_YET
timeStep = (flags & ASSOC_MOVEMENT ? relSpeed*hierarchy->totalLength : speed) * timeDelta;
#endif
currentTime += timeStep; currentTime += timeStep;
if(currentTime >= hierarchy->totalLength){ if(currentTime >= hierarchy->totalLength){

View File

@ -12,12 +12,12 @@ enum {
ASSOC_PARTIAL = 0x10, ASSOC_PARTIAL = 0x10,
ASSOC_MOVEMENT = 0x20, // ??? ASSOC_MOVEMENT = 0x20, // ???
ASSOC_HAS_TRANSLATION = 0x40, ASSOC_HAS_TRANSLATION = 0x40,
ASSOC_WALK = 0x80, // for CPed::PlayFootSteps(void) ASSOC_HAS_X_TRANSLATION = 0x80, // for 2d velocity extraction
ASSOC_FLAG_XPRESS = 0x100, // only used by xpress scratch, see CPed::Chat(void) ASSOC_WALK = 0x100, // for CPed::PlayFootSteps(void)
ASSOC_NOWALK = 0x200, // see CPed::PlayFootSteps(void) ASSOC_FLAG_XPRESS = 0x200, // only used by xpress scratch, see CPed::Chat(void)
ASSOC_BLOCK = 0x400, // unused in assoc description, blocks other anims from being played ASSOC_NOWALK = 0x400, // see CPed::PlayFootSteps(void)
ASSOC_FRONTAL = 0x800, // anims that we fall to front ASSOC_BLOCK = 0x800, // unused in assoc description, blocks other anims from being played
ASSOC_HAS_X_TRANSLATION = 0x1000, // for 2d velocity extraction ASSOC_FRONTAL = 0x1000, // anims that we fall to front
}; };
// Anim hierarchy associated with a clump // Anim hierarchy associated with a clump
@ -74,6 +74,7 @@ public:
void SetCurrentTime(float time); void SetCurrentTime(float time);
void SyncAnimation(CAnimBlendAssociation *other); void SyncAnimation(CAnimBlendAssociation *other);
void Start(float time); void Start(float time);
void UpdateTimeStep(float timeDelta, float relSpeed);
bool UpdateTime(float timeDelta, float relSpeed); bool UpdateTime(float timeDelta, float relSpeed);
bool UpdateBlend(float timeDelta); bool UpdateBlend(float timeDelta);

View File

@ -11,6 +11,7 @@ struct AnimBlendFrameData
IGNORE_TRANSLATION = 4, IGNORE_TRANSLATION = 4,
VELOCITY_EXTRACTION = 8, VELOCITY_EXTRACTION = 8,
VELOCITY_EXTRACTION_3D = 0x10, VELOCITY_EXTRACTION_3D = 0x10,
UPDATE_KEYFRAMES = 0x20,
}; };
uint8 flag; uint8 flag;

View File

@ -6,6 +6,8 @@
#include "AnimBlendAssociation.h" #include "AnimBlendAssociation.h"
#include "RpAnimBlend.h" #include "RpAnimBlend.h"
//--MIAMI: file done
CAnimBlendClumpData *gpAnimBlendClump; CAnimBlendClumpData *gpAnimBlendClump;
// PS2 names without "NonSkinned" // PS2 names without "NonSkinned"
@ -17,7 +19,6 @@ void FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg);
void FrameUpdateCallBackWithVelocityExtractionSkinned(AnimBlendFrameData *frame, void *arg); void FrameUpdateCallBackWithVelocityExtractionSkinned(AnimBlendFrameData *frame, void *arg);
void FrameUpdateCallBackWith3dVelocityExtractionSkinned(AnimBlendFrameData *frame, void *arg); void FrameUpdateCallBackWith3dVelocityExtractionSkinned(AnimBlendFrameData *frame, void *arg);
void void
FrameUpdateCallBackNonSkinned(AnimBlendFrameData *frame, void *arg) FrameUpdateCallBackNonSkinned(AnimBlendFrameData *frame, void *arg)
{ {
@ -47,7 +48,12 @@ FrameUpdateCallBackNonSkinned(AnimBlendFrameData *frame, void *arg)
(*node)->Update(vec, q, 1.0f-totalBlendAmount); (*node)->Update(vec, q, 1.0f-totalBlendAmount);
if((*node)->sequence->HasTranslation()) if((*node)->sequence->HasTranslation())
pos += vec; pos += vec;
rot += q; #ifdef FIX_BUGS
if(DotProduct(rot, q) < 0.0f)
rot -= q;
else
#endif
rot += q;
} }
++*node; ++*node;
} }
@ -101,7 +107,12 @@ FrameUpdateCallBackWithVelocityExtractionNonSkinned(AnimBlendFrameData *frame, v
for(node = updateData->nodes; *node; node++){ for(node = updateData->nodes; *node; node++){
if((*node)->sequence){ if((*node)->sequence){
bool nodelooped = (*node)->Update(vec, q, 1.0f-totalBlendAmount); bool nodelooped = (*node)->Update(vec, q, 1.0f-totalBlendAmount);
rot += q; #ifdef FIX_BUGS
if(DotProduct(rot, q) < 0.0f)
rot -= q;
else
#endif
rot += q;
if((*node)->sequence->HasTranslation()){ if((*node)->sequence->HasTranslation()){
pos += vec; pos += vec;
if((*node)->association->HasTranslation()){ if((*node)->association->HasTranslation()){
@ -179,7 +190,12 @@ FrameUpdateCallBackWith3dVelocityExtractionNonSkinned(AnimBlendFrameData *frame,
for(node = updateData->nodes; *node; node++){ for(node = updateData->nodes; *node; node++){
if((*node)->sequence){ if((*node)->sequence){
bool nodelooped = (*node)->Update(vec, q, 1.0f-totalBlendAmount); bool nodelooped = (*node)->Update(vec, q, 1.0f-totalBlendAmount);
rot += q; #ifdef FIX_BUGS
if(DotProduct(rot, q) < 0.0f)
rot -= q;
else
#endif
rot += q;
if((*node)->sequence->HasTranslation()){ if((*node)->sequence->HasTranslation()){
pos += vec; pos += vec;
if((*node)->association->HasTranslation()){ if((*node)->association->HasTranslation()){
@ -212,8 +228,6 @@ FrameUpdateCallBackWith3dVelocityExtractionNonSkinned(AnimBlendFrameData *frame,
RwMatrixUpdate(mat); RwMatrixUpdate(mat);
} }
#ifdef PED_SKIN
void void
FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg) FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg)
{ {
@ -243,7 +257,10 @@ FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg)
(*node)->Update(vec, q, 1.0f-totalBlendAmount); (*node)->Update(vec, q, 1.0f-totalBlendAmount);
if((*node)->sequence->HasTranslation()) if((*node)->sequence->HasTranslation())
pos += vec; pos += vec;
rot += q; if(DotProduct(rot, q) < 0.0f)
rot -= q;
else
rot += q;
} }
++*node; ++*node;
} }
@ -298,7 +315,10 @@ FrameUpdateCallBackWithVelocityExtractionSkinned(AnimBlendFrameData *frame, void
for(node = updateData->nodes; *node; node++){ for(node = updateData->nodes; *node; node++){
if((*node)->sequence){ if((*node)->sequence){
bool nodelooped = (*node)->Update(vec, q, 1.0f-totalBlendAmount); bool nodelooped = (*node)->Update(vec, q, 1.0f-totalBlendAmount);
rot += q; if(DotProduct(rot, q) < 0.0f)
rot -= q;
else
rot += q;
if((*node)->sequence->HasTranslation()){ if((*node)->sequence->HasTranslation()){
pos += vec; pos += vec;
if((*node)->association->HasTranslation()){ if((*node)->association->HasTranslation()){
@ -376,7 +396,12 @@ FrameUpdateCallBackWith3dVelocityExtractionSkinned(AnimBlendFrameData *frame, vo
for(node = updateData->nodes; *node; node++){ for(node = updateData->nodes; *node; node++){
if((*node)->sequence){ if((*node)->sequence){
bool nodelooped = (*node)->Update(vec, q, 1.0f-totalBlendAmount); bool nodelooped = (*node)->Update(vec, q, 1.0f-totalBlendAmount);
rot += q; #ifdef FIX_BUGS
if(DotProduct(rot, q) < 0.0f)
rot -= q;
else
#endif
rot += q;
if((*node)->sequence->HasTranslation()){ if((*node)->sequence->HasTranslation()){
pos += vec; pos += vec;
if((*node)->association->HasTranslation()){ if((*node)->association->HasTranslation()){
@ -410,4 +435,9 @@ FrameUpdateCallBackWith3dVelocityExtractionSkinned(AnimBlendFrameData *frame, vo
} }
} }
#endif void
FrameUpdateCallBackOffscreen(AnimBlendFrameData *frame, void *arg)
{
if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION && gpAnimBlendClump->velocity)
FrameUpdateCallBackWithVelocityExtractionSkinned(frame, arg);
}

View File

@ -9,9 +9,9 @@
#include "AnimBlendHierarchy.h" #include "AnimBlendHierarchy.h"
#include "AnimBlendAssociation.h" #include "AnimBlendAssociation.h"
#include "RpAnimBlend.h" #include "RpAnimBlend.h"
#ifdef PED_SKIN
#include "PedModelInfo.h" #include "PedModelInfo.h"
#endif
//--MIAMI: file done
RwInt32 ClumpOffset; RwInt32 ClumpOffset;
@ -141,7 +141,6 @@ FrameInitCBskin(AnimBlendFrameData *frameData, void*)
frameData->flag = 0; frameData->flag = 0;
} }
#ifdef PED_SKIN
void void
RpAnimBlendClumpInitSkinned(RpClump *clump) RpAnimBlendClumpInitSkinned(RpClump *clump)
{ {
@ -155,7 +154,7 @@ RpAnimBlendClumpInitSkinned(RpClump *clump)
RpAnimBlendAllocateData(clump); RpAnimBlendAllocateData(clump);
clumpData = *RPANIMBLENDCLUMPDATA(clump); clumpData = *RPANIMBLENDCLUMPDATA(clump);
atomic = IsClumpSkinned(clump); atomic = GetFirstAtomic(clump);
assert(atomic); assert(atomic);
skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic)); skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic));
assert(skin); assert(skin);
@ -175,7 +174,6 @@ RpAnimBlendClumpInitSkinned(RpClump *clump)
clumpData->ForAllFrames(FrameInitCBskin, nil); clumpData->ForAllFrames(FrameInitCBskin, nil);
clumpData->frames[0].flag |= AnimBlendFrameData::VELOCITY_EXTRACTION; clumpData->frames[0].flag |= AnimBlendFrameData::VELOCITY_EXTRACTION;
} }
#endif
void void
RpAnimBlendClumpInitNotSkinned(RpClump *clump) RpAnimBlendClumpInitNotSkinned(RpClump *clump)
@ -199,11 +197,9 @@ RpAnimBlendClumpInitNotSkinned(RpClump *clump)
void void
RpAnimBlendClumpInit(RpClump *clump) RpAnimBlendClumpInit(RpClump *clump)
{ {
#ifdef PED_SKIN
if(IsClumpSkinned(clump)) if(IsClumpSkinned(clump))
RpAnimBlendClumpInitSkinned(clump); RpAnimBlendClumpInitSkinned(clump);
else else
#endif
RpAnimBlendClumpInitNotSkinned(clump); RpAnimBlendClumpInitNotSkinned(clump);
} }
@ -348,9 +344,11 @@ CAnimBlendAssociation*
RpAnimBlendClumpGetFirstAssociation(RpClump *clump) RpAnimBlendClumpGetFirstAssociation(RpClump *clump)
{ {
CAnimBlendClumpData *clumpData = *RPANIMBLENDCLUMPDATA(clump); CAnimBlendClumpData *clumpData = *RPANIMBLENDCLUMPDATA(clump);
if(clumpData == nil) return nil; if(!RpAnimBlendClumpIsInitialized(clump))
if(clumpData->link.next == nil) return nil; return nil;
return CAnimBlendAssociation::FromLink(clumpData->link.next); if(clumpData->link.next)
return CAnimBlendAssociation::FromLink(clumpData->link.next);
return nil;
} }
// FillFrameArrayCallBack on PS2 // FillFrameArrayCallBack on PS2
@ -361,7 +359,6 @@ FillFrameArrayCBnonskin(AnimBlendFrameData *frame, void *arg)
frames[CVisibilityPlugins::GetFrameHierarchyId(frame->frame)] = frame; frames[CVisibilityPlugins::GetFrameHierarchyId(frame->frame)] = frame;
} }
#ifdef PED_SKIN
void void
RpAnimBlendClumpFillFrameArraySkin(RpClump *clump, AnimBlendFrameData **frames) RpAnimBlendClumpFillFrameArraySkin(RpClump *clump, AnimBlendFrameData **frames)
{ {
@ -371,16 +368,13 @@ RpAnimBlendClumpFillFrameArraySkin(RpClump *clump, AnimBlendFrameData **frames)
for(i = PED_MID; i < PED_NODE_MAX; i++) for(i = PED_MID; i < PED_NODE_MAX; i++)
frames[i] = &clumpData->frames[RpHAnimIDGetIndex(hier, ConvertPedNode2BoneTag(i))]; frames[i] = &clumpData->frames[RpHAnimIDGetIndex(hier, ConvertPedNode2BoneTag(i))];
} }
#endif
void void
RpAnimBlendClumpFillFrameArray(RpClump *clump, AnimBlendFrameData **frames) RpAnimBlendClumpFillFrameArray(RpClump *clump, AnimBlendFrameData **frames)
{ {
#ifdef PED_SKIN
if(IsClumpSkinned(clump)) if(IsClumpSkinned(clump))
RpAnimBlendClumpFillFrameArraySkin(clump, frames); RpAnimBlendClumpFillFrameArraySkin(clump, frames);
else else
#endif
(*RPANIMBLENDCLUMPDATA(clump))->ForAllFrames(FillFrameArrayCBnonskin, frames); (*RPANIMBLENDCLUMPDATA(clump))->ForAllFrames(FillFrameArrayCBnonskin, frames);
} }
@ -429,9 +423,27 @@ RpAnimBlendClumpFindBone(RpClump *clump, uint32 boneTag)
} }
void void
RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta) RpAnimBlendNodeUpdateKeyframes(AnimBlendFrameData *frames, AnimBlendFrameUpdateData *updateData, int32 numNodes)
{
CAnimBlendNode **node;
int i;
for(node = updateData->nodes; *node; node++){
CAnimBlendAssociation *a = (*node)->association;
for(i = 0; i < numNodes; i++)
if((frames[i].flag & AnimBlendFrameData::VELOCITY_EXTRACTION) == 0 ||
gpAnimBlendClump->velocity == nil){
if((*node)[i].sequence)
(*node)[i].FindKeyFrame(a->currentTime - a->timeStep);
}
}
}
void
RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta, bool doRender)
{ {
int i; int i;
CAnimBlendAssociation *assoc;
AnimBlendFrameUpdateData updateData; AnimBlendFrameUpdateData updateData;
float totalLength = 0.0f; float totalLength = 0.0f;
float totalBlend = 0.0f; float totalBlend = 0.0f;
@ -447,30 +459,45 @@ RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta)
updateData.foobar = 0; updateData.foobar = 0;
for(link = clumpData->link.next; link; link = next){ for(link = clumpData->link.next; link; link = next){
next = link->next; next = link->next;
CAnimBlendAssociation *assoc = CAnimBlendAssociation::FromLink(link); assoc = CAnimBlendAssociation::FromLink(link);
if(assoc->UpdateBlend(timeDelta)){ if(assoc->UpdateBlend(timeDelta)){
// CAnimManager::UncompressAnimation(v6->hierarchy) if(assoc->hierarchy->sequences){
updateData.nodes[i++] = assoc->GetNode(0); //CAnimManager::UncompressAnimation(v6->hierarchy)
if(assoc->flags & ASSOC_MOVEMENT){ if(i < 11)
totalLength += assoc->hierarchy->totalLength/assoc->speed * assoc->blendAmount; updateData.nodes[i++] = assoc->GetNode(0);
totalBlend += assoc->blendAmount; if(assoc->flags & ASSOC_MOVEMENT){
totalLength += assoc->hierarchy->totalLength/assoc->speed * assoc->blendAmount;
totalBlend += assoc->blendAmount;
}else
updateData.foobar = 1;
}else }else
updateData.foobar = 1; debug("anim %s is not loaded\n", assoc->hierarchy->name);
} }
} }
updateData.nodes[i] = nil;
#ifdef PED_SKIN
if(IsClumpSkinned(clump))
clumpData->ForAllFrames(FrameUpdateCallBackSkinned, &updateData);
else
#endif
clumpData->ForAllFrames(FrameUpdateCallBackNonSkinned, &updateData);
for(link = clumpData->link.next; link; link = link->next){ for(link = clumpData->link.next; link; link = link->next){
CAnimBlendAssociation *assoc = CAnimBlendAssociation::FromLink(link); assoc = CAnimBlendAssociation::FromLink(link);
float relSpeed = totalLength == 0.0f ? 1.0f : totalBlend/totalLength; assoc->UpdateTimeStep(timeDelta, totalLength == 0.0f ? 1.0f : totalBlend/totalLength);
assoc->UpdateTime(timeDelta, relSpeed); }
updateData.nodes[i] = nil;
if(doRender){
if(clumpData->frames[0].flag & AnimBlendFrameData::UPDATE_KEYFRAMES)
RpAnimBlendNodeUpdateKeyframes(clumpData->frames, &updateData, clumpData->numFrames);
if(IsClumpSkinned(clump))
clumpData->ForAllFrames(FrameUpdateCallBackSkinned, &updateData);
else
clumpData->ForAllFrames(FrameUpdateCallBackNonSkinned, &updateData);
clumpData->frames[0].flag &= ~AnimBlendFrameData::UPDATE_KEYFRAMES;
}else{
clumpData->ForAllFrames(FrameUpdateCallBackOffscreen, &updateData);
clumpData->frames[0].flag |= AnimBlendFrameData::UPDATE_KEYFRAMES;
}
for(link = clumpData->link.next; link; link = link->next){
assoc = CAnimBlendAssociation::FromLink(link);
assoc->UpdateTime(timeDelta, totalLength == 0.0f ? 1.0f : totalBlend/totalLength);
} }
RwFrameUpdateObjects(RpClumpGetFrame(clump)); RwFrameUpdateObjects(RpClumpGetFrame(clump));
} }

View File

@ -35,9 +35,11 @@ CAnimBlendAssociation *RpAnimBlendClumpGetMainAssociation_N(RpClump *clump, int
CAnimBlendAssociation *RpAnimBlendClumpGetMainPartialAssociation_N(RpClump *clump, int n); CAnimBlendAssociation *RpAnimBlendClumpGetMainPartialAssociation_N(RpClump *clump, int n);
CAnimBlendAssociation *RpAnimBlendClumpGetFirstAssociation(RpClump *clump, uint32 mask); CAnimBlendAssociation *RpAnimBlendClumpGetFirstAssociation(RpClump *clump, uint32 mask);
CAnimBlendAssociation *RpAnimBlendClumpGetFirstAssociation(RpClump *clump); CAnimBlendAssociation *RpAnimBlendClumpGetFirstAssociation(RpClump *clump);
void RpAnimBlendClumpUpdateAnimations(RpClump* clump, float timeDelta); void RpAnimBlendNodeUpdateKeyframes(AnimBlendFrameData *frames, AnimBlendFrameUpdateData *updateData, int32 numNodes);
void RpAnimBlendClumpUpdateAnimations(RpClump* clump, float timeDelta, bool doRender = true);
extern CAnimBlendClumpData *gpAnimBlendClump; extern CAnimBlendClumpData *gpAnimBlendClump;
void FrameUpdateCallBackNonSkinned(AnimBlendFrameData *frame, void *arg); void FrameUpdateCallBackNonSkinned(AnimBlendFrameData *frame, void *arg);
void FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg); void FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg);
void FrameUpdateCallBackOffscreen(AnimBlendFrameData *frame, void *arg);

View File

@ -280,12 +280,12 @@ CCam::Process(void)
if(DirectionWasLooking != LOOKING_BEHIND) if(DirectionWasLooking != LOOKING_BEHIND)
TheCamera.m_bJust_Switched = true; TheCamera.m_bJust_Switched = true;
DirectionWasLooking = LOOKING_BEHIND; DirectionWasLooking = LOOKING_BEHIND;
}else if(CPad::GetPad(0)->GetLookLeft()){ }else if(!((CVehicle*)CamTargetEntity)->IsRealHeli() && CPad::GetPad(0)->GetLookLeft()){
LookLeft(); LookLeft();
if(DirectionWasLooking != LOOKING_LEFT) if(DirectionWasLooking != LOOKING_LEFT)
TheCamera.m_bJust_Switched = true; TheCamera.m_bJust_Switched = true;
DirectionWasLooking = LOOKING_LEFT; DirectionWasLooking = LOOKING_LEFT;
}else if(CPad::GetPad(0)->GetLookRight()){ }else if(!((CVehicle*)CamTargetEntity)->IsRealHeli() && CPad::GetPad(0)->GetLookRight()){
LookRight(); LookRight();
if(DirectionWasLooking != LOOKING_RIGHT) if(DirectionWasLooking != LOOKING_RIGHT)
TheCamera.m_bJust_Switched = true; TheCamera.m_bJust_Switched = true;

View File

@ -1926,6 +1926,7 @@ CWorld::Process(void)
if(csObj && csObj->m_entryInfoList.first) { if(csObj && csObj->m_entryInfoList.first) {
if(csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP && if(csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) { RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) {
// TODO(MIAMI): doRender argument
RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), RpAnimBlendClumpUpdateAnimations(csObj->GetClump(),
0.02f * (csObj->IsObject() 0.02f * (csObj->IsObject()
? CTimer::GetTimeStepNonClipped() ? CTimer::GetTimeStepNonClipped()
@ -1944,6 +1945,7 @@ CWorld::Process(void)
CEntity *movingEnt = (CEntity *)node->item; CEntity *movingEnt = (CEntity *)node->item;
if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP && if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) { RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
// TODO(MIAMI): doRender argument
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(),
0.02f * (movingEnt->IsObject() 0.02f * (movingEnt->IsObject()
? CTimer::GetTimeStepNonClipped() ? CTimer::GetTimeStepNonClipped()

View File

@ -323,7 +323,7 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Spawn", "Spawn Banshee", [](){ SpawnCar(MI_BANSHEE); }); DebugMenuAddCmd("Spawn", "Spawn Banshee", [](){ SpawnCar(MI_BANSHEE); });
DebugMenuAddCmd("Spawn", "Spawn Cuban", [](){ SpawnCar(MI_CUBAN); }); DebugMenuAddCmd("Spawn", "Spawn Cuban", [](){ SpawnCar(MI_CUBAN); });
DebugMenuAddCmd("Spawn", "Spawn Voodoo", [](){ SpawnCar(MI_VOODOO); }); DebugMenuAddCmd("Spawn", "Spawn Voodoo", [](){ SpawnCar(MI_VOODOO); });
DebugMenuAddCmd("Spawn", "Spawn Dodo", [](){ SpawnCar(MI_DODO); }); DebugMenuAddCmd("Spawn", "Spawn Sparrow", [](){ SpawnCar(MI_SPARROW); });
DebugMenuAddCmd("Spawn", "Spawn Rhino", [](){ SpawnCar(MI_RHINO); }); DebugMenuAddCmd("Spawn", "Spawn Rhino", [](){ SpawnCar(MI_RHINO); });
DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); }); DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); });
DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); }); DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); });

View File

@ -16,6 +16,7 @@
#include "Train.h" #include "Train.h"
#include "Plane.h" #include "Plane.h"
#include "Heli.h" #include "Heli.h"
#include "Bike.h"
#include "ModelIndices.h" #include "ModelIndices.h"
#include "ModelInfo.h" #include "ModelInfo.h"
@ -82,9 +83,13 @@ RwObjectNameIdAssocation carIds[] = {
}; };
RwObjectNameIdAssocation boatIds[] = { RwObjectNameIdAssocation boatIds[] = {
{ "boat_moving_hi", BOAT_MOVING, VEHICLE_FLAG_COLLAPSE }, { "boat_moving_hi", BOAT_MOVING, 0 },
{ "boat_rudder_hi", BOAT_RUDDER, VEHICLE_FLAG_COLLAPSE }, { "boat_rudder_hi", BOAT_RUDDER, 0 },
{ "windscreen", BOAT_WINDSCREEN, VEHICLE_FLAG_WINDSCREEN | VEHICLE_FLAG_COLLAPSE }, { "boat_flap_left", BOAT_FLAP_LEFT, 0 },
{ "boat_flap_right", BOAT_FLAP_RIGHT, 0 },
{ "boat_rearflap_left", BOAT_REARFLAP_LEFT, 0 },
{ "boat_rearflap_right", BOAT_REARFLAP_RIGHT, 0 },
{ "windscreen_hi_ok", BOAT_WINDSCREEN, VEHICLE_FLAG_WINDSCREEN | VEHICLE_FLAG_DRAWLAST },
{ "ped_frontseat", BOAT_POS_FRONTSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "ped_frontseat", BOAT_POS_FRONTSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
{ nil, 0, 0 } { nil, 0, 0 }
}; };
@ -112,8 +117,8 @@ RwObjectNameIdAssocation heliIds[] = {
}; };
RwObjectNameIdAssocation planeIds[] = { RwObjectNameIdAssocation planeIds[] = {
{ "wheel_front_dummy", 2, 0 }, { "wheel_front_dummy", PLANE_WHEEL_FRONT, 0 },
{ "wheel_rear_dummy", 3, 0 }, { "wheel_rear_dummy", PLANE_WHEEL_READ, 0 },
{ "light_tailplane", PLANE_POS_LIGHT_TAIL, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "light_tailplane", PLANE_POS_LIGHT_TAIL, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
{ "light_left", PLANE_POS_LIGHT_LEFT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "light_left", PLANE_POS_LIGHT_LEFT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
{ "light_right", PLANE_POS_LIGHT_RIGHT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "light_right", PLANE_POS_LIGHT_RIGHT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
@ -121,16 +126,18 @@ RwObjectNameIdAssocation planeIds[] = {
}; };
RwObjectNameIdAssocation bikeIds[] = { RwObjectNameIdAssocation bikeIds[] = {
{ "chassis_dummy", 1, 0 }, { "chassis_dummy", BIKE_CHASSIS, 0 },
{ "forks_front", 2, 0 }, { "forks_front", BIKE_FORKS_FRONT, 0 },
{ "forks_rear", 3, 0 }, { "forks_rear", BIKE_FORKS_REAR, 0 },
{ "wheel_front", 4, 0 }, { "wheel_front", BIKE_WHEEL_FRONT, 0 },
{ "wheel_rear", 5, 0 }, { "wheel_rear", BIKE_WHEEL_REAR, 0 },
{ "mudguard", 6, 0 }, { "mudguard", BIKE_MUDGUARD, 0 },
{ "ped_frontseat", 2, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "handlebars", BIKE_HANDLEBARS, 0 },
{ "headlights", 0, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "ped_frontseat", BIKE_POS_FRONTSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
{ "taillights", 1, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "ped_backseat", BIKE_POS_BACKSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
{ "exhaust", 9, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "headlights", BIKE_POS_HEADLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
{ "taillights", BIKE_POS_TAILLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
{ "exhaust", BIKE_POS_EXHAUST, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID },
{ "extra1", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, { "extra1", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID },
{ "extra2", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, { "extra2", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID },
{ "extra3", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, { "extra3", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID },

View File

@ -195,7 +195,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy)
CMatrix mat2(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF])); CMatrix mat2(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF]));
mat1.GetPosition() += CVector(mat2.GetPosition().x + 0.1f, 0.0f, mat2.GetPosition().z); mat1.GetPosition() += CVector(mat2.GetPosition().x + 0.1f, 0.0f, mat2.GetPosition().z);
mat1.UpdateRW(); mat1.UpdateRW();
}else if(GetModelIndex() == MI_SPARROW || GetModelIndex() == MI_RCRAIDER){ }else if(IsRealHeli()){
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LF]), 0); RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LF]), 0);
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RF]), 0); RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_RF]), 0);
RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LB]), 0); RpAtomicSetFlags((RpAtomic*)GetFirstObject(m_aCarNodes[CAR_WHEEL_LB]), 0);
@ -672,9 +672,7 @@ CAutomobile::ProcessControl(void)
acceleration /= m_fForceMultiplier; acceleration /= m_fForceMultiplier;
// unused // unused
if(GetModelIndex() == MI_RCBARON || if(GetModelIndex() == MI_RCBARON || IsRealHeli())
GetModelIndex() == MI_RCRAIDER ||
GetModelIndex() == MI_SPARROW)
acceleration = 0.0f; acceleration = 0.0f;
brake = m_fBrakePedal * pHandling->fBrakeDeceleration * CTimer::GetTimeStep(); brake = m_fBrakePedal * pHandling->fBrakeDeceleration * CTimer::GetTimeStep();
@ -1023,18 +1021,18 @@ CAutomobile::ProcessControl(void)
FlyingControl(FLIGHT_MODEL_DODO); FlyingControl(FLIGHT_MODEL_DODO);
}else if(GetModelIndex() == MI_RCBARON){ }else if(GetModelIndex() == MI_RCBARON){
FlyingControl(FLIGHT_MODEL_RCPLANE); FlyingControl(FLIGHT_MODEL_RCPLANE);
}else if(GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_SPARROW || bAllCarCheat){ }else if(IsRealHeli() || bAllCarCheat){
#ifdef ALLCARSHELI_CHEAT #ifdef ALLCARSHELI_CHEAT
if (bAllCarCheat) if (bAllCarCheat)
FlyingControl(FLIGHT_MODEL_HELI); FlyingControl(FLIGHT_MODEL_HELI);
else else
#endif #endif
{ {
if (CPad::GetPad(0)->GetCircleJustDown()) // if (CPad::GetPad(0)->GetCircleJustDown())
m_aWheelSpeed[0] = Max(m_aWheelSpeed[0] - 0.03f, 0.0f); // m_aWheelSpeed[0] = Max(m_aWheelSpeed[0] - 0.03f, 0.0f);
if (m_aWheelSpeed[0] < 0.22f) // if (m_aWheelSpeed[0] < 0.22f)
m_aWheelSpeed[0] += 0.0001f; // m_aWheelSpeed[0] += 0.0001f;
if (m_aWheelSpeed[0] > 0.15f) // if (m_aWheelSpeed[0] > 0.15f)
FlyingControl(FLIGHT_MODEL_HELI); FlyingControl(FLIGHT_MODEL_HELI);
} }
} }

View File

@ -36,7 +36,7 @@ enum eCarPositions
CAR_POS_TAILLIGHTS, CAR_POS_TAILLIGHTS,
CAR_POS_FRONTSEAT, CAR_POS_FRONTSEAT,
CAR_POS_BACKSEAT, CAR_POS_BACKSEAT,
CAR_POS_EXHAUST = 9, CAR_POS_EXHAUST
}; };
// These are used for all the wheel arrays // These are used for all the wheel arrays

View File

@ -1,7 +1,5 @@
#pragma once #pragma once
// some miami bike leftovers
enum eBikeNodes { enum eBikeNodes {
BIKE_NODE_NONE, BIKE_NODE_NONE,
BIKE_CHASSIS, BIKE_CHASSIS,
@ -12,4 +10,13 @@ enum eBikeNodes {
BIKE_MUDGUARD, BIKE_MUDGUARD,
BIKE_HANDLEBARS, BIKE_HANDLEBARS,
BIKE_NUM_NODES BIKE_NUM_NODES
}; };
enum eBikePositions
{
BIKE_POS_HEADLIGHTS,
BIKE_POS_TAILLIGHTS,
BIKE_POS_FRONTSEAT,
BIKE_POS_BACKSEAT,
BIKE_POS_EXHAUST
};

View File

@ -5,8 +5,12 @@
enum eBoatNodes enum eBoatNodes
{ {
BOAT_MOVING = 1, BOAT_MOVING = 1,
BOAT_WINDSCREEN,
BOAT_RUDDER, BOAT_RUDDER,
BOAT_WINDSCREEN BOAT_FLAP_LEFT,
BOAT_FLAP_RIGHT,
BOAT_REARFLAP_LEFT,
BOAT_REARFLAP_RIGHT
}; };
class CBoat : public CVehicle class CBoat : public CVehicle

View File

@ -2,6 +2,13 @@
#include "Vehicle.h" #include "Vehicle.h"
enum ePlaneNodes
{
PLANE_WHEEL_FRONT = 2,
PLANE_WHEEL_READ,
NUM_PLANE_NODES
};
enum ePlanePositions enum ePlanePositions
{ {
PLANE_POS_LIGHT_LEFT, PLANE_POS_LIGHT_LEFT,

View File

@ -423,17 +423,16 @@ CVehicle::FlyingControl(eFlightModel flightModel)
} }
else { else {
fPitch = CPad::GetPad(0)->GetSteeringUpDown() / 128.0f; fPitch = CPad::GetPad(0)->GetSteeringUpDown() / 128.0f;
fRoll = CPad::GetPad(0)->GetLookLeft(); fYaw = CPad::GetPad(0)->GetLookRight();
if (CPad::GetPad(0)->GetLookRight()) if (CPad::GetPad(0)->GetLookLeft())
fRoll = -1.0f; fYaw = -1.0f;
fYaw = CPad::GetPad(0)->GetSteeringLeftRight() / 128.0f; fRoll = -CPad::GetPad(0)->GetSteeringLeftRight() / 128.0f;
} }
if (CPad::GetPad(0)->GetHorn()) { if (CPad::GetPad(0)->GetHorn()) {
fYaw = 0.0f; fYaw = 0.0f;
fPitch = clamp(10.0f * DotProduct(m_vecMoveSpeed, GetUp()), -200.0f, 1.3f); fPitch = clamp(10.0f * DotProduct(m_vecMoveSpeed, GetUp()), -200.0f, 1.3f);
fRoll = clamp(10.0f * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f); fRoll = clamp(10.0f * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f);
} }
debug("fPitch: %f\n", fPitch);
ApplyTurnForce(fPitch * GetUp() * fPitchVar * m_fTurnMass * CTimer::GetTimeStep(), GetForward()); ApplyTurnForce(fPitch * GetUp() * fPitchVar * m_fTurnMass * CTimer::GetTimeStep(), GetForward());
ApplyTurnForce(fRoll * GetUp() * fRollVar * m_fTurnMass * CTimer::GetTimeStep(), GetRight()); ApplyTurnForce(fRoll * GetUp() * fRollVar * m_fTurnMass * CTimer::GetTimeStep(), GetRight());
ApplyTurnForce(fYaw * GetForward() * fYawVar * m_fTurnMass * CTimer::GetTimeStep(), GetRight()); ApplyTurnForce(fYaw * GetForward() * fYawVar * m_fTurnMass * CTimer::GetTimeStep(), GetRight());

View File

@ -5,6 +5,7 @@
#include "ModelIndices.h" #include "ModelIndices.h"
#include "AnimManager.h" #include "AnimManager.h"
#include "Weapon.h" #include "Weapon.h"
#include "HandlingMgr.h"
class CPed; class CPed;
class CFire; class CFire;
@ -294,6 +295,7 @@ public:
bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1; } bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1; }
CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); } CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); }
bool IsTaxi(void) { return GetModelIndex() == MI_TAXI || GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_ZEBRA || GetModelIndex() == MI_KAUFMAN; } bool IsTaxi(void) { return GetModelIndex() == MI_TAXI || GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_ZEBRA || GetModelIndex() == MI_KAUFMAN; }
bool IsRealHeli(void) { return !!(pHandling->Flags & HANDLING_IS_HELI); }
AnimationId GetDriverAnim(void) { return IsCar() && bLowVehicle ? ANIM_CAR_LSIT : (IsBoat() && GetModelIndex() != MI_SPEEDER ? ANIM_DRIVE_BOAT : ANIM_CAR_SIT); } AnimationId GetDriverAnim(void) { return IsCar() && bLowVehicle ? ANIM_CAR_LSIT : (IsBoat() && GetModelIndex() != MI_SPEEDER ? ANIM_DRIVE_BOAT : ANIM_CAR_SIT); }
static bool bWheelsOnlyCheat; static bool bWheelsOnlyCheat;