[Bf-blender-cvs] [9dc4bf1] alembic_basic_io: Remove alembicManager, and other unused functions.
Kévin Dietrich
noreply at git.blender.org
Wed Apr 6 23:52:36 CEST 2016
Commit: 9dc4bf1a0e260d6dd7d5cbfb36a64dbac9d26bf6
Author: Kévin Dietrich
Date: Wed Apr 6 23:47:22 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB9dc4bf1a0e260d6dd7d5cbfb36a64dbac9d26bf6
Remove alembicManager, and other unused functions.
===================================================================
M source/blender/alembic/ABC_alembic.h
M source/blender/alembic/intern/abc_mesh.cc
M source/blender/alembic/intern/alembic_capi.cc
M source/blender/modifiers/intern/MOD_meshcache.c
===================================================================
diff --git a/source/blender/alembic/ABC_alembic.h b/source/blender/alembic/ABC_alembic.h
index bf57c1e..edef0d2 100644
--- a/source/blender/alembic/ABC_alembic.h
+++ b/source/blender/alembic/ABC_alembic.h
@@ -52,8 +52,6 @@ void ABC_import(struct bContext *C, const char *filename, int from_forward, int
void ABC_get_vertex_cache(const char *filepath, float time, void *verts, int max_verts, const char *sub_obj, int is_mvert);
-void ABC_destroy_mesh_data(void *key);
-
int ABC_check_subobject_valid(const char *name, const char *sub_obj);
#ifdef __cplusplus
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 39991fd..618b840 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1061,6 +1061,22 @@ static void mesh_add_mpolygons(Mesh *mesh, size_t len)
} /* mesh_utils */
#if 0
+static Material *findMaterial(const char *name)
+{
+ Main *bmain = G.main;
+ Material *material, *found_material = NULL;
+
+ for (material = (Material*)bmain->mat.first; material; material = (Material*)material->id.next) {
+
+ if (BLI_strcaseeq(material->id.name+2, name) == true) {
+ found_material = material;
+ break;
+ }
+ }
+
+ return found_material;
+}
+
static void ABC_apply_materials(Object *ob, void *key)
{
AbcInfo &meshmap = abc_manager->mesh_map[key];
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 431e442..431e7c8 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -24,7 +24,6 @@
#include <Alembic/AbcCoreHDF5/All.h>
#include <Alembic/AbcCoreOgawa/All.h>
-#include <algorithm>
#include "abc_exporter.h"
#include "abc_camera.h"
@@ -33,28 +32,14 @@
#include "abc_util.h"
extern "C" {
-#include "MEM_guardedalloc.h"
-
-#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_global.h"
-#include "BKE_idprop.h"
-#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_mesh.h"
-#include "BKE_object.h"
-#include "BKE_scene.h"
#include "BLI_math.h"
-#include "BLI_listbase.h"
-#include "BLI_string.h"
-#include "BLI_threads.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -73,566 +58,36 @@ using Alembic::AbcGeom::IObject;
using Alembic::AbcGeom::IPolyMesh;
using Alembic::AbcGeom::IPolyMeshSchema;
using Alembic::AbcGeom::ISampleSelector;
-using Alembic::AbcGeom::IXform;
-using Alembic::AbcGeom::IXformSchema;
-static Object *find_object(bContext *C, const std::string &name)
+static IArchive open_archive(const std::string &filename)
{
- Scene *scene = CTX_data_scene(C);
- Base *base;
-
- for (base = static_cast<Base *>(scene->base.first); base; base = base->next) {
- Object *ob = base->object;
-
- if (ob->id.name + 2 == name) {
- return ob;
- }
- }
-
- return NULL;
-}
-
-static const int max_alembic_files = 300;
-
-struct AbcInfo {
- Mesh *mesh;
- int current_mat;
-
- std::string filename, sub_object;
- std::vector< std::pair<IPolyMeshSchema, IObject> > schema_cache;
-
- std::map<std::string, int> mat_map;
- std::map<std::string, Material *> materials;
-
- AbcInfo()
- : mesh(NULL)
- , current_mat(0)
- {}
-};
-
-typedef std::map<void *, AbcInfo> MeshMap;
-
-struct alembicManager {
- alembicManager()
- {
- mutex = BLI_mutex_alloc();
- }
-
- ~alembicManager()
- {
- BLI_mutex_lock(mutex);
-
- mesh_map.clear();
- mesh_map_cache.clear();
- object_map.clear();
- xform_map.clear();
-
- std::tr1::unordered_map<std::string, IArchive *>::iterator it = archives.begin();
-
- for (; it != archives.end(); ++it) {
- /* XXX */
- try {
- delete it->second;
- }
- catch (const Alembic::Util::Exception &e) {
- std::cerr << e.what() << '\n';
- }
- }
-
- BLI_mutex_unlock(mutex);
+ Alembic::AbcCoreAbstract::ReadArraySampleCachePtr cache_ptr;
+ IArchive archive;
- BLI_mutex_free(mutex);
+ try {
+ archive = IArchive(Alembic::AbcCoreHDF5::ReadArchive(),
+ filename.c_str(), ErrorHandler::kThrowPolicy,
+ cache_ptr);
}
-
- IArchive *getArchive(const std::string &filename)
- {
- std::tr1::unordered_map<std::string, IArchive*>::iterator it = archives.find(filename);
-
- if (it != archives.end()) {
- return it->second;
- }
-
- if ((int)archives.size() > max_alembic_files) {
- std::tr1::unordered_map<IArchive *, std::tr1::unordered_map<std::string, IObject> >::iterator it_ob;
- std::tr1::unordered_map<IArchive *, std::tr1::unordered_map<std::string, IXformSchema> >::iterator it_xf;
-
- it = archives.begin();
-
- it_ob = object_map.find(it->second);
- it_xf = xform_map.find(it->second);;
-
- if (it_ob != object_map.end()) {
- object_map.erase(it_ob);
- }
-
- if (it_xf != xform_map.end()) {
- xform_map.erase(it_xf);
- }
-
- delete it->second;
- archives.erase(it);
- }
-
- IArchive *archive;
-
+ catch (const Exception &) {
try {
- archive = new IArchive(Alembic::AbcCoreHDF5::ReadArchive(),
- filename.c_str(), ErrorHandler::kThrowPolicy,
- cache_ptr);
+ archive = IArchive(Alembic::AbcCoreOgawa::ReadArchive(),
+ filename.c_str(), ErrorHandler::kThrowPolicy,
+ cache_ptr);
}
catch (const Exception &e) {
- try {
- archive = new IArchive(Alembic::AbcCoreOgawa::ReadArchive(),
- filename.c_str(), ErrorHandler::kThrowPolicy,
- cache_ptr);
- }
- catch (const Exception &e) {
- std::cerr << e.what() << std::endl;
- return NULL;
- }
- }
-
- archives[filename] = archive;
-
- return archive;
- }
-
- void visitObjects(IObject iObj, IObject &ret, std::string path, bool &found)
- {
- if (!iObj.valid()) {
- return;
- }
-
- IArchive *archive = getArchive(iObj.getArchive().getName());
-
- const bool archive_ok = object_map.find(archive) != object_map.end();
- std::tr1::unordered_map<std::string, IObject> archive_map;
-
- if (archive_ok) {
- archive_map = object_map[archive];
-
- if (archive_map.find(path) != archive_map.end()) {
- ret = archive_map[path];
- found = true;
- return;
- }
- }
-
- std::vector<std::string> tokens;
- split(path, "/", tokens);
-
- IObject arch_it = iObj;
- std::string current_path;
-
- for (int i = 0; i < tokens.size(); ++i) {
- current_path += "/" + tokens[i];
- if (archive_ok) {
- if (archive_map.find(current_path) != archive_map.end()) {
- arch_it = archive_map[current_path];
- continue;
- }
- }
- IObject obj = arch_it.getChild(tokens[i]);
- arch_it = obj;
-
- if (!obj.valid())
- return;
-
- if (archive_ok) {
- archive_map[current_path] = arch_it;
- }
- }
- ret = arch_it;
- if (ret.valid())
- found = true;
- }
-
-
- IXformSchema getXFormSchema(std::string filename, std::string path, bool &found) {
- IArchive *archive = getArchive(filename);
-
- if (!archive || !archive->valid())
- return IXformSchema();
-
- std::tr1::unordered_map< IArchive*, std::tr1::unordered_map<std::string, IXformSchema> >::iterator it = xform_map.find(archive);
- if (it != xform_map.end()) {
- if (it->second.find(path) != it->second.end()) {
- found = true;
- return it->second[path];
- }
- }
- IObject arch_it;
- visitObjects(archive->getTop(), arch_it, path, found);
-
- if (!found)
- return IXformSchema();
-
- const MetaData &md = arch_it.getMetaData();
- if (IXformSchema::matches(md)) {
- IXform x(arch_it, kWrapExisting);
- IXformSchema &schema(x.getSchema());
- xform_map[archive][path] = schema;
- return schema;
- }
-
- return IXformSchema();
- }
-
- IObject getObject(std::string filename, std::string path, bool &found)
- {
- IObject ret;
-
- IArchive *archive = getArchive(filename);
-
- if (!archive || !archive->valid())
- return ret;
-
- if (object_map.find(archive) != object_map.end()) {
- if (object_map[archive].find(path) != object_map[archive].end()) {
- found = true;
- return object_map[archive][path];
- }
- }
-
- visitObjects(archive->getTop(), ret, path, found);
-
- if (found) {
- object_map[archive][path] = ret;
- found = true;
- return ret;
- }
-
- return IObject();
- }
-
- // datas
- std::tr1::unordered_map< IArchive*, std::tr1::unordered_map<std::string, IObject> > object_map;
- std::tr1::unordered_map< IArchive*, std::tr1::unordered_map<std::string, IXformSchema> > xform_map;
- std::tr1::unordered_map<std::string, IArchive*> archives;
- ::Alembic::AbcCoreAbstract::ReadArraySampleCachePtr cache_ptr;
- ThreadMutex *mutex;
-
- MeshMap mesh_map;
- MeshMap mesh_map_cache;
-};
-
-/* TODO */
-static alembicManager __abc_manager;
-static alembicManager *abc_manager = &__abc_manager;// new alembicManager();
-
-#if 0
-static Material *findMaterial(const char *name)
-{
- Main *bmain = G.main;
- Material *material, *found_material = NULL;
-
- for (material = (Material*)bmain->mat.first; material; material = (Material*)material->id.next) {
-
- if (BLI_strcaseeq(material->id.name+2, name) == true) {
- found_material = material;
- break;
+ std::cerr << e.what() << '\n';
+ return IArchive();
}
}
- return found_material;
-}
-
-static void ABC_mutex_lock()
-{
- BLI_mutex_lock(abc_manager->mutex);
-}
-
-static void ABC_mutex_unlock()
-{
- BLI_mutex_unlock(abc_manager->mutex);
-}
-
-static void visitObjectMatrix(IObject iObj, std::string abc_subobject, float time, float mat[][4])
-{
- if (!iObj.valid())
- return;
-
- for (int i = 0;i < iObj.getNumChildren(); ++i) {
- IObject child(iObj, iObj.getChildHeader(i).getName());
-
- if (!child.valid())
- continue;
-
- const MetaData &md = child.getMetaData();
-
- if (IXformSchema::matches(md) && child.getFullName() == abc_subobject) {
- XformSample xs;
- IXform x(child, kWrapExisting);
- IXformSchema &schema(x.getSchema());
- ISampleSelector sample_sel(time);
- schema.get(xs, sample_sel);
- for (int i = 0; i < 4; ++i) {
- for (int j = 0; j < 4; j++) {
- mat[i][j] = xs.getMatrix()[i][j
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list