From 92d65462b9e3efbf739090ce0a418f48388fb864 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 6 Apr 2020 12:46:28 -0400 Subject: [PATCH] CCameraSpline: Resolve sign-conversion warnings All call sites are already compatible with these changes, so they can safely be made. --- Runtime/Camera/CCameraSpline.cpp | 33 +++++++++++++++++++------------- Runtime/Camera/CCameraSpline.hpp | 10 +++++----- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Runtime/Camera/CCameraSpline.cpp b/Runtime/Camera/CCameraSpline.cpp index 52e5d5a9f..3079feb64 100644 --- a/Runtime/Camera/CCameraSpline.cpp +++ b/Runtime/Camera/CCameraSpline.cpp @@ -50,15 +50,18 @@ void CCameraSpline::Initialize(TUniqueId cameraId, const std::vector= x4_positions.size()) +void CCameraSpline::SetKnotPosition(size_t idx, const zeus::CVector3f& pos) { + if (idx >= x4_positions.size()) { return; + } x4_positions[idx] = pos; } -const zeus::CVector3f& CCameraSpline::GetKnotPosition(int idx) const { - if (idx >= x4_positions.size()) +const zeus::CVector3f& CCameraSpline::GetKnotPosition(size_t idx) const { + if (idx >= x4_positions.size()) { return zeus::skZero3f; + } return x4_positions[idx]; } -float CCameraSpline::GetKnotT(int idx) const { - if (idx >= x4_positions.size()) +float CCameraSpline::GetKnotT(size_t idx) const { + if (idx >= x4_positions.size()) { return 0.f; + } return x24_t[idx]; } @@ -117,10 +123,11 @@ float CCameraSpline::CalculateSplineLength() { return 0.f; } -bool CCameraSpline::GetSurroundingPoints(int idx, rstl::reserved_vector& positions, +bool CCameraSpline::GetSurroundingPoints(size_t idx, rstl::reserved_vector& positions, rstl::reserved_vector& directions) const { - if (x4_positions.size() <= 3 || idx < 0 || idx >= x4_positions.size()) + if (x4_positions.size() <= 3 || idx < 0 || idx >= x4_positions.size()) { return false; + } if (idx > 0) { positions.push_back(x4_positions[idx - 1]); diff --git a/Runtime/Camera/CCameraSpline.hpp b/Runtime/Camera/CCameraSpline.hpp index 4a958e425..7dd48aece 100644 --- a/Runtime/Camera/CCameraSpline.hpp +++ b/Runtime/Camera/CCameraSpline.hpp @@ -15,18 +15,18 @@ class CCameraSpline { std::vector x34_directions; float x44_length = 0.f; bool x48_closedLoop = false; - bool GetSurroundingPoints(int idx, rstl::reserved_vector& positions, + bool GetSurroundingPoints(size_t idx, rstl::reserved_vector& positions, rstl::reserved_vector& directions) const; public: explicit CCameraSpline(bool closedLoop); void CalculateKnots(TUniqueId cameraId, const std::vector& connections, CStateManager& mgr); void Initialize(TUniqueId cameraId, const std::vector& connections, CStateManager& mgr); - void Reset(int size); + void Reset(size_t size); void AddKnot(const zeus::CVector3f& pos, const zeus::CVector3f& dir); - void SetKnotPosition(int idx, const zeus::CVector3f& pos); - const zeus::CVector3f& GetKnotPosition(int idx) const; - float GetKnotT(int idx) const; + void SetKnotPosition(size_t idx, const zeus::CVector3f& pos); + const zeus::CVector3f& GetKnotPosition(size_t idx) const; + float GetKnotT(size_t idx) const; float CalculateSplineLength(); void UpdateSplineLength() { x44_length = CalculateSplineLength(); } zeus::CTransform GetInterpolatedSplinePointByLength(float pos) const;