def test(self): # Input is a plane stretched in X plane = IECoreScene.MeshPrimitive.createPlane( imath.Box2f(imath.V2f(-1), imath.V2f(1)), imath.V2i(10)) plane["Pref"] = plane["P"] plane["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [p * imath.V3f(2, 1, 1) for p in plane["P"].data])) objectToScene = GafferScene.ObjectToScene() objectToScene["object"].setValue(plane) # Node should do nothing without a filter applied. meshDistortion = GafferScene.MeshDistortion() meshDistortion["in"].setInput(objectToScene["out"]) self.assertScenesEqual(objectToScene["out"], meshDistortion["out"]) self.assertSceneHashesEqual(objectToScene["out"], meshDistortion["out"]) mesh = meshDistortion["out"].object("/object") self.assertNotIn("distortion", mesh) self.assertNotIn("uvDistortion", mesh) # Applying a filter should kick it into action. f = GafferScene.PathFilter() f["paths"].setValue(IECore.StringVectorData(["/object"])) meshDistortion["filter"].setInput(f["out"]) mesh = meshDistortion["out"].object("/object") self.assertIn("distortion", mesh) self.assertIn("uvDistortion", mesh) self.assertIsInstance(mesh["distortion"].data, IECore.FloatVectorData) self.assertIsInstance(mesh["uvDistortion"].data, IECore.V2fVectorData) # We should be able to request only one sort of distortion, # or redirect the values to a different primitive variable. meshDistortion["distortion"].setValue("") mesh = meshDistortion["out"].object("/object") self.assertNotIn("distortion", mesh) self.assertIn("uvDistortion", mesh) meshDistortion["uvDistortion"].setValue("D") mesh = meshDistortion["out"].object("/object") self.assertNotIn("distortion", mesh) self.assertNotIn("uvDistortion", mesh) self.assertIn("D", mesh)