chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:05:14 +08:00
commit 2a547be7fe
7904 changed files with 1000926 additions and 0 deletions
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.16...3.27)
# If you use the example outside of the Rerun SDK you need to specify
# where the rerun_c build is to be found by setting the `RERUN_CPP_URL` variable.
# This can be done by passing `-DRERUN_CPP_URL=<path to rerun_sdk_cpp zip>` to cmake.
if(DEFINED RERUN_REPOSITORY)
add_executable(example_incremental_logging main.cpp)
rerun_strict_warning_settings(example_incremental_logging)
else()
project(example_incremental_logging LANGUAGES CXX)
add_executable(example_incremental_logging main.cpp)
# Set the path to the rerun_c build.
set(RERUN_CPP_URL "https://github.com/rerun-io/rerun/releases/latest/download/rerun_cpp_sdk.zip" CACHE STRING "URL to the rerun_cpp zip.")
# Download the rerun_sdk
include(FetchContent)
FetchContent_Declare(rerun_sdk URL ${RERUN_CPP_URL})
FetchContent_MakeAvailable(rerun_sdk)
endif()
# Link against rerun_sdk.
target_link_libraries(example_incremental_logging PRIVATE rerun_sdk)
@@ -0,0 +1,26 @@
<!--[metadata]
title = "Incremental logging"
tags = ["3D", "API Example"]
thumbnail = "https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/480w.png"
thumbnail_dimensions = [480, 301]
-->
Showcases how to incrementally log data belonging to the same archetype, and re-use some or all of it across frames.
<picture>
<img src="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/full.png" alt="">
<source media="(max-width: 480px)" srcset="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/incremental_logging/b7a2bd889b09c3840f56dc31bd6d677934ab3126/1200w.png">
</picture>
## Run the code
To build it from a checkout of the repository (requires a Rust toolchain):
```bash
cmake .
cmake --build . --target example_incremental_logging
./examples/cpp/incremental/example_incremental_logging
```
+72
View File
@@ -0,0 +1,72 @@
// Showcase how to incrementally log data belonging to the same archetype, and re-use some or all
// of it across frames.
#include <rerun.hpp>
#include <algorithm>
#include <random>
static const char* README = R"(
# Incremental Logging
This example showcases how to incrementally log data belonging to the same archetype, and re-use some or all of it across frames.
It was logged with the following code:
```cpp
std::vector<rerun::Color> colors(10, rerun::Color(255, 0, 0));
std::vector<rerun::Radius> radii(10, rerun::Radius(0.1f));
// Only log colors and radii once.
rec.set_time_sequence("frame_nr", 0);
rec.log("points", colors, radii);
std::default_random_engine gen;
std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f);
// Then log only the points themselves each frame.
//
// They will automatically re-use the colors and radii logged at the beginning.
for (int i = 0; i < 10; ++i) {
rec.set_time_sequence("frame_nr", i);
std::vector<rerun::Position3D> points(10);
std::generate(points.begin(), points.end(), [&] {
return rerun::Position3D(dist_pos(gen), dist_pos(gen), dist_pos(gen));
});
rec.log("points", rerun::Points3D(points));
}
```
Move the time cursor around, and notice how the colors and radii from frame 0 are still picked up by later frames, while the points themselves keep changing every frame.
)";
int main() {
const auto rec = rerun::RecordingStream("rerun_example_incremental_logging");
rec.spawn().exit_on_failure();
rec.log_static(
"readme",
rerun::TextDocument(README).with_media_type(rerun::components::MediaType::markdown())
);
// Only log colors and radii once.
// Logging statically with `RecordingStream::log_static` would also work.
rec.set_time_sequence("frame_nr", 0);
rec.log("points", rerun::Points3D().with_colors(rerun::Color(255, 0, 0)).with_radii(0.1f));
std::default_random_engine gen;
std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f);
// Then log only the points themselves each frame.
//
// They will automatically re-use the colors and radii logged at the beginning.
for (int i = 0; i < 10; ++i) {
rec.set_time_sequence("frame_nr", i);
std::vector<rerun::Position3D> points(10);
std::generate(points.begin(), points.end(), [&] {
return rerun::Position3D(dist_pos(gen), dist_pos(gen), dist_pos(gen));
});
rec.log("points", rerun::Points3D::update_fields().with_positions(points));
}
}