public void CopyManifoldWideProperties(ref Vector3 offsetB, ref PairMaterialProperties material) { Common.OffsetB = offsetB; Common.FrictionCoefficient = material.FrictionCoefficient; Common.SpringSettings = material.SpringSettings; Common.MaximumRecoveryVelocity = material.MaximumRecoveryVelocity; }
public bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { //The IContactManifold parameter includes functions for accessing contact data regardless of what the underlying type of the manifold is. //If you want to have direct access to the underlying type, you can use the manifold.Convex property and a cast like Unsafe.As<TManifold, ConvexContactManifold or NonconvexContactManifold>(ref manifold). //The engine does not define any per-body material properties. Instead, all material lookup and blending operations are handled by the callbacks. //For the purposes of this demo, we'll use the same settings for all pairs. //(Note that there's no bounciness property! See here for more details: https://github.com/bepu/bepuphysics2/issues/3) pairMaterial.FrictionCoefficient = 1f; pairMaterial.MaximumRecoveryVelocity = 2f; pairMaterial.SpringSettings = new SpringSettings(30, 1); //For the purposes of the demo, contact constraints are always generated. try { OnCollision(pair.A, pair.B); } catch (Exception e) { Console.WriteLine(e); } return(false); }
public unsafe bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { pairMaterial = new PairMaterialProperties { FrictionCoefficient = 1, MaximumRecoveryVelocity = 2, SpringSettings = new SpringSettings(30, 1) }; Characters.TryReportContacts(pair, ref manifold, workerIndex, ref pairMaterial); return(true); }
void ConfigureMaterial(out PairMaterialProperties pairMaterial) { //The engine does not define any per-body material properties. Instead, all material lookup and blending operations are handled by the callbacks. //For the purposes of this demo, we'll use the same settings for all pairs. //(Note that there's no bounciness property! See here for more details: https://github.com/bepu/bepuphysics2/issues/3) pairMaterial.FrictionCoefficient = 1f; pairMaterial.MaximumRecoveryVelocity = 2f; pairMaterial.SpringSettings = new SpringSettings(30, 1); }
public unsafe bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { BepuPhysicsComponent a = getFromReference(pair.A); BepuPhysicsComponent b = getFromReference(pair.B); pairMaterial.FrictionCoefficient = a.FrictionCoefficient * b.FrictionCoefficient; pairMaterial.MaximumRecoveryVelocity = (a.MaximumRecoveryVelocity + b.MaximumRecoveryVelocity) * 0.5f; pairMaterial.SpringSettings.AngularFrequency = (a.SpringSettings.AngularFrequency + b.SpringSettings.AngularFrequency) * 0.5f; pairMaterial.SpringSettings.TwiceDampingRatio = (a.SpringSettings.TwiceDampingRatio + b.SpringSettings.TwiceDampingRatio) * 0.5f; if (((uint)a.CanCollideWith & (uint)b.CollisionGroup) != 0) { RecordContact(a, b, ref manifold); return(!a.GhostBody && !b.GhostBody); } return(false); }
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, ConvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { pairMaterial = new PairMaterialProperties(); return(false); }
void ConfigureMaterial(out PairMaterialProperties pairMaterial) { pairMaterial = new PairMaterialProperties(); }
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, ConvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { if (manifold->Count > 0) { Console.WriteLine($"CONVEX PAIR: {pair.A} versus {pair.B}"); } ConfigureMaterial(out pairMaterial); return(true); }
public unsafe bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { if (manifold.Count > 0) { if (manifold.Convex) { Console.WriteLine($"CONVEX PAIR: {pair.A} versus {pair.B}"); } else { Console.WriteLine($"NONCONVEX PAIR: {pair.A} versus {pair.B}"); } } pairMaterial.FrictionCoefficient = 1f; pairMaterial.MaximumRecoveryVelocity = 2f; pairMaterial.SpringSettings = new SpringSettings(30, 1); return(true); }
public unsafe bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { pairMaterial = new PairMaterialProperties(); return(false); }
public unsafe bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { //For the purposes of this demo, we'll use multiplicative blending for the friction and choose spring properties according to which collidable has a higher maximum recovery velocity. var a = CollidableMaterials[pair.A]; var b = CollidableMaterials[pair.B]; pairMaterial.FrictionCoefficient = a.FrictionCoefficient * b.FrictionCoefficient; pairMaterial.MaximumRecoveryVelocity = MathF.Max(a.MaximumRecoveryVelocity, b.MaximumRecoveryVelocity); pairMaterial.SpringSettings = pairMaterial.MaximumRecoveryVelocity == a.MaximumRecoveryVelocity ? a.SpringSettings : b.SpringSettings; return(true); }
public unsafe bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : unmanaged, IContactManifold <TManifold> { pairMaterial.FrictionCoefficient = this.FrictionCoefficient; pairMaterial.MaximumRecoveryVelocity = this.MaximumRecoveryVelocity; pairMaterial.SpringSettings = this.ContactSpringiness; return(true); }
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, ConvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { GetMaterial(out pairMaterial); //Console.WriteLine("ConfigureContactManifold2"); //Console.WriteLine(pair.A.Handle); //Console.WriteLine(pair.B.Handle); return(true); }
/// <summary> /// Provides a notification that a manifold has been created for a pair. Offers an opportunity to change the manifold's details. /// </summary> /// <param name="workerIndex">Index of the worker thread that created this manifold.</param> /// <param name="pair">Pair of collidables that the manifold was detected between.</param> /// <param name="manifold">Set of contacts detected between the collidables.</param> /// <param name="pairMaterial">Material properties of the manifold.</param> /// <returns>True if a constraint should be created for the manifold, false otherwise.</returns> public bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { ConfigureMaterial(out pairMaterial); return(true); }
static void GetMaterial(out PairMaterialProperties pairMaterial) { pairMaterial = new PairMaterialProperties { FrictionCoefficient = 1, MaximumRecoveryVelocity = 2, SpringSettings = new SpringSettings(30, 1) }; }
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, ConvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { GetMaterial(out pairMaterial); return(true); }
void ConfigureMaterial(out PairMaterialProperties pairMaterial) { pairMaterial.FrictionCoefficient = 1f; pairMaterial.MaximumRecoveryVelocity = 2f; pairMaterial.SpringSettings = new SpringSettings(30, 1); }
public unsafe bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { pairMaterial.FrictionCoefficient = Properties[pair.A.Handle].Friction; if (pair.B.Mobility != CollidableMobility.Static) { //If two bodies collide, just average the friction. pairMaterial.FrictionCoefficient = (pairMaterial.FrictionCoefficient + Properties[pair.B.Handle].Friction) * 0.5f; } pairMaterial.MaximumRecoveryVelocity = 2f; pairMaterial.SpringSettings = new SpringSettings(30, 1); return(true); }
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, NonconvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { ConfigureMaterial(out pairMaterial); events.HandleManifold(workerIndex, pair, manifold); return(true); }
public bool ConfigureContactManifold(int workerIndex, CollidablePair pair, ContactManifold *manifold, out PairMaterialProperties pairMaterial) { pairMaterial.FrictionCoefficient = 1; pairMaterial.MaximumRecoveryVelocity = float.MaxValue; pairMaterial.SpringSettings.NaturalFrequency = MathHelper.Pi * 30; pairMaterial.SpringSettings.DampingRatio = 100f;// 100000; return(true); }
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, NonconvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { GetMaterial(out pairMaterial); Characters.TryReportContacts(pair, ref *manifold, workerIndex, ref pairMaterial); return(true); }
public unsafe bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { pairMaterial.FrictionCoefficient = 1; pairMaterial.MaximumRecoveryVelocity = 2f; pairMaterial.SpringSettings = new SpringSettings(30, 1); return(true); }
public bool ConfigureContactManifold <TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold <TManifold> { CreateMaterial(out pairMaterial); return(CollisionGroup.AllowCollision(CollisionGroups[pair.A.Handle].Filter, CollisionGroups[pair.B.Handle].Filter)); }