icuurd12b42: If you want native sorting, why not use a list? Put the depth above the 32bits of the object ID and insert the whole thing into a list, then sort it. You can then loop through the list and AND off the lower 32bits to get the order of your objects? Like this...where d is the depth. Make sure its a WHOLE number, scaling it up if you have to. Personally I wouldn't use the ID directly, I'd use an indirection table., This would keep the number of items down to <16bits, allowing more depth to be used.
It's too slow. No matter what method is used... I dont think you understand the purpose of the function, by your response.
You know, my message was cut a little short, I got people ringing at the door and had to step out so I finished the post a little abruptly.
It's for getting rid of 3d artfacts like triangles interfering with one another AND specifically, for alphaed models or models with alphaed textures. Many posts in the 3d section are about these 2 problems.
the fastest script in gml is this
with(argument2) depth = point_distance(x,y,argument0,argument1);
if that was native it would be useable. but a gml implementation is too demanding on the interpreter
Any other code, like storing in an array, or a list, and then sort... Why? you just need to set the depth to the distance. There is no benifit of using an array or a list, objects are created and destroy every step. the overhead would be too large.
Right now, the most efficient, half decent method is that we have to go in a round about way, using randomized alarm in each object so all the instances dont do it at the same time and dont do it every step, to keep the FPS up to speed
alarm = random(30)+1;
depth = point_distance(x,y,cam.x,cam.y)
alarm = room_speed/4;
if you were able to add draw_self(), I'm sure this one liner code would be implemented faster than us discussing the cost benifit.
Fixed wording, fixed example code
Edited by icuurd12b42, 19 March 2011 - 11:19 PM.