I am trying to build an interactive application to render USD models and I have translate/rotate parameters that I want to update in real time.
I apply the transformations to the model like this:
I might be wrong here but Isn’t the Render call just suppose to be setup once in the initialisation face of your program? Perhaps that is the reason it is slow?
I would not recommend calling ClearXformOpOrder and AddTransformOp on every frame update-- that is probably triggering prim resyncs and blowing various caches. Would set up the transformOp once and update just its value.
A simple check to see if you’ve already got a transform op that can be overwritten might also be helpful.
auto op = geom.GetTransformOp();
if (op.GetOpType() != UsdGeomXformOp::TypeTransform) {
geom.ClearXformOpOrder(); // clear the local transform stack
geom.AddTransformOp().Set(localOffset);
}
else {
op.Set(localOffset, tc);
}
Thanks @nporcino - your code helps a little, but still, when I call op.Set(…), the next m_engine->Render(…) takes ~600ms, where it takes less than 1ms otherwise.
I am testing with the Kitchen Set model.
So I guess it invalidates the cache anyway and some recalculation is happening. Will try to check what happens exactly… but will probably need a different way of doing this.
The main reason I am doing this is that I manually add child prim to the model which is a X/Z plane grid. When I apply transforms to the model I want to be able to translate/rotate the model and keep the X/Z grid in place.
Without the grid I could simply modify the camera matrix passed as argument to the Render function.
Perhaps I need to create a separate grid model and render twice with different camera matrices?
Below the result where grid stays in original position/rotation and the Kitchen scene rotated/translated by some arbitrary values.