diff options
Diffstat (limited to 'src/objects')
-rw-r--r-- | src/objects/CutsceneHead.cpp | 194 | ||||
-rw-r--r-- | src/objects/CutsceneHead.h | 28 | ||||
-rw-r--r-- | src/objects/CutsceneObject.cpp | 44 | ||||
-rw-r--r-- | src/objects/CutsceneObject.h | 17 | ||||
-rw-r--r-- | src/objects/DummyObject.cpp | 1 | ||||
-rw-r--r-- | src/objects/DummyObject.h | 2 | ||||
-rw-r--r-- | src/objects/Object.cpp | 34 | ||||
-rw-r--r-- | src/objects/Object.h | 42 |
8 files changed, 62 insertions, 300 deletions
diff --git a/src/objects/CutsceneHead.cpp b/src/objects/CutsceneHead.cpp deleted file mode 100644 index 55e75807..00000000 --- a/src/objects/CutsceneHead.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include "common.h" -#include <rpskin.h> - -#include "main.h" -#include "RwHelper.h" -#include "RpAnimBlend.h" -#include "AnimBlendClumpData.h" -#include "Bones.h" -#include "Directory.h" -#include "CutsceneMgr.h" -#include "Streaming.h" -#include "CutsceneHead.h" -#include "CdStream.h" - - -CCutsceneHead::CCutsceneHead(CObject *obj) -{ - RpAtomic *atm; - - assert(RwObjectGetType(obj->m_rwObject) == rpCLUMP); -#ifdef PED_SKIN - unk1 = 0; - bIsSkinned = false; - m_parentObject = (CCutsceneObject*)obj; - // Hide original head - if(IsClumpSkinned(obj->GetClump())){ - m_parentObject->SetRenderHead(false); - bIsSkinned = true; - }else -#endif - { - m_pHeadNode = RpAnimBlendClumpFindFrame((RpClump*)obj->m_rwObject, "Shead")->frame; - atm = (RpAtomic*)GetFirstObject(m_pHeadNode); - if(atm){ - assert(RwObjectGetType((RwObject*)atm) == rpATOMIC); - RpAtomicSetFlags(atm, RpAtomicGetFlags(atm) & ~rpATOMICRENDER); - } - } -} - -void -CCutsceneHead::CreateRwObject(void) -{ - RpAtomic *atm; - - CEntity::CreateRwObject(); - assert(RwObjectGetType(m_rwObject) == rpCLUMP); - atm = GetFirstAtomic((RpClump*)m_rwObject); - RpSkinAtomicSetHAnimHierarchy(atm, RpHAnimFrameGetHierarchy(GetFirstChild(RpClumpGetFrame((RpClump*)m_rwObject)))); -} - -void -CCutsceneHead::DeleteRwObject(void) -{ - CEntity::DeleteRwObject(); -} - -void -CCutsceneHead::ProcessControl(void) -{ - RpAtomic *atm; - RpHAnimHierarchy *hier; - - // android/xbox calls is at the end - CPhysical::ProcessControl(); - -#ifdef PED_SKIN - if(bIsSkinned){ - UpdateRpHAnim(); - UpdateRwFrame(); - - RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(m_parentObject->GetClump()); - int idx = RpHAnimIDGetIndex(hier, BONE_head); - RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; - if(RwV3dLength(&mat->pos) > 100.0f){ - m_matrix.SetRotateY(PI/2); - m_matrix = CMatrix(mat) * m_matrix; - } - }else -#endif - { - m_matrix.SetRotateY(PI/2); - m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix; - UpdateRwFrame(); // android/xbox don't call this - } - - assert(RwObjectGetType(m_rwObject) == rpCLUMP); - atm = GetFirstAtomic((RpClump*)m_rwObject); - hier = RpSkinAtomicGetHAnimHierarchy(atm); - RpHAnimHierarchyAddAnimTime(hier, CTimer::GetTimeStepNonClipped()/50.0f); -} - -void -CCutsceneHead::Render(void) -{ - RpAtomic *atm; - -#ifdef PED_SKIN - if(bIsSkinned){ - RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(m_parentObject->GetClump()); - RpHAnimHierarchyUpdateMatrices(hier); - int idx = RpHAnimIDGetIndex(hier, BONE_head); - RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; - if(RwV3dLength(&mat->pos) > 100.0f){ - m_matrix.SetRotateY(PI/2); - m_matrix = CMatrix(mat) * m_matrix; - } - // This is head...it has no limbs -#ifndef FIX_BUGS - RenderLimb(BONE_Lhand); - RenderLimb(BONE_Rhand); -#endif - }else -#endif - { - m_matrix.SetRotateY(PI/2); - m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix; - } - - UpdateRwFrame(); - - assert(RwObjectGetType(m_rwObject) == rpCLUMP); - atm = GetFirstAtomic((RpClump*)m_rwObject); - RpHAnimHierarchyUpdateMatrices(RpSkinAtomicGetHAnimHierarchy(atm)); - - CObject::Render(); -} - -#ifdef PED_SKIN -void -CCutsceneHead::RenderLimb(int32 bone) -{ - // It's not clear what this is... - // modelinfo for this object is not a ped so it also doesn't have any limbs -#ifndef FIX_BUGS - RpAtomic *atomic; - RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(m_parentObject->GetClump()); - int idx = RpHAnimIDGetIndex(hier, bone); - RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier); - CPedModelInfo *mi = (CPedModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); - assert(mi->GetModelType() == MITYPE_PED); - switch(bone){ - case BONE_Lhand: - atomic = mi->getLeftHand(); - break; - case BONE_Rhand: - atomic = mi->getRightHand(); - break; - default: - return; - } - if(atomic){ - RwFrame *frame = RpAtomicGetFrame(atomic); - RwMatrixTransform(RwFrameGetMatrix(frame), &mats[idx], rwCOMBINEREPLACE); - RwFrameUpdateObjects(frame); - RpAtomicRender(atomic); - } -#endif -} -#endif - -void -CCutsceneHead::PlayAnimation(const char *animName) -{ - RpAtomic *atm; - RpHAnimHierarchy *hier; - RpHAnimAnimation *anim; - uint32 offset, size; - RwStream *stream; - - assert(RwObjectGetType(m_rwObject) == rpCLUMP); - atm = GetFirstAtomic((RpClump*)m_rwObject); - hier = RpSkinAtomicGetHAnimHierarchy(atm); - - sprintf(gString, "%s.anm", animName); - - if(CCutsceneMgr::ms_pCutsceneDir->FindItem(gString, offset, size)){ - stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "ANIM\\CUTS.IMG"); - assert(stream); - - CStreaming::MakeSpaceFor(size * CDSTREAM_SECTOR_SIZE); - CStreaming::ImGonnaUseStreamingMemory(); - - RwStreamSkip(stream, offset*2048); - if(RwStreamFindChunk(stream, rwID_HANIMANIMATION, nil, nil)){ - anim = RpHAnimAnimationStreamRead(stream); - RpHAnimHierarchySetCurrentAnim(hier, anim); - } - - CStreaming::IHaveUsedStreamingMemory(); - - RwStreamClose(stream, nil); - } -} diff --git a/src/objects/CutsceneHead.h b/src/objects/CutsceneHead.h deleted file mode 100644 index c931eb01..00000000 --- a/src/objects/CutsceneHead.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "CutsceneObject.h" - -class CCutsceneHead : public CCutsceneObject -{ -public: - RwFrame *m_pHeadNode; -#ifdef PED_SKIN - int32 unk1; - CCutsceneObject *m_parentObject; - int32 unk2; - int32 bIsSkinned; -#endif - - CCutsceneHead(CObject *obj); - - void CreateRwObject(void); - void DeleteRwObject(void); - void ProcessControl(void); - void Render(void); - void RenderLimb(int32 bone); - - void PlayAnimation(const char *animName); -}; -#ifndef PED_SKIN -VALIDATE_SIZE(CCutsceneHead, 0x19C); -#endif diff --git a/src/objects/CutsceneObject.cpp b/src/objects/CutsceneObject.cpp index 5c10d37d..bf39bd03 100644 --- a/src/objects/CutsceneObject.cpp +++ b/src/objects/CutsceneObject.cpp @@ -21,12 +21,6 @@ CCutsceneObject::CCutsceneObject(void) ObjectCreatedBy = CUTSCENE_OBJECT; m_fMass = 1.0f; m_fTurnMass = 1.0f; - -#ifdef PED_SKIN - bRenderHead = true; - bRenderRightHand = true; - bRenderLeftHand = true; -#endif } void @@ -85,47 +79,9 @@ CCutsceneObject::PreRender(void) void CCutsceneObject::Render(void) { -#ifdef PED_SKIN - if(IsClumpSkinned(GetClump())){ - if(bRenderLeftHand) RenderLimb(BONE_Lhand); - if(bRenderRightHand) RenderLimb(BONE_Rhand); - if(bRenderHead) RenderLimb(BONE_head); - } -#endif CObject::Render(); } -#ifdef PED_SKIN -void -CCutsceneObject::RenderLimb(int32 bone) -{ - RpAtomic *atomic; - CPedModelInfo *mi = (CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex()); - switch(bone){ - case BONE_head: - atomic = mi->getHead(); - break; - case BONE_Lhand: - atomic = mi->getLeftHand(); - break; - case BONE_Rhand: - atomic = mi->getRightHand(); - break; - default: - return; - } - if(atomic){ - RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump()); - int idx = RpHAnimIDGetIndex(hier, bone); - RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; - RwFrame *frame = RpAtomicGetFrame(atomic); - *RwFrameGetMatrix(frame) = *mat; - RwFrameUpdateObjects(frame); - RpAtomicRender(atomic); - } -} -#endif - bool CCutsceneObject::SetupLighting(void) { diff --git a/src/objects/CutsceneObject.h b/src/objects/CutsceneObject.h index 407adcc7..bb642f3e 100644 --- a/src/objects/CutsceneObject.h +++ b/src/objects/CutsceneObject.h @@ -5,29 +5,12 @@ class CCutsceneObject : public CObject { public: -#ifdef PED_SKIN - bool bRenderHead; - bool bRenderRightHand; - bool bRenderLeftHand; - - bool GetRenderHead(void) { return bRenderHead; } - bool GetRenderRightHand(void) { return bRenderRightHand; } - bool GetRenderLeftHand(void) { return bRenderLeftHand; } - void SetRenderHead(bool render) { bRenderHead = render; } - void SetRenderRightHand(bool render) { bRenderRightHand = render; } - void SetRenderLeftHand(bool render) { bRenderLeftHand = render; } -#endif - CCutsceneObject(void); void SetModelIndex(uint32 id); void ProcessControl(void); void PreRender(void); void Render(void); - void RenderLimb(int32 bone); bool SetupLighting(void); void RemoveLighting(bool reset); }; -#ifndef PED_SKIN -VALIDATE_SIZE(CCutsceneObject, 0x198); -#endif diff --git a/src/objects/DummyObject.cpp b/src/objects/DummyObject.cpp index d5805073..8dd1643d 100644 --- a/src/objects/DummyObject.cpp +++ b/src/objects/DummyObject.cpp @@ -10,4 +10,5 @@ CDummyObject::CDummyObject(CObject *obj) AttachToRwObject(obj->m_rwObject); obj->DetachFromRwObject(); m_level = obj->m_level; + m_area = obj->m_area; } diff --git a/src/objects/DummyObject.h b/src/objects/DummyObject.h index d6f88335..680df685 100644 --- a/src/objects/DummyObject.h +++ b/src/objects/DummyObject.h @@ -10,5 +10,3 @@ public: CDummyObject(void) {} CDummyObject(CObject *obj); }; - -VALIDATE_SIZE(CDummyObject, 0x68); diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index c5f73987..daa48d98 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -14,7 +14,8 @@ #include "soundlist.h" int16 CObject::nNoTempObjects; -int16 CObject::nBodyCastHealth = 1000; +//int16 CObject::nBodyCastHealth = 1000; +float CObject::fDistToNearestTree; void *CObject::operator new(size_t sz) { return CPools::GetObjectPool()->New(); } void *CObject::operator new(size_t sz, int handle) { return CPools::GetObjectPool()->New(handle);}; @@ -69,6 +70,7 @@ CObject::CObject(CDummyObject *dummy) dummy->DetachFromRwObject(); Init(); m_level = dummy->m_level; + m_area = dummy->m_area; } CObject::~CObject(void) @@ -160,6 +162,7 @@ CObject::ObjectDamage(float amount) return; static int8 nFrameGen = 0; bool bBodyCastDamageEffect = false; +#if 0 if (GetModelIndex() == MI_BODYCAST) { if (amount > 50.0f) nBodyCastHealth = (int16)(nBodyCastHealth - 0.5f * amount); @@ -169,6 +172,7 @@ CObject::ObjectDamage(float amount) bBodyCastDamageEffect = true; amount = 0.0f; } +#endif if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { const CVector& vecPos = m_matrix.GetPosition(); const float fDirectionZ = 0.0002f * amount; @@ -326,6 +330,8 @@ CObject::Init(void) m_colour1 = 0; m_colour2 = 0; m_nBonusValue = 0; + bIsWeapon = false; +// TODO(MIAMI): some new field here m_pCollidingEntity = nil; CColPoint point; CEntity* outEntity = nil; @@ -334,10 +340,15 @@ CObject::Init(void) m_pCurSurface = outEntity; else m_pCurSurface = nil; - if (GetModelIndex() == MI_BODYCAST) - nBodyCastHealth = 1000; - else if (GetModelIndex() == MI_BUOY) + + if (GetModelIndex() == MI_BUOY) bTouchingWater = true; + + if(CModelInfo::GetModelInfo(GetModelIndex())->GetModelType() == MITYPE_WEAPON) + bIsWeapon = true; + bIsStreetLight = IsLightObject(GetModelIndex()); + + m_area = AREA_EVERYWHERE; } bool @@ -395,3 +406,18 @@ CObject::DeleteAllTempObjectsInArea(CVector point, float fRadius) } } } + +bool +IsObjectPointerValid(CObject* pObject) +{ + if (!pObject) + return false; + int index = CPools::GetObjectPool()->GetJustIndex(pObject); +#ifdef FIX_BUGS + if (index < 0 || index >= CPools::GetObjectPool()->GetSize()) +#else + if (index < 0 || index > CPools::GetObjectPool()->GetSize()) +#endif + return false; + return pObject->bIsBIGBuilding || pObject->m_entryInfoList.first; +} diff --git a/src/objects/Object.h b/src/objects/Object.h index c9a1bba8..5a9c0195 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -25,13 +25,29 @@ enum CollisionDamageEffect DAMAGE_EFFECT_NONE, DAMAGE_EFFECT_CHANGE_MODEL, DAMAGE_EFFECT_SPLIT_MODEL, - DAMAGE_EFFECT_SMASH_COMPLETELY, + DAMAGE_EFFECT_SMASH_AND_DAMAGE_TRAFFICLIGHTS, + + DAMAGE_EFFECT_SMASH_COMPLETELY = 20, DAMAGE_EFFECT_CHANGE_THEN_SMASH, DAMAGE_EFFECT_SMASH_CARDBOARD_COMPLETELY = 50, + DAMAGE_EFFECT_SMASH_YELLOW_TARGET_COMPLETELY, + DAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY = 60, DAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY = 70, - DAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY = 80 + DAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY = 80, + + DAMAGE_EFFECT_SMASH_NEWSTANDNEW1 = 91, + DAMAGE_EFFECT_SMASH_NEWSTANDNEW21, + DAMAGE_EFFECT_SMASH_NEWSTANDNEW31, + DAMAGE_EFFECT_SMASH_NEWSTANDNEW41, + DAMAGE_EFFECT_SMASH_NEWSTANDNEW51, + + DAMAGE_EFFECT_SMASH_BLACKBAG = 100, + DAMAGE_EFFECT_SMASH_VEGPALM = 110, + DAMAGE_EFFECT_BURST_BEACHBALL = 120, + DAMAGE_EFFECT_SMASH_BEACHLOUNGE_WOOD = 131, + DAMAGE_EFFECT_SMASH_BEACHLOUNGE_TOWEL, }; class CVehicle; @@ -43,18 +59,22 @@ public: CMatrix m_objectMatrix; float m_fUprootLimit; int8 ObjectCreatedBy; - int8 bIsPickup : 1; - int8 bPickupObjWithMessage : 1; - int8 bOutOfStock : 1; - int8 bGlassCracked : 1; - int8 bGlassBroken : 1; - int8 bHasBeenDamaged : 1; - int8 bUseVehicleColours : 1; + uint8 bIsPickup : 1; + uint8 obj_flag_02 : 1; + uint8 bPickupObjWithMessage : 1; + uint8 bOutOfStock : 1; + uint8 bGlassCracked : 1; + uint8 bGlassBroken : 1; + uint8 bHasBeenDamaged : 1; + uint8 bUseVehicleColours : 1; + uint8 bIsWeapon : 1; + uint8 bIsStreetLight : 1; int8 m_nBonusValue; float m_fCollisionDamageMultiplier; uint8 m_nCollisionDamageEffect; uint8 m_nSpecialCollisionResponseCases; bool m_bCameraToAvoidThisObject; + int8 m_nBeachballBounces; uint32 m_obj_unused1; uint32 m_nEndOfLifeTime; int16 m_nRefModelIndex; @@ -63,7 +83,7 @@ public: int8 m_colour1, m_colour2; static int16 nNoTempObjects; - static int16 nBodyCastHealth; + static float fDistToNearestTree; static void *operator new(size_t); static void *operator new(size_t, int); @@ -91,4 +111,4 @@ public: static void DeleteAllTempObjectsInArea(CVector point, float fRadius); }; -VALIDATE_SIZE(CObject, 0x198); +bool IsObjectPointerValid(CObject* pObject); |