Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/pointcache/intern')
-rw-r--r--source/blender/pointcache/intern/alembic.h72
-rw-r--r--source/blender/pointcache/intern/export.cpp76
-rw-r--r--source/blender/pointcache/intern/export.h57
-rw-r--r--source/blender/pointcache/intern/ptc_types.cpp42
-rw-r--r--source/blender/pointcache/intern/ptc_types.h276
-rw-r--r--source/blender/pointcache/intern/reader.cpp55
-rw-r--r--source/blender/pointcache/intern/reader.h75
-rw-r--r--source/blender/pointcache/intern/thread.h31
-rw-r--r--source/blender/pointcache/intern/writer.cpp54
-rw-r--r--source/blender/pointcache/intern/writer.h61
10 files changed, 799 insertions, 0 deletions
diff --git a/source/blender/pointcache/intern/alembic.h b/source/blender/pointcache/intern/alembic.h
new file mode 100644
index 00000000000..79341566afc
--- /dev/null
+++ b/source/blender/pointcache/intern/alembic.h
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+#ifndef PTC_ALEMBIC_H
+#define PTC_ALEMBIC_H
+
+#include "reader.h"
+#include "writer.h"
+
+#include "PTC_api.h"
+
+struct Object;
+struct ClothModifierData;
+struct DynamicPaintSurface;
+struct PointCacheModifierData;
+struct DerivedMesh;
+struct ParticleSystem;
+struct RigidBodyWorld;
+struct SmokeDomainSettings;
+struct SoftBody;
+
+namespace PTC {
+
+/* Particles */
+Writer *abc_writer_particles(Scene *scene, Object *ob, ParticleSystem *psys);
+Reader *abc_reader_particles(Scene *scene, Object *ob, ParticleSystem *psys);
+//Writer *abc_writer_particle_paths(Scene *scene, Object *ob, ParticleSystem *psys);
+Reader *abc_reader_particle_paths(Scene *scene, Object *ob, ParticleSystem *psys, eParticlePathsMode mode);
+Writer *abc_writer_particle_combined(Scene *scene, Object *ob, ParticleSystem *psys);
+
+/* Cloth */
+Writer *abc_writer_cloth(Scene *scene, Object *ob, ClothModifierData *clmd);
+Reader *abc_reader_cloth(Scene *scene, Object *ob, ClothModifierData *clmd);
+
+/* SoftBody */
+Writer *abc_writer_softbody(Scene *scene, Object *ob, SoftBody *softbody);
+Reader *abc_reader_softbody(Scene *scene, Object *ob, SoftBody *softbody);
+
+/* Rigid Bodies */
+Writer *abc_writer_rigidbody(Scene *scene, RigidBodyWorld *rbw);
+Reader *abc_reader_rigidbody(Scene *scene, RigidBodyWorld *rbw);
+
+/* Smoke */
+Writer *abc_writer_smoke(Scene *scene, Object *ob, SmokeDomainSettings *domain);
+Reader *abc_reader_smoke(Scene *scene, Object *ob, SmokeDomainSettings *domain);
+
+/* Dynamic Paint */
+Writer *abc_writer_dynamicpaint(Scene *scene, Object *ob, DynamicPaintSurface *surface);
+Reader *abc_reader_dynamicpaint(Scene *scene, Object *ob, DynamicPaintSurface *surface);
+
+/* Modifier Stack */
+Writer *abc_writer_point_cache(Scene *scene, Object *ob, PointCacheModifierData *pcmd);
+Reader *abc_reader_point_cache(Scene *scene, Object *ob, PointCacheModifierData *pcmd);
+
+} /* namespace PTC */
+
+#endif /* PTC_EXPORT_H */
diff --git a/source/blender/pointcache/intern/export.cpp b/source/blender/pointcache/intern/export.cpp
new file mode 100644
index 00000000000..b7df49666a7
--- /dev/null
+++ b/source/blender/pointcache/intern/export.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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 "export.h"
+#include "writer.h"
+
+extern "C" {
+#include "DNA_scene_types.h"
+
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_scene.h"
+}
+
+namespace PTC {
+
+Exporter::Exporter(Main *bmain, Scene *scene, EvaluationContext *evalctx, short *stop, short *do_update, float *progress) :
+ m_bmain(bmain),
+ m_scene(scene),
+ m_evalctx(evalctx),
+ m_stop(stop),
+ m_do_update(do_update),
+ m_progress(progress)
+{
+}
+
+void Exporter::bake(Writer *writer, int start_frame, int end_frame)
+{
+// thread_scoped_lock(m_mutex);
+
+ set_progress(0.0f);
+
+ for (int cfra = start_frame; cfra <= end_frame; ++cfra) {
+ m_scene->r.cfra = cfra;
+ BKE_scene_update_for_newframe(m_evalctx, m_bmain, m_scene, m_scene->lay);
+
+ if (writer)
+ writer->write_sample();
+
+ set_progress((float)(cfra - start_frame + 1) / (float)(end_frame - start_frame + 1));
+
+ if (stop())
+ break;
+ }
+}
+
+bool Exporter::stop() const
+{
+ if (*m_stop)
+ return true;
+
+ return (G.is_break);
+}
+
+void Exporter::set_progress(float progress)
+{
+ *m_do_update = 1;
+ *m_progress = progress;
+}
+
+} /* namespace PTC */
diff --git a/source/blender/pointcache/intern/export.h b/source/blender/pointcache/intern/export.h
new file mode 100644
index 00000000000..34736b2e649
--- /dev/null
+++ b/source/blender/pointcache/intern/export.h
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+#ifndef PTC_EXPORT_H
+#define PTC_EXPORT_H
+
+#include "thread.h"
+
+struct Main;
+struct Scene;
+struct EvaluationContext;
+
+namespace PTC {
+
+class Writer;
+
+class Exporter
+{
+public:
+ Exporter(Main *bmain, Scene *scene, EvaluationContext *evalctx, short *stop, short *do_update, float *progress);
+
+ void bake(Writer *writer, int start_frame, int end_frame);
+
+ bool stop() const;
+
+ void set_progress(float progress);
+
+private:
+ thread_mutex m_mutex;
+
+ Main *m_bmain;
+ Scene *m_scene;
+ EvaluationContext *m_evalctx;
+
+ short *m_stop;
+ short *m_do_update;
+ float *m_progress;
+};
+
+} /* namespace PTC */
+
+#endif /* PTC_EXPORT_H */
diff --git a/source/blender/pointcache/intern/ptc_types.cpp b/source/blender/pointcache/intern/ptc_types.cpp
new file mode 100644
index 00000000000..3a012429586
--- /dev/null
+++ b/source/blender/pointcache/intern/ptc_types.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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_types.h"
+
+extern "C" {
+#include "BKE_DerivedMesh.h"
+}
+
+namespace PTC {
+
+DerivedMesh *PointCacheReader::acquire_result()
+{
+ DerivedMesh *dm = m_result;
+ m_result = NULL;
+ return dm;
+}
+
+void PointCacheReader::discard_result()
+{
+ if (m_result) {
+ m_result->release(m_result);
+ m_result = NULL;
+ }
+}
+
+} /* namespace PTC */
diff --git a/source/blender/pointcache/intern/ptc_types.h b/source/blender/pointcache/intern/ptc_types.h
new file mode 100644
index 00000000000..e81c052185d
--- /dev/null
+++ b/source/blender/pointcache/intern/ptc_types.h
@@ -0,0 +1,276 @@
+/*
+ * 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.
+ */
+
+#ifndef PTC_TYPES_H
+#define PTC_TYPES_H
+
+#include "reader.h"
+#include "writer.h"
+
+extern "C" {
+#include "DNA_dynamicpaint_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
+#include "DNA_particle_types.h"
+#include "DNA_rigidbody_types.h"
+#include "DNA_smoke_types.h"
+}
+
+namespace PTC {
+
+class ClothWriter : public Writer {
+public:
+ ClothWriter(Scene *scene, Object *ob, ClothModifierData *clmd, WriterArchive *archive) :
+ Writer(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_clmd(clmd)
+ {}
+
+ ~ClothWriter()
+ {}
+
+protected:
+ Object *m_ob;
+ ClothModifierData *m_clmd;
+};
+
+class ClothReader : public Reader {
+public:
+ ClothReader(Scene *scene, Object *ob, ClothModifierData *clmd, ReaderArchive *archive) :
+ Reader(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_clmd(clmd)
+ {}
+
+ ~ClothReader()
+ {}
+
+protected:
+ Object *m_ob;
+ ClothModifierData *m_clmd;
+};
+
+
+class DynamicPaintWriter : public Writer {
+public:
+ DynamicPaintWriter(Scene *scene, Object *ob, DynamicPaintSurface *surface, WriterArchive *archive) :
+ Writer(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_surface(surface)
+ {}
+
+ ~DynamicPaintWriter()
+ {}
+
+protected:
+ Object *m_ob;
+ DynamicPaintSurface *m_surface;
+};
+
+class DynamicPaintReader : public Reader {
+public:
+ DynamicPaintReader(Scene *scene, Object *ob, DynamicPaintSurface *surface, ReaderArchive *archive) :
+ Reader(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_surface(surface)
+ {}
+
+ ~DynamicPaintReader()
+ {}
+
+protected:
+ Object *m_ob;
+ DynamicPaintSurface *m_surface;
+};
+
+
+class PointCacheWriter : public Writer {
+public:
+ PointCacheWriter(Scene *scene, Object *ob, PointCacheModifierData *pcmd, WriterArchive *archive) :
+ Writer(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_pcmd(pcmd)
+ {}
+
+ ~PointCacheWriter()
+ {}
+
+protected:
+ Object *m_ob;
+ PointCacheModifierData *m_pcmd;
+};
+
+class PointCacheReader : public Reader {
+public:
+ PointCacheReader(Scene *scene, Object *ob, PointCacheModifierData *pcmd, ReaderArchive *archive) :
+ Reader(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_pcmd(pcmd),
+ m_result(0)
+ {}
+
+ ~PointCacheReader()
+ {}
+
+ virtual DerivedMesh *acquire_result();
+ virtual void discard_result();
+
+protected:
+ Object *m_ob;
+ PointCacheModifierData *m_pcmd;
+
+ DerivedMesh *m_result;
+};
+
+
+class ParticlesWriter : public Writer {
+public:
+ ParticlesWriter(Scene *scene, Object *ob, ParticleSystem *psys, WriterArchive *archive) :
+ Writer(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_psys(psys)
+ {}
+
+ ~ParticlesWriter()
+ {}
+
+protected:
+ Object *m_ob;
+ ParticleSystem *m_psys;
+};
+
+class ParticlesReader : public Reader {
+public:
+ ParticlesReader(Scene *scene, Object *ob, ParticleSystem *psys, ReaderArchive *archive) :
+ Reader(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_psys(psys),
+ m_totpoint(0)
+ {}
+
+ ~ParticlesReader()
+ {}
+
+ int totpoint() const { return m_totpoint; }
+
+protected:
+ Object *m_ob;
+ ParticleSystem *m_psys;
+
+ int m_totpoint;
+};
+
+
+class RigidBodyWriter : public Writer {
+public:
+ RigidBodyWriter(Scene *scene, RigidBodyWorld *rbw, WriterArchive *archive) :
+ Writer(scene, (ID *)scene, archive),
+ m_rbw(rbw)
+ {}
+
+ ~RigidBodyWriter()
+ {}
+
+protected:
+ RigidBodyWorld *m_rbw;
+};
+
+class RigidBodyReader : public Reader {
+public:
+ RigidBodyReader(Scene *scene, RigidBodyWorld *rbw, ReaderArchive *archive) :
+ Reader(scene, (ID *)scene, archive),
+ m_rbw(rbw)
+ {}
+
+ ~RigidBodyReader()
+ {}
+
+protected:
+ RigidBodyWorld *m_rbw;
+};
+
+
+class SmokeWriter : public Writer {
+public:
+ SmokeWriter(Scene *scene, Object *ob, SmokeDomainSettings *domain, WriterArchive *archive) :
+ Writer(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_domain(domain)
+ {}
+
+ ~SmokeWriter()
+ {}
+
+protected:
+ Object *m_ob;
+ SmokeDomainSettings *m_domain;
+};
+
+class SmokeReader : public Reader {
+public:
+ SmokeReader(Scene *scene, Object *ob, SmokeDomainSettings *domain, ReaderArchive *archive) :
+ Reader(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_domain(domain)
+ {}
+
+ ~SmokeReader()
+ {}
+
+protected:
+ Object *m_ob;
+ SmokeDomainSettings *m_domain;
+};
+
+
+class SoftBodyWriter : public Writer {
+public:
+ SoftBodyWriter(Scene *scene, Object *ob, SoftBody *softbody, WriterArchive *archive) :
+ Writer(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_softbody(softbody)
+ {}
+
+ ~SoftBodyWriter()
+ {}
+
+protected:
+ Object *m_ob;
+ SoftBody *m_softbody;
+};
+
+class SoftBodyReader : public Reader {
+public:
+ SoftBodyReader(Scene *scene, Object *ob, SoftBody *softbody, ReaderArchive *archive) :
+ Reader(scene, (ID *)ob, archive),
+ m_ob(ob),
+ m_softbody(softbody)
+ {}
+
+ ~SoftBodyReader()
+ {}
+
+protected:
+ Object *m_ob;
+ SoftBody *m_softbody;
+};
+
+} /* namespace PTC */
+
+#endif /* PTC_EXPORT_H */
diff --git a/source/blender/pointcache/intern/reader.cpp b/source/blender/pointcache/intern/reader.cpp
new file mode 100644
index 00000000000..829e4eb807d
--- /dev/null
+++ b/source/blender/pointcache/intern/reader.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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 "reader.h"
+#include "util_error_handler.h"
+
+extern "C" {
+#include "DNA_scene_types.h"
+}
+
+namespace PTC {
+
+Reader::Reader(Scene *scene, ID *id, ReaderArchive *archive) :
+ m_error_handler(0),
+ m_archive(archive),
+ m_scene(scene),
+ m_id(id)
+{
+}
+
+Reader::~Reader()
+{
+ if (m_error_handler)
+ delete m_error_handler;
+}
+
+void Reader::set_error_handler(ErrorHandler *handler)
+{
+ if (m_error_handler)
+ delete m_error_handler;
+
+ m_error_handler = handler;
+}
+
+bool Reader::valid() const
+{
+ return m_error_handler ? m_error_handler->max_error_level() >= PTC_ERROR_CRITICAL : true;
+}
+
+} /* namespace PTC */
diff --git a/source/blender/pointcache/intern/reader.h b/source/blender/pointcache/intern/reader.h
new file mode 100644
index 00000000000..1c89c0c9b42
--- /dev/null
+++ b/source/blender/pointcache/intern/reader.h
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+#ifndef PTC_READER_H
+#define PTC_READER_H
+
+#include <string>
+
+#include "util_error_handler.h"
+#include "util_types.h"
+
+struct ID;
+struct Scene;
+
+namespace PTC {
+
+class ReaderArchive {
+public:
+ virtual ~ReaderArchive() {}
+
+ virtual bool get_frame_range(int &start_frame, int &end_frame) = 0;
+
+ virtual PTCReadSampleResult test_sample(float frame) = 0;
+};
+
+class Reader {
+public:
+ Reader(Scene *scene, ID *id, ReaderArchive *archive);
+ virtual ~Reader();
+
+ void set_error_handler(ErrorHandler *handler);
+ ErrorHandler *get_error_handler() const { return m_error_handler; }
+ bool valid() const;
+
+ inline bool get_frame_range(int &start_frame, int &end_frame)
+ {
+ return m_archive->get_frame_range(start_frame, end_frame);
+ }
+
+ inline PTCReadSampleResult test_sample(float frame)
+ {
+ return m_archive->test_sample(frame);
+ }
+
+ virtual PTCReadSampleResult read_sample(float frame) = 0;
+
+ Scene *scene() const { return m_scene; }
+ ID *id() const { return m_id; }
+
+protected:
+ ErrorHandler *m_error_handler;
+ ReaderArchive *m_archive;
+
+ Scene *m_scene;
+ ID *m_id;
+};
+
+} /* namespace PTC */
+
+#endif /* PTC_READER_H */
diff --git a/source/blender/pointcache/intern/thread.h b/source/blender/pointcache/intern/thread.h
new file mode 100644
index 00000000000..229c0f54f59
--- /dev/null
+++ b/source/blender/pointcache/intern/thread.h
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+#ifndef PTC_THREAD_H
+#define PTC_THREAD_H
+
+#include <boost/thread.hpp>
+
+namespace PTC {
+
+typedef boost::mutex thread_mutex;
+typedef boost::mutex::scoped_lock thread_scoped_lock;
+
+} /* namespace PTC */
+
+#endif /* PTC_THREAD_H */
diff --git a/source/blender/pointcache/intern/writer.cpp b/source/blender/pointcache/intern/writer.cpp
new file mode 100644
index 00000000000..cbdee4234d7
--- /dev/null
+++ b/source/blender/pointcache/intern/writer.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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 "writer.h"
+
+extern "C" {
+#include "DNA_scene_types.h"
+}
+
+namespace PTC {
+
+Writer::Writer(Scene *scene, ID *id, WriterArchive *archive) :
+ m_error_handler(0),
+ m_scene(scene),
+ m_id(id),
+ m_archive(archive)
+{
+}
+
+Writer::~Writer()
+{
+ if (m_error_handler)
+ delete m_error_handler;
+}
+
+void Writer::set_error_handler(ErrorHandler *handler)
+{
+ if (m_error_handler)
+ delete m_error_handler;
+
+ m_error_handler = handler;
+}
+
+bool Writer::valid() const
+{
+ return m_error_handler ? m_error_handler->max_error_level() >= PTC_ERROR_CRITICAL : true;
+}
+
+} /* namespace PTC */
diff --git a/source/blender/pointcache/intern/writer.h b/source/blender/pointcache/intern/writer.h
new file mode 100644
index 00000000000..69ad2a69c24
--- /dev/null
+++ b/source/blender/pointcache/intern/writer.h
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+#ifndef PTC_WRITER_H
+#define PTC_WRITER_H
+
+#include <string>
+
+#include "util_error_handler.h"
+
+struct ID;
+struct Scene;
+
+namespace PTC {
+
+class WriterArchive {
+public:
+ virtual ~WriterArchive() {}
+};
+
+class Writer {
+public:
+ Writer(Scene *scene, ID *id, WriterArchive *archive);
+ virtual ~Writer();
+
+ void set_error_handler(ErrorHandler *handler);
+ bool valid() const;
+
+ virtual void write_sample() = 0;
+
+ Scene *scene() const { return m_scene; }
+ ID *id() const { return m_id; }
+
+protected:
+ ErrorHandler *m_error_handler;
+
+ Scene *m_scene;
+ ID *m_id;
+
+private:
+ WriterArchive *m_archive;
+};
+
+} /* namespace PTC */
+
+#endif /* PTC_WRITER_H */