Skip to content

Commit

Permalink
Instancer : Basic test that render hashes include proto root
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser-ie committed Oct 31, 2024
1 parent 70968dd commit f3786b5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions python/GafferSceneTest/InstancerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2960,6 +2960,29 @@ def testVaryingPrimvars( self ) :
self.assertEqual( [ instancer["out"].attributes( "/object/instances/%s/%i/%s" % ("abdc"[i],i,"abdc"[i]) )["testAttribute"].value for i in range(4) ], [ 42.0 ] * 4 )
self.assertEqual( [ instancer["out"].attributes( "/object/instances/%s/%i" % ("abdc"[i],i) ).get("user:varyingFloat") for i in range(4) ], [ None ] * 4 )

def testRenderHashes( self ) :

script = self.buildPrototypeRootsScript()
script["instancer"]["prototypeMode"].setValue( GafferScene.Instancer.PrototypeMode.IndexedRootsList )
script["instancer"]["prototypeRootsList"].setValue( IECore.StringVectorData( [
"/foo", "/bar"
] ) )
script["instancer"]["encapsulate"].setValue( True )

renderer = GafferScene.Private.IECoreScenePreview.CapturingRenderer( GafferScene.Private.IECoreScenePreview.Renderer.RenderType.Batch )

script["instancer"]["out"].object( "/object/instances" ).render( renderer )

# Make sure that the capsules we produce have different hashes when the prototype roots are different
rootsByHash = {}
for n in renderer.capturedObjectNames():
co = renderer.capturedObject( n ).capturedSamples()[0]
if co.hash() in rootsByHash:
with self.subTest( location = n ) :
self.assertEqual( co.root(), rootsByHash[ co.hash() ] )
else:
rootsByHash[ co.hash() ] = co.root()

@GafferTest.TestRunner.PerformanceTestMethod( repeat = 10 )
def testBoundPerformance( self ) :

Expand Down

0 comments on commit f3786b5

Please sign in to comment.