From 4615f37f592d99c034d593617540fbd6d4567f31 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 22 Apr 2016 13:22:45 -0700 Subject: [PATCH] Various imps --- Runtime/AutoMapper/CMapWorldInfo.cpp | 5 ++ Runtime/AutoMapper/CMapWorldInfo.hpp | 7 +- Runtime/CStateManager.cpp | 2 +- Runtime/CStateManager.hpp | 4 +- Runtime/Character/CAnimPlaybackParms.hpp | 27 +++++++ Runtime/Character/CMakeLists.txt | 1 + Runtime/Character/CModelData.hpp | 3 + Runtime/Collision/CCollisionPrimitive.hpp | 6 +- Runtime/Collision/CGameCollision.cpp | 1 + Runtime/Collision/CMakeLists.txt | 4 +- Runtime/Collision/CMaterialFilter.hpp | 16 ++++ Runtime/Collision/CMaterialList.hpp | 88 +++++++++++++++++++- Runtime/Collision/CRayCastResult.cpp | 2 + Runtime/Collision/CRayCastResult.hpp | 30 +++++++ Runtime/Particle/CVectorElement.cpp | 14 +++- Runtime/World/CActor.cpp | 78 +++++++++++++++++- Runtime/World/CActor.hpp | 97 +++++++++++++++-------- Runtime/World/CActorParameters.hpp | 2 + Runtime/World/CEntity.cpp | 6 +- Runtime/World/CEntity.hpp | 11 ++- Runtime/World/CPhysicsActor.cpp | 9 ++- Runtime/World/CPhysicsActor.hpp | 78 +++++++++--------- Runtime/World/CScriptActor.cpp | 4 +- Runtime/World/CScriptActor.hpp | 2 +- Runtime/World/CScriptDock.cpp | 6 +- Runtime/World/CScriptDoor.cpp | 84 ++++++++++++++++---- Runtime/World/CScriptDoor.hpp | 42 +++++++++- Runtime/World/CScriptEffect.cpp | 2 +- Runtime/World/CScriptGrapplePoint.cpp | 7 +- Runtime/World/CScriptPlatform.cpp | 14 ++-- Runtime/World/CScriptPlatform.hpp | 2 +- Runtime/World/CScriptSound.cpp | 2 +- Runtime/World/CScriptTrigger.cpp | 2 +- Runtime/World/CScriptWaypoint.cpp | 2 +- Runtime/World/CVisorParameters.hpp | 8 +- Runtime/World/ScriptLoader.cpp | 12 +-- 36 files changed, 536 insertions(+), 144 deletions(-) create mode 100644 Runtime/Character/CAnimPlaybackParms.hpp create mode 100644 Runtime/Collision/CMaterialFilter.hpp create mode 100644 Runtime/Collision/CRayCastResult.cpp create mode 100644 Runtime/Collision/CRayCastResult.hpp diff --git a/Runtime/AutoMapper/CMapWorldInfo.cpp b/Runtime/AutoMapper/CMapWorldInfo.cpp index 9c5aab606..d8bff39f6 100644 --- a/Runtime/AutoMapper/CMapWorldInfo.cpp +++ b/Runtime/AutoMapper/CMapWorldInfo.cpp @@ -3,4 +3,9 @@ namespace urde { +void CMapWorldInfo::SetDoorVisited(TEditorId eid, bool visited) +{ + x14_[eid] = visited; +} + } diff --git a/Runtime/AutoMapper/CMapWorldInfo.hpp b/Runtime/AutoMapper/CMapWorldInfo.hpp index d029f650a..ba82bf9c5 100644 --- a/Runtime/AutoMapper/CMapWorldInfo.hpp +++ b/Runtime/AutoMapper/CMapWorldInfo.hpp @@ -1,13 +1,16 @@ #ifndef __URDE_CMAPWORLDINFO_HPP__ #define __URDE_CMAPWORLDINFO_HPP__ +#include "RetroTypes.hpp" + namespace urde { - class CMapWorldInfo { + std::map x14_; +public: + void SetDoorVisited(TEditorId eid, bool val); }; - } #endif // __URDE_CMAPWORLDINFO_HPP__ diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 635bf32b5..c9942f4db 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -300,7 +300,7 @@ void CStateManager::GetBuildForScript(TEditorId) const { } -void CStateManager::GetEditorIdForUniqueId() const +TEditorId CStateManager::GetEditorIdForUniqueId(TUniqueId) const { } diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 0f30ec559..10d3216ee 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -168,7 +168,7 @@ public: void SendScriptMsg(TUniqueId uid, TEditorId eid, EScriptObjectMessage msg, EScriptObjectState state); void FreeScriptObjects(TAreaId); void GetBuildForScript(TEditorId) const; - void GetEditorIdForUniqueId() const; + TEditorId GetEditorIdForUniqueId(TUniqueId) const; TUniqueId GetIdForScript(TEditorId) const; void GetIdListForScript(TEditorId) const; void LoadScriptObjects(TAreaId, CInputStream& in, EScriptPersistence); @@ -233,6 +233,8 @@ public: CCameraFilterPass& GetCameraFilterPass(int idx) {return xaf8_camFilterPasses[idx];} CWorld* GetWorld() {return x850_world.get();} + + std::shared_ptr MapWorldInfo() { return x8c0_mapWorldInfo; } }; } diff --git a/Runtime/Character/CAnimPlaybackParms.hpp b/Runtime/Character/CAnimPlaybackParms.hpp new file mode 100644 index 000000000..ba57a5086 --- /dev/null +++ b/Runtime/Character/CAnimPlaybackParms.hpp @@ -0,0 +1,27 @@ +#ifndef __CANIMPLAYBACKPARMS_HPP__ +#define __CANIMPLAYBACKPARMS_HPP__ + +#include "RetroTypes.hpp" + +namespace urde +{ +class CAnimPlaybackParms +{ + s32 x0_; + s32 x4_; + float x8_; + bool xc_; + s32 x10_ = 0; + s32 x14_ = 0; + bool x28_ = false; + s32 x2c_ = 0; + s32 x30_ = 0; + s32 x34_ = 0; +public: + CAnimPlaybackParms(s32 a, s32 b, float c, bool d) + : x0_(a), x4_(b), xc_(c), x10_(d) + {} +}; +} + +#endif // CANIMPLAYBACKPARMS_HPP diff --git a/Runtime/Character/CMakeLists.txt b/Runtime/Character/CMakeLists.txt index 471eabad5..b0879aeac 100644 --- a/Runtime/Character/CMakeLists.txt +++ b/Runtime/Character/CMakeLists.txt @@ -55,6 +55,7 @@ add_library(RuntimeCommonCharacter CAnimTreeTweenBase.hpp CAnimTreeTweenBase.cpp CAnimTreeSingleChild.hpp CAnimTreeSingleChild.cpp CAnimTreeDoubleChild.hpp CAnimTreeDoubleChild.cpp + CAnimPlaybackParms.hpp IAnimReader.hpp IAnimReader.cpp CPrimitive.hpp CPrimitive.cpp CHalfTransition.hpp CHalfTransition.cpp diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index 5d94a832c..bc3756234 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -38,6 +38,7 @@ struct CAnimRes class CModelData { + friend class CActor; zeus::CVector3f x0_particleScale; std::unique_ptr xc_animData; union @@ -101,6 +102,8 @@ public: const CActorLights* lights, const CModelFlags& drawFlags) const; void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags) const; + + std::unique_ptr& AnimationData() { return xc_animData; } }; } diff --git a/Runtime/Collision/CCollisionPrimitive.hpp b/Runtime/Collision/CCollisionPrimitive.hpp index 1aef97b39..01627cb3e 100644 --- a/Runtime/Collision/CCollisionPrimitive.hpp +++ b/Runtime/Collision/CCollisionPrimitive.hpp @@ -1,11 +1,13 @@ #ifndef __URDE_CCOLLISIONPRIMITIVE_HPP__ #define __URDE_CCOLLISIONPRIMITIVE_HPP__ +#include "Collision/CMaterialList.hpp" namespace urde { class CCollisionPrimitive { + CMaterialList x8_material; public: enum class Type { @@ -14,10 +16,6 @@ public: static void InitBeginTypes(); static void InitAddType(Type tp); static void InitEndTypes(); - - static void InitBeginColliders(); - static void InitAddCollider(Type tp); - static void InitEndTypes(); }; } diff --git a/Runtime/Collision/CGameCollision.cpp b/Runtime/Collision/CGameCollision.cpp index e69de29bb..4abd80232 100644 --- a/Runtime/Collision/CGameCollision.cpp +++ b/Runtime/Collision/CGameCollision.cpp @@ -0,0 +1 @@ +#include "CMaterialFilter.hpp" diff --git a/Runtime/Collision/CMakeLists.txt b/Runtime/Collision/CMakeLists.txt index 60d9fa400..74a6867aa 100644 --- a/Runtime/Collision/CMakeLists.txt +++ b/Runtime/Collision/CMakeLists.txt @@ -3,4 +3,6 @@ add_library(RuntimeCommonCollision CCollisionInfo.hpp CCollisionInfo.cpp CCollidableOBBTree.hpp CCollidableOBBTree.cpp CCollidableOBBTreeGroup.hpp CCollidableOBBTreeGroup.cpp - CMaterialList.hpp) + CMaterialList.hpp + CMaterialFilter.hpp + CRayCastResult.hpp CRayCastResult.cpp) diff --git a/Runtime/Collision/CMaterialFilter.hpp b/Runtime/Collision/CMaterialFilter.hpp new file mode 100644 index 000000000..378bab8c1 --- /dev/null +++ b/Runtime/Collision/CMaterialFilter.hpp @@ -0,0 +1,16 @@ +#ifndef __URDE_CMATERIALFILTER_HPP__ +#define __URDE_CMATERIALFILTER_HPP__ + +#include "CMaterialList.hpp" +#include "zeus/Math.hpp" +namespace urde +{ +class CMaterialFilter +{ + CMaterialList x0_; + CMaterialList x8_; + u32 x10_ = 0; +public: +}; +} +#endif // __CMATERIALFILTER_HPP__ diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index fbbdffa89..668ee75c3 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -5,13 +5,97 @@ namespace urde { +enum class EMaterialTypes +{ + Six = 6, + Eight = 8, + Ten = 10, + Eleven = 11, + Twelve = 12, + Thirten = 13, + Fourteen = 14, + Fifteen = 15, + Nineteen = 19, + ThirtyTwo = 32, + ThirtyFour = 34, + FourtyOne = 41, + FourtyTwo = 42, + FourtyThree = 43, + FourtyEight = 48, + FourtyNine = 49, + SixtyThree = 63 +}; class CMaterialList { -public: + friend class CMaterialFilter; u64 x0_ = 0; +public: CMaterialList() = default; - CMaterialList(int idx) : x0_(1ull << idx) {} + CMaterialList(u64 flags) : x0_(flags) {} + CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5, EMaterialTypes t6) + : CMaterialList(t1, t2, t3, t4, t5) + { x0_ = 1ull << u64(t6); } + + CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5) + : CMaterialList(t1, t2, t3, t4) + { x0_ = 1ull << u64(t5); } + + CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4) + : CMaterialList(t1, t2, t3) + { x0_ = 1ull << u64(t4); } + + CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3) + : CMaterialList(t1, t2) + { x0_ = 1ull << u64(t3); } + + CMaterialList(EMaterialTypes t1, EMaterialTypes t2) + : CMaterialList(t1) + { x0_ = 1ull << u64(t2); } + + CMaterialList(EMaterialTypes t1) + : x0_(1ull << u64(t1)) + { + } + + static u32 BitPosition(u64 flag) + { + for (u32 i = 0; i < 63; ++i) + if ((flag & (1ull << i)) != 0) + return i; + return -1; + } + + void Add(EMaterialTypes type) + { + x0_ |= (1ull << u64(type)); + } + + void Remove(EMaterialTypes type) + { + x0_ &= ~(1ull << u64(type)); + } + + void Remove(const CMaterialList& other) + { + x0_ &= ~(other.x0_); + } + + bool HasMaterial(EMaterialTypes type) + { + return (x0_ & (1ull << u64(type))) != 0; + } + + bool SharesMaterials(const CMaterialList& other) + { + for (u32 i = 0; i < 64; i++) + { + if ((x0_ & (1ull << i)) != 0 && (other.x0_ & (1ull << i)) != 0) + return true; + } + + return false; + } }; } diff --git a/Runtime/Collision/CRayCastResult.cpp b/Runtime/Collision/CRayCastResult.cpp new file mode 100644 index 000000000..9f1387afe --- /dev/null +++ b/Runtime/Collision/CRayCastResult.cpp @@ -0,0 +1,2 @@ +#include "CRayCastResult.hpp" + diff --git a/Runtime/Collision/CRayCastResult.hpp b/Runtime/Collision/CRayCastResult.hpp new file mode 100644 index 000000000..d816ee7cd --- /dev/null +++ b/Runtime/Collision/CRayCastResult.hpp @@ -0,0 +1,30 @@ +#ifndef __URDE_CRAYCASTRESULT_HPP__ +#define __URDE_CRAYCASTRESULT_HPP__ + +#include "CMaterialList.hpp" +#include "zeus/zeus.hpp" + +namespace urde +{ +class CRayCastResult +{ +public: + enum class EInvalid + { + Zero, + One + }; +private: + EInvalid invalid = EInvalid::Zero; + zeus::CVector3f x4_; + zeus::CVector3f x10_; + CMaterialList x28_material; +public: + CRayCastResult(); + CRayCastResult(float, const zeus::CVector3f&, const zeus::CPlane, const CMaterialList& matList) + : x28_material(matList) + {} +}; +} + +#endif // __URDE_CRAYCASTRESULT_HPP__ diff --git a/Runtime/Particle/CVectorElement.cpp b/Runtime/Particle/CVectorElement.cpp index 5aab74fdf..698871008 100644 --- a/Runtime/Particle/CVectorElement.cpp +++ b/Runtime/Particle/CVectorElement.cpp @@ -285,22 +285,28 @@ bool CVEParticleLocation::GetValue(int /*frame*/, zeus::CVector3f& valOut) const bool CVEParticleSystemOrientationFront::GetValue(int /*frame*/, zeus::CVector3f& valOut) const { - /* TODO: Get front vector */ zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation(); + valOut.x = trans.m_basis.vec[1].x; + valOut.y = trans.m_basis.vec[2].y; + valOut.z = trans.m_origin.z; return false; } bool CVEParticleSystemOrientationUp::GetValue(int /*frame*/, zeus::CVector3f& valOut) const { - /* TODO: Get up vector */ zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation(); + valOut.x = trans.m_basis.vec[2].x; + valOut.y = trans.m_basis.vec[0].z; + valOut.z = trans.m_origin.y; return false; } bool CVEParticleSystemOrientationRight::GetValue(int /*frame*/, zeus::CVector3f& valOut) const { - /* TODO: Get right vector */ - zeus::CTransform trans= CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation(); + zeus::CTransform trans = CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation(); + valOut.x = trans.m_basis.vec[0].x; + valOut.y = trans.m_basis.vec[1].y; + valOut.z = trans.m_basis.vec[2].z; return false; } diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 07005e9a4..f8fd0ffdd 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -1,13 +1,83 @@ #include "CActor.hpp" +#include "CActorParameters.hpp" +#include "CStateManager.hpp" +#include "Collision/CMaterialList.hpp" namespace urde { -CActor::CActor(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, - const zeus::CTransform&, const CModelData&, const CMaterialList&, - const CActorParameters&, TUniqueId) -: CEntity(uid, info, active, name) +static CMaterialList MakeActorMaterialList(const CMaterialList& materialList, const CActorParameters& params) { + CMaterialList ret = materialList; + if (params.GetVisorParameters().x0_28_b3) + ret.Add(EMaterialTypes::Fourteen); + if (params.GetVisorParameters().x0_29_b4) + ret.Add(EMaterialTypes::Fifteen); + return ret; +} + +CActor::CActor(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, + const zeus::CTransform&, CModelData&& mData, const CMaterialList& list, + const CActorParameters& params, TUniqueId) +: CEntity(uid, info, active, name), + x68_(MakeActorMaterialList(list, params)), + x70_(EMaterialTypes::Nineteen) +{ + if (mData.x1c_normalModel) + x64_modelData = std::make_unique(std::move(mData)); +} + +void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, CStateManager& mgr) +{ + x68_.Remove(t1); + RemoveMaterial(t2, t3, t4, mgr); +} + +void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, CStateManager & mgr) +{ + x68_.Remove(t1); + RemoveMaterial(t2, t3, mgr); +} + +void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, CStateManager& mgr) +{ + x68_.Remove(t1); +} + +void CActor::RemoveMaterial(EMaterialTypes t, CStateManager& mgr) +{ + x68_.Remove(t); + mgr.UpdateObjectInLists(*this); +} + +void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5, CStateManager& mgr) +{ + x68_.Add(t1); + AddMaterial(t2, t3, t4, t5, mgr); +} + +void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, CStateManager& mgr) +{ + x68_.Add(t1); + AddMaterial(t2, t3, t4, mgr); +} + +void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, CStateManager& mgr) +{ + x68_.Add(t1); + AddMaterial(t2, t3, mgr); +} + +void CActor::AddMaterial(EMaterialTypes t1, EMaterialTypes t2, CStateManager& mgr) +{ + x68_.Add(t1); + AddMaterial(t2, mgr); +} + +void CActor::AddMaterial(EMaterialTypes type, CStateManager& mgr) +{ + x68_.Add(type); + mgr.UpdateObjectInLists(*this); } } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 4997c9e8a..295bbe44e 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -3,6 +3,8 @@ #include "CEntity.hpp" #include "zeus/zeus.hpp" +#include "Collision/CMaterialList.hpp" +#include "Character/CModelData.hpp" namespace urde { @@ -12,12 +14,6 @@ enum class ECollisionResponseType Unknown12 = 0xC, }; -enum class EMaterialTypes -{ -}; - -class CModelData; -class CMaterialList; class CActorParameters; class CWeaponMode; class CHealthInfo; @@ -35,51 +31,88 @@ protected: }; zeus::CTransform x34_transform; - float x40_unknown; - float x50_unknown; - float x60_unknown; - u32 x68_unknown; - u32 x6c_unknown; - bool xd0_b0_flags : 1; - bool xd0_b1_flags : 1; - bool xd0_b2_flags : 1; + std::unique_ptr x64_modelData; + CMaterialList x68_; + CMaterialList x70_; + union + { + struct + { + bool xe4_27_ : 1; + bool xe4_28_ : 1; + bool xe4_29_ : 1; + bool xe5_0_opaque : 1; + bool xe5_26_muted : 1; + bool xe5_27_useInSortedLists : 1; + bool xe5_28_callTouch : 1; + }; + u32 dummy1 = 0; + }; + + union + { + struct + { + bool xe7_29_ : 1; + }; + u32 dummy2 = 0; + }; public: CActor(TUniqueId, bool, const std::string&, const CEntityInfo&, - const zeus::CTransform&, const CModelData&, const CMaterialList&, + const zeus::CTransform&, CModelData&&, const CMaterialList&, const CActorParameters&, TUniqueId); - virtual void Accept(IVisitor&); + virtual void Accept(IVisitor&) /*= 0*/; virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) {} + virtual void SetActive(bool active) + { + xe4_27_ = true; + xe4_28_ = true; + xe4_29_ = true; + xe7_29_ = true; + CEntity::SetActive(active); + } + virtual zeus::CVector3f GetAimPosition(const CStateManager&, float) - { return zeus::CVector3f(x40_unknown, x50_unknown, x60_unknown); } + { return x34_transform.m_origin; } virtual bool ValidAimTarget() { return true; } virtual bool ValidOrbitTarget() { return true; } virtual bool GetOrbitDistanceCheck() { return true; } virtual zeus::CVector3f GetOrbitPosition() - { return zeus::CVector3f(x40_unknown, x50_unknown, x60_unknown); } + { return x34_transform.m_origin; } virtual ECollisionResponseType GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, int) { return ECollisionResponseType::Unknown12; } - void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&){} - void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&){ } - void RemoveMaterial(EMaterialTypes, EMaterialTypes, CStateManager&){ } - void RemoveMaterial(EMaterialTypes, CStateManager&){ } - void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&){ } - void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&){} - void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&){ } - void AddMaterial(EMaterialTypes, EMaterialTypes, CStateManager&){ } - void AddMaterial(EMaterialTypes, CStateManager&){ } + void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); + void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); + void RemoveMaterial(EMaterialTypes, EMaterialTypes, CStateManager&); + void RemoveMaterial(EMaterialTypes, CStateManager&); + void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); + void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); + void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); + void AddMaterial(EMaterialTypes, EMaterialTypes, CStateManager&); + void AddMaterial(EMaterialTypes, CStateManager&); - virtual void SetActive(bool active) + void SetCallTouch(bool callTouch) { - //xd0_flags |= (Unknown5 | Unknown6 | Unknown7); - CEntity::SetActive(active); + xe5_28_callTouch = callTouch; } - virtual void SetCallTouch(bool callTouch) + bool GetCallTouch() const { - //xd1_flags = Unknown6 + return xe5_28_callTouch; } + + void SetUseInSortedList(bool use) + { + xe5_27_useInSortedLists = use; + } + + bool GetUseInSortedLists() const + { + return xe5_27_useInSortedLists; + } + }; } diff --git a/Runtime/World/CActorParameters.hpp b/Runtime/World/CActorParameters.hpp index dceb8d8e7..bf5f23108 100644 --- a/Runtime/World/CActorParameters.hpp +++ b/Runtime/World/CActorParameters.hpp @@ -30,6 +30,8 @@ public: x44_xrayAssets(xrayAssets), x4c_thermalAssets(thermalAssets), x54_visorParms(visorParms), b1(a), b2(b), b3(c), b4(d) {} static CActorParameters None() {return CActorParameters();} + + CVisorParameters GetVisorParameters() const { return x54_visorParms; } }; } diff --git a/Runtime/World/CEntity.cpp b/Runtime/World/CEntity.cpp index 6d815f25c..21d32ab7b 100644 --- a/Runtime/World/CEntity.cpp +++ b/Runtime/World/CEntity.cpp @@ -3,10 +3,11 @@ namespace urde { +const std::vector CEntity::NullConnectionList; CEntity::CEntity(TUniqueId uniqueId, const CEntityInfo& info, bool active, const std::string& name) -: x4_areaId(info.x0_areaId), x8_uid(uniqueId), xc_savwId(info.x14_savwId), x10_name(name), - x20_conns(info.x4_conns), x30_24_active(active) {} +: x4_areaId(info.GetAreaId()), x8_uid(uniqueId), xc_editorId(info.GetEditorId()), x10_name(name), + x20_conns(info.GetConnectionList()), x30_24_active(active) {} void CEntity::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) { @@ -48,5 +49,4 @@ void CEntity::SendScriptMsgs(EScriptObjectState state, CStateManager& stateMgr, if (conn.x0_state == state && conn.x4_msg != skipMsg) stateMgr.SendScriptMsg(x8_uid, conn.x8_objId, conn.x4_msg, state); } - } diff --git a/Runtime/World/CEntity.hpp b/Runtime/World/CEntity.hpp index 65d2a7e14..e91cfd578 100644 --- a/Runtime/World/CEntity.hpp +++ b/Runtime/World/CEntity.hpp @@ -18,14 +18,15 @@ struct SConnection class CEntityInfo { - friend class CEntity; TAreaId x0_areaId; std::vector x4_conns; - ResId x14_savwId; + TEditorId x14_editorId; public: CEntityInfo(TAreaId aid, const std::vector& conns, ResId savwId=-1) : x0_areaId(aid), x4_conns(conns) {} TAreaId GetAreaId() const {return x0_areaId;} + std::vector GetConnectionList() const { return x4_conns; } + ResId GetEditorId() const { return x14_editorId; } }; class CEntity @@ -33,7 +34,7 @@ class CEntity protected: TAreaId x4_areaId; TUniqueId x8_uid; - ResId xc_savwId; + ResId xc_editorId; std::string x10_name; std::vector x20_conns; @@ -49,15 +50,17 @@ protected: }; public: + static const std::vector NullConnectionList; virtual ~CEntity() {} CEntity(TUniqueId uid, const CEntityInfo& info, bool active, const std::string& name); virtual void Accept(IVisitor&)=0; virtual void PreThink(float, CStateManager&) {} virtual void Think(float, CStateManager&) {} virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); - virtual bool GetActive() const {return x30_24_active;} + bool GetActive() const {return x30_24_active;} virtual void SetActive(bool active) {x30_24_active = active;} + TAreaId GetAreaId() const { return x4_areaId; } TUniqueId GetUniqueId() const {return x8_uid;} void SendScriptMsgs(EScriptObjectState state, CStateManager& stateMgr, EScriptObjectMessage msg); }; diff --git a/Runtime/World/CPhysicsActor.cpp b/Runtime/World/CPhysicsActor.cpp index 01f8be3fe..46e9c33ff 100644 --- a/Runtime/World/CPhysicsActor.cpp +++ b/Runtime/World/CPhysicsActor.cpp @@ -4,11 +4,16 @@ namespace urde { CPhysicsActor::CPhysicsActor(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, - const zeus::CTransform& xf, const CModelData& mData, const CMaterialList& matList, + const zeus::CTransform& xf, CModelData&& mData, const CMaterialList& matList, const zeus::CAABox& box, const SMoverData& moverData, const CActorParameters& actorParms, float, float) -: CActor(uid, active, name, info, xf, mData, matList, actorParms, kInvalidUniqueId) + : CActor(uid, active, name, info, xf, std::move(mData), matList, actorParms, kInvalidUniqueId) { } +zeus::CAABox CPhysicsActor::GetBoundingBox() +{ + zeus::CAABox ret; +} + } diff --git a/Runtime/World/CPhysicsActor.hpp b/Runtime/World/CPhysicsActor.hpp index ed81f7ed9..74cabfef5 100644 --- a/Runtime/World/CPhysicsActor.hpp +++ b/Runtime/World/CPhysicsActor.hpp @@ -2,21 +2,13 @@ #define __URDE_CPHYSICSACTOR_HPP__ #include "CActor.hpp" +#include "Collision/CCollisionPrimitive.hpp" namespace urde { +class CCollisionInfoList; struct SMoverData; -class CCollisionPrimitive -{ -public: - zeus::CVector3f x1d8_offset; -}; - -class CCollisionInfoList -{ -}; - struct SMoverData { zeus::CVector3f x0_; @@ -31,33 +23,34 @@ struct SMoverData class CPhysicsActor : public CActor { protected: - float xd8_mass; - float xdc_massRecip; - float xe0_inertialTensor; - float xe4_inertialTensorRecip; - zeus::CAABox x194_baseBoundingBox; - CCollisionPrimitive x1b0_collisionPrimitive; - float x228_stepUpHeight; - float x22c_stepDownHeight; - float x230_restitutionCoefModifier; - float x234_collisionAccuracyModifier; + float xe8_mass; + float xec_massRecip; + float xf0_inertialTensor; + float xf4_inertialTensorRecip; + zeus::CAABox x1a4_baseBoundingBox; + CCollisionPrimitive x1c0_collisionPrimitive; + zeus::CVector3f x1e8_primitiveOffset; + float x23c_stepUpHeight; + float x240_stepDownHeight; + float x244_restitutionCoefModifier; + float x248_collisionAccuracyModifier; public: CPhysicsActor(TUniqueId, bool, const std::string&, const CEntityInfo&, - const zeus::CTransform&, const CModelData&, const CMaterialList&, + const zeus::CTransform&, CModelData&&, const CMaterialList&, const zeus::CAABox&, const SMoverData&, const CActorParameters&, float, float); float GetCollisionAccuracyModifier() - { return x234_collisionAccuracyModifier; } + { return x248_collisionAccuracyModifier; } void SetCollisionAccuracyModifier(float modifier) - { x234_collisionAccuracyModifier = modifier; } + { x248_collisionAccuracyModifier = modifier; } float GetCoefficientOfRestitutionModifier() - { return x230_restitutionCoefModifier; } + { return x244_restitutionCoefModifier; } void SetCoefficientOfRestitutionModifier(float modifier) - { x230_restitutionCoefModifier = modifier;} + { x244_restitutionCoefModifier = modifier;} void DrawCollisionPrimitive() { } @@ -77,31 +70,38 @@ public: { return GetBoundingBox().center(); } float GetStepUpHeight() - { return x228_stepUpHeight; } + { return x23c_stepUpHeight; } float GetStepDownHeight() - { return x22c_stepDownHeight; } + { return x240_stepDownHeight; } void SetPrimitiveOffset(const zeus::CVector2f& offset) - { x1b0_collisionPrimitive.x1d8_offset = offset; } + { x1e8_primitiveOffset = offset; } zeus::CVector3f GetPrimitiveOffset() - { return x1b0_collisionPrimitive.x1d8_offset; } + { return x1e8_primitiveOffset; } float GetWeight() - { return 24.525002f * xd8_mass; } + { return 24.525002f * xe8_mass; } + + void MoveCollisionPrimitive(const zeus::CVector3f& offset) + { + x1e8_primitiveOffset = offset; + } void SetBoundingBox(const zeus::CAABox& box) - { x194_baseBoundingBox = box; } + { + x1a4_baseBoundingBox = box; + MoveCollisionPrimitive(zeus::CVector3f::skZero); + } zeus::CAABox GetMotionVolume() { return zeus::CAABox::skInvertedBox; } - zeus::CAABox GetBoundingBox() - { return zeus::CAABox::skInvertedBox; } + zeus::CAABox GetBoundingBox(); const zeus::CAABox& GetBaseBoundingBox() const - { return x194_baseBoundingBox; } + { return x1a4_baseBoundingBox; } void CollidedWith(const TUniqueId&, const CCollisionInfoList&, CStateManager&) {} @@ -112,24 +112,24 @@ public: } const CCollisionPrimitive& GetCollisionPrimitive() const - { return x1b0_collisionPrimitive; } + { return x1c0_collisionPrimitive; } void SetInertiaTensorScalar(float tensor) { if (tensor <= 0.0f) tensor = 1.0f; - xe0_inertialTensor = tensor; - xe4_inertialTensorRecip = 1.0f / tensor; + xf0_inertialTensor = tensor; + xf4_inertialTensorRecip = 1.0f / tensor; } void SetMass(float mass) { - xd8_mass = mass; + xe8_mass = mass; float tensor = 1.0f; if (mass > 0.0f) tensor = 1.0f / mass; - xdc_massRecip = tensor; + xec_massRecip = tensor; SetInertiaTensorScalar(mass * tensor); } }; diff --git a/Runtime/World/CScriptActor.cpp b/Runtime/World/CScriptActor.cpp index 0f079a517..8b05d0a82 100644 --- a/Runtime/World/CScriptActor.cpp +++ b/Runtime/World/CScriptActor.cpp @@ -4,10 +4,10 @@ namespace urde { CScriptActor::CScriptActor(TUniqueId uid, const std::string& name, const CEntityInfo& info, - const zeus::CTransform& xf, const CModelData& mData, const zeus::CAABox& aabb, float a, float, + const zeus::CTransform& xf, CModelData&& mData, const zeus::CAABox& aabb, float a, float, const CMaterialList& matList, const CHealthInfo&, const CDamageVulnerability&, const CActorParameters& actParms, bool, bool active, u32, float, bool, bool, bool, bool) -: CPhysicsActor(uid, active, name, info, xf, mData, matList, aabb, SMoverData(a), actParms, 0.3f, 0.1f) + : CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(a), actParms, 0.3f, 0.1f) { } diff --git a/Runtime/World/CScriptActor.hpp b/Runtime/World/CScriptActor.hpp index 366fe76a7..35639cb8c 100644 --- a/Runtime/World/CScriptActor.hpp +++ b/Runtime/World/CScriptActor.hpp @@ -10,7 +10,7 @@ class CScriptActor : public CPhysicsActor { public: CScriptActor(TUniqueId, const std::string&, const CEntityInfo&, - const zeus::CTransform&, const CModelData&, const zeus::CAABox& aabb, float, float, + const zeus::CTransform&, CModelData&&, const zeus::CAABox& aabb, float, float, const CMaterialList& matList, const CHealthInfo&, const CDamageVulnerability&, const CActorParameters&, bool, bool, u32, float, bool, bool, bool, bool); }; diff --git a/Runtime/World/CScriptDock.cpp b/Runtime/World/CScriptDock.cpp index 1d2a49b25..975a5cda8 100644 --- a/Runtime/World/CScriptDock.cpp +++ b/Runtime/World/CScriptDock.cpp @@ -8,9 +8,9 @@ namespace urde CMaterialList MakeDockMaterialList() { CMaterialList list; - list.x0_ |= (1ull << 34); - list.x0_ |= (1ull << 43); - list.x0_ |= (1ull << 48); + list.Add(EMaterialTypes::ThirtyFour); + list.Add(EMaterialTypes::FourtyThree); + list.Add(EMaterialTypes::FourtyEight); return list; } diff --git a/Runtime/World/CScriptDoor.cpp b/Runtime/World/CScriptDoor.cpp index e1813d725..2ae408a91 100644 --- a/Runtime/World/CScriptDoor.cpp +++ b/Runtime/World/CScriptDoor.cpp @@ -1,5 +1,9 @@ #include "CScriptDoor.hpp" #include "Collision/CMaterialList.hpp" +#include "Character/CAnimData.hpp" +#include "Character/CAnimPlaybackParms.hpp" +#include "AutoMapper/CMapWorldInfo.hpp" +#include "CStateManager.hpp" namespace urde { @@ -7,30 +11,82 @@ namespace urde static CMaterialList MakeDoorMaterialList(bool material) { CMaterialList ret; + ret.Add(EMaterialTypes::Nineteen); + ret.Add(EMaterialTypes::FourtyThree); + ret.Add(EMaterialTypes::FourtyOne); if (material) - { - ret.x0_ |= 1ull << 19; - ret.x0_ |= 1ull << 43; - ret.x0_ |= 1ull << 41; - } - else - { - ret.x0_ |= 1ull << 43; - ret.x0_ |= 1ull << 42; - ret.x0_ |= 1ull << 19; - ret.x0_ |= 1ull << 41; - } + ret.Add(EMaterialTypes::FourtyTwo); + return ret; } CScriptDoor::CScriptDoor(TUniqueId uid, const std::string& name, const CEntityInfo& info, - const zeus::CTransform& xf, const CModelData& mData, const CActorParameters& actParms, + const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, const zeus::CVector3f&, const zeus::CAABox& aabb, bool active, bool material, bool, float, bool ballDoor) -: CPhysicsActor(uid, active, name, info, xf, mData, MakeDoorMaterialList(material), + : CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakeDoorMaterialList(material), aabb, SMoverData(1.f), actParms, 0.3f, 0.1f) { + x264_ = GetBoundingBox(); +} +void CScriptDoor::ForceClosed(CStateManager & mgr) +{ + if (x2a8_26_) + { + x2a8_26_ = false; + x2a8_25_ = false; + + /* TODO: Figure out what goes here this */ + /* + * mgr->x870->x80_->sub_80083118(x8_uid) + * mgr->x870->x80_->sub_800830F4(x8_uid) + */ + + SetDoorAnimation(EDoorAnimType::One); + SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None); + + x25c_ = 0.f; + x2a8_27_ = false; + x2a8_30_ = false; + } + else if (x2a8_27_) + { + x2a8_27_ = false; + x2a8_30_ = false; + SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None); + } +} + +void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr) +{ + TEditorId eid = mgr.GetEditorIdForUniqueId(uid); + mgr.MapWorldInfo()->SetDoorVisited(eid, true); + + const CScriptDoor* door = dynamic_cast(mgr.GetObjectById(uid)); + + if (door) + x27c_otherId = door->x8_uid; + + SetDoorAnimation(EDoorAnimType::Zero); + if (x27c_otherId != kInvalidUniqueId) + SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None); + else + { + SendScriptMsgs(EScriptObjectState::Open, mgr, EScriptObjectMessage::None); + + /* TODO: Finish this */ + } +} + +void CScriptDoor::SetDoorAnimation(CScriptDoor::EDoorAnimType type) +{ + CModelData* modelData = x64_modelData.get(); + if (x260_doorState == EDoorAnimType::Zero) + return; + + if (modelData->AnimationData()) + modelData->AnimationData()->SetAnimation(CAnimPlaybackParms(0, -1, 1.f, true), false); } } diff --git a/Runtime/World/CScriptDoor.hpp b/Runtime/World/CScriptDoor.hpp index 50e2c0d1a..4001393a5 100644 --- a/Runtime/World/CScriptDoor.hpp +++ b/Runtime/World/CScriptDoor.hpp @@ -8,11 +8,51 @@ namespace urde class CScriptDoor : public CPhysicsActor { +public: + enum class EDoorAnimType + { + Zero, + One, + Two, + Three + }; + + float x25c_; + EDoorAnimType x260_doorState = EDoorAnimType::Zero; + zeus::CAABox x264_; + TUniqueId x27c_otherId = kInvalidUniqueId; + + union + { + struct + { + bool x2a0_25_ : 1; + bool x2a0_26_ : 1; + }; + u32 dummy1 = 0; + }; + + union + { + struct + { + bool x2a8_25_ : 1; + bool x2a8_26_ : 1; + bool x2a8_27_ : 1; + bool x2a8_29_ : 1; + bool x2a8_30_ : 1; + }; + u32 dummy2 = 0; + }; public: CScriptDoor(TUniqueId, const std::string& name, const CEntityInfo& info, - const zeus::CTransform&, const CModelData&, const CActorParameters&, + const zeus::CTransform&, CModelData&&, const CActorParameters&, const zeus::CVector3f&, const zeus::CAABox&, bool active, bool material, bool, float, bool ballDoor); + + void ForceClosed(CStateManager&); + void OpenDoor(TUniqueId, CStateManager&); + void SetDoorAnimation(EDoorAnimType); }; } diff --git a/Runtime/World/CScriptEffect.cpp b/Runtime/World/CScriptEffect.cpp index b430eb8b3..fbac1642e 100644 --- a/Runtime/World/CScriptEffect.cpp +++ b/Runtime/World/CScriptEffect.cpp @@ -11,7 +11,7 @@ CScriptEffect::CScriptEffect(TUniqueId uid, const std::string& name, const CEnti ResId partId, ResId elscId, bool, bool, bool, bool active, bool, float, float, float, float, bool, float, float, float, bool, bool, bool, const CLightParameters& lParms, bool) -: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(0), +: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId) { } diff --git a/Runtime/World/CScriptGrapplePoint.cpp b/Runtime/World/CScriptGrapplePoint.cpp index 1b5d612a9..a793d853c 100644 --- a/Runtime/World/CScriptGrapplePoint.cpp +++ b/Runtime/World/CScriptGrapplePoint.cpp @@ -7,10 +7,11 @@ namespace urde { CScriptGrapplePoint::CScriptGrapplePoint(TUniqueId uid, const std::string &name, const CEntityInfo& info, const zeus::CTransform &transform, bool active, const CGrappleParameters ¶ms) - : CActor(uid, active, name, info, transform, CModelData::CModelDataNull(), CMaterialList(41), CActorParameters::None(), + : CActor(uid, active, name, info, transform, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::FourtyOne), + CActorParameters::None(), kInvalidUniqueId), - xe8_({x40_unknown - 0.5f, x50_unknown - 0.5f, x60_unknown - 0.5f}, - {x40_unknown + 0.5f, x50_unknown + 0.5f, x60_unknown + 0.5f}), + xe8_(x34_transform.m_origin - 0.5f, + x34_transform.m_origin + 0.5f), x100_parameters(params) { } diff --git a/Runtime/World/CScriptPlatform.cpp b/Runtime/World/CScriptPlatform.cpp index 3b260711d..2bfa64d47 100644 --- a/Runtime/World/CScriptPlatform.cpp +++ b/Runtime/World/CScriptPlatform.cpp @@ -7,21 +7,21 @@ namespace urde static CMaterialList MakePlatformMaterialList() { CMaterialList ret; - ret.x0_ |= 1ull << 19; - ret.x0_ |= 1ull << 43; - ret.x0_ |= 1ull << 49; - ret.x0_ |= 1ull << 42; + ret.Add(EMaterialTypes::Nineteen); + ret.Add(EMaterialTypes::FourtyThree); + ret.Add(EMaterialTypes::FourtyNine); + ret.Add(EMaterialTypes::FourtyTwo); return ret; } CScriptPlatform::CScriptPlatform(TUniqueId uid, const std::string& name, const CEntityInfo& info, - const zeus::CTransform& xf, const CModelData& mData, + const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float, bool, float, bool active, const CHealthInfo& hInfo, const CDamageVulnerability& dInfo, const TLockedToken& dcln, bool, u32, u32) -: CPhysicsActor(uid, active, name, info, xf, mData, MakePlatformMaterialList(), - aabb, SMoverData(15000.f), actParms, 0.3f, 0.1f) + : CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakePlatformMaterialList(), + aabb, SMoverData(15000.f), actParms, 0.3f, 0.1f) { } diff --git a/Runtime/World/CScriptPlatform.hpp b/Runtime/World/CScriptPlatform.hpp index d6782e42e..b048a634c 100644 --- a/Runtime/World/CScriptPlatform.hpp +++ b/Runtime/World/CScriptPlatform.hpp @@ -13,7 +13,7 @@ class CScriptPlatform : public CPhysicsActor { public: CScriptPlatform(TUniqueId, const std::string& name, const CEntityInfo& info, - const zeus::CTransform& xf, const CModelData& mData, + const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float, bool, float, bool, const CHealthInfo& hInfo, const CDamageVulnerability& dInfo, const TLockedToken& dcln, bool, u32, u32); diff --git a/Runtime/World/CScriptSound.cpp b/Runtime/World/CScriptSound.cpp index 584134b7e..66c24f767 100644 --- a/Runtime/World/CScriptSound.cpp +++ b/Runtime/World/CScriptSound.cpp @@ -10,7 +10,7 @@ CScriptSound::CScriptSound(TUniqueId uid, const std::string& name, const CEntity const zeus::CTransform& xf, s16 soundId, bool active, float, float, float, u32, u32, u32, u32, u32, bool, bool, bool, bool, bool, bool, bool, bool, u32) : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), - CMaterialList(0), CActorParameters::None(), kInvalidUniqueId) + CMaterialList(), CActorParameters::None(), kInvalidUniqueId) { } diff --git a/Runtime/World/CScriptTrigger.cpp b/Runtime/World/CScriptTrigger.cpp index d1caa19ad..b3cad839c 100644 --- a/Runtime/World/CScriptTrigger.cpp +++ b/Runtime/World/CScriptTrigger.cpp @@ -11,7 +11,7 @@ CScriptTrigger::CScriptTrigger(TUniqueId uid, const std::string& name, const CEn const CDamageInfo& dInfo, const zeus::CVector3f& orientedForce, u32 triggerFlags, bool active, bool, bool) : CActor(uid, active, name, info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(), - CMaterialList(34), CActorParameters::None(), kInvalidUniqueId) + CMaterialList(EMaterialTypes::ThirtyFour), CActorParameters::None(), kInvalidUniqueId) { } diff --git a/Runtime/World/CScriptWaypoint.cpp b/Runtime/World/CScriptWaypoint.cpp index 215dcdae2..c85e1eafa 100644 --- a/Runtime/World/CScriptWaypoint.cpp +++ b/Runtime/World/CScriptWaypoint.cpp @@ -9,7 +9,7 @@ namespace urde CScriptWaypoint::CScriptWaypoint(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, bool active, float, float, u32, u32, u32, u32, u32, u32, u32) -: CActor(uid, active, name, info, xf, CModelData(), CMaterialList(0), +: CActor(uid, active, name, info, xf, CModelData(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId) { } diff --git a/Runtime/World/CVisorParameters.hpp b/Runtime/World/CVisorParameters.hpp index 02097a1dd..49be372bc 100644 --- a/Runtime/World/CVisorParameters.hpp +++ b/Runtime/World/CVisorParameters.hpp @@ -8,13 +8,15 @@ namespace urde class CVisorParameters { - u8 x0_mask : 4; +public: + u32 x0_mask : 4; bool x0_4_b1 : 1; bool x0_5_b2 : 1; -public: + bool x0_28_b3 : 1; + bool x0_29_b4 : 1; CVisorParameters() : x0_mask(0xf), x0_4_b1(false), x0_5_b2(false) {} - CVisorParameters(u8 mask, bool b1, bool b2) + CVisorParameters(u32 mask, bool b1, bool b2) : x0_mask(mask), x0_4_b1(b1), x0_5_b2(b2) {} }; diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 466fec8c1..f71ceb109 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -360,13 +360,13 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, CMaterialList list; if (b2) - list.x0_ = 0x80000000000; + list.Add(EMaterialTypes::SixtyThree); if (b3) - list.x0_ |= 8; + list.Add(EMaterialTypes::Eight); if (b4) - list.x0_ |= 32; + list.Add(EMaterialTypes::ThirtyTwo); bool generateExtent = false; if (collisionExtent.x < 0.f || collisionExtent.y < 0.f || collisionExtent.z < 0.f) @@ -395,7 +395,7 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, aabb = data.GetBounds(head.x10_transform.getRotation()); return new CScriptActor(mgr.AllocateUniqueId(), head.x0_name, info, - head.x10_transform, data, aabb, f1, f2, list, hInfo, dInfo, + head.x10_transform, std::move(data), aabb, f1, f2, list, hInfo, dInfo, actParms, b1, b5, w2, f3, b6, b7, b8, b9); } @@ -469,7 +469,7 @@ CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in, isMorphballDoor = in.readBool(); return new CScriptDoor(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, - mData, actParms, v1, aabb, b1, b2, b3, f1, isMorphballDoor); + std::move(mData), actParms, v1, aabb, b1, b2, b3, f1, isMorphballDoor); } CEntity* ScriptLoader::LoadTrigger(CStateManager& mgr, CInputStream& in, @@ -651,7 +651,7 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, aabb = data.GetBounds(head.x10_transform.getRotation()); return new CScriptPlatform(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, - data, actParms, aabb, f1, b2, f2, b1, hInfo, dInfo, dclnToken, b3, w2, w3); + std::move(data), actParms, aabb, f1, b2, f2, b1, hInfo, dInfo, dclnToken, b3, w2, w3); } CEntity* ScriptLoader::LoadSound(CStateManager& mgr, CInputStream& in,