mdegans / weave

Branching story writing tool with generative AI
Other
1 stars 0 forks source link

Nodes stick to edges of the screen #17

Open mdegans opened 2 months ago

mdegans commented 2 months ago

This is caused by some collision code. The issue is the node velocity keeps changing direction, but with a very high damping. This is intended to cause a bounce effect, and it does, but because the node's collision rect can get outside the window bounds (the window is still constrained) the bounce code gets triggered at every frame. Because of the damping, the node's velocity quickly drops to 0.

Possible solutions are to either disable the collision code or fix the clamping so the node rect cannot be outside the bounds of the window, which is how it gets stuck in a cycle of alternating velocity. This way when a node hits the side of the window the velocity will only alternate once, creating the desired bounce effect rather than sticking.

mdegans commented 2 months ago

Even with the node constraints fixed, this seems to still be an issue. Best guess is the issue is one of floating point precision and this line below. It only happens on the left edge for some reason.

if !bounds.contains_rect(new_pos) {

If this is the last outstanding bug for this feature we can release as-is. Users can just drag stuck nodes away from the left edge to fix them.