Collision is incorrect

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
snoozbuster
Posts: 172
Joined: Sat Sep 24, 2011 7:31 am

Collision is incorrect

Post by snoozbuster »

So, if I have a bunch of rollers set up like a conveyor, and a sliding pane of glass at the end of this belt, if I have a box roll down the rollers and hit the glass pane and make sure that it stops completely, then if I slide the pane away, the box won't move, even if the rollers are still rotating. When another object touches it, it will start moving again, but if it comes to a complete stop it won't continue moving until acted on by another force. I don't want this to happen; I want to make sure the box keeps doing collision detection and moving when obstructions are removed. I think it mainly happens when a dynamic entity is interacting with one or more kinematic entities, is there a way to fix this? A large portion of my game is based on kinematic entities.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Collision is incorrect

Post by Norbo »

Could you make a quick demo in the BEPUphysicsDemos project reproducing the issue? That will help me diagnose the issue and create a fix if necessary much faster.
snoozbuster
Posts: 172
Joined: Sat Sep 24, 2011 7:31 am

Re: Collision is incorrect

Post by snoozbuster »

Sure. Do you still have the code and resources I sent you last time you helped me? If you do, all I'll need to send is an updated .cs file. EDIT: I lied, I forgot I deleted a file I decided not to use in the zip I sent you even though it was still in the project on my side.

EDIT: I got it working. I'll PM you a link to the .cs and resources, in case you don't have the other stuff. Lucky for me, I still have the same .zip I sent the first one in, so just merge the folders in there with the original. Also, make sure all the resources EXCEPT tube_y have a X axis rotation of -90 in the Properties. Also, machine1_glass might complain about missing textures, just direct it to wherever tabletop.png is found.

Also, it might take a couple of tries to see the problem. Wait until the box touching the pane is almost totally still, and then remove the pane. It still works with a few boxes stacked up, so don't worry about that.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Collision is incorrect

Post by Norbo »

It should be fixed in the latest development version:
http://bepuphysics.codeplex.com/SourceC ... evelopment

Thanks for the report!
snoozbuster
Posts: 172
Joined: Sat Sep 24, 2011 7:31 am

Re: Collision is incorrect

Post by snoozbuster »

So it was a bug? Just out of curiousity, what was causing that?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Collision is incorrect

Post by Norbo »

Yup.

The primary cause was a corner case in handling activity with kinematics. Kinematics do not belong to simulation islands like dynamic objects, so active kinematic objects must wake up touched dynamic objects in other ways. Long ago, a 'robust' solution was used that added in some unacceptable overhead even when no active kinematics were involved. It was replaced by a much faster, targeted version. I knew that there might be a hole in the new system (and if it existed, there was an easy fix), but I couldn't think of it at the time. So, I waited until an existence proof was available to introduce the extra logic to fix it :) It had to do with a persistent changing contact manifold involving a moving kinematic and nearly motionless dynamic entity.

A secondary cause was an over-eager loop which could sometimes sabotage the efforts of the kinematic-related deactivation logic when there were less than DeactivationManager.MaximumDeactivationsPerFrame entities.

I also made removing kinematic objects activate all connected dynamic entities. This wasn't an absolutely necessary change to address the problem you saw, but it is more consistent with dynamic entity removal and is more convenient.
snoozbuster
Posts: 172
Joined: Sat Sep 24, 2011 7:31 am

Re: Collision is incorrect

Post by snoozbuster »

Alright. I tested it, and it works like a charm now. When the glass pane slides up in my game, the boxes even catch a bit to add to realism. ;D
Post Reply