Make NUSpline public members protected
Some checks are pending
checkrefs / lfscheck (push) Waiting to run
checkrefs / checkrefs (push) Waiting to run
lint / cppcheck (push) Waiting to run
lint / copyright (push) Waiting to run
lint / jenkinsfiles (push) Waiting to run
pre-commit / build (push) Waiting to run

Add a getter for MaxDistance and make members protected and inline
initialization.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2026-07-21 09:41:28 +02:00
parent aeeda05433
commit 0340cc9abd
No known key found for this signature in database
4 changed files with 10 additions and 13 deletions

View file

@ -92,12 +92,12 @@ void CCinemaManager::DrawSpline(Renderer::Backend::IDeviceCommandContext& device
if (spline.GetAllNodes().size() == 2)
smoothness = 2;
const float start = spline.m_MaxDistance.ToFloat() / smoothness;
const float start = spline.GetMaxDistance().ToFloat() / smoothness;
std::vector<CVector3D> line;
for (int i = 0; i <= smoothness; ++i)
{
const float time = start * i / spline.m_MaxDistance.ToFloat();
const float time = start * i / spline.GetMaxDistance().ToFloat();
line.emplace_back(spline.GetPosition(time));
}
@ -108,7 +108,7 @@ void CCinemaManager::DrawSpline(Renderer::Backend::IDeviceCommandContext& device
{
for (int i = 0; i <= smoothness; ++i)
{
const float time = start * i / spline.m_MaxDistance.ToFloat();
const float time = start * i / spline.GetMaxDistance().ToFloat();
const CVector3D tmp = spline.GetPosition(time);
const float groundY = g_Game->GetWorld()->GetTerrain().GetExactGroundLevel(tmp.X, tmp.Z);
g_Renderer.GetDebugRenderer().DrawLine(deviceCommandContext, tmp, CVector3D(tmp.X, groundY, tmp.Z), splineColor, 0.1f, false);

View file

@ -52,10 +52,7 @@ CVector3D GetPositionOnCubic(const CVector3D& startPos, const CVector3D& startVe
/*********************************** R N S **************************************************/
RNSpline::RNSpline()
: m_NodeCount(0)
{
}
RNSpline::RNSpline() = default;
RNSpline::~RNSpline() = default;

View file

@ -63,11 +63,11 @@ public:
CVector3D GetRotation(float time) const;
const std::vector<SplineData>& GetAllNodes() const;
fixed m_MaxDistance;
int m_NodeCount;
fixed GetMaxDistance() const { return m_MaxDistance; }
protected:
fixed m_MaxDistance;
int m_NodeCount{0};
std::vector<SplineData> m_Nodes;
CVector3D GetStartVelocity(int index);
CVector3D GetEndVelocity(int index);

View file

@ -90,7 +90,7 @@ fixed CCinemaPath::GetNodeDuration(const int index) const
fixed CCinemaPath::GetDuration() const
{
return m_MaxDistance;
return GetMaxDistance();
}
float CCinemaPath::GetNodeFraction() const
@ -121,8 +121,8 @@ void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRota
if (m_LookAtTarget)
{
if (m_TimeElapsed <= m_TargetSpline.m_MaxDistance.ToFloat())
camera.LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.m_MaxDistance.ToFloat()), CVector3D(0, 1, 0));
if (m_TimeElapsed <= m_TargetSpline.GetMaxDistance().ToFloat())
camera.LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.GetMaxDistance().ToFloat()), CVector3D(0, 1, 0));
else
camera.LookAt(pos, m_TargetSpline.GetAllNodes().back().Position, CVector3D(0, 1, 0));
}