Request for minimal demo (Stackoverflow Exception)

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
UnLogick
Posts: 3
Joined: Tue Feb 05, 2019 11:01 pm

Request for minimal demo (Stackoverflow Exception)

Post by UnLogick » Thu Feb 07, 2019 2:30 pm

I'm new here, this is my first post so if I missed something obvious please don't hesitate to point it out.

Looking at the demos for BEPU v2 I find that they are very far from my need. I truly appreciate the design that leaves the critical callbacks entirely at my fingertips. It's part of the reason that I have great hopes for it. It is also the source of my frustration that merits this post. Obviously as this is a "new" open source project the documentation is pretty much non-existent, no reason for me to whine about that, but it forces me to look at the demos and I find them overly complex, show casing the wonders at the end of the tunnel.

What I am sorely missing is a basic setup, much simpler than the current demos. I don't care about a custom renderer that I would never add to my projects, it looks almost as if the BEPU demo is set up as a foundation to be it's own engine. That is your choice and if that is how you plan to use it I hold no rights to criticize that. But I'm slightly dissappointed to not find a clean demo(or test) project that just sets up some very basic handlers. The demo could be as simple as a cube sliding down a tilted plane with a pure textual feedback. That would allow me to put a primitive version of BEPU into the engine of my choice (Unity) and get confirmation that everything is functioning nominally, right now I know it's compiling, but I need to traverse the steep learning curve of getting everything to work in order to get any functional feedback. I don't know how effectively the unity .net standard 2.0 implementation unity is using is treating your code. So I can't determine if v2 is a viable option or if we're stuck on v1. Once I knew it wasn't a dead end I could look at each of your advanced demo handlers and extend my integration bit by bit until it's done.

Regards,
Joen - UnLogick
Last edited by UnLogick on Thu Feb 07, 2019 10:52 pm, edited 1 time in total.

UnLogick
Posts: 3
Joined: Tue Feb 05, 2019 11:01 pm

Re: Request for minimal demo

Post by UnLogick » Thu Feb 07, 2019 10:43 pm

Followup, I tried making my own minimal demo, copying the DemoNarrowPhaseCallbacks and DemoPoseIntegratorCallbacks from the official demos. Unfortunately I was greeted with a stack overflow exception. I'm probably doing something very stupid here, but that serves to prove my point a minimal viable setup would help people hit the ground running. Instead of banging their head against the wall. :)

Code: Select all

    void SimpleTest()
    {
        var BufferPool = new BufferPool();
        var sim = Simulation.Create(BufferPool, new DemoNarrowPhaseCallbacks(), new DemoPoseIntegratorCallbacks());

        var sphere = new Sphere(1);
        AddBody(sim, sphere, new Vector3(10, 0, 0));

        var box = new Box(1, 1, 1);
        AddBody(sim, box, new Vector3(0, 0, 0));

        sim.Timestep(0.1f); // this is what provokes the stack overflow exception
    }

    private int AddBody<TShape>(Simulation sim, TShape shape, Vector3 position)
        where TShape : struct, IShape
    {
        var index = sim.Shapes.Add(shape);
        var body = new BodyDescription()
        {
            Velocity = new BodyVelocity(),
            Pose = new RigidPose(position, BepuUtilities.Quaternion.Identity),
            Activity = new BodyActivityDescription(0.001f, 4),
            Collidable = new CollidableDescription(index, 0.01f),
            LocalInertia = new BodyInertia()
        };
        return sim.Bodies.Add(body);
    }

Code: Select all

StackOverflowException: The requested operation caused a stack overflow.
  at BepuPhysics.Trees.Tree.Intersects (BepuPhysics.Trees.NodeChild& a, BepuPhysics.Trees.NodeChild& b) <0x3308c260 + 0x00024> in <d3a1ac0efc714861953a83f95dd7025c>:0 
  at BepuPhysics.Trees.Tree.GetOverlapsInNode[TOverlapHandler] (BepuPhysics.Trees.Node* node, TOverlapHandler& results) [0x0000f] in C:\Source\Unity\VoxelTerrain\Voxel1\Unity\Assets\bepu2\BepuPhysics\Trees\Tree_SelfQueries.cs:125 
  at BepuPhysics.Trees.Tree.GetOverlapsInNode[TOverlapHandler] (BepuPhysics.Trees.Node* node, TOverlapHandler& results) [0x00027] in C:\Source\Unity\VoxelTerrain\Voxel1\Unity\Assets\bepu2\BepuPhysics\Trees\Tree_SelfQueries.cs:128 
[....]
  at BepuPhysics.Trees.Tree.GetOverlapsInNode[TOverlapHandler] (BepuPhysics.Trees.Node* node, TOverlapHandler& results) [0x00027] in C:\Source\Unity\VoxelTerrain\Voxel1\Unity\Assets\bepu2\BepuPhysics\Trees\Tree_SelfQueries.cs:128 
  at BepuPhysics.Trees.Tree.TestNodeAgainstLeaf[TOverlapHandler] (System.Int32 nodeIndex, System.Int32 leafIndex, System.Numerics.Vector3& leafMin, System.Numerics.Vector3& leafMax, TOverlapHandler& results) [0x00027] in C:\Source\Unity\VoxelTerrain\Voxel1\Unity\Assets\bepu2\BepuPhysics\Trees\Tree_IntertreeQueries.cs:33 
  at BepuPhysics.Trees.Tree.DispatchTestForNodeAgainstLeaf[TOverlapHandler] (System.Int32 leafIndex, System.Numerics.Vector3& leafMin, System.Numerics.Vector3& leafMax, System.Int32 nodeIndex, TOverlapHandler& results) [0x00025] in C:\Source\Unity\VoxelTerrain\Voxel1\Unity\Assets\bepu2\BepuPhysics\Trees\Tree_IntertreeQueries.cs:20 
  at BepuPhysics.Trees.Tree.TestNodeAgainstLeaf[TOverlapHandler] (System.Int32 nodeIndex, System.Int32 leafIndex, System.Numerics.Vector3& leafMin, System.Numerics.Vector3& leafMax, TOverlapHandler& results) [0x0005c] in C:\Source\Unity\VoxelTerrain\Voxel1\Unity\Assets\bepu2\BepuPhysics\Trees\Tree_IntertreeQueries.cs:37 
[....]
  at BepuPhysics.Trees.Tree.DispatchTestForNodeAgainstLeaf[TOverlapHandler] (System.Int32 leafIndex, System.Numerics.Vector3& leafMin, System.Numerics.Vector3& leafMax, System.Int32 nodeIndex, TOverlapHandler& results) [0x00025] in C:\Source\Unity\VoxelTerrain\Voxel1\Unity\Assets\bepu2\BepuPhysics\Trees\Tree_IntertreeQueries.cs:20 
  at BepuPhysics.Trees.Tree.TestNodeAgainstLeaf[TOverlapHandler] (System.Int32 nodeIndex, System.Int32 leafIndex, System.Numerics.Vector3& leafMin, System.Numerics.Vector3& leafMax, TOverlapHandler& results) [0x0005c] in C:\Source\Unity\VoxelTerrain\Voxel1\Unity\Assets\bepu2\BepuPhysics\Trees\Tree_IntertreeQueries.cs:37 
My problem is that I have no way of knowing if this is a BEPU problem, a problem with Unity's .net standard runner, or me being stupid.

Norbo
Site Admin
Posts: 4673
Joined: Tue Jul 04, 2006 4:45 am

Re: Request for minimal demo (Stackoverflow Exception)

Post by Norbo » Fri Feb 08, 2019 1:06 am

Went ahead and added one: https://github.com/bepu/bepuphysics2/bl ... nedDemo.cs

The other demos are generally pretty isolated from the surrounding framework too. The Initialize function does all the physicsy stuff for the most part, the Demo.Update calls Simulation.Timestep, and most demos use one of the demo callback types. All the DemoRenderer and DemoHarness and input management stuff is incidental and can be ignored for the purposes of understanding the physics engine itself.

Some demos have some custom interface rendering stuff or 'shoot a ball' type interaction, but none of those cases do anything particularly interesting from a physics perspective.
My problem is that I have no way of knowing if this is a BEPU problem, a problem with Unity's .net standard runner, or me being stupid.
I can't reproduce the issue locally. Unfortunately, if you're using the latest version of v2 master, that's probably a unity issue. :(

It would be interesting if you can get it to work, since I don't have any recent performance numbers for it on the unity runtime. When I did a few microbenchmarks over a year ago, it looked like it might be two orders of magnitude slower than RyuJIT due to the heavy use of intrinsics that unity doesn't (or didn't) support. A wee bit disappointing, but they are still doing a lot of work related to their runtime, so hopefully things improve (or have improved).

UnLogick
Posts: 3
Joined: Tue Feb 05, 2019 11:01 pm

Re: Request for minimal demo (Stackoverflow Exception)

Post by UnLogick » Sun Feb 10, 2019 12:03 am

Norbo wrote:
Fri Feb 08, 2019 1:06 am
Went ahead and added one: https://github.com/bepu/bepuphysics2/bl ... nedDemo.cs

The other demos are generally pretty isolated from the surrounding framework too. The Initialize function does all the physicsy stuff for the most part, the Demo.Update calls Simulation.Timestep, and most demos use one of the demo callback types. All the DemoRenderer and DemoHarness and input management stuff is incidental and can be ignored for the purposes of understanding the physics engine itself.

Some demos have some custom interface rendering stuff or 'shoot a ball' type interaction, but none of those cases do anything particularly interesting from a physics perspective.
My problem is that I have no way of knowing if this is a BEPU problem, a problem with Unity's .net standard runner, or me being stupid.
I can't reproduce the issue locally. Unfortunately, if you're using the latest version of v2 master, that's probably a unity issue. :(

It would be interesting if you can get it to work, since I don't have any recent performance numbers for it on the unity runtime. When I did a few microbenchmarks over a year ago, it looked like it might be two orders of magnitude slower than RyuJIT due to the heavy use of intrinsics that unity doesn't (or didn't) support. A wee bit disappointing, but they are still doing a lot of work related to their runtime, so hopefully things improve (or have improved).
Great stuff, this was exactly what I needed to know, a simple piece of code that had been verified by others before I started hacking.

Unfortunately it didn't work. The threaded version died silently and my attempts to add an exception handler and log what happened was equally silent. Removing the thread dispatcher gave the same stack overflow exception.

Not much here for me to attack, the unity 2018.3.4f1 flat out refused to play ball with Bepu2. :( I tried both the mono and the il2cpp scripting backend. It compiles just fine with the .net standard 2.0 API compatibility target but clearly something is amiss. I'm not even sure what to write to the unity devs to get their attention at this. I guess I should submit a bug report with a clean project and then do a forum post and hope for the best.

Norbo
Site Admin
Posts: 4673
Joined: Tue Jul 04, 2006 4:45 am

Re: Request for minimal demo (Stackoverflow Exception)

Post by Norbo » Mon Feb 11, 2019 12:11 am

I guess I should submit a bug report with a clean project and then do a forum post and hope for the best.
I don't envy whoever tries to tackle that report- v2 does enough unusual stuff that it's practically a fuzz test. Best of luck!

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests