Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 2D CSG nodes #3731

Open
CsloudX opened this issue Dec 31, 2021 · 3 comments
Open

Add 2D CSG nodes #3731

CsloudX opened this issue Dec 31, 2021 · 3 comments

Comments

@CsloudX
Copy link

CsloudX commented Dec 31, 2021

Describe the project you are working on

Maybe a 2d sandbox game

Describe the problem or limitation you are having in your project

I want implement a destructible terrain, in 3d, CSG nodes is a good choose, but in 2d, there was not such nodes.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

2d version CSG nodes, CSGCombine2d can help me. And in godot, lots of nodes have the 2d and 3d version, it's a so good features and easy study

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I thin it's a very useful nodes, many people need it.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I'm a new programmer, so I wish godot's developer can implement this.

Is there a reason why this should be core and not an add-on in the asset library?

There was 3d version CSG nodes, so 2d version CSG nodes should be.

@Calinou Calinou changed the title 2d version CSG nodes Add 2D CSG nodes Dec 31, 2021
@Calinou
Copy link
Member

Calinou commented Dec 31, 2021

I want implement a destructible terrain, in 3d, CSG nodes is a good choose, but in 2d, there was not such nodes.

CSG nodes are actually a poor choice for implementing desctructible terrain, especially in 2D. If you want to avoid stuttering at 60 FPS, performance will plummet as soon as you use more than a few subtractive shapes.

In 2D, there are plenty of alternatives to CSG for implementing something like destructible terrain.

@CsloudX
Copy link
Author

CsloudX commented Dec 31, 2021

@Calinou Thanks

@Xrayez
Copy link
Contributor

Xrayez commented Jan 1, 2022

CSG nodes are actually a poor choice for implementing desctructible terrain, especially in 2D. If you want to avoid stuttering at 60 FPS, performance will plummet as soon as you use more than a few subtractive shapes.

With proper implementation you don't have to clip shapes at 60 FPS, but only once (existing CSG shapes in 3D don't clip meshes at 60 FPS either, unless you move local shapes). Chunking colliders into rectangles would also help dramatically (similarly to grid-based broad phase in physics collision detection).

This proposal is already implemented in Goost. See PolyNode2D node and their primitives, like PolyCircle2D, PolyRectangle2D etc. You can also try out the following example: https://github.com/goostengine/goost-examples/tree/gd3/2d/destructible_terrain

You may ask: why not CSG name but Poly?

  • Because I've rarely stumbled upon CSG name in 2D field, and there are other features that make the current nodes different from 3D. CSG in Godot is rather geared more towards to 3D level prototyping, unfortunately.
  • Most (if not all) clipping operations are done against polygons only, and all shapes can be represented using polygons in 2D (including holes).

Note that I've been implementing destructible terrain in Godot for the past 4 years for the project I'm working on.

In 2D, there are plenty of alternatives to CSG for implementing something like destructible terrain.

In my experience, no other alternative would be as fast as clipping polygons, like with bitmap physics, for which you'd need to implement your own pixel-perfect collision detection and physics, which is a challenge in and of itself. One would certainly need to use C++ for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants