bepu / bepuphysics2

Pure C# 3D real time physics simulation library, now with a higher version number.
Apache License 2.0
2.25k stars 261 forks source link

2.5.0-beta.20 - Convex hull error #313

Closed sDIMMaX closed 3 months ago

sDIMMaX commented 3 months ago

Test - ConvexHullTestDemo Unhandled exception. System.ArgumentException: Could not create a convex hull from the point set; is it degenerate? Convex hull shapes must have volume.

Edit: I make simple new project and force target Net7.0(and BepuPhysics and BepuUtil in .csproj files) and ... it work. O_O Net8.0 - error in runtime, Net7.0 - ok.

RossNordby commented 3 months ago

There are some pieces of test content in that demo which will trigger that error intentionally; a point set with no volume is invalid input. Did you see that error for a point set that unambiguously has volume?

sDIMMaX commented 3 months ago

I tested with simple manual cube. points[0] = new System.Numerics.Vector3(0, 0, 0); points[1] = new System.Numerics.Vector3(0, 0, boxScale); ... Error only if Net8.0. somewhere in rawFaceVertexIndices in ComputeHull. in one case this 0 in other 2.

RossNordby commented 3 months ago

I'm not seeing a similar failure with CreateBoxConvexHull in ConvexHullTestDemo, could you give me a snippet of code that reproduces the problem within ConvexHullTestDemo?

sDIMMaX commented 3 months ago

PCS.zip my dotnet version 8.0.201 and 7.0.406 (what you 8.0.xxx version?) if in BepuPhysics.csproj and BepuUtilities.csproj i change to net7.0 - this works.

i think main problem in dotnet runtime. unsafe buffers/operations...

RossNordby commented 3 months ago

That's odd; running the repro with 8.0.201 appears to work for me. What CPU/OS are you using?

sDIMMaX commented 3 months ago

Reinstall. really odd, now i think this is CPU problem. something like https://github.com/dotnet/runtime/issues/98704
i have 2 legacy pc(as remote "terminal") win10(1809 17763.3650) - cpu Intel celeron e3300 and old notebook win7(7601) intel p6100 and both have some issue. need test on main server pc when i reinstall hypervisor, dockers, os`s ... in attachment 2 compiled versions Debug.zip

edit: tested on net8.0.preview.1 - and it works... OO ... preview.2 and rc.1 - nope --

sDIMMaX commented 3 months ago

after hours of Console.WriteLine and debug.... i Found previousEdgeDirection = Vector2.Normalize(facePoints[nextIndex] - facePoints[previousEndIndex]); in ReduceFace

code

            var v1 = new Vector2(0,2);
            var v2 = new Vector2(0,0);
            var previousEdgeDirection = Vector2.Normalize(v1 - v2);
            Console.WriteLine(previousEdgeDirection);

show <0 ∞> in net8.0 and <0 1> in 7.0.

OMG. Close issue in this place and open in https://github.com/dotnet/runtime/issues/99391

RossNordby commented 3 months ago

Nice work! I know how fun narrowing that kind of thing down can be :P