Eric
unread,Mar 20, 2008, 5:24:42 PM3/20/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to APE General
Not sure how much the main codelines are being maintained but I have
been playing around with the latest version of 0.5 in the trunk and
even the rigidape branch. Both have initial support for Collision
events.
In the few tests that I've run, useful function calls involving
velocity and position during the callbacks are ignored (changes to
properties like "solid" and "fixed" work fine).
I've tracked the issue down to the "resolveCollision()" call in the
AbstractParticle class:
/-----------------------------
internal function resolveCollision(mtd:Vector, vel:Vector, n:Vector,
d:Number,
o:int, p:AbstractParticle):void {
testParticleEvents(p);
if (fixed || (! solid) || (! p.solid)) return;
curr.copy(samp);
curr.plusEquals(mtd);
velocity = vel;
}
/-----------------------------
"testParticleEvents(p)" will trigger the actual callbacks. Velocity-
related values are modified *after* the collision callbacks have
returned. I changed the function to look like the following:
/-----------------------------
internal function resolveCollision(mtd:Vector, vel:Vector, n:Vector,
d:Number,
o:int, p:AbstractParticle):void {
if (fixed || (! solid) || (! p.solid)) {
testParticleEvents(p);
return;
}
curr.copy(samp);
curr.plusEquals(mtd);
velocity = vel;
testParticleEvents(p);
}
/-----------------------------
"testParticleEvents()" is now the last thing to get called in a given
"resolveCollision()" call. You can now register collision events and
reset position/muck with velocities, etc.
Anyone see a reason that this could break down?