Get the newest version of the source/final scripts on Github.



DEVELOPER WORDS

I am currently using this tool in my game Fracture Hell. You can take a look to see what it is capable of or how it can be used. Buying Fracture Hell is a great way to support me if you are interested and any feedback regarding this tool or Fracture Hell is greatly appreciated. Fracture Hell is available on SteamItch Io, and Gotm.

You can play the demo for free right here on itch in the browser, enjoy!



Updates

  • UPDATE v2.0.0 ported to Godot 4.0 (Godot 4.2+)
  • UPDATE v1.4.0 Restore Polygon System implemented. Supershape functions added. (Godot 3.2+)
  • UPDATE v1.3.0 Texture System and Point Fracture System implemented. (Godot 3.2+)
  • HOTFIX v1.2.1 Pool Instances were not freed on game exit. (memory leak) (Godot 3.2+)
  • UPDATE v1.2.0 overhauled the mouse cut system (bonus: pool manager-script) (Godot 3.2+)
  • UPDATE v1.1.0 adds cutting of polygons. (Godot 3.2+)


Info

Works with GodotEngine 4.2+. Tested with Godot Versions: 4.2.2
Godot Polygon Fracture 2D v1.4 and before only works with Godot 3!

Two simple scripts for fracturing and cutting polygons. PolygonFracture.gd is the actual script that fractures/cuts polygons. PolygonLib.gd adds nice helper functions for polygons like calculateArea, triangulate, getRandomPointsInPolygon, getBoundingRect, makeCirclePolygon etc.

Point Fracture

Originally I wanted to do a more sophisticated point fracture system but it always turned out to be a complicated mess. Finally, I figured out a simpler way by using the already implemented Cut-Fracture system. I added a func to generate a randomized polygon and with a point (like a collision point), this randomized polygon can be used in the cut fracture method.



Texture System

Polygons with textures can now be fractured too. Texture Offset/Rotation/Scale can be any value or randomized. Fracture Shards and Finals Shapes update their textures accordingly. 




Cut Methods

There is just one cut method. It uses 1 polygon as the source and 1 polygon as a cut shape. The intersected shape (the parts overlapping in both polygons) can be fractured if desired. I also added helper funcs to PolygonLib.gd to create simple polygon shapes (currently: rectangle, circle, beam).


NEW SYSTEM (v1.2.0)



OLD SYSTEM




Fracturing Methods

There are two different systems for fracturing polygons.

 - Delaunay Fracture -> uses the delaunay triangulation to calculate random triangles inside the polygon. DelaunyFractureConvex assumes the polygon is convex and     DelaunyFractureRectangle assumes the polygon is a rectangle (convex/rectangle makes the fracturing simpler). Produces triangle fractures.

 - Fracture -> uses randomly generated cut lines to actually cut the polygon. Fracture and Fracture simple have different methods of obtaining the random cut lines but are otherwise the same. Produces polygon fractures.


Delaunay System



Cut Line System




RESTORE POLYGONS

I implemented 2 different methods of restoring polygons.

Simple

Use the polygon restorer class to save polygons in a stack. The first element of the stack represents the original state the last element represents the previous state. By simply getting the last element, the polygon can be restored to the previous state.




Advanced

The advanced method just uses one function in the polygon lib. While the simple method restores only discrete states of the polygon the advanced method can restore any amount of the polygon by growing it and restraining it to the shape of the original polygon. The advanced method has a bigger impact on performance.




Superellipse & Supershape

I added functions for creating superellipse and supershape polygons to the polygon lib. 

I had the idea after watching a coding challenge from The Coding Train. Really well-explained tutorials with the source code provided. 

I highly recommend checking it out :D 

Supershape coding challenge

Superellipse coding challenge

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



My method is not the best or most performant method out there, and also implemented via GDScript (for ease of use), so don´t expect any performance miracles. There are other solutions out there, but I did not find a simple solution for fracturing 2d polygons in the way I wanted. Maybe sometime in the future, I will look into Voronoi fractures, to make the fractures look better. (Now the polygon is just randomly fractured) 


Support Me

You can support me here on itch io or via GitHub Sponsors. I truly appreciate any support!


StatusReleased
CategoryTool
PlatformsHTML5, Windows, Linux
Rating
Rated 5.0 out of 5 stars
(10 total ratings)
AuthorDave Green
Made withGodot
Tags2D, Destruction, fracture, Godot, polygon
Code licenseMIT License
Average sessionA few seconds
InputsKeyboard, Mouse

Download

Download NowName your own price

Click download now to get access to the following files:

Polygon Fracture 2D (2.0.0) [newest] 25 MB
Polygon Fracture 2D (2.0.0) [newest] 22 MB

Development log

Comments

Log in with itch.io to leave a comment.

(1 edit)

Incredible work and incredible library :D

I used your library in my game for a gamejam. If you wanna check it out https://ille.itch.io/plummet-panic

Thank you very much :) 

Great game! I am happy the tool is still used and helps people make games :)

Does this work with Godot 4?

I don´t know. I haven´t checked it and am currently not using Godot, so unfortunately I don´t know. You would have to try it out ;)

It now works with Godot 4 ;)

This looks like a brilliant tool, and very impressive demos :)

Will definitely check out the source for inspiration, I've been experimenting with the 2D geometry methods introduced in Godot 3.2 for a little project of mine :)

Thank you :) 

Yeah, this tool only uses the geometry class and my own code (if I remember correctly xD). Basically, the triangulation and Delaunay triangulation functions were the most important for me.

(+1)

It would be nice to have binary version for Linux

(+2)

I just uploaded one from the latest release (v1.4.0) ;) 

Thanks for sharing this. Looks incredible!

Thanks a lot, I really appreciate it :D

This is awesome!

Thank you very much :D