Commit: 4c436672b423a670e6a4d40edacf6185ed00a38f
Author: Kévin Dietrich
Date:   Thu Apr 7 12:32:12 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB4c436672b423a670e6a4d40edacf6185ed00a38f

Cleanup: de-duplicate 'get_id_name'.

===================================================================

M       source/blender/alembic/intern/abc_exporter.cc
M       source/blender/alembic/intern/abc_mesh.cc
M       source/blender/alembic/intern/abc_object.cc
M       source/blender/alembic/intern/abc_transform.cc
M       source/blender/alembic/intern/abc_util.cc
M       source/blender/alembic/intern/abc_util.h

===================================================================

diff --git a/source/blender/alembic/intern/abc_exporter.cc 
b/source/blender/alembic/intern/abc_exporter.cc
index 8a52ae8..5fe5153 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -276,7 +276,7 @@ void AbcExporter::createTransformWritersFlat()
                Object *ob = base->object;
 
                if (m_options.exportObject(ob) && objectIsShape(ob)) {
-                       std::string name = get_object_name(ob);
+                       std::string name = get_id_name(ob);
                        m_xforms[name] = new AbcTransformWriter(ob, 
m_archive.getTop(), 0, m_trans_sampling_index, m_options);
                }
 
diff --git a/source/blender/alembic/intern/abc_mesh.cc 
b/source/blender/alembic/intern/abc_mesh.cc
index f159444..e39df4c 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -945,11 +945,7 @@ void AbcMeshWriter::getGeoGroups(
                        continue;
                }
 
-               std::string name = (mat->id.name + 2);
-
-               std::replace(name.begin(), name.end(), ' ', '_');
-               std::replace(name.begin(), name.end(), '.', '_');
-               std::replace(name.begin(), name.end(), ':', '_');
+               std::string name = get_id_name(&mat->id);
 
                if (geo_groups.find(name) == geo_groups.end()) {
                        std::vector<int32_t> faceArray;
@@ -962,10 +958,7 @@ void AbcMeshWriter::getGeoGroups(
        if (geo_groups.size() == 0) {
                Material *mat = give_current_material(m_object, 1);
 
-               std::string name = (mat) ? (mat->id.name + 2) : "default";
-               std::replace(name.begin(), name.end(), ' ', '_');
-               std::replace(name.begin(), name.end(), '.', '_');
-               std::replace(name.begin(), name.end(), ':', '_');
+               std::string name = (mat) ? get_id_name(&mat->id) : "default";
 
                std::vector<int32_t> faceArray;
 
diff --git a/source/blender/alembic/intern/abc_object.cc 
b/source/blender/alembic/intern/abc_object.cc
index c530336..0de6873 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -54,7 +54,7 @@ AbcObjectWriter::AbcObjectWriter(Object *obj, 
AbcExportOptions &opts)
     , m_options(opts)
     , m_first_frame(true)
 {
-       m_name = get_object_name(m_object) + "Shape";
+       m_name = get_id_name(m_object) + "Shape";
 }
 
 AbcObjectWriter::~AbcObjectWriter()
diff --git a/source/blender/alembic/intern/abc_transform.cc 
b/source/blender/alembic/intern/abc_transform.cc
index f887135eb..1532242 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -50,7 +50,7 @@ AbcTransformWriter::AbcTransformWriter(Object *obj,
                timeSampling = 0;
        }
 
-    m_xform = OXform(abcParent, get_object_name(m_object), timeSampling);
+    m_xform = OXform(abcParent, get_id_name(m_object), timeSampling);
        m_schema = m_xform.getSchema();
 
        if (writerParent) {
diff --git a/source/blender/alembic/intern/abc_util.cc 
b/source/blender/alembic/intern/abc_util.cc
index 1468756a..8dd96cd 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -28,14 +28,18 @@ extern "C" {
 #include "DNA_object_types.h"
 }
 
-std::string get_object_name(Object *ob)
+std::string get_id_name(Object *ob)
 {
        if (!ob) {
                return "";
        }
 
        ID *id = reinterpret_cast<ID *>(ob);
+       return get_id_name(id);
+}
 
+std::string get_id_name(ID *id)
+{
        std::string name(id->name + 2);
        std::replace(name.begin(), name.end(), ' ', '_');
        std::replace(name.begin(), name.end(), '.', '_');
@@ -46,17 +50,17 @@ std::string get_object_name(Object *ob)
 
 std::string get_object_dag_path_name(Object *ob, Object *dupli_parent)
 {
-    std::string name = get_object_name(ob);
+    std::string name = get_id_name(ob);
 
     Object *p = ob->parent;
 
     while (p) {
-        name = get_object_name(p) + "/" + name;
+        name = get_id_name(p) + "/" + name;
         p = p->parent;
     }
 
        if (dupli_parent && (ob != dupli_parent)) {
-               name = get_object_name(dupli_parent) + "/" + name;
+               name = get_id_name(dupli_parent) + "/" + name;
        }
 
     return name;
diff --git a/source/blender/alembic/intern/abc_util.h 
b/source/blender/alembic/intern/abc_util.h
index 621b3e1..3d75c6e 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -25,9 +25,11 @@
 
 #include <Alembic/Abc/All.h>
 
+struct ID;
 struct Object;
 
-std::string get_object_name(Object *ob);
+std::string get_id_name(ID *id);
+std::string get_id_name(Object *ob);
 std::string get_object_dag_path_name(Object *ob, Object *dupli_parent);
 
 bool object_selected(Object *ob);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to