Comments (7)
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.
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.
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.
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.
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 thenevermind, this would require to store store previous components data as well to compare againstPartialEq
toComponent
trait would allow the filter to check for equality in case version number changed- refactoring
ComponentResourceSet
to use multiple versions (per component), in such caseComponentResourceSet::data_slice_mut<T>
should be in charge of incrementing versions numbers andComponentResourceSet::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.
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.
It seems to be fixed now on master, probably in c99326e
from legion.
Related Issues (20)
- Should maybe_changed always match at least once?
- Failed World::clone_from(), because of missing Duplicate::register_clone(), asserts
- Include license file in legion_codegen crate
- Make `KnownLength` public
- Using systems and scheduler in wasm? HOT 1
- Idiomatic way of removing specific entities HOT 3
- How to apply Filter in #[system] with Query<(Entity, &Component)> HOT 3
- Resources are marked as !Send and !Sync? HOT 2
- Game map questions (Resource vs Entity) HOT 1
- how to remove/stop system? HOT 2
- How to get component/components from a particular entity? HOT 2
- Fallible systems
- Is there way to push entities with dynamic components?
- Query with ordering / sorting?
- Prototype game no longer working in browser after adding legion
- Delete entities based on component? HOT 2
- Is project dead? HOT 2
- Linking legion entities with rapier2d colliders.
- can't build at webassembly
- crossbeam-0.1.6 cannot transmute between types of different sizes, or dependently-sized types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from legion.