Open bakscratch opened 1 year ago
Should be more reliable now, I'll keep this issue open for a bit to see if it comes up again.
I can get these pretty reliably in Grubs.
System.Exception: Exception of type 'System.Exception' was thrown.
at Sandbox.Polygons.PolygonMeshBuilder.FindAboveSweepEdge(Edge& edge) in PolygonMeshBuilder.Fill.cs:line 190
at Sandbox.Polygons.PolygonMeshBuilder.Fill_SplitIntoMonotonicPolygons() in PolygonMeshBuilder.Fill.cs:line 258
at Sandbox.Polygons.PolygonMeshBuilder.Fill() in PolygonMeshBuilder.Fill.cs:line 17
at Sandbox.Sdf.Sdf2DMeshWriter.WriteRenderMesh(Sdf2DLayer layer) in 2D/Sdf2DMeshWriter.cs:line 570
at Sandbox.Sdf.Sdf2DMeshWriter.Write(Sdf2DArrayData data, Sdf2DLayer layer, Boolean renderMesh, Boolean collisionMesh) in 2D/Sdf2DMeshWriter.cs:line 438
at Sandbox.Sdf.Sdf2DArray.WriteTo(Sdf2DMeshWriter writer, Sdf2DLayer layer, Boolean renderMesh, Boolean collisionMesh) in 2D/Sdf2DArray.cs:line 153
at Sandbox.Sdf.Sdf2DChunk.OnUpdateMeshAsync() in 2D/Sdf2DChunk.cs:line 60
Reproduction steps:
I find I can get the error pretty regularly this way, but it is not consistent. And often, after experiencing the error once, it does not happen again until a Grubs gamemode restart.
Having a look again now.
@trundlr I've pushed a new version that should be slightly improved, but the main thing is it'll give you a log like this instead of the old exception:
Internal error in PolygonMeshBuilder!
Please paste the info below in this thread:
https://github.com/Facepunch/sbox-sdf/issues/17
{
"Exception": "System.Exception: Exception of type \u0027System.Exception\u0027 was thrown.\r\n at Sandbox.Polygons.PolygonMeshBuilder.FindAboveSweepEdge(Edge\u0026 edge) in C:\\users\\metap\\documents\\s\u0026box projects\\librarytest\\Libraries\\libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 191\r\n at Sandbox.Polygons.PolygonMeshBuilder.Fill_SplitIntoMonotonicPolygons() in C:\\users\\metap\\documents\\s\u0026box projects\\librarytest\\Libraries\\libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 253\r\n at Sandbox.Polygons.PolygonMeshBuilder.Fill() in C:\\users\\metap\\documents\\s\u0026box projects\\librarytest\\Libraries\\libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 17\r\n at DMD\u003CSystem.Void Sandbox.Sdf.Sdf2DMeshWriter:WriteRenderMesh(Sandbox.Sdf.Sdf2DLayer)\u003E(Sdf2DMeshWriter this, Sdf2DLayer layer)",
"EdgeLoops": "0,5.9941177;-1,6.0416665;-1.5590278,7;-1.6675392,8;-1.6675392,13;-1.570946,14;-1.377451,15;-1.3952382,16;-1.539855,17;-1,17.539856;0,17.447826;1,17.427927;6,17.427927;7,17.406542;9,17.412037;9.927083,17;9,16.470238;7,16.482143;6,16.441177;3,16.452942;1,16.434525;0,16.3481;-0.39855075,16;-0.4797297,15;0,14.538961;1,14.410714;3,14.434524;6,14.429412;7,14.470238;8,14.4759035;9,14.464705;9.705358,14;9.549383,13;9.173077,12;9,11.644737;8.664384,11;8.007246,10;8,9.990741;7.1507936,9;7,8.849206;6.009259,8;6,7.9927535;5,7.3356166;4.355263,7;4,6.826923;3,6.4506173;2,6.1987953;1,6.0416665;\n",
"EdgeStyle": "Bevel",
"EdgeWidth": 0.5,
"EdgeFaces": 3
}
Could you get people to post them here whenever they happen, it'll help me find all the edge cases. Thanks!
Sounds great! I'll see if I can just automate collecting all logs of this type after the contest, but for now, I'll post them when I see them. Thanks so much!
2024/07/29 16:55:08.5018 [GameMenu] Internal error in PolygonMeshBuilder!
Please paste the info below in this thread:
https://github.com/Facepunch/sbox-sdf/issues/17
{
"Exception": "System.Exception: Exception of type \u0027System.Exception\u0027 was thrown.\r\n at Sandbox.Polygons.PolygonMeshBuilder.FindAboveSweepEdge(Edge\u0026 edge) in C:\\Users\\Aiden\\Documents\\S\u0026box Projects\\grubs\\Libraries\\facepunch.libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 191\r\n at Sandbox.Polygons.PolygonMeshBuilder.Fill_SplitIntoMonotonicPolygons() in C:\\Users\\Aiden\\Documents\\S\u0026box Projects\\grubs\\Libraries\\facepunch.libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 280\r\n at Sandbox.Polygons.PolygonMeshBuilder.Fill() in C:\\Users\\Aiden\\Documents\\S\u0026box Projects\\grubs\\Libraries\\facepunch.libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 17\r\n at DMD\u003CSystem.Void Sandbox.Sdf.Sdf2DMeshWriter:WriteRenderMesh(Sandbox.Sdf.Sdf2DLayer)\u003E(Sdf2DMeshWriter this, Sdf2DLayer layer)",
"EdgeLoops": "-1,-1.6675392;-1.6675392,-1;-1.6675392,0;-1.6675392,1;-1.6350574,2;-1.4525862,3;-1,3.990566;0,2.990566;1,1.990566;2,1.990566;2.011628,2;3,2.988372;3.494186,2;3.494186,0;4,-0.71311474;4.9722223,-1;4,-1.2160494;3,-1.5496454;2,-1.6675392;0,-1.6675392;\n6,-1.4009434;5.0116277,-1;6,-0.50581396;6.494186,-1;\n12,-1.2160494;11.713115,-1;12,-0.027777791;12.286885,-1;\n16,-1.0078125;15.5,-1;15.988636,0;16,0.5;16.005882,0;16.005882,-1;\n10,-0.9722222;9.027778,0;10,0.28688523;10.286885,0;\n12,0.027777778;11.713115,1;12,1.9722222;12.972222,1;\n14,0.50581396;13.011628,1;13.713115,2;13,2.7131147;12.027778,3;12.713115,4;13,4.9722223;14.972222,3;14.972222,2;14.494186,1;\n16,1.5;15.5,2;15.5,3;16,3.5;16.005882,2;\n9,2.505814;8.011628,3;9,3.988372;10,3.9722223;10.972222,3;10,2.7131147;\n9,4.0277777;8.027778,5;9,5.9722223;9.972222,5;\n16,4.5;15.5,5;16,5.5;16.005882,5;\n1,5.0277777;0.027777778,6;1,6.9722223;1.9722222,6;\n13,5.0277777;12.713115,6;13,6.9722223;14,6.2868853;14.972222,6;14,5.0277777;\n-1,6.0277777;-1.2160494,7;-1.2160494,8;-1,8.972222;-0.027777791,8;-0.027777791,7;\n16,6.5;15.5,7;15.988636,8;15.988636,9;15.5,10;16,10.5;\n-1,10.713115;-1.2160494,11;-1,11.972222;-0.027777791,11;\n11,10.027778;10.713115,11;10,11.713115;9.027778,12;10,12.972222;11.972222,11;\n16,11.5;15.988636,12;15.988636,13;16,13.5;16.005882,12;\n3,12.027778;2.7131147,13;3,13.286885;3.9722223,13;\n14,12.027778;13.027778,13;13.027778,14;14,14.286885;15,15.286885;16,15.5;16.005882,15;16,14.5;15,14.027778;14.972222,14;14.286885,13;\n11,13.713115;10.027778,14;11,14.972222;11.972222,14;\n6,14.027778;5.0277777,15;6,15.972222;6.2868853,15;\n9,15.713115;8.713115,16;9,16.972221;9.286885,16;\n0,16.713116;-0.28688526,17;0,17.21605;0.9722222,17;\n2,16.505814;1.0116279,17;2,17.400944;2.988372,17;\n4,16.027779;3.0277777,17;4,17.21605;4.2868853,17;\n16,16.5;15.5,17;16,17.007812;16.005882,17;\n",
"EdgeStyle": "Round",
"EdgeWidth": 0.5,
"EdgeFaces": 3
}
After updating Grubs with the newest version, I seem to be getting these errors very consistently - basically every single startup.
That's a really nice test case, lots going wrong there!
https://github.com/user-attachments/assets/5c4df70a-57ee-4a79-b66d-5829b591528e
Sorting this out is my priority now, sorry for the delay.
No worries at all - this library is the only reason Grubs has been possible and the whole team appreciates everything you do ❤️
Current progress: fixed some edge cases in PolygonMeshBuilder, but the main issue in Grubs seems to be Sdf2DMeshWriter generating incorrect polygons. I'm solving that next.
Edit: nevermind, red herring. More edges cases in PolygonMeshBuilder to solve.
Hackweeking this week, so mostly won't be working on this.
"Exception": "System.Exception: Exception of type \u0027System.Exception\u0027 was thrown.\r\n at Sandbox.Polygons.PolygonMeshBuilder.FindAboveSweepEdge(Edge\u0026 edge) in facepunch.libpolygon/PolygonMeshBuilder.Fill.cs:line 191\r\n at Sandbox.Polygons.PolygonMeshBuilder.Fill_SplitIntoMonotonicPolygons() in facepunch.libpolygon/PolygonMeshBuilder.Fill.cs:line 248\r\n at Sandbox.Polygons.PolygonMeshBuilder.Fill() in facepunch.libpolygon/PolygonMeshBuilder.Fill.cs:line 17\r\n at Sandbox.Sdf.Sdf2DMeshWriter.WriteRenderMesh(Sdf2DLayer layer) in 2D/Sdf2DMeshWriter.cs:line 580\r\n at Sandbox.Sdf.Sdf2DMeshWriter.Write(Sdf2DArrayData data, Sdf2DLayer layer, Boolean renderMesh, Boolean collisionMesh) in 2D/Sdf2DMeshWriter.cs:line 445", "EdgeLoops": "2,-1.4009434;1.0116279,-1;2,-0.0116279125;2.494186,-1;\n7,-1.4525862;6.0094337,-1;7.0094337,0;7.0094337,1;7,1.0277778;6,1.7131147;5.0277777,2;5,2.0277777;4.9722223,2;4,1.7131147;3.2868853,1;4,0.49418604;5,0.990566;5.9905663,0;5,-0.990566;4,-0.9883721;3.011628,0;3,0.027777778;2.7131147,1;2.0277777,2;2.7131147,3;3,3.2868853;3.505814,4;4,4.988372;5.988372,4;6,3.9722223;7.9722223,2;8,1.990566;8.027778,2;8.027778,3;9,3.9722223;10,3.9722223;10.005882,4;10,4.0116277;9,4.0116277;8.011628,5;9,5.494186;10,5.494186;11,5.9722223;12,6.9722223;12.005882,7;12,7.0094337;11,7.0116277;10.972222,7;10,6.7131147;9.027778,7;9,7.0116277;8.011628,8;8.011628,9;10.011628,11;10.505814,12;10.009434,13;10.011628,14;10,14.005882;9.972222,14;9.988372,13;9,12.505814;8.011628,13;8,13.027778;7,14.027778;6,13.027778;5.7131147,14;5,14.713115;4.494186,14;4,13.011628;3.9722223,13;3.9722223,12;4,11.988372;4.0094337,12;5,12.990566;5.9905663,12;5.9905663,11;5,10.009434;4,10.011628;3.988372,10;4,9.990566;5,9.990566;5.9905663,9;5,8.009434;3,8.011628;2.505814,9;2,9.713115;1,8.713115;0,8.5;0,12.5;0.011363637,12;1,11.286885;2,11.972222;2.0277777,12;2.0277777,13;3,13.972222;3.011628,14;3.0277777,15;3.7131147,16;2.7131147,17;3,17.21605;4,17.549644;5,17.452587;5.9905663,17;6,16.972221;6.0094337,17;7,17.452587;8,17.452587;8.990566,17;8.972222,16;9,15.972222;9.027778,16;9.027778,17;10,17.21605;10.286885,17;11,16.286884;12,16.286884;12.505814,17;13,17.400944;14,17.21605;15,17.21605;15.972222,17;15.972222,16;16,15.972222;16.972221,15;17,14.990566;17.452587,14;17.590322,13;17.66754,12;17.66754,0;17.66754,-1;17,-1.6675392;16,-1.6675392;9,-1.6675392;8,-1.6350574;\n0,-0.0113636255;-0.0058823824,0;0,0.011363637;0.5,0;\n2,3.505814;1.0116279,4;1,4.0277777;0.71311474,5;1,5.2868853;2,5.9905663;2.0277777,6;2,6.0116277;1.505814,7;2,7.988372;3,7.9722223;3.2868853,7;4,6.2868853;4.9722223,6;4,5.0277777;3,5.0277777;2.990566,5;2.494186,4;\n6,5.0094337;5.0094337,6;5.0116277,7;6,7.494186;6.505814,8;7,8.988372;7.988372,8;7.9905663,7;\n9.494186,8;10,7.2868853;10.505814,8;11.505814,9;11,9.505814;10,9.505814;9.494186,9;\n7,9.011628;6.505814,10;7,10.988372;7.0277777,11;7,11.009434;6.0094337,12;7,12.990566;7.9905663,12;8,11.972222;8.972222,11;8,10.027778;7.988372,10;\n13,9.494186;13.505814,10;13.027778,11;14,11.972222;14.005882,12;14.027778,13;14.027778,14;14,14.009434;13.972222,14;13.972222,13;13,12.027778;12,12.505814;11.494186,12;11.494186,11;\n2.2868853,11;3,10.494186;3.505814,11;3,11.713115;\n11.494186,14;12,13.494186;12.713115,14;12,14.713115;\n2,14.027778;0.027777778,16;0,16.5;-0.0058823824,17;0,17.007812;0.5,17;1,16.972221;2,16.286884;2.2868853,16;2.9722223,15;\n12.972222,15;13,14.972222;13.009434,15;13.009434,16;13,16.011627;12.972222,16;\n17,16.009434;16.009434,17;17,17.452587;17.452587,17;\n", "SdfData": { "Samples": "1KuAVauAgIBLEQAAAAAAAAAAANR/gICAVUuAgEsAAAAAAAAAAADUq4CrbquAq4BLJAAAAAAAAAAA1ICAgG5ugG5ugG4kAAAAAAAAANSAgKtubm5ugIBubiQAAAAAAADUgIBVq1VVgICrgIArJAAAAAAA1KtuS4CAq4CAgFVVbm4kAAAAANSAq4BuboBLgICrq4BuJAAAAADUgKtVbquAVUuAgG6AgCsAAAAA1ICrgICAgKtVgFWrVUsRAAAAANR/bqtVS0uAgIBVq6tVVTIAAADUf25uVYCAq1WAgFVVVatVAAAA1H9ubqtVS4CAboCAVauAbiQAANR/q4BugEuAS4Crq1WrgIArJADUgICAboCAgICAVYBLVW6Abm4k1ICAgIBVq26Abm6AVatugG5uS9SrgG6Abm5ubm5uK25ugEtuboDUgG5uq25ubm5ugG5uboBLboCA1H\u002BAq24yS4BLS4Buq6tVbm6ASw==", "BaseIndex": 20, "Size": 16, "RowStride": 19 }, "EdgeStyle": "Round", "EdgeWidth": 0.5, "EdgeFaces": 3
I got a bunch more with EdgeWidth of 0.5 and EdgeFaces of 3
FWIW I get these literally every single time in Grubs, just haven't been reporting actively. Not sure how much you want me to share.
Internal error in PolygonMeshBuilder!
Please paste the info below in this thread:
https://github.com/Facepunch/sbox-sdf/issues/17
{
"Exception": "System.Exception: Exception of type \u0027System.Exception\u0027 was thrown.\r\n at Sandbox.Polygons.PolygonMeshBuilder.FindAboveSweepEdge(Edge\u0026 edge) in C:\\Users\\Aiden\\Documents\\S\u0026box Projects\\grubs\\Libraries\\facepunch.libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 191\r\n at Sandbox.Polygons.PolygonMeshBuilder.Fill_SplitIntoMonotonicPolygons() in C:\\Users\\Aiden\\Documents\\S\u0026box Projects\\grubs\\Libraries\\facepunch.libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 280\r\n at Sandbox.Polygons.PolygonMeshBuilder.Fill() in C:\\Users\\Aiden\\Documents\\S\u0026box Projects\\grubs\\Libraries\\facepunch.libsdf\\Code\\facepunch.libpolygon\\PolygonMeshBuilder.Fill.cs:line 17\r\n at Sandbox.Sdf.Sdf2DMeshWriter.WriteRenderMesh(Sdf2DLayer layer) in C:\\Users\\Aiden\\Documents\\S\u0026box Projects\\grubs\\Libraries\\facepunch.libsdf\\Code\\2D\\Sdf2DMeshWriter.cs:line 580\r\n at Sandbox.Sdf.Sdf2DMeshWriter.Write(Sdf2DArrayData data, Sdf2DLayer layer, Boolean renderMesh, Boolean collisionMesh) in C:\\Users\\Aiden\\Documents\\S\u0026box Projects\\grubs\\Libraries\\facepunch.libsdf\\Code\\2D\\Sdf2DMeshWriter.cs:line 445",
"EdgeLoops": "0,-1.0078125;-0.0058823824,-1;-0.0058823824,0;-0.0058823824,2;0,2.0113637;0.011363637,2;0.011363637,1;0.5,0;0.5,-1;\n8,-1.2160494;7.7131147,-1;8,-0.71311474;9,-0.71311474;9.713115,0;10,0.9722222;11,0.9941176;11.009434,1;15.009434,5;15.027778,6;16,6.2868853;16.505814,7;17,7.494186;17.400944,7;17.549644,6;17.66754,5;17.66754,0;17.66754,-1;17,-1.6675392;16,-1.6675392;11,-1.6675392;10,-1.5496454;9,-1.2160494;\n9,1.0116279;8.505814,2;9,2.494186;9.988372,2;\n1,4.0277777;0.71311474,5;1,5.9722223;1.2868853,5;\n5,4.7131147;4.7131147,5;5,5.9722223;5.2868853,5;\n12,8.713115;11.713115,9;12,9.286885;12.286885,9;\n9,10.027778;8.027778,11;9,11.286885;9.972222,11;\n11,14.027778;10.713115,15;11,15.286885;12,15.286885;12.286885,15;12,14.027778;\n",
"SdfData": {
"Samples": "1H\u002BAq4CAq6urbm4yAAAAAAAAANR/gKuAgKurq6urbisRAAAAAADUf6urgICAgICAgICASxEAAAAA1H\u002Brq4CrgKurq1WAgIBLEQAAANSrq6uAgICrq6urgICrgEsRAADUgICAq4CrgKuAq4CAgICASxEA1Ktuq6urbquAq4CrgKurq4BLANSrgICrq4CAq4CAgKuAgICAbjLUq4CrgICAgICAq4CAgICrq6tV1ICAq6urgICrq6uAq6urq4Crq9Srq6urq6uAgICAq6tuq4CrgKvUq6uAgKuAq6urgICAq6uAq4Cr1Kurq4CAq6urgG6AgICAgKuAq9Srq4CAq6urq4CrgICrq6uAq6vUq4CrgICAgKuAq6urgKurq4CA1KuAq4Crq6urq4CrgICAgKuAgNSrgICAq6uAgKuAq25uq6uAgKvUq6urgICAgKurq6urq4CrgKur1Kurq6urq4CrgKurq4CrgICrqw==",
"BaseIndex": 20,
"Size": 16,
"RowStride": 19
},
"EdgeStyle": "Round",
"EdgeWidth": 0.5,
"EdgeFaces": 3
}
at Sandbox.Sdf.Sdf2DMeshWriter.Write(Sdf2DArrayData data, Sdf2DLayer layer, Boolean renderMesh, Boolean collisionMesh) in C:\Users\Aiden\Documents\S&box Projects\grubs\Libraries\facepunch.libsdf\Code\2D\Sdf2DMeshWriter.cs:line 445
Thanks for these, and sorry for the slow progress here.
I'm pretty sure I'll need to do a more substantial rewrite rather than tweaking epsilons, since fixing one case tends to cause another to regress. Something I'm unsure about is if I can get away with using fixed point internally to avoid precision issues.
That makes sense. I am curious why it started behaving so much worse after scene though 👀 We rarely received these issues in entity-system Grubs. Even our pre-existing texture levels get black squares and errors, when they never did before.