[Bf-blender-cvs] [307c4a4] master: Another crappy approach to spirals on hairs, crazy expensive though.
Lukas Tönne
noreply at git.blender.org
Tue Jan 20 09:53:32 CET 2015
Commit: 307c4a4df92cdde64b39e7fe28ab2db80355025f
Author: Lukas Tönne
Date: Tue Jan 13 17:24:20 2015 +0100
Branches: master
https://developer.blender.org/rB307c4a4df92cdde64b39e7fe28ab2db80355025f
Another crappy approach to spirals on hairs, crazy expensive though.
Conflicts:
source/blender/blenkernel/intern/particle.c
===================================================================
M release/scripts/startup/bl_ui/properties_particle.py
M source/blender/blenkernel/BKE_particle.h
M source/blender/blenkernel/intern/object_dupli.c
M source/blender/blenkernel/intern/particle.c
M source/blender/blenkernel/intern/particle_child.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/editors/object/object_modifier.c
M source/blender/editors/space_view3d/drawobject.c
M source/blender/makesdna/DNA_particle_types.h
M source/blender/makesrna/intern/rna_particle.c
M source/blender/render/intern/source/convertblender.c
M source/blender/render/intern/source/pointdensity.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index b5f9520..04ff156 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -1233,10 +1233,10 @@ class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
if part.kink in {'SPIRAL'}:
col = split.column()
col.prop(part, "kink_amplitude", text="Radius")
- col.prop(part, "kink_flat", text="Start", slider=True)
col = split.column(align=True)
col.prop(part, "kink_frequency", text="Frequency")
col.prop(part, "kink_shape", text="Shape", slider=True)
+ col.prop(part, "kink_extra_steps", text="Steps")
else:
col = split.column()
sub = col.column(align=True)
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 35e89ee..a2b283a 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -126,7 +126,7 @@ typedef struct ParticleCacheKey {
float rot[4];
float col[3];
float time;
- int steps;
+ int segments;
} ParticleCacheKey;
typedef struct ParticleThreadContext {
@@ -150,7 +150,7 @@ typedef struct ParticleThreadContext {
struct ParticleData *tpars;
/* path caching */
- int editupdate, between, steps;
+ int editupdate, between, segments, extra_segments;
int totchild, totparent, parent_pass;
float cfra;
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 2bee6b7..057f999 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -970,8 +970,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
/* some hair paths might be non-existent so they can't be used for duplication */
if (hair &&
- ((a < totpart && psys->pathcache[a]->steps < 0) ||
- (a >= totpart && psys->childcache[a - totpart]->steps < 0)))
+ ((a < totpart && psys->pathcache[a]->segments < 0) ||
+ (a >= totpart && psys->childcache[a - totpart]->segments < 0)))
{
continue;
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 3f8d694..15afd36 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -105,7 +105,7 @@ static void get_child_modifier_parameters(ParticleSettings *part, ParticleThread
ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex);
extern void do_child_modifiers(ParticleSimulationData *sim,
ParticleTexture *ptex, ParticleKey *par, float *par_rot, const float par_orco[3],
- ChildParticle *cpa, const float orco[3], float mat[4][4], ParticleKey *state, float t, float spiral_start[3], float *time_prev, float *co_prev);
+ ChildParticle *cpa, const float orco[3], float mat[4][4], ParticleKey *state, float t);
/* few helpers for countall etc. */
int count_particles(ParticleSystem *psys)
@@ -139,7 +139,7 @@ int count_particles_mod(ParticleSystem *psys, int totgr, int cur)
#define PATH_CACHE_BUF_SIZE 1024
-static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot, int steps)
+static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot, int totkeys)
{
LinkData *buf;
ParticleCacheKey **cache;
@@ -152,10 +152,10 @@ static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot,
while (totkey < tot) {
totbufkey = MIN2(tot - totkey, PATH_CACHE_BUF_SIZE);
buf = MEM_callocN(sizeof(LinkData), "PathCacheLinkData");
- buf->data = MEM_callocN(sizeof(ParticleCacheKey) * totbufkey * steps, "ParticleCacheKey");
+ buf->data = MEM_callocN(sizeof(ParticleCacheKey) * totbufkey * totkeys, "ParticleCacheKey");
for (i = 0; i < totbufkey; i++)
- cache[totkey + i] = ((ParticleCacheKey *)buf->data) + i * steps;
+ cache[totkey + i] = ((ParticleCacheKey *)buf->data) + i * totkeys;
totkey += totbufkey;
BLI_addtail(bufs, buf);
@@ -1139,9 +1139,9 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
ParticleCacheKey *cur = first;
/* scale the requested time to fit the entire path even if the path is cut early */
- t *= (first + first->steps)->time;
+ t *= (first + first->segments)->time;
- while (i < first->steps && cur->time < t)
+ while (i < first->segments && cur->time < t)
cur++;
if (cur->time == t)
@@ -1671,7 +1671,7 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int in
/************************************************/
extern void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, float flat,
- short type, short axis, float obmat[4][4], int smooth_start, float spiral_start[3], float *time_prev, float *co_prev);
+ short type, short axis, float obmat[4][4], int smooth_start);
extern float do_clump(ParticleKey *state, ParticleKey *par, float time, const float orco_offset[3], float clumpfac, float clumppow, float pa_clump,
bool use_clump_noise, float clump_noise_size, CurveMapping *clumpcurve);
@@ -1793,11 +1793,10 @@ int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, i
{
ParticleKey key, par;
float orco_offset[3] = {0.0f, 0.0f, 0.0f};
- float spiral_start[3], time_prev = 0.0f, co_prev[3] = {0,0,0};
par.co[0] = par.co[1] = par.co[2] = 0.0f;
copy_v3_v3(key.co, vec_to_point);
- do_kink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0, spiral_start, &time_prev, co_prev);
+ do_kink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0);
do_clump(&key, &par, guidetime, orco_offset, pd->clump_fac, pd->clump_pow, 1.0f,
part->child_flag & PART_CHILD_USE_CLUMP_NOISE, part->clump_noise_size, part->clumpcurve);
copy_v3_v3(vec_to_point, key.co);
@@ -1943,7 +1942,7 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSi
ParticleSystem *psys = sim->psys;
ParticleSettings *part = psys->part;
int totparent = 0, between = 0;
- int steps = 1 << part->draw_step;
+ int segments = 1 << part->draw_step;
int totchild = psys->totchild;
psys_thread_context_init(ctx, sim);
@@ -1955,7 +1954,7 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSi
if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0)
totchild = 0;
- steps = 1 << pset->draw_step;
+ segments = 1 << pset->draw_step;
}
if (totchild && part->childtype == PART_CHILD_FACES) {
@@ -1969,7 +1968,7 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSi
}
if (psys->renderdata)
- steps = (int)pow(2.0, (double)part->ren_step);
+ segments = 1 << part->ren_step;
else {
totchild = (int)((float)totchild * (float)part->disp / 100.0f);
totparent = MIN2(totparent, totchild);
@@ -1980,7 +1979,11 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSi
/* fill context values */
ctx->between = between;
- ctx->steps = steps;
+ ctx->segments = segments;
+ if (ELEM(part->kink, PART_KINK_SPIRAL))
+ ctx->extra_segments = max_ii(part->kink_extra_steps, 1);
+ else
+ ctx->extra_segments = 0;
ctx->totchild = totchild;
ctx->totparent = totparent;
ctx->parent_pass = 0;
@@ -2060,7 +2063,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
if (!needupdate)
return;
else
- memset(child_keys, 0, sizeof(*child_keys) * (ctx->steps + 1));
+ memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1));
}
/* get parent paths */
@@ -2083,14 +2086,14 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
if (part->flag & PART_CHILD_LONG_HAIR) {
/* For long hair use tip distance/root distance as parting factor instead of root to tip angle. */
float d1 = len_v3v3(key[0]->co, key[w]->co);
- float d2 = len_v3v3((key[0] + key[0]->steps - 1)->co, (key[w] + key[w]->steps - 1)->co);
+ float d2 = len_v3v3((key[0] + key[0]->segments - 1)->co, (key[w] + key[w]->segments - 1)->co);
d = d1 > 0.f ? d2 / d1 - 1.f : 10000.f;
}
else {
float v1[3], v2[3];
- sub_v3_v3v3(v1, (key[0] + key[0]->steps - 1)->co, key[0]->co);
- sub_v3_v3v3(v2, (key[w] + key[w]->steps - 1)->co, key[w]->co);
+ sub_v3_v3v3(v1, (key[0] + key[0]->segments - 1)->co, key[0]->co);
+ sub_v3_v3v3(v2, (key[w] + key[w]->segments - 1)->co, key[w]->co);
normalize_v3(v1);
normalize_v3(v2);
@@ -2138,7 +2141,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
if (!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC))
return;
- memset(child_keys, 0, sizeof(*child_keys) * (ctx->steps + 1));
+ memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1));
}
/* get the parent path */
@@ -2157,18 +2160,18 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat);
}
- child_keys->steps = ctx->steps;
+ child_keys->segments = ctx->segments;
/* get different child parameters from textures & vgroups */
get_child_modifier_parameters(part, ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex);
if (ptex.exist < psys_frand(psys, i + 24)) {
- child_keys->steps = -1;
+ child_keys->segments = -1;
return;
}
/* create the child path */
- for (k = 0, child = child_keys; k <= ctx->steps; k++, child++) {
+ for (k = 0, child = child_keys; k <= ctx->segments; k++, child++) {
if (ctx->between) {
int w = 0;
@@ -2186,7 +218
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list