1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 07:37:45 +00:00

add position offset calcs

This commit is contained in:
Tahir 2024-06-19 03:18:37 +01:00
parent 0e55c62e2d
commit 011cf1b6d2
2 changed files with 21 additions and 0 deletions

View file

@ -80,6 +80,25 @@ uint8_t Util::floatToUInt8Rot( float val )
return static_cast< uint8_t >( 0x80 * ( ( val + PI ) ) / PI );
}
FFXIVARR_POSITION3 Util::getOffsettedPosition( const FFXIVARR_POSITION3& pos, float rot, float left, float up, float forward )
{
FFXIVARR_POSITION3 ret{ pos };
// height
ret.y += up;
// forward
float angle = rot + ( PI / 2 );
ret.x -= forward * cos( angle );
ret.z += forward * sin( angle );
// side
ret.x += left * cos( rot );
ret.z += left * sin( rot );
return ret;
}
FFXIVARR_POSITION3 Util::transform( const FFXIVARR_POSITION3& vector, const Matrix33& matrix )
{
FFXIVARR_POSITION3 dst{};

View file

@ -29,6 +29,8 @@ namespace Sapphire::Common::Util
uint8_t floatToUInt8Rot( float val );
FFXIVARR_POSITION3 getOffsettedPosition( const FFXIVARR_POSITION3& pos, float rotation, float left, float up, float forward );
template < typename T >
T clamp( T val, T minimum, T maximum )
{