mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-04-15 22:12:34 +03:00
Add Vector Zero Funcs. & Improve Vector.Inc File
Add **bool: IsVectorZero ( Float: Vector [ 3 ] )** to check whether a vector equals to zero. Add **SetVectorZero ( Float: Vector [ 3 ] )** to assign a vector to zero. Remove redundant tabs at some lines. Fix spelling @ **get_distance_f**. This PR intends to complete AMXX's Vector library adding new stuff to it. Also, the new two functions listed above will help plugins using this kind of stuff look more readable.
This commit is contained in:
parent
582df637ce
commit
39cabb5e79
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* @param origin1 The first vector
|
* @param origin1 The first vector
|
||||||
* @param origin2 The second vector
|
* @param origin2 The second vector
|
||||||
*
|
*
|
||||||
* @return The distance between two input vectors
|
* @return The distance between two input vectors
|
||||||
*/
|
*/
|
||||||
native get_distance(const origin1[3], const origin2[3]);
|
native get_distance(const origin1[3], const origin2[3]);
|
||||||
@ -38,10 +38,10 @@ native get_distance(const origin1[3], const origin2[3]);
|
|||||||
*
|
*
|
||||||
* @param origin1 The first vector
|
* @param origin1 The first vector
|
||||||
* @param origin2 The second vector
|
* @param origin2 The second vector
|
||||||
*
|
*
|
||||||
* @return The distance between two input vectors
|
* @return The distance between two input vectors
|
||||||
*/
|
*/
|
||||||
native Float:get_distance_f(const Float:Origin1[3], const Float:Origin2[3]);
|
native Float:get_distance_f(const Float:origin1[3], const Float:origin2[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates velocity in the direction player is looking.
|
* Calculates velocity in the direction player is looking.
|
||||||
@ -49,7 +49,7 @@ native Float:get_distance_f(const Float:Origin1[3], const Float:Origin2[3]);
|
|||||||
* @param iIndex Client index
|
* @param iIndex Client index
|
||||||
* @param iVelocity Multiply vRetValue length by this much
|
* @param iVelocity Multiply vRetValue length by this much
|
||||||
* @param vRetValue Store the calculated velocity in this vector.
|
* @param vRetValue Store the calculated velocity in this vector.
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error If client is not connected or client index is not
|
* @error If client is not connected or client index is not
|
||||||
* within the range of 1 to MaxClients.
|
* within the range of 1 to MaxClients.
|
||||||
@ -61,7 +61,7 @@ native velocity_by_aim(iIndex, iVelocity, Float:vRetValue[3]);
|
|||||||
*
|
*
|
||||||
* @param fVector Input vector
|
* @param fVector Input vector
|
||||||
* @param vReturn Output angle vector
|
* @param vReturn Output angle vector
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
native vector_to_angle(const Float:fVector[3], Float:vReturn[3]);
|
native vector_to_angle(const Float:fVector[3], Float:vReturn[3]);
|
||||||
@ -72,7 +72,7 @@ native vector_to_angle(const Float:fVector[3], Float:vReturn[3]);
|
|||||||
* @param vector Input angle vector
|
* @param vector Input angle vector
|
||||||
* @param FRU One of the ANGLEVECTOR_* constants
|
* @param FRU One of the ANGLEVECTOR_* constants
|
||||||
* @param ret Output vector
|
* @param ret Output vector
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
native angle_vector(const Float:vector[3], FRU, Float:ret[3]);
|
native angle_vector(const Float:vector[3], FRU, Float:ret[3]);
|
||||||
@ -81,7 +81,7 @@ native angle_vector(const Float:vector[3], FRU, Float:ret[3]);
|
|||||||
* Calculates the length of a vector.
|
* Calculates the length of a vector.
|
||||||
*
|
*
|
||||||
* @param vVector Input vector
|
* @param vVector Input vector
|
||||||
*
|
*
|
||||||
* @return Length of the input vector
|
* @return Length of the input vector
|
||||||
*/
|
*/
|
||||||
native Float:vector_length(const Float:vVector[3]);
|
native Float:vector_length(const Float:vVector[3]);
|
||||||
@ -91,7 +91,7 @@ native Float:vector_length(const Float:vVector[3]);
|
|||||||
*
|
*
|
||||||
* @param vVector The first vector
|
* @param vVector The first vector
|
||||||
* @param vVector2 The second vector
|
* @param vVector2 The second vector
|
||||||
*
|
*
|
||||||
* @return Distance between two input vectors
|
* @return Distance between two input vectors
|
||||||
*/
|
*/
|
||||||
native Float:vector_distance(const Float:vVector[3], const Float:vVector2[3]);
|
native Float:vector_distance(const Float:vVector[3], const Float:vVector2[3]);
|
||||||
@ -101,7 +101,7 @@ native Float:vector_distance(const Float:vVector[3], const Float:vVector2[3]);
|
|||||||
*
|
*
|
||||||
* @param IVec Input integer vector
|
* @param IVec Input integer vector
|
||||||
* @param FVec Output float vector
|
* @param FVec Output float vector
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
stock IVecFVec(const IVec[3], Float:FVec[3])
|
stock IVecFVec(const IVec[3], Float:FVec[3])
|
||||||
@ -118,7 +118,7 @@ stock IVecFVec(const IVec[3], Float:FVec[3])
|
|||||||
*
|
*
|
||||||
* @param FVec Input float vector
|
* @param FVec Input float vector
|
||||||
* @param IVec Output integer vector
|
* @param IVec Output integer vector
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
stock FVecIVec(const Float:FVec[3], IVec[3])
|
stock FVecIVec(const Float:FVec[3], IVec[3])
|
||||||
@ -126,6 +126,30 @@ stock FVecIVec(const Float:FVec[3], IVec[3])
|
|||||||
IVec[0] = floatround(FVec[0]);
|
IVec[0] = floatround(FVec[0]);
|
||||||
IVec[1] = floatround(FVec[1]);
|
IVec[1] = floatround(FVec[1]);
|
||||||
IVec[2] = floatround(FVec[2]);
|
IVec[2] = floatround(FVec[2]);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a vector is zero.
|
||||||
|
*
|
||||||
|
* @param Vector The input vector
|
||||||
|
*
|
||||||
|
* @return True if the vector is zero, false otherwise
|
||||||
|
*/
|
||||||
|
stock bool:IsVectorZero(const Float:Vector[3])
|
||||||
|
{
|
||||||
|
return (Vector[0] == 0.0 && Vector[1] == 0.0 && Vector[2] == 0.0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a vector to zero
|
||||||
|
*
|
||||||
|
* @param Vector Vector
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
stock SetVectorZero(Float:Vector[3])
|
||||||
|
{
|
||||||
|
Vector[0] = Vector[1] = Vector[2] = 0.0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user