Skip to content

Harden relationships between Points/Edges/Paths and Anchors #398

Description

@mxgrey

Following up on #396 there are some known issues where changes to anchor-dependent types (Point, Edge, Path) can result in inconsistent state where Anchors mistakenly think it has a dependent that it actually doesn't. There could also be cases where Anchors aren't aware of a dependent that it does have, and we just haven't caught that yet.

This problem is strongly tied into the concept of relationships in bevy, but unfortunately bevy relationships currently only support one-to-many relationships, but anchors need many-to-many.

My instinct would be to use observers or component hooks, but I'm not aware of a way to trigger either for a modification (rather than an insert). Instead we might need to make systems that track Changed<Point>, Changed<Edge>, and Changed<Path>. We'll need to introduce a LastKnown<T> component to store the last known value of Point, Edge, or Path and do a comparison between the last known value and the current value every time a change is detected. Then we can subtract dependents from anchors that are no longer used and add dependents to newly used anchors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions