8000 Tracking objects with `RenderID` · Issue #94 · ricosjp/truck · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Tracking objects with RenderID #94
Open
@tymokvo

Description

@tymokvo

Hello,

I am trying to implement modifications to objects already in a Scene. The simplest example is the ability to delete a PolygonInstance after it has been added to a scene.

The Scene::remove_object requires a pointer to the entire T: Rendered rather than a RenderID, even though it simply references the object by id for removal from the Scene::objects member. Is it necessary to keep a pointer to the T: Rendered object in order to implement this behavior?

This is a bit onerous as it requires propagating lifetimes to maintain the collection of pointers, e.g. my_objects: HashMap<String, &'a PolygonInstance>. I understand I may be missing something about how these are used to synchronize data with the GPU, though.

/// Removes a render object from the scene.
///
/// If there does not exist the render object in the scene, does nothing and returns `false`.
#[inline(always)]
pub fn remove_object<R: Rendered>(&mut self, object: &R) -> bool {
self.objects.remove(&object.render_id()).is_some()
}

Would it be reasonable to add a Scene::remove_object_by_id member? I would be happy to open a PR if the change makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0