@@ -61,6 +61,42 @@ def testObjectSamples( self ) :
6161
6262 self .assertEqual ( [ s .radius () for s in samples ], [ 0.75 , 1.25 ] )
6363
64+ def testObjectSamplesMatchingHash ( self ) :
65+
66+ # If the input object has a hash that doesn't vary with time, then we just get one sample when
67+ # we try to sample over time.
68+ sphere = GafferScene .Sphere ()
69+ sphere ["type" ].setValue ( sphere .Type .Primitive )
70+
71+ with Gaffer .Context () as c :
72+ c ["scene:path" ] = IECore .InternedStringVectorData ( [ "sphere" ] )
73+ samples = GafferScene .Private .RendererAlgo .objectSamples ( sphere ["out" ]["object" ], [ 0.75 , 1.25 ] )
74+
75+ self .assertEqual ( [ s .radius () for s in samples ], [ 1.0 ] )
76+
77+ def testObjectSamplesMatchingResult ( self ) :
78+
79+ # If the input object has different hashes at different times, but still produces identical objects,
80+ # then we should still only output one sample.
81+
82+ frame = GafferTest .FrameNode ()
83+
84+ # Quick hack to produce a value that doesn't vary, but has a hash that does: feed the frame
85+ # through an integer multiply node, which will truncate the value to an integer
86+ multiply = GafferTest .MultiplyNode ()
87+ multiply ["op1" ].setValue ( 1 )
88+ multiply ["op2" ].setInput ( frame ["output" ] )
89+
90+ sphere = GafferScene .Sphere ()
91+ sphere ["type" ].setValue ( sphere .Type .Primitive )
92+ sphere ["radius" ].setInput ( multiply ["product" ] )
93+
94+ with Gaffer .Context () as c :
95+ c ["scene:path" ] = IECore .InternedStringVectorData ( [ "sphere" ] )
96+ samples = GafferScene .Private .RendererAlgo .objectSamples ( sphere ["out" ]["object" ], [ 1.25 , 1.75 ] )
97+
98+ self .assertEqual ( [ s .radius () for s in samples ], [ 1.0 ] )
99+
64100 def testNonInterpolableObjectSamples ( self ) :
65101
66102 frame = GafferTest .FrameNode ()
0 commit comments