-
Notifications
You must be signed in to change notification settings - Fork 203
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
Instance import, part 1 #794
Conversation
…instances # Conflicts: # lib/mayaUsd/fileio/jobs/jobArgs.cpp # lib/mayaUsd/fileio/jobs/jobArgs.h # lib/mayaUsd/fileio/jobs/readJob.cpp # lib/mayaUsd/fileio/jobs/readJob.h # plugin/pxr/maya/lib/usdMaya/importCommand.cpp
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 think I'll have to defer to @pmolodo for the final approval since he's much more knowledgable on this subject than I am, but it generally looks good to me. I had just a few mostly minor notes.
const UsdPrimRange range = UsdPrimRange::PreAndPostVisit(rootPrim); | ||
_PrimReaderMap primReaderMap; | ||
const UsdPrimRange range = | ||
mArgs.instanceMode == UsdMayaJobImportArgsTokens->flatten ? |
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.
Do we expect that there might some day be more instanceMode
options, or could this equality be replaced with buildInstances
from above?
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.
Not sure about that one. With the current code, using instanceMode=anything_but_flatten_or_build
would end up not loading any instance, which was the old behavior before this patch.
Is that a valid mode that should be preserved in the Import options? I would call it "ignore"...
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.
No, I don't think it makes sense to preserve the behavior where instances in USD are ignored. If I'm reading the changes in jobArgs.cpp correctly, I think we'll fallback to building instances if instanceMode was given something bogus?
My main thought here was just whether we could re-use the buildInstances
boolean from above. No big deal though.
test/lib/usd/translators/UsdImportInstancesTest/ComplexScenario_optimized.usda
Outdated
Show resolved
Hide resolved
test/lib/usd/translators/UsdImportInstancesTest/ComplexScenario_unoptimized.usda
Outdated
Show resolved
Hide resolved
test/lib/usd/translators/UsdImportInstancesTest/ComplexScenario_unoptimized.usda
Outdated
Show resolved
Hide resolved
pCube1_pCubeShape1 [Scope] | ||
pCubeShape1 [Mesh] | ||
|
||
The goal would be for Maya to skip all [Scope] items and end up with: |
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.
Ahh... so maybe this explains the missing type names in the USD above. Prims with the Scope
type name are different from the typeless prims we have at the moment though. Do we really mean Scope
here and we should add that type name above, or should this read typeless here instead?
primPath="/", | ||
instanceMode="buildInstances") |
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 think this setting of primPath
can be removed, since that should be the default? Similarly, instanceMode=buildInstances
looks like it was made the default as well, but I'm ok with that staying since I think it makes the intent of the test clear.
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.
Isn't primPath the defaultPrim
, which would be pCube1 in the test scenes?
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.
So, I don't have too much additional to add to what @mattyjams said - mostly looks good.
My one concern is that, if we do release as is, and later want to support "cleaning up" the "extra" Scope args, it will obviously change the resulting maya scene. If we release this as is, people may become dependent on the behavior implemented in this PR... and I'd hate to lock us into having the unnecessary xforms. Are we ok with making a potentially breaking change to eliminate them in the future?
} | ||
} | ||
|
||
over "InstanceSources" |
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 think Prototypes would be bad too, because in the latest updates to USD, they're replacing "master" with "Prototype". (Which is going to require a some API changes here, but there's already post-20.08-incompatibilities in the existing maya_usd codebase, so we can punt on that for now).
And if we can't use Prototypes... then I might prefer the current InstanceSources
over something which is essentially generic, like InstanceModels
or InstanceAssets
. I see where you're coming from, but:
sources
is NOT the same term as the "official" term (which wasmasters
, and is nowprototypes
)- conceptually they DO convey something similar... but the basic problem is that what we're trying to do IS something conceptually similar to what the "official" USD-created masters do. So it's a bit of a catch 22 - any name that accurately describes or invokes what the purpose here is automatically going to be treading pretty close to "masters"/"prototypes". So I'd rather go with the option that has some descriptive value, as long as it avoids the "official" term.
@mattyjams , would it help if it were named something more maya-centric, like say, MayaExportedInstanceSources
? If we eventually want to implement special behavior for prims located here (which we will, if we ever do the eliminate-Scopes thing later), then it would be good to have it named a bit less generically, anyway.
test/lib/usd/translators/UsdImportInstancesTest/ComplexScenario_optimized.usda
Outdated
Show resolved
Hide resolved
Also investigated and fixed a few asserts poppping up in the test suite.
…instances # Conflicts: # lib/mayaUsd/fileio/jobs/jobArgs.cpp # lib/mayaUsd/fileio/jobs/jobArgs.h
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.
Looks good to me. I'd still like to change the name of "InstanceSources" to be more maya-specific, but I suppose we can make that a separate PR if you'd prefer.
if (status) { | ||
while (masterNode.childCount()) { | ||
masterNode.removeChildAt(masterNode.childCount() - 1); | ||
} |
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.
Is there some sort of error or something that happens if you don't remove the children before deleting the parent? Since these child removals aren't done via a MDGModifier, will this undo properly? (Though - not sure if the the import command as a whole is even undoable...)
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.
With the special builds we use, we get asserts about incorrect children counts on file->new because the instance count and children count differ. It is not something you will see with a shipped Maya cut.
} | ||
} | ||
|
||
over "InstanceSources" |
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.
Yeah, I think it would, but I don't think it should be a problem to change it there too...
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.
Looks good to me!
const UsdPrimRange range = UsdPrimRange::PreAndPostVisit(rootPrim); | ||
_PrimReaderMap primReaderMap; | ||
const UsdPrimRange range = | ||
mArgs.instanceMode == UsdMayaJobImportArgsTokens->flatten ? |
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.
No, I don't think it makes sense to preserve the behavior where instances in USD are ignored. If I'm reading the changes in jobArgs.cpp correctly, I think we'll fallback to building instances if instanceMode was given something bogus?
My main thought here was just whether we could re-use the buildInstances
boolean from above. No big deal though.
upAxis = "Y" | ||
) | ||
|
||
def Xform "pCube1" ( |
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.
One small nit-pick with the type names here, but it looks like we ended up with type names everywhere. I would think the majority of the time when you have a prim referencing other prims, you likely want a typeless def for the prim doing the referencing. I think in most cases below, the type names between the referencer and the referenced agree, so I don't think it's a practical issue here. Typeless defs let the type of the referenced prim shine through to the referencer whatever that type may be, so you don't have to match the types yourself. Specifying a different type on the referencer will actually change the type of the composed prim, which is pretty rarely what you intend.
Brings in the original @sirpalee / @pmolodo instancing code from the following Luma branch.
This code adds an Instance Mode option on import to either build instances or flatten the scene.
Updates:
Bug fixes:
Fixes #340, fixes #723, fixes #310
Still todo:
The following issues have been found and will likely be fixed in a follow-up update: