[Bf-blender-cvs] [6d94c2f] gooseberry: Cache API for export/import of Blender data to/from Alembic files.
Lukas Tönne
noreply at git.blender.org
Mon Mar 23 13:00:29 CET 2015
Commit: 6d94c2f57ad635aae65c3b279dd436880d46be12
Author: Lukas Tönne
Date: Mon Mar 23 11:53:56 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB6d94c2f57ad635aae65c3b279dd436880d46be12
Cache API for export/import of Blender data to/from Alembic files.
The pointcache API is designed to keep the general concept of caching
separate from the concrete Alembic implementation. Other types of file
export/import would be possible, e.g. for OpenVDB data.
===================================================================
M build_files/cmake/macros.cmake
M source/blender/CMakeLists.txt
M source/blender/SConscript
M source/blender/blenkernel/CMakeLists.txt
M source/blender/blenkernel/SConscript
M source/blender/modifiers/CMakeLists.txt
M source/blender/modifiers/SConscript
A source/blender/pointcache/CMakeLists.txt
A source/blender/pointcache/PTC_api.cpp
A source/blender/pointcache/PTC_api.h
A source/blender/pointcache/SConscript
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
A source/blender/pointcache/intern/export.cpp
A source/blender/pointcache/intern/export.h
A source/blender/pointcache/intern/ptc_types.cpp
A source/blender/pointcache/intern/ptc_types.h
A source/blender/pointcache/intern/reader.cpp
A source/blender/pointcache/intern/reader.h
A source/blender/pointcache/intern/thread.h
A source/blender/pointcache/intern/writer.cpp
A source/blender/pointcache/intern/writer.h
A source/blender/pointcache/util/util_error_handler.cpp
A source/blender/pointcache/util/util_error_handler.h
A source/blender/pointcache/util/util_path.cpp
A source/blender/pointcache/util/util_path.h
A source/blender/pointcache/util/util_types.h
M source/blender/windowmanager/WM_api.h
===================================================================
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 17a1b60..fa29ba3 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -566,6 +566,8 @@ macro(SETUP_BLENDER_SORTED_LIBS)
ge_videotex
bf_dna
bf_blenfont
+ bf_pointcache
+ bf_pointcache_alembic
bf_intern_audaspace
bf_intern_mikktspace
bf_intern_dualcon
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index bdea88e..ed62b0b 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -109,6 +109,7 @@ add_subdirectory(gpu)
add_subdirectory(imbuf)
add_subdirectory(nodes)
add_subdirectory(modifiers)
+add_subdirectory(pointcache)
add_subdirectory(makesdna)
add_subdirectory(makesrna)
diff --git a/source/blender/SConscript b/source/blender/SConscript
index 64eca6a..a0ad457 100644
--- a/source/blender/SConscript
+++ b/source/blender/SConscript
@@ -43,7 +43,8 @@ SConscript(['avi/SConscript',
'ikplugin/SConscript',
'physics/SConscript',
'windowmanager/SConscript',
- 'blenfont/SConscript'])
+ 'blenfont/SConscript',
+ 'pointcache/SConscript'])
makesrna = SConscript('makesrna/SConscript')
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 6265298..04cda82 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -37,6 +37,7 @@ set(INC
../modifiers
../nodes
../physics
+ ../pointcache
../render/extern/include
../../../intern/ghost
../../../intern/guardedalloc
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index 47bba5f..8c5d245 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -66,6 +66,7 @@ incs = [
'../modifiers',
'../nodes',
'../physics',
+ '../pointcache',
'../render/extern/include',
'../windowmanager',
env['BF_ZLIB_INC'],
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 57e927f..6a05c40 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -33,6 +33,7 @@ set(INC
../makesdna
../makesrna
../bmesh
+ ../pointcache
../render/extern/include
../../../intern/elbeem/extern
../../../intern/guardedalloc
diff --git a/source/blender/modifiers/SConscript b/source/blender/modifiers/SConscript
index b4c8299..7087b59 100644
--- a/source/blender/modifiers/SConscript
+++ b/source/blender/modifiers/SConscript
@@ -44,6 +44,7 @@ incs = [
'../makesrna',
'../blenkernel',
'../gpu',
+ '../pointcache',
env['BF_ZLIB_INC'],
]
diff --git a/source/blender/pointcache/CMakeLists.txt b/source/blender/pointcache/CMakeLists.txt
new file mode 100644
index 0000000..ed8a69c
--- /dev/null
+++ b/source/blender/pointcache/CMakeLists.txt
@@ -0,0 +1,65 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2013, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ .
+ intern
+ util
+ ../blenkernel
+ ../blenlib
+ ../makesdna
+ ../makesrna
+ ../../../intern/guardedalloc
+)
+
+set(INC_SYS
+)
+
+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_path.h
+ util/util_path.cpp
+ util/util_types.h
+
+ PTC_api.h
+ PTC_api.cpp
+)
+
+if(WITH_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
new file mode 100644
index 0000000..6e3eda4
--- /dev/null
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -0,0 +1,403 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "PTC_api.h"
+
+#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"
+
+#include "DNA_modifier_types.h"
+
+#include "BKE_modifier.h"
+#include "BKE_report.h"
+
+#include "RNA_access.h"
+}
+
+using namespace PTC;
+
+void PTC_error_handler_std(void)
+{
+ ErrorHandler::clear_default_handler();
+}
+
+void PTC_error_handler_callback(PTCErrorCallback cb, void *userdata)
+{
+ ErrorHandler::set_default_handler(new CallbackErrorHandler(cb, userdata));
+}
+
+static ReportType report_type_from_error_level(PTCErrorLevel level)
+{
+ switch (level) {
+ case PTC_ERROR_NONE: return RPT_DEBUG;
+ case PTC_ERROR_INFO: return RPT_INFO;
+ case PTC_ERROR_WARNING: return RPT_WARNING;
+ case PTC_ERROR_CRITICAL: return RPT_ERROR;
+ }
+ return RPT_ERROR;
+}
+
+static void error_handler_reports_cb(void *vreports, PTCErrorLevel level, const char *message)
+{
+ ReportList *reports = (ReportList *)vreports;
+
+ BKE_report(reports, report_type_from_error_level(level), message);
+}
+
+void PTC_error_handler_reports(struct ReportList *reports)
+{
+ ErrorHandler::set_default_handler(new CallbackErrorHandler(error_handler_reports_cb, reports));
+}
+
+static void error_handler_modifier_cb(void *vmd, PTCErrorLevel UNUSED(level), const char *message)
+{
+ ModifierData *md = (ModifierData *)vmd;
+
+ modifier_setError(md, "%s", message);
+}
+
+void PTC_error_handler_modifier(struct ModifierData *md)
+{
+ ErrorHandler::set_default_handler(new CallbackErrorHandler(error_handler_modifier_cb, md));
+}
+
+
+void PTC_writer_free(PTCWriter *_writer)
+{
+ PTC::Writer *writer = (PTC::Writer *)_writer;
+ delete writer;
+}
+
+void PTC_write_sample(struct PTCWriter *_writer)
+{
+ PTC::Writer *writer = (PTC::Writer *)_writer;
+ writer->write_sample();
+}
+
+void PTC_bake(struct Main *bmain, struct Scene *scene, struct EvaluationContext *evalctx, struct PTCWriter *_writer, int start_frame, int end_frame,
+ short *stop, short *do_update, float *progress)
+{
+ PTC::Writer *writer = (PTC::Writer *)_writer;
+ PTC::Exporter exporter(bmain, scene, evalctx, stop, do_update, progress);
+ exporter.bake(writer, start_frame, end_frame);
+}
+
+
+void PTC_reader_free(PTCReader *_reader)
+{
+ PTC::Reader *reader = (PTC::Reader *)_reader;
+ delete reader;
+}
+
+bool PTC_reader_get_frame_range(PTCReader *_reader, int *start_frame, int *end_frame)
+{
+ PTC::Reader *reader = (PTC::Reader *)_reader;
+ int sfra, efra;
+ if (reader->get_frame_range(sfra, efra)) {
+ if (start_frame) *start_frame = sfra;
+ if (end_frame) *end_frame = efra;
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+PTCReadSampleResult PTC_read_sample(PTCReader *_reader, float frame)
+{
+ PTC::Reader *reader = (PTC::Reader *)_reader;
+ return reader->read_sample(frame);
+}
+
+PTCReadSampleResult PTC_test_sample(PTCReader *_reader, float frame)
+{
+ PTC::Reader *reader = (PTC::Reader *)_reader;
+ return reader->test_sample(frame);
+}
+
+/* get writer/reader from RNA type */
+PTCWriter *PTC_writer_from_rna(Scene *scene, PointerRNA *ptr)
+{
+ if (RNA_struct_is_a(ptr->type, &RNA_ParticleSystem)) {
+ Object *ob = (Object *)ptr->id.data;
+ ParticleSystem *psys = (ParticleSystem *)ptr->data;
+ return PTC_writer_particles_combined(scene, ob, psys);
+ }
+ if (RNA_struct_is_a(ptr->type, &RNA_ClothModifier)) {
+ Object *ob = (Object *)ptr->id.data;
+ ClothModifierData *clmd = (ClothModifierData *)ptr->data;
+ return PTC_writer_cloth(scene, ob, clmd);
+ }
+ if (RNA_struct_is_a(ptr->type, &RNA_SoftBodySettings)) {
+ Object *ob = (Object *)ptr->id.data;
+ SoftBody *softbody = (SoftBody *)ptr->data;
+ return PTC_writer_softbody(scene, ob, softbody);
+ }
+ if (RNA_struct_is_a(ptr->type, &RNA_RigidBodyWorld)) {
+ BLI_assert((Scene *)ptr->id.data == scene);
+ RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
+ return PTC_writer_rigidbody(scene, rbw);
+ }
+ if (RNA_struct_is_a(ptr->type, &RNA_SmokeDomainSettings)) {
+ Object *ob = (Object *)ptr->id.data;
+ SmokeDomainSettings *domain = (SmokeDomainSettings *)ptr->data;
+ return PTC_writer_smoke(scene, ob, domain);
+ }
+ if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) {
+ Object *ob = (Object *)ptr->id.data;
+ DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
+ return PTC_writer_dynamicpaint(scene, ob, surface);
+ }
+#if 0 /* modifier uses internal writer during scene update */
+ if (RNA_struct_is_a(ptr->type, &RNA_PointCacheModifier)) {
+ Object *ob = (Object *)ptr->id.data;
+ PointCacheModifierData *pcmd = (PointCacheMod
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list