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.
This commit is contained in:
elexis 2017-07-01 15:49:59 +00:00
parent c67d79d9f3
commit 14e1b79a0f
2 changed files with 7 additions and 2 deletions

View File

@ -16,6 +16,9 @@
*/
#include "precompiled.h"
#include <algorithm>
#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;
}

View File

@ -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);