Skip to content

Commit

Permalink
Revamped ContactEventsDemo to show how to handle more types of events…
Browse files Browse the repository at this point in the history
…. Tightened generic constraint on contact manifolds in contact callbacks.
  • Loading branch information
RossNordby committed Jun 12, 2021
1 parent 8e39c77 commit 11f7e09
Show file tree
Hide file tree
Showing 16 changed files with 418 additions and 111 deletions.
2 changes: 1 addition & 1 deletion BepuPhysics/BepuPhysics.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>2.4.0-beta3</Version>
<Version>2.4.0-beta4</Version>
<Company>Bepu Entertainment LLC</Company>
<Authors>Ross Nordby</Authors>
<Description>Speedy real time physics simulation library.</Description>
Expand Down
2 changes: 1 addition & 1 deletion BepuPhysics/CollisionDetection/INarrowPhaseCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public unsafe interface INarrowPhaseCallbacks
/// <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>
bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold<TManifold>;
bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : unmanaged, IContactManifold<TManifold>;

//TODO: There is an argument for finer grained material tuning, both per child and per contact. Need an efficient way to do this before we commit-
//one possibility is a material per convex manifold. For nonconvex manifolds, there would be a material property per contact.
Expand Down
2 changes: 1 addition & 1 deletion BepuUtilities/BepuUtilities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<AssemblyName>BepuUtilities</AssemblyName>
<RootNamespace>BepuUtilities</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>2.4.0-beta3</Version>
<Version>2.4.0-beta4</Version>
<Company>Bepu Entertainment LLC</Company>
<Authors>Ross Nordby</Authors>
<Description>Supporting utilities library for BEPUphysics v2.</Description>
Expand Down
2 changes: 1 addition & 1 deletion Demos/DemoCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public bool AllowContactGeneration(int workerIndex, CollidablePair pair, int chi
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold<TManifold>
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : unmanaged, IContactManifold<TManifold>
{
pairMaterial.FrictionCoefficient = 1f;
pairMaterial.MaximumRecoveryVelocity = 2f;
Expand Down
2 changes: 1 addition & 1 deletion Demos/Demos/BouncinessDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public bool AllowContactGeneration(int workerIndex, CollidablePair pair, int chi
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold<TManifold>
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : unmanaged, 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];
Expand Down
2 changes: 1 addition & 1 deletion Demos/Demos/Cars/CarCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public bool AllowContactGeneration(int workerIndex, CollidablePair pair, int chi
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold<TManifold>
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : unmanaged, IContactManifold<TManifold>
{
pairMaterial.FrictionCoefficient = Properties[pair.A.BodyHandle].Friction;
if (pair.B.Mobility != CollidableMobility.Static)
Expand Down
2 changes: 1 addition & 1 deletion Demos/Demos/Characters/CharacterNarrowphaseCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public bool AllowContactGeneration(int workerIndex, CollidablePair pair, int chi
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold<TManifold>
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : unmanaged, IContactManifold<TManifold>
{
pairMaterial = new PairMaterialProperties { FrictionCoefficient = 1, MaximumRecoveryVelocity = 2, SpringSettings = new SpringSettings(30, 1) };
Characters.TryReportContacts(pair, ref manifold, workerIndex, ref pairMaterial);
Expand Down
2 changes: 1 addition & 1 deletion Demos/Demos/ClothDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public bool AllowContactGeneration(int workerIndex, CollidablePair pair, int chi
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : struct, IContactManifold<TManifold>
public unsafe bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : unmanaged, IContactManifold<TManifold>
{
pairMaterial.FrictionCoefficient = 0.25f;
pairMaterial.MaximumRecoveryVelocity = 2f;
Expand Down
Loading

0 comments on commit 11f7e09

Please sign in to comment.