diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/physics | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/dynamicpaint_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_boids.c | 48 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 797 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 106 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 93 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_pointcache.c | 30 |
6 files changed, 546 insertions, 536 deletions
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 41600bdb728..417cddb74fe 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -73,7 +73,7 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) /* set preview for this surface only and set active */ canvas->active_sur = 0; - for(surface=surface->prev; surface; surface=surface->prev) { + for (surface=surface->prev; surface; surface=surface->prev) { surface->flags &= ~MOD_DPAINT_PREVIEW; canvas->active_sur++; } @@ -113,8 +113,8 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op)) surface = canvas->surfaces.first; /* find active surface and remove it */ - for(; surface; surface=surface->next) { - if(id == canvas->active_sur) { + for (; surface; surface=surface->next) { + if (id == canvas->active_sur) { canvas->active_sur -= 1; dynamicPaint_freeSurface(surface); break; @@ -408,7 +408,7 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) static int dynamicpaint_bake_exec(bContext *C, wmOperator *op) { /* Bake dynamic paint */ - if(!dynamicPaint_initBake(C, op)) { + if (!dynamicPaint_initBake(C, op)) { return OPERATOR_CANCELLED;} return OPERATOR_FINISHED; diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index 8440b7144a5..7a7c16b23ff 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -65,7 +65,7 @@ static int rule_add_exec(bContext *C, wmOperator *op) BoidRule *rule; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; part = psys->part; @@ -73,7 +73,7 @@ static int rule_add_exec(bContext *C, wmOperator *op) state = boid_get_current_state(part->boids); - for(rule=state->rules.first; rule; rule=rule->next) + for (rule=state->rules.first; rule; rule=rule->next) rule->flag &= ~BOIDRULE_CURRENT; rule = boid_new_rule(type); @@ -113,14 +113,14 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op)) BoidRule *rule; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; state = boid_get_current_state(psys->part->boids); - for(rule=state->rules.first; rule; rule=rule->next) { - if(rule->flag & BOIDRULE_CURRENT) { + for (rule=state->rules.first; rule; rule=rule->next) { + if (rule->flag & BOIDRULE_CURRENT) { BLI_remlink(&state->rules, rule); MEM_freeN(rule); break; @@ -129,7 +129,7 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op)) } rule = state->rules.first; - if(rule) + if (rule) rule->flag |= BOIDRULE_CURRENT; DAG_scene_sort(bmain, scene); @@ -162,12 +162,12 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op)) BoidRule *rule; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; state = boid_get_current_state(psys->part->boids); - for(rule = state->rules.first; rule; rule=rule->next) { - if(rule->flag & BOIDRULE_CURRENT && rule->prev) { + for (rule = state->rules.first; rule; rule=rule->next) { + if (rule->flag & BOIDRULE_CURRENT && rule->prev) { BLI_remlink(&state->rules, rule); BLI_insertlink(&state->rules, rule->prev->prev, rule); @@ -200,12 +200,12 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op)) BoidRule *rule; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; state = boid_get_current_state(psys->part->boids); - for(rule = state->rules.first; rule; rule=rule->next) { - if(rule->flag & BOIDRULE_CURRENT && rule->next) { + for (rule = state->rules.first; rule; rule=rule->next) { + if (rule->flag & BOIDRULE_CURRENT && rule->next) { BLI_remlink(&state->rules, rule); BLI_insertlink(&state->rules, rule->next, rule); @@ -240,12 +240,12 @@ static int state_add_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; part = psys->part; - for(state=part->boids->states.first; state; state=state->next) + for (state=part->boids->states.first; state; state=state->next) state->flag &= ~BOIDSTATE_CURRENT; state = boid_new_state(part->boids); @@ -281,13 +281,13 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; part = psys->part; - for(state=part->boids->states.first; state; state=state->next) { - if(state->flag & BOIDSTATE_CURRENT) { + for (state=part->boids->states.first; state; state=state->next) { + if (state->flag & BOIDSTATE_CURRENT) { BLI_remlink(&part->boids->states, state); MEM_freeN(state); break; @@ -296,7 +296,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) } /* there must be at least one state */ - if(!part->boids->states.first) { + if (!part->boids->states.first) { state = boid_new_state(part->boids); BLI_addtail(&part->boids->states, state); } @@ -335,13 +335,13 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op)) BoidSettings *boids; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; boids = psys->part->boids; - for(state = boids->states.first; state; state=state->next) { - if(state->flag & BOIDSTATE_CURRENT && state->prev) { + for (state = boids->states.first; state; state=state->next) { + if (state->flag & BOIDSTATE_CURRENT && state->prev) { BLI_remlink(&boids->states, state); BLI_insertlink(&boids->states, state->prev->prev, state); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -371,13 +371,13 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op)) BoidSettings *boids; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; boids = psys->part->boids; - for(state = boids->states.first; state; state=state->next) { - if(state->flag & BOIDSTATE_CURRENT && state->next) { + for (state = boids->states.first; state; state=state->next) { + if (state->flag & BOIDSTATE_CURRENT && state->next) { BLI_remlink(&boids->states, state); BLI_insertlink(&boids->states, state->next, state); DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 15f2006e2b8..68d464da261 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -89,16 +89,16 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys); #define KEY_K PTCacheEditKey *key; int k #define POINT_P PTCacheEditPoint *point; int p -#define LOOP_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) -#define LOOP_VISIBLE_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(!(point->flag & PEP_HIDE)) -#define LOOP_SELECTED_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point_is_selected(point)) -#define LOOP_UNSELECTED_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(!point_is_selected(point)) -#define LOOP_EDITED_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point->flag & PEP_EDIT_RECALC) -#define LOOP_TAGGED_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point->flag & PEP_TAG) -#define LOOP_KEYS for(k=0, key=point->keys; k<point->totkey; k++, key++) -#define LOOP_VISIBLE_KEYS for(k=0, key=point->keys; k<point->totkey; k++, key++) if(!(key->flag & PEK_HIDE)) -#define LOOP_SELECTED_KEYS for(k=0, key=point->keys; k<point->totkey; k++, key++) if((key->flag & PEK_SELECT) && !(key->flag & PEK_HIDE)) -#define LOOP_TAGGED_KEYS for(k=0, key=point->keys; k<point->totkey; k++, key++) if(key->flag & PEK_TAG) +#define LOOP_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) +#define LOOP_VISIBLE_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(!(point->flag & PEP_HIDE)) +#define LOOP_SELECTED_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point_is_selected(point)) +#define LOOP_UNSELECTED_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(!point_is_selected(point)) +#define LOOP_EDITED_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point->flag & PEP_EDIT_RECALC) +#define LOOP_TAGGED_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point->flag & PEP_TAG) +#define LOOP_KEYS for (k=0, key=point->keys; k<point->totkey; k++, key++) +#define LOOP_VISIBLE_KEYS for (k=0, key=point->keys; k<point->totkey; k++, key++) if(!(key->flag & PEK_HIDE)) +#define LOOP_SELECTED_KEYS for (k=0, key=point->keys; k<point->totkey; k++, key++) if((key->flag & PEK_SELECT) && !(key->flag & PEK_HIDE)) +#define LOOP_TAGGED_KEYS for (k=0, key=point->keys; k<point->totkey; k++, key++) if(key->flag & PEK_TAG) #define KEY_WCO (key->flag & PEK_USE_WCO ? key->world_co : key->co) @@ -109,7 +109,7 @@ int PE_poll(bContext *C) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - if(!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) + if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; return (PE_get_current(scene, ob) != NULL); @@ -121,7 +121,7 @@ int PE_hair_poll(bContext *C) Object *ob= CTX_data_active_object(C); PTCacheEdit *edit; - if(!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) + if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; edit= PE_get_current(scene, ob); @@ -139,28 +139,28 @@ void PE_free_ptcache_edit(PTCacheEdit *edit) { POINT_P; - if(edit==0) return; + if (edit==0) return; PTCacheUndo_clear(edit); - if(edit->points) { + if (edit->points) { LOOP_POINTS { - if(point->keys) + if (point->keys) MEM_freeN(point->keys); } MEM_freeN(edit->points); } - if(edit->mirror_cache) + if (edit->mirror_cache) MEM_freeN(edit->mirror_cache); - if(edit->emitter_cosnos) { + if (edit->emitter_cosnos) { MEM_freeN(edit->emitter_cosnos); edit->emitter_cosnos= 0; } - if(edit->emitter_field) { + if (edit->emitter_field) { BLI_kdtree_free(edit->emitter_field); edit->emitter_field= 0; } @@ -176,9 +176,9 @@ void PE_free_ptcache_edit(PTCacheEdit *edit) int PE_start_edit(PTCacheEdit *edit) { - if(edit) { + if (edit) { edit->edited = 1; - if(edit->psys) + if (edit->psys) edit->psys->flag |= PSYS_EDITED; return 1; } @@ -202,7 +202,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) ListBase pidlist; PTCacheID *pid; - if(pset==NULL || ob==NULL) + if (pset==NULL || ob==NULL) return NULL; pset->scene = scene; @@ -211,7 +211,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); /* in the case of only one editable thing, set pset->edittype accordingly */ - if(pidlist.first && pidlist.first == pidlist.last) { + if (pidlist.first && pidlist.first == pidlist.last) { pid = pidlist.first; switch(pid->type) { case PTCACHE_TYPE_PARTICLES: @@ -226,25 +226,25 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) } } - for(pid=pidlist.first; pid; pid=pid->next) { - if(pset->edittype == PE_TYPE_PARTICLES && pid->type == PTCACHE_TYPE_PARTICLES) { + for (pid=pidlist.first; pid; pid=pid->next) { + if (pset->edittype == PE_TYPE_PARTICLES && pid->type == PTCACHE_TYPE_PARTICLES) { ParticleSystem *psys = pid->calldata; - if(psys->flag & PSYS_CURRENT) { - if(psys->part && psys->part->type == PART_HAIR) { - if(psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) { - if(create && !psys->pointcache->edit) + if (psys->flag & PSYS_CURRENT) { + if (psys->part && psys->part->type == PART_HAIR) { + if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) { + if (create && !psys->pointcache->edit) PE_create_particle_edit(scene, ob, pid->cache, NULL); edit = pid->cache->edit; } else { - if(create && !psys->edit && psys->flag & PSYS_HAIR_DONE) + if (create && !psys->edit && psys->flag & PSYS_HAIR_DONE) PE_create_particle_edit(scene, ob, NULL, psys); edit = psys->edit; } } else { - if(create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) + if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) PE_create_particle_edit(scene, ob, pid->cache, psys); edit = pid->cache->edit; } @@ -272,7 +272,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) } } - if(edit) + if (edit) edit->pid = *pid; BLI_freelistN(&pidlist); @@ -292,7 +292,7 @@ PTCacheEdit *PE_create_current(Scene *scene, Object *ob) void PE_current_changed(Scene *scene, Object *ob) { - if(ob->mode == OB_MODE_PARTICLE_EDIT) + if (ob->mode == OB_MODE_PARTICLE_EDIT) PE_create_current(scene, ob); } @@ -302,10 +302,10 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra) POINT_P; KEY_K; - if(pset->flag & PE_FADE_TIME && pset->selectmode==SCE_SELECT_POINT) { + if (pset->flag & PE_FADE_TIME && pset->selectmode==SCE_SELECT_POINT) { LOOP_POINTS { LOOP_KEYS { - if(fabs(cfra-*key->time) < pset->fade_frames) + if (fabs(cfra-*key->time) < pset->fade_frames) key->flag &= ~PEK_HIDE; else { key->flag |= PEK_HIDE; @@ -325,7 +325,7 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra) static int pe_x_mirror(Object *ob) { - if(ob->type == OB_MESH) + if (ob->type == OB_MESH) return (((Mesh*)ob->data)->editflag & ME_EDIT_MIRROR_X); return 0; @@ -380,8 +380,8 @@ static void PE_set_view3d_data(bContext *C, PEData *data) /* note, the object argument means the modelview matrix does not account for the objects matrix, use viewmat rather than (obmat * viewmat) */ view3d_get_transformation(data->vc.ar, data->vc.rv3d, NULL, &data->mats); - if((data->vc.v3d->drawtype>OB_WIRE) && (data->vc.v3d->flag & V3D_ZBUF_SELECT)) { - if(data->vc.v3d->flag & V3D_INVALID_BACKBUF) { + if ((data->vc.v3d->drawtype>OB_WIRE) && (data->vc.v3d->flag & V3D_ZBUF_SELECT)) { + if (data->vc.v3d->flag & V3D_INVALID_BACKBUF) { /* needed or else the draw matrix can be incorrect */ view3d_operator_needs_opengl(C); @@ -404,12 +404,12 @@ static int key_test_depth(PEData *data, const float co[3]) short wco[3], x,y; /* nothing to do */ - if((v3d->drawtype<=OB_WIRE) || (v3d->flag & V3D_ZBUF_SELECT)==0) + if ((v3d->drawtype<=OB_WIRE) || (v3d->flag & V3D_ZBUF_SELECT)==0) return 1; project_short(data->vc.ar, co, wco); - if(wco[0] == IS_CLIPPED) + if (wco[0] == IS_CLIPPED) return 0; gluProject(co[0],co[1],co[2], data->mats.modelview, data->mats.projection, @@ -434,7 +434,7 @@ static int key_test_depth(PEData *data, const float co[3]) } #endif - if((float)uz - 0.00001f > depth) + if ((float)uz - 0.00001f > depth) return 0; else return 1; @@ -447,18 +447,18 @@ static int key_inside_circle(PEData *data, float rad, const float co[3], float * project_int(data->vc.ar, co, sco); - if(sco[0] == IS_CLIPPED) + if (sco[0] == IS_CLIPPED) return 0; dx= data->mval[0] - sco[0]; dy= data->mval[1] - sco[1]; dist= sqrt(dx*dx + dy*dy); - if(dist > rad) + if (dist > rad) return 0; - if(key_test_depth(data, co)) { - if(distance) + if (key_test_depth(data, co)) { + if (distance) *distance=dist; return 1; @@ -473,10 +473,10 @@ static int key_inside_rect(PEData *data, const float co[3]) project_int(data->vc.ar, co,sco); - if(sco[0] == IS_CLIPPED) + if (sco[0] == IS_CLIPPED) return 0; - if(sco[0] > data->rect->xmin && sco[0] < data->rect->xmax && + if (sco[0] > data->rect->xmin && sco[0] < data->rect->xmax && sco[1] > data->rect->ymin && sco[1] < data->rect->ymax) return key_test_depth(data, co); @@ -485,7 +485,7 @@ static int key_inside_rect(PEData *data, const float co[3]) static int key_inside_test(PEData *data, const float co[3]) { - if(data->mval) + if (data->mval) return key_inside_circle(data, data->rad, co, NULL); else return key_inside_rect(data, co); @@ -495,7 +495,7 @@ static int point_is_selected(PTCacheEditPoint *point) { KEY_K; - if(point->flag & PEP_HIDE) + if (point->flag & PEP_HIDE) return 0; LOOP_SELECTED_KEYS { @@ -520,43 +520,43 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, int nearest) float dist= data->rad; /* in path select mode we have no keys */ - if(pset->selectmode==SCE_SELECT_PATH) + if (pset->selectmode==SCE_SELECT_PATH) return; nearest_point= -1; nearest_key= -1; LOOP_VISIBLE_POINTS { - if(pset->selectmode == SCE_SELECT_END) { + if (pset->selectmode == SCE_SELECT_END) { /* only do end keys */ key= point->keys + point->totkey-1; - if(nearest) { - if(key_inside_circle(data, dist, KEY_WCO, &dist)) { + if (nearest) { + if (key_inside_circle(data, dist, KEY_WCO, &dist)) { nearest_point= p; nearest_key= point->totkey-1; } } - else if(key_inside_test(data, KEY_WCO)) + else if (key_inside_test(data, KEY_WCO)) func(data, p, point->totkey-1); } else { /* do all keys */ LOOP_VISIBLE_KEYS { - if(nearest) { - if(key_inside_circle(data, dist, KEY_WCO, &dist)) { + if (nearest) { + if (key_inside_circle(data, dist, KEY_WCO, &dist)) { nearest_point= p; nearest_key= k; } } - else if(key_inside_test(data, KEY_WCO)) + else if (key_inside_test(data, KEY_WCO)) func(data, p, k); } } } /* do nearest only */ - if(nearest && nearest_point > -1) + if (nearest && nearest_point > -1) func(data, nearest_point, nearest_key); } @@ -567,23 +567,23 @@ static void foreach_mouse_hit_point(PEData *data, ForPointFunc func, int selecte POINT_P; KEY_K; /* all is selected in path mode */ - if(pset->selectmode==SCE_SELECT_PATH) + if (pset->selectmode==SCE_SELECT_PATH) selected=0; LOOP_VISIBLE_POINTS { - if(pset->selectmode==SCE_SELECT_END) { + if (pset->selectmode==SCE_SELECT_END) { /* only do end keys */ key= point->keys + point->totkey - 1; - if(selected==0 || key->flag & PEK_SELECT) - if(key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) + if (selected==0 || key->flag & PEK_SELECT) + if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) func(data, p); } else { /* do all keys */ LOOP_VISIBLE_KEYS { - if(selected==0 || key->flag & PEK_SELECT) { - if(key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { + if (selected==0 || key->flag & PEK_SELECT) { + if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { func(data, p); break; } @@ -602,21 +602,21 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected POINT_P; KEY_K; float mat[4][4]= MAT4_UNITY, imat[4][4]= MAT4_UNITY; - if(edit->psys) + if (edit->psys) psmd= psys_get_modifier(data->ob, edit->psys); /* all is selected in path mode */ - if(pset->selectmode==SCE_SELECT_PATH) + if (pset->selectmode==SCE_SELECT_PATH) selected= 0; LOOP_VISIBLE_POINTS { - if(pset->selectmode==SCE_SELECT_END) { + if (pset->selectmode==SCE_SELECT_END) { /* only do end keys */ key= point->keys + point->totkey-1; - if(selected==0 || key->flag & PEK_SELECT) { - if(key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { - if(edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { + if (selected==0 || key->flag & PEK_SELECT) { + if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { + if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, psmd->dm, psys->part->from, psys->particles + p, mat); invert_m4_m4(imat,mat); } @@ -628,9 +628,9 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected else { /* do all keys */ LOOP_VISIBLE_KEYS { - if(selected==0 || key->flag & PEK_SELECT) { - if(key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { - if(edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { + if (selected==0 || key->flag & PEK_SELECT) { + if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { + if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, psmd->dm, psys->part->from, psys->particles + p, mat); invert_m4_m4(imat,mat); } @@ -682,14 +682,14 @@ static int count_selected_keys(Scene *scene, PTCacheEdit *edit) int sel= 0; LOOP_VISIBLE_POINTS { - if(pset->selectmode==SCE_SELECT_POINT) { + if (pset->selectmode==SCE_SELECT_POINT) { LOOP_SELECTED_KEYS { sel++; } } - else if(pset->selectmode==SCE_SELECT_END) { + else if (pset->selectmode==SCE_SELECT_END) { key = point->keys + point->totkey - 1; - if(key->flag & PEK_SELECT) + if (key->flag & PEK_SELECT) sel++; } } @@ -716,7 +716,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) psmd= psys_get_modifier(ob, psys); totpart= psys->totpart; - if(!psmd->dm) + if (!psmd->dm) return; tree= BLI_kdtree_new(totpart); @@ -733,7 +733,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) BLI_kdtree_balance(tree); /* lookup particles and set in mirror cache */ - if(!edit->mirror_cache) + if (!edit->mirror_cache) edit->mirror_cache= MEM_callocN(sizeof(int)*totpart, "PE mirror cache"); LOOP_PARTICLES { @@ -746,7 +746,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) index= BLI_kdtree_find_nearest(tree, co, NULL, &nearest); /* this needs a custom threshold still, duplicated for editmode mirror */ - if(index != -1 && index != p && (nearest.dist <= 0.0002f)) + if (index != -1 && index != p && (nearest.dist <= 0.0002f)) edit->mirror_cache[p]= index; else edit->mirror_cache[p]= -1; @@ -754,9 +754,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) /* make sure mirrors are in two directions */ LOOP_PARTICLES { - if(edit->mirror_cache[p]) { + if (edit->mirror_cache[p]) { index= edit->mirror_cache[p]; - if(edit->mirror_cache[index] != p) + if (edit->mirror_cache[index] != p) edit->mirror_cache[p]= -1; } } @@ -777,15 +777,15 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys i= pa - psys->particles; /* find mirrored particle if needed */ - if(!mpa) { - if(!edit->mirror_cache) + if (!mpa) { + if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); - if(!edit->mirror_cache) + if (!edit->mirror_cache) return; /* something went wrong! */ mi= edit->mirror_cache[i]; - if(mi == -1) + if (mi == -1) return; mpa= psys->particles + mi; } @@ -796,9 +796,9 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys mpoint = edit->points + mi; /* make sure they have the same amount of keys */ - if(pa->totkey != mpa->totkey) { - if(mpa->hair) MEM_freeN(mpa->hair); - if(mpoint->keys) MEM_freeN(mpoint->keys); + if (pa->totkey != mpa->totkey) { + if (mpa->hair) MEM_freeN(mpa->hair); + if (mpoint->keys) MEM_freeN(mpoint->keys); mpa->hair= MEM_dupallocN(pa->hair); mpa->totkey= pa->totkey; @@ -807,7 +807,7 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys mhkey= mpa->hair; mkey= mpoint->keys; - for(k=0; k<mpa->totkey; k++, mkey++, mhkey++) { + for (k=0; k<mpa->totkey; k++, mkey++, mhkey++) { mkey->co= mhkey->co; mkey->time= &mhkey->time; mkey->flag &= ~PEK_SELECT; @@ -823,21 +823,21 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys mhkey=mpa->hair; key= point->keys; mkey= mpoint->keys; - for(k=0; k<pa->totkey; k++, hkey++, mhkey++, key++, mkey++) { + for (k=0; k<pa->totkey; k++, hkey++, mhkey++, key++, mkey++) { copy_v3_v3(mhkey->co, hkey->co); mul_m4_v3(mat, mhkey->co); mhkey->co[0]= -mhkey->co[0]; mul_m4_v3(immat, mhkey->co); - if(key->flag & PEK_TAG) + if (key->flag & PEK_TAG) mkey->flag |= PEK_TAG; mkey->length = key->length; } - if(point->flag & PEP_TAG) + if (point->flag & PEP_TAG) mpoint->flag |= PEP_TAG; - if(point->flag & PEP_EDIT_RECALC) + if (point->flag & PEP_EDIT_RECALC) mpoint->flag |= PEP_EDIT_RECALC; } @@ -847,35 +847,35 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys) ParticleSystemModifierData *psmd; POINT_P; - if(!psys) + if (!psys) return; edit= psys->edit; psmd= psys_get_modifier(ob, psys); - if(!psmd->dm) + if (!psmd->dm) return; - if(!edit->mirror_cache) + if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); - if(!edit->mirror_cache) + if (!edit->mirror_cache) return; /* something went wrong */ /* we delay settings the PARS_EDIT_RECALC for mirrored particles * to avoid doing mirror twice */ LOOP_POINTS { - if(point->flag & PEP_EDIT_RECALC) { + if (point->flag & PEP_EDIT_RECALC) { PE_mirror_particle(ob, psmd->dm, psys, psys->particles + p, NULL); - if(edit->mirror_cache[p] != -1) + if (edit->mirror_cache[p] != -1) edit->points[edit->mirror_cache[p]].flag &= ~PEP_EDIT_RECALC; } } LOOP_POINTS { - if(point->flag & PEP_EDIT_RECALC) - if(edit->mirror_cache[p] != -1) + if (point->flag & PEP_EDIT_RECALC) + if (edit->mirror_cache[p] != -1) edit->points[edit->mirror_cache[p]].flag |= PEP_EDIT_RECALC; } } @@ -894,13 +894,13 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) float *vec, *nor, dvec[3], dot, dist_1st=0.0f; float hairimat[4][4], hairmat[4][4]; - if(edit==NULL || edit->psys==NULL || (pset->flag & PE_DEFLECT_EMITTER)==0 || (edit->psys->flag & PSYS_GLOBAL_HAIR)) + if (edit==NULL || edit->psys==NULL || (pset->flag & PE_DEFLECT_EMITTER)==0 || (edit->psys->flag & PSYS_GLOBAL_HAIR)) return; psys = edit->psys; psmd = psys_get_modifier(ob,psys); - if(!psmd->dm) + if (!psmd->dm) return; LOOP_EDITED_POINTS { @@ -911,7 +911,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) } LOOP_KEYS { - if(k==0) { + if (k==0) { dist_1st = len_v3v3((key+1)->co, key->co); dist_1st *= 0.75f * pset->emitterdist; } @@ -926,8 +926,8 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) dot=dot_v3v3(dvec,nor); copy_v3_v3(dvec,nor); - if(dot>0.0f) { - if(dot<dist_1st) { + if (dot>0.0f) { + if (dot<dist_1st) { normalize_v3(dvec); mul_v3_fl(dvec,dist_1st-dot); add_v3_v3(key->co, dvec); @@ -938,7 +938,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) mul_v3_fl(dvec,dist_1st-dot); add_v3_v3(key->co, dvec); } - if(k==1) + if (k==1) dist_1st*=1.3333f; } } @@ -958,15 +958,15 @@ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit) POINT_P; KEY_K; float dv1[3]; - if(edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) + if (edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) return; - if(edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) + if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) return; LOOP_EDITED_POINTS { LOOP_KEYS { - if(k) { + if (k) { sub_v3_v3v3(dv1, key->co, (key - 1)->co); normalize_v3(dv1); mul_v3_fl(dv1, (key - 1)->length); @@ -987,17 +987,17 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit) float dv1[3]= {0.0f, 0.0f, 0.0f}; float dv2[3]= {0.0f, 0.0f, 0.0f}; - if(edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) + if (edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) return; - if(edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) + if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) return; LOOP_EDITED_POINTS { - for(j=1; j<point->totkey; j++) { + for (j=1; j<point->totkey; j++) { float mul= 1.0f / (float)point->totkey; - if(pset->flag & PE_LOCK_FIRST) { + if (pset->flag & PE_LOCK_FIRST) { key= point->keys + 1; k= 1; dv1[0]= dv1[1]= dv1[2]= 0.0; @@ -1008,20 +1008,20 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit) dv0[0]= dv0[1]= dv0[2]= 0.0; } - for(; k<point->totkey; k++, key++) { - if(k) { + for (; k<point->totkey; k++, key++) { + if (k) { sub_v3_v3v3(dv0, (key - 1)->co, key->co); tlen= normalize_v3(dv0); mul_v3_fl(dv0, (mul * (tlen - (key - 1)->length))); } - if(k < point->totkey - 1) { + if (k < point->totkey - 1) { sub_v3_v3v3(dv2, (key + 1)->co, key->co); tlen= normalize_v3(dv2); mul_v3_fl(dv2, mul * (tlen - key->length)); } - if(k) { + if (k) { add_v3_v3((key-1)->co, dv1); } @@ -1035,12 +1035,12 @@ static void recalc_lengths(PTCacheEdit *edit) { POINT_P; KEY_K; - if(edit==0) + if (edit==0) return; LOOP_EDITED_POINTS { key= point->keys; - for(k=0; k<point->totkey-1; k++, key++) { + for (k=0; k<point->totkey-1; k++, key++) { key->length= len_v3v3(key->co, (key + 1)->co); } } @@ -1054,10 +1054,10 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys) float *vec, *nor; int i, totface /*, totvert*/; - if(!dm) + if (!dm) return; - if(edit->emitter_cosnos) + if (edit->emitter_cosnos) MEM_freeN(edit->emitter_cosnos); BLI_kdtree_free(edit->emitter_field); @@ -1072,7 +1072,7 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys) vec=edit->emitter_cosnos; nor=vec+3; - for(i=0; i<totface; i++, vec+=6, nor+=6) { + for (i=0; i<totface; i++, vec+=6, nor+=6) { MFace *mface=dm->getTessFaceData(dm,i,CD_MFACE); MVert *mvert; @@ -1088,7 +1088,7 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys) add_v3_v3v3(vec,vec,mvert->co); VECADD(nor,nor,mvert->no); - if(mface->v4) { + if (mface->v4) { mvert=dm->getVertData(dm,mface->v4,CD_MVERT); add_v3_v3v3(vec,vec,mvert->co); VECADD(nor,nor,mvert->no); @@ -1113,13 +1113,13 @@ static void PE_update_selection(Scene *scene, Object *ob, int useflag) POINT_P; KEY_K; /* flag all particles to be updated if not using flag */ - if(!useflag) + if (!useflag) LOOP_POINTS point->flag |= PEP_EDIT_RECALC; /* flush edit key flag to hair key flag to preserve selection * on save */ - if(edit->psys) LOOP_POINTS { + if (edit->psys) LOOP_POINTS { hkey = edit->psys->particles[p].hair; LOOP_KEYS { hkey->editflag= key->flag; @@ -1142,16 +1142,16 @@ static void update_world_cos(Object *ob, PTCacheEdit *edit) POINT_P; KEY_K; float hairmat[4][4]; - if(psys==0 || psys->edit==0 || psmd->dm==NULL) + if (psys==0 || psys->edit==0 || psmd->dm==NULL) return; LOOP_POINTS { - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles+p, hairmat); LOOP_KEYS { copy_v3_v3(key->world_co,key->co); - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) mul_m4_v3(hairmat, key->world_co); } } @@ -1163,37 +1163,37 @@ static void update_velocities(PTCacheEdit *edit) POINT_P; KEY_K; /* hair doesn't use velocities */ - if(edit->psys || !edit->points || !edit->points->keys->vel) + if (edit->psys || !edit->points || !edit->points->keys->vel) return; frs_sec = edit->pid.flag & PTCACHE_VEL_PER_SEC ? 25.0f : 1.0f; LOOP_EDITED_POINTS { LOOP_KEYS { - if(k==0) { + if (k==0) { dfra = *(key+1)->time - *key->time; - if(dfra <= 0.0f) + if (dfra <= 0.0f) continue; sub_v3_v3v3(key->vel, (key+1)->co, key->co); - if(point->totkey>2) { + if (point->totkey>2) { sub_v3_v3v3(vec1, (key+1)->co, (key+2)->co); project_v3_v3v3(vec2, vec1, key->vel); sub_v3_v3v3(vec2, vec1, vec2); madd_v3_v3fl(key->vel, vec2, 0.5f); } } - else if(k==point->totkey-1) { + else if (k==point->totkey-1) { dfra = *key->time - *(key-1)->time; - if(dfra <= 0.0f) + if (dfra <= 0.0f) continue; sub_v3_v3v3(key->vel, key->co, (key-1)->co); - if(point->totkey>2) { + if (point->totkey>2) { sub_v3_v3v3(vec1, (key-2)->co, (key-1)->co); project_v3_v3v3(vec2, vec1, key->vel); sub_v3_v3v3(vec2, vec1, vec2); @@ -1203,7 +1203,7 @@ static void update_velocities(PTCacheEdit *edit) else { dfra = *(key+1)->time - *(key-1)->time; - if(dfra <= 0.0f) + if (dfra <= 0.0f) continue; sub_v3_v3v3(key->vel, (key+1)->co, (key-1)->co); @@ -1221,11 +1221,11 @@ void PE_update_object(Scene *scene, Object *ob, int useflag) PTCacheEdit *edit = PE_get_current(scene, ob); POINT_P; - if(!edit) + if (!edit) return; /* flag all particles to be updated if not using flag */ - if(!useflag) + if (!useflag) LOOP_POINTS { point->flag |= PEP_EDIT_RECALC; } @@ -1234,11 +1234,11 @@ void PE_update_object(Scene *scene, Object *ob, int useflag) pe_iterate_lengths(scene, edit); pe_deflect_emitter(scene, ob, edit); PE_apply_lengths(scene, edit); - if(pe_x_mirror(ob)) + if (pe_x_mirror(ob)) PE_apply_mirror(ob,edit->psys); - if(edit->psys) + if (edit->psys) update_world_cos(ob, edit); - if(pset->flag & PE_AUTO_VELOCITY) + if (pset->flag & PE_AUTO_VELOCITY) update_velocities(edit); PE_hide_keys_time(scene, edit, CFRA); @@ -1250,7 +1250,7 @@ void PE_update_object(Scene *scene, Object *ob, int useflag) point->flag &= ~PEP_EDIT_RECALC; } - if(edit->psys) + if (edit->psys) edit->psys->flag &= ~PSYS_HAIR_UPDATED; } @@ -1266,7 +1266,7 @@ static void select_key(PEData *data, int point_index, int key_index) PTCacheEditPoint *point = edit->points + point_index; PTCacheEditKey *key = point->keys + key_index; - if(data->select) + if (data->select) key->flag |= PEK_SELECT; else key->flag &= ~PEK_SELECT; @@ -1281,7 +1281,7 @@ static void select_keys(PEData *data, int point_index, int UNUSED(key_index)) KEY_K; LOOP_KEYS { - if(data->select) + if (data->select) key->flag |= PEK_SELECT; else key->flag &= ~PEK_SELECT; @@ -1342,7 +1342,8 @@ static int pe_select_all_exec(bContext *C, wmOperator *op) if ((key->flag & PEK_SELECT) == 0) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; - } else { + } + else { key->flag &= ~PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } @@ -1383,10 +1384,10 @@ int PE_mouse_particles(bContext *C, const int mval[2], int extend) PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; - if(!extend) { + if (!extend) { LOOP_VISIBLE_POINTS { LOOP_SELECTED_KEYS { key->flag &= ~PEK_SELECT; @@ -1554,7 +1555,7 @@ int PE_border_select(bContext *C, rcti *rect, int select, int extend) PTCacheEdit *edit= PE_get_current(scene, ob); PEData data; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; if (extend == 0 && select) @@ -1581,7 +1582,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) PTCacheEdit *edit= PE_get_current(scene, ob); PEData data; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return OPERATOR_FINISHED; PE_set_view3d_data(C, &data); @@ -1614,7 +1615,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho PEData data; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; if (extend == 0 && select) @@ -1624,38 +1625,38 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho PE_set_view3d_data(C, &data); LOOP_VISIBLE_POINTS { - if(edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) + if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + p, mat); - if(pset->selectmode==SCE_SELECT_POINT) { + if (pset->selectmode==SCE_SELECT_POINT) { LOOP_KEYS { copy_v3_v3(co, key->co); mul_m4_v3(mat, co); project_int(ar, co, vertco); - if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { - if(select && !(key->flag & PEK_SELECT)) { + if ((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { + if (select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } - else if(key->flag & PEK_SELECT) { + else if (key->flag & PEK_SELECT) { key->flag &= ~PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } } } } - else if(pset->selectmode==SCE_SELECT_END) { + else if (pset->selectmode==SCE_SELECT_END) { key= point->keys + point->totkey - 1; copy_v3_v3(co, key->co); mul_m4_v3(mat, co); project_int(ar, co,vertco); - if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { - if(select && !(key->flag & PEK_SELECT)) { + if ((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { + if (select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } - else if(key->flag & PEK_SELECT) { + else if (key->flag & PEK_SELECT) { key->flag &= ~PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } @@ -1678,7 +1679,7 @@ static int hide_exec(bContext *C, wmOperator *op) PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - if(RNA_enum_get(op->ptr, "unselected")) { + if (RNA_enum_get(op->ptr, "unselected")) { LOOP_UNSELECTED_POINTS { point->flag |= PEP_HIDE; point->flag |= PEP_EDIT_RECALC; @@ -1730,7 +1731,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) POINT_P; KEY_K; LOOP_POINTS { - if(point->flag & PEP_HIDE) { + if (point->flag & PEP_HIDE) { point->flag &= ~PEP_HIDE; point->flag |= PEP_EDIT_RECALC; @@ -1768,22 +1769,22 @@ static void select_less_keys(PEData *data, int point_index) KEY_K; LOOP_SELECTED_KEYS { - if(k==0) { - if(((key+1)->flag&PEK_SELECT)==0) + if (k==0) { + if (((key+1)->flag&PEK_SELECT)==0) key->flag |= PEK_TAG; } - else if(k==point->totkey-1) { - if(((key-1)->flag&PEK_SELECT)==0) + else if (k==point->totkey-1) { + if (((key-1)->flag&PEK_SELECT)==0) key->flag |= PEK_TAG; } else { - if((((key-1)->flag & (key+1)->flag) & PEK_SELECT)==0) + if ((((key-1)->flag & (key+1)->flag) & PEK_SELECT)==0) key->flag |= PEK_TAG; } } LOOP_KEYS { - if(key->flag&PEK_TAG) { + if (key->flag&PEK_TAG) { key->flag &= ~(PEK_TAG|PEK_SELECT); point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ } @@ -1826,24 +1827,24 @@ static void select_more_keys(PEData *data, int point_index) KEY_K; LOOP_KEYS { - if(key->flag & PEK_SELECT) continue; + if (key->flag & PEK_SELECT) continue; - if(k==0) { - if((key+1)->flag&PEK_SELECT) + if (k==0) { + if ((key+1)->flag&PEK_SELECT) key->flag |= PEK_TAG; } - else if(k==point->totkey-1) { - if((key-1)->flag&PEK_SELECT) + else if (k==point->totkey-1) { + if ((key-1)->flag&PEK_SELECT) key->flag |= PEK_TAG; } else { - if(((key-1)->flag | (key+1)->flag) & PEK_SELECT) + if (((key-1)->flag | (key+1)->flag) & PEK_SELECT) key->flag |= PEK_TAG; } } LOOP_KEYS { - if(key->flag&PEK_TAG) { + if (key->flag&PEK_TAG) { key->flag &= ~PEK_TAG; key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ @@ -1911,7 +1912,7 @@ static void rekey_particle(PEData *data, int pa_index) dval= (end - sta) / (float)(data->totrekey - 1); /* interpolate new keys from old ones */ - for(k=1,key++; k<data->totrekey-1; k++,key++) { + for (k=1,key++; k<data->totrekey-1; k++,key++) { state.time= (float)k / (float)(data->totrekey-1); psys_get_particle_on_path(&sim, pa_index, &state, 0); copy_v3_v3(key->co, state.co); @@ -1919,22 +1920,22 @@ static void rekey_particle(PEData *data, int pa_index) } /* replace keys */ - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); pa->hair= new_keys; point->totkey=pa->totkey=data->totrekey; - if(point->keys) + if (point->keys) MEM_freeN(point->keys); ekey= point->keys= MEM_callocN(pa->totkey * sizeof(PTCacheEditKey),"Hair re-key edit keys"); - for(k=0, key=pa->hair; k<pa->totkey; k++, key++, ekey++) { + for (k=0, key=pa->hair; k<pa->totkey; k++, key++, ekey++) { ekey->co= key->co; ekey->time= &key->time; ekey->flag |= PEK_SELECT; - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) ekey->flag |= PEK_USE_WCO; } @@ -1989,7 +1990,7 @@ static void rekey_particle_to_time(Scene *scene, Object *ob, int pa_index, float PTCacheEditKey *ekey; int k; - if(!edit || !edit->psys) return; + if (!edit || !edit->psys) return; psys = edit->psys; @@ -2004,19 +2005,19 @@ static void rekey_particle_to_time(Scene *scene, Object *ob, int pa_index, float key= new_keys= MEM_dupallocN(pa->hair); /* interpolate new keys from old ones (roots stay the same) */ - for(k=1, key++; k < pa->totkey; k++, key++) { + for (k=1, key++; k < pa->totkey; k++, key++) { state.time= path_time * (float)k / (float)(pa->totkey-1); psys_get_particle_on_path(&sim, pa_index, &state, 0); copy_v3_v3(key->co, state.co); } /* replace hair keys */ - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); pa->hair= new_keys; /* update edit pointers */ - for(k=0, key=pa->hair, ekey=edit->points[pa_index].keys; k<pa->totkey; k++, key++, ekey++) { + for (k=0, key=pa->hair, ekey=edit->points[pa_index].keys; k<pa->totkey; k++, key++, ekey++) { ekey->co= key->co; ekey->time= &key->time; } @@ -2035,7 +2036,7 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror) ParticleSystemModifierData *psmd; int i, new_totpart= psys->totpart, removed= 0; - if(mirror) { + if (mirror) { /* mirror tags */ psmd= psys_get_modifier(ob, psys); @@ -2049,16 +2050,16 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror) removed++; } - if(new_totpart != psys->totpart) { - if(new_totpart) { + if (new_totpart != psys->totpart) { + if (new_totpart) { npa= new_pars= MEM_callocN(new_totpart * sizeof(ParticleData), "ParticleData array"); npoint= new_points= MEM_callocN(new_totpart * sizeof(PTCacheEditPoint), "PTCacheEditKey array"); - if(ELEM(NULL, new_pars, new_points)) { + if (ELEM(NULL, new_pars, new_points)) { /* allocation error! */ - if(new_pars) + if (new_pars) MEM_freeN(new_pars); - if(new_points) + if (new_points) MEM_freeN(new_points); return 0; } @@ -2066,11 +2067,11 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror) pa= psys->particles; point= edit->points; - for(i=0; i<psys->totpart; i++, pa++, point++) { - if(point->flag & PEP_TAG) { - if(point->keys) + for (i=0; i<psys->totpart; i++, pa++, point++) { + if (point->flag & PEP_TAG) { + if (point->keys) MEM_freeN(point->keys); - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); } else { @@ -2081,18 +2082,18 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror) } } - if(psys->particles) MEM_freeN(psys->particles); + if (psys->particles) MEM_freeN(psys->particles); psys->particles= new_pars; - if(edit->points) MEM_freeN(edit->points); + if (edit->points) MEM_freeN(edit->points); edit->points= new_points; - if(edit->mirror_cache) { + if (edit->mirror_cache) { MEM_freeN(edit->mirror_cache); edit->mirror_cache= NULL; } - if(psys->child) { + if (psys->child) { MEM_freeN(psys->child); psys->child= NULL; psys->totchild=0; @@ -2114,7 +2115,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) ParticleSystemModifierData *psmd; short new_totkey; - if(pe_x_mirror(ob)) { + if (pe_x_mirror(ob)) { /* mirror key tags */ psmd= psys_get_modifier(ob, psys); @@ -2132,7 +2133,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) new_totkey--; } /* we can't have elements with less than two keys*/ - if(new_totkey < 2) + if (new_totkey < 2) point->flag |= PEP_TAG; } remove_tagged_particles(ob, psys, pe_x_mirror(ob)); @@ -2145,7 +2146,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) new_totkey--; } - if(new_totkey != pa->totkey) { + if (new_totkey != pa->totkey) { nhkey= new_hkeys= MEM_callocN(new_totkey*sizeof(HairKey), "HairKeys"); nkey= new_keys= MEM_callocN(new_totkey*sizeof(PTCacheEditKey), "particle edit keys"); @@ -2156,7 +2157,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) hkey++; } - if(hkey < pa->hair + pa->totkey) { + if (hkey < pa->hair + pa->totkey) { copy_v3_v3(nhkey->co, hkey->co); nhkey->editflag = hkey->editflag; nhkey->time= hkey->time; @@ -2175,10 +2176,10 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) hkey++; } - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); - if(point->keys) + if (point->keys) MEM_freeN(point->keys); pa->hair= new_hkeys; @@ -2214,12 +2215,12 @@ static void subdivide_particle(PEData *data, int pa_index) sim.ob= data->ob; sim.psys= edit->psys; - for(k=0, ekey=point->keys; k<pa->totkey-1; k++,ekey++) { - if(ekey->flag&PEK_SELECT && (ekey+1)->flag&PEK_SELECT) + for (k=0, ekey=point->keys; k<pa->totkey-1; k++,ekey++) { + if (ekey->flag&PEK_SELECT && (ekey+1)->flag&PEK_SELECT) totnewkey++; } - if(totnewkey==0) return; + if (totnewkey==0) return; pa->flag |= PARS_REKEY; @@ -2229,7 +2230,7 @@ static void subdivide_particle(PEData *data, int pa_index) key = pa->hair; endtime= key[pa->totkey-1].time; - for(k=0, ekey=point->keys; k<pa->totkey-1; k++, key++, ekey++) { + for (k=0, ekey=point->keys; k<pa->totkey-1; k++, key++, ekey++) { memcpy(nkey,key,sizeof(HairKey)); memcpy(nekey,ekey,sizeof(PTCacheEditKey)); @@ -2240,7 +2241,7 @@ static void subdivide_particle(PEData *data, int pa_index) nkey++; nekey++; - if(ekey->flag & PEK_SELECT && (ekey+1)->flag & PEK_SELECT) { + if (ekey->flag & PEK_SELECT && (ekey+1)->flag & PEK_SELECT) { nkey->time= (key->time + (key+1)->time)*0.5f; state.time= (endtime != 0.0f)? nkey->time/endtime: 0.0f; psys_get_particle_on_path(&sim, pa_index, &state, 0); @@ -2249,7 +2250,7 @@ static void subdivide_particle(PEData *data, int pa_index) nekey->co= nkey->co; nekey->time= &nkey->time; nekey->flag |= PEK_SELECT; - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) nekey->flag |= PEK_USE_WCO; nekey++; @@ -2263,11 +2264,11 @@ static void subdivide_particle(PEData *data, int pa_index) nekey->co= nkey->co; nekey->time= &nkey->time; - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); pa->hair= new_keys; - if(point->keys) + if (point->keys) MEM_freeN(point->keys); point->keys= new_ekeys; @@ -2319,7 +2320,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) float mat[4][4], co[3], threshold= RNA_float_get(op->ptr, "threshold"); int n, totn, removed, totremoved; - if(psys->flag & PSYS_GLOBAL_HAIR) + if (psys->flag & PSYS_GLOBAL_HAIR) return OPERATOR_CANCELLED; edit= psys->edit; @@ -2349,10 +2350,10 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) totn= BLI_kdtree_find_n_nearest(tree,10,co,NULL,nearest); - for(n=0; n<totn; n++) { + for (n=0; n<totn; n++) { /* this needs a custom threshold still */ - if(nearest[n].index > p && nearest[n].dist < threshold) { - if(!(point->flag & PEP_TAG)) { + if (nearest[n].index > p && nearest[n].dist < threshold) { + if (!(point->flag & PEP_TAG)) { point->flag |= PEP_TAG; removed++; } @@ -2367,7 +2368,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) totremoved += removed; } while(removed); - if(totremoved == 0) + if (totremoved == 0) return OPERATOR_CANCELLED; BKE_reportf(op->reports, RPT_INFO, "Remove %d double particles", totremoved); @@ -2451,12 +2452,12 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); ParticleBrushData *brush; - if(pset->brushtype < 0) + if (pset->brushtype < 0) return; brush= &pset->brush[pset->brushtype]; - if(brush) { + if (brush) { glPushMatrix(); glTranslatef((float)x, (float)y, 0.0f); @@ -2476,11 +2477,11 @@ static void toggle_particle_cursor(bContext *C, int enable) { ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); - if(pset->paintcursor && !enable) { + if (pset->paintcursor && !enable) { WM_paint_cursor_end(CTX_wm_manager(C), pset->paintcursor); pset->paintcursor = NULL; } - else if(enable) + else if (enable) pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_view3d, brush_drawcursor, NULL); } @@ -2514,12 +2515,12 @@ static int delete_exec(bContext *C, wmOperator *op) PE_set_data(C, &data); - if(type == DEL_KEY) { + if (type == DEL_KEY) { foreach_selected_key(&data, set_delete_particle_key); remove_tagged_keys(data.ob, data.edit->psys); recalc_lengths(data.edit); } - else if(type == DEL_PARTICLE) { + else if (type == DEL_PARTICLE) { foreach_selected_point(&data, set_delete_particle); remove_tagged_particles(data.ob, data.edit->psys, pe_x_mirror(data.ob)); recalc_lengths(data.edit); @@ -2564,25 +2565,25 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) int *mirrorfaces = NULL; int rotation, totpart, newtotpart; - if(psys->flag & PSYS_GLOBAL_HAIR) + if (psys->flag & PSYS_GLOBAL_HAIR) return; psmd= psys_get_modifier(ob, psys); - if(!psmd->dm) + if (!psmd->dm) return; mirrorfaces= mesh_get_x_mirror_faces(ob, NULL); - if(!edit->mirror_cache) + if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); totpart= psys->totpart; newtotpart= psys->totpart; LOOP_VISIBLE_POINTS { pa = psys->particles + p; - if(!tagged) { - if(point_is_selected(point)) { - if(edit->mirror_cache[p] != -1) { + if (!tagged) { + if (point_is_selected(point)) { + if (edit->mirror_cache[p] != -1) { /* already has a mirror, don't need to duplicate */ PE_mirror_particle(ob, psmd->dm, psys, pa, NULL); continue; @@ -2592,28 +2593,28 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) } } - if((point->flag & PEP_TAG) && mirrorfaces[pa->num*2] != -1) + if ((point->flag & PEP_TAG) && mirrorfaces[pa->num*2] != -1) newtotpart++; } - if(newtotpart != psys->totpart) { + if (newtotpart != psys->totpart) { /* allocate new arrays and copy existing */ new_pars= MEM_callocN(newtotpart*sizeof(ParticleData), "ParticleData new"); new_points= MEM_callocN(newtotpart*sizeof(PTCacheEditPoint), "PTCacheEditPoint new"); - if(psys->particles) { + if (psys->particles) { memcpy(new_pars, psys->particles, totpart*sizeof(ParticleData)); MEM_freeN(psys->particles); } psys->particles= new_pars; - if(edit->points) { + if (edit->points) { memcpy(new_points, edit->points, totpart*sizeof(PTCacheEditPoint)); MEM_freeN(edit->points); } edit->points= new_points; - if(edit->mirror_cache) { + if (edit->mirror_cache) { MEM_freeN(edit->mirror_cache); edit->mirror_cache= NULL; } @@ -2624,19 +2625,19 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) newpa= psys->particles + totpart; newpoint= edit->points + totpart; - for(p=0, point=edit->points; p<totpart; p++, point++) { + for (p=0, point=edit->points; p<totpart; p++, point++) { pa = psys->particles + p; - if(point->flag & PEP_HIDE) + if (point->flag & PEP_HIDE) continue; - if(!(point->flag & PEP_TAG) || mirrorfaces[pa->num*2] == -1) + if (!(point->flag & PEP_TAG) || mirrorfaces[pa->num*2] == -1) continue; /* duplicate */ *newpa= *pa; *newpoint= *point; - if(pa->hair) newpa->hair= MEM_dupallocN(pa->hair); - if(point->keys) newpoint->keys= MEM_dupallocN(point->keys); + if (pa->hair) newpa->hair= MEM_dupallocN(pa->hair); + if (point->keys) newpoint->keys= MEM_dupallocN(point->keys); /* rotate weights according to vertex index rotation */ rotation= mirrorfaces[pa->num*2+1]; @@ -2658,7 +2659,7 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) /* update edit key pointers */ key= newpoint->keys; - for(k=0, hkey=newpa->hair; k<newpa->totkey; k++, hkey++, key++) { + for (k=0, hkey=newpa->hair; k<newpa->totkey; k++, hkey++, key++) { key->co= hkey->co; key->time= &hkey->time; } @@ -2714,7 +2715,7 @@ static void brush_comb(PEData *data, float UNUSED(mat[][4]), float imat[][4], in ParticleEditSettings *pset= PE_settings(data->scene); float cvec[3], fac; - if(pset->flag & PE_LOCK_FIRST && key_index == 0) return; + if (pset->flag & PE_LOCK_FIRST && key_index == 0) return; fac= (float)pow((double)(1.0f - data->dist / data->rad), (double)data->combfac); @@ -2739,10 +2740,10 @@ static void brush_cut(PEData *data, int pa_index) int vertco[2]; /* blunt scissors */ - if(BLI_frand() > data->cutfac) return; + if (BLI_frand() > data->cutfac) return; /* don't cut hidden */ - if(edit->points[pa_index].flag & PEP_HIDE) + if (edit->points[pa_index].flag & PEP_HIDE) return; rad2= data->rad * data->rad; @@ -2760,16 +2761,16 @@ static void brush_cut(PEData *data, int pa_index) xo1= x1 - o1; /* check if root is inside circle */ - if(xo0*xo0 + xo1*xo1 < rad2 && key_test_depth(data, key->co)) { + if (xo0*xo0 + xo1*xo1 < rad2 && key_test_depth(data, key->co)) { cut_time= -1.0f; cut= 1; } else { /* calculate path time closest to root that was inside the circle */ - for(k=1, key++; k<=keys; k++, key++) { + for (k=1, key++; k<=keys; k++, key++) { project_int_noclip(ar, key->co, vertco); - if(key_test_depth(data, key->co) == 0) { + if (key_test_depth(data, key->co) == 0) { x0= (float)vertco[0]; x1= (float)vertco[1]; @@ -2787,15 +2788,15 @@ static void brush_cut(PEData *data, int pa_index) d= dv * rad2 - d*d; - if(d > 0.0f) { + if (d > 0.0f) { d= sqrt(d); cut_time= -(v0*xo0 + v1*xo1 + d); - if(cut_time > 0.0f) { + if (cut_time > 0.0f) { cut_time /= dv; - if(cut_time < 1.0f) { + if (cut_time < 1.0f) { cut_time += (float)(k-1); cut_time /= (float)keys; cut= 1; @@ -2812,8 +2813,8 @@ static void brush_cut(PEData *data, int pa_index) } } - if(cut) { - if(cut_time < 0.0f) { + if (cut) { + if (cut_time < 0.0f) { edit->points[pa_index].flag |= PEP_TAG; } else { @@ -2831,7 +2832,7 @@ static void brush_length(PEData *data, int point_index) float dvec[3],pvec[3] = {0.0f, 0.0f, 0.0f}; LOOP_KEYS { - if(k==0) { + if (k==0) { copy_v3_v3(pvec,key->co); } else { @@ -2863,7 +2864,7 @@ static void brush_puff(PEData *data, int point_index) puff_volume = brush->flag & PE_BRUSH_DATA_PUFF_VOLUME; } - if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { + if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, data->dm, psys->part->from, psys->particles + point_index, mat); invert_m4_m4(imat,mat); } @@ -2873,14 +2874,14 @@ static void brush_puff(PEData *data, int point_index) } LOOP_KEYS { - if(k==0) { + if (k==0) { /* find root coordinate and normal on emitter */ copy_v3_v3(co, key->co); mul_m4_v3(mat, co); mul_v3_m4v3(kco, data->ob->imat, co); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */ point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL); - if(point_index == -1) return; + if (point_index == -1) return; copy_v3_v3(rootco, co); copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]); @@ -2891,7 +2892,7 @@ static void brush_puff(PEData *data, int point_index) fac= (float)pow((double)(1.0f - data->dist / data->rad), (double)data->pufffac); fac *= 0.025f; - if(data->invert) + if (data->invert) fac= -fac; } else { @@ -2901,7 +2902,7 @@ static void brush_puff(PEData *data, int point_index) copy_v3_v3(co, key->co); mul_m4_v3(mat, co); length += len_v3v3(lastco, co); - if((data->select==0 || (key->flag & PEK_SELECT)) && !(key->flag & PEK_HIDE)) { + if ((data->select==0 || (key->flag & PEK_SELECT)) && !(key->flag & PEK_HIDE)) { madd_v3_v3v3fl(kco, rootco, nor, length); /* blend between the current and straight position */ @@ -2913,7 +2914,7 @@ static void brush_puff(PEData *data, int point_index) mul_v3_m4v3(key->co, imat, co); - if(puff_volume) { + if (puff_volume) { /* accumulate the total distance moved to apply to unselected * keys that come after */ ofs[0] += key->co[0] - dco[0]; @@ -2924,13 +2925,13 @@ static void brush_puff(PEData *data, int point_index) } else { - if(puff_volume) { + if (puff_volume) { #if 0 /* this is simple but looks bad, adds annoying kinks */ add_v3_v3(key->co, ofs); #else /* translate (not rotate) the rest of the hair if its not selected */ - if(ofs[0] || ofs[1] || ofs[2]) { + if (ofs[0] || ofs[1] || ofs[2]) { #if 0 /* kindof works but looks worse then whats below */ /* Move the unselected point on a vector based on the @@ -2955,7 +2956,7 @@ static void brush_puff(PEData *data, int point_index) mul_v3_m4v3(kco, data->ob->imat, oco); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */ point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL); - if(point_index != -1) { + if (point_index != -1) { copy_v3_v3(onor, &edit->emitter_cosnos[point_index*6+3]); mul_mat3_m4_v3(data->ob->obmat, onor); /* normal into worldspace */ mul_mat3_m4_v3(imat, onor); /* worldspace into particle space */ @@ -2973,7 +2974,7 @@ static void brush_puff(PEData *data, int point_index) } } - if(change) + if (change) point->flag |= PEP_EDIT_RECALC; } @@ -2981,7 +2982,7 @@ static void brush_puff(PEData *data, int point_index) static void brush_weight(PEData *data, float UNUSED(mat[][4]), float UNUSED(imat[][4]), int point_index, int key_index, PTCacheEditKey *UNUSED(key)) { /* roots have full weight allways */ - if(key_index) { + if (key_index) { PTCacheEdit *edit = data->edit; ParticleSystem *psys = edit->psys; @@ -2994,7 +2995,7 @@ static void brush_weight(PEData *data, float UNUSED(mat[][4]), float UNUSED(imat static void brush_smooth_get(PEData *data, float mat[][4], float UNUSED(imat[][4]), int UNUSED(point_index), int key_index, PTCacheEditKey *key) { - if(key_index) { + if (key_index) { float dvec[3]; sub_v3_v3v3(dvec,key->co,(key-1)->co); @@ -3008,7 +3009,7 @@ static void brush_smooth_do(PEData *data, float UNUSED(mat[][4]), float imat[][4 { float vec[3], dvec[3]; - if(key_index) { + if (key_index) { copy_v3_v3(vec, data->vec); mul_mat3_m4_v3(imat,vec); @@ -3054,16 +3055,16 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3],p_max[3]; float cur_ipoint[3]; - if(dm == NULL){ + if (dm == NULL) { psys_disable_all(ob); dm=mesh_get_derived_final(scene, ob, 0); - if(dm == NULL) + if (dm == NULL) dm=mesh_get_derived_deform(scene, ob, 0); psys_enable_all(ob); - if(dm == NULL) + if (dm == NULL) return 0; } @@ -3071,12 +3072,12 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, DM_ensure_tessface(dm); - if(pa_minmax==0){ + if (pa_minmax==0) { INIT_MINMAX(p_min,p_max); DO_MINMAX(co1,p_min,p_max); DO_MINMAX(co2,p_min,p_max); } - else{ + else { copy_v3_v3(p_min,pa_minmax); copy_v3_v3(p_max,pa_minmax+3); } @@ -3086,23 +3087,23 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, mvert=dm->getVertDataArray(dm,CD_MVERT); /* lets intersect the faces */ - for(i=0; i<totface; i++,mface++){ - if(vert_cos){ + for (i=0; i<totface; i++,mface++) { + if (vert_cos) { copy_v3_v3(v1,vert_cos+3*mface->v1); copy_v3_v3(v2,vert_cos+3*mface->v2); copy_v3_v3(v3,vert_cos+3*mface->v3); - if(mface->v4) + if (mface->v4) copy_v3_v3(v4,vert_cos+3*mface->v4); } - else{ + else { copy_v3_v3(v1,mvert[mface->v1].co); copy_v3_v3(v2,mvert[mface->v2].co); copy_v3_v3(v3,mvert[mface->v3].co); - if(mface->v4) + if (mface->v4) copy_v3_v3(v4,mvert[mface->v4].co); } - if(face_minmax==0){ + if (face_minmax==0) { INIT_MINMAX(min,max); DO_MINMAX(v1,min,max); DO_MINMAX(v2,min,max); @@ -3112,25 +3113,25 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, if (isect_aabb_aabb_v3(min,max,p_min,p_max)==0) continue; } - else{ + else { copy_v3_v3(min, face_minmax+6*i); copy_v3_v3(max, face_minmax+6*i+3); - if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0) + if (isect_aabb_aabb_v3(min,max,p_min,p_max)==0) continue; } - if(radius>0.0f){ - if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){ - if(cur_d<*min_d){ + if (radius>0.0f) { + if (isect_sweeping_sphere_tri_v3(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)) { + if (cur_d<*min_d) { *min_d=cur_d; copy_v3_v3(ipoint,cur_ipoint); *min_face=i; intersect=1; } } - if(mface->v4){ - if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){ - if(cur_d<*min_d){ + if (mface->v4) { + if (isect_sweeping_sphere_tri_v3(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)) { + if (cur_d<*min_d) { *min_d=cur_d; copy_v3_v3(ipoint,cur_ipoint); *min_face=i; @@ -3139,23 +3140,23 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, } } } - else{ - if(isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)){ - if(cur_d<*min_d){ + else { + if (isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)) { + if (cur_d<*min_d) { *min_d=cur_d; min_w[0]= 1.0f - cur_uv[0] - cur_uv[1]; min_w[1]= cur_uv[0]; min_w[2]= cur_uv[1]; min_w[3]= 0.0f; - if(mface->v4) + if (mface->v4) intersect_dm_quad_weights(v1, v2, v3, v4, min_w); *min_face=i; intersect=1; } } - if(mface->v4){ - if(isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)){ - if(cur_d<*min_d){ + if (mface->v4) { + if (isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)) { + if (cur_d<*min_d) { *min_d=cur_d; min_w[0]= 1.0f - cur_uv[0] - cur_uv[1]; min_w[1]= 0.0f; @@ -3192,7 +3193,7 @@ static int brush_add(PEData *data, short number) DerivedMesh *dm=0; invert_m4_m4(imat,ob->obmat); - if(psys->flag & PSYS_GLOBAL_HAIR) + if (psys->flag & PSYS_GLOBAL_HAIR) return 0; BLI_srandom(psys->seed+data->mval[0]+data->mval[1]); @@ -3205,13 +3206,13 @@ static int brush_add(PEData *data, short number) timestep= psys_get_timestep(&sim); /* painting onto the deformed mesh, could be an option? */ - if(psmd->dm->deformedOnly) + if (psmd->dm->deformedOnly) dm= psmd->dm; else dm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); - for(i=0; i<number; i++) { - if(number>1) { + for (i=0; i<number; i++) { + if (number>1) { dmx=dmy=size; while(dmx*dmx+dmy*dmy>size2) { dmx=(short)((2.0f*BLI_frand()-1.0f)*size); @@ -3228,12 +3229,12 @@ static int brush_add(PEData *data, short number) min_d=2.0; /* warning, returns the derived mesh face */ - if(particle_intersect_dm(scene, ob,dm,0,co1,co2,&min_d,&add_pars[n].num,add_pars[n].fuv,0,0,0,0)) { + if (particle_intersect_dm(scene, ob,dm,0,co1,co2,&min_d,&add_pars[n].num,add_pars[n].fuv,0,0,0,0)) { add_pars[n].num_dmcache= psys_particle_dm_face_lookup(ob,psmd->dm,add_pars[n].num,add_pars[n].fuv,NULL); n++; } } - if(n) { + if (n) { int newtotpart=totpart+n; float hairmat[4][4], cur_co[3]; KDTree *tree=0; @@ -3247,22 +3248,22 @@ static int brush_add(PEData *data, short number) memcpy(new_points, edit->points, totpart * sizeof(PTCacheEditPoint)); /* change old arrays to new ones */ - if(psys->particles) MEM_freeN(psys->particles); + if (psys->particles) MEM_freeN(psys->particles); psys->particles= new_pars; - if(edit->points) MEM_freeN(edit->points); + if (edit->points) MEM_freeN(edit->points); edit->points= new_points; - if(edit->mirror_cache) { + if (edit->mirror_cache) { MEM_freeN(edit->mirror_cache); edit->mirror_cache= NULL; } /* create tree for interpolation */ - if(pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) { + if (pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) { tree=BLI_kdtree_new(psys->totpart); - for(i=0, pa=psys->particles; i<totpart; i++, pa++) { + for (i=0, pa=psys->particles; i<totpart; i++, pa++) { psys_particle_on_dm(psmd->dm,psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,cur_co,0,0,0,0,0); BLI_kdtree_insert(tree, i, cur_co, NULL); } @@ -3276,17 +3277,17 @@ static int brush_add(PEData *data, short number) pa= psys->particles + totpart; point= edit->points + totpart; - for(i=totpart; i<newtotpart; i++, pa++, point++) { + for (i=totpart; i<newtotpart; i++, pa++, point++) { memcpy(pa, add_pars + i - totpart, sizeof(ParticleData)); pa->hair= MEM_callocN(pset->totaddkey * sizeof(HairKey), "BakeKey key add"); key= point->keys= MEM_callocN(pset->totaddkey * sizeof(PTCacheEditKey), "PTCacheEditKey add"); point->totkey= pa->totkey= pset->totaddkey; - for(k=0, hkey=pa->hair; k<pa->totkey; k++, hkey++, key++) { + for (k=0, hkey=pa->hair; k<pa->totkey; k++, hkey++, key++) { key->co= hkey->co; key->time= &hkey->time; - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) key->flag |= PEK_USE_WCO; } @@ -3294,12 +3295,12 @@ static int brush_add(PEData *data, short number) initialize_particle(&sim, pa,i); reset_particle(&sim, pa, 0.0, 1.0); point->flag |= PEP_EDIT_RECALC; - if(pe_x_mirror(ob)) + if (pe_x_mirror(ob)) point->flag |= PEP_TAG; /* signal for duplicate */ framestep= pa->lifetime/(float)(pset->totaddkey-1); - if(tree) { + if (tree) { ParticleData *ppa; HairKey *thkey; ParticleKey key3[3]; @@ -3312,20 +3313,20 @@ static int brush_add(PEData *data, short number) maxd= ptn[maxw-1].dist; - for(w=0; w<maxw; w++) { + for (w=0; w<maxw; w++) { weight[w]= (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd)); totw += weight[w]; } - for(;w<3; w++) { + for (;w<3; w++) { weight[w]= 0.0f; } - for(w=0; w<maxw; w++) + for (w=0; w<maxw; w++) weight[w] /= totw; ppa= psys->particles+ptn[0].index; - for(k=0; k<pset->totaddkey; k++) { + for (k=0; k<pset->totaddkey; k++) { thkey= (HairKey*)pa->hair + k; thkey->time= pa->time + k * framestep; @@ -3336,13 +3337,13 @@ static int brush_add(PEData *data, short number) /* TODO: interpolatint the weight would be nicer */ thkey->weight= (ppa->hair+MIN2(k, ppa->totkey-1))->weight; - if(maxw>1) { + if (maxw>1) { key3[1].time= key3[0].time; psys_get_particle_on_path(&sim, ptn[1].index, &key3[1], 0); mul_v3_fl(key3[1].co, weight[1]); add_v3_v3(key3[0].co, key3[1].co); - if(maxw>2) { + if (maxw>2) { key3[2].time= key3[0].time; psys_get_particle_on_path(&sim, ptn[2].index, &key3[2], 0); mul_v3_fl(key3[2].co, weight[2]); @@ -3350,7 +3351,7 @@ static int brush_add(PEData *data, short number) } } - if(k==0) + if (k==0) sub_v3_v3v3(co1, pa->state.co, key3[0].co); add_v3_v3v3(thkey->co, key3[0].co, co1); @@ -3359,26 +3360,26 @@ static int brush_add(PEData *data, short number) } } else { - for(k=0, hkey=pa->hair; k<pset->totaddkey; k++, hkey++) { + for (k=0, hkey=pa->hair; k<pset->totaddkey; k++, hkey++) { madd_v3_v3v3fl(hkey->co, pa->state.co, pa->state.vel, k * framestep * timestep); hkey->time += k * framestep; hkey->weight = 1.f - (float)k/(float)(pset->totaddkey-1); } } - for(k=0, hkey=pa->hair; k<pset->totaddkey; k++, hkey++) { + for (k=0, hkey=pa->hair; k<pset->totaddkey; k++, hkey++) { psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); invert_m4_m4(imat,hairmat); mul_m4_v3(imat, hkey->co); } } - if(tree) + if (tree) BLI_kdtree_free(tree); } - if(add_pars) + if (add_pars) MEM_freeN(add_pars); - if(!psmd->dm->deformedOnly) + if (!psmd->dm->deformedOnly) dm->release(dm); return n; @@ -3407,7 +3408,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) ARegion *ar= CTX_wm_region(C); BrushEdit *bedit; - if(pset->brushtype < 0) + if (pset->brushtype < 0) return 0; initgrabz(ar->regiondata, ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2]); @@ -3442,7 +3443,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) float dx, dy, dmax; int lock_root = pset->flag & PE_LOCK_FIRST; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return; RNA_float_get_array(itemptr, "mouse", mousef); @@ -3450,7 +3451,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) mouse[1] = mousef[1]; flip= RNA_boolean_get(itemptr, "pen_flip"); - if(bedit->first) { + if (bedit->first) { bedit->lastmouse[0]= mouse[0]; bedit->lastmouse[1]= mouse[1]; } @@ -3463,10 +3464,10 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) /* disable locking temporatily for disconnected hair */ - if(edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) + if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) pset->flag &= ~PE_LOCK_FIRST; - if(((pset->brushtype == PE_BRUSH_ADD) ? + if (((pset->brushtype == PE_BRUSH_ADD) ? (sqrt(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) : (dx != 0 || dy != 0)) || bedit->first) { PEData data= bedit->data; @@ -3480,7 +3481,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) dx /= (float)tot_steps; dy /= (float)tot_steps; - for(step = 1; step<=tot_steps; step++) { + for (step = 1; step<=tot_steps; step++) { mval[0] = bedit->lastmouse[0] + step*dx; mval[1] = bedit->lastmouse[1] + step*dy; @@ -3492,7 +3493,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.rad= (float)brush->size; data.combfac= (brush->strength - 0.5f) * 2.0f; - if(data.combfac < 0.0f) + if (data.combfac < 0.0f) data.combfac= 1.0f - 9.0f * data.combfac; else data.combfac= 1.0f - data.combfac; @@ -3509,18 +3510,18 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_CUT: { - if(edit->psys && edit->pathcache) { + if (edit->psys && edit->pathcache) { data.mval= mval; data.rad= (float)brush->size; data.cutfac= brush->strength; - if(selected) + if (selected) foreach_selected_point(&data, brush_cut); else foreach_point(&data, brush_cut); removed= remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob)); - if(pset->flag & PE_KEEP_LENGTHS) + if (pset->flag & PE_KEEP_LENGTHS) recalc_lengths(edit); } else @@ -3535,27 +3536,27 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.rad= (float)brush->size; data.growfac= brush->strength / 50.0f; - if(brush->invert ^ flip) + if (brush->invert ^ flip) data.growfac= 1.0f - data.growfac; else data.growfac= 1.0f + data.growfac; foreach_mouse_hit_point(&data, brush_length, selected); - if(pset->flag & PE_KEEP_LENGTHS) + if (pset->flag & PE_KEEP_LENGTHS) recalc_lengths(edit); break; } case PE_BRUSH_PUFF: { - if(edit->psys) { + if (edit->psys) { data.dm= psmd->dm; data.mval= mval; data.rad= (float)brush->size; data.select= selected; data.pufffac= (brush->strength - 0.5f) * 2.0f; - if(data.pufffac < 0.0f) + if (data.pufffac < 0.0f) data.pufffac= 1.0f - 9.0f * data.pufffac; else data.pufffac= 1.0f - data.pufffac; @@ -3569,12 +3570,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_ADD: { - if(edit->psys && edit->psys->part->from==PART_FROM_FACE) { + if (edit->psys && edit->psys->part->from==PART_FROM_FACE) { data.mval= mval; added= brush_add(&data, brush->count); - if(pset->flag & PE_KEEP_LENGTHS) + if (pset->flag & PE_KEEP_LENGTHS) recalc_lengths(edit); } else @@ -3595,7 +3596,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) foreach_mouse_hit_key(&data, brush_smooth_get, selected); - if(data.tot) { + if (data.tot) { mul_v3_fl(data.vec, 1.0f / (float)data.tot); foreach_mouse_hit_key(&data, brush_smooth_do, selected); } @@ -3604,7 +3605,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_WEIGHT: { - if(edit->psys) { + if (edit->psys) { data.dm= psmd->dm; data.mval= mval; data.rad= (float)brush->size; @@ -3617,11 +3618,11 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) break; } } - if((pset->flag & PE_KEEP_LENGTHS)==0) + if ((pset->flag & PE_KEEP_LENGTHS)==0) recalc_lengths(edit); - if(ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_CUT) && (added || removed)) { - if(pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob)) + if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_CUT) && (added || removed)) { + if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob)) PE_mirror_x(scene, ob, 1); update_world_cos(ob,edit); @@ -3657,7 +3658,7 @@ static void brush_edit_exit(wmOperator *op) static int brush_edit_exec(bContext *C, wmOperator *op) { - if(!brush_edit_init(C, op)) + if (!brush_edit_init(C, op)) return OPERATOR_CANCELLED; RNA_BEGIN(op->ptr, itemptr, "stroke") { @@ -3689,7 +3690,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) static int brush_edit_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!brush_edit_init(C, op)) + if (!brush_edit_init(C, op)) return OPERATOR_CANCELLED; brush_edit_apply_event(C, op, event); @@ -3749,16 +3750,16 @@ static void free_PTCacheUndo(PTCacheUndo *undo) PTCacheEditPoint *point; int i; - for(i=0, point=undo->points; i<undo->totpoint; i++, point++) { - if(undo->particles && (undo->particles + i)->hair) + for (i=0, point=undo->points; i<undo->totpoint; i++, point++) { + if (undo->particles && (undo->particles + i)->hair) MEM_freeN((undo->particles + i)->hair); - if(point->keys) + if (point->keys) MEM_freeN(point->keys); } - if(undo->points) + if (undo->points) MEM_freeN(undo->points); - if(undo->particles) + if (undo->particles) MEM_freeN(undo->particles); BKE_ptcache_free_mem(&undo->mem_cache); @@ -3771,12 +3772,12 @@ static void make_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) undo->totpoint= edit->totpoint; - if(edit->psys) { + if (edit->psys) { ParticleData *pa; pa= undo->particles= MEM_dupallocN(edit->psys->particles); - for(i=0; i<edit->totpoint; i++, pa++) + for (i=0; i<edit->totpoint; i++, pa++) pa->hair= MEM_dupallocN(pa->hair); undo->psys_flag = edit->psys->flag; @@ -3787,8 +3788,8 @@ static void make_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) BLI_duplicatelist(&undo->mem_cache, &edit->pid.cache->mem_cache); pm = undo->mem_cache.first; - for(; pm; pm=pm->next) { - for(i=0; i<BPHYS_TOT_DATA; i++) + for (; pm; pm=pm->next) { + for (i=0; i<BPHYS_TOT_DATA; i++) pm->data[i] = MEM_dupallocN(pm->data[i]); } } @@ -3796,7 +3797,7 @@ static void make_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) point= undo->points = MEM_dupallocN(edit->points); undo->totpoint = edit->totpoint; - for(i=0; i<edit->totpoint; i++, point++) { + for (i=0; i<edit->totpoint; i++, point++) { point->keys= MEM_dupallocN(point->keys); /* no need to update edit key->co & key->time pointers here */ } @@ -3810,17 +3811,17 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) POINT_P; KEY_K; LOOP_POINTS { - if(psys && psys->particles[p].hair) + if (psys && psys->particles[p].hair) MEM_freeN(psys->particles[p].hair); - if(point->keys) + if (point->keys) MEM_freeN(point->keys); } - if(psys && psys->particles) + if (psys && psys->particles) MEM_freeN(psys->particles); - if(edit->points) + if (edit->points) MEM_freeN(edit->points); - if(edit->mirror_cache) { + if (edit->mirror_cache) { MEM_freeN(edit->mirror_cache); edit->mirror_cache= NULL; } @@ -3832,7 +3833,7 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) point->keys= MEM_dupallocN(point->keys); } - if(psys) { + if (psys) { psys->particles= MEM_dupallocN(undo->particles); psys->totpart= undo->totpoint; @@ -3860,15 +3861,15 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) pm = edit->pid.cache->mem_cache.first; - for(; pm; pm=pm->next) { - for(i=0; i<BPHYS_TOT_DATA; i++) + for (; pm; pm=pm->next) { + for (i=0; i<BPHYS_TOT_DATA; i++) pm->data[i] = MEM_dupallocN(pm->data[i]); BKE_ptcache_mem_pointers_init(pm); LOOP_POINTS { LOOP_KEYS { - if((int)key->ftime == (int)pm->frame) { + if ((int)key->ftime == (int)pm->frame) { key->co = pm->cur[BPHYS_DATA_LOCATION]; key->vel = pm->cur[BPHYS_DATA_VELOCITY]; key->rot = pm->cur[BPHYS_DATA_ROTATION]; @@ -3887,7 +3888,7 @@ void PE_undo_push(Scene *scene, const char *str) PTCacheUndo *undo; int nr; - if(!edit) return; + if (!edit) return; /* remove all undos after (also when curundo==NULL) */ while(edit->undo.last != edit->curundo) { @@ -3907,10 +3908,10 @@ void PE_undo_push(Scene *scene, const char *str) undo= edit->undo.last; while(undo) { nr++; - if(nr==U.undosteps) break; + if (nr==U.undosteps) break; undo= undo->prev; } - if(undo) { + if (undo) { while(edit->undo.first!=undo) { PTCacheUndo *first= edit->undo.first; BLI_remlink(&edit->undo, first); @@ -3927,16 +3928,16 @@ void PE_undo_step(Scene *scene, int step) { PTCacheEdit *edit= PE_get_current(scene, OBACT); - if(!edit) return; + if (!edit) return; - if(step==0) { + if (step==0) { get_PTCacheUndo(edit,edit->curundo); } - else if(step==1) { + else if (step==1) { - if(edit->curundo==NULL || edit->curundo->prev==NULL); + if (edit->curundo==NULL || edit->curundo->prev==NULL); else { - if(G.f & G_DEBUG) printf("undo %s\n", edit->curundo->name); + if (G.f & G_DEBUG) printf("undo %s\n", edit->curundo->name); edit->curundo= edit->curundo->prev; get_PTCacheUndo(edit, edit->curundo); } @@ -3944,11 +3945,11 @@ void PE_undo_step(Scene *scene, int step) else { /* curundo has to remain current situation! */ - if(edit->curundo==NULL || edit->curundo->next==NULL); + if (edit->curundo==NULL || edit->curundo->next==NULL); else { get_PTCacheUndo(edit, edit->curundo->next); edit->curundo= edit->curundo->next; - if(G.f & G_DEBUG) printf("redo %s\n", edit->curundo->name); + if (G.f & G_DEBUG) printf("redo %s\n", edit->curundo->name); } } @@ -3959,7 +3960,7 @@ int PE_undo_valid(Scene *scene) { PTCacheEdit *edit= PE_get_current(scene, OBACT); - if(edit) { + if (edit) { return (edit->undo.last != edit->undo.first); } return 0; @@ -3969,7 +3970,7 @@ static void PTCacheUndo_clear(PTCacheEdit *edit) { PTCacheUndo *undo; - if(edit==NULL) return; + if (edit==NULL) return; undo= edit->undo.first; while(undo) { @@ -3996,8 +3997,8 @@ void PE_undo_number(Scene *scene, int nr) PTCacheUndo *undo; int a=0; - for(undo= edit->undo.first; undo; undo= undo->next, a++) { - if(a==nr) break; + for (undo= edit->undo.first; undo; undo= undo->next, a++) { + if (a==nr) break; } edit->curundo= undo; PE_undo_step(scene, 0); @@ -4011,12 +4012,12 @@ const char *PE_undo_get_name(Scene *scene, int nr, int *active) PTCacheEdit *edit= PE_get_current(scene, OBACT); PTCacheUndo *undo; - if(active) *active= 0; + if (active) *active= 0; - if(edit) { + if (edit) { undo= BLI_findlink(&edit->undo, nr); - if(undo) { - if(active && undo==edit->curundo) + if (undo) { + if (active && undo==edit->curundo) *active= 1; return undo->name; } @@ -4036,15 +4037,15 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) float co[3], mat[4][4]; int ok= 0; - if(!edit) return ok; + if (!edit) return ok; - if((psys = edit->psys)) + if ((psys = edit->psys)) psmd= psys_get_modifier(ob, psys); else unit_m4(mat); LOOP_VISIBLE_POINTS { - if(psys) + if (psys) psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles+p, mat); LOOP_SELECTED_KEYS { @@ -4055,7 +4056,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) } } - if(!ok) { + if (!ok) { minmax_object(ob, min, max); ok= 1; } @@ -4076,23 +4077,23 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, int totpoint; /* no psmd->dm happens in case particle system modifier is not enabled */ - if(!(psys && psmd && psmd->dm) && !cache) + if (!(psys && psmd && psmd->dm) && !cache) return; - if(cache && cache->flag & PTCACHE_DISK_CACHE) + if (cache && cache->flag & PTCACHE_DISK_CACHE) return; - if(psys == NULL && cache->mem_cache.first == NULL) + if (psys == NULL && cache->mem_cache.first == NULL) return; - if(!edit) { + if (!edit) { totpoint = psys ? psys->totpart : (int)((PTCacheMem*)cache->mem_cache.first)->totpoint; edit= MEM_callocN(sizeof(PTCacheEdit), "PE_create_particle_edit"); edit->points=MEM_callocN(totpoint*sizeof(PTCacheEditPoint),"PTCacheEditPoints"); edit->totpoint = totpoint; - if(psys && !cache) { + if (psys && !cache) { psys->edit= edit; edit->psys = psys; @@ -4112,7 +4113,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, key->co= hkey->co; key->time= &hkey->time; key->flag= hkey->editflag; - if(!(psys->flag & PSYS_GLOBAL_HAIR)) { + if (!(psys->flag & PSYS_GLOBAL_HAIR)) { key->flag |= PEK_USE_WCO; hkey->editflag |= PEK_USE_WCO; } @@ -4131,15 +4132,15 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, cache->free_edit= PE_free_ptcache_edit; edit->psys = NULL; - for(pm=cache->mem_cache.first; pm; pm=pm->next) + for (pm=cache->mem_cache.first; pm; pm=pm->next) totframe++; - for(pm=cache->mem_cache.first; pm; pm=pm->next) { + for (pm=cache->mem_cache.first; pm; pm=pm->next) { LOOP_POINTS { - if(BKE_ptcache_mem_pointers_seek(p, pm) == 0) + if (BKE_ptcache_mem_pointers_seek(p, pm) == 0) continue; - if(!point->totkey) { + if (!point->totkey) { key = point->keys = MEM_callocN(totframe*sizeof(PTCacheEditKey),"ParticleEditKeys"); point->flag |= PEP_EDIT_RECALC; } @@ -4163,7 +4164,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col); recalc_lengths(edit); - if(psys && !cache) + if (psys && !cache) recalc_emitter_field(ob, psys); PE_update_object(scene, ob, 1); @@ -4177,7 +4178,7 @@ static int particle_edit_toggle_poll(bContext *C) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - if(!scene || !ob || ob->id.lib) + if (!scene || !ob || ob->id.lib) return 0; return (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)); @@ -4188,14 +4189,14 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { + if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) { PTCacheEdit *edit; ob->mode |= OB_MODE_PARTICLE_EDIT; edit= PE_create_current(scene, ob); /* mesh may have changed since last entering editmode. * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ - if(edit && edit->psys) + if (edit && edit->psys) recalc_emitter_field(ob, edit->psys); toggle_particle_cursor(C, 1); @@ -4234,8 +4235,8 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= CTX_data_active_object(C); ParticleSystem *psys = psys_get_current(ob); - if(psys->edit) { - if(psys->edit->edited || 1) { // XXX okee("Lose changes done in particle mode?")) + if (psys->edit) { + if (psys->edit->edited || 1) { // XXX okee("Lose changes done in particle mode?")) PE_free_ptcache_edit(psys->edit); psys->edit = NULL; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 964f83d8d9f..1e71cf61817 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -70,7 +70,7 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Scene *scene = CTX_data_scene(C); - if(!scene || !ob) + if (!scene || !ob) return OPERATOR_CANCELLED; object_add_particle_system(scene, ob, NULL); @@ -101,7 +101,7 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Scene *scene = CTX_data_scene(C); int mode_orig = ob->mode; - if(!scene || !ob) + if (!scene || !ob) return OPERATOR_CANCELLED; object_remove_particle_system(scene, ob); @@ -109,9 +109,9 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) /* possible this isn't the active object * object_remove_particle_system() clears the mode on the last psys * */ - if(mode_orig & OB_MODE_PARTICLE_EDIT) - if((ob->mode & OB_MODE_PARTICLE_EDIT)==0) - if(scene->basact && scene->basact->object==ob) + if (mode_orig & OB_MODE_PARTICLE_EDIT) + if ((ob->mode & OB_MODE_PARTICLE_EDIT)==0) + if (scene->basact && scene->basact->object==ob) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); @@ -157,14 +157,14 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) psys = ptr.data; /* add or copy particle setting */ - if(psys->part) + if (psys->part) part= psys_copy_settings(psys->part); else part= psys_new_settings("ParticleSettings", bmain); ob= ptr.id.data; - if(psys->part) + if (psys->part) psys->part->id.us--; psys->part = part; @@ -206,11 +206,11 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) ParticleTarget *pt; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; pt = psys->targets.first; - for(; pt; pt=pt->next) + for (; pt; pt=pt->next) pt->flag &= ~PTARGET_CURRENT; pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target"); @@ -252,12 +252,12 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) ParticleTarget *pt; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT) { + for (; pt; pt=pt->next) { + if (pt->flag & PTARGET_CURRENT) { BLI_remlink(&psys->targets, pt); MEM_freeN(pt); break; @@ -266,7 +266,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) } pt = psys->targets.last; - if(pt) + if (pt) pt->flag |= PTARGET_CURRENT; DAG_scene_sort(bmain, scene); @@ -300,12 +300,12 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ptr.id.data; ParticleTarget *pt; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT && pt->prev) { + for (; pt; pt=pt->next) { + if (pt->flag & PTARGET_CURRENT && pt->prev) { BLI_remlink(&psys->targets, pt); BLI_insertlink(&psys->targets, pt->prev->prev, pt); @@ -339,11 +339,11 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ptr.id.data; ParticleTarget *pt; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT && pt->next) { + for (; pt; pt=pt->next) { + if (pt->flag & PTARGET_CURRENT && pt->next) { BLI_remlink(&psys->targets, pt); BLI_insertlink(&psys->targets, pt->next, pt); @@ -377,12 +377,12 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; ParticleDupliWeight *dw; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; part = psys->part; - for(dw=part->dupliweights.first; dw; dw=dw->next) { - if(dw->flag & PART_DUPLIW_CURRENT && dw->prev) { + for (dw=part->dupliweights.first; dw; dw=dw->next) { + if (dw->flag & PART_DUPLIW_CURRENT && dw->prev) { BLI_remlink(&part->dupliweights, dw); BLI_insertlink(&part->dupliweights, dw->prev->prev, dw); @@ -415,11 +415,11 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; ParticleDupliWeight *dw; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; part = psys->part; - for(dw=part->dupliweights.first; dw; dw=dw->next) { - if(dw->flag & PART_DUPLIW_CURRENT) { + for (dw=part->dupliweights.first; dw; dw=dw->next) { + if (dw->flag & PART_DUPLIW_CURRENT) { dw->flag &= ~PART_DUPLIW_CURRENT; dw = MEM_dupallocN(dw); dw->flag |= PART_DUPLIW_CURRENT; @@ -454,12 +454,12 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; ParticleDupliWeight *dw; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; part = psys->part; - for(dw=part->dupliweights.first; dw; dw=dw->next) { - if(dw->flag & PART_DUPLIW_CURRENT) { + for (dw=part->dupliweights.first; dw; dw=dw->next) { + if (dw->flag & PART_DUPLIW_CURRENT) { BLI_remlink(&part->dupliweights, dw); MEM_freeN(dw); break; @@ -468,7 +468,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) } dw = part->dupliweights.last; - if(dw) + if (dw) dw->flag |= PART_DUPLIW_CURRENT; WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); @@ -499,12 +499,12 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; ParticleDupliWeight *dw; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; part = psys->part; - for(dw=part->dupliweights.first; dw; dw=dw->next) { - if(dw->flag & PART_DUPLIW_CURRENT && dw->next) { + for (dw=part->dupliweights.first; dw; dw=dw->next) { + if (dw->flag & PART_DUPLIW_CURRENT && dw->next) { BLI_remlink(&part->dupliweights, dw); BLI_insertlink(&part->dupliweights, dw->next, dw); @@ -542,27 +542,27 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) int i, k; float hairmat[4][4]; - if(!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) + if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) return; - if(!psys->part || psys->part->type != PART_HAIR) + if (!psys->part || psys->part->type != PART_HAIR) return; edit = psys->edit; point= edit ? edit->points : NULL; - for(i=0, pa=psys->particles; i<psys->totpart; i++,pa++) { - if(point) { + for (i=0, pa=psys->particles; i<psys->totpart; i++,pa++) { + if (point) { ekey = point->keys; point++; } psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - for(k=0,key=pa->hair; k<pa->totkey; k++,key++) { + for (k=0,key=pa->hair; k<pa->totkey; k++,key++) { mul_m4_v3(hairmat,key->co); - if(ekey) { + if (ekey) { ekey->flag &= ~PEK_USE_WCO; ekey++; } @@ -573,7 +573,7 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) psys->flag |= PSYS_GLOBAL_HAIR; - if(ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF)) + if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF)) pset->brushtype = PE_BRUSH_NONE; PE_update_object(scene, ob, 0); @@ -587,11 +587,11 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op) ParticleSystem *psys= NULL; int all = RNA_boolean_get(op->ptr, "all"); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; - if(all) { - for(psys=ob->particlesystem.first; psys; psys=psys->next) { + if (all) { + for (psys=ob->particlesystem.first; psys; psys=psys->next) { disconnect_hair(scene, ob, psys); } } @@ -637,13 +637,13 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) float hairmat[4][4], imat[4][4]; float v[4][3], vec[3]; - if(!psys || !psys->part || psys->part->type != PART_HAIR) + if (!psys || !psys->part || psys->part->type != PART_HAIR) return; edit= psys->edit; point= edit ? edit->points : NULL; - if(psmd->dm->deformedOnly) + if (psmd->dm->deformedOnly) /* we don't want to mess up psmd->dm when converting to global coordinates below */ dm= CDDM_copy(psmd->dm); else @@ -661,7 +661,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) bvhtree_from_mesh_faces(&bvhtree, dm, 0.0, 2, 6); - for(i=0, pa= psys->particles; i<psys->totpart; i++,pa++) { + for (i=0, pa= psys->particles; i<psys->totpart; i++,pa++) { key = pa->hair; nearest.index = -1; @@ -669,7 +669,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) BLI_bvhtree_find_nearest(bvhtree.tree, key->co, &nearest, bvhtree.nearest_callback, &bvhtree); - if(nearest.index == -1) { + if (nearest.index == -1) { if (G.f & G_DEBUG) printf("No nearest point found for hair root!"); continue; @@ -680,7 +680,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) copy_v3_v3(v[0], CDDM_get_vert(dm,mface->v1)->co); copy_v3_v3(v[1], CDDM_get_vert(dm,mface->v2)->co); copy_v3_v3(v[2], CDDM_get_vert(dm,mface->v3)->co); - if(mface->v4) { + if (mface->v4) { copy_v3_v3(v[3], CDDM_get_vert(dm,mface->v4)->co); interp_weights_poly_v3( pa->fuv,v, 4, nearest.co); } @@ -695,16 +695,16 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) sub_v3_v3v3(vec, nearest.co, key->co); - if(point) { + if (point) { ekey = point->keys; point++; } - for(k=0,key=pa->hair; k<pa->totkey; k++,key++) { + for (k=0,key=pa->hair; k<pa->totkey; k++,key++) { add_v3_v3(key->co, vec); mul_m4_v3(imat,key->co); - if(ekey) { + if (ekey) { ekey->flag |= PEK_USE_WCO; ekey++; } @@ -729,11 +729,11 @@ static int connect_hair_exec(bContext *C, wmOperator *op) ParticleSystem *psys= NULL; int all = RNA_boolean_get(op->ptr, "all"); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; - if(all) { - for(psys=ob->particlesystem.first; psys; psys=psys->next) { + if (all) { + for (psys=ob->particlesystem.first; psys; psys=psys->next) { connect_hair(scene, ob, psys); } } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index af229fc4cb1..23765b03d35 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -129,7 +129,8 @@ static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fs { if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { copy_v3_v3(gravity, scene->physics_settings.gravity); - } else { + } + else { copy_v3_v3(gravity, fss->grav); } } @@ -138,7 +139,8 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * { if (!scene->unit.system) { return fss->realsize; - } else { + } + else { float dim[3]; float longest_axis; @@ -212,20 +214,22 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char int i,j; int channelSize = paramsize; - if(entries==3) { + if (entries==3) { elbeemSimplifyChannelVec3( channel, &channelSize); - } else if(entries==1) { + } + else if (entries==1) { elbeemSimplifyChannelFloat( channel, &channelSize); - } else { + } + else { // invalid, cant happen? } fprintf(file, " CHANNEL %s = \n", str); - for(i=0; i<channelSize;i++) { + for (i=0; i<channelSize;i++) { fprintf(file," "); - for(j=0;j<=entries;j++) { // also print time value + for (j=0;j<=entries;j++) { // also print time value fprintf(file," %f ", channel[i*(entries+1)+j] ); - if(j==entries-1){ fprintf(file," "); } + if (j==entries-1) { fprintf(file," "); } } fprintf(file," \n"); } @@ -298,7 +302,7 @@ static void set_vertex_channel(float *channel, float time, struct Scene *scene, } /* fill frame of channel with vertex locations */ - for(j=0; j < (3*numVerts); j++) { + for (j=0; j < (3*numVerts); j++) { channel[i*framesize + j] = verts[j]; } channel[i*framesize + framesize-1] = time; @@ -468,7 +472,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid /* init euler rotation values and convert to elbeem format */ /* get the rotation from ob->obmat rather than ob->rot to account for parent animations */ - if(i) { + if (i) { copy_v3_v3(old_rot, fobj->Rotation + 4*(i-1)); mul_v3_fl(old_rot, -M_PI/180.f); } @@ -538,16 +542,16 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) fsmesh.channelScale = fobj->Scale; fsmesh.channelActive = fobj->Active; - if( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) { + if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) { fsmesh.channelInitialVel = fobj->InitialVelocity; fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD)?1:0); } - if(fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) + if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; - else if(fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) + else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP; - else if(fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) + else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP; fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue; @@ -578,7 +582,7 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) } /* animated meshes */ - if(deform) { + if (deform) { fsmesh.channelSizeVertices = length; fsmesh.channelVertices = fobj->VertexCache; @@ -590,8 +594,8 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) elbeemAddMesh(&fsmesh); - if(verts) MEM_freeN(verts); - if(tris) MEM_freeN(tris); + if (verts) MEM_freeN(verts); + if (tris) MEM_freeN(tris); } } @@ -602,7 +606,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom int channelObjCount = 0; int fluidInputCount = 0; - for(base=scene->base.first; base; base= base->next) + for (base=scene->base.first; base; base= base->next) { Object *ob = base->object; FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); @@ -610,7 +614,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom /* only find objects with fluid modifiers */ if (!fluidmdtmp || ob->type != OB_MESH) continue; - if(fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) { + if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) { /* if no initial domain object given, find another potential domain */ if (!fsDomain) { newdomain = ob; @@ -685,13 +689,13 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // check selected directory // simply try to open cfg file for writing to test validity of settings fileCfg = BLI_fopen(targetFile, "w"); - if(fileCfg) { + if (fileCfg) { dirExist = 1; fclose(fileCfg); // remove cfg dummy from directory test BLI_delete(targetFile, 0,0); } - if(targetDir[0] == '\0' || (!dirExist)) { + if (targetDir[0] == '\0' || (!dirExist)) { char blendDir[FILE_MAX]; char blendFile[FILE_MAX]; @@ -709,7 +713,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // check if modified output dir is ok #if 0 - if(outStringsChanged) { + if (outStringsChanged) { char dispmsg[FILE_MAX+256]; int selection=0; BLI_strncpy(dispmsg,"Output settings set to: '", sizeof(dispmsg)); @@ -718,7 +722,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // ask user if thats what he/she wants... selection = pupmenu(dispmsg); - if(selection<1) return 0; // 0 from menu, or -1 aborted + if (selection<1) return 0; // 0 from menu, or -1 aborted BLI_strncpy(targetDir, newSurfdataPath, sizeof(targetDir)); strncpy(domainSettings->surfdataPath, newSurfdataPath, FILE_MAXDIR); BLI_path_abs(targetDir, G.main->name); // fixed #frame-no @@ -751,7 +755,7 @@ static int fluidbake_breakjob(void *customdata) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - if(fb->stop && *(fb->stop)) + if (fb->stop && *(fb->stop)) return 1; /* this is not nice yet, need to make the jobs list template better @@ -865,7 +869,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *r BLI_delete(targetFileVel, 0, 0); BLI_delete(previewFile, 0, 0); } - } while(exists); + } while (exists); return; } @@ -904,7 +908,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job"); - if(getenv(strEnvName)) { + if (getenv(strEnvName)) { int dlevel = atoi(getenv(strEnvName)); elbeemSetDebugLevel(dlevel); BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName); @@ -913,7 +917,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */; noFrames = scene->r.efra - 0; - if(noFrames<=0) { + if (noFrames<=0) { BKE_report(reports, RPT_ERROR, "No frames to export - check your animation range settings"); fluidbake_free_data(channels, fobjects, fsset, fb); return 0; @@ -943,7 +947,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fluidsim_delete_until_lastframe(domainSettings, relbase); /* rough check of settings... */ - if(domainSettings->previewresxyz > domainSettings->resolutionxyz) { + if (domainSettings->previewresxyz > domainSettings->resolutionxyz) { BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz , domainSettings->resolutionxyz); elbeemDebugOut(debugStrBuffer); domainSettings->previewresxyz = domainSettings->resolutionxyz; @@ -952,16 +956,19 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // this should do as an approximation, with in/outflow // doing this more accurate would be overkill // perhaps add manual setting? - if(domainSettings->maxRefine <0) { - if(domainSettings->resolutionxyz>128) { + if (domainSettings->maxRefine <0) { + if (domainSettings->resolutionxyz>128) { gridlevels = 2; - } else - if(domainSettings->resolutionxyz>64) { + } + else + if (domainSettings->resolutionxyz>64) { gridlevels = 1; - } else { + } + else { gridlevels = 0; } - } else { + } + else { gridlevels = domainSettings->maxRefine; } BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels ); @@ -983,7 +990,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); - if(!invert_m4_m4(invDomMat, domainMat)) { + if (!invert_m4_m4(invDomMat, domainMat)) { BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::error - Invalid obj matrix?\n"); elbeemDebugOut(debugStrBuffer); BKE_report(reports, RPT_ERROR, "Invalid object matrix"); @@ -997,7 +1004,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor BLI_join_dirfile(targetFile, sizeof(targetFile), targetDir, suffixConfigTmp); // make sure these directories exist as well - if(outStringsChanged) { + if (outStringsChanged) { BLI_make_existing_file(targetFile); } @@ -1051,7 +1058,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fsset->domainobsPartslip = domainSettings->partSlipValue; /* use domainobsType also for surface generation flag (bit: >=64) */ - if(domainSettings->typeFlags & OB_FSSG_NOOBS) + if (domainSettings->typeFlags & OB_FSSG_NOOBS) fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS; else fsset->mFsSurfGenSetting = 0; // "normal" mode @@ -1060,8 +1067,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // init blender domain transform matrix { int j; - for(i=0; i<4; i++) { - for(j=0; j<4; j++) { + for (i=0; i<4; i++) { + for (j=0; j<4; j++) { fsset->surfaceTrafo[i*4+j] = invDomMat[j][i]; } } } @@ -1076,7 +1083,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* custom data for fluid bake job */ fb->settings = fsset; - if(do_job) { + if (do_job) { wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS); /* setup job */ @@ -1139,10 +1146,10 @@ static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { /* only one bake job at a time */ - if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) + if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) return OPERATOR_CANCELLED; - if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE)) + if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -1150,7 +1157,7 @@ static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) static int fluid_bake_exec(bContext *C, wmOperator *op) { - if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), FALSE)) + if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), FALSE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 9501dee30db..6573647aaee 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -67,7 +67,7 @@ static int ptcache_bake_all_poll(bContext *C) { Scene *scene= CTX_data_scene(C); - if(!scene) + if (!scene) return 0; return 1; @@ -114,7 +114,8 @@ static int ptcache_bake_all_exec(bContext *C, wmOperator *op) baker.progressbar = (void (*)(void *, int))WM_timecursor; baker.progressend = (void (*)(void *))WM_cursor_restore; baker.progresscontext = win; - } else { + } + else { baker.progressbar = bake_console_progress; baker.progressend = bake_console_progress_end; baker.progresscontext = NULL; @@ -134,10 +135,10 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op)) PTCacheID *pid; ListBase pidlist; - for(base=scene->base.first; base; base= base->next) { + for (base=scene->base.first; base; base= base->next) { BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { + for (pid=pidlist.first; pid; pid=pid->next) { pid->cache->flag &= ~PTCACHE_BAKED; } @@ -194,8 +195,8 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op) BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->cache == cache) + for (pid=pidlist.first; pid; pid=pid->next) { + if (pid->cache == cache) break; } @@ -216,7 +217,8 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op) baker.progressbar = (void (*)(void *, int))WM_timecursor; baker.progressend = (void (*)(void *))WM_cursor_restore; baker.progresscontext = win; - } else { + } + else { printf("\n"); /* empty first line before console reports */ baker.progressbar = bake_console_progress; baker.progressend = bake_console_progress_end; @@ -238,8 +240,8 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op)) PointCache *cache= ptr.data; Object *ob= ptr.id.data; - if(cache->edit) { - if(!cache->edit->edited || 1) {// XXX okee("Lose changes done in particle mode?")) { + if (cache->edit) { + if (!cache->edit->edited || 1) {// XXX okee("Lose changes done in particle mode?")) { PE_free_ptcache_edit(cache->edit); cache->edit = NULL; cache->flag &= ~PTCACHE_BAKED; @@ -320,8 +322,8 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op)) BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->cache == cache) { + for (pid=pidlist.first; pid; pid=pid->next) { + if (pid->cache == cache) { PointCache *cache = BKE_ptcache_add(pid->ptcaches); cache->step = pid->default_step; *(pid->cache_ptr) = cache; @@ -347,9 +349,9 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->cache == cache) { - if(pid->ptcaches->first == pid->ptcaches->last) + for (pid=pidlist.first; pid; pid=pid->next) { + if (pid->cache == cache) { + if (pid->ptcaches->first == pid->ptcaches->last) continue; /* don't delete last cache */ BLI_remlink(pid->ptcaches, pid->cache); |