From f3786b5fa4877aae7d04755f97ee5b43cbd0ab6f Mon Sep 17 00:00:00 2001 From: Daniel Dresser Date: Thu, 31 Oct 2024 15:34:35 -0700 Subject: [PATCH] Instancer : Basic test that render hashes include proto root --- python/GafferSceneTest/InstancerTest.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/python/GafferSceneTest/InstancerTest.py b/python/GafferSceneTest/InstancerTest.py index 818fad3dea3..298288f58fd 100644 --- a/python/GafferSceneTest/InstancerTest.py +++ b/python/GafferSceneTest/InstancerTest.py @@ -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 ) :