|
34 | 34 |
|
35 | 35 | #include "IECoreScene/CoordinateSystem.h" |
36 | 36 |
|
| 37 | +#include "IECore/SimpleTypedData.h" |
37 | 38 | #include "IECore/MurmurHash.h" |
38 | 39 |
|
| 40 | +#include "Imath/ImathMatrix.h" |
| 41 | +#include "Imath/ImathMatrixAlgo.h" |
| 42 | + |
39 | 43 | using namespace IECore; |
40 | 44 | using namespace IECoreScene; |
41 | 45 | using namespace boost; |
@@ -104,6 +108,30 @@ void CoordinateSystem::load( LoadContextPtr context ) |
104 | 108 | unsigned int v = m_ioVersion; |
105 | 109 | ConstIndexedIOPtr container = context->container( staticTypeName(), v ); |
106 | 110 | container->read( g_nameEntry, m_name ); |
| 111 | + |
| 112 | + // CoordinateSystem used to have a transform property, but that has |
| 113 | + // been removed in favour of transforms being accessed independently |
| 114 | + // of objects in SceneInterface (and Gaffer). If a legacy transform |
| 115 | + // exists, load it and stash it as blind data for use by legacy tools. |
| 116 | + |
| 117 | + ConstIndexedIOPtr matrixTransformContainer = container; |
| 118 | + for( auto name : { "transform", "data", "MatrixTransform", "data" } ) |
| 119 | + { |
| 120 | + matrixTransformContainer = matrixTransformContainer->subdirectory( name, IndexedIO::MissingBehaviour::NullIfMissing ); |
| 121 | + if( !matrixTransformContainer ) |
| 122 | + { |
| 123 | + break; |
| 124 | + } |
| 125 | + } |
| 126 | + |
| 127 | + const IndexedIO::EntryID matrixEntry( "matrix" ); |
| 128 | + if( matrixTransformContainer && matrixTransformContainer->hasEntry( matrixEntry ) ) |
| 129 | + { |
| 130 | + M44fDataPtr matrix = new M44fData; |
| 131 | + float *f = matrix->writable().getValue(); |
| 132 | + matrixTransformContainer->read( matrixEntry, f, 16 ); |
| 133 | + blindData()->writable()["LegacyTransform"] = matrix; |
| 134 | + } |
107 | 135 | } |
108 | 136 |
|
109 | 137 | void CoordinateSystem::hash( MurmurHash &h ) const |
|
0 commit comments