Skip to content

C++ serialization support for most nested types, transform3d roundtrip test#2937

Merged
Wumpf merged 18 commits intomainfrom
andreas/cpp/union-support
Aug 9, 2023
Merged

C++ serialization support for most nested types, transform3d roundtrip test#2937
Wumpf merged 18 commits intomainfrom
andreas/cpp/union-support

Conversation

@Wumpf
Copy link
Copy Markdown
Member

@Wumpf Wumpf commented Aug 8, 2023

Part of:

What

Major facelift of the C++ codegen as it got restructured to support more support more nested kind of serialization and moved away entirely from using the arrow type registry at all (this happened originally due to c&p from Rust without understanding the details; this change makes a lot of the code a lot simpler!)

In order to test the new nested serialization this also enables the transform 3d roundtrip test which required adding some extensions on various datatypes to make the test code readable.
These are not the transform related final extensions. More is under way in a future PR to make transform usable.

The resulting transforms can't yet be loaded in the viewer due to #2871

The only remaining cases that don't produce (presumably until tested) correct serialization now are:

  • nullable component/datatype inside a transparent component/datatype
  • lists/vectors inside as a union variant

(they are not particularly hard to solve, just left out of this PR)

Checklist

@Wumpf Wumpf added codegen/idl sdk-cpp C/C++ API specific labels Aug 8, 2023
@Wumpf Wumpf force-pushed the andreas/cpp/union-support branch from 80aa047 to 85a5fca Compare August 8, 2023 11:25
@Wumpf Wumpf changed the title C++ serialization support most forms of nested classes, transform3d roundtrip test C++ serialization support for most forms of nested types, transform3d roundtrip test Aug 8, 2023
@Wumpf Wumpf changed the title C++ serialization support for most forms of nested types, transform3d roundtrip test C++ serialization support for most nested types, transform3d roundtrip test Aug 8, 2023
@teh-cmc teh-cmc self-requested a review August 9, 2023 07:02
@Wumpf Wumpf force-pushed the andreas/cpp/union-support branch from 9ac33f0 to 088e540 Compare August 9, 2023 07:48
@Wumpf Wumpf merged commit b3689d9 into main Aug 9, 2023
@Wumpf Wumpf deleted the andreas/cpp/union-support branch August 9, 2023 08:02
Wumpf added a commit that referenced this pull request Aug 9, 2023
### What

* depends on #2937
* part of #2919 
* fixes #2791

Roundtrip test is part of #2937
Does not yet work in viewer because of
#2871

C++ extensions now get additional includes copied into the generated
header

Extensions circle around making use of the `Transform3D` archetype easy.
Note that the willingness of a c++ compiler to convert arrays and floats
to bool causes us quite a lot of extra overloads (luckily the added unit
tests catches these and there are warnings emitted).
The amount of overloads introduced leaves a bit of a bad taste, but the
expectation is that this is rather special to `Transform3D`. Some of the
provided overloads may be generated in the future if a pattern emerges.

A bunch of code example added to demonstrate what it looks like now to
use Transform3D:
```cpp
// translation only
rr_stream.log("translated", rr::artchetypes::Transform3D({1.0f, 0.0f, 0.0f}));

// translation/rotation/uniform-scale
rr_stream.log(
    "rotated_scaled",
    rr::archetypes::Transform3D(
        rrd::RotationAxisAngle({0.0f, 0.0f, 1.0f}, rrd::Angle::radians(pi / 4.0f)),
        2.0f
    )
);

// 3x3 matrix
rec_stream.log(
    "translation_and_mat3x3/rotation",
    rr::archetypes::Transform3D({
        {1.0f, 4.0f, 7.0f},
        {2.0f, 5.0f, 8.0f},
        {3.0f, 6.0f, 9.0f},
    })
);
```

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2940) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2940)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp%2Ftransform3d/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp%2Ftransform3d/examples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen/idl sdk-cpp C/C++ API specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants