Closed azrogers closed 8 months ago
Updated review! @csciguy8. This one is pretty hefty. It's now blocked by CesiumGS/cesium-native#797 - the cesium-native implementation of GlobeFlightPath
- as well as #380, which is required to get this project up to date with the latest version of cesium-native. Because of that, it'll probably take a while to get this one merged!
With that being said, I've moved the math behind CesiumFlyToController
onto the cesium-native side so we can take advantage of glm's math functions to get the precision we need. More info about that side of things is in the cesium-native issue linked in the paragraph above. Then there's the glue in the cesium-unity native plugin to connect things up between C++ and Unity.
Speaking of which, I'd like some input from @kring on that part if possible. CeisumGlobeFlightPath
isn't supposed to be constructed directly - you're supposed to go through FromEarthCenteredEarthFixedCoordinates
or FromLongituteLatitudeHeight
. The reason for this is because the creation of the GlobeFlightPath
can fail (if the coordinates couldn't be mapped to the WGS84 geodetic surface) and needs to be able to return an empty value (the C++ side uses std::optional for this). But it doesn't look like Reinterop supports making a non-public constructor for a class, meaning you can happily call new CesiumGlobeFlightPath
and you won't know you've done something wrong until an assertion on the C++ side crashes Unity. How can I solve this? Is there a different paradigm I should use for constructing objects where that construction can fail?
But it doesn't look like Reinterop supports making a non-public constructor for a class, meaning you can happily call new CesiumGlobeFlightPath and you won't know you've done something wrong until an assertion on the C++ side crashes Unity.
Some confusion here I think. Your CesiumGlobeFlightPath
does have a public default constructor. The C# compiler has generated it because you haven't explicitly declared any constructors at all. And because you're using it from ConfigureReinterop.cs
, Reinterop has made it accessible from C++.
If you don't want any public constructors, you need to define a private one (even if it has no implementation). Then the line you added to ConfigureReinterop.cs will be a compiler error, and you'll want to simply remove it. Then I think everything will be working as expected, but let me know if not.
Thanks, Kevin! With that, I was able to make the constructor private and get everything working!
@kring Resolved your comments!
@kring Changed to std::optional
!
Looks great, just one last nitpick! :)
Resolved that last item!
Looks good @azrogers!.
Checked all remaining comments, retested, and a did a sanity check over all the file diffs once more.
Will merge once CI completes...
Fixes #390 and #334.
The
CesiumFlyToController
had a jump at the end of its flight path, similar to the bug in the Unreal plugin. However, the fix that we used for the Unreal plugin couldn't just be dropped in as the way the two implementations work was quite different. This change rewritesCesiumFlyToController
to match the implementation of the Unreal equivalent, fixing the jump bug in the process.