Skip to content

Commit 5257c71

Browse files
committed
USDScene : Fix timecodes used by writeAttribute()
1 parent f530b71 commit 5257c71

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Changes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
10.5.x.x (relative to 10.5.12.0)
2+
========
3+
4+
Fixes
5+
-----
6+
7+
- USDScene : Fixed timecodes used when writing animated attributes.
8+
19
10.5.12.0 (relative to 10.5.11.0)
210
========
311

contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ void USDScene::writeAttribute( const SceneInterface::Name &name, const Object *a
13411341
pxr::TfToken( g.first.string().substr( 10 ) ),
13421342
DataAlgo::valueTypeName( d )
13431343
);
1344-
globalAttribute.Set( DataAlgo::toUSD( d ) );
1344+
globalAttribute.Set( DataAlgo::toUSD( d ), m_root->timeCode( time ) );
13451345
}
13461346
}
13471347
}
@@ -1357,14 +1357,14 @@ void USDScene::writeAttribute( const SceneInterface::Name &name, const Object *a
13571357
pxr::UsdGeomPrimvar usdPrimvar = primvarsAPI.CreatePrimvar(
13581358
usdName.name, DataAlgo::valueTypeName( data ), pxr::UsdGeomTokens->constant
13591359
);
1360-
usdPrimvar.Set( DataAlgo::toUSD( data ), time );
1360+
usdPrimvar.Set( DataAlgo::toUSD( data ), m_root->timeCode( time ) );
13611361
}
13621362
else
13631363
{
13641364
pxr::UsdAttribute newAttribute = m_location->prim.CreateAttribute(
13651365
usdName.name, DataAlgo::valueTypeName( data )
13661366
);
1367-
newAttribute.Set( DataAlgo::toUSD( data ), time );
1367+
newAttribute.Set( DataAlgo::toUSD( data ), m_root->timeCode( time ) );
13681368
}
13691369
}
13701370
}

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,6 +2809,23 @@ def testAttributeBadPrefix( self ):
28092809
self.assertEqual( set( root.child( "loc" ).attributeNames() ), set( ['ai:testAttribute' ] ) )
28102810
self.assertEqual( root.child( "loc" ).readAttribute( 'ai:testAttribute', 0 ), IECore.FloatData( 9 ) )
28112811

2812+
def testWriteAnimatedAttribute( self ) :
2813+
2814+
fileName = os.path.join( self.temporaryDirectory(), "test.usda" )
2815+
root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write )
2816+
child = root.createChild( "child" )
2817+
2818+
for t in ( 0.0, 0.5, 1.0 ) :
2819+
child.writeAttribute( "user:test", IECore.FloatData( t ), t )
2820+
2821+
del child, root
2822+
2823+
root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read )
2824+
child = root.child( "child" )
2825+
2826+
for t in ( 0.0, 0.5, 1.0 ) :
2827+
self.assertEqual( child.readAttribute( "user:test", t ), IECore.FloatData( t ) )
2828+
28122829
def testShaders( self ) :
28132830

28142831
# Write shaders

0 commit comments

Comments
 (0)