Skip to content

Commit a6bbc83

Browse files
committed
Some tuning.
1 parent 6d671c4 commit a6bbc83

5 files changed

Lines changed: 71 additions & 72 deletions

File tree

BepuPhysics/CollisionDetection/CollidableOverlapFinder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,6 @@ public void DispatchOverlaps3(float dt, IThreadDispatcher threadDispatcher = nul
822822
narrowStack = &narrowTaskStack;
823823
const int targetJobsPerThread = 1;
824824
int maximumTaskSize = int.Max(1, previousPairCount3 / (threadDispatcher.ThreadCount * targetJobsPerThread));
825-
//Console.WriteLine($"maixmum taskese: {maximumTaskSize}");
826825
var estimatedMaximumTaskCountPerThread = targetJobsPerThread * 2;
827826
for (int i = 0; i < threadDispatcher.ThreadCount; ++i)
828827
{

BepuPhysics/Trees/Tree_IntertreeQueriesMT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void PrepareJobs(ref Tree treeA, ref Tree treeB, TOverlapHandler[] overla
4646
return;
4747
}
4848
Debug.Assert(overlapHandlers.Length >= threadCount);
49-
const float jobMultiplier = 8f;
49+
const float jobMultiplier = 4f;
5050
var targetJobCount = Math.Max(1, jobMultiplier * threadCount);
5151
//TODO: Not a lot of thought was put into this leaf threshold for intertree. Probably better options.
5252
leafThreshold = (int)((treeA.LeafCount + treeB.LeafCount) / targetJobCount);

BepuPhysics/Trees/Tree_SelfQueriesMT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void PrepareJobs(ref Tree tree, TOverlapHandler[] overlapHandlers, int th
7676
return;
7777
}
7878
Debug.Assert(overlapHandlers.Length >= threadCount);
79-
const float jobMultiplier = 8f;
79+
const float jobMultiplier = 4f;
8080
var targetJobCount = Math.Max(1, jobMultiplier * threadCount);
8181
leafThreshold = (int)(tree.LeafCount / targetJobCount);
8282
jobs = new QuickList<Job>((int)(targetJobCount * 2), Pool);

Demos/SpecializedTests/SimpleTestDemo.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using BepuUtilities;
2+
using DemoRenderer;
3+
using BepuPhysics;
4+
using BepuPhysics.Collidables;
5+
using System;
6+
using System.Numerics;
7+
using BepuUtilities.Collections;
8+
using DemoContentLoader;
9+
using BepuPhysics.Constraints;
10+
using DemoUtilities;
11+
12+
namespace Demos.SpecializedTests;
13+
14+
public class StaggeredDropTestDemo : Demo
15+
{
16+
public override void Initialize(ContentArchive content, Camera camera)
17+
{
18+
camera.Position = new Vector3(-30, 10, -30);
19+
//camera.Yaw = MathHelper.Pi ;
20+
camera.Yaw = MathHelper.Pi * 3f / 4;
21+
//camera.Pitch = MathHelper.PiOver2 * 0.999f;
22+
Simulation = Simulation.Create(BufferPool, new DemoNarrowPhaseCallbacks(new SpringSettings(30, 1)), new DemoPoseIntegratorCallbacks(new Vector3(0, -10, 0)), new SolveDescription(4, 1));
23+
24+
var box = new Box(1f, 3f, 2f);
25+
26+
var boxInertia = box.ComputeInertia(1);
27+
var boxIndex = Simulation.Shapes.Add(box);
28+
const int width = 256;
29+
const int height = 1;
30+
const int length = 256;
31+
var shapeCount = 0;
32+
var random = new Random(5);
33+
for (int i = 0; i < width; ++i)
34+
{
35+
for (int j = 0; j < height; ++j)
36+
{
37+
for (int k = 0; k < length; ++k)
38+
{
39+
var location = new Vector3(6, 3, 6) * new Vector3(i, j, k) + new Vector3(-width * 3, 5.5f + random.NextSingle() * 5, -length * 3);
40+
var bodyDescription = BodyDescription.CreateDynamic(location, boxInertia, boxIndex, -0.01f);
41+
var index = shapeCount++;
42+
Simulation.Bodies.Add(bodyDescription);
43+
}
44+
}
45+
}
46+
47+
Simulation.Statics.Add(new StaticDescription(new Vector3(), Simulation.Shapes.Add(new Box(5000, 1, 5000))));
48+
//var mesh = DemoMeshHelper.CreateDeformedPlane(128, 128, (x, y) => new Vector3(x - 64, 2f * (float)(Math.Sin(x * 0.5f) * Math.Sin(y * 0.5f)), y - 64), new Vector3(4, 1, 4), BufferPool);
49+
//Simulation.Statics.Add(new StaticDescription(new Vector3(), Simulation.Shapes.Add(mesh)));
50+
}
51+
52+
double time = 0;
53+
long frameCount = 0;
54+
public override void Update(Window window, Camera camera, Input input, float dt)
55+
{
56+
base.Update(window, camera, input, dt);
57+
const long minimumFrameToMeasure = 512;
58+
frameCount++;
59+
if (frameCount >= minimumFrameToMeasure)
60+
{
61+
var frameTime = Simulation.Profiler[Simulation.BroadPhaseOverlapFinder];
62+
time += frameTime;
63+
Console.WriteLine($"coldet time (ms): {1e3 * frameTime}, average (ms): {1e3 * time / (frameCount - minimumFrameToMeasure)}");
64+
}
65+
66+
}
67+
}
68+
69+

0 commit comments

Comments
 (0)