Code Monkey home page Code Monkey logo

Comments (4)

distransient avatar distransient commented on May 26, 2024

Hey! Just pinging to say thanks for opening the issue. I'm gonna see if I could investigate this sometime soon.

Main reason why the description warns people to not use the repository is because it currently has git hash dependencies still (and probably more bugs like this). I think it's not too far off a 0.1.0 release, however. At which point I'll probably remove that warning.

from nphysics-ecs-dumb.

dylemma avatar dylemma commented on May 26, 2024

I'm glad to hear back!

If it's any help, I tried two approaches to fix this in my toy app.

  • Write my own Storage trait for types that are Event + Clone and have it send a clone of any value that gets removed as an event to its EventChannel. I ended up getting stuck trying to add subscribers to it in my System implementation... I think this change would have to be implemented in specs, but I could be wrong there... I still consider myself a Rust noob.
  • Set up a kind of reference loop between the Entity/Storage layer and the CollisionWorld.
    • Have CollisionObjects in the CollisionWorld hold an Option<Entity> in their data field, which is initially None.
    • A Collider component holds a CollisionObjectHandle, which you get while constructing the CollisionObject.
    • Use FlaggedStorage for the Collider so we can see when new colliders are added/removed.
    • In the SyncCollisionWorld system, iterate the entity ids that were added to the collider storage. Follow the entity.id --> Entity --> Collider --> CollisionObjectHandle --> CollisionObject chain of references to get a mutable reference to the new CollisionObject. Set its Option<Entity> to Some(entity).
    • Collect removed entity ids from the collider storage into a BitSet. Iterate over the CollisionObjects in the CollisionWorld. If that CollisionObject's Option<Entity> has an id() that was in the BitSet, mark that object to be removed, and remove all of the marked objects after iterating.

The second approach seems to work, but it feels dirty and somewhat unextensible. That said, it might solve the issue here, which is that there's currently no way to get back to the Entities for a collision. Nevermind, now that I poked around more in your source I think you already solved that.

from nphysics-ecs-dumb.

dylemma avatar dylemma commented on May 26, 2024

I put some more time in and figured out how to make my first approach work. I made a DetailedComponentEvent<E> enum that's basically the same as ComponentEvent but where the removal includes an E value. Here's my implementation: https://github.com/dylemma/Falldown.rs/blob/master/src/storage/mod.rs

from nphysics-ecs-dumb.

distransient avatar distransient commented on May 26, 2024

The custom storage part is interesting to me. This problem of synchronization between libraries that force all data into World-like instances and an ECS application is truly frustrating and error prone. It feels like every line of code has a bit of interconnected state in it that's bound to blow up somehow that's completely impossible to test for.

from nphysics-ecs-dumb.

Related Issues (8)

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.