Skip to content
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

Instancer : Basic test that render hashes include proto root #6129

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions python/GafferSceneTest/InstancerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3022,6 +3022,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
Loading