Skip to content

v3.4.0

Compare
Choose a tag to compare
@andywiecko andywiecko released this 25 Oct 16:43
· 27 commits to main since this release

πŸŽƒ Halloween Update πŸŽƒ

✨ What's new?

πŸ†• Dynamic triangulation

This release introduces basic support for dynamic triangulation with the new DynamicInsertPoint extension. It allows for dynamically inserting a point into a triangulation within a specified triangle using barycentric coordinates. Future updates will expand functionality to include additional extensions for splitting a halfedge and removing specific points, as well as, updates will increase performance related to point insertion/removal.

Here's an example snippet showcasing triangulation followed by a dynamic point insertion:

var t = new UnsafeTriangulator<float2>();

using var positions = new NativeArray<float2>(..., Allocator.Persistent);
using var constraints = new NativeArray<int>(..., Allocator.Persistent);
var input = new InputData<float2> { Positions = positions, ConstraintEdges = constraints };

using var outputPositions = new NativeList<float2>(Allocator.Persistent);
using var triangles = new NativeList<int>(Allocator.Persistent);
using var halfedges = new NativeList<int>(Allocator.Persistent);
using var constrainedHalfedges = new NativeList<bool>(Allocator.Persistent);
var output = new OutputData<float2> { Positions = outputPositions, Triangles = triangles, Halfedges = halfedges, ConstrainedHalfedges = constrainedHalfedges };

t.Triangulate(input, output, args: Args.Default(autoHolesAndBoundary: true), Allocator.Persistent);

// Insert a new point in triangle with index 42 at the center (barycentric coordinates: [β…“, β…“, β…“]).
t.DynamicInsertPoint(output, tId: 42, bar: 1f / 3, allocator: Allocator.Persistent);

Learn more in the manual.

πŸ†• Online demo

To better demonstrate the package's capabilities, we've prepared a small online demo, available here.

image

πŸ“ˆ Enhanced refinement performance

To support dynamic triangulation, we refactored portions of the refinement process, resulting in a nearly 2x performance improvement after recent fixes and optimizations.

image

πŸ“ˆ Improved editor compatibility

TriangulationSettings is now better suited with UnityEditor, enhancing the user experience when configuring settings in the editor.

image

πŸ”§ Important refinement fixes

This release addresses two key issues related to refinement.

  1. Fixed a rare issue that could produce invalid results, especially in cases where the input data included clustered subsegments, which occasionally caused points to appear outside the triangulation domain.
  2. Resolved an issue where refinement with constraints would ignore boundaries if no holes were present.

πŸ“ Changelog

Added

  • Dynamic triangulation support. Introduced DynamicInsertPoint extension for UnsafeTriangulator to support dynamic point insertion.
  • A new demo scene to better illustrate the functionality in the documentation.

Changed

  • Improved support for TriangulatorSettings in UnityEditor by adding a missing backing field, a setter, and editor-related attributes for properties.
  • Refinement step optimization. Refactored the refinement step to enhance performance and simplify the code.

Fixed

  • Refinement with constraints without holes. Corrected an issue where refinement with constraints would ignore boundaries when holes were absent.
  • Invalid refinement results. Fixed a rare issue where refinement could produce invalid results, especially when input data included subsegment clusters, leading to points appearing outside the triangulation domain.

Full Changelog: v3.3.0...v3.4.0