Godot Polygon2d Fracture Versions Save

A simple script for fracturing polygons. Also adds nice helper functions for polygons like calculateArea, triangulate, getRandomPointsInPolygon, getBoundingRect)

v1.4.0

2 years ago

Features

  • New Polygon Restore Systems:

    • Simple via the new Polygon Restorer class.
    • Advanced via a new function in the Polygon Lib class.
  • 2 new demo scenes to showcase the restore functionallity.

  • New function for creating Superellipse polygons. Thanks to The Coding Train

  • New function for creating Supershape polygons. Thanks to The Coding Train

-> Check out The Coding Train on GitHub or on the Website.

v1.3.0

3 years ago

Features

  • Texture System -> Fractured polygons can have textures now.
  • Point Fracture -> Just use a single point and a randomized polygon for this new system.
  • Scale System -> Scaled things can be cut/fractured now.
  • Fracture Shard -> simple fake rigid body if you don't want to use the physics system. (like collisions)

Cleanup

  • General Code Clean up.
  • Polygon Lib uses only transforms now.
  • Polygon Lib no longer rotates the source polygon but transforms the cut shape into the source's local space.
  • License text added to all gd files.

v1.2.1

3 years ago

Hotfix

  • pool instances were not freed on game exit

v1.2.0

3 years ago

Important Bugfixes

  • Triangle area calculation sometimes returned invalid integers causing corrupt polygons

Added Functionality

Mouse Cut System Overhaul

  • Now instead of always drawing a straight line, the path of the mouse is traced, simplified, and converted into a cut shape.
  • The input system was unified to 1 button so it works on touch screens too. (HOLD LMB for cut lines, Tap LMB for simple circle cut)

Bonus

  • I implemented a simple pool manager script for handling "fracture bodies" and "cut shape visualizer". You can use it as is or use it as inspiration for your own pooling system :)

v1.1.1

3 years ago

Disappearing Polygon Bug Fixed

Sometimes after cutting a polygon, 1 half disappeared while the other was spawned. Probably happened with fracture shards too. (but was not noticeable because so many fracture shards were spawned. As it turned out, triangulating a polygon sometimes produced very small triangles where my area calculation code produced invalid areas (-1.#IND) causing all code using that invalid area to produce invalid polygons. These small triangles had such a small area that probably through float imprecisions a negative value (instead of 0) was used in sqrt causing the -1.#IND values. The triangle area code now returns 1.0 if a negative value is detected.

Cut Line System Overhaul

The cut line system in the cut fracture test scene was improved. Looks more like Fruit Ninja now xD.

v1.1.0

3 years ago

It is now possible to cut polygons with other polygons and fracture the cutouts. Funcs for creating simple polygons were added to PolygonLib.gd.

v1.0.2

3 years ago

Contains the 2 final scripts for fracturing polygons and the demo project to showcase the fracturing.