All Projects → SoloByte → godot-polygon2d-fracture

SoloByte / godot-polygon2d-fracture

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

Programming Languages

GDScript
375 projects

Projects that are alternatives of or similar to godot-polygon2d-fracture

Fake-Interior-Shader-for-GodotEngine
Interior Mapping shader for the Godot Game Engine 3.x that works with both GLES3 and GLES2.
Stars: ✭ 40 (-72.97%)
Mutual labels:  godot, godot-engine
BrainfuckIDE
A Brainfuck IDE/debugger designed to be intuitive, featureful and visually appealing
Stars: ✭ 77 (-47.97%)
Mutual labels:  godot, godot-engine
godot-plugin-refresher
Adds a dropdown and refresh button combo to the toolbar for instantly toggling off/on a plugin. Enables faster workflows for Godot plugin developers.
Stars: ✭ 104 (-29.73%)
Mutual labels:  godot, godot-engine
OpMon-Godot
An open source Pokemon-inspired game, now with Godot
Stars: ✭ 50 (-66.22%)
Mutual labels:  godot, godot-engine
godot-size-benchmarks
Benchmarks to compare Godot binary sizes with different build-time options
Stars: ✭ 36 (-75.68%)
Mutual labels:  godot, godot-engine
Godot-3.0-Noise-Shaders
Godot 3.0 Noise Shaders
Stars: ✭ 38 (-74.32%)
Mutual labels:  godot, godot-engine
Freedom-Hunter
Monster Hunter like action RPG game
Stars: ✭ 71 (-52.03%)
Mutual labels:  godot, godot-engine
Persistence
Plugin para almacenar datos de forma persistente en Godot Engine 3
Stars: ✭ 20 (-86.49%)
Mutual labels:  godot, godot-engine
-godot-gj-api
GameJolt API plugin for Godot Engine
Stars: ✭ 45 (-69.59%)
Mutual labels:  godot, godot-engine
Logic-Circuit-Simulator
A free and open-source Logic Circuit Simulator built in Godot Engine.
Stars: ✭ 23 (-84.46%)
Mutual labels:  godot, godot-engine
GodotDiscordSDK
A Discord Game SDK wrapper for Godot, written in C.
Stars: ✭ 40 (-72.97%)
Mutual labels:  godot, godot-engine
godot-uuid
Unique identifier generation v4 for Godot Engine
Stars: ✭ 96 (-35.14%)
Mutual labels:  godot, godot-engine
godopy
[WIP] Python scripting for the Godot game engine
Stars: ✭ 27 (-81.76%)
Mutual labels:  godot, godot-engine
godot-nightly
A program to download the latest version of Godot Nightly Builds
Stars: ✭ 23 (-84.46%)
Mutual labels:  godot, godot-engine
godot-kotlin
Kotlin Native bindings for Godot Engine
Stars: ✭ 11 (-92.57%)
Mutual labels:  godot, godot-engine
godot-shotgun-party
An evolving multiplayer project for Godot Engine 3.
Stars: ✭ 171 (+15.54%)
Mutual labels:  godot, godot-engine
gdosc
OSC module for Godot game engine - it is now discontinued in favor of https://gitlab.com/frankiezafe/gdosc
Stars: ✭ 14 (-90.54%)
Mutual labels:  godot, godot-engine
godot-sponza
Sponza demo for Godot 3.x (`master` branch) and 4 (`4.0-dev` branch)
Stars: ✭ 133 (-10.14%)
Mutual labels:  godot, godot-engine
godot-ci
Docker image to export Godot Engine games. Templates for Gitlab CI and GitHub Actions to deploy to GitLab Pages/GitHub Pages/Itch.io.
Stars: ✭ 316 (+113.51%)
Mutual labels:  godot, godot-engine
godot-lod-demo
Demonstration project for the Level of Detail (LOD) Godot 3.x add-on
Stars: ✭ 34 (-77.03%)
Mutual labels:  godot, godot-engine

godot-polygon2d-fracture

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 Steam and Itch Io.

UPDATES

  • UPDATE v1.4.0 adds polygon restoring - simple and advanced
  • UPDATE v1.3.0 texture system + point fracture system + big cleanup
  • UPDATE v1.2.0 overhaul of mouse cut system + important bug fixes + pool manager script (bonus) + "juice".
  • UPDATE v1.1.0 adds cutting of polygons.

Info

Works with GodotEngine 3.2+ Tested with Godot Versions: 3.2.3, 3.3, 3.3.1

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.

The final scripts are located in the polygon2d-fracture folder. The demo project is located in the demo folder.

The pool manager script added in [Update v1.2.0] is just a bonus. You can use it as is or use it as inspiration for your own pooling system :)

You can download/play the demo on itch.io. :D

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 with 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.

In this gif you can also see that polygons with textures can now be cut/fractured too :)

Cut Method

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).

[Update v1.2.0] overhauled the mouse cut system for the demo project. 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)

NEW CUT METHOD

OLD CUT METHOD

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

Restoring

I added two different methods of restoring polygons to their original state.

Simple

The simple method uses the polygonRestorer.gd script. This is a simple class with an array(stack) of polygons. Each polygon represents a state. The last element represents the previous polygon, the first element represents the original polygon. The user can add new shapes, get the original state, the current state or the previous state with simple functions.

Advanced

The advanced method just uses 1 function in the polygonLib.gd script. The simple method stores the states of the polygon and can restore each state. The advanced method grows the polygon by a certain amount while restricting it to the original polygons shape. In other words: the simple method can only restore discrete states while the advanced method can restore any amount in between. Unfortunately the advanced method comes with a bigger performace cost. As seen in the demo, it should not be a problem using it every now and then but restore intervals below about 0.2 seconds can slow things down significantly.

I would suggest just testing it because as always it depends on how and for what you want to use it ;)

I need the fracturing for my game but I thought I share it with anyone interested. 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)

Other Solutions

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].