diff --git a/Engine/source/math/mConsoleFunctions.cpp b/Engine/source/math/mConsoleFunctions.cpp index 0b5541f2f..5252d2306 100644 --- a/Engine/source/math/mConsoleFunctions.cpp +++ b/Engine/source/math/mConsoleFunctions.cpp @@ -105,6 +105,17 @@ DefineEngineFunction( mRound, S32, ( F32 v ),, return mRound(v); } +DefineEngineFunction(mRoundDelta, S32, (F32 v, S32 d), (0.0, 1), + "Round v to the nearest number based on the delta" + "@param v Value to round" + "@param d Delta use when rounding" + "@return The rounded value as a S32." + "@ingroup Math") +{ + return (mFloor(v / d + 0.5) * d); +} + + DefineEngineFunction( mRoundColour, F32, ( F32 v, S32 n ), (0), "Round v to the nth decimal place or the nearest whole number by default." "@param v Value to roundn" @@ -412,4 +423,4 @@ DefineEngineFunction(mGetSignedAngleBetweenVectors, F32, (VectorF vecA, VectorF } return MathUtils::getSignedAngleBetweenVectors(vecA, vecB, norm); -} \ No newline at end of file +} diff --git a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Events/VDirectorEvent.cs b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Events/VDirectorEvent.cs index 6eb5bf331..75321c28a 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Events/VDirectorEvent.cs +++ b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Events/VDirectorEvent.cs @@ -91,7 +91,7 @@ function VDirectorEvent::getSnapTime( %this, %targetTime ) if ( $VerveEditor::Event::SnapTime > 0 ) { // Snap. - return mRound( %targetTime, $VerveEditor::Event::SnapTime ); + return mRoundDelta( %targetTime, $VerveEditor::Event::SnapTime ); } // No Snap! diff --git a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Events/VEvent.cs b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Events/VEvent.cs index 57ec6ce85..09129020c 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Events/VEvent.cs +++ b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Events/VEvent.cs @@ -197,7 +197,7 @@ function VEvent::getSnapTime( %this, %targetTime ) if ( $Pref::VerveEditor::Event::SnapToTime && $Pref::VerveEditor::Event::SnapToTimeThreshold > 0 ) { // Snap. - return mRound( %targetTime, $Pref::VerveEditor::Event::SnapToTimeThreshold ); + return mRoundDelta( %targetTime, $Pref::VerveEditor::Event::SnapToTimeThreshold ); } // No Snap! diff --git a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Utility.cs b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Utility.cs index 4a63d6484..bb1ce5397 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Utility.cs +++ b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Utility.cs @@ -45,17 +45,6 @@ function GuiControl::getParentOfType( %this, %className ) return 0; } -//----------------------------------------------------------------------------- -// -// MATH -// -//----------------------------------------------------------------------------- - -function mRound( %number, %delta ) -{ - return ( mFloor( %number / %delta + 0.5 ) * %delta ); -} - //----------------------------------------------------------------------------- // // STRING