-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Codes like this could be optimized significantly using VectorSize
Codes below seems to be very slow according to performance profiler results..
stock IsObjectInSphere(objectid,Float:x,Float:y,Float:z,Float:radius2) { new Float:x1,Float:y1,Float:z1,Float:tmpdis; GetObjectPos(objectid,x1,y1,z1); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+ floatpower(floatabs(floatsub(y,y1)),2)+ floatpower(floatabs(floatsub(z,z1)),2)); // if(tmpdis < radius2) return 1; return 0; }
to
`IsObjectInSphere(objectid, Float:x, Float:y, Float:z, Float:radius2)
{
new Float:x1, Float:y1, Float:z1;
if (GetObjectPos(objectid, x1, y1, z1)) // object exists
{
return VectorSize(x1-x, y1-y, z1-z) <= radius2;
}
return 0;
}`
a more optimized version
Perhaps you could consider doing major optimizations on the scripts so it performs better
Metadata
Metadata
Assignees
Labels
No labels