Good, now we can talk about this right here
From other thread
Maarten Baert, on Sep 20 2009, 05:53 PM, said:
Version 1.0 doesn't draw anything in the DLL. Version 2.0 does, but only for debugging. When using the extension (instead of the scripts), drawing objects in GM instead of in the DLL won't make a huge difference. The scripts and external_call function calls are slow, not GM's drawing functions. I am using the scripts instead of the extension in 2.0 for now, because it makes testing the DLL a lot easier.
Quote
shouldnt that be
if(obj1.group & obj2.group) && (obj1.collide || obj2.collide){
No, group and collide are both 32-bit unsigned integers:
- 'group' defines the group(s) the component belongs to (for example, 0101 (binary) means "this component belongs to group 1<<0 and 1<<2")
- 'collide' defines the group(s) the component should collide with (for example, 0011 (binary) means "this component collides with components of group 1<<0 and 1<<1")
Oh I see the variable name confused me. And I get the bit method for grouping, that's what gmbullet does.
Actually, drawing from GML, you have to ask for the position and rotation of the instance via your get variable, I assume... That seriously limits the number of instances. In 2d, that's just x,y,image_abgle. but in 3d that's x,y,z,rx,ry,rz. Looks at the gmbullet topic. In short, calling APIs in gml is very slow. SO calling 3 apis for each instance reduces the number of possible instances drastically. Since you are drawing from the dll, you dont see that hapening right now (Using gmapi I assume)
In gmbullet, various methods have been tried...
The fastest that still involves GML is me passing you a ds_list which you fill up with
instance id
x
y
image_angle (in degrees because the extra rad to deg is also costly)
I can then ask for the positions in one sigle call
var thelist; thelist = ds_list_create();
getinstancesdata(thelist); //your dll api does the ds_list_add, you can exclude deactivated bodies
var i; i = 0;
var sz; sz = ds_list_size(thelist)/4;
repeat(sz)
{
with(ds_list_find_value(thelist,i))
{
x =ds_list_find_value(thelist,i+1)
y =ds_list_find_value(thelist,i+2)
image_angle =ds_list_find_value(thelist,i+4)
}
i+=4;
}
ds_list_destroy(thelist)
asking for ds_ elements is faster than calling api functions.
But the fastest way is you drawing for me. it looks like you are already setup to take over the drawing. I suggest you do that if possible. all you need is the sprite index of the instance and possibly how to draw it (image_blend, scales and blend mode)
Useful functions to add
associatebody(bodyid,instanceid)
if you can draw for me, meaning a hell of a lot of instances can have physics not impeded with me having to ask, in gml, for the position of the instance
setbodydrawinfo(bodyid,spriteindex,imageindex,imag
e_blend,image_xscale,image_yscale,image_alpha,blen
d
_mode)
which you can use in the dll via gmapi, to call draw_sprite_ext for each intances associated with a body
drawForMe() in the draw event.
I guaranty, this will beat the crap out of GMPhysics for the number of object you can handle.
This post has been edited by icuurd12b42: 21 September 2009 - 12:09 AM