-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Large refactor of the C++ code #626
Conversation
When I write a mega-change like this, I try to break it up after the fact into commits that could at least compile and might even work. I'm a fan of the workflow described in https://git-scm.com/docs/git-stash#Documentation/git-stash.txt-Testingpartialcommits
I have no idea if it is practical to do this for this commit, or even a good use of time, so this is just a noob suggestion! |
Thanks for the suggestion @timoore. It could be tricky to detangle things at this point, but I agree with everything you said. I haven't tried that specific workflow but I'll give it a shot the next time this happens (which hopefully won't be very often). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by review
|
||
namespace cesium::omniverse::CppUtil { | ||
|
||
template <typename T, typename L, uint64_t... I> const auto& dispatchImpl(std::index_sequence<I...>, L lambda) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty hairy stuff. I think that you are calling a lambda or other function on a list of arbitrary types, and returning the results in an array?
Someday you are going to regret returning a static array 🥲 I think you could use std:array here and return it safely. https://stackoverflow.com/questions/12024304/c11-number-of-variadic-template-function-parameters getting the length.
I don't think the type of the lambda needs to be a template argument. You could write auto&& lambda
instead.
Perhaps this is all bikeshedding; I don't see where you're using this function in your PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I borrowed this solution from stack overflow, but I can't seem to find the post right now...
This function is called by CALL_TEMPLATED_FUNCTION_WITH_RUNTIME_DATA_TYPE
and related macros. When used in that context, dispatchImpl
returns an array storing function pointers for all enumerations, and dispatch
calls the function for the given enumeration.
I had tried to switch to std::array
before, and thought I was using sizeof...(I)
correctly, but got blocked by something. I just tried it again and it worked🤷♂️. I pushed the change: 61f2698
I did just try auto&& lambda
, but that only seems possible with C++ 20.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is called by
CALL_TEMPLATED_FUNCTION_WITH_RUNTIME_DATA_TYPE
and related macros. When used in that context,dispatchImpl
returns an array storing function pointers for all enumerations, anddispatch
calls the function for the given enumeration.
Ah, OK. I searched for uses of dispatch() but didn't realize that dispatchImpl is actually the one used.
I had tried to switch to
std::array
before, and thought I was usingsizeof...(I)
correctly, but got blocked by something. I just tried it again and it worked🤷♂️. I pushed the change: 61f2698I did just try
auto&& lambda
, but that only seems possible with C++ 20.
My bad, that only works in lambda argument lists pre C++20.
|
||
#include <optional> | ||
|
||
#ifdef CESIUM_OMNI_MSVC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine that this nugget of joy is dealt with in every Cesium program that uses cesium-native. I wonder if there's a way to deal with it there, or at least come up with a standard idiom for killing the OPAQUE macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened a cesium-native PR for that: CesiumGS/cesium-native#796
exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi
Show resolved
Hide resolved
This isn't related to this PR, but it is making me ask the question of if there's a better approach than having a |
…und for old files in Context.cpp
There's an issue in this branch that doesn't reproduce in
|
I disabled building tests on CI - I was seeing linker errors that I couldn't reproduce locally and don't really have the energy to figure out. The test infrastructure needs to be rethought in order to be CI compatible.
|
@corybarr I don't think I can get to the sign out issue in this PR, though I would like to address it before the release. I'm marking the PR as non-draft now. I think I've tested as much as I can and it would be good to get this finally merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This codebase feels considerable more manageable now.
Fixes #539
Fixes #584
Fixes #600
Fixes #588
Fixes #616
This is a wide reaching cleanup PR that has both functional changes and C++ style changes. Ideally this would have been spit into multiple PRs, but here we are 🤕
Globe Anchors
Python <-> C++
syncing issues have been fixed and globe anchors can now be defined directly in USD at the Python layer.cesium:transform
op to the attached prim. Instead they modify thetranslate
,rotate
(all variants), andscale
ops directly.Asset Registry
Omni
class. AllOmni
objects are stored in and accessed fromAssetRegistry
. A lot of time was spent making sureUsdNotificationHandler
was accurately updatingAssetRegistry
and the variousOmni
classes.OmniPolygonImagery
andOmniIonImagery
now own the underlying cesium-native raster overlay object. This will allow multiple tilesets to use the same imagery resource once Userel
for imagery layers #585 is implemented.GlobeAnchorRegistry
andSessonRegistry
have been consolidated intoAssetRegistry
Context
Context
.Context
objects can now be created, if desired, such as in unit testsCesiumIonServerManager
. I hoped to do more refactoring in this PR but ran out of time.File changes
CppUtil
for various C++ or standard library related helper functionsFabric***Definition
toFabric***Descriptor
Fabric
structsStyle changes
++i
instead ofi++
for the slight performance gain and to match cesium-native conventionsconst
more frequently***Util.h
files are now scoped in sub namespaces ofcesium::omniverse
p
prefix to pointers, similar to cesium-native stylesrw
andisrw
tofabricStage
andiFabricStage
std::string_view
instead ofconst char*
in certain placespxr::
->PXR_NS::
which is more consistent with other projects likekit-extension-template-cpp
clang-tidy
but there are still a few remainingOther changes
/Cesium
or/CesiumGeoreference
prims aren't defined orrel
's are emptyoneTimeWarning
, which fixes #588FabricTexture
to handle more channels and bit depths, which fixes #616CesiumOmniverse.h
no longer depends onGfMatrix4d
. This is one step closer towards towards C API #3Usd::Gf
math.glm
is used almost everywhere now.