From f8b8211b0f90937189270fccc386f53dec8853f0 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 25 Jun 2018 19:42:16 -1000 Subject: [PATCH] Name PathCamera property fields --- DataSpec/DNAMP1/ScriptObjects/PathCamera.hpp | 26 ++++++++++---------- Runtime/Camera/CCameraSpline.cpp | 2 +- Runtime/Camera/CCameraSpline.hpp | 2 +- Runtime/Camera/CPathCamera.cpp | 20 ++++++++------- Runtime/Camera/CPathCamera.hpp | 15 +++++------ Runtime/World/ScriptLoader.cpp | 15 +++++------ 6 files changed, 42 insertions(+), 38 deletions(-) diff --git a/DataSpec/DNAMP1/ScriptObjects/PathCamera.hpp b/DataSpec/DNAMP1/ScriptObjects/PathCamera.hpp index bca12dbc6..fb14216e0 100644 --- a/DataSpec/DNAMP1/ScriptObjects/PathCamera.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/PathCamera.hpp @@ -14,25 +14,25 @@ struct PathCamera : IScriptObject String<-1> name; Value location; Value orientation; - Value unknown1; + Value active; struct CameraParameters : BigDNA { AT_DECL_DNA Value propertyCount; - Value unknown1; - Value unknown2; - Value unknown3; - Value unknown4; - Value unknown5; - Value unknown6; + Value closedLoop; + Value noFilter; + Value tangentOrientation; + Value easeDist; + Value useHintLookZ; + Value clampToClosedDoor; } cameraParameters; - Value unknown2; - Value unknown3; - Value unknown4; - Value unknown5; - Value unknown6; - Value unknown7; + Value lengthExtent; + Value filterMag; + Value filterProportion; + Value initPos; + Value minEaseDist; + Value maxEaseDist; }; } diff --git a/Runtime/Camera/CCameraSpline.cpp b/Runtime/Camera/CCameraSpline.cpp index bd047033d..bcb01066b 100644 --- a/Runtime/Camera/CCameraSpline.cpp +++ b/Runtime/Camera/CCameraSpline.cpp @@ -5,7 +5,7 @@ namespace urde { -CCameraSpline::CCameraSpline(bool b) : x48_closedLoop(b) {} +CCameraSpline::CCameraSpline(bool closedLoop) : x48_closedLoop(closedLoop) {} void CCameraSpline::CalculateKnots(TUniqueId cameraId, const std::vector& connections, CStateManager& mgr) { diff --git a/Runtime/Camera/CCameraSpline.hpp b/Runtime/Camera/CCameraSpline.hpp index 7cec25c01..f1ad8a22e 100644 --- a/Runtime/Camera/CCameraSpline.hpp +++ b/Runtime/Camera/CCameraSpline.hpp @@ -21,7 +21,7 @@ class CCameraSpline bool GetSurroundingPoints(int idx, rstl::reserved_vector& positions, rstl::reserved_vector& directions) const; public: - CCameraSpline(bool); + CCameraSpline(bool closedLoop); void CalculateKnots(TUniqueId, const std::vector&, CStateManager&); void Initialize(TUniqueId, const std::vector&, CStateManager&); void Reset(int size); diff --git a/Runtime/Camera/CPathCamera.cpp b/Runtime/Camera/CPathCamera.cpp index 76e5fea3d..07345c778 100644 --- a/Runtime/Camera/CPathCamera.cpp +++ b/Runtime/Camera/CPathCamera.cpp @@ -12,15 +12,17 @@ namespace urde { CPathCamera::CPathCamera(TUniqueId uid, std::string_view name, const CEntityInfo& info, - const zeus::CTransform& xf, bool active, float f1, float f2, - float f3, float f4, float f5, u32 flags, EInitialSplinePosition initPos) + const zeus::CTransform& xf, bool active, float lengthExtent, float filterMag, + float filterProportion, float minEaseDist, float maxEaseDist, u32 flags, + EInitialSplinePosition initPos) : CGameCamera(uid, active, name, info, xf, CCameraManager::ThirdPersonFOV(), CCameraManager::NearPlane(), CCameraManager::FarPlane(), CCameraManager::Aspect(), kInvalidUniqueId, 0, 0) -, x188_spline(flags & 1), x1dc_lengthExtent(f1), x1e0_(f2), x1e4_(f3), x1e8_initPos(initPos) -, x1ec_flags(flags), x1f0_(f4), x1f4_(f5) +, x188_spline(flags & 1), x1dc_lengthExtent(lengthExtent), x1e0_filterMag(filterMag) +, x1e4_filterProportion(filterProportion), x1e8_initPos(initPos), x1ec_flags(flags) +, x1f0_minEaseDist(minEaseDist), x1f4_maxEaseDist(maxEaseDist) { } @@ -168,7 +170,8 @@ zeus::CTransform CPathCamera::MoveAlongSpline(float t, CStateManager& mgr) float distToPlayer = 0.f; if (splineToPlayer.canBeNormalized()) distToPlayer = splineToPlayer.magnitude(); - f30 *= 1.f - std::sin(zeus::degToRad(zeus::clamp(0.f, (distToPlayer - x1f0_) / (x1f4_ - x1f0_), 1.f) * 90.f)); + f30 *= 1.f - std::sin(zeus::degToRad(zeus::clamp(0.f, (distToPlayer - x1f0_minEaseDist) / + (x1f4_maxEaseDist - x1f0_minEaseDist), 1.f) * 90.f)); } float newPos; @@ -207,9 +210,8 @@ zeus::CTransform CPathCamera::MoveAlongSpline(float t, CStateManager& mgr) if (x188_spline.IsClosedLoop()) { float absDelta = std::fabs(newPos - x1d4_pos); - if (absDelta > x188_spline.GetLength() - absDelta) - absDelta = x188_spline.GetLength() - absDelta; - float tBias = zeus::clamp(-1.f, absDelta / x1e4_, 1.f) * x1e0_ * t; + absDelta = std::min(absDelta, x188_spline.GetLength() - absDelta); + float tBias = zeus::clamp(-1.f, absDelta / x1e4_filterProportion, 1.f) * x1e0_filterMag * t; float tmpAbs = std::fabs(x1d4_pos - newPos); float absDelta2 = x188_spline.GetLength() - tmpAbs; if (x1d4_pos > newPos) @@ -227,7 +229,7 @@ zeus::CTransform CPathCamera::MoveAlongSpline(float t, CStateManager& mgr) else { x1d4_pos = x188_spline.ValidateLength( - zeus::clamp(-1.f, (newPos - x1d4_pos) / x1e4_, 1.f) * x1e0_ * t + x1d4_pos); + zeus::clamp(-1.f, (newPos - x1d4_pos) / x1e4_filterProportion, 1.f) * x1e0_filterMag * t + x1d4_pos); } ret = x188_spline.GetInterpolatedSplinePointByLength(x1d4_pos); } diff --git a/Runtime/Camera/CPathCamera.hpp b/Runtime/Camera/CPathCamera.hpp index df606aeb6..fd7bd7e04 100644 --- a/Runtime/Camera/CPathCamera.hpp +++ b/Runtime/Camera/CPathCamera.hpp @@ -23,17 +23,18 @@ private: float x1d4_pos = 0.f; float x1d8_time = 0.f; float x1dc_lengthExtent; - float x1e0_; - float x1e4_; + float x1e0_filterMag; + float x1e4_filterProportion; EInitialSplinePosition x1e8_initPos; u32 x1ec_flags; - float x1f0_; - float x1f4_; + float x1f0_minEaseDist; + float x1f4_maxEaseDist; public: - CPathCamera(TUniqueId, std::string_view name, const CEntityInfo& info, - const zeus::CTransform& xf, bool, float, float, float, - float, float, u32, EInitialSplinePosition); + CPathCamera(TUniqueId uid, std::string_view name, const CEntityInfo& info, + const zeus::CTransform& xf, bool active, float lengthExtent, float filterMag, + float filterProportion, float minEaseDist, float maxEaseDist, u32 flags, + EInitialSplinePosition initPos); void Accept(IVisitor&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index feb2afaa1..13a5b73af 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -1452,14 +1452,15 @@ CEntity* ScriptLoader::LoadPathCamera(CStateManager& mgr, CInputStream& in, int SActorHead aHead = LoadActorHead(in, mgr); bool active = in.readBool(); u32 flags = LoadParameterFlags(in); - float f1 = in.readFloatBig(); - float f2 = in.readFloatBig(); - float f3 = in.readFloatBig(); + float lengthExtent = in.readFloatBig(); + float filterMag = in.readFloatBig(); + float filterProportion = in.readFloatBig(); CPathCamera::EInitialSplinePosition initPos = CPathCamera::EInitialSplinePosition(in.readUint32Big()); - float f4 = in.readFloatBig(); - float f5 = in.readFloatBig(); - return new CPathCamera(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform, active, f1, f2, f3, f4, f5, - flags, initPos); + float minEaseDist = in.readFloatBig(); + float maxEaseDist = in.readFloatBig(); + + return new CPathCamera(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform, active, lengthExtent, + filterMag, filterProportion, minEaseDist, maxEaseDist, flags, initPos); } CEntity* ScriptLoader::LoadGrapplePoint(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)