Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vector Zero Funcs. & Improve Vector.Inc File #549

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions plugins/include/vector.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
*
* @param origin1 The first vector
* @param origin2 The second vector
*
*
* @return The distance between two input vectors
*/
native get_distance(const origin1[3], const origin2[3]);

/**
* Calculates the distance between two input float vectors.
*
* @param origin1 The first vector
* @param origin2 The second vector
*
* @param Origin1 The first vector
* @param Origin2 The second vector
*
* @return The distance between two input vectors
*/
native Float:get_distance_f(const Float:Origin1[3], const Float:Origin2[3]);
Expand All @@ -49,7 +49,7 @@ native Float:get_distance_f(const Float:Origin1[3], const Float:Origin2[3]);
* @param iIndex Client index
* @param iVelocity Multiply vRetValue length by this much
* @param vRetValue Store the calculated velocity in this vector.
*
*
* @noreturn
* @error If client is not connected or client index is not
* within the range of 1 to MaxClients.
Expand All @@ -61,7 +61,7 @@ native velocity_by_aim(iIndex, iVelocity, Float:vRetValue[3]);
*
* @param fVector Input vector
* @param vReturn Output angle vector
*
*
* @noreturn
*/
native vector_to_angle(const Float:fVector[3], Float:vReturn[3]);
Expand All @@ -72,7 +72,7 @@ native vector_to_angle(const Float:fVector[3], Float:vReturn[3]);
* @param vector Input angle vector
* @param FRU One of the ANGLEVECTOR_* constants
* @param ret Output vector
*
*
* @noreturn
*/
native angle_vector(const Float:vector[3], FRU, Float:ret[3]);
Expand All @@ -81,7 +81,7 @@ native angle_vector(const Float:vector[3], FRU, Float:ret[3]);
* Calculates the length of a vector.
*
* @param vVector Input vector
*
*
* @return Length of the input vector
*/
native Float:vector_length(const Float:vVector[3]);
Expand All @@ -91,7 +91,7 @@ native Float:vector_length(const Float:vVector[3]);
*
* @param vVector The first vector
* @param vVector2 The second vector
*
*
* @return Distance between two input vectors
*/
native Float:vector_distance(const Float:vVector[3], const Float:vVector2[3]);
Expand All @@ -101,7 +101,7 @@ native Float:vector_distance(const Float:vVector[3], const Float:vVector2[3]);
*
* @param IVec Input integer vector
* @param FVec Output float vector
*
*
* @noreturn
*/
stock IVecFVec(const IVec[3], Float:FVec[3])
Expand All @@ -118,14 +118,38 @@ stock IVecFVec(const IVec[3], Float:FVec[3])
*
* @param FVec Input float vector
* @param IVec Output integer vector
*
*
* @noreturn
*/
stock FVecIVec(const Float:FVec[3], IVec[3])
{
IVec[0] = floatround(FVec[0]);
IVec[1] = floatround(FVec[1]);
IVec[2] = floatround(FVec[2]);

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 && Vector[1] == 0 && Vector[2] == 0;
}

/**
* Sets a vector to zero.
*
* @param Vector Vector
*
* @noreturn
*/
stock SetVectorZero({_, Float}:Vector[3])
{
Vector[0] = Vector[1] = Vector[2] = 0;
}