Giter Site home page Giter Site logo

Comments (7)

cart avatar cart commented on May 9, 2024

I'm not a legion expert but I have a theory: the archetype changed when you added Bar, which resulted in a move of the entity's components, which triggered a "changed" event for Foo?

from legion.

TomGillen avatar TomGillen commented on May 9, 2024

Cart is right. When you add a component to an entity, it internally moves the entity into a new chunk, which will cause all components to be seen as changed. Composition changes are essentially removing the entity and then inserting a new one with the same Entity ID.

from legion.

cart avatar cart commented on May 9, 2024

Its good that we understand why its happening, but is the behavior of this event desirable? Is there a way to make the event behave the way most people would expect it to?

It makes the event less useful for things like "I only want to update the transform hierarchy when the position component changes".

from legion.

cart avatar cart commented on May 9, 2024

In that case, the value of the component hasnt changed. Only the internal legion representation of the value. From the perspective of the public interface presented nothing has changed.

from legion.

IcanDivideBy0 avatar IcanDivideBy0 commented on May 9, 2024

Yes, I've come to the same conclusion that archetype change is in cause. Specifically, changed filter checks for the version number of the component slice (not the component).

Some possibilities i see:

  • adding the PartialEq to Component trait would allow the filter to check for equality in case version number changed nevermind, this would require to store store previous components data as well to compare against
  • refactoring ComponentResourceSet to use multiple versions (per component), in such case ComponentResourceSet::data_slice_mut<T> should be in charge of incrementing versions numbers and ComponentResourceSet::data_raw_mut may not be public anymore. This will add some overhead but will provide the "correct" behavior IMO
  • renaming filter to may_have_changed ?

let me know if you have any other ideas

I'm not really familiar with legion nor the archetype storage strategy, if you have some documents or articles around these subject, it might worth putting a link into the readme, took me a lot of time getting my head around the basic principle.

from legion.

IcanDivideBy0 avatar IcanDivideBy0 commented on May 9, 2024

Any news / feedback on this ?
It seems the changed filter is broken in many ways at the moment, not just in the case of adding a component. Also having a filter for added / deleted components seems essential IMO.
I'd be happy to contribute if you can point me in the right direction @TomGillen

from legion.

IcanDivideBy0 avatar IcanDivideBy0 commented on May 9, 2024

It seems to be fixed now on master, probably in c99326e

from legion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.