Skip to content

Conversation

@danieldresser-ie
Copy link
Contributor

A quick attempt at implementing the approach I discussed with John today.

I initially did actually try to make the hashes more consistent using a map that assigned 0 to the first time a fileName is opened - but then I realized that we use SdfPath's hashes all over the place, so none of the hashes are consistent anyway, so it really makes more sense to just use a global counter.

It seems like in addition to resolving the issue with prototype names swapping around, this also means that it's now OK to use SdfPath::Hash() as we currently are - it seems like SdfPaths are reliably consistent for the lifespan of a USD file. This is based on two observations:

  • if this wasn't true, then everything would currently be broken
  • a cursory reading of CrateFile::_ReadPaths seems to suggest that the CrateFile does keep all the contained SdfPaths alive


// Used to identify a file uniquely ( including between different openings of the same filename,
// since closing and reopening a file may cause USD to shuffle the contents ).
const int m_uniqueId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why store copies of this redundantly in the one-per-location USDScene class? Why not just store it next to the filename in the one-per-stage IO object?


self.assertNotEqual( h1, h2 )

self.assertFalse( h1 in usedHashes )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a small thing, but assertNotIn() gives more informative error messages than assertFalse().

self.assertEqual( h1, instanceJ.child( "world" ).hash( scene.HashType.TransformHash, 1 ) )
del instanceJ

self.assertFalse( h2 in usedHashes )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

… identical USDScenes

This is intentionally no longer true - it was the easiest way to account for USD shuffling scenes when
reopening them. Users should avoid opening the same file multiple times.
@danieldresser-ie
Copy link
Contributor Author

Addressed feedback. I also addressed a problem that I had planned to mention yesterday, and forgot: there was one assert in testSetHashes which tested that two different USDScenes opened from the same file had the same hashes. Since it is now our intention that this not be true, I've just removed that failing assert.

@johnhaddon johnhaddon merged commit 531e5c8 into ImageEngine:RB-10.4 Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants