void mdhim_options_set_db_paths(struct mdhim_options_t* opts, char **paths, int num_paths) { int i = 0; int ret; int verified_paths = -1; if (num_paths <= 0) { return; } opts->db_paths = malloc(sizeof(char *) * num_paths); for (i = 0; i < num_paths; i++) { if (!paths[i]) { continue; } ret = check_path_length(opts, paths[i]); if (!ret) { continue; } if (!i) { set_manifest_path(opts, paths[i]); } verified_paths++; opts->db_paths[verified_paths] = malloc(strlen(paths[i]) + 1); sprintf(opts->db_paths[verified_paths], "%s", paths[i]); } opts->num_paths = ++verified_paths; };
void mdhim_options_set_db_path(mdhim_options_t* opts, char *path) { int ret; if (!path) { return; } ret = check_path_length(opts, path); if (ret) { opts->db_path = path; set_manifest_path(opts, path); } };
void psys_apply_child_modifiers(ParticleThreadContext *ctx, struct ListBase *modifiers, ChildParticle *cpa, ParticleTexture *ptex, const float orco[3], const float ornor[3], float hairmat[4][4], ParticleCacheKey *keys, ParticleCacheKey *parent_keys, const float parent_orco[3]) { struct ParticleSettings *part = ctx->sim.psys->part; struct Material *ma = ctx->ma; const bool draw_col_ma = (part->draw_col == PART_DRAW_COL_MAT); const bool use_length_check = !ELEM(part->kink, PART_KINK_SPIRAL); ParticlePathModifier *mod; ParticleCacheKey *key; int totkeys, k; float max_length; #if 0 /* TODO for the future: use true particle modifiers that work on the whole curve */ for (mod = modifiers->first; mod; mod = mod->next) { mod->apply(keys, totkeys, parent_keys); } #else (void)modifiers; (void)mod; if (part->kink == PART_KINK_SPIRAL) { do_kink_spiral(ctx, ptex, parent_orco, cpa, orco, hairmat, keys, parent_keys, &totkeys, &max_length); keys->segments = totkeys - 1; } else { /* Fill in invariant part of modifier context. */ ParticleChildModifierContext modifier_ctx = {NULL}; modifier_ctx.thread_ctx = ctx; modifier_ctx.sim = &ctx->sim; modifier_ctx.ptex = ptex; modifier_ctx.cpa = cpa; modifier_ctx.orco = orco; modifier_ctx.parent_keys = parent_keys; totkeys = ctx->segments + 1; max_length = ptex->length; for (k = 0, key = keys; k < totkeys; k++, key++) { ParticlePathIterator iter; psys_path_iter_get(&iter, keys, totkeys, parent_keys, k); ParticleKey *par = (ParticleKey *)iter.parent_key; /* Fill in variant part of modifier context. */ modifier_ctx.par_co = par->co; modifier_ctx.par_vel = par->vel; modifier_ctx.par_rot = iter.parent_rotation; modifier_ctx.par_orco = parent_orco; /* Apply different deformations to the child path. */ do_child_modifiers(&modifier_ctx, hairmat, (ParticleKey *)key, iter.time); } } { const float step_length = 1.0f / (float)(totkeys - 1); float cur_length = 0.0f; if (max_length <= 0.0f) { keys->segments = -1; totkeys = 0; } /* we have to correct velocity because of kink & clump */ for (k = 0, key = keys; k < totkeys; ++k, ++key) { if (k >= 2) { sub_v3_v3v3((key-1)->vel, key->co, (key-2)->co); mul_v3_fl((key-1)->vel, 0.5); if (ma && draw_col_ma) get_strand_normal(ma, ornor, cur_length, (key-1)->vel); } if (use_length_check && k > 0) { float dvec[3]; /* check if path needs to be cut before actual end of data points */ if (!check_path_length(k, keys, key, max_length, step_length, &cur_length, dvec)) { /* last key */ sub_v3_v3v3(key->vel, key->co, (key-1)->co); if (ma && draw_col_ma) { copy_v3_v3(key->col, &ma->r); } break; } } if (k == totkeys-1) { /* last key */ sub_v3_v3v3(key->vel, key->co, (key-1)->co); } if (ma && draw_col_ma) { copy_v3_v3(key->col, &ma->r); get_strand_normal(ma, ornor, cur_length, key->vel); } } } #endif }