mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Make NUSpline public members protected
Some checks are pending
Some checks are pending
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:
parent
aeeda05433
commit
0340cc9abd
4 changed files with 10 additions and 13 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue