-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented with the help of @Wumpf. This semantically mimics very closely the way things are done in Rust, minus all technical differences due to the differences between both the languages and the SDKs. For that reason, everything stated in #8304 (comment) basically applies as-is. Pretty happy about it, I must say. * DNM: requires #8304 * Part of #7948 --------- Co-authored-by: Andreas Reich <[email protected]>
- Loading branch information
Showing
272 changed files
with
3,154 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <rerun.hpp> | ||
|
||
int main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_descriptors_builtin_archetype"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
rec.log_static("data", rerun::Points3D({{1.0f, 2.0f, 3.0f}}).with_radii({0.3f, 0.2f, 0.1f})); | ||
|
||
// The tags are indirectly checked by the Rust version (have a look over there for more info). | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <rerun.hpp> | ||
|
||
int main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_descriptors_builtin_component"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
rerun::Position3D positions[1] = {{1.0f, 2.0f, 3.0f}}; | ||
rec.log_static("data", positions); | ||
|
||
// The tags are indirectly checked by the Rust version (have a look over there for more info). | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <rerun.hpp> | ||
#include <vector> | ||
|
||
struct CustomPosition3D { | ||
rerun::components::Position3D position; | ||
}; | ||
|
||
template <> | ||
struct rerun::Loggable<CustomPosition3D> { | ||
static constexpr ComponentDescriptor Descriptor = "user.CustomPosition3D"; | ||
|
||
static const std::shared_ptr<arrow::DataType>& arrow_datatype() { | ||
return rerun::Loggable<rerun::components::Position3D>::arrow_datatype(); | ||
} | ||
|
||
// TODO(#4257) should take a rerun::Collection instead of pointer and size. | ||
static rerun::Result<std::shared_ptr<arrow::Array>> to_arrow( | ||
const CustomPosition3D* instances, size_t num_instances | ||
) { | ||
return rerun::Loggable<rerun::components::Position3D>::to_arrow( | ||
reinterpret_cast<const rerun::components::Position3D*>(instances), | ||
num_instances | ||
); | ||
} | ||
}; | ||
|
||
/// A custom archetype that extends Rerun's builtin `rerun::Points3D` archetype with a custom component. | ||
struct CustomPoints3D { | ||
static constexpr const char IndicatorComponentName[] = "user.CustomPoints3DIndicator"; | ||
using IndicatorComponent = rerun::components::IndicatorComponent<IndicatorComponentName>; | ||
|
||
rerun::Collection<CustomPosition3D> positions; | ||
std::optional<rerun::Collection<rerun::Color>> colors; | ||
}; | ||
|
||
template <> | ||
struct rerun::AsComponents<CustomPoints3D> { | ||
static Result<std::vector<ComponentBatch>> serialize(const CustomPoints3D& archetype) { | ||
std::vector<rerun::ComponentBatch> batches; | ||
|
||
CustomPoints3D::IndicatorComponent indicator; | ||
batches.push_back(ComponentBatch::from_loggable(indicator).value_or_throw()); | ||
|
||
auto positions_descr = rerun::Loggable<CustomPosition3D>::Descriptor | ||
.or_with_archetype_name("user.CustomPoints3D") | ||
.or_with_archetype_field_name("custom_positions"); | ||
batches.push_back( | ||
ComponentBatch::from_loggable(archetype.positions, positions_descr).value_or_throw() | ||
); | ||
|
||
if (archetype.colors) { | ||
auto colors_descr = rerun::Loggable<rerun::Color>::Descriptor | ||
.or_with_archetype_name("user.CustomPoints3D") | ||
.or_with_archetype_field_name("colors"); | ||
batches.push_back( | ||
ComponentBatch::from_loggable(archetype.colors, colors_descr).value_or_throw() | ||
); | ||
} | ||
|
||
return batches; | ||
} | ||
}; | ||
|
||
int main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_descriptors_custom_archetype"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
CustomPosition3D positions[1] = {{rerun::components::Position3D{1.0f, 2.0f, 3.0f}}}; | ||
rerun::Color colors[1] = {rerun::Color(0xFF00FFFF)}; | ||
|
||
rec.log_static("data", CustomPoints3D{positions, colors}); | ||
|
||
// The tags are indirectly checked by the Rust version (have a look over there for more info). | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <rerun.hpp> | ||
|
||
struct CustomPosition3D { | ||
rerun::components::Position3D position; | ||
}; | ||
|
||
template <> | ||
struct rerun::Loggable<CustomPosition3D> { | ||
static constexpr const ComponentDescriptor Descriptor = | ||
ComponentDescriptor("user.CustomArchetype", "custom_positions", "user.CustomPosition3D"); | ||
|
||
static const std::shared_ptr<arrow::DataType>& arrow_datatype() { | ||
return rerun::Loggable<rerun::components::Position3D>::arrow_datatype(); | ||
} | ||
|
||
// TODO(#4257) should take a rerun::Collection instead of pointer and size. | ||
static rerun::Result<std::shared_ptr<arrow::Array>> to_arrow( | ||
const CustomPosition3D* instances, size_t num_instances | ||
) { | ||
return rerun::Loggable<rerun::components::Position3D>::to_arrow( | ||
reinterpret_cast<const rerun::components::Position3D*>(instances), | ||
num_instances | ||
); | ||
} | ||
}; | ||
|
||
int main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_descriptors_custom_component"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
CustomPosition3D positions[1] = {{rerun::components::Position3D{1.0f, 2.0f, 3.0f}}}; | ||
rec.log_static("data", positions); | ||
|
||
// The tags are indirectly checked by the Rust version (have a look over there for more info). | ||
} |
Oops, something went wrong.