From c20eb7618957e658f970e6fc1891ccf1f50f2864 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 13 Sep 2016 22:45:46 -0700 Subject: [PATCH] Various imps and stubs --- Runtime/Audio/CAudioStateWin.cpp | 33 +++++ Runtime/Audio/CAudioStateWin.hpp | 6 +- Runtime/AutoMapper/CMapUniverse.cpp | 7 +- Runtime/Camera/CFirstPersonCamera.cpp | 6 +- Runtime/Camera/CGameCamera.cpp | 106 ++++++++++++- Runtime/Camera/CGameCamera.hpp | 48 +++++- Runtime/Character/CAnimTreeDoubleChild.hpp | 16 +- Runtime/Character/CAnimTreeScale.hpp | 13 -- Runtime/Character/CAnimTreeSingleChild.cpp | 1 + Runtime/Character/CAnimTreeTimeScale.cpp | 50 +++++++ Runtime/Character/CAnimTreeTimeScale.hpp | 16 +- Runtime/Character/CAnimTreeTweenBase.cpp | 28 ++-- Runtime/Character/CAnimTreeTweenBase.hpp | 2 +- Runtime/Character/CCharAnimTime.cpp | 140 +++++++++--------- Runtime/Character/CCharAnimTime.hpp | 25 +++- .../Character/CConstantAnimationTimeScale.cpp | 19 +++ .../Character/CConstantAnimationTimeScale.hpp | 22 +++ ...cale.cpp => CLinearAnimationTimeScale.cpp} | 0 .../Character/CLinearAnimationTimeScale.hpp | 31 ++++ Runtime/Character/CMakeLists.txt | 4 +- .../Character/IVaryingAnimationTimeScale.hpp | 29 ++++ Runtime/GuiSys/CGuiObject.hpp | 1 + Runtime/Particle/CVectorElement.cpp | 6 +- Runtime/World/CActor.hpp | 1 - Runtime/World/CWorldTransManager.hpp | 1 + specter | 2 +- 26 files changed, 479 insertions(+), 134 deletions(-) delete mode 100644 Runtime/Character/CAnimTreeScale.hpp create mode 100644 Runtime/Character/CConstantAnimationTimeScale.cpp create mode 100644 Runtime/Character/CConstantAnimationTimeScale.hpp rename Runtime/Character/{CAnimTreeScale.cpp => CLinearAnimationTimeScale.cpp} (100%) create mode 100644 Runtime/Character/CLinearAnimationTimeScale.hpp create mode 100644 Runtime/Character/IVaryingAnimationTimeScale.hpp diff --git a/Runtime/Audio/CAudioStateWin.cpp b/Runtime/Audio/CAudioStateWin.cpp index e69de29bb..93dc02695 100644 --- a/Runtime/Audio/CAudioStateWin.cpp +++ b/Runtime/Audio/CAudioStateWin.cpp @@ -0,0 +1,33 @@ +#include "CAudioStateWin.hpp" +#include "CSfxManager.hpp" +#include "CArchitectureMessage.hpp" +#include "CArchitectureQueue.hpp" +#include "GameGlobalObjects.hpp" +#include "CGameState.hpp" + +namespace urde +{ + +CIOWin::EMessageReturn CAudioStateWin::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) +{ +#if 0 + const EArchMsgType msgType = msg.GetType(); + if (msgType == EArchMsgType::SetGameState) + { + CSfxManager::KillAll(CSfxManager::ESfxChannels::One); + CSfxManager::TurnOnChannel(CSfxManager::ESfxChannels::One); + } + else if (msgType == EArchMsgType::QuitGameplay) + { + if (g_GameState->GetWorldTransitionManager()->GetTransitionType() == CWorldTransManager::ETransType::Disabled || + g_Main->x12c_ != 0) + { + CSfxManager::SetChannel(CSfxManager::ESfxChannels::Zero); + CSfxManager::KillAll(CSfxManager::ESfxChannels::One); + } + } +#endif + return EMessageReturn::Normal; +} + +} diff --git a/Runtime/Audio/CAudioStateWin.hpp b/Runtime/Audio/CAudioStateWin.hpp index 59d833506..b8986c76b 100644 --- a/Runtime/Audio/CAudioStateWin.hpp +++ b/Runtime/Audio/CAudioStateWin.hpp @@ -5,15 +5,11 @@ namespace urde { - class CAudioStateWin : public CIOWin { public: CAudioStateWin() : CIOWin("CAudioStateWin") {} - CIOWin::EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) - { - return EMessageReturn::Normal; - } + CIOWin::EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue); }; } diff --git a/Runtime/AutoMapper/CMapUniverse.cpp b/Runtime/AutoMapper/CMapUniverse.cpp index 3336da418..806f1bac9 100644 --- a/Runtime/AutoMapper/CMapUniverse.cpp +++ b/Runtime/AutoMapper/CMapUniverse.cpp @@ -38,12 +38,7 @@ CMapUniverse::CMapWorldData::CMapWorldData(CInputStream& in, u32 version) x60_ = zeus::CColor::lerp(zeus::CColor::skWhite, x5c_, 0.5f); for (const zeus::CTransform& xf : x44_areaData) - { - zeus::CMatrix4f mat = xf.toMatrix4f().transposed(); - x64_.x += mat.vec[1].x; - x64_.y += mat.vec[2].y; - x64_.z += mat.vec[3].z; - } + x64_ += xf.origin; x64_ *= 1.0f / float(x44_areaData.size()); } diff --git a/Runtime/Camera/CFirstPersonCamera.cpp b/Runtime/Camera/CFirstPersonCamera.cpp index c8c340f97..b546dc4a1 100644 --- a/Runtime/Camera/CFirstPersonCamera.cpp +++ b/Runtime/Camera/CFirstPersonCamera.cpp @@ -4,11 +4,11 @@ namespace urde { -CFirstPersonCamera::CFirstPersonCamera(TUniqueId uid, const zeus::CTransform& xf, TUniqueId id2, - float, float a, float b, float c, float d) +CFirstPersonCamera::CFirstPersonCamera(TUniqueId uid, const zeus::CTransform& xf, TUniqueId watchedObj, + float, float fov, float nearz, float farz, float aspect) : CGameCamera(uid, true, "First Person Camera", CEntityInfo(kInvalidAreaId, CEntity::NullConnectionList), - xf, a, b, c, d, id2, 0, 0) + xf, fov, nearz, farz, aspect, watchedObj, false, 0) { } diff --git a/Runtime/Camera/CGameCamera.cpp b/Runtime/Camera/CGameCamera.cpp index f59810f58..9ee728926 100644 --- a/Runtime/Camera/CGameCamera.cpp +++ b/Runtime/Camera/CGameCamera.cpp @@ -1,14 +1,114 @@ #include "CGameCamera.hpp" +#include "CStateManager.hpp" +#include "Camera/CCameraManager.hpp" #include "World/CActorParameters.hpp" namespace urde { CGameCamera::CGameCamera(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, - const zeus::CTransform& xf, float, float, float, float, TUniqueId, bool, u32) -: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), - CMaterialList(EMaterialTypes::Zero), CActorParameters::None(), kInvalidUniqueId) + const zeus::CTransform& xf, float fovy, float znear, float zfar, float aspect, TUniqueId uid2, + bool b1, u32 w1) +: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Zero), + CActorParameters::None(), kInvalidUniqueId) +, xe8_watchedObject(uid2) +, x12c_(xf) +, x15c_fov(fovy) +, x160_znear(znear) +, x164_zfar(zfar) +, x168_aspect(aspect) +, x16c_(w1) +, x170_24_perspDirty(true) +, x170_25_disablesInput(b1) +, x180_(fovy) +, x184_(fovy) { + + xe7_29_ = false; } +void CGameCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) +{ + if (msg == EScriptObjectMessage::InternalMessage15) + { + mgr.GetCameraManager()->SetInsideFluid(true, uid); + return; + } + else if (msg == EScriptObjectMessage::InternalMessage17) + { + mgr.GetCameraManager()->SetInsideFluid(false, kInvalidUniqueId); + return; + } + + CActor::AcceptScriptMsg(msg, uid, mgr); +} + +void CGameCamera::SetActive(bool active) +{ + CActor::SetActive(active); + xe7_29_ = false; +} + +zeus::CMatrix4f CGameCamera::GetPerspectiveMatrix() const +{ + if (x170_24_perspDirty) + { + const_cast(this)->xec_perspectiveMatrix = + CGraphics::CalculatePerspectiveMatrix(x15c_fov, x168_aspect, x160_znear, x164_zfar, false); + const_cast(this)->x170_24_perspDirty = false; + } + + return xec_perspectiveMatrix; +} + +zeus::CVector3f CGameCamera::ConvertToScreenSpace(const zeus::CVector3f& v) const +{ + zeus::CVector3f rVec = x34_transform.transposeRotate(v - x34_transform.origin); + + if (rVec.x == 0.f && rVec.y == 0.f && rVec.z == 0.f) + return {-1.f, -1.f, 1.f}; + + zeus::CMatrix4f mtx = GetPerspectiveMatrix(); + return mtx.multiplyOneOverW(rVec); +} + +zeus::CTransform CGameCamera::ValidateCameraTransform(const zeus::CTransform& a, const zeus::CTransform& b) +{ + zeus::CTransform xfCpy(a); + constexpr double epsilon = FLT_EPSILON * 1000.f; + if ((a.rightVector().magnitude() - 1.f) >= epsilon || (a.frontVector().magnitude() - 1.f) >= epsilon || + (a.upVector().magnitude() - 1.f) >= epsilon) + xfCpy.orthonormalize(); + float f2 = zeus::kUpVec.x + a.upVector().x * a.upVector().y * a.upVector().z * zeus::kUpVec.y + zeus::kUpVec.z; + if (std::fabs(f2) > 1.0f) + f2 = (f2 >= -0.f ? -1.0f : 1.0f); + if (std::fabs(f2) > 0.999f) + xfCpy = b; + + if (xfCpy.upVector().z < -0.2f) + xfCpy = zeus::CQuaternion::fromAxisAngle(xfCpy.frontVector(), M_PIF).toTransform() * xfCpy; + + if (std::fabs(xfCpy.rightVector().z - 0.f) >= 0.000009f && std::fabs(xfCpy.upVector().z - 0.f) > 0.000009f) + { + if (xfCpy.frontVector().canBeNormalized()) + xfCpy = zeus::lookAt(zeus::CUnitVector3f(xfCpy.frontVector(), true), zeus::CVector3f::skZero); + else + xfCpy = b; + } + + xfCpy.origin = a.origin; + return xfCpy; +} + +float CGameCamera::GetNearClipDistance() const { return x160_znear; } + +float CGameCamera::GetFarClipDistance() const { return x164_zfar; } + +float CGameCamera::GetAspectRatio() const { return x168_aspect; } + +TUniqueId CGameCamera::GetWatchedObject() const { return xe8_watchedObject; } + +float CGameCamera::GetFov() const { return x15c_fov; } + +void CGameCamera::SetFov(float fov) { x15c_fov = fov; } } diff --git a/Runtime/Camera/CGameCamera.hpp b/Runtime/Camera/CGameCamera.hpp index cc53e4894..9bf922535 100644 --- a/Runtime/Camera/CGameCamera.hpp +++ b/Runtime/Camera/CGameCamera.hpp @@ -10,16 +10,50 @@ class CFinalInput; class CGameCamera : public CActor { + TUniqueId xe8_watchedObject; + zeus::CMatrix4f xec_perspectiveMatrix; + zeus::CTransform x12c_; + float x15c_fov; + float x160_znear; + float x164_zfar; + float x168_aspect; + u32 x16c_; + union { + struct + { + bool x170_24_perspDirty : 1; + bool x170_25_disablesInput : 1; + }; + u32 _dummy = 0; + }; + float x174_ = 0.f; + float x178_ = 0.f; + float x17c_ = 0.f; + float x180_; + float x184_; public: - CGameCamera(TUniqueId, bool active, const std::string& name, const CEntityInfo& info, - const zeus::CTransform& xf, float fov, float nearz, float farz, float aspect, - TUniqueId, bool, u32); - const zeus::CTransform& GetTransform() const {return x34_transform;} + CGameCamera(TUniqueId, bool active, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, + float fov, float nearz, float farz, float aspect, TUniqueId, bool, u32); + + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); + void SetActive(bool active); + virtual void ProcessInput(const CFinalInput&, CStateManager& mgr) = 0; + virtual void Reset(const zeus::CTransform&, CStateManager& mgr) = 0; + + const zeus::CTransform& GetTransform() const { return x34_transform; } + zeus::CMatrix4f GetPerspectiveMatrix() const; + zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f&) const; + zeus::CTransform ValidateCameraTransform(const zeus::CTransform&, const zeus::CTransform&); + float GetNearClipDistance() const; + float GetFarClipDistance() const; + float GetAspectRatio() const; + TUniqueId GetWatchedObject() const; + float GetFov() const; + void SetFov(float); + void GetControllerNumber() const; + bool DisablesInput() const; - virtual void ProcessInput(const CFinalInput&, CStateManager& mgr)=0; - virtual void Reset(const zeus::CTransform&, CStateManager& mgr)=0; }; - } #endif // __URDE_CGAMECAMERA_HPP__ diff --git a/Runtime/Character/CAnimTreeDoubleChild.hpp b/Runtime/Character/CAnimTreeDoubleChild.hpp index 2f7a5140f..2ee83b2b4 100644 --- a/Runtime/Character/CAnimTreeDoubleChild.hpp +++ b/Runtime/Character/CAnimTreeDoubleChild.hpp @@ -8,6 +8,18 @@ namespace urde class CAnimTreeDoubleChild : public CAnimTreeNode { +public: + class CDoubleChildAdvancementResult + { + CCharAnimTime x0_; + SAdvancementDeltas x8_; + SAdvancementDeltas x24_; + public: + CDoubleChildAdvancementResult(const CCharAnimTime&, const SAdvancementDeltas&, const SAdvancementDeltas); + void GetLeftAdvancementDeltas() const; + void GetRightAdvancementDeltas() const; + void GetTrueAdvancement() const; + }; protected: std::shared_ptr x14_a; std::shared_ptr x18_b; @@ -32,8 +44,8 @@ public: std::shared_ptr VGetBestUnblendedChild() const; void VGetWeightedReaders(std::vector>>& out, float w) const; - virtual float VGetLeftChildWeight() const = 0; - float GetLeftChildWeight() const { return VGetLeftChildWeight(); } + //virtual float VGetTotalChildWeight(float) const = 0; + //float GetTotalChildWeight(float f) const { return VGetTotalChildWeight(f); } virtual float VGetRightChildWeight() const = 0; float GetRightChildWeight() const { return VGetRightChildWeight(); } diff --git a/Runtime/Character/CAnimTreeScale.hpp b/Runtime/Character/CAnimTreeScale.hpp deleted file mode 100644 index 4104e8270..000000000 --- a/Runtime/Character/CAnimTreeScale.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __URDE_CANIMTREESCALE_HPP__ -#define __URDE_CANIMTREESCALE_HPP__ - -namespace urde -{ - -class CAnimTreeScale -{ -}; - -} - -#endif // __URDE_CANIMTREESCALE_HPP__ diff --git a/Runtime/Character/CAnimTreeSingleChild.cpp b/Runtime/Character/CAnimTreeSingleChild.cpp index b0b9ad940..fd77bd5d3 100644 --- a/Runtime/Character/CAnimTreeSingleChild.cpp +++ b/Runtime/Character/CAnimTreeSingleChild.cpp @@ -5,6 +5,7 @@ namespace urde CAnimTreeSingleChild::CAnimTreeSingleChild(const std::weak_ptr& node, const std::string& name) : CAnimTreeNode(name) +, x14_child(node.lock()) { } diff --git a/Runtime/Character/CAnimTreeTimeScale.cpp b/Runtime/Character/CAnimTreeTimeScale.cpp index e69de29bb..14125404b 100644 --- a/Runtime/Character/CAnimTreeTimeScale.cpp +++ b/Runtime/Character/CAnimTreeTimeScale.cpp @@ -0,0 +1,50 @@ +#include "CAnimTreeTimeScale.hpp" + +namespace urde +{ + +CAnimTreeTimeScale::CAnimTreeTimeScale(const std::weak_ptr& node, float scale, const std::string& name) + : CAnimTreeSingleChild(node, name) + , x18_timeScale(new CConstantAnimationTimeScale(scale)) +{ +} + +std::string CAnimTreeTimeScale::CreatePrimitiveName(const std::weak_ptr&, float, const CCharAnimTime&, float) +{ + return {}; +} + +CCharAnimTime CAnimTreeTimeScale::GetRealLifeTime(const CCharAnimTime& time) const +{ + CCharAnimTime timeRem = x14_child->VGetTimeRemaining(); + + CCharAnimTime tmp = std::min(timeRem, time); + if (x28_ > CCharAnimTime()) + { + if (tmp < CCharAnimTime(x28_ * x20_)) + return x18_timeScale->TimeScaleIntegral(x20_, x20_ + tmp); + else + { + CCharAnimTime integral = x18_timeScale->TimeScaleIntegral(x20_, x28_); + + if (integral > tmp) + return x18_timeScale->FindUpperLimit(x20_, tmp) * x20_; + else + return integral + (integral * tmp); + } + } + + return tmp; +} + +void CAnimTreeTimeScale::VSetPhase(float phase) +{ + x14_child->VSetPhase(phase); +} + +std::shared_ptr CAnimTreeTimeScale::VSimplified() +{ + return {}; +} + +} diff --git a/Runtime/Character/CAnimTreeTimeScale.hpp b/Runtime/Character/CAnimTreeTimeScale.hpp index 40edb4769..901c7d6e9 100644 --- a/Runtime/Character/CAnimTreeTimeScale.hpp +++ b/Runtime/Character/CAnimTreeTimeScale.hpp @@ -1,11 +1,25 @@ #ifndef __URDE_CANIMTREETIMESCALE_HPP__ #define __URDE_CANIMTREETIMESCALE_HPP__ +#include "CAnimTreeSingleChild.hpp" +#include "CConstantAnimationTimeScale.hpp" + namespace urde { -class CAnimTreeTimeScale +class CAnimTreeTimeScale : public CAnimTreeSingleChild { + std::unique_ptr x18_timeScale; + CCharAnimTime x20_; + CCharAnimTime x28_; +public: + CAnimTreeTimeScale(const std::weak_ptr&, float, const std::string&); + + static std::string CreatePrimitiveName(const std::weak_ptr&, float, const CCharAnimTime&, float); + + CCharAnimTime GetRealLifeTime(const CCharAnimTime&) const; + void VSetPhase(float); + std::shared_ptr VSimplified(); }; } diff --git a/Runtime/Character/CAnimTreeTweenBase.cpp b/Runtime/Character/CAnimTreeTweenBase.cpp index 8a4f4c53d..a03b7ee1c 100644 --- a/Runtime/Character/CAnimTreeTweenBase.cpp +++ b/Runtime/Character/CAnimTreeTweenBase.cpp @@ -11,10 +11,11 @@ CAnimTreeTweenBase::CAnimTreeTweenBase(bool b1, const std::weak_ptrVHasOffset(seg) || x18_b->VHasOffset(seg)); } zeus::CVector3f CAnimTreeTweenBase::VGetOffset(const CSegId& seg) const { - return {}; + const float weight = GetBlendingWeight(); + if (weight >= 1.0f) + return x18_b->VGetOffset(seg); + + const zeus::CVector3f oA = x14_a->VGetOffset(seg); + const zeus::CVector3f oB = x18_b->VGetOffset(seg); + return zeus::CVector3f::lerp(oA, oB, weight); } zeus::CQuaternion CAnimTreeTweenBase::VGetRotation(const CSegId& seg) const { - return {}; + const float weight = GetBlendingWeight(); + if (weight >= 1.0f) + return x18_b->VGetRotation(seg); + + const zeus::CQuaternion qA = x14_a->VGetRotation(seg); + const zeus::CQuaternion qB = x18_b->VGetRotation(seg); + return zeus::CQuaternion::slerp(qA, qB, weight); } -std::shared_ptr CAnimTreeTweenBase::VSimplified() -{ - return {}; -} +std::shared_ptr CAnimTreeTweenBase::VSimplified() { return {}; } } diff --git a/Runtime/Character/CAnimTreeTweenBase.hpp b/Runtime/Character/CAnimTreeTweenBase.hpp index 68e09b9cc..07b877f60 100644 --- a/Runtime/Character/CAnimTreeTweenBase.hpp +++ b/Runtime/Character/CAnimTreeTweenBase.hpp @@ -24,7 +24,7 @@ public: float GetBlendingWeight() const { return VGetBlendingWeight(); } - float VGetLeftChildWeight() const { return 1.f - GetBlendingWeight(); } + //void VGetTotalChildWeight(float) const; float VGetRightChildWeight() const { return GetBlendingWeight(); } void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const; diff --git a/Runtime/Character/CCharAnimTime.cpp b/Runtime/Character/CCharAnimTime.cpp index 4d56fa12e..45bf7f5bd 100644 --- a/Runtime/Character/CCharAnimTime.cpp +++ b/Runtime/Character/CCharAnimTime.cpp @@ -9,36 +9,36 @@ namespace urde CCharAnimTime CCharAnimTime::Infinity() { CCharAnimTime ret(1.f); - ret.m_type = Type::Infinity; + ret.x4_type = EType::Infinity; return ret; } bool CCharAnimTime::EqualsZero() const { - if (m_type == Type::ZeroIncreasing || m_type == Type::ZeroSteady || m_type == Type::ZeroDecreasing) + if (x4_type == EType::ZeroIncreasing || x4_type == EType::ZeroSteady || x4_type == EType::ZeroDecreasing) return false; - return (m_time == 0.f); + return (x0_time == 0.f); } bool CCharAnimTime::EpsilonZero() const { - return (std::fabs(m_time) < FLT_EPSILON); + return (std::fabs(x0_time) < FLT_EPSILON); } bool CCharAnimTime::GreaterThanZero() const { if (EqualsZero()) return false; - return (m_time > 0.f); + return (x0_time > 0.f); } bool CCharAnimTime::operator ==(const CCharAnimTime& other) const { - if (m_type == Type::NonZero) + if (x4_type == EType::NonZero) { - if (other.m_type == Type::NonZero) - return m_time == other.m_time; + if (other.x4_type == EType::NonZero) + return x0_time == other.x0_time; return !other.EqualsZero(); } @@ -47,18 +47,18 @@ bool CCharAnimTime::operator ==(const CCharAnimTime& other) const if (other.EqualsZero()) { int type = -1; - if (m_type != Type::ZeroDecreasing) + if (x4_type != EType::ZeroDecreasing) { - if (m_type != Type::ZeroSteady) + if (x4_type != EType::ZeroSteady) type = 1; else type = 0; } int otherType = -1; - if (other.m_type != Type::ZeroDecreasing) + if (other.x4_type != EType::ZeroDecreasing) { - if (other.m_type != Type::ZeroSteady) + if (other.x4_type != EType::ZeroSteady) otherType = 1; else otherType = 0; @@ -69,8 +69,8 @@ bool CCharAnimTime::operator ==(const CCharAnimTime& other) const return false; } - if (other.m_type == Type::Infinity) - return m_time * other.m_time < 0.f; + if (other.x4_type == EType::Infinity) + return x0_time * other.x0_time < 0.f; return false; } @@ -103,14 +103,14 @@ bool CCharAnimTime::operator >(const CCharAnimTime& other) const bool CCharAnimTime::operator <(const CCharAnimTime& other) const { - if (m_type == Type::NonZero) + if (x4_type == EType::NonZero) { - if (other.m_type == Type::NonZero) - return m_time < other.m_time; + if (other.x4_type == EType::NonZero) + return x0_time < other.x0_time; if (other.EqualsZero()) - return m_time < 0.f; + return x0_time < 0.f; else - return other.m_time > 0.f; + return other.x0_time > 0.f; } if (EqualsZero()) @@ -118,18 +118,18 @@ bool CCharAnimTime::operator <(const CCharAnimTime& other) const if (other.EqualsZero()) { int type = -1; - if (m_type != Type::ZeroDecreasing) + if (x4_type != EType::ZeroDecreasing) { - if (m_type != Type::ZeroSteady) + if (x4_type != EType::ZeroSteady) type = 1; else type = 0; } int otherType = -1; - if (other.m_type != Type::ZeroDecreasing) + if (other.x4_type != EType::ZeroDecreasing) { - if (other.m_type != Type::ZeroSteady) + if (other.x4_type != EType::ZeroSteady) otherType = 1; else otherType = 0; @@ -138,15 +138,15 @@ bool CCharAnimTime::operator <(const CCharAnimTime& other) const return type < otherType; } - if (other.m_type == Type::NonZero) - return other.m_time > 0.f; - return other.m_time < 0.f; + if (other.x4_type == EType::NonZero) + return other.x0_time > 0.f; + return other.x0_time < 0.f; } else { - if (m_type == Type::Infinity) - return m_time < 0.f && other.m_time > 0.f; - return m_time < other.m_time; + if (x4_type == EType::Infinity) + return x0_time < 0.f && other.x0_time > 0.f; + return x0_time < other.x0_time; } } @@ -164,33 +164,33 @@ CCharAnimTime& CCharAnimTime::operator+=(const CCharAnimTime& other) CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other) { - if (m_type == Type::Infinity && other.m_type == Type::Infinity) + if (x4_type == EType::Infinity && other.x4_type == EType::Infinity) { - if (other.m_time != m_time) + if (other.x0_time != x0_time) return CCharAnimTime(); return *this; } - else if (m_type == Type::Infinity) + else if (x4_type == EType::Infinity) return *this; - else if (other.m_type == Type::Infinity) + else if (other.x4_type == EType::Infinity) return other; if (!EqualsZero() || !other.EqualsZero()) - return CCharAnimTime(m_time + other.m_time); + return CCharAnimTime(x0_time + other.x0_time); int type = -1; - if (m_type != Type::ZeroDecreasing) + if (x4_type != EType::ZeroDecreasing) { - if (m_type != Type::ZeroSteady) + if (x4_type != EType::ZeroSteady) type = 1; else type = 0; } int otherType = -1; - if (other.m_type != Type::ZeroDecreasing) + if (other.x4_type != EType::ZeroDecreasing) { - if (other.m_type != Type::ZeroSteady) + if (other.x4_type != EType::ZeroSteady) otherType = 1; else otherType = 0; @@ -201,11 +201,11 @@ CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other) CCharAnimTime ret; if (otherType == -1) - ret.m_type = Type::ZeroDecreasing; + ret.x4_type = EType::ZeroDecreasing; else if (otherType == 0) - ret.m_type = Type::ZeroSteady; + ret.x4_type = EType::ZeroSteady; else - ret.m_type = Type::ZeroIncreasing; + ret.x4_type = EType::ZeroIncreasing; return ret; } @@ -218,37 +218,37 @@ CCharAnimTime& CCharAnimTime::operator-=(const CCharAnimTime& other) CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other) { - if (m_type == Type::Infinity && other.m_type == Type::Infinity) + if (x4_type == EType::Infinity && other.x4_type == EType::Infinity) { - if (other.m_time == m_time) + if (other.x0_time == x0_time) return CCharAnimTime(); return *this; } - else if (m_type == Type::Infinity) + else if (x4_type == EType::Infinity) return *this; - else if (other.m_type == Type::Infinity) + else if (other.x4_type == EType::Infinity) { - CCharAnimTime ret(-other.m_time); - ret.m_type = Type::Infinity; + CCharAnimTime ret(-other.x0_time); + ret.x4_type = EType::Infinity; return ret; } if (!EqualsZero() || !other.EqualsZero()) - return CCharAnimTime(m_time - other.m_time); + return CCharAnimTime(x0_time - other.x0_time); int type = -1; - if (m_type != Type::ZeroDecreasing) + if (x4_type != EType::ZeroDecreasing) { - if (m_type != Type::ZeroSteady) + if (x4_type != EType::ZeroSteady) type = 1; else type = 0; } int otherType = -1; - if (other.m_type != Type::ZeroDecreasing) + if (other.x4_type != EType::ZeroDecreasing) { - if (other.m_type != Type::ZeroSteady) + if (other.x4_type != EType::ZeroSteady) otherType = 1; else otherType = 0; @@ -257,44 +257,44 @@ CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other) CCharAnimTime ret; type -= otherType; if (type == -1) - ret.m_type = Type::ZeroDecreasing; + ret.x4_type = EType::ZeroDecreasing; else if (type == 0) - ret.m_type = Type::ZeroSteady; + ret.x4_type = EType::ZeroSteady; else - ret.m_type = Type::ZeroIncreasing; + ret.x4_type = EType::ZeroIncreasing; return ret; } CCharAnimTime CCharAnimTime::operator*(const CCharAnimTime& other) { - if (m_type == Type::Infinity && other.m_type == Type::Infinity) + if (x4_type == EType::Infinity && other.x4_type == EType::Infinity) { - if (other.m_time != m_time) + if (other.x0_time != x0_time) return CCharAnimTime(); return *this; } - else if (m_type == Type::Infinity) + else if (x4_type == EType::Infinity) return *this; - else if (other.m_type == Type::Infinity) + else if (other.x4_type == EType::Infinity) return other; if (!EqualsZero() || !other.EqualsZero()) - return CCharAnimTime(m_time * other.m_time); + return CCharAnimTime(x0_time * other.x0_time); int type = -1; - if (m_type != Type::ZeroDecreasing) + if (x4_type != EType::ZeroDecreasing) { - if (m_type != Type::ZeroSteady) + if (x4_type != EType::ZeroSteady) type = 1; else type = 0; } int otherType = -1; - if (other.m_type != Type::ZeroDecreasing) + if (other.x4_type != EType::ZeroDecreasing) { - if (other.m_type != Type::ZeroSteady) + if (other.x4_type != EType::ZeroSteady) otherType = 1; else otherType = 0; @@ -305,11 +305,11 @@ CCharAnimTime CCharAnimTime::operator*(const CCharAnimTime& other) CCharAnimTime ret; if (otherType == -1) - ret.m_type = Type::ZeroDecreasing; + ret.x4_type = EType::ZeroDecreasing; else if (otherType == 0) - ret.m_type = Type::ZeroSteady; + ret.x4_type = EType::ZeroSteady; else - ret.m_type = Type::ZeroIncreasing; + ret.x4_type = EType::ZeroIncreasing; return ret; } @@ -320,14 +320,14 @@ CCharAnimTime CCharAnimTime::operator*(const float& other) return ret; if (!EqualsZero()) - return CCharAnimTime(m_time * other); + return CCharAnimTime(x0_time * other); if (other > 0.f) return *this; else if (other == 0.f) return ret; - ret.m_type = m_type; + ret.x4_type = x4_type; return ret; } @@ -336,7 +336,7 @@ float CCharAnimTime::operator/(const CCharAnimTime& other) if (other.EqualsZero()) return 0.f; - return m_time / other.m_time; + return x0_time / other.x0_time; } } diff --git a/Runtime/Character/CCharAnimTime.hpp b/Runtime/Character/CCharAnimTime.hpp index b8c54ec6f..7bef80bde 100644 --- a/Runtime/Character/CCharAnimTime.hpp +++ b/Runtime/Character/CCharAnimTime.hpp @@ -8,26 +8,35 @@ namespace urde class CCharAnimTime { - float m_time = 0.f; - enum class Type +public: + enum class EType { NonZero, ZeroIncreasing, ZeroSteady, ZeroDecreasing, Infinity - } m_type = Type::ZeroSteady; + }; +private: + float x0_time = 0.f; + EType x4_type = EType::ZeroSteady; public: CCharAnimTime() = default; CCharAnimTime(CInputStream& in) - : m_time(in.readFloatBig()), - m_type(Type(in.readUint32Big())) {} + : x0_time(in.readFloatBig()), + x4_type(EType(in.readUint32Big())) {} CCharAnimTime(float time) - : m_time(time), - m_type(m_time != 0.f ? Type::NonZero : Type::ZeroSteady) {} + : x0_time(time), + x4_type(x0_time != 0.f ? EType::NonZero : EType::ZeroSteady) {} + + CCharAnimTime(EType type, const float& t) + : x0_time(t) + , x4_type(type) + { + } static CCharAnimTime Infinity(); - operator float() const {return m_time;} + operator float() const {return x0_time;} bool EqualsZero() const; bool EpsilonZero() const; diff --git a/Runtime/Character/CConstantAnimationTimeScale.cpp b/Runtime/Character/CConstantAnimationTimeScale.cpp new file mode 100644 index 000000000..1113e0475 --- /dev/null +++ b/Runtime/Character/CConstantAnimationTimeScale.cpp @@ -0,0 +1,19 @@ +#include "CConstantAnimationTimeScale.hpp" + +namespace urde +{ + +float CConstantAnimationTimeScale::VTimeScaleIntegral(const float& a, const float& b) const { return (b - a) * x4_; } +float CConstantAnimationTimeScale::VFindUpperLimit(const float& a, const float& b) const { return (b / x4_) + a; } + +std::unique_ptr CConstantAnimationTimeScale::VClone() const +{ + return std::make_unique(x4_); +} + +std::unique_ptr CConstantAnimationTimeScale::VGetFunctionMirrored(const float&) const +{ + return Clone(); +} + +} diff --git a/Runtime/Character/CConstantAnimationTimeScale.hpp b/Runtime/Character/CConstantAnimationTimeScale.hpp new file mode 100644 index 000000000..aacdaad22 --- /dev/null +++ b/Runtime/Character/CConstantAnimationTimeScale.hpp @@ -0,0 +1,22 @@ +#ifndef __URDE_CONSTANTANIMATIONTIMESCALE_HPP__ +#define __URDE_CONSTANTANIMATIONTIMESCALE_HPP__ + +#include "IVaryingAnimationTimeScale.hpp" + +namespace urde +{ +class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale +{ +private: + float x4_; +public: + CConstantAnimationTimeScale(float f) : x4_(f) {} + + u32 GetType() const { return 0; } + float VTimeScaleIntegral(const float &, const float &) const; + float VFindUpperLimit(const float &, const float &) const; + std::unique_ptr VClone() const; + std::unique_ptr VGetFunctionMirrored(const float &) const; +}; +} +#endif // __URDE_CONSTANTANIMATIONTIMESCALE_HPP__ diff --git a/Runtime/Character/CAnimTreeScale.cpp b/Runtime/Character/CLinearAnimationTimeScale.cpp similarity index 100% rename from Runtime/Character/CAnimTreeScale.cpp rename to Runtime/Character/CLinearAnimationTimeScale.cpp diff --git a/Runtime/Character/CLinearAnimationTimeScale.hpp b/Runtime/Character/CLinearAnimationTimeScale.hpp new file mode 100644 index 000000000..a11e8ae75 --- /dev/null +++ b/Runtime/Character/CLinearAnimationTimeScale.hpp @@ -0,0 +1,31 @@ +#ifndef __URDE_CLINEARANIMATIONTIMESCALE_HPP__ +#define __URDE_CLINEARANIMATIONTIMESCALE_HPP__ + +#include "IVaryingAnimationTimeScale.hpp" + +namespace urde +{ +class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale +{ +public: + class CFunctionDescription + { + public: + CFunctionDescription(const float&, const float&, const float&); + CFunctionDescription FunctionMirroredAround(const float&) const; + }; + +private: +public: + CLinearAnimationTimeScale(const CCharAnimTime&, float, const CCharAnimTime&, float); + u32 GetType() const { return 1; } + float VTimeScaleIntegral(const float &, const float &) const { return 0.f; } + float VFindUpperLimit(const float &, const float &) const { return 0.f; } + std::unique_ptr VClone() { return {}; } + std::unique_ptr VGetFunctionMirrored(const float &) const { return {}; } + float TimeScaleIntegralWithSortedLimits(const CFunctionDescription&, const float&, const float&); + float GetScale(const CFunctionDescription&, const float&); +}; +} + +#endif // __URDE_CLINEARANIMATIONTIMESCALE_HPP__ diff --git a/Runtime/Character/CMakeLists.txt b/Runtime/Character/CMakeLists.txt index 9a3865e3f..6d434e4cf 100644 --- a/Runtime/Character/CMakeLists.txt +++ b/Runtime/Character/CMakeLists.txt @@ -7,6 +7,9 @@ set(CHARACTER_SOURCES CCharAnimTime.hpp CCharAnimTime.cpp IMetaAnim.hpp IMetaAnim.cpp IMetaTrans.hpp + IVaryingAnimationTimeScale.hpp + CLinearAnimationTimeScale.hpp CLinearAnimationTimeScale.cpp + CConstantAnimationTimeScale.hpp CConstantAnimationTimeScale.cpp CAnimationDatabase.hpp CAnimationDatabaseGame.hpp CAnimationDatabaseGame.cpp CTransitionDatabase.hpp @@ -53,7 +56,6 @@ set(CHARACTER_SOURCES CTreeUtils.hpp CTreeUtils.cpp CAnimTreeBlend.hpp CAnimTreeBlend.cpp CAnimTreeNode.hpp CAnimTreeNode.cpp - CAnimTreeScale.hpp CAnimTreeScale.cpp CAnimTreeTimeScale.hpp CAnimTreeTimeScale.cpp CAnimTreeTransition.hpp CAnimTreeTransition.cpp CAnimTreeTweenBase.hpp CAnimTreeTweenBase.cpp diff --git a/Runtime/Character/IVaryingAnimationTimeScale.hpp b/Runtime/Character/IVaryingAnimationTimeScale.hpp new file mode 100644 index 000000000..4c603f808 --- /dev/null +++ b/Runtime/Character/IVaryingAnimationTimeScale.hpp @@ -0,0 +1,29 @@ +#ifndef __URDE_IVARYINGANIMATIONTIMESCALE_HPP__ +#define __URDE_IVARYINGANIMATIONTIMESCALE_HPP__ + +#include "CCharAnimTime.hpp" + +namespace urde +{ +class IVaryingAnimationTimeScale +{ +public: + virtual u32 GetType() const = 0; + virtual float VTimeScaleIntegral(const float&, const float&) const = 0; + virtual float VFindUpperLimit(const float&, const float&) const = 0; + virtual std::unique_ptr VClone() const = 0; + virtual std::unique_ptr VGetFunctionMirrored(const float&) const = 0; + CCharAnimTime FindUpperLimit(const CCharAnimTime& a, const CCharAnimTime& b) const + { + return VFindUpperLimit(a, b); + } + + CCharAnimTime TimeScaleIntegral(const CCharAnimTime& a, const CCharAnimTime& b) const + { + return VTimeScaleIntegral(a, b); + } + + std::unique_ptr Clone() const { return VClone(); } +}; +} +#endif // __URDE_IVARYINGANIMATIONTIMESCALE_HPP__ diff --git a/Runtime/GuiSys/CGuiObject.hpp b/Runtime/GuiSys/CGuiObject.hpp index 4c7e11edb..5ddb75240 100644 --- a/Runtime/GuiSys/CGuiObject.hpp +++ b/Runtime/GuiSys/CGuiObject.hpp @@ -3,6 +3,7 @@ #include "RetroTypes.hpp" #include "zeus/CVector3f.hpp" +#include "zeus/CQuaternion.hpp" #include "zeus/CTransform.hpp" namespace urde diff --git a/Runtime/Particle/CVectorElement.cpp b/Runtime/Particle/CVectorElement.cpp index 37ec6cba5..47425e709 100644 --- a/Runtime/Particle/CVectorElement.cpp +++ b/Runtime/Particle/CVectorElement.cpp @@ -286,21 +286,21 @@ bool CVEParticleLocation::GetValue(int /*frame*/, zeus::CVector3f& valOut) const bool CVEParticleSystemOrientationFront::GetValue(int /*frame*/, zeus::CVector3f& valOut) const { zeus::CMatrix4f trans = CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation().toMatrix4f().transposed(); - valOut.assign(trans.vec[0].y, trans.vec[1].z, trans.vec[3].x); + valOut.assign(trans.vec[0].y, trans.vec[1].y, trans.vec[2].y); return false; } bool CVEParticleSystemOrientationUp::GetValue(int /*frame*/, zeus::CVector3f& valOut) const { zeus::CMatrix4f trans = CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation().toMatrix4f().transposed(); - valOut.assign(trans.vec[0].z, trans.vec[2].x, trans.vec[3].y); + valOut.assign(trans.vec[0].z, trans.vec[1].z, trans.vec[2].z); return false; } bool CVEParticleSystemOrientationRight::GetValue(int /*frame*/, zeus::CVector3f& valOut) const { zeus::CMatrix4f trans = CParticleGlobals::g_currentParticleSystem->x4_system->GetOrientation().toMatrix4f().transposed(); - valOut.assign(trans.vec[0].x, trans.vec[1].y, trans.vec[2].z); + valOut.assign(trans.vec[0].x, trans.vec[1].x, trans.vec[2].x); return false; } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 2411e6249..48929d3a0 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -59,7 +59,6 @@ protected: bool xe4_28_ : 1; bool xe4_29_ : 1; bool xe4_30_ : 1; - bool xe5_0_opaque : 1; bool xe5_26_muted : 1; bool xe5_27_useInSortedLists : 1; bool xe5_28_callTouch : 1; diff --git a/Runtime/World/CWorldTransManager.hpp b/Runtime/World/CWorldTransManager.hpp index 9455604a6..72b1871ac 100644 --- a/Runtime/World/CWorldTransManager.hpp +++ b/Runtime/World/CWorldTransManager.hpp @@ -118,6 +118,7 @@ public: bool IsTransitionEnabled() const { return x30_type != ETransType::Disabled; } void DisableTransition(); void TouchModels(); + ETransType GetTransType() { return x30_type; } }; } diff --git a/specter b/specter index 752480995..981cc9d0b 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 75248099540cc05b60beeac00fdebe47b80a1928 +Subproject commit 981cc9d0b3e7f99b314ebe1ef87b23a94e38e58e