diff options
Diffstat (limited to 'source/blender/pointcache/intern')
-rw-r--r-- | source/blender/pointcache/intern/ptc_types.cpp | 44 | ||||
-rw-r--r-- | source/blender/pointcache/intern/ptc_types.h | 237 | ||||
-rw-r--r-- | source/blender/pointcache/intern/reader.cpp | 57 | ||||
-rw-r--r-- | source/blender/pointcache/intern/reader.h | 69 | ||||
-rw-r--r-- | source/blender/pointcache/intern/writer.cpp | 56 | ||||
-rw-r--r-- | source/blender/pointcache/intern/writer.h | 59 |
6 files changed, 522 insertions, 0 deletions
diff --git a/source/blender/pointcache/intern/ptc_types.cpp b/source/blender/pointcache/intern/ptc_types.cpp new file mode 100644 index 00000000000..f2df356ca5b --- /dev/null +++ b/source/blender/pointcache/intern/ptc_types.cpp @@ -0,0 +1,44 @@ +/* + * 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 { + +Factory *Factory::alembic = NULL; + +DerivedMesh *DerivedMeshReader::acquire_result() +{ + DerivedMesh *dm = m_result; + m_result = NULL; + return dm; +} + +void DerivedMeshReader::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..c9e63d7abb6 --- /dev/null +++ b/source/blender/pointcache/intern/ptc_types.h @@ -0,0 +1,237 @@ +/* + * 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_group_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_types.h" +#include "DNA_object_force.h" +#include "DNA_particle_types.h" +} + +struct CacheLibrary; +struct IDProperty; + +namespace PTC { + +class ClothWriter { +public: + ClothWriter(Object *ob, ClothModifierData *clmd, const std::string &name) : + m_ob(ob), + m_clmd(clmd), + m_name(name) + {} + + ~ClothWriter() + {} + +protected: + Object *m_ob; + ClothModifierData *m_clmd; + std::string m_name; +}; + +class ClothReader { +public: + ClothReader(Object *ob, ClothModifierData *clmd, const std::string &name) : + m_ob(ob), + m_clmd(clmd), + m_name(name) + {} + + ~ClothReader() + {} + +protected: + Object *m_ob; + ClothModifierData *m_clmd; + std::string m_name; +}; + + +class DerivedMeshWriter { +public: + /** \note Targeted DerivedMesh at \a dm_ptr must be available only on \fn write_sample calls */ + DerivedMeshWriter(Object *ob, DerivedMesh **dm_ptr, const std::string &name) : + m_ob(ob), + m_dm_ptr(dm_ptr), + m_name(name) + {} + + ~DerivedMeshWriter() + {} + +protected: + Object *m_ob; + DerivedMesh **m_dm_ptr; + std::string m_name; +}; + +class DerivedMeshReader { +public: + DerivedMeshReader(Object *ob, const std::string &name) : + m_ob(ob), + m_result(0), + m_name(name) + {} + + ~DerivedMeshReader() + { + discard_result(); + } + + DerivedMesh *acquire_result(); + void discard_result(); + +protected: + Object *m_ob; + DerivedMesh *m_result; + std::string m_name; +}; + +class GroupWriter { +public: + GroupWriter(Group *group, const std::string &name) : + m_group(group), + m_name(name) + {} + +protected: + Group *m_group; + std::string m_name; +}; + +class GroupReader { +public: + GroupReader(Group *group, const std::string &name) : + m_group(group), + m_name(name) + {} + +protected: + Group *m_group; + std::string m_name; +}; + +class ObjectWriter { +public: + ObjectWriter(Object *ob, const std::string &name) : + m_ob(ob), + m_name(name) + {} + +protected: + Object *m_ob; + std::string m_name; +}; + +class ObjectReader { +public: + ObjectReader(Object *ob, const std::string &name) : + m_ob(ob), + m_name(name) + {} + +protected: + Object *m_ob; + std::string m_name; +}; + +class ParticlesWriter { +public: + ParticlesWriter(Object *ob, ParticleSystem *psys, const std::string &name) : + m_ob(ob), + m_psys(psys), + m_name(name) + {} + + ~ParticlesWriter() + {} + +protected: + Object *m_ob; + ParticleSystem *m_psys; + std::string m_name; +}; + +class ParticlesReader { +public: + ParticlesReader(Object *ob, ParticleSystem *psys, const std::string &name) : + m_ob(ob), + m_psys(psys), + m_name(name), + m_totpoint(0) + {} + + ~ParticlesReader() + {} + + int totpoint() const { return m_totpoint; } + +protected: + Object *m_ob; + ParticleSystem *m_psys; + std::string m_name; + + int m_totpoint; +}; + +struct Factory { + virtual const std::string &get_default_extension() = 0; + virtual WriterArchive *open_writer_archive(double fps, float start_frame, const std::string &name, PTCArchiveResolution resolutions, + const char *app_name, const char *description, const struct tm *time, struct IDProperty *metadata, ErrorHandler *error_handler) = 0; + virtual ReaderArchive *open_reader_archive(double fps, float start_frame, const std::string &name, ErrorHandler *error_handler) = 0; + + virtual void slice(ReaderArchive *in, WriterArchive *out, float start_frame, float end_frame) = 0; + + virtual Writer *create_writer_object(const std::string &name, Scene *scene, Object *ob) = 0; + virtual Reader *create_reader_object(const std::string &name, Object *ob) = 0; + + virtual Writer *create_writer_group(const std::string &name, Group *group) = 0; + virtual Reader *create_reader_group(const std::string &name, Group *group) = 0; + + /* Cloth */ + virtual Writer *create_writer_cloth(const std::string &name, Object *ob, ClothModifierData *clmd) = 0; + virtual Reader *create_reader_cloth(const std::string &name, Object *ob, ClothModifierData *clmd) = 0; + + /* Modifier Stack */ + virtual Writer *create_writer_derived_mesh(const std::string &name, Object *ob, DerivedMesh **dm_ptr) = 0; + virtual Reader *create_reader_derived_mesh(const std::string &name, Object *ob) = 0; + + virtual Writer *create_writer_derived_final_realtime(const std::string &name, Object *ob) = 0; + virtual Writer *create_writer_derived_final_render(const std::string &name, Scene *scene, Object *ob, DerivedMesh **render_dm_ptr) = 0; + + virtual Writer *create_writer_dupligroup(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group, CacheLibrary *cachelib) = 0; + virtual Writer *create_writer_duplicache(const std::string &name, Group *group, DupliCache *dupcache, int datatypes, bool do_sim_debug) = 0; + virtual Reader *create_reader_duplicache(const std::string &name, Group *group, DupliCache *dupcache, + bool read_strands_motion, bool read_strands_children, bool read_sim_debug) = 0; + virtual Reader *create_reader_duplicache_object(const std::string &name, Object *ob, DupliObjectData *data, + bool read_strands_motion, bool read_strands_children) = 0; + + static Factory *alembic; +}; + +} /* 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..56b0f54e982 --- /dev/null +++ b/source/blender/pointcache/intern/reader.cpp @@ -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. + */ + +#include "reader.h" +#include "util_error_handler.h" + +extern "C" { +#include "DNA_scene_types.h" +} + +namespace PTC { + +Reader::Reader() : + m_error_handler(0) +{ +} + +Reader::Reader(ErrorHandler *error_handler) : + m_error_handler(error_handler) +{ +} + +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..39d0ab20197 --- /dev/null +++ b/source/blender/pointcache/intern/reader.h @@ -0,0 +1,69 @@ +/* + * 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" +#include "PTC_api.h" + +struct ID; +struct IDProperty; +struct CacheArchiveInfo; + +namespace PTC { + +class ReaderArchive { +public: + virtual ~ReaderArchive() {} + + virtual PTCArchiveResolution get_resolutions() = 0; + virtual void use_render(bool enable) = 0; + + virtual bool get_frame_range(int &start_frame, int &end_frame) = 0; + virtual void get_info_stream(void (*stream)(void *, const char *), void *userdata) = 0; + virtual void get_info(CacheArchiveInfo *info, IDProperty *metadata) = 0; + virtual void get_info_nodes(CacheArchiveInfo *info, bool calc_bytes_size) = 0; +}; + +class Reader { +public: + Reader(); + Reader(ErrorHandler *error_handler); + virtual ~Reader(); + + virtual void init(ReaderArchive *archive) = 0; + + void set_error_handler(ErrorHandler *handler); + ErrorHandler *get_error_handler() const { return m_error_handler; } + bool valid() const; + + virtual bool get_frame_range(int &start_frame, int &end_frame) = 0; + virtual PTCReadSampleResult test_sample(float frame) = 0; + virtual PTCReadSampleResult read_sample(float frame) = 0; + +protected: + ErrorHandler *m_error_handler; +}; + +} /* namespace PTC */ + +#endif /* PTC_READER_H */ diff --git a/source/blender/pointcache/intern/writer.cpp b/source/blender/pointcache/intern/writer.cpp new file mode 100644 index 00000000000..97a6b9ad405 --- /dev/null +++ b/source/blender/pointcache/intern/writer.cpp @@ -0,0 +1,56 @@ +/* + * 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() : + m_error_handler(0) +{ +} + +Writer::Writer(ErrorHandler *handler) : + m_error_handler(handler) +{ +} + +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..008c391bffc --- /dev/null +++ b/source/blender/pointcache/intern/writer.h @@ -0,0 +1,59 @@ +/* + * 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; + +namespace PTC { + +class WriterArchive { +public: + virtual ~WriterArchive() {} + + virtual void use_render(bool enable) = 0; +}; + +class Writer { +public: + Writer(); + Writer(ErrorHandler *handler); + virtual ~Writer(); + + void set_error_handler(ErrorHandler *handler); + bool valid() const; + + virtual void init(WriterArchive *archive) = 0; + + /* create references to other objects */ + virtual void create_refs() {} + + virtual void write_sample() = 0; + +protected: + ErrorHandler *m_error_handler; +}; + +} /* namespace PTC */ + +#endif /* PTC_WRITER_H */ |