From 9131afc04d18e0b4e8c1cfdb6c1023caf69d2aaa Mon Sep 17 00:00:00 2001 From: Josef Date: Tue, 12 Nov 2024 09:03:36 +0100 Subject: [PATCH] SVG, Procedural Updates --- .../Triangle.NET/Triangle/Geometry/Contour.cs | 30 +- Icons/Rokojori-Action-Library-Logo.svg | 46 ++- Runtime/Godot/MakeResourcesUnique.cs | 23 ++ .../Godot/Scenes/Objects/SceneFileObject.cs | 2 +- Runtime/Logging/RJLog.cs | 37 ++ Runtime/Math/BernsteinPolynom.cs | 29 ++ Runtime/Math/Bezier.cs | 54 +++ Runtime/Math/BinomialCoefficient.cs | 18 + Runtime/Math/CubicBezier.cs | 54 +++ Runtime/Math/Geometry/Curve2.cs | 199 ++++++++++ Runtime/Math/Geometry/Curve3.cs | 296 ++++++++++++++- Runtime/Math/Geometry/CustomCurve3.cs | 22 ++ Runtime/Math/Geometry/LerpCurve3.cs | 6 +- Runtime/Math/Geometry/Line2.cs | 5 + Runtime/Math/Geometry/Line3.cs | 4 +- Runtime/Math/Geometry/Path2.cs | 71 +++- Runtime/Math/Geometry/Pose.cs | 74 ++++ Runtime/Math/Geometry/Shape2.cs | 241 +++++++++++- Runtime/Math/Geometry/SplineCurve.cs | 218 ++++++++++- Runtime/Math/Geometry/SplineCurveCreator.cs | 56 ++- Runtime/Math/Geometry/Triangle3.cs | 26 ++ Runtime/Math/Math2D.cs | 24 ++ Runtime/Math/Math3D.cs | 56 +++ Runtime/Math/MathX.cs | 100 +++++ Runtime/Math/QuadraticBezier.cs | 50 +++ Runtime/Math/Range.cs | 11 - Runtime/Procedural/Assets/Grass/GrassPatch.cs | 347 ++++++++++++++++++ Runtime/Procedural/Assets/Leaf/LeafMesh.cs | 192 ++++++++++ Runtime/Procedural/MeshCreationTest.cs | 4 +- Runtime/Procedural/MeshGeometry.cs | 178 ++++++++- .../Procedural/Parametric/Spline/Spline.cs | 74 +++- .../Parametric/Spline/SplinePoint.cs | 7 + Runtime/Procedural/Parametric/Tube/Tube.cs | 262 +++++++++++++ .../Procedural/Parametric/Tube/TubeShape.cs | 105 ++++++ .../Scatter/Generators/GenerateFence.cs | 4 +- .../Scatter/Generators/GenerateOnSpline.cs | 4 +- Runtime/Random/Noise.cs | 17 + Runtime/Random/RandomEngine.cs | 28 +- Runtime/Sorting/ValueSorter.cs | 6 + Runtime/Text/Lexing/Lexer.cs | 3 +- Runtime/Tools/Lists.cs | 124 +++++++ Runtime/Tools/ReflectionHelper.cs | 23 +- Runtime/XML/SVG/SVGArc.cs | 107 ++++++ Runtime/XML/SVG/SVGPathCommand.cs | 12 + Runtime/XML/SVG/SVGPathExtractor.cs | 175 ++++----- Runtime/XML/SVG/SVGPathInstruction.cs | 146 ++++++++ Runtime/XML/SVG/SVGPathParser.cs | 30 +- Runtime/XML/XMLAttributeName.cs | 8 + Runtime/XML/XMLReader.cs | 22 +- Runtime/XML/XMLReaderTest.cs | 107 +++++- 50 files changed, 3551 insertions(+), 186 deletions(-) create mode 100644 Runtime/Godot/MakeResourcesUnique.cs create mode 100644 Runtime/Math/BernsteinPolynom.cs create mode 100644 Runtime/Math/Bezier.cs create mode 100644 Runtime/Math/BinomialCoefficient.cs create mode 100644 Runtime/Math/CubicBezier.cs create mode 100644 Runtime/Math/Geometry/Curve2.cs create mode 100644 Runtime/Math/Geometry/CustomCurve3.cs create mode 100644 Runtime/Math/QuadraticBezier.cs create mode 100644 Runtime/Procedural/Assets/Grass/GrassPatch.cs create mode 100644 Runtime/Procedural/Assets/Leaf/LeafMesh.cs create mode 100644 Runtime/Procedural/Parametric/Tube/Tube.cs create mode 100644 Runtime/Procedural/Parametric/Tube/TubeShape.cs create mode 100644 Runtime/XML/SVG/SVGArc.cs create mode 100644 Runtime/XML/SVG/SVGPathInstruction.cs diff --git a/External/Triangle.NET/Triangle/Geometry/Contour.cs b/External/Triangle.NET/Triangle/Geometry/Contour.cs index db8fce4..47d71a4 100644 --- a/External/Triangle.NET/Triangle/Geometry/Contour.cs +++ b/External/Triangle.NET/Triangle/Geometry/Contour.cs @@ -130,6 +130,22 @@ namespace TriangleNet.Geometry private static Point FindPointInPolygon(List contour, int limit, double eps) { + if ( contour.Count <= 3 ) + { + var x = 0.0; + var y = 0.0; + + for ( int i = 0; i < contour.Count; i++ ) + { + x += contour[ i ].X; + y += contour[ i ].Y; + } + + var w = contour.Count == 0 ? 0 : ( 1.0 / contour.Count ); + + return new Point( x * w, y * w); + } + var bounds = new Rectangle(); bounds.Expand(contour.Cast()); @@ -204,7 +220,19 @@ namespace TriangleNet.Geometry } } - throw new Exception(); + + var exceptionInfo = "Found no point inside polygon:"; + + var sp = "G"; + var ci = System.Globalization.CultureInfo.InvariantCulture; + + for ( int i = 0; i < Math.Min( 20, length ); i++ ) + { + exceptionInfo += " "; + exceptionInfo += "(" + contour[ i ].X.ToString( sp, ci ) + ", " + contour[ i ].Y.ToString( sp, ci ) + ")"; + } + + throw new Exception( exceptionInfo ); } /// diff --git a/Icons/Rokojori-Action-Library-Logo.svg b/Icons/Rokojori-Action-Library-Logo.svg index 1851829..1d75c38 100644 --- a/Icons/Rokojori-Action-Library-Logo.svg +++ b/Icons/Rokojori-Action-Library-Logo.svg @@ -24,15 +24,15 @@ inkscape:deskcolor="#333333" inkscape:document-units="px" showgrid="false" - inkscape:zoom="0.41781005" - inkscape:cx="543.30909" - inkscape:cy="522.96492" + inkscape:zoom="1.6712402" + inkscape:cx="304.56424" + inkscape:cy="543.00992" inkscape:window-width="1920" inkscape:window-height="1017" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" - inkscape:current-layer="svg5" /> + style="display:inline;fill:#ffffff;fill-opacity:1">