Files
itgmania212121/src/RageMath.h
T
MrThatKidandColby Klein e15e0e68be Add nITG's various path shape & other modifiers - V2 (#1435)
* Implemented nITG's Square modifiers

Modifiers added:
Square
SquareOffset
SquarePeriod
SquareZ
SquareZOffset
SquareZPeriod

* Implemented nITG's BumpyX Modifiers

Also fixes up some tiny bits pertaining to the square modifiers.
Modifiers Added:
BumpyX
BumpyXPeriod
BumpyXOffset

* Implemented nITG's TornadoZ Modifiers

Modifiers Added:
TornadoZ
TornadoZPeriod
TornadoZOffset

Another commit is needed to update fallback's metrics

* Update fallback's metrics to accommodate TornadoX

* Implemented nITG's Parabola Modifiers

Modifiers Added:
ParabolaX
ParabolaY
ParabolaZ

* Implemented nITG's Sawtooth Modifiers

Modifiers Added:
Sawtooth
SawtoothPeriod
SawtoothZ
SawtoothZPeriod

* Implemented nITG's Zigzag Modifiers

Modifiers Added:
Zigzag
ZigzagPeriod
ZigzagOffset
ZigzagZ
ZigzagZPeriod
ZigzagZOffset

* Implemented nITG's ModTimer modifiers

Modifiers Added:
ModTimer (Lua method name is ModTimerSetting (takes enums. Ex: 'ModTimerType_Song'). Can be activated with mod strings 'modtimer(song/beat/game/default)' )
ModTimerOffset
ModTimerMult

* Remove Log use from ArrowEffects::GetTime()

* Accidentally removed a CPY(m_BatteryLives)

* Implemented nITG's DrunkZ modifiers

Modifiers added:
drunkz
drunkzspeed
drunkzoffset
drunkzperiod

Another commit is needed to update fallback's metrics

* Update fallback's metrics to accommodate DrunkZ

* Implemented nITG's BeatY & BeatZ Modifers

Modifiers Added:
beaty
beatyoffset
beatyperiod
beatymult	
beatz
beatzoffset
beatzperiod
beatzmult

Another commit is needed to update fallback's metrics

* Updated fallback's metrics to accommodate ...

the new Beat modifiers.

* Implemented nITG's Digital Modifiers

Modifers Added:
digital
digitalsteps
digitalperiod
digitaloffset
digitalz
digitalzsteps
digitalzperiod
digitalzoffset

* Removed duplicate zbuffer check.

* Updated Luadocs with the new modifiers

* Removed accidental duplicate Mini from Luadocs

* Split up long modifier lines.

Hopefully, this makes it a bit easier to read.

* Remove accidental commit to root of repo.

* Split up long modifier lines

Hopefully, this makes it easier to read.

* Redid Square functions to not use FastSin

This implementation is based off of 5.2's square_wave function from ModValue.

* Redid zigzag functions to not use FastSin

This implementation is based off of 5.2's triangle_wave function from ModValue.

* Moved square & zigzag calculation to RageMath.

New RageMath functions:
RageSquare
RageTriangle

* Made Square & Digital have the same period...

as Zigzag and Sawtooth.

* Deduplicate tornado calculations.

* Fixed typo in UpdateTornado, and moved UpdateTornado logic to ArrowEffects::Init because it doesn't depend on anything that changes every frame.  Tornado metrics are also loaded in ArrowEffects::Init.

* Deduplicated Beat mod update logic.

The logic is now placed into a function called UpdateBeat.
The m_fBeatFactor members are now a 1D array, similar to m_MaxTornado and m_MinTornado.
2017-05-13 11:34:34 -07:00

125 lines
5.1 KiB
C++

/* RageMath - vector/matrix math utilities. */
#ifndef RAGE_MATH_H
#define RAGE_MATH_H
#define PI (3.141592653589793f)
#define DegreeToRadian( degree ) ((degree) * (PI / 180.0f))
#define RadianToDegree( radian ) ((radian) * (180.0f / PI))
struct lua_State;
struct RageVector2;
struct RageVector3;
struct RageVector4;
struct RageMatrix;
void RageVec3ClearBounds( RageVector3 &mins, RageVector3 &maxs );
void RageVec3AddToBounds( const RageVector3 &p, RageVector3 &mins, RageVector3 &maxs );
void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV );
void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV );
void VectorFloatNormalize(vector<float>& v);
void RageVec3Cross(RageVector3* ret, RageVector3 const* a, RageVector3 const* b);
void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM );
void RageVec3TransformNormal( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM );
void RageVec4TransformCoord( RageVector4* pOut, const RageVector4* pV, const RageMatrix* pM );
void RageMatrixIdentity( RageMatrix* pOut );
// pOut = pB * pA
void RageMatrixMultiply( RageMatrix* pOut, const RageMatrix* pA, const RageMatrix* pB );
void RageMatrixTranslation( RageMatrix* pOut, float x, float y, float z );
void RageMatrixScaling( RageMatrix* pOut, float x, float y, float z );
void RageMatrixSkewX( RageMatrix* pOut, float fAmount );
void RageMatrixSkewY( RageMatrix* pOut, float fAmount );
void RageMatrixTranslate( RageMatrix* pOut, float fTransX, float fTransY, float fTransZ );
void RageMatrixScale( RageMatrix* pOut, float fScaleX, float fScaleY, float fScaleZ );
void RageMatrixRotationX( RageMatrix* pOut, float fTheta );
void RageMatrixRotationY( RageMatrix* pOut, float fTheta );
void RageMatrixRotationZ( RageMatrix* pOut, float fTheta );
void RageMatrixRotationXYZ( RageMatrix* pOut, float rX, float rY, float rZ );
void RageAARotate(RageVector3* inret, RageVector3 const* axis, float angle);
void RageQuatFromHPR(RageVector4* pOut, RageVector3 hpr );
void RageQuatFromPRH(RageVector4* pOut, RageVector3 prh );
void RageMatrixFromQuat( RageMatrix* pOut, const RageVector4 q );
void RageQuatSlerp(RageVector4 *pOut, const RageVector4 &from, const RageVector4 &to, float t);
RageVector4 RageQuatFromH(float theta);
RageVector4 RageQuatFromP(float theta);
RageVector4 RageQuatFromR(float theta);
void RageQuatMultiply( RageVector4* pOut, const RageVector4 &pA, const RageVector4 &pB );
RageMatrix RageLookAt(
float eyex, float eyey, float eyez,
float centerx, float centery, float centerz,
float upx, float upy, float upz );
void RageMatrixAngles( RageMatrix* pOut, const RageVector3 &angles );
void RageMatrixTranspose( RageMatrix* pOut, const RageMatrix* pIn );
float RageFastSin( float x ) CONST_FUNCTION;
float RageFastCos( float x ) CONST_FUNCTION;
float RageSquare( float x) CONST_FUNCTION;
float RageTriangle( float x) CONST_FUNCTION;
class RageQuadratic
{
public:
void SetFromBezier( float fC1, float fC2, float fC3, float fC4 );
void GetBezier( float &fC1, float &fC2, float &fC3, float &fC4 ) const;
void SetFromCubic( float fX1, float fX2, float fX3, float fX4 );
float Evaluate( float fT ) const;
float GetSlope( float fT ) const;
/* Equivalent to Evaluate(0.0f) and Evaluate(1.0f), but faster: */
float GetBezierStart() const { return m_fD; }
float GetBezierEnd() const { return m_fA + m_fB + m_fC + m_fD; }
void PushSelf(lua_State* L);
private:
float m_fA, m_fB, m_fC, m_fD;
};
class RageBezier2D
{
public:
void SetFromBezier( float fC1X, float fC2X, float fC3X, float fC4X,
float fC1Y, float fC2Y, float fC3Y, float fC4Y );
void Evaluate( float fT, float *pX, float *pY ) const;
float EvaluateYFromX( float fX ) const;
RageQuadratic& get_x() { return m_X; }
RageQuadratic& get_y() { return m_Y; }
void PushSelf(lua_State* L);
private:
RageQuadratic m_X;
RageQuadratic m_Y;
};
#endif
/*
* Copyright (c) 2001-2006 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/