Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Further optimizations #5

@izrie1

Description

@izrie1

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions