Page 1 of 1

Greater resolution per object

Posted: Fri Feb 25, 2011 3:56 am
by markhula
Hi,

Not sure what I am asking is even possible but here goes.
One main problem with chipmunk (and indeed all physics engines to some extent) is that visually an object can potentially intersect another.
This can be reduced my calling cpspacestep more frequently.
Would it not be possible to have this but on a per body basis?
i.e. I don't care that the baddie might 'bump' off a wall but the player character is the centre of focus and therefore it is noticeable if it happens to that body.
I appreciate this may be either completely non-trivial or simply not possible to have 1 body within the simulated space 'correct itself' with a different time step than the others.

just a thought! ;-)

Cheers

Re: Greater resolution per object

Posted: Fri Feb 25, 2011 11:07 am
by slembcke
My first reaction was, "No, not really," but there is actually a bit of merit to that. Though it's not a, "Great, will it be done in a week then?" sort of feature, but an "Great, will it be done in a year" sort of feature.

Chipmunk sleeping algorithm works by grouping objects that are connected. So if you had 3 piles of boxes, each pile would be in a group. Because each group is completely separate, they can be simulated separately without affecting objects in other groups. This would allow you to set the iteration count and maximum timestep on a per body basis. I'll have to think about this, but like I said. Definitely not an easy or quick thing to implement.

Re: Greater resolution per object

Posted: Sun Feb 27, 2011 5:24 am
by markhula
Man, that would be so cool!

I guess what I am asking is to do:

int steps = 2;
cpFloat dt = 1.0f/60.0f/(cpFloat)steps;

for(int i=0; i<steps; i++){
cpSpaceStep(space, dt);
}

on a per body basis and not the whole simulation.
I wasn't sure if it was a good or even sensible suggestion; but I am glad it is. I am really beginning to love Chipmunk.

Cheers