From 14e1b79a0ff86424544b7a484b67e34c211bf0f1 Mon Sep 17 00:00:00 2001 From: elexis Date: Sat, 1 Jul 2017 15:49:59 +0000 Subject: [PATCH] Insert cinematic path nodes after the currently selected node instead of before (so paths are not created in the opposite of the expected order). Differential Revision: https://code.wildfiregames.com/D656 Refs #3871 Patch By: Vladislav This was SVN commit r19864. --- source/maths/NUSpline.cpp | 7 ++++++- .../tools/atlas/GameInterface/Handlers/CinemaHandler.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/maths/NUSpline.cpp b/source/maths/NUSpline.cpp index d68e811dbc..0ff68d77ec 100644 --- a/source/maths/NUSpline.cpp +++ b/source/maths/NUSpline.cpp @@ -16,6 +16,9 @@ */ #include "precompiled.h" + +#include + #include "NUSpline.h" #include "Matrix3D.h" @@ -218,7 +221,7 @@ void TNSpline::AddNode(const CFixedVector3D& pos, const CFixedVector3D& rotation //Inserts node before position void TNSpline::InsertNode(const int index, const CFixedVector3D& pos, const CFixedVector3D& UNUSED(rotation), fixed timePeriod) { - if (NodeCount >= MAX_SPLINE_NODES || index < 0 || index > NodeCount - 1) + if (NodeCount >= MAX_SPLINE_NODES || index < 0 || index > NodeCount) return; if (NodeCount == 0) @@ -230,6 +233,8 @@ void TNSpline::InsertNode(const int index, const CFixedVector3D& pos, const CFix temp.Position = pos; temp.Distance = timePeriod; Node.insert(Node.begin() + index, temp); + if (index > 0) + std::swap(Node[index].Distance, Node[index - 1].Distance); ++NodeCount; } diff --git a/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp b/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp index f107aaf929..e41af2666c 100644 --- a/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp +++ b/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp @@ -340,7 +340,7 @@ BEGIN_COMMAND(AddPathNode) fixed::FromFloat(focus.Y), fixed::FromFloat(focus.Z) ); - spline.InsertNode(index, target, CFixedVector3D(), fixed::FromInt(1)); + spline.InsertNode(index + 1, target, CFixedVector3D(), fixed::FromInt(1)); spline.BuildSpline(); cmpCinemaManager->DeletePath(name);