From 1845a1465b4c67bd59fab1b95654f385f2b45a94 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 22 Apr 2017 04:04:07 -0700 Subject: [PATCH] Initial CJointCollisionDescription imps, minor CScriptTrigger cleanup --- Runtime/Character/CBodyStateCmdMgr.hpp | 3 ++ .../Collision/CJointCollisionDescription.cpp | 46 +++++++++++++++++-- .../Collision/CJointCollisionDescription.hpp | 27 +++++++---- Runtime/World/CScriptTrigger.cpp | 8 ++-- Runtime/World/ScriptLoader.cpp | 9 ++-- 5 files changed, 69 insertions(+), 24 deletions(-) diff --git a/Runtime/Character/CBodyStateCmdMgr.hpp b/Runtime/Character/CBodyStateCmdMgr.hpp index 426887f8e..4726c9ddf 100644 --- a/Runtime/Character/CBodyStateCmdMgr.hpp +++ b/Runtime/Character/CBodyStateCmdMgr.hpp @@ -34,6 +34,9 @@ public: { }; private: + float x34_steeringSpeedMin; + float x38_steeringSpeedMax; + rstl::reserved_vector x44_; public: CBodyStateCmdMgr() = default; void DeliverCmd(EBodyStateCmd); diff --git a/Runtime/Collision/CJointCollisionDescription.cpp b/Runtime/Collision/CJointCollisionDescription.cpp index 536c669b7..ee31b8c31 100644 --- a/Runtime/Collision/CJointCollisionDescription.cpp +++ b/Runtime/Collision/CJointCollisionDescription.cpp @@ -3,11 +3,49 @@ namespace urde { -CJointCollisionDescription::CJointCollisionDescription(ECollisionType, CSegId, CSegId, const zeus::CVector3f&, - const zeus::CVector3f&, float, float, EOrientationType, - const std::string&, float) +CJointCollisionDescription::CJointCollisionDescription(ECollisionType colType, CSegId seg1, CSegId seg2, + const zeus::CVector3f& v1, const zeus::CVector3f& v2, float f1, + float f2, EOrientationType orientType, const std::string& name, + float f3) +: x0_colType(colType) +, x4_orientType(orientType) +, x8_(seg1) +, x9_(seg2) +, xc_(v1) +, x18_(v2) +, x24_(f1) +, x28_(f2) +, x2c_name(name) +, x40_(f3) { } - +CJointCollisionDescription CJointCollisionDescription::SphereSubdivideCollision(CSegId seg1, CSegId seg2, float f1, + float f2, EOrientationType orientType, + const std::string& name, float f3) +{ + return CJointCollisionDescription(ECollisionType::SphereSubdivide, seg1, seg2, zeus::CVector3f::skZero, + zeus::CVector3f::skZero, f1, f2, orientType, name, f3); +} + +CJointCollisionDescription CJointCollisionDescription::SphereCollision(CSegId, float f1, const std::string&, float f2) +{ + return CJointCollisionDescription(ECollisionType::Sphere, segId, -1, zeus::CVector3f::skZero, + zeus::CVector3f::skZero, f1, 0.f, EOrientationType::Zero, name, f2); +} + +CJointCollisionDescription CJointCollisionDescription::AABoxCollision(CSegId segId, const zeus::CVector3f& v1, + const std::string& name, float f1) +{ + return CJointCollisionDescription(ECollisionType::AABox, segId, -1, v1, zeus::CVector3f::skZero, 0.f, 0.f, + EOrientationType::Zero, name, f1); +} + +CJointCollisionDescription CJointCollisionDescription::OBBCollision(CSegId segId, const zeus::CVector3f& v1, + const zeus::CVector3f& v2, const std::string& name, + float f1) +{ + return CJointCollisionDescription(ECollisionType::OBB, segId, -1, v1, v2, 0.f, 0.f, EOrientationType::Zero, name, + f1); +} } diff --git a/Runtime/Collision/CJointCollisionDescription.hpp b/Runtime/Collision/CJointCollisionDescription.hpp index bcf8d8383..e1cbce868 100644 --- a/Runtime/Collision/CJointCollisionDescription.hpp +++ b/Runtime/Collision/CJointCollisionDescription.hpp @@ -11,16 +11,21 @@ class CJointCollisionDescription public: enum class ECollisionType { + Sphere, + SphereSubdivide, + AABox, + OBBAutoSize, + OBB, }; enum class EOrientationType { - + Zero, }; private: - u32 x0_; - u32 x4_; + ECollisionType x0_colType; + EOrientationType x4_orientType; CSegId x8_; CSegId x9_; zeus::CVector3f xc_; @@ -28,7 +33,7 @@ private: float x24_; float x28_; std::string x2c_name; - TUniqueId x3c_actorId; + TUniqueId x3c_actorId = kInvalidUniqueId; float x40_; public: @@ -36,12 +41,14 @@ public: float, EOrientationType, const std::string&, float); const std::string& GetName() const { return x2c_name; } TUniqueId GetCollisionActorId() const { return x3c_actorId; } - void SphereSubdivideCollision(ECollisionType, CSegId, CSegId, float, float, EOrientationType, const std::string&, - float); - void SphereCollision(CSegId, float, const std::string&, float); - void AABoxCollision(CSegId, zeus::CVector3f const&, const std::string&, float); - void OBBAutoSizeCollision(CSegId, CSegId, const zeus::CVector3f&, EOrientationType, const std::string&, float); - void OBBCollision(CSegId, const zeus::CVector3f&, const zeus::CVector3f&, const std::string&, float); + static CJointCollisionDescription SphereSubdivideCollision(CSegId, CSegId, float, float, + EOrientationType, const std::string&, float); + static CJointCollisionDescription SphereCollision(CSegId, float, const std::string&, float); + static CJointCollisionDescription AABoxCollision(CSegId, zeus::CVector3f const&, const std::string&, float); + static CJointCollisionDescription OBBAutoSizeCollision(CSegId, CSegId, const zeus::CVector3f&, EOrientationType, + const std::string&, float); + static CJointCollisionDescription OBBCollision(CSegId, const zeus::CVector3f&, const zeus::CVector3f&, + const std::string&, float); zeus::CVector3f GetPivotPoint() const; float GetRadius() const; void SetCollisionActorId(TUniqueId); diff --git a/Runtime/World/CScriptTrigger.cpp b/Runtime/World/CScriptTrigger.cpp index c166bfce3..4883c1429 100644 --- a/Runtime/World/CScriptTrigger.cpp +++ b/Runtime/World/CScriptTrigger.cpp @@ -15,8 +15,8 @@ namespace urde CScriptTrigger::CScriptTrigger(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos, const zeus::CAABox& bounds, const CDamageInfo& dInfo, - const zeus::CVector3f& forceField, ETriggerFlags triggerFlags, bool active, bool b2, - bool b3) + const zeus::CVector3f& forceField, ETriggerFlags triggerFlags, bool active, bool deactivateOnEntered, + bool deactivateOnExited) : CActor(uid, active, name, info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Trigger), CActorParameters::None(), kInvalidUniqueId) , x100_damageInfo(dInfo) @@ -25,8 +25,8 @@ CScriptTrigger::CScriptTrigger(TUniqueId uid, const std::string& name, const CEn , x12c_flags(triggerFlags) , x130_bounds(bounds) { - x148_26_deactivateOnEntered = b2; - x148_27_deactivateOnExited = b3; + x148_26_deactivateOnEntered = deactivateOnEntered; + x148_27_deactivateOnExited = deactivateOnExited; } void CScriptTrigger::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 2f337a347..77b024f31 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -511,16 +511,13 @@ CEntity* ScriptLoader::LoadTrigger(CStateManager& mgr, CInputStream& in, int pro std::string name = mgr.HashInstanceName(in); - zeus::CVector3f position; - position.readBig(in); + zeus::CVector3f position = zeus::CVector3f::ReadBig(in); - zeus::CVector3f extent; - extent.readBig(in); + zeus::CVector3f extent = zeus::CVector3f::ReadBig(in); CDamageInfo dInfo(in); - zeus::CVector3f forceVec; - forceVec.readBig(in); + zeus::CVector3f forceVec = zeus::CVector3f::ReadBig(in); ETriggerFlags flags = ETriggerFlags(in.readUint32Big()); bool active = in.readBool();