Since you're only doing this to sort them by distance, it should be significantly faster to do without a squareroot... I don't have time to test it right now, but if I've understood you correctly, something like this should really be faster and achieve the same effect:the fastest script in gml is this
with(argument2) depth = point_distance(x,y,argument0,argument1);
var dx, dy;
with(argument2) {
dx = x - argument0;
dy = y - argument1;
depth = dx * dx + dy * dy;
}That said, I wouldn't be surprised if it's slower in GML... Which brings me to a feature request!Could we please have a point_distance_squared(x1, y1, x2, y2) function? Often in cases like this the square is all you need, and it's much faster to compute, it would be nice to have a nice fast built-in version.
EDIT: And if I may be so bold as to bring my feature request up to 15 minutes, point_distance_3d(x1, y1, z1, x2, y2, z2) and point_distance_squared_3d(x1, y1, z1, x2, y2, z2) would also be nice!
Edited by ~Dannyboy~, 20 March 2011 - 04:55 AM.



This topic is locked







