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:
authorJanne Karhu <jhkarh@gmail.com>2011-01-09 22:09:41 +0300
committerJanne Karhu <jhkarh@gmail.com>2011-01-09 22:09:41 +0300
commit9231ff41604039ca55f1da4945a077cfab9e1e84 (patch)
treec9c29bb10aabaa44e8e683bab8d3ce7a06a39744 /source/blender/blenloader
parent84a464ab62e67eb21e12d0c3b0fad061c38d9e4a (diff)
Viscoelastic springs for sph particle fluids, original patch by Stephen Whitehorn (chickencoop)
* Viscoelastic springs between the fluid particles can simulate all kinds of viscous and elastic substances, such as jelly and honey. This is achieved by creating springs dynamically between neighboring particles and adjusting their rest length based on stretching/compression. * This nearly completes the currently intended functionality for particle fluids. The last missing thing is a surfacing extraction algorithm, which is needed for a proper representation of a sph fluid. * I also cleaned up and renamed some of the fluid parameters to make the ui a bit easier to understand. * One addition to the patch is an option to use "initial rest length" for the springs, which uses the lengths between the particles at the time of spring creation as the spring rest lengths instead of interaction radius/2. This makes the fluid keep it's original shape better (good for very viscoelastic materials), but can create large density differences inside the fluid (not really physically correct for a fluid). * Viscoelastic springs are stored in point cache as extra data.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c7
-rw-r--r--source/blender/blenloader/intern/writefile.c12
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index cc2b73d87f5..a86363cf7ad 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2929,6 +2929,7 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache)
{
if((cache->flag & PTCACHE_DISK_CACHE)==0) {
PTCacheMem *pm;
+ PTCacheExtra *extra;
int i;
link_list(fd, &cache->mem_cache);
@@ -2948,6 +2949,11 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache)
SWITCH_INT(poin[j]);
}
}
+
+ link_list(fd, &pm->extradata);
+
+ for(extra=pm->extradata.first; extra; extra=extra->next)
+ extra->data = newdataadr(fd, extra->data);
}
}
else
@@ -3156,6 +3162,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
pa->boid = NULL;
}
+ psys->fluid_springs = newdataadr(fd, psys->fluid_springs);
psys->child = newdataadr(fd,psys->child);
psys->effectors = NULL;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 8230050fc2f..fd8fb8ad8a6 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -780,6 +780,8 @@ static void write_pointcaches(WriteData *wd, ListBase *ptcaches)
PTCacheMem *pm = cache->mem_cache.first;
for(; pm; pm=pm->next) {
+ PTCacheExtra *extra = pm->extradata.first;
+
writestruct(wd, DATA, "PTCacheMem", 1, pm);
for(i=0; i<BPHYS_TOT_DATA; i++) {
@@ -790,6 +792,13 @@ static void write_pointcaches(WriteData *wd, ListBase *ptcaches)
writestruct(wd, DATA, ptcache_datastruct[i], pm->totpoint, pm->data[i]);
}
}
+
+ for(; extra; extra=extra->next) {
+ if(strcmp(ptcache_extra_datastruct[extra->type], "")==0)
+ continue;
+ writestruct(wd, DATA, "PTCacheExtra", 1, extra);
+ writestruct(wd, DATA, ptcache_extra_datastruct[extra->type], extra->totdata, extra->data);
+ }
}
}
}
@@ -850,6 +859,9 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
if(psys->particles->boid && psys->part->phystype == PART_PHYS_BOIDS)
writestruct(wd, DATA, "BoidParticle", psys->totpart, psys->particles->boid);
+
+ if(psys->part->fluid && psys->part->phystype == PART_PHYS_FLUID && (psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS))
+ writestruct(wd, DATA, "ParticleSpring", psys->tot_fluidsprings, psys->fluid_springs);
}
pt = psys->targets.first;
for(; pt; pt=pt->next)