Closed limbonaut closed 4 months ago
Not really a fix but a quick workaround. An actual fix would be to generate a closed curve. But I think this workaround suffices for the two people actually using open shapes.
Edit: Just wanted to suggest to update the doc comment and suddenly a new commit is pushed :D
Thanks for fixing!
@mphe I actually use open shapes :sweat_smile: , but in a rather unusual manner - secret areas:
That's how I discovered this issue.
How exactly? (hard to see on the picture) I use closed shapes for secret areas but without "solid" collisions, so you can walk through them and they fade out.
@mphe, I use smash-to-reveal areas like this:
I've posted the code on discord some time ago - if you search for "secret area" you'll find it.
Ahh ok, so there is an open shape with a closed one without edges attached. In such cases I usually use one shape and set material overrides on respective edges to "don't render".
Not exactly, the cover is a Polygon2D with a script.
@tool
## Script that manages a "cover" (see below). Updates are performed when transform is changed.
## It doesn't deal with rotations.
## Note: Not the full source code.
@export var sync_shape: SS2D_Shape
## `cover` is a Polygon2D that syncs its own fill texture to the SS2D's.
## It serves as an overlay that can be put on top of an SS2D and cover a "secret" area.
@onready var cover: Polygon2D = $Editable/Cover
func _notification(p_what: int) -> void:
if p_what == NOTIFICATION_TRANSFORM_CHANGED:
_update_cover_offset()
func _update_cover_offset() -> void:
if not sync_shape:
return
for i in cover.polygon.size():
cover.polygon[i] += cover.global_position
cover.global_position = Vector2.ZERO
var offset: Vector2 = sync_shape.global_position - cover.global_position
cover.global_position = sync_shape.global_position
for i in cover.polygon.size():
cover.polygon[i] -= offset
Fixes #164