SOLVED Sphere vs. Terrain collision not happening

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
sergiusz308
Posts: 49
Joined: Mon Oct 08, 2012 4:57 pm

SOLVED Sphere vs. Terrain collision not happening

Post by sergiusz308 »

Hello Norbo.

I have following space setup:

Code: Select all

this.space.ForceUpdater.Gravity = new BEPUutilities.Vector3(0, -9.81f, 0f);

			Bpp.Settings.MotionSettings.DefaultPositionUpdateMode = Bpp.PositionUpdating.PositionUpdateMode.Continuous;

			this.space.Solver.IterationLimit = 10;
			Bpp.CollisionTests.CollisionAlgorithms.GeneralConvexPairTester.UseSimplexCaching = false;
			Bpp.Settings.MotionSettings.UseExtraExpansionForContinuousBoundingBoxes = false;

			Bpp.Settings.CollisionResponseSettings.MaximumPenetrationRecoverySpeed = 2;
			Bpp.Settings.CollisionResponseSettings.BouncinessVelocityThreshold = 1;
			Bpp.Settings.CollisionResponseSettings.StaticFrictionVelocityThreshold = .2f;
			Bpp.Settings.CollisionDetectionSettings.ContactInvalidationLength = .1f;
			Bpp.Settings.CollisionDetectionSettings.ContactMinimumSeparationDistance = .1f;
			Bpp.Settings.CollisionDetectionSettings.MaximumContactDistance = .1f;
			Bpp.Settings.CollisionDetectionSettings.DefaultMargin = .04f;
			Bpp.Settings.CollisionDetectionSettings.AllowedPenetration = .01f;
I'm creating sphere entity and applying impulse with about 300 magnitude.

I'm setting sphere collision rule personal to "NoSolver" - in this particular case I want contacts managed by the engine but provide my own solver.

Everything works fine except that sometimes sphere not triggering collision with terrain - there is no particular pattern when it happens. I tried switching on "ImproveBoundaryBehavior" but no luck.

I'm checking collisions in sphere's ContactCreated event - it works perfectly fine for all objects - goes through them and triggering event, but not for the terrain sometimes.

What I'm possible doing wrong here?

Thanks,
S.
Last edited by sergiusz308 on Wed Feb 26, 2014 9:20 am, edited 1 time in total.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Sphere vs. Terrain collision not happening

Post by Norbo »

The default MotionSettings.CCDFilter does not permit collision pairs with a NoSolver or more restrictive collision rule to undergo continuous collision detection. This is because CCD tends to cause nasty artifacts when there is no collision response, like halting briefly before continuing. So, the sphere could scoot through the world pretty easily when given a hard push.

You can override that default behavior by supplying a custom CCDFilter that just returns true. Since you plan to provide your own collision response, the artifacts shouldn't be an issue.
I tried switching on "ImproveBoundaryBehavior" but no luck.
For reference, ImproveBoundaryBehavior prevents bad contacts on the border between adjacent connected triangles. It should be on by default. It is unrelated to CCD.
sergiusz308
Posts: 49
Joined: Mon Oct 08, 2012 4:57 pm

Re: Sphere vs. Terrain collision not happening

Post by sergiusz308 »

Thanks, this seems solved the case.
Post Reply