71 const float spiral_start[3])
75 CLAMP(time, 0.0f, 1.0f);
87 const float b = shape * (1.0f +
sqrtf(5.0f)) /
float(
M_PI) * 0.25f;
92 float spiral_axis[3],
rot[3][3];
95 float theta = freq * time * 2.0f *
float(
M_PI);
96 float radius = amplitude *
expf(
b * theta);
99 if (amplitude < 0.0f) {
124 const float parent_orco[3],
135 const int totkeys = ctx->
segments + 1;
150 float spiral_start[3] = {0.0f, 0.0f, 0.0f};
151 float spiral_start_time = 0.0f;
152 float spiral_par_co[3] = {0.0f, 0.0f, 0.0f};
153 float spiral_par_vel[3] = {0.0f, 0.0f, 0.0f};
154 float spiral_par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f};
157 int start_index = 0, end_index = 0;
163 cut_time = (totkeys - 1) * ptex->
length;
166 for (k = 0, key = keys; k < totkeys - 1; k++, key++) {
167 if (
float(k + 1) >= cut_time) {
168 float fac = cut_time -
float(k);
172 end_index = start_index + extrakeys;
174 spiral_start_time = (
float(k) + fac) /
float(totkeys - 1);
194 modifier_ctx.
sim = &ctx->
sim;
195 modifier_ctx.
ptex = ptex;
196 modifier_ctx.
cpa = cpa;
197 modifier_ctx.
orco = orco;
200 for (k = 0, key = keys; k < end_index; k++, key++) {
202 float *par_co, *par_vel, *par_rot;
205 if (k < start_index) {
210 par_co = parent_keys[k].
co;
211 par_vel = parent_keys[k].
vel;
212 par_rot = parent_keys[k].
rot;
215 float spiral_time =
float(k - start_index) /
float(extrakeys - 1);
216 float kink[3], tmp[3];
219 par_time = spiral_start_time;
220 par_co = spiral_par_co;
221 par_vel = spiral_par_vel;
222 par_rot = spiral_par_rot;
228 if (kink_axis_random > 0.0f) {
229 float a = kink_axis_random * (
psys_frand(ctx->
sim.
psys, 7112 + seed) * 2.0f - 1.0f) *
248 modifier_ctx.
par_co = par_co;
249 modifier_ctx.
par_vel = par_vel;
250 modifier_ctx.
par_rot = par_rot;
251 modifier_ctx.
par_orco = parent_orco;
258 for (k = 0, key = keys; k < end_index - 1; k++, key++) {
262 *r_totkeys = end_index;
263 *r_max_length = totlen;
276 if (*cur_length + step_length > max_length) {
278 mul_v3_fl(dvec, (max_length - *cur_length) / step_length);
285 *cur_length += step_length;
290 ListBaseT<ModifierData> * ,
297 const float parent_orco[3])
312 ctx, ptex, parent_orco, cpa, orco, hairmat, keys, parent_keys, &totkeys, &max_length);
319 modifier_ctx.
sim = &ctx->
sim;
320 modifier_ctx.
ptex = ptex;
321 modifier_ctx.
cpa = cpa;
322 modifier_ctx.
orco = orco;
326 max_length = ptex->
length;
328 for (k = 0, key = keys; k < totkeys; k++, key++) {
338 modifier_ctx.
par_orco = parent_orco;
346 const float step_length = 1.0f /
float(totkeys - 1);
347 float cur_length = 0.0f;
349 if (max_length <= 0.0f) {
355 for (k = 0, key = keys; k < totkeys; k++, key++) {
361 if (use_length_check && k > 0) {
364 if (!
check_path_length(k, keys, key, max_length, step_length, &cur_length, dvec)) {
367 if (ma && draw_col_ma) {
373 if (k == totkeys - 1) {
378 if (ma && draw_col_ma) {
388 const float par_co[3],
389 const float par_vel[3],
390 const float par_rot[4],
398 const float obmat[4][4],
401 float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3];
402 float t, dt = 1.0f,
result[3];
408 CLAMP(time, 0.0f, 1.0f);
412 time =
pow(time, 1.0f + shape);
415 time =
pow(time, 1.0f / (1.0f - shape));
425 dt =
sinf(dt / 2.0f);
450 float curl_offset[3];
451 float q1[4] = {1.0f, 0.0f, 0.0f, 0.0f};
489 float y_vec[3] = {0.0f, 1.0f, 0.0f};
490 float z_vec[3] = {0.0f, 0.0f, 1.0f};
491 float vec_one[3], state_co[3];
492 float inp_y, inp_z,
length;
511 else if (inp_z > 0.0f) {
537 shape = 2.0f *
float(
M_PI) * (1.0f + shape);
562 const float par_co[3],
577 else if (clumpfac != 0.0f) {
580 if (clumppow < 0.0f) {
581 cpow = 1.0f + clumppow;
584 cpow = 1.0f + 9.0f * clumppow;
587 if (clumpfac < 0.0f) {
588 clump = -clumpfac * pa_clump *
float(
pow(1.0 -
double(time),
double(cpow)));
591 clump = clumpfac * pa_clump *
float(
pow(
double(time),
double(cpow)));
601 const float par_co[3],
603 const float orco_offset[3],
607 bool use_clump_noise,
608 float clump_noise_size,
613 if (use_clump_noise && clump_noise_size != 0.0f) {
614 float center[3], noisevec[3];
617 mul_v3_v3fl(noisevec, orco_offset, 1.0f / clump_noise_size);
626 state->co,
state->co, par_co, time, clumpfac, clumppow, pa_clump, clumpcurve);
632 const float mat[4][4],
643 if (
fabsf(
float(-1.5f + loc[0] + loc[1] + loc[2])) < 1.5f * thres) {
663 const float loc[3],
const float mat[4][4],
float t,
float fac,
float shape,
ParticleKey *
state)
668 roughfac = fac *
float(
pow(
double(t), shape));
670 rough[0] = -1.0f + 2.0f * rough[0];
671 rough[1] = -1.0f + 2.0f * rough[1];
679 const float mat[4][4],
720 const int index =
clamp_i(time * num_segments, 0, num_segments);
736 float integral = 0.0f;
742 integral +=
y *
step;
765 if (part->
twist == 0.0f) {
781 if (ptex !=
nullptr) {
784 if (twist_curve !=
nullptr) {
808 CurveMapping *clumpcurve =
nullptr, *roughcurve =
nullptr;
822 float rough1 = part->
rough1;
823 float rough2 = part->
rough2;
832 rough_end *= ptex->
roughe;
844 float orco_offset[3];
854 ptex ? ptex->
clump : 1.0f,
859 if (kink_freq != 0.0f) {
860 kink_amp *= (1.0f - kink_amp_clump * clump);
873 sim->
ob->object_to_world().ptr(),
892 if (rough_end > 0.0f) {
Object is a sort of wrapper for general info.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void psys_path_iter_get(ParticlePathIterator *iter, ParticleCacheKey *keys, int totkeys, ParticleCacheKey *parent, int index)
void mul_m3_v3(const float M[3][3], float r[3])
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
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)
void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx, float mat[4][4], ParticleKey *state, float t)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[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])
MINLINE void mul_v2_fl(float r[2], float f)
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)
MINLINE void copy_v2_v2(float r[2], const float a[2])
static int twist_num_segments(const ParticleChildModifierContext *modifier_ctx)
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
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 mul_qt_qtqt(float q[4], const float a[4], const float b[4])
static void do_rough_curve(const float loc[3], const float mat[4][4], float time, float fac, float size, CurveMapping *roughcurve, ParticleKey *state)
static void do_rough_end(const float loc[3], const float mat[4][4], float t, float fac, float shape, ParticleKey *state)
void psys_apply_child_modifiers(struct ParticleThreadContext *ctx, ListBaseT< ModifierData > *modifiers, struct ChildParticle *cpa, struct ParticleTexture *ptex, const float orco[3], float hairmat[4][4], struct ParticleCacheKey *keys, struct ParticleCacheKey *parent_keys, const float parent_orco[3])
MINLINE void mul_v3_fl(float r[3], float f)
static void twist_get_axis(const ParticleChildModifierContext *modifier_ctx, const float time, float r_axis[3])
static bool check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *key, float max_length, float step_length, float *cur_length, float dvec[3])
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
void mul_qt_v3(const float q[4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
static void do_rough(const float loc[3], const float mat[4][4], float t, float fac, float size, float thres, ParticleKey *state)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void copy_qt_qt(float q[4], const float a[4])
void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
@ PART_CHILD_USE_ROUGH_CURVE
@ PART_CHILD_USE_TWIST_CURVE
@ PART_CHILD_USE_CLUMP_NOISE
@ PART_CHILD_USE_CLUMP_CURVE
static void do_twist(const ParticleChildModifierContext *modifier_ctx, ParticleKey *state, const float time)
MINLINE void negate_v3(float r[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void zero_v3(float r[3])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
static float BKE_curvemapping_integrate_clamped(const CurveMapping *curve, float start, float end, float step)
MINLINE float normalize_v3(float n[3])
MINLINE void add_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])
BLI_INLINE void psys_frand_vec(ParticleSystem *psys, unsigned int seed, float vec[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)
bool do_guides(struct Depsgraph *depsgraph, struct ParticleSettings *part, ListBaseT< EffectorCache > *effectors, ParticleKey *state, int index, float time)
BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], float angle)
MINLINE int clamp_i(int value, int min, int max)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
void rotate_v3_v3v3fl(float r[3], const float p[3], const float axis[3], float angle)
MINLINE float clamp_f(float value, float min, float max)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ParticleCacheKey * parent_keys
ParticleSimulationData * sim
ParticleThreadContext * thread_ctx
ParticleCacheKey * parent_key
eParticleChildFlag child_flag
eParticleChildType childtype
eParticleDrawCol draw_col
struct CurveMapping * twistcurve
struct CurveMapping * clumpcurve
struct CurveMapping * roughcurve
struct Depsgraph * depsgraph
struct ParticleSystem * psys
struct ListBaseT< struct EffectorCache > * effectors
struct CurveMapping * clumpcurve
struct CurveMapping * roughcurve
struct CurveMapping * twistcurve
struct ParticleSimulationData sim