[Bf-blender-cvs] [743ee83] alembic_pointcache: Separation of the main point cache API from the Alembic implementation.

Lukas Tönne noreply at git.blender.org
Thu Feb 12 13:42:36 CET 2015


Commit: 743ee837b0ec9b27a4d58471110d6ed2a543641e
Author: Lukas Tönne
Date:   Thu Feb 12 12:28:49 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB743ee837b0ec9b27a4d58471110d6ed2a543641e

Separation of the main point cache API from the Alembic implementation.

Even though we probably will use only the Alembic backend in the
foreseeable future, it is still good design to have a bit of abstraction
in this place and not directly call Alembic functions.

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

M	build_files/cmake/macros.cmake
M	source/blender/makesdna/DNA_pointcache_types.h
M	source/blender/pointcache/CMakeLists.txt
M	source/blender/pointcache/PTC_api.cpp
A	source/blender/pointcache/alembic/CMakeLists.txt
A	source/blender/pointcache/alembic/abc_cloth.cpp
A	source/blender/pointcache/alembic/abc_cloth.h
A	source/blender/pointcache/alembic/abc_dynamicpaint.cpp
A	source/blender/pointcache/alembic/abc_dynamicpaint.h
A	source/blender/pointcache/alembic/abc_frame_mapper.cpp
A	source/blender/pointcache/alembic/abc_frame_mapper.h
A	source/blender/pointcache/alembic/abc_mesh.cpp
A	source/blender/pointcache/alembic/abc_mesh.h
A	source/blender/pointcache/alembic/abc_particles.cpp
A	source/blender/pointcache/alembic/abc_particles.h
A	source/blender/pointcache/alembic/abc_reader.cpp
A	source/blender/pointcache/alembic/abc_reader.h
A	source/blender/pointcache/alembic/abc_rigidbody.cpp
A	source/blender/pointcache/alembic/abc_rigidbody.h
A	source/blender/pointcache/alembic/abc_schema.h
A	source/blender/pointcache/alembic/abc_smoke.cpp
A	source/blender/pointcache/alembic/abc_smoke.h
A	source/blender/pointcache/alembic/abc_softbody.cpp
A	source/blender/pointcache/alembic/abc_softbody.h
A	source/blender/pointcache/alembic/abc_writer.cpp
A	source/blender/pointcache/alembic/abc_writer.h
A	source/blender/pointcache/intern/alembic.h
D	source/blender/pointcache/intern/cloth.cpp
D	source/blender/pointcache/intern/cloth.h
D	source/blender/pointcache/intern/dynamicpaint.cpp
D	source/blender/pointcache/intern/dynamicpaint.h
D	source/blender/pointcache/intern/mesh.cpp
D	source/blender/pointcache/intern/mesh.h
D	source/blender/pointcache/intern/particles.cpp
D	source/blender/pointcache/intern/particles.h
A	source/blender/pointcache/intern/ptc_types.cpp
A	source/blender/pointcache/intern/ptc_types.h
M	source/blender/pointcache/intern/reader.cpp
M	source/blender/pointcache/intern/reader.h
D	source/blender/pointcache/intern/rigidbody.cpp
D	source/blender/pointcache/intern/rigidbody.h
D	source/blender/pointcache/intern/schema.h
D	source/blender/pointcache/intern/smoke.cpp
D	source/blender/pointcache/intern/smoke.h
D	source/blender/pointcache/intern/softbody.cpp
D	source/blender/pointcache/intern/softbody.h
M	source/blender/pointcache/intern/writer.cpp
M	source/blender/pointcache/intern/writer.h
M	source/blender/pointcache/util/util_error_handler.cpp
M	source/blender/pointcache/util/util_error_handler.h
D	source/blender/pointcache/util/util_frame_mapper.cpp
D	source/blender/pointcache/util/util_frame_mapper.h

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

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 8ddac0c..056ca94 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -565,6 +565,8 @@ macro(SETUP_BLENDER_SORTED_LIBS)
 		bf_dna
 		bf_blenfont
 		bf_pointcache
+		bf_pointcache_alembic
+		bf_pointcache
 		bf_intern_audaspace
 		bf_intern_mikktspace
 		bf_intern_dualcon
diff --git a/source/blender/makesdna/DNA_pointcache_types.h b/source/blender/makesdna/DNA_pointcache_types.h
index 808f4a7..b77858a 100644
--- a/source/blender/makesdna/DNA_pointcache_types.h
+++ b/source/blender/makesdna/DNA_pointcache_types.h
@@ -188,5 +188,10 @@ typedef enum ePointCacheCompression {
 /* PTCACHE_OUTDATED + PTCACHE_FRAMES_SKIPPED */
 #define _PTCACHE_REDO_NEEDED_DEPRECATED			258
 
+typedef enum ePointCacheArchive_Type {
+	PTC_ARCHIVE_BPHYS		= 0,
+	PTC_ARCHIVE_ALEMBIC		= 1,
+} ePointCacheArchive_Type;
+
 #endif
 
diff --git a/source/blender/pointcache/CMakeLists.txt b/source/blender/pointcache/CMakeLists.txt
index eb03e26..ed8a69c 100644
--- a/source/blender/pointcache/CMakeLists.txt
+++ b/source/blender/pointcache/CMakeLists.txt
@@ -33,14 +33,22 @@ set(INC
 )
 
 set(INC_SYS
-	${BOOST_INCLUDE_DIR}
 )
 
 set(SRC
+	intern/alembic.h
+	intern/export.h
+	intern/export.cpp
+	intern/ptc_types.h
+	intern/ptc_types.cpp
+	intern/reader.h
+	intern/reader.cpp
+	intern/thread.h
+	intern/writer.h
+	intern/writer.cpp
+
 	util/util_error_handler.h
 	util/util_error_handler.cpp
-	util/util_frame_mapper.h
-	util/util_frame_mapper.cpp
 	util/util_path.h
 	util/util_path.cpp
 	util/util_types.h
@@ -50,38 +58,8 @@ set(SRC
 )
 
 if(WITH_ALEMBIC)
-	list(APPEND INC_SYS
-	${ALEMBIC_INCLUDE_DIRS}
-	${OPENEXR_INCLUDE_DIR}/OpenEXR
-	)
-
-	list(APPEND SRC
-	intern/export.h
-	intern/export.cpp
-	intern/reader.h
-	intern/reader.cpp
-	intern/schema.h
-	intern/thread.h
-	intern/writer.h
-	intern/writer.cpp
-
-	intern/particles.h
-	intern/particles.cpp
-	intern/cloth.h
-	intern/cloth.cpp
-	intern/dynamicpaint.h
-	intern/dynamicpaint.cpp
-	intern/mesh.h
-	intern/mesh.cpp
-	intern/rigidbody.h
-	intern/rigidbody.cpp
-	intern/softbody.h
-	intern/softbody.cpp
-	intern/smoke.h
-	intern/smoke.cpp
-	)
-
-	add_definitions(-DWITH_ALEMBIC)
+	add_definitions(-DWITH_PTC_ALEMBIC)
+	add_subdirectory(alembic)
 endif()
 
 blender_add_lib(bf_pointcache "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 7f2a769..78f2d63 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -18,14 +18,15 @@
 
 #include "PTC_api.h"
 
-#ifdef WITH_ALEMBIC
-
 #include "util/util_error_handler.h"
 
 #include "reader.h"
 #include "writer.h"
 #include "export.h"
 
+#include "alembic.h"
+#include "ptc_types.h"
+
 extern "C" {
 #include "BLI_math.h"
 
@@ -233,14 +234,159 @@ PTCReader *PTC_reader_from_rna(Scene *scene, PointerRNA *ptr)
 	return NULL;
 }
 
-#else
 
-void PTC_writer_free(PTCWriter *_writer)
+/* ==== CLOTH ==== */
+
+PTCWriter *PTC_writer_cloth(Scene *scene, Object *ob, ClothModifierData *clmd)
 {
+	return (PTCWriter *)abc_writer_cloth(scene, ob, clmd);
 }
 
-void PTC_write(struct PTCWriter *_writer)
+PTCReader *PTC_reader_cloth(Scene *scene, Object *ob, ClothModifierData *clmd)
 {
+	return (PTCReader *)abc_reader_cloth(scene, ob, clmd);
 }
 
-#endif
+
+/* ==== DYNAMIC PAINT ==== */
+
+PTCWriter *PTC_writer_dynamicpaint(Scene *scene, Object *ob, DynamicPaintSurface *surface)
+{
+	return (PTCWriter *)abc_writer_dynamicpaint(scene, ob, surface);
+}
+
+PTCReader *PTC_reader_dynamicpaint(Scene *scene, Object *ob, DynamicPaintSurface *surface)
+{
+	return (PTCReader *)abc_reader_dynamicpaint(scene, ob, surface);
+}
+
+
+/* ==== MESH ==== */
+
+PTCWriter *PTC_writer_point_cache(Scene *scene, Object *ob, PointCacheModifierData *pcmd)
+{
+	return (PTCWriter *)abc_writer_point_cache(scene, ob, pcmd);
+}
+
+PTCReader *PTC_reader_point_cache(Scene *scene, Object *ob, PointCacheModifierData *pcmd)
+{
+	return (PTCReader *)abc_reader_point_cache(scene, ob, pcmd);
+}
+
+struct DerivedMesh *PTC_reader_point_cache_acquire_result(PTCReader *_reader)
+{
+	PointCacheReader *reader = (PointCacheReader *)_reader;
+	return reader->acquire_result();
+}
+
+void PTC_reader_point_cache_discard_result(PTCReader *_reader)
+{
+}
+
+ePointCacheModifierMode PTC_mod_point_cache_get_mode(PointCacheModifierData *pcmd)
+{
+	/* can't have simultaneous read and write */
+	if (pcmd->writer) {
+		BLI_assert(!pcmd->reader);
+		return MOD_POINTCACHE_MODE_WRITE;
+	}
+	else if (pcmd->reader) {
+		BLI_assert(!pcmd->writer);
+		return MOD_POINTCACHE_MODE_READ;
+	}
+	else
+		return MOD_POINTCACHE_MODE_NONE;
+}
+
+ePointCacheModifierMode PTC_mod_point_cache_set_mode(Scene *scene, Object *ob, PointCacheModifierData *pcmd, ePointCacheModifierMode mode)
+{
+	switch (mode) {
+		case MOD_POINTCACHE_MODE_READ:
+			if (pcmd->writer) {
+				PTC_writer_free(pcmd->writer);
+				pcmd->writer = NULL;
+			}
+			if (!pcmd->reader) {
+				pcmd->reader = PTC_reader_point_cache(scene, ob, pcmd);
+			}
+			return pcmd->reader ? MOD_POINTCACHE_MODE_READ : MOD_POINTCACHE_MODE_NONE;
+		
+		case MOD_POINTCACHE_MODE_WRITE:
+			if (pcmd->reader) {
+				PTC_reader_free(pcmd->reader);
+				pcmd->reader = NULL;
+			}
+			if (!pcmd->writer) {
+				pcmd->writer = PTC_writer_point_cache(scene, ob, pcmd);
+			}
+			return pcmd->writer ? MOD_POINTCACHE_MODE_WRITE : MOD_POINTCACHE_MODE_NONE;
+		
+		default:
+			if (pcmd->writer) {
+				PTC_writer_free(pcmd->writer);
+				pcmd->writer = NULL;
+			}
+			if (pcmd->reader) {
+				PTC_reader_free(pcmd->reader);
+				pcmd->reader = NULL;
+			}
+			return MOD_POINTCACHE_MODE_NONE;
+	}
+}
+
+
+/* ==== PARTICLES ==== */
+
+PTCWriter *PTC_writer_particles(Scene *scene, Object *ob, ParticleSystem *psys)
+{
+	return (PTCWriter *)abc_writer_particles(scene, ob, psys);
+}
+
+PTCReader *PTC_reader_particles(Scene *scene, Object *ob, ParticleSystem *psys)
+{
+	return (PTCReader *)abc_reader_particles(scene, ob, psys);
+}
+
+int PTC_reader_particles_totpoint(PTCReader *_reader)
+{
+	return ((PTC::ParticlesReader *)_reader)->totpoint();
+}
+
+
+/* ==== RIGID BODY ==== */
+
+PTCWriter *PTC_writer_rigidbody(Scene *scene, RigidBodyWorld *rbw)
+{
+	return (PTCWriter *)abc_writer_rigidbody(scene, rbw);
+}
+
+PTCReader *PTC_reader_rigidbody(Scene *scene, RigidBodyWorld *rbw)
+{
+	return (PTCReader *)abc_reader_rigidbody(scene, rbw);
+}
+
+
+/* ==== SMOKE ==== */
+
+PTCWriter *PTC_writer_smoke(Scene *scene, Object *ob, SmokeDomainSettings *domain)
+{
+	return (PTCWriter *)abc_writer_smoke(scene, ob, domain);
+}
+
+PTCReader *PTC_reader_smoke(Scene *scene, Object *ob, SmokeDomainSettings *domain)
+{
+	return (PTCReader *)abc_reader_smoke(scene, ob, domain);
+}
+
+
+/* ==== SOFT BODY ==== */
+
+PTCWriter *PTC_writer_softbody(Scene *scene, Object *ob, SoftBody *softbody)
+{
+	return (PTCWriter *)abc_writer_softbody(scene, ob, softbody);
+}
+
+PTCReader *PTC_reader_softbody(Scene *scene, Object *ob, SoftBody *softbody)
+{
+	return (PTCReader *)abc_reader_softbody(scene, ob, softbody);
+}
diff --git a/source/blender/pointcache/CMakeLists.txt b/source/blender/pointcache/alembic/CMakeLists.txt
similarity index 54%
copy from source/blender/pointcache/CMakeLists.txt
copy to source/blender/pointcache/alembic/CMakeLists.txt
index eb03e26..ac5dba0 100644
--- a/source/blender/pointcache/CMakeLists.txt
+++ b/source/blender/pointcache/alembic/CMakeLists.txt
@@ -23,65 +23,47 @@
 
 set(INC
 	.
-	intern
-	util
-	../blenkernel
-	../blenlib
-	../makesdna
-	../makesrna
-	../../../intern/guardedalloc
+	../
+	../intern
+	../util
+	../../blenkernel
+	../../blenlib
+	../../makesdna
+	../../makesrna
+	../../../../intern/guardedalloc
 )
 
 set(INC_SYS
 	${BOOST_INCLUDE_DIR}
+	${ALEMBIC_INCLUDE_DIRS}
+	${OPENEXR_INCLUDE_DIR}/OpenEXR
 )
 
 set(SRC
-	util/util_error_handler.h
-	util/util_error_handler.cpp
-	util/util_frame_mapper.h
-	util/util_frame_mapper.cpp
-	util/util_path.h
-	util/util_path.cpp
-	util/util_types.h
+	abc_frame_mapper.cpp
+	abc_frame_mapper.h
+	abc_reader.cpp
+	abc_reader.h
+	abc_schema.h
+	abc_writer.cpp
+	abc_writer.h
 
-	PTC_api.h
-	PTC_api.cpp
+	abc_cloth.cpp
+	abc_cloth.h
+	abc_dynamicpaint.cpp
+	abc_dynamicpaint.h
+	abc_mesh.cpp
+	abc_mesh.h
+	abc_particles.cpp
+	abc_particles.h
+	abc_rigidbody.cpp
+	abc_rigidbody.h
+	abc_smoke.cpp
+	abc_smoke.h
+	abc_softbody.cpp
+	abc_softbody.h
 )
 
-if(WITH_ALEMBIC)
-	list(APPEND INC_SYS
-	${ALEMBIC_INCLUDE_DIRS}
-	${OPENEXR_INCLUDE_DIR}/OpenEXR
-	)
-
-	list(APPEND SRC
-	intern/export.h
-	intern/export.cpp
-	intern/reader.h
-	intern/reader.cpp
-	intern/schema.h
-	intern/thread.h
-	intern/writer.h
-	intern/writer.cpp
-
-	intern/particles.h
-	intern/particles.cpp
-	intern/cloth.h
-	intern/cloth.cpp
-	intern/dynamicpaint.h
-	intern/dynamicpaint.cpp
-	intern/mesh.h
-	intern/mesh.cpp
-	intern/rigidbody.h
-	intern/rigidbody.cpp
-	intern/softbody.h
-	intern/softbody.cpp
-	intern/smoke.h
-	intern/smoke.cpp
-	)
-
-	add_definitions(-DWITH_ALEMBIC)
-endif()
+add_definitions(-DWITH_ALEMBIC)
 
-blender_add_lib(bf_pointcache "${SRC}" "${INC}" "${INC_SYS}")
+blender_add_lib(bf_pointcache_alembic "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/pointcache/intern/cloth.cpp b/source/blender/pointcache/alembic/abc_cloth.cpp
similarity index 52%
rename from source/blender/pointcache/intern/cloth.cpp
rename to source/blender/pointcache/alembic/abc_cloth.cpp
index 4fbc23d..ca54315 100644
--- a/source/blender/pointcache/intern/cloth.cpp
+++ b/source/blender/pointcache/alembic/abc_cloth.cpp
@@ -16,7 +16,9 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include "cloth.h"
+#include "alembic.h"
+
+#include "abc_cloth.h"
 
 extern "C" {
 #include "DNA_object_types.h"
@@ -30,57 +32,50 @@ namespace PTC {
 using namespace Abc;
 using namespace AbcGeom;
 
-ClothWriter::ClothWriter(Scene *scene, Object *ob, ClothModifierData *clmd) :
-    Writer(scene, &ob->id, clmd->point_cache),
-    m_ob(ob),
-    m_clmd(clmd)
+AbcClothWriter::AbcClothWriter(Scene *scene, Object *ob, ClothModifierData *clmd) :
+    ClothWriter(scene, ob, clmd, &m_archive),
+    m_archive(scene, &ob->id, clmd->point_cache, m_error_h

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list