-
Notifications
You must be signed in to change notification settings - Fork 125
CoordinateSystem: Backwards compatibility - Read legacy transform #1504
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
base: RB-10.6
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,8 +34,12 @@ | |
|
|
||
| #include "IECoreScene/CoordinateSystem.h" | ||
|
|
||
| #include "IECore/SimpleTypedData.h" | ||
| #include "IECore/MurmurHash.h" | ||
|
|
||
| #include "Imath/ImathMatrix.h" | ||
| #include "Imath/ImathMatrixAlgo.h" | ||
|
|
||
| using namespace IECore; | ||
| using namespace IECoreScene; | ||
| using namespace boost; | ||
|
|
@@ -104,6 +108,46 @@ void CoordinateSystem::load( LoadContextPtr context ) | |
| unsigned int v = m_ioVersion; | ||
| ConstIndexedIOPtr container = context->container( staticTypeName(), v ); | ||
| container->read( g_nameEntry, m_name ); | ||
|
|
||
| // CoordinateSystem used to derive from the deprecated and removed StateRenderable | ||
| // holding additional transform information for the renderer. A better approach that is also | ||
| // used in Gaffer, the transform information is better stored as separate transform information. | ||
| // Cortex 10.6 also removed all DCC integrations, i.e. IECoreMaya, which stored, for example | ||
| // Locator transformation on the CoordinateSystem. We provide a way to still retrieve this | ||
| // information from old SceneCaches, although not fully transparent and backwards compatible. | ||
| // Clients of CoordinateSystem will need to be adjusted if needed. | ||
|
|
||
| // We look for a matrix entry somewhere underneath the CoordinateSystem, directly read it from | ||
| // there instead of loading an object and stash it in the BlindData. | ||
| const IndexedIO::EntryID matrixEntry( "matrix" ); | ||
| Imath::M44f matrix; | ||
|
|
||
| std::function<void(ConstIndexedIOPtr)> findMatrixEntry = [&]( ConstIndexedIOPtr directory ) | ||
| { | ||
| if( directory->hasEntry( matrixEntry ) ) | ||
| { | ||
| float *f = matrix.getValue(); | ||
| directory->read( matrixEntry, f, 16 ); | ||
| } | ||
|
|
||
| IndexedIO::EntryIDList levelDirectories; | ||
| directory->entryIds( levelDirectories, IndexedIO::EntryType::Directory ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a feeling that |
||
|
|
||
| for ( auto levelDirectory : levelDirectories ) | ||
| { | ||
| ConstIndexedIOPtr subdirectory = directory->subdirectory( levelDirectory, IndexedIO::MissingBehaviour::NullIfMissing ); | ||
| if( subdirectory ) | ||
| { | ||
| findMatrixEntry( subdirectory ); | ||
| } | ||
|
Comment on lines
+136
to
+142
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you using this recursive search because you need to support MatrixMotionTransform as well as MatrixTransform, and it's convenient to deal with both using the same code?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I solely focused on I initially wanted to go directly to the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To me, a naive reader, the recursive search says "I want to find any entry called To satisfy my curiosity, I tried this more direct approach. I don't know what's up with |
||
| } | ||
| }; | ||
|
|
||
| findMatrixEntry( container ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps it's worth starting the search from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly to the comment about using a recursive search, if I recall correctly, Here again, I might have missed something and am very open to a different and better solution |
||
| if( matrix != Imath::identity44f ) | ||
| { | ||
| blindData()->writable()["LegacyTransform"] = new IECore::M44fData( matrix ); | ||
| } | ||
| } | ||
|
|
||
| void CoordinateSystem::hash( MurmurHash &h ) const | ||
|
|
||
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.
Should this
returnas soon as a matrix is found? And if so, should we stop the iteration throughlevelDirectorieswhen it does?