41 iter->
key = keys + index;
69 const float spiral_start[3])
73 CLAMP(time, 0.0f, 1.0f);
85 const float b = shape * (1.0f +
sqrtf(5.0f)) /
float(
M_PI) * 0.25f;
90 float spiral_axis[3],
rot[3][3];
93 float theta = freq * time * 2.0f *
float(
M_PI);
94 float radius = amplitude *
expf(
b * theta);
97 if (amplitude < 0.0f) {
122 const float parent_orco[3],
133 const int totkeys = ctx->
segments + 1;
136 float kink_amp_random = part->kink_amp_random;
137 float kink_amp = part->kink_amp *
139 float kink_freq = part->kink_freq;
140 float kink_shape = part->kink_shape;
141 float kink_axis_random = part->kink_axis_random;
148 float spiral_start[3] = {0.0f, 0.0f, 0.0f};
149 float spiral_start_time = 0.0f;
150 float spiral_par_co[3] = {0.0f, 0.0f, 0.0f};
151 float spiral_par_vel[3] = {0.0f, 0.0f, 0.0f};
152 float spiral_par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f};
155 int start_index = 0, end_index = 0;
161 cut_time = (totkeys - 1) * ptex->
length;
164 for (k = 0, key = keys; k < totkeys - 1; k++, key++) {
165 if (
float(k + 1) >= cut_time) {
166 float fac = cut_time -
float(k);
170 end_index = start_index + extrakeys;
172 spiral_start_time = (
float(k) + fac) /
float(totkeys - 1);
186 kink_base[part->kink_axis] = 1.0f;
192 modifier_ctx.
sim = &ctx->
sim;
193 modifier_ctx.
ptex = ptex;
194 modifier_ctx.
cpa = cpa;
195 modifier_ctx.
orco = orco;
198 for (k = 0, key = keys; k < end_index; k++, key++) {
200 float *par_co, *par_vel, *par_rot;
203 if (k < start_index) {
208 par_co = parent_keys[k].
co;
209 par_vel = parent_keys[k].
vel;
210 par_rot = parent_keys[k].
rot;
213 float spiral_time =
float(k - start_index) /
float(extrakeys - 1);
214 float kink[3], tmp[3];
217 par_time = spiral_start_time;
218 par_co = spiral_par_co;
219 par_vel = spiral_par_vel;
220 par_rot = spiral_par_rot;
226 if (kink_axis_random > 0.0f) {
246 modifier_ctx.
par_co = par_co;
247 modifier_ctx.
par_vel = par_vel;
248 modifier_ctx.
par_rot = par_rot;
249 modifier_ctx.
par_orco = parent_orco;
256 for (k = 0, key = keys; k < end_index - 1; k++, key++) {
260 *r_totkeys = end_index;
261 *r_max_length = totlen;
274 if (*cur_length + step_length > max_length) {
276 mul_v3_fl(dvec, (max_length - *cur_length) / step_length);
283 *cur_length += step_length;
295 const float parent_orco[3])
310 ctx, ptex, parent_orco, cpa, orco, hairmat, keys, parent_keys, &totkeys, &max_length);
317 modifier_ctx.
sim = &ctx->
sim;
318 modifier_ctx.
ptex = ptex;
319 modifier_ctx.
cpa = cpa;
320 modifier_ctx.
orco = orco;
324 max_length = ptex->
length;
326 for (k = 0, key = keys; k < totkeys; k++, key++) {
336 modifier_ctx.
par_orco = parent_orco;
344 const float step_length = 1.0f /
float(totkeys - 1);
345 float cur_length = 0.0f;
347 if (max_length <= 0.0f) {
353 for (k = 0, key = keys; k < totkeys; k++, key++) {
359 if (use_length_check && k > 0) {
362 if (!
check_path_length(k, keys, key, max_length, step_length, &cur_length, dvec)) {
365 if (ma && draw_col_ma) {
371 if (k == totkeys - 1) {
376 if (ma && draw_col_ma) {
386 const float par_co[3],
387 const float par_vel[3],
388 const float par_rot[4],
396 const float obmat[4][4],
399 float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3];
400 float t, dt = 1.0f, result[3];
406 CLAMP(time, 0.0f, 1.0f);
410 time =
float(
pow(time, 1.0f + shape));
413 time =
float(
pow(time, 1.0f / (1.0f - shape)));
423 dt =
sinf(dt / 2.0f);
448 float curl_offset[3];
449 float q1[4] = {1.0f, 0.0f, 0.0f, 0.0f};
487 float y_vec[3] = {0.0f, 1.0f, 0.0f};
488 float z_vec[3] = {0.0f, 0.0f, 1.0f};
489 float vec_one[3], state_co[3];
490 float inp_y, inp_z,
length;
509 else if (inp_z > 0.0f) {
529 mul_v3_fl(par_vec, std::min(length, amplitude / 2.0f));
535 shape = 2.0f *
float(
M_PI) * (1.0f + shape);
560 const float par_co[3],
575 else if (clumpfac != 0.0f) {
578 if (clumppow < 0.0f) {
579 cpow = 1.0f + clumppow;
582 cpow = 1.0f + 9.0f * clumppow;
585 if (clumpfac < 0.0f) {
586 clump = -clumpfac * pa_clump *
float(
pow(1.0 -
double(time),
double(cpow)));
589 clump = clumpfac * pa_clump *
float(
pow(
double(time),
double(cpow)));
599 const float par_co[3],
601 const float orco_offset[3],
605 bool use_clump_noise,
606 float clump_noise_size,
611 if (use_clump_noise && clump_noise_size != 0.0f) {
612 float center[3], noisevec[3];
615 mul_v3_v3fl(noisevec, orco_offset, 1.0f / clump_noise_size);
624 state->co,
state->co, par_co, time, clumpfac, clumppow, pa_clump, clumpcurve);
630 const float mat[4][4],
641 if (
fabsf(
float(-1.5f + loc[0] + loc[1] + loc[2])) < 1.5f * thres) {
661 const float loc[3],
const float mat[4][4],
float t,
float fac,
float shape,
ParticleKey *
state)
666 roughfac = fac *
float(
pow(
double(t), shape));
668 rough[0] = -1.0f + 2.0f * rough[0];
669 rough[1] = -1.0f + 2.0f * rough[1];
677 const float mat[4][4],
718 const int index =
clamp_i(time * num_segments, 0, num_segments);
734 float integral = 0.0f;
740 integral += y * step;
763 if (part->twist == 0.0f) {
772 twist_curve = (thread_ctx !=
nullptr) ? thread_ctx->
twistcurve : part->twistcurve;
778 float angle = part->twist;
779 if (ptex !=
nullptr) {
780 angle *= (ptex->
twist - 0.5f) * 2.0f;
782 if (twist_curve !=
nullptr) {
806 CurveMapping *clumpcurve =
nullptr, *roughcurve =
nullptr;
811 clumpcurve = (ctx !=
nullptr) ? ctx->
clumpcurve : part->clumpcurve;
814 roughcurve = (ctx !=
nullptr) ? ctx->
roughcurve : part->roughcurve;
817 float kink_amp = part->kink_amp;
818 float kink_amp_clump = part->kink_amp_clump;
819 float kink_freq = part->kink_freq;
820 float rough1 = part->rough1;
821 float rough2 = part->rough2;
822 float rough_end = part->rough_end;
830 rough_end *= ptex->
roughe;
846 float orco_offset[3];
856 ptex ? ptex->
clump : 1.0f,
858 part->clump_noise_size,
861 if (kink_freq != 0.0f) {
862 kink_amp *= (1.0f - kink_amp_clump * clump);
875 sim->
ob->object_to_world().ptr(),
891 do_rough(vec, mat, t, rough2, part->rough2_size, part->rough2_thres,
state);
894 if (rough_end > 0.0f) {
bool do_guides(struct Depsgraph *depsgraph, struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int index, float time)
BLI_INLINE void psys_frand_vec(ParticleSystem *psys, unsigned int seed, float vec[3])
BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
MINLINE float clamp_f(float value, float min, float max)
MINLINE int clamp_i(int value, int min, int max)
void mul_m3_v3(const float M[3][3], float r[3])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], float angle)
void mul_qt_v3(const float q[4], float r[3])
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
void copy_qt_qt(float q[4], const float a[4])
void rotate_v3_v3v3fl(float r[3], const float p[3], const float axis[3], float angle)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
Object is a sort of wrapper for general info.
@ PART_CHILD_USE_TWIST_CURVE
@ PART_CHILD_USE_CLUMP_CURVE
@ PART_CHILD_USE_CLUMP_NOISE
@ PART_CHILD_USE_ROUGH_CURVE
static unsigned long seed
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
local_group_size(16, 16) .push_constant(Type b
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
static void do_twist(const ParticleChildModifierContext *modifier_ctx, ParticleKey *state, const float time)
float do_clump(ParticleKey *state, const float par_co[3], float time, const float orco_offset[3], float clumpfac, float clumppow, float pa_clump, bool use_clump_noise, float clump_noise_size, const CurveMapping *clumpcurve)
static bool check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *key, float max_length, float step_length, float *cur_length, float dvec[3])
static void do_kink_spiral_deform(ParticleKey *state, const float dir[3], const float kink[3], float time, float freq, float shape, float amplitude, const float spiral_start[3])
static float BKE_curvemapping_integrate_clamped(const CurveMapping *curve, float start, float end, float step)
void psys_apply_child_modifiers(ParticleThreadContext *ctx, ListBase *, ChildParticle *cpa, ParticleTexture *ptex, const float orco[3], float hairmat[4][4], ParticleCacheKey *keys, ParticleCacheKey *parent_keys, const float parent_orco[3])
static void do_kink_spiral(ParticleThreadContext *ctx, ParticleTexture *ptex, const float parent_orco[3], ChildParticle *cpa, const float orco[3], float hairmat[4][4], ParticleCacheKey *keys, ParticleCacheKey *parent_keys, int *r_totkeys, float *r_max_length)
static void do_rough_end(const float loc[3], const float mat[4][4], float t, float fac, float shape, ParticleKey *state)
static void twist_get_axis(const ParticleChildModifierContext *modifier_ctx, const float time, float r_axis[3])
static float do_clump_level(float result[3], const float co[3], const float par_co[3], float time, float clumpfac, float clumppow, float pa_clump, const CurveMapping *clumpcurve)
static void do_rough(const float loc[3], const float mat[4][4], float t, float fac, float size, float thres, ParticleKey *state)
static void psys_path_iter_get(ParticlePathIterator *iter, ParticleCacheKey *keys, int totkeys, ParticleCacheKey *parent, int index)
static int twist_num_segments(const ParticleChildModifierContext *modifier_ctx)
void do_kink(ParticleKey *state, const float par_co[3], const float par_vel[3], const float par_rot[4], float time, float freq, float shape, float amplitude, float flat, short type, short axis, const float obmat[4][4], int smooth_start)
void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx, float mat[4][4], ParticleKey *state, float t)
static void do_rough_curve(const float loc[3], const float mat[4][4], float time, float fac, float size, CurveMapping *roughcurve, ParticleKey *state)
ParticleThreadContext * thread_ctx
ParticleCacheKey * parent_keys
ParticleSimulationData * sim
ParticleCacheKey * parent_key
struct Depsgraph * depsgraph
struct ParticleSystem * psys
struct ListBase * effectors
struct CurveMapping * roughcurve
struct CurveMapping * twistcurve
struct CurveMapping * clumpcurve
struct ParticleSimulationData sim