-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e6d36d
commit 16b77b8
Showing
5 changed files
with
71 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using BepuUtilities; | ||
using DemoRenderer; | ||
using BepuPhysics; | ||
using BepuPhysics.Collidables; | ||
using System; | ||
using System.Numerics; | ||
using BepuUtilities.Collections; | ||
using DemoContentLoader; | ||
using BepuPhysics.Constraints; | ||
using DemoUtilities; | ||
|
||
namespace Demos.SpecializedTests; | ||
|
||
public class StaggeredDropTestDemo : Demo | ||
{ | ||
public override void Initialize(ContentArchive content, Camera camera) | ||
{ | ||
camera.Position = new Vector3(-30, 10, -30); | ||
//camera.Yaw = MathHelper.Pi ; | ||
camera.Yaw = MathHelper.Pi * 3f / 4; | ||
//camera.Pitch = MathHelper.PiOver2 * 0.999f; | ||
Simulation = Simulation.Create(BufferPool, new DemoNarrowPhaseCallbacks(new SpringSettings(30, 1)), new DemoPoseIntegratorCallbacks(new Vector3(0, -10, 0)), new SolveDescription(4, 1)); | ||
|
||
var box = new Box(1f, 3f, 2f); | ||
|
||
var boxInertia = box.ComputeInertia(1); | ||
var boxIndex = Simulation.Shapes.Add(box); | ||
const int width = 256; | ||
const int height = 1; | ||
const int length = 256; | ||
var shapeCount = 0; | ||
var random = new Random(5); | ||
for (int i = 0; i < width; ++i) | ||
{ | ||
for (int j = 0; j < height; ++j) | ||
{ | ||
for (int k = 0; k < length; ++k) | ||
{ | ||
var location = new Vector3(6, 3, 6) * new Vector3(i, j, k) + new Vector3(-width * 3, 5.5f + random.NextSingle() * 5, -length * 3); | ||
var bodyDescription = BodyDescription.CreateDynamic(location, boxInertia, boxIndex, -0.01f); | ||
var index = shapeCount++; | ||
Simulation.Bodies.Add(bodyDescription); | ||
} | ||
} | ||
} | ||
|
||
Simulation.Statics.Add(new StaticDescription(new Vector3(), Simulation.Shapes.Add(new Box(5000, 1, 5000)))); | ||
//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); | ||
//Simulation.Statics.Add(new StaticDescription(new Vector3(), Simulation.Shapes.Add(mesh))); | ||
} | ||
|
||
double time = 0; | ||
long frameCount = 0; | ||
public override void Update(Window window, Camera camera, Input input, float dt) | ||
{ | ||
base.Update(window, camera, input, dt); | ||
const long minimumFrameToMeasure = 512; | ||
frameCount++; | ||
if (frameCount >= minimumFrameToMeasure) | ||
{ | ||
var frameTime = Simulation.Profiler[Simulation.BroadPhaseOverlapFinder]; | ||
time += frameTime; | ||
Console.WriteLine($"coldet time (ms): {1e3 * frameTime}, average (ms): {1e3 * time / (frameCount - minimumFrameToMeasure)}"); | ||
} | ||
|
||
} | ||
} | ||
|
||
|