Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearing entities with transforms leaves an identity transform behind #7729

Open
stonier opened this issue Oct 14, 2024 · 3 comments
Open

Clearing entities with transforms leaves an identity transform behind #7729

stonier opened this issue Oct 14, 2024 · 3 comments
Labels
😤 annoying Something in the UI / SDK is annoying to use 🟦 blueprint The data that defines our UI 🪳 bug Something isn't working heuristics Space-view heuristics etc

Comments

@stonier
Copy link

stonier commented Oct 14, 2024

Describe the bug

Everything seems to be working as documented, i.e.

  • Clear - empties all components of an entity
  • Spaces & Transforms - unless otherwise specified, every path is trivially connected to it's parent by the identity transform

However, it's the combination of the two when a non-identity transform is logged to an entity. It gets first cleared, and then reactivated as the identity keyframe which is subsequently visualized at the origin.

This can cause spurious transforms to appear in the 3D view, it can also cause rerun to excessively zoom out if entities are all far from the origin to compensate for the one re-registered at the world origin.

To Reproduce

  1. Log a transform under an entity name, e.g. recording_stream.log("/bob", &transform);
    (transform must not be the identity)
  2. Clear the entity, e.g. recording_stream.log("\bob", &rerun::Clear::recursive());
  3. View the replay - the original transform keyframe is replaced by an identity transform keyframe at the origin

Expected behavior

The transform is not restored (and thus not re-visualized).

Desktop (please complete the following information):

  • OS: Ubuntu 24.04

Rerun version
0.18.2

@stonier stonier added 👀 needs triage This issue needs to be triaged by the Rerun team 🪳 bug Something isn't working labels Oct 14, 2024
@stonier
Copy link
Author

stonier commented Oct 15, 2024

A reproduceable program:

use rerun as rr;

fn generate_transform(x: f32) -> rr::Transform3D {
    rr::Transform3D::from_translation_rotation(
        rr::Vec3D::new(x, 0.0, 0.0),
        rr::Quaternion::IDENTITY,
    )
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (stream, storage) = rr::RecordingStreamBuilder::new("Clear").memory()?;
    let t_3 = generate_transform(3.0);
    let t_5 = generate_transform(5.0);
    let t_6 = generate_transform(6.0);
    stream.set_time_seconds("sim_time", 0.0);
    stream.log("/foo", &t_3)?;
    stream.log("/bar", &t_5)?;
    stream.set_time_seconds("sim_time", 1.0);
    stream.log("/foo", &t_3)?;
    stream.log("/bar", &t_6)?;
    stream.set_time_seconds("sim_time", 2.0);
    stream.log("/foo", &t_3)?;
    stream.log("/bar", &rerun::Clear::flat())?; // <-- sends the visual 3d axes back to the origin
    rr::native_viewer::show(storage.take())?;
    Ok(())
}

@Nikita240
Copy link

Here is a workaround for now:

use rerun as rr;

fn generate_transform(x: f32) -> rr::Transform3D {
    rr::Transform3D::from_translation_rotation(
        rr::Vec3D::new(x, 0.0, 0.0),
        rr::Quaternion::IDENTITY,
    )
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (stream, storage) = rr::RecordingStreamBuilder::new("Clear").memory()?;
    let t_3 = generate_transform(3.0);
    let t_5 = generate_transform(5.0);
    let t_6 = generate_transform(6.0);
    stream.set_time_seconds("sim_time", 0.0);
    stream.log("/foo", &t_3)?;
    stream.log("/bar", &t_5)?;
    stream.set_time_seconds("sim_time", 1.0);
    stream.log("/foo", &t_3)?;
    stream.log("/bar", &t_6)?;
    stream.set_time_seconds("sim_time", 2.0);
    stream.log("/foo", &t_3)?;
    stream.log("/bar", &rerun::Clear::flat())?; // <-- sends the visual 3d axes back to the origin
    stream.log("/bar", &rr::Transform3D::clear().with_axis_length(0.0))?; // <-- workaround
    rr::native_viewer::show(storage.take())?;
    Ok(())
}

@stonier
Copy link
Author

stonier commented Oct 15, 2024

Aye, started with that workaround, but going two steps further...

Step 1: Use that zero'd axis length to make them vanish (easy)

but ... if entities are far from the origin, rerun zooms out excessively to try and fit in a transform that has been sent to the origin

Step 2: Reset the transform with the last transform (more of a pain)

but ... none of this handles transforms that have been cleared for sub-entities when using recursive

Step 3: Reset the transforms of all subentities with their last transforms (can be too difficult to be worth chasing)

@Wumpf Wumpf added 😤 annoying Something in the UI / SDK is annoying to use 🟦 blueprint The data that defines our UI heuristics Space-view heuristics etc and removed 👀 needs triage This issue needs to be triaged by the Rerun team labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😤 annoying Something in the UI / SDK is annoying to use 🟦 blueprint The data that defines our UI 🪳 bug Something isn't working heuristics Space-view heuristics etc
Projects
None yet
Development

No branches or pull requests

3 participants