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 clipping to CSGPolygon in path mode #10561

Open
nickpolet opened this issue Aug 26, 2024 · 4 comments
Open

Add clipping to CSGPolygon in path mode #10561

nickpolet opened this issue Aug 26, 2024 · 4 comments
Labels

Comments

@nickpolet
Copy link

nickpolet commented Aug 26, 2024

Describe the project you are working on

Working on a racing game that requires some fairly complex meshes to be extruded along curves (for racetracks), Currently, CSGPolygon meshes can be generated along a curve nicely, but the only option is to extrude along the whole curve.

Describe the problem or limitation you are having in your project

Being able to have different CSGPolygon meshes that can have different start and end points along the curve would allow for much greater flexibility.

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

Adding clip_start and clip_end or something similar to CSGPolygon would allow the generated mesh to start and end at custom points along the mesh. Ideally, the interval length should be respected and the mesh should start from the clip_start and end at clip_end.

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

The basic idea is to add clip_start and clip_end to CSGPolygon, which affects the mesh similar to the below mockup.

These are just rough values to help show the idea. The Curve3D is represented by the green line here.

image1
image1-6
image1-2

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

I don't think this is possible with just a few lines.

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

After having a look through the _build_brush function for CSGPolygon, the initial sample point for the curve is hardcoded to 0. There would also need to be quite a few adjustments to other variables/logic in that function. I don't think any of this is exposed to gdscript to make adjustments there.

@nickpolet
Copy link
Author

Here's a quick and dirty attempt at getting this functionality working to show the proposal functionality better than the description above.

2024-08-30.21-58-33.mp4

Since this type of functionality is quite important for the game I'm working on, I'd be quite happy to spend some time working on getting this functionality, however, I have a couple of questions.

  • Would the clipping need to be available to all Path, Depth and Spin modes for CSGPolygon?
  • What would be the best data type for this. In my quick example video above, it's 2 floats, one for start one for end. It might work better acting like the mix/max variables in particle settings.
  • Is additional CSG functionality like this likely to be accepted and merged if it gets to a useful state?

Any pointers or direction on this would be really helpful. I haven't contributed before, so I'm unsure of the path through 😅

@Calinou
Copy link
Member

Calinou commented Aug 31, 2024

  • Would the clipping need to be available to all Path, Depth and Spin modes for CSGPolygon?

I think this property only really makes sense for the Path mode, at least for now.

  • What would be the best data type for this. In my quick example video above, it's 2 floats, one for start one for end. It might work better acting like the mix/max variables in particle settings.

2 floats is the most logical option. The particle inspector uses a special inspector plugin to allow the inspector to display it in a special manner: godotengine/godot#81260

This would be a lot of work to implement just for CSG, so I'd leave it as-is.

  • Is additional CSG functionality like this likely to be accepted and merged if it gets to a useful state?

CSG lacks an active maintainer, so it's hard to say. There's also the fact that CSGPath3D is often being used without actually needing CSG features (union, subtraction, intersection). This has a significant performance overhead as some of this logic runs even if the CSG node has no parent or child CSG nodes.

In other words, what you probably need is a 3D line builder, rather than a CSG node that happens to generate something that can look like a 3D line.

@nickpolet
Copy link
Author

nickpolet commented Sep 1, 2024

@Calinou, thanks for that. Given me some direction.

CSG lacks an active maintainer, so it's hard to say. There's also the fact that CSGPath3D is often being used without actually needing CSG features (union, subtraction, intersection). This has a significant performance overhead as some of this logic runs even if the CSG node has no parent or child CSG nodes.

In other words, what you probably need is a #6151, rather than a CSG node that happens to generate something that can look like a 3D line.

I think I'm willing to try and implement this functionality. I can see the benefit of being able to do this. Unfortunately something like Line3D isn't what I need here, and doesn't help with complex extrusions along a path with complex shapes.

Is there a good discord channel where I can ask implementation specific questions that I might have as I start implementing this?

@Calinou
Copy link
Member

Calinou commented Sep 5, 2024

Is there a good discord channel where I can ask implementation specific questions that I might have as I start implementing this?

Engine development is coordinated on the Godot Contributors Chat 🙂

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

No branches or pull requests

3 participants