Various imps

This commit is contained in:
Phillip Stephens 2016-04-22 13:22:45 -07:00
parent 2260632ac6
commit 4615f37f59
36 changed files with 536 additions and 144 deletions

View File

@ -3,4 +3,9 @@
namespace urde
{
void CMapWorldInfo::SetDoorVisited(TEditorId eid, bool visited)
{
x14_[eid] = visited;
}
}

View File

@ -1,13 +1,16 @@
#ifndef __URDE_CMAPWORLDINFO_HPP__
#define __URDE_CMAPWORLDINFO_HPP__
#include "RetroTypes.hpp"
namespace urde
{
class CMapWorldInfo
{
std::map<TEditorId, bool> x14_;
public:
void SetDoorVisited(TEditorId eid, bool val);
};
}
#endif // __URDE_CMAPWORLDINFO_HPP__

View File

@ -300,7 +300,7 @@ void CStateManager::GetBuildForScript(TEditorId) const
{
}
void CStateManager::GetEditorIdForUniqueId() const
TEditorId CStateManager::GetEditorIdForUniqueId(TUniqueId) const
{
}

View File

@ -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<CMapWorldInfo> MapWorldInfo() { return x8c0_mapWorldInfo; }
};
}

View File

@ -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

View File

@ -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

View File

@ -38,6 +38,7 @@ struct CAnimRes
class CModelData
{
friend class CActor;
zeus::CVector3f x0_particleScale;
std::unique_ptr<CAnimData> 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<CAnimData>& AnimationData() { return xc_animData; }
};
}

View File

@ -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();
};
}

View File

@ -0,0 +1 @@
#include "CMaterialFilter.hpp"

View File

@ -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)

View File

@ -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__

View File

@ -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;
}
};
}

View File

@ -0,0 +1,2 @@
#include "CRayCastResult.hpp"

View File

@ -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__

View File

@ -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;
}

View File

@ -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<CModelData>(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);
}
}

View File

@ -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<CModelData> 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;
}
};
}

View File

@ -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; }
};
}

View File

@ -3,10 +3,11 @@
namespace urde
{
const std::vector<SConnection> 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);
}
}

View File

@ -18,14 +18,15 @@ struct SConnection
class CEntityInfo
{
friend class CEntity;
TAreaId x0_areaId;
std::vector<SConnection> x4_conns;
ResId x14_savwId;
TEditorId x14_editorId;
public:
CEntityInfo(TAreaId aid, const std::vector<SConnection>& conns, ResId savwId=-1)
: x0_areaId(aid), x4_conns(conns) {}
TAreaId GetAreaId() const {return x0_areaId;}
std::vector<SConnection> 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<SConnection> x20_conns;
@ -49,15 +50,17 @@ protected:
};
public:
static const std::vector<SConnection> 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);
};

View File

@ -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;
}
}

View File

@ -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);
}
};

View File

@ -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)
{
}

View File

@ -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);
};

View File

@ -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;
}

View File

@ -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<const CScriptDoor*>(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);
}
}

View File

@ -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);
};
}

View File

@ -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)
{
}

View File

@ -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 &params)
: 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)
{
}

View File

@ -7,20 +7,20 @@ 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<CCollidableOBBTreeGroup>& dcln,
bool, u32, u32)
: CPhysicsActor(uid, active, name, info, xf, mData, MakePlatformMaterialList(),
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakePlatformMaterialList(),
aabb, SMoverData(15000.f), actParms, 0.3f, 0.1f)
{
}

View File

@ -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<CCollidableOBBTreeGroup>& dcln, bool, u32, u32);

View File

@ -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)
{
}

View File

@ -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)
{
}

View File

@ -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)
{
}

View File

@ -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) {}
};

View File

@ -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,