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

Allow scaling a path-following CSGPolygon #2412

Open
kb173 opened this issue Mar 6, 2021 · 6 comments
Open

Allow scaling a path-following CSGPolygon #2412

kb173 opened this issue Mar 6, 2021 · 6 comments

Comments

@kb173
Copy link

kb173 commented Mar 6, 2021

Describe the project you are working on

A landscape visualization which includes dynamically generated streets from geodata. For these, we have a CSGPolygon with a PoolVector2Array polygon, which is extruded along the paths representing the streets.

Describe the problem or limitation you are having in your project

We would like to generically resize that polygon without having to know its exact points, so that we can easily adapt any street profile to the exact width at that segment. For example, we would pre-define a street profile at a width of 2m and then dynamically adapt that width to the actual width at a given position. I had expected to be able to do this by setting the 'Scale' parameter in its Transform.

However, the scale entered in the CSGPolygon's Transform is only visible until a different node is selected; then is resets (only visually - the different value is still in the Transform). For the short moment where the scale is visible, it doesn't actually scale the polygon, but the whole mesh extruded along the path. This is the result I would expect when scaling the path, not the polygon.

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

Scaling the CSGPolygon by setting its 'Transform -> Scale' parameter should scale the polygon itself, so that a line which is extruded from it becomes thicker/thinner.

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

There is no need for new editor tabs or code functions - the existing Scale from the Transform which CSGPolygon inherits from would be used as described above.

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

With a scale of 1, everything will remain the same. The behavior for non-1 scale is changed - in a way, this breaks compatibility for projects which rely on the scale not affecting the CSGPolygon, but the current behavior seems more like a bug to me?

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

I intuitively expected scaling the CSGPolygon to have the result described above; I assume that it might be similar for others. Additionally, as I said above, the current behavior feels like a bug due to the short moment in which the scale is visible (in an unexpected way). Some type of change is required to clear up confusion (e.g. an editor warning when scaling a CSGPolygon, if this enhancement is not implemented).

(This supercedes godotengine/godot#32171)

@Calinou
Copy link
Member

Calinou commented Mar 9, 2021

Thinking about it, isn't this a duplicate of #1062? I just reminded myself about that proposal.

@Zireael07
Copy link

Yep, looks like a dupe.

@kb173
Copy link
Author

kb173 commented Mar 9, 2021

Oh true, it's similar, but not quite the same I think -- if I understand correctly, the other proposal is about being able to have a different CSGPolygon for the start and the end, while this proposal calls for being able to use the Transform's Scale property for scaling one CSGPolygon involved in a PathFollow uniformly. (I suppose that the other proposal might benefit from the implementation of this one, since it mentions scaling, but in that case it expands on this proposal.)

@stebulba
Copy link

stebulba commented Apr 1, 2021

(I suppose that the other proposal might benefit from the implementation of this one, since it mentions scaling, but in that case it expands on this proposal.)

No I included a scaling mode in my code: godotengine/godot#41499

The interpolation work using a Curve who interpolate between two polygon array. If both polygons are equal, a single scaling mode is active.

By default, if you did't modify the second array, the scaling mode is activate. If you modify the second array, the expand mode is activate. I like "expand" to call this mode :)

Remember, that if you want scaling a perfect square, you have to set up yours arrays with the position 0, 0 as center. By default the path polygon make a rectangle in positive position.

@stebulba
Copy link

@kb173 I made a new pull request. godotengine/godot#53195
Does this solve your limitation ?

@kb173
Copy link
Author

kb173 commented Sep 29, 2021

@kb173 I made a new pull request. godotengine/godot#53195 Does this solve your limitation ?

@stebulba Yes, this looks amazing! The x-axis scaling you show off in the first video is exactly what we need, given that we're working with streets. Thank you for your work!

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

4 participants