Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2017-05-23 18:27:09 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2017-05-23 18:27:15 +0300
commit7b25ffb618dd7509d425f7a5891c64d4a3668743 (patch)
treee955a54b4e84c0a517054b819de504f9d2a23fff /tests
parentcc0cc880de5a66d72f571bec4c7d3eb1219aefc0 (diff)
Fix T51534: Alembic: added support for face-varying vertex colours
Houdini writes vertex data in a different format than Blender does; Houdini uses "face-varying scope", which means that the vertex colours are indexed by an ever-increasing number over all vertices of all faces instead of the vertex index. I've also merged the read_custom_data_mcols() and read_mcols() functions, because the latter was only called from the former, and the changes in this commit would add yet more function parameters to pass.
Diffstat (limited to 'tests')
-rw-r--r--tests/python/bl_alembic_import_test.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py
index ef5ae372333..358b8a3c758 100644
--- a/tests/python/bl_alembic_import_test.py
+++ b/tests/python/bl_alembic_import_test.py
@@ -31,7 +31,7 @@ import bpy
args = None
-class SimpleImportTest(unittest.TestCase):
+class AbstractAlembicTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.testdir = args.testdir
@@ -43,6 +43,18 @@ class SimpleImportTest(unittest.TestCase):
# Make sure we always start with a known-empty file.
bpy.ops.wm.open_mainfile(filepath=str(self.testdir / "empty.blend"))
+ def assertAlmostEqualFloatArray(self, actual, expect, places=6, delta=None):
+ """Asserts that the arrays of floats are almost equal."""
+
+ self.assertEqual(len(actual), len(expect),
+ 'Actual array has %d items, expected %d' % (len(actual), len(expect)))
+
+ for idx, (act, exp) in enumerate(zip(actual, expect)):
+ self.assertAlmostEqual(act, exp, places=places, delta=delta,
+ msg='%f != %f at index %d' % (act, exp, idx))
+
+
+class SimpleImportTest(AbstractAlembicTest):
def test_import_cube_hierarchy(self):
res = bpy.ops.wm.alembic_import(
filepath=str(self.testdir / "cubes-hierarchy.abc"),
@@ -158,6 +170,38 @@ class SimpleImportTest(unittest.TestCase):
self.assertEqual('CubeShape', bpy.data.objects['Cube'].data.name)
+class VertexColourImportTest(AbstractAlembicTest):
+ def test_import_from_houdini(self):
+ # Houdini saved "face-varying", and as RGB.
+ res = bpy.ops.wm.alembic_import(
+ filepath=str(self.testdir / "vertex-colours-houdini.abc"),
+ as_background_job=False)
+ self.assertEqual({'FINISHED'}, res)
+
+ ob = bpy.context.active_object
+ layer = ob.data.vertex_colors['Cf'] # MeshLoopColorLayer
+
+ # Test some known-good values.
+ self.assertAlmostEqualFloatArray(layer.data[0].color, (0, 0, 0))
+ self.assertAlmostEqualFloatArray(layer.data[98].color, (0.9019607, 0.4745098, 0.2666666))
+ self.assertAlmostEqualFloatArray(layer.data[99].color, (0.8941176, 0.4705882, 0.2627451))
+
+ def test_import_from_blender(self):
+ # Blender saved per-vertex, and as RGBA.
+ res = bpy.ops.wm.alembic_import(
+ filepath=str(self.testdir / "vertex-colours-blender.abc"),
+ as_background_job=False)
+ self.assertEqual({'FINISHED'}, res)
+
+ ob = bpy.context.active_object
+ layer = ob.data.vertex_colors['Cf'] # MeshLoopColorLayer
+
+ # Test some known-good values.
+ self.assertAlmostEqualFloatArray(layer.data[0].color, (1.0, 0.0156862, 0.3607843))
+ self.assertAlmostEqualFloatArray(layer.data[98].color, (0.0941176, 0.1215686, 0.9137254))
+ self.assertAlmostEqualFloatArray(layer.data[99].color, (0.1294117, 0.3529411, 0.7529411))
+
+
def main():
global args
import argparse