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:
authorLukas Tönne <lukas.toenne@gmail.com>2015-03-05 15:43:31 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-03-26 16:12:48 +0300
commit38b0940a5472404e04f0c2475e911bd98ca6cc71 (patch)
tree9d85d1ebbc02d80899788a8e83b9a08a403a6c2e /source/blender
parent15e3298d54b393f9f95d721a3e143069d946c734 (diff)
Use a combined class for hair dynamics for cloth and mesh data.
Particles store a copy of the DM internally as the emitter.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/cache_library.c4
-rw-r--r--source/blender/pointcache/PTC_api.cpp20
-rw-r--r--source/blender/pointcache/PTC_api.h5
-rw-r--r--source/blender/pointcache/alembic/abc_cloth.h19
-rw-r--r--source/blender/pointcache/alembic/abc_particles.cpp51
-rw-r--r--source/blender/pointcache/alembic/abc_particles.h33
-rw-r--r--source/blender/pointcache/alembic/alembic.cpp20
-rw-r--r--source/blender/pointcache/intern/ptc_types.h4
8 files changed, 111 insertions, 45 deletions
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index fd843d4fa90..585c0f0b7e8 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -719,7 +719,7 @@ void BKE_cache_library_writers(CacheLibrary *cachelib, Scene *scene, DerivedMesh
case CACHE_TYPE_HAIR: {
ParticleSystem *psys = (ParticleSystem *)BLI_findlink(&item->ob->particlesystem, item->index);
if (psys && psys->part && psys->part->type == PART_HAIR && psys->clmd) {
- cachelib_add_writer(writers, item, PTC_writer_hair_dynamics(name, item->ob, psys->clmd));
+ cachelib_add_writer(writers, item, PTC_writer_hair_dynamics(name, item->ob, psys));
}
break;
}
@@ -812,7 +812,7 @@ static struct PTCReader *cache_library_reader_hair_dynamics(CacheLibrary *cachel
char name[2*MAX_NAME];
BKE_cache_item_name(ob, CACHE_TYPE_HAIR, index, name);
- return PTC_reader_hair_dynamics(name, ob, psys->clmd);
+ return PTC_reader_hair_dynamics(name, ob, psys);
}
return NULL;
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 2d3878225de..5da526820d6 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -244,16 +244,6 @@ PTCReader *PTC_reader_cloth(const char *name, Object *ob, ClothModifierData *clm
return (PTCReader *)PTC::Factory::alembic->create_reader_cloth(name, ob, clmd);
}
-PTCWriter *PTC_writer_hair_dynamics(const char *name, Object *ob, ClothModifierData *clmd)
-{
- return (PTCWriter *)PTC::Factory::alembic->create_writer_hair_dynamics(name, ob, clmd);
-}
-
-PTCReader *PTC_reader_hair_dynamics(const char *name, Object *ob, ClothModifierData *clmd)
-{
- return (PTCReader *)PTC::Factory::alembic->create_reader_hair_dynamics(name, ob, clmd);
-}
-
/* ==== MESH ==== */
@@ -318,6 +308,16 @@ int PTC_reader_particles_totpoint(PTCReader *_reader)
return ((PTC::ParticlesReader *)_reader)->totpoint();
}
+PTCWriter *PTC_writer_hair_dynamics(const char *name, Object *ob, ParticleSystem *psys)
+{
+ return (PTCWriter *)PTC::Factory::alembic->create_writer_hair_dynamics(name, ob, psys);
+}
+
+PTCReader *PTC_reader_hair_dynamics(const char *name, Object *ob, ParticleSystem *psys)
+{
+ return (PTCReader *)PTC::Factory::alembic->create_reader_hair_dynamics(name, ob, psys);
+}
+
PTCWriter *PTC_writer_particles_pathcache_parents(const char *name, Object *ob, ParticleSystem *psys)
{
return (PTCWriter *)PTC::Factory::alembic->create_writer_particles_pathcache_parents(name, ob, psys);
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index e57a528ae6e..5afa6519cf3 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -92,6 +92,9 @@ struct PTCWriter *PTC_writer_particles(const char *name, struct Object *ob, stru
struct PTCReader *PTC_reader_particles(const char *name, struct Object *ob, struct ParticleSystem *psys);
int PTC_reader_particles_totpoint(struct PTCReader *reader);
+struct PTCWriter *PTC_writer_hair_dynamics(const char *name, struct Object *ob, struct ParticleSystem *psys);
+struct PTCReader *PTC_reader_hair_dynamics(const char *name, struct Object *ob, struct ParticleSystem *psys);
+
struct PTCWriter *PTC_writer_particles_pathcache_parents(const char *name, struct Object *ob, struct ParticleSystem *psys);
struct PTCReader *PTC_reader_particles_pathcache_parents(const char *name, struct Object *ob, struct ParticleSystem *psys);
struct PTCWriter *PTC_writer_particles_pathcache_children(const char *name, struct Object *ob, struct ParticleSystem *psys);
@@ -100,8 +103,6 @@ struct PTCReader *PTC_reader_particles_pathcache_children(const char *name, stru
/* Cloth */
struct PTCWriter *PTC_writer_cloth(const char *name, struct Object *ob, struct ClothModifierData *clmd);
struct PTCReader *PTC_reader_cloth(const char *name, struct Object *ob, struct ClothModifierData *clmd);
-struct PTCWriter *PTC_writer_hair_dynamics(const char *name, struct Object *ob, struct ClothModifierData *clmd);
-struct PTCReader *PTC_reader_hair_dynamics(const char *name, struct Object *ob, struct ClothModifierData *clmd);
struct PTCWriter *PTC_writer_derived_mesh(const char *name, struct Object *ob, struct DerivedMesh **dm_ptr);
struct PTCReader *PTC_reader_derived_mesh(const char *name, struct Object *ob);
diff --git a/source/blender/pointcache/alembic/abc_cloth.h b/source/blender/pointcache/alembic/abc_cloth.h
index 9b4d2ed9707..947f49aa8ce 100644
--- a/source/blender/pointcache/alembic/abc_cloth.h
+++ b/source/blender/pointcache/alembic/abc_cloth.h
@@ -63,25 +63,6 @@ private:
AbcGeom::IP3fGeomParam m_param_goal_positions;
};
-
-/* Hair is just a cloth sim in disguise ... */
-
-class AbcHairDynamicsWriter : public AbcClothWriter {
-public:
- AbcHairDynamicsWriter(const std::string &name, Object *ob, ClothModifierData *clmd) :
- AbcClothWriter(name, ob, clmd)
- {}
-};
-
-class AbcHairDynamicsReader : public AbcClothReader {
-public:
- AbcHairDynamicsReader(const std::string &name, Object *ob, ClothModifierData *clmd) :
- AbcClothReader(name, ob, clmd)
- {}
-
- PTCReadSampleResult read_sample(float frame) { return AbcClothReader::read_sample(frame); }
-};
-
} /* namespace PTC */
#endif /* PTC_CLOTH_H */
diff --git a/source/blender/pointcache/alembic/abc_particles.cpp b/source/blender/pointcache/alembic/abc_particles.cpp
index 6dcbbb5bbc9..ac9ea7124a1 100644
--- a/source/blender/pointcache/alembic/abc_particles.cpp
+++ b/source/blender/pointcache/alembic/abc_particles.cpp
@@ -17,11 +17,13 @@
*/
#include "abc_cloth.h"
+#include "abc_mesh.h"
#include "abc_particles.h"
extern "C" {
#include "BLI_math.h"
+#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
@@ -131,6 +133,55 @@ PTCReadSampleResult AbcParticlesReader::read_sample(float frame)
}
+AbcHairDynamicsWriter::AbcHairDynamicsWriter(const std::string &name, Object *ob, ParticleSystem *psys) :
+ ParticlesWriter(ob, psys, name),
+ m_dm_writer(name+"__mesh", ob, &psys_get_modifier(ob, psys)->dm),
+ m_cloth_writer(name+"__cloth", ob, psys->clmd)
+{
+}
+
+void AbcHairDynamicsWriter::open_archive(WriterArchive *archive)
+{
+ m_dm_writer.open_archive(archive);
+ m_cloth_writer.open_archive(archive);
+}
+
+void AbcHairDynamicsWriter::write_sample()
+{
+ m_dm_writer.write_sample();
+ m_cloth_writer.write_sample();
+}
+
+AbcHairDynamicsReader::AbcHairDynamicsReader(const std::string &name, Object *ob, ParticleSystem *psys) :
+ ParticlesReader(ob, psys, name),
+ m_dm_reader(name+"__mesh", ob),
+ m_cloth_reader(name+"__cloth", ob, psys->clmd)
+{
+}
+
+void AbcHairDynamicsReader::open_archive(ReaderArchive *archive)
+{
+ m_dm_reader.open_archive(archive);
+ m_cloth_reader.open_archive(archive);
+}
+
+PTCReadSampleResult AbcHairDynamicsReader::read_sample(float frame)
+{
+ if (m_dm_reader.read_sample(frame) == PTC_READ_SAMPLE_INVALID)
+ return PTC_READ_SAMPLE_INVALID;
+
+ ParticleSystemModifierData *psmd = psys_get_modifier(m_ob, m_psys);
+ if (psmd->dm)
+ psmd->dm->release(psmd->dm);
+ psmd->dm = m_dm_reader.acquire_result();
+
+ if (m_cloth_reader.read_sample(frame) == PTC_READ_SAMPLE_INVALID)
+ return PTC_READ_SAMPLE_INVALID;
+
+ return PTC_READ_SAMPLE_EXACT;
+}
+
+
AbcParticlePathcacheWriter::AbcParticlePathcacheWriter(const std::string &name, Object *ob, ParticleSystem *psys, ParticleCacheKey ***pathcache, int *totpath, const std::string &suffix) :
ParticlesWriter(ob, psys, name),
m_pathcache(pathcache),
diff --git a/source/blender/pointcache/alembic/abc_particles.h b/source/blender/pointcache/alembic/abc_particles.h
index 5e624e6c388..968ff7a2505 100644
--- a/source/blender/pointcache/alembic/abc_particles.h
+++ b/source/blender/pointcache/alembic/abc_particles.h
@@ -39,6 +39,9 @@ struct ParticleCacheKey;
namespace PTC {
class AbcClothWriter;
+class AbcClothReader;
+class AbcDerivedMeshWriter;
+class AbcDerivedMeshReader;
class AbcParticlesWriter : public ParticlesWriter, public AbcWriter {
public:
@@ -66,6 +69,36 @@ private:
AbcGeom::IPoints m_points;
};
+
+/* Hair is just a cloth sim in disguise ... */
+
+class AbcHairDynamicsWriter : public ParticlesWriter, public AbcWriter {
+public:
+ AbcHairDynamicsWriter(const std::string &name, Object *ob, ParticleSystem *psys);
+
+ void open_archive(WriterArchive *archive);
+
+ void write_sample();
+
+private:
+ AbcDerivedMeshWriter m_dm_writer;
+ AbcClothWriter m_cloth_writer;
+};
+
+class AbcHairDynamicsReader : public ParticlesReader, public AbcReader {
+public:
+ AbcHairDynamicsReader(const std::string &name, Object *ob, ParticleSystem *psys);
+
+ void open_archive(ReaderArchive *archive);
+
+ PTCReadSampleResult read_sample(float frame);
+
+private:
+ AbcDerivedMeshReader m_dm_reader;
+ AbcClothReader m_cloth_reader;
+};
+
+
class AbcParticlePathcacheWriter : public ParticlesWriter, public AbcWriter {
protected:
AbcParticlePathcacheWriter(const std::string &name, Object *ob, ParticleSystem *psys, ParticleCacheKey ***pathcache, int *totpath, const std::string &suffix);
diff --git a/source/blender/pointcache/alembic/alembic.cpp b/source/blender/pointcache/alembic/alembic.cpp
index 38ff9a7f730..d14a86ec9d7 100644
--- a/source/blender/pointcache/alembic/alembic.cpp
+++ b/source/blender/pointcache/alembic/alembic.cpp
@@ -56,6 +56,16 @@ class AbcFactory : public Factory {
return new AbcParticlesReader(name, ob, psys);
}
+ Writer *create_writer_hair_dynamics(const std::string &name, Object *ob, ParticleSystem *psys)
+ {
+ return new AbcHairDynamicsWriter(name, ob, psys);
+ }
+
+ Reader *create_reader_hair_dynamics(const std::string &name, Object *ob, ParticleSystem *psys)
+ {
+ return new AbcHairDynamicsReader(name, ob, psys);
+ }
+
Writer *create_writer_particles_pathcache_parents(const std::string &name, Object *ob, ParticleSystem *psys)
{
return new AbcParticlePathcacheParentsWriter(name, ob, psys);
@@ -88,16 +98,6 @@ class AbcFactory : public Factory {
return new AbcClothReader(name, ob, clmd);
}
- Writer *create_writer_hair_dynamics(const std::string &name, Object *ob, ClothModifierData *clmd)
- {
- return new AbcHairDynamicsWriter(name, ob, clmd);
- }
-
- Reader *create_reader_hair_dynamics(const std::string &name, Object *ob, ClothModifierData *clmd)
- {
- return new AbcHairDynamicsReader(name, ob, clmd);
- }
-
/* Modifier Stack */
Writer *create_writer_derived_mesh(const std::string &name, Object *ob, DerivedMesh **dm_ptr)
{
diff --git a/source/blender/pointcache/intern/ptc_types.h b/source/blender/pointcache/intern/ptc_types.h
index 42f4ca95d00..37dc5f2f33d 100644
--- a/source/blender/pointcache/intern/ptc_types.h
+++ b/source/blender/pointcache/intern/ptc_types.h
@@ -148,6 +148,8 @@ struct Factory {
/* Particles */
virtual Writer *create_writer_particles(const std::string &name, Object *ob, ParticleSystem *psys) = 0;
virtual Reader *create_reader_particles(const std::string &name, Object *ob, ParticleSystem *psys) = 0;
+ virtual Writer *create_writer_hair_dynamics(const std::string &name, Object *ob, ParticleSystem *psys) = 0;
+ virtual Reader *create_reader_hair_dynamics(const std::string &name, Object *ob, ParticleSystem *psys) = 0;
virtual Writer *create_writer_particles_pathcache_parents(const std::string &name, Object *ob, ParticleSystem *psys) = 0;
virtual Reader *create_reader_particles_pathcache_parents(const std::string &name, Object *ob, ParticleSystem *psys) = 0;
virtual Writer *create_writer_particles_pathcache_children(const std::string &name, Object *ob, ParticleSystem *psys) = 0;
@@ -156,8 +158,6 @@ struct Factory {
/* 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;
- virtual Writer *create_writer_hair_dynamics(const std::string &name, Object *ob, ClothModifierData *clmd) = 0;
- virtual Reader *create_reader_hair_dynamics(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;