Skip to content

Introduce splatted indicator components#3479

Merged
teh-cmc merged 7 commits intomainfrom
cmc/splatted_indicators
Sep 27, 2023
Merged

Introduce splatted indicator components#3479
teh-cmc merged 7 commits intomainfrom
cmc/splatted_indicators

Conversation

@teh-cmc
Copy link
Copy Markdown
Contributor

@teh-cmc teh-cmc commented Sep 26, 2023

This implements splatted indicator components for all languages, which allows for nicer indicator-component-creation APIs, which in turn allows for some pretty sleek use cases as demo'd in the new manual_indicator example.


rr.log(
    "points_and_mesh",
    [
        rr.Points3D.indicator(),
        rr.Mesh3D.indicator(),
        rr.components.Position3DBatch([[0.0, 0.0, 0.0], [10.0, 0.0, 0.0], [0.0, 10.0, 0.0]]),
        rr.components.ColorBatch([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]),
        rr.components.RadiusBatch([1.0]),
    ],
)
rec.log_component_batches(
    "points_and_mesh",
    false,
    [
        Points3D::indicator().as_ref() as &dyn ComponentBatch,
        Mesh3D::indicator().as_ref(),
        &[[0.0, 0.0, 0.0], [10.0, 0.0, 0.0], [0.0, 10.0, 0.0]].map(Position3D::from),
        &[[255, 0, 0], [0, 255, 0], [0, 0, 255]].map(|[r, g, b]| Color::from_rgb(r, g, b)),
        &[1.0].map(Radius::from),
    ],
)?;
std::vector<rr::components::Position3D> positions = {
    {0.0, 0.0, 0.0},
    {10.0, 0.0, 0.0},
    {0.0, 10.0, 0.0},
};
std::vector<rr::components::Color> colors = {
    {255, 0, 0},
    {0, 255, 0},
    {0, 0, 255},
};
std::vector<rr::components::Radius> radii = {1.0};

rec.log_component_batches(
    "points_and_mesh",
    3,
    rr::Points3D::indicator(),
    rr::Mesh3D::indicator(),
    positions,
    colors,
    radii
);

image (18)


Checklist

@teh-cmc teh-cmc added sdk-python Python logging API sdk-rust Rust logging API 🍏 primitives Relating to Rerun primitives sdk-cpp C/C++ API specific include in changelog labels Sep 26, 2023
@teh-cmc
Copy link
Copy Markdown
Contributor Author

teh-cmc commented Sep 26, 2023

I've went the extra mile in order to make indicators fully static and thus pretty much free in Rust because why not, that's very little extra effort.
Others might or might not want to do something similar in Python & C++ at some point... I'm not going to go into that rabbit hole myself right now 😬

@teh-cmc teh-cmc force-pushed the cmc/splatted_indicators branch from 2fe3828 to 95f65b3 Compare September 26, 2023 14:49
@jleibs jleibs self-requested a review September 26, 2023 15:04
}

// Only re-build if source-hash exists
if !Path::new(SOURCE_HASH_PATH).exists() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't this change already land in another PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.. not sure how that still generates a diff :| will prob disappear once I rebase eh

cpp_includes.insert_rerun("indicator_component.hpp");

Method {
docs: "Creates an `AnonymousComponentBatch` out of the associated indicator component. \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't anonymous if it has an indicator, is it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean. Anonymous is what the cpp SDK calls an erased ComponentBatch.

Are you saying you'd like this to return a non-erased ComponentBatch, or just that the Anonymous prefix sounds weird?

return "rerun.archetypes." + type(self).__name__
@classmethod
def archetype_name(cls) -> str:
return "rerun.archetypes." + cls.__name__
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: I ran into an issue earlier where subclassing an archetype causes this to have unexpected behavior. We can file as a separate issue though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't a classmethod until this PR, it was a plain one... that might be why you had a bad surprise earlier?

@teh-cmc teh-cmc mentioned this pull request Sep 26, 2023
3 tasks
@teh-cmc teh-cmc force-pushed the cmc/splatted_indicators branch from 95f65b3 to 871eb8c Compare September 27, 2023 07:39
@teh-cmc teh-cmc merged commit 19c8d14 into main Sep 27, 2023
@teh-cmc teh-cmc deleted the cmc/splatted_indicators branch September 27, 2023 08:05
teh-cmc added a commit that referenced this pull request Sep 27, 2023
Implement new `AsComponents` trait, which is now in charge of all the
data/batch serialization management.
This makes it easier to work with custom data: see the updated example
of the same name.

Also stop generating `try_to_arrow` while we're at it.

- Fixes #3383
- Fixes #3386 
- Requires #3479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

include in changelog 🍏 primitives Relating to Rerun primitives sdk-cpp C/C++ API specific sdk-python Python logging API sdk-rust Rust logging API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make rr.Points3D.indicator possible

2 participants