diff options
-rw-r--r-- | source/blender/io/alembic/intern/abc_util.cc | 14 | ||||
-rw-r--r-- | source/blender/io/alembic/intern/abc_util.h | 1 | ||||
-rw-r--r-- | source/blender/io/alembic/intern/abc_writer_hair.cc | 3 | ||||
-rw-r--r-- | source/blender/io/alembic/intern/abc_writer_points.cc | 3 | ||||
-rw-r--r-- | tests/python/alembic_tests.py | 16 |
5 files changed, 22 insertions, 15 deletions
diff --git a/source/blender/io/alembic/intern/abc_util.cc b/source/blender/io/alembic/intern/abc_util.cc index 1f3bd2a1aaa..92f4b9532a1 100644 --- a/source/blender/io/alembic/intern/abc_util.cc +++ b/source/blender/io/alembic/intern/abc_util.cc @@ -49,12 +49,16 @@ std::string get_id_name(const Object *const ob) std::string get_id_name(const ID *const id) { - std::string name(id->name + 2); - std::replace(name.begin(), name.end(), ' ', '_'); - std::replace(name.begin(), name.end(), '.', '_'); - std::replace(name.begin(), name.end(), ':', '_'); + return get_valid_abc_name(id->name + 2); +} - return name; +std::string get_valid_abc_name(const char *name) +{ + std::string name_string(name); + std::replace(name_string.begin(), name_string.end(), ' ', '_'); + std::replace(name_string.begin(), name_string.end(), '.', '_'); + std::replace(name_string.begin(), name_string.end(), ':', '_'); + return name_string; } /** diff --git a/source/blender/io/alembic/intern/abc_util.h b/source/blender/io/alembic/intern/abc_util.h index 57b4d9800a5..8a5763bb38b 100644 --- a/source/blender/io/alembic/intern/abc_util.h +++ b/source/blender/io/alembic/intern/abc_util.h @@ -49,6 +49,7 @@ struct Object; std::string get_id_name(const ID *const id); std::string get_id_name(const Object *const ob); +std::string get_valid_abc_name(const char *name); std::string get_object_dag_path_name(const Object *const ob, Object *dupli_parent); /* Convert from float to Alembic matrix representations. Does NOT convert from Z-up to Y-up. */ diff --git a/source/blender/io/alembic/intern/abc_writer_hair.cc b/source/blender/io/alembic/intern/abc_writer_hair.cc index ed62889b03d..43c05627130 100644 --- a/source/blender/io/alembic/intern/abc_writer_hair.cc +++ b/source/blender/io/alembic/intern/abc_writer_hair.cc @@ -53,7 +53,8 @@ AbcHairWriter::AbcHairWriter(Object *ob, { m_psys = psys; - OCurves curves(parent->alembicXform(), psys->name, m_time_sampling); + std::string psys_name = get_valid_abc_name(psys->name); + OCurves curves(parent->alembicXform(), psys_name, m_time_sampling); m_schema = curves.getSchema(); } diff --git a/source/blender/io/alembic/intern/abc_writer_points.cc b/source/blender/io/alembic/intern/abc_writer_points.cc index ac663b62693..6be4bcfdbe7 100644 --- a/source/blender/io/alembic/intern/abc_writer_points.cc +++ b/source/blender/io/alembic/intern/abc_writer_points.cc @@ -51,7 +51,8 @@ AbcPointsWriter::AbcPointsWriter(Object *ob, { m_psys = psys; - OPoints points(parent->alembicXform(), psys->name, m_time_sampling); + std::string psys_name = get_valid_abc_name(psys->name); + OPoints points(parent->alembicXform(), psys_name, m_time_sampling); m_schema = points.getSchema(); } diff --git a/tests/python/alembic_tests.py b/tests/python/alembic_tests.py index fbb9496c9df..ec290001a6f 100644 --- a/tests/python/alembic_tests.py +++ b/tests/python/alembic_tests.py @@ -280,10 +280,10 @@ class HairParticlesExportTest(AbstractAlembicTest): def test_with_both(self, tempdir: pathlib.Path): abc = self._do_test(tempdir, True, True) - abcprop = self.abcprop(abc, '/Suzanne/Hair system/.geom') + abcprop = self.abcprop(abc, '/Suzanne/Hair_system/.geom') self.assertIn('nVertices', abcprop) - abcprop = self.abcprop(abc, '/Suzanne/Non-hair particle system/.geom') + abcprop = self.abcprop(abc, '/Suzanne/Non-hair_particle_system/.geom') self.assertIn('.velocities', abcprop) abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom') @@ -293,11 +293,11 @@ class HairParticlesExportTest(AbstractAlembicTest): def test_with_hair_only(self, tempdir: pathlib.Path): abc = self._do_test(tempdir, True, False) - abcprop = self.abcprop(abc, '/Suzanne/Hair system/.geom') + abcprop = self.abcprop(abc, '/Suzanne/Hair_system/.geom') self.assertIn('nVertices', abcprop) self.assertRaises(AbcPropError, self.abcprop, abc, - '/Suzanne/Non-hair particle system/.geom') + '/Suzanne/Non-hair_particle_system/.geom') abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom') self.assertIn('.faceIndices', abcprop) @@ -306,9 +306,9 @@ class HairParticlesExportTest(AbstractAlembicTest): def test_with_particles_only(self, tempdir: pathlib.Path): abc = self._do_test(tempdir, False, True) - self.assertRaises(AbcPropError, self.abcprop, abc, '/Suzanne/Hair system/.geom') + self.assertRaises(AbcPropError, self.abcprop, abc, '/Suzanne/Hair_system/.geom') - abcprop = self.abcprop(abc, '/Suzanne/Non-hair particle system/.geom') + abcprop = self.abcprop(abc, '/Suzanne/Non-hair_particle_system/.geom') self.assertIn('.velocities', abcprop) abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom') @@ -318,9 +318,9 @@ class HairParticlesExportTest(AbstractAlembicTest): def test_with_neither(self, tempdir: pathlib.Path): abc = self._do_test(tempdir, False, False) - self.assertRaises(AbcPropError, self.abcprop, abc, '/Suzanne/Hair system/.geom') + self.assertRaises(AbcPropError, self.abcprop, abc, '/Suzanne/Hair_system/.geom') self.assertRaises(AbcPropError, self.abcprop, abc, - '/Suzanne/Non-hair particle system/.geom') + '/Suzanne/Non-hair_particle_system/.geom') abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom') self.assertIn('.faceIndices', abcprop) |