diff options
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/dynamicpaint_ops.c | 24 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_boids.c | 42 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 192 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 192 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 266 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_pointcache.c | 30 | ||||
-rw-r--r-- | source/blender/editors/physics/rigidbody_world.c | 4 |
8 files changed, 379 insertions, 379 deletions
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 4f516ec9c51..d63c28bb0cf 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -100,7 +100,7 @@ void DPAINT_OT_surface_slot_add(wmOperatorType *ot) ot->name = "Add Surface Slot"; ot->idname = "DPAINT_OT_surface_slot_add"; ot->description = "Add a new Dynamic Paint surface slot"; - + /* api callbacks */ ot->exec = surface_slot_add_exec; ot->poll = ED_operator_object_active_editable; @@ -148,7 +148,7 @@ void DPAINT_OT_surface_slot_remove(wmOperatorType *ot) ot->name = "Remove Surface Slot"; ot->idname = "DPAINT_OT_surface_slot_remove"; ot->description = "Remove the selected surface slot"; - + /* api callbacks */ ot->exec = surface_slot_remove_exec; ot->poll = ED_operator_object_active_editable; @@ -179,7 +179,7 @@ static int type_toggle_exec(bContext *C, wmOperator *op) if (!dynamicPaint_createType(pmd, type, scene)) return OPERATOR_CANCELLED; } - + /* update dependency */ DAG_id_tag_update(&cObject->id, OB_RECALC_DATA); DAG_relations_tag_update(CTX_data_main(C)); @@ -196,14 +196,14 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot) ot->name = "Toggle Type Active"; ot->idname = "DPAINT_OT_type_toggle"; ot->description = "Toggle whether given type is active or not"; - + /* api callbacks */ ot->exec = type_toggle_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "type", rna_enum_prop_dynamicpaint_type_items, MOD_DYNAMICPAINT_TYPE_CANVAS, "Type", ""); ot->prop = prop; @@ -223,7 +223,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op) if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { int exists = dynamicPaint_outputLayerExists(surface, ob, output); const char *name; - + if (output == 0) name = surface->output_name; else @@ -233,7 +233,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op) if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { if (!exists) ED_mesh_color_add(ob->data, name, true); - else + else ED_mesh_color_remove_named(ob->data, name); } /* Vertex Weight Layer */ @@ -263,14 +263,14 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot) ot->name = "Toggle Output Layer"; ot->idname = "DPAINT_OT_output_toggle"; ot->description = "Add or remove Dynamic Paint output data layer"; - + /* api callbacks */ ot->exec = output_toggle_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "output", prop_output_toggle_types, 0, "Output Toggle", ""); } @@ -505,7 +505,7 @@ void DPAINT_OT_bake(wmOperatorType *ot) ot->name = "Dynamic Paint Bake"; ot->description = "Bake dynamic paint image sequence surface"; ot->idname = "DPAINT_OT_bake"; - + /* api callbacks */ ot->exec = dynamicpaint_bake_exec; ot->poll = ED_operator_object_active_editable; diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index cac96030b96..526eeb5d3ea 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -76,7 +76,7 @@ static int rule_add_exec(bContext *C, wmOperator *op) BLI_addtail(&state->rules, rule); DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); - + return OPERATOR_FINISHED; } @@ -86,14 +86,14 @@ void BOID_OT_rule_add(wmOperatorType *ot) ot->name = "Add Boid Rule"; ot->description = "Add a boid rule to the current boid state"; ot->idname = "BOID_OT_rule_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = rule_add_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_boidrule_type_items, 0, "Type", ""); } static int rule_del_exec(bContext *C, wmOperator *UNUSED(op)) @@ -133,7 +133,7 @@ void BOID_OT_rule_del(wmOperatorType *ot) ot->name = "Remove Boid Rule"; ot->idname = "BOID_OT_rule_del"; ot->description = "Delete current boid rule"; - + /* api callbacks */ ot->exec = rule_del_exec; @@ -151,7 +151,7 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op)) if (!part || part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; - + state = boid_get_current_state(part->boids); for (rule = state->rules.first; rule; rule=rule->next) { if (rule->flag & BOIDRULE_CURRENT && rule->prev) { @@ -162,7 +162,7 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -173,7 +173,7 @@ void BOID_OT_rule_move_up(wmOperatorType *ot) ot->idname = "BOID_OT_rule_move_up"; ot->exec = rule_move_up_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -187,7 +187,7 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op)) if (!part || part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; - + state = boid_get_current_state(part->boids); for (rule = state->rules.first; rule; rule=rule->next) { if (rule->flag & BOIDRULE_CURRENT && rule->next) { @@ -198,7 +198,7 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -209,7 +209,7 @@ void BOID_OT_rule_move_down(wmOperatorType *ot) ot->idname = "BOID_OT_rule_move_down"; ot->exec = rule_move_down_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -242,10 +242,10 @@ void BOID_OT_state_add(wmOperatorType *ot) ot->name = "Add Boid State"; ot->description = "Add a boid state to the particle system"; ot->idname = "BOID_OT_state_add"; - + /* api callbacks */ ot->exec = state_add_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -279,7 +279,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) DAG_relations_tag_update(bmain); DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); - + return OPERATOR_FINISHED; } @@ -289,7 +289,7 @@ void BOID_OT_state_del(wmOperatorType *ot) ot->name = "Remove Boid State"; ot->idname = "BOID_OT_state_del"; ot->description = "Delete current boid state"; - + /* api callbacks */ ot->exec = state_del_exec; @@ -309,7 +309,7 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; boids = part->boids; - + for (state = boids->states.first; state; state=state->next) { if (state->flag & BOIDSTATE_CURRENT && state->prev) { BLI_remlink(&boids->states, state); @@ -317,7 +317,7 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -328,7 +328,7 @@ void BOID_OT_state_move_up(wmOperatorType *ot) ot->idname = "BOID_OT_state_move_up"; ot->exec = state_move_up_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -344,7 +344,7 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; boids = part->boids; - + for (state = boids->states.first; state; state=state->next) { if (state->flag & BOIDSTATE_CURRENT && state->next) { BLI_remlink(&boids->states, state); @@ -353,7 +353,7 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -364,7 +364,7 @@ void BOID_OT_state_move_down(wmOperatorType *ot) ot->idname = "BOID_OT_state_move_down"; ot->exec = state_move_down_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index c05bf4f7dea..2a15fb21fb8 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -92,7 +92,7 @@ int PE_poll(bContext *C) if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; - + return (PE_get_current(scene, ob) != NULL); } @@ -104,7 +104,7 @@ int PE_hair_poll(bContext *C) if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; - + edit= PE_get_current(scene, ob); return (edit && edit->psys); @@ -179,7 +179,7 @@ static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *br // here we can enable unified brush size, needs more work... // UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; // float size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size; - + return brush->size * U.pixelsize; } @@ -320,7 +320,7 @@ static int pe_x_mirror(Object *ob) { if (ob->type == OB_MESH) return (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X); - + return 0; } @@ -329,7 +329,7 @@ static int pe_x_mirror(Object *ob) typedef struct PEData { ViewContext vc; bglMats mats; - + Scene *scene; Object *ob; DerivedMesh *dm; @@ -394,13 +394,13 @@ static void PE_set_view3d_data(bContext *C, PEData *data) static bool PE_create_shape_tree(PEData *data, Object *shapeob) { DerivedMesh *dm = shapeob->derivedFinal; - + memset(&data->shape_bvh, 0, sizeof(data->shape_bvh)); - + if (!dm) { return false; } - + return (bvhtree_from_mesh_get(&data->shape_bvh, dm, BVHTREE_FROM_LOOPTRI, 4) != NULL); } @@ -472,7 +472,7 @@ static bool key_inside_circle(PEData *data, float rad, const float co[3], float return 1; } - + return 0; } @@ -511,7 +511,7 @@ static bool point_is_selected(PTCacheEditPoint *point) LOOP_SELECTED_KEYS { return 1; } - + return 0; } @@ -756,7 +756,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) /* lookup particles and set in mirror cache */ if (!edit->mirror_cache) edit->mirror_cache= MEM_callocN(sizeof(int)*totpart, "PE mirror cache"); - + LOOP_PARTICLES { key = pa->hair; psys_mat_hair_to_orco(ob, psmd->dm_final, psys->part->from, pa, mat); @@ -801,7 +801,7 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys if (!mpa) { if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); - + if (!edit->mirror_cache) return; /* something went wrong! */ @@ -927,7 +927,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) LOOP_EDITED_POINTS { psys_mat_hair_to_object(ob, psmd->dm_final, psys->part->from, psys->particles + p, hairmat); - + LOOP_KEYS { mul_m4_v3(hairmat, key->co); } @@ -939,7 +939,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) } else { index= BLI_kdtree_find_nearest(edit->emitter_field, key->co, NULL); - + vec=edit->emitter_cosnos +index*6; nor=vec+3; @@ -964,7 +964,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) dist_1st*=1.3333f; } } - + invert_m4_m4(hairimat, hairmat); LOOP_KEYS { @@ -975,7 +975,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) /* force set distances between neighboring keys */ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit) { - + ParticleEditSettings *pset=PE_settings(scene); POINT_P; KEY_K; float dv1[3]; @@ -1114,7 +1114,7 @@ void recalc_emitter_field(Object *ob, ParticleSystem *psys) mvert=dm->getVertData(dm, mface->v4, CD_MVERT); add_v3_v3v3(vec, vec, mvert->co); VECADD(nor, nor, mvert->no); - + mul_v3_fl(vec, 0.25); } else @@ -1139,7 +1139,7 @@ static void PE_update_selection(Scene *scene, Object *ob, int useflag) LOOP_POINTS point->flag |= PEP_EDIT_RECALC; - /* flush edit key flag to hair key flag to preserve selection + /* flush edit key flag to hair key flag to preserve selection * on save */ if (edit->psys) LOOP_POINTS { hkey = edit->psys->particles[p].hair; @@ -1224,7 +1224,7 @@ static void update_velocities(PTCacheEdit *edit) } else { dfra = *(key+1)->time - *(key-1)->time; - + if (dfra <= 0.0f) continue; @@ -1411,7 +1411,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) ot->name = "(De)select All"; ot->idname = "PARTICLE_OT_select_all"; ot->description = "(De)select all particles' keys"; - + /* api callbacks */ ot->exec = pe_select_all_exec; ot->poll = PE_poll; @@ -1431,7 +1431,7 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec Object *ob= CTX_data_active_object(C); PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; @@ -1471,7 +1471,7 @@ static void select_root(PEData *data, int point_index) if (point->flag & PEP_HIDE) return; - + if (data->select_action != SEL_TOGGLE) select_action_apply(point, key, data->select_action); else if (key->flag & PEK_SELECT) @@ -1509,7 +1509,7 @@ void PARTICLE_OT_select_roots(wmOperatorType *ot) ot->name = "Select Roots"; ot->idname = "PARTICLE_OT_select_roots"; ot->description = "Select roots of all visible particles"; - + /* api callbacks */ ot->exec = select_roots_exec; ot->poll = PE_poll; @@ -1533,10 +1533,10 @@ static void select_tip(PEData *data, int point_index) } key = &point->keys[point->totkey - 1]; - + if (point->flag & PEP_HIDE) return; - + if (data->select_action != SEL_TOGGLE) select_action_apply(point, key, data->select_action); else if (key->flag & PEK_SELECT) @@ -1708,7 +1708,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->idname = "PARTICLE_OT_select_linked"; ot->description = "Select nearest particle from mouse pointer"; - + /* api callbacks */ ot->exec = select_linked_exec; ot->invoke = select_linked_invoke; @@ -1881,7 +1881,7 @@ static int hide_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - + if (RNA_enum_get(op->ptr, "unselected")) { LOOP_UNSELECTED_POINTS { point->flag |= PEP_HIDE; @@ -1913,7 +1913,7 @@ void PARTICLE_OT_hide(wmOperatorType *ot) ot->name = "Hide Selected"; ot->idname = "PARTICLE_OT_hide"; ot->description = "Hide selected particles"; - + /* api callbacks */ ot->exec = hide_exec; ot->poll = PE_poll; @@ -1958,7 +1958,7 @@ void PARTICLE_OT_reveal(wmOperatorType *ot) ot->name = "Reveal"; ot->idname = "PARTICLE_OT_reveal"; ot->description = "Show hidden particles"; - + /* api callbacks */ ot->exec = reveal_exec; ot->poll = PE_poll; @@ -2020,7 +2020,7 @@ void PARTICLE_OT_select_less(wmOperatorType *ot) ot->name = "Select Less"; ot->idname = "PARTICLE_OT_select_less"; ot->description = "Deselect boundary selected keys of each particle"; - + /* api callbacks */ ot->exec = select_less_exec; ot->poll = PE_poll; @@ -2082,7 +2082,7 @@ void PARTICLE_OT_select_more(wmOperatorType *ot) ot->name = "Select More"; ot->idname = "PARTICLE_OT_select_more"; ot->description = "Select keys linked to boundary selected keys of each particle"; - + /* api callbacks */ ot->exec = select_more_exec; ot->poll = PE_poll; @@ -2142,7 +2142,7 @@ static void rekey_particle(PEData *data, int pa_index) 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++) { ekey->co= key->co; ekey->time= &key->time; @@ -2165,7 +2165,7 @@ static int rekey_exec(bContext *C, wmOperator *op) data.totrekey= RNA_int_get(op->ptr, "keys_number"); foreach_selected_point(&data, rekey_particle); - + recalc_lengths(data.edit); PE_update_object(data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); @@ -2179,7 +2179,7 @@ void PARTICLE_OT_rekey(wmOperatorType *ot) ot->name = "Rekey"; ot->idname = "PARTICLE_OT_rekey"; ot->description = "Change the number of keys of selected particles (root and tip keys included)"; - + /* api callbacks */ ot->exec = rekey_exec; ot->invoke = WM_operator_props_popup; @@ -2216,7 +2216,7 @@ static void rekey_particle_to_time(Scene *scene, Object *ob, int pa_index, float pa->flag |= PARS_REKEY; 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++) { state.time= path_time * (float)k / (float)(pa->totkey-1); @@ -2375,7 +2375,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) nhkey->editflag = hkey->editflag; nhkey->time= hkey->time; nhkey->weight= hkey->weight; - + nkey->co= nhkey->co; nkey->time= &nhkey->time; /* these can be copied from old edit keys */ @@ -2394,7 +2394,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) if (point->keys) MEM_freeN(point->keys); - + pa->hair= new_hkeys; point->keys= new_keys; @@ -2439,7 +2439,7 @@ static void subdivide_particle(PEData *data, int pa_index) nkey= new_keys= MEM_callocN((pa->totkey+totnewkey)*(sizeof(HairKey)), "Hair subdivide keys"); nekey= new_ekeys= MEM_callocN((pa->totkey+totnewkey)*(sizeof(PTCacheEditKey)), "Hair subdivide edit keys"); - + key = pa->hair; endtime= key[pa->totkey-1].time; @@ -2496,7 +2496,7 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op)) PE_set_data(C, &data); foreach_point(&data, subdivide_particle); - + recalc_lengths(data.edit); PE_update_object(data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); @@ -2510,7 +2510,7 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot) ot->name = "Subdivide"; ot->idname = "PARTICLE_OT_subdivide"; ot->description = "Subdivide selected particles segments (adds keys)"; - + /* api callbacks */ ot->exec = subdivide_exec; ot->poll = PE_hair_poll; @@ -2545,7 +2545,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) removed= 0; tree=BLI_kdtree_new(psys->totpart); - + /* insert particles into kd tree */ LOOP_SELECTED_POINTS { psys_mat_hair_to_object(ob, psmd->dm_final, psys->part->from, psys->particles+p, mat); @@ -2599,7 +2599,7 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) ot->name = "Remove Doubles"; ot->idname = "PARTICLE_OT_remove_doubles"; ot->description = "Remove selected particles close enough of others"; - + /* api callbacks */ ot->exec = remove_doubles_exec; ot->poll = PE_hair_poll; @@ -2687,7 +2687,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) glutil_draw_lined_arc(0.0, M_PI*2.0, pe_brush_size_get(scene, brush), 40); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); - + glPopMatrix(); } } @@ -2757,7 +2757,7 @@ void PARTICLE_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->idname = "PARTICLE_OT_delete"; ot->description = "Delete selected particles or keys"; - + /* api callbacks */ ot->exec = delete_exec; ot->invoke = WM_menu_invoke; @@ -2850,7 +2850,7 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) } edit->totpoint= psys->totpart= newtotpart; - + /* create new elements */ newpa= psys->particles + totpart; newpoint= edit->points + totpart; @@ -2925,7 +2925,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); PTCacheEdit *edit= PE_get_current(scene, ob); - + PE_mirror_x(scene, ob, 0); update_world_cos(ob, edit); @@ -2941,7 +2941,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot) ot->name = "Mirror"; ot->idname = "PARTICLE_OT_mirror"; ot->description = "Duplicate and mirror the selected particles along the local X axis"; - + /* api callbacks */ ot->exec = mirror_exec; ot->poll = PE_hair_poll; @@ -3000,7 +3000,7 @@ static void brush_cut(PEData *data, int pa_index) o0= (float)data->mval[0]; o1= (float)data->mval[1]; - + xo0= x0 - o0; xo1= x1 - o1; @@ -3030,7 +3030,7 @@ static void brush_cut(PEData *data, int pa_index) dv= v0*v0 + v1*v1; d= (v0*xo1 - v1*xo0); - + d= dv * rad2 - d*d; if (d > 0.0f) { @@ -3263,7 +3263,7 @@ static void BKE_brush_weight_get(PEData *data, float UNUSED(mat[4][4]), float UN } static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4][4]), int UNUSED(point_index), int key_index, PTCacheEditKey *key) -{ +{ if (key_index) { float dvec[3]; @@ -3277,7 +3277,7 @@ static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4] static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4][4], int point_index, int key_index, PTCacheEditKey *key) { float vec[3], dvec[3]; - + if (key_index) { copy_v3_v3(vec, data->vec); mul_mat3_m4_v3(imat, vec); @@ -3286,7 +3286,7 @@ static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4] sub_v3_v3v3(dvec, vec, dvec); mul_v3_fl(dvec, data->smoothfac); - + add_v3_v3(key->co, dvec); } @@ -3323,7 +3323,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, int i, totface, intersect=0; 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) { psys_disable_all(ob); @@ -3339,7 +3339,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, /* BMESH_ONLY, deform dm may not have tessface */ DM_ensure_tessface(dm); - + if (pa_minmax==0) { INIT_MINMAX(p_min, p_max); @@ -3509,7 +3509,7 @@ static int brush_add(PEData *data, short number) mul_m4_v3(imat, co1); mul_m4_v3(imat, co2); 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_dmcache, add_pars[n].fuv, 0, 0, 0, 0)) { if (psys->part->use_modifier_stack && !psmd->dm_final->deformedOnly) { @@ -3560,7 +3560,7 @@ static int brush_add(PEData *data, short number) /* create tree for interpolation */ if (pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) { tree=BLI_kdtree_new(psys->totpart); - + for (i=0, pa=psys->particles; i<totpart; i++, pa++) { psys_particle_on_dm(psmd->dm_final, 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); @@ -3588,14 +3588,14 @@ static int brush_add(PEData *data, short number) if (!(psys->flag & PSYS_GLOBAL_HAIR)) key->flag |= PEK_USE_WCO; } - + pa->size= 1.0f; initialize_particle(&sim, pa); reset_particle(&sim, pa, 0.0, 1.0); point->flag |= PEP_EDIT_RECALC; if (pe_x_mirror(ob)) point->flag |= PEP_TAG; /* signal for duplicate */ - + framestep= pa->lifetime/(float)(pset->totaddkey-1); if (tree) { @@ -3610,7 +3610,7 @@ static int brush_add(PEData *data, short number) maxw = BLI_kdtree_find_nearest_n(tree, co1, ptn, 3); maxd= ptn[maxw-1].dist; - + for (w=0; w<maxw; w++) { weight[w] = (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd)); totw += weight[w]; @@ -3637,10 +3637,10 @@ static int brush_add(PEData *data, short number) key3[0].time= thkey->time/ 100.0f; psys_get_particle_on_path(&sim, ptn[0].index, key3, 0); mul_v3_fl(key3[0].co, weight[0]); - + /* TODO: interpolating the weight would be nicer */ thkey->weight= (ppa->hair+MIN2(k, ppa->totkey-1))->weight; - + if (maxw>1) { key3[1].time= key3[0].time; psys_get_particle_on_path(&sim, ptn[1].index, &key3[1], 0); @@ -3684,7 +3684,7 @@ static int brush_add(PEData *data, short number) MEM_freeN(add_pars); BLI_rng_free(rng); - + return n; } @@ -3712,7 +3712,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) ARegion *ar= CTX_wm_region(C); BrushEdit *bedit; float min[3], max[3]; - + if (pset->brushtype < 0) return 0; @@ -3840,7 +3840,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) case PE_BRUSH_LENGTH: { data.mval= mval; - + data.rad= pe_brush_size_get(scene, brush); data.growfac= brush->strength / 50.0f; @@ -4001,7 +4001,7 @@ static int brush_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event) { if (!brush_edit_init(C, op)) return OPERATOR_CANCELLED; - + brush_edit_apply_event(C, op, event); WM_event_add_modal_handler(C, op); @@ -4036,7 +4036,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot) ot->name = "Brush Edit"; ot->idname = "PARTICLE_OT_brush_edit"; ot->description = "Apply a stroke of brush to the particles"; - + /* api callbacks */ ot->exec = brush_edit_exec; ot->invoke = brush_edit_invoke; @@ -4060,12 +4060,12 @@ static int shape_cut_poll(bContext *C) if (PE_hair_poll(C)) { Scene *scene = CTX_data_scene(C); ParticleEditSettings *pset = PE_settings(scene); - + if (pset->shape_object && (pset->shape_object->type == OB_MESH)) { return true; } } - + return false; } @@ -4077,9 +4077,9 @@ typedef struct PointInsideBVH { static void point_inside_bvh_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) { PointInsideBVH *data = userdata; - + data->bvhdata.raycast_callback(&data->bvhdata, index, ray, hit); - + if (hit->index != -1) ++data->num_hits; } @@ -4090,14 +4090,14 @@ static bool shape_cut_test_point(PEData *data, ParticleCacheKey *key) BVHTreeFromMesh *shape_bvh = &data->shape_bvh; const float dir[3] = {1.0f, 0.0f, 0.0f}; PointInsideBVH userdata; - + userdata.bvhdata = data->shape_bvh; userdata.num_hits = 0; - + BLI_bvhtree_ray_cast_all( shape_bvh->tree, key->co, dir, 0.0f, BVH_RAYCAST_DIST_MAX, point_inside_bvh_cb, &userdata); - + /* for any point inside a watertight mesh the number of hits is uneven */ return (userdata.num_hits % 2) == 1; } @@ -4108,17 +4108,17 @@ static void shape_cut(PEData *data, int pa_index) Object *ob = data->ob; ParticleEditSettings *pset = PE_settings(data->scene); ParticleCacheKey *key; - + bool cut; float cut_time = 1.0; int k, totkeys = 1 << pset->draw_step; - + /* don't cut hidden */ if (edit->points[pa_index].flag & PEP_HIDE) return; - + cut = false; - + /* check if root is inside the cut shape */ key = edit->pathcache[pa_index]; if (!shape_cut_test_point(data, key)) { @@ -4130,10 +4130,10 @@ static void shape_cut(PEData *data, int pa_index) BVHTreeRayHit hit; float dir[3]; float len; - + sub_v3_v3v3(dir, (key+1)->co, key->co); len = normalize_v3(dir); - + memset(&hit, 0, sizeof(hit)); hit.index = -1; hit.dist = len; @@ -4168,32 +4168,32 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) Object *shapeob = pset->shape_object; int selected = count_selected_keys(scene, edit); int lock_root = pset->flag & PE_LOCK_FIRST; - + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; - + /* disable locking temporatily for disconnected hair */ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) pset->flag &= ~PE_LOCK_FIRST; - + if (edit->psys && edit->pathcache) { PEData data; int removed; - + PE_set_data(C, &data); if (!PE_create_shape_tree(&data, shapeob)) { /* shapeob may not have faces... */ return OPERATOR_CANCELLED; } - + if (selected) foreach_selected_point(&data, shape_cut); else foreach_point(&data, shape_cut); - + removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob)); recalc_lengths(edit); - + if (removed) { update_world_cos(ob, edit); psys_free_path_cache(NULL, edit); @@ -4201,7 +4201,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) } else PE_update_object(scene, ob, 1); - + if (edit->psys) { WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); } @@ -4209,12 +4209,12 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); } - + PE_free_shape_tree(&data); } - + pset->flag |= lock_root; - + return OPERATOR_FINISHED; } @@ -4224,7 +4224,7 @@ void PARTICLE_OT_shape_cut(wmOperatorType *ot) ot->name = "Shape Cut"; ot->idname = "PARTICLE_OT_shape_cut"; ot->description = "Cut hair to conform to the set shape object"; - + /* api callbacks */ ot->exec = shape_cut_exec; ot->poll = shape_cut_poll; @@ -4413,12 +4413,12 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) PTCacheEdit *edit; ob->mode |= mode_flag; 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) recalc_emitter_field(ob, edit->psys); - + toggle_particle_cursor(C, 1); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); } @@ -4439,7 +4439,7 @@ void PARTICLE_OT_particle_edit_toggle(wmOperatorType *ot) ot->name = "Particle Edit Toggle"; ot->idname = "PARTICLE_OT_particle_edit_toggle"; ot->description = "Toggle particle edit mode"; - + /* api callbacks */ ot->exec = particle_edit_toggle_exec; ot->poll = particle_edit_toggle_poll; @@ -4455,7 +4455,7 @@ 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) { PE_free_ptcache_edit(psys->edit); @@ -4494,7 +4494,7 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot) ot->name = "Clear Edited"; ot->idname = "PARTICLE_OT_edited_clear"; ot->description = "Undo all edition performed on the particle system"; - + /* api callbacks */ ot->exec = clear_edited_exec; ot->poll = particle_edit_toggle_poll; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index c4bcb6a8469..8a363276c28 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -84,10 +84,10 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; object_add_particle_system(scene, ob, NULL); - + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); - + return OPERATOR_FINISHED; } @@ -97,11 +97,11 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot) ot->name = "Add Particle System Slot"; ot->idname = "OBJECT_OT_particle_system_add"; ot->description = "Add a particle system"; - + /* api callbacks */ ot->poll = ED_operator_object_active_editable; ot->exec = particle_system_add_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -131,7 +131,7 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); - + return OPERATOR_FINISHED; } @@ -141,7 +141,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot) ot->name = "Remove Particle System Slot"; ot->idname = "OBJECT_OT_particle_system_remove"; ot->description = "Remove the selected particle system"; - + /* api callbacks */ ot->poll = ED_operator_object_active_editable; ot->exec = particle_system_remove_exec; @@ -189,7 +189,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); - + return OPERATOR_FINISHED; } @@ -199,7 +199,7 @@ void PARTICLE_OT_new(wmOperatorType *ot) ot->name = "New Particle Settings"; ot->idname = "PARTICLE_OT_new"; ot->description = "Add new particle settings"; - + /* api callbacks */ ot->exec = new_particle_settings_exec; ot->poll = psys_poll; @@ -237,7 +237,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); - + return OPERATOR_FINISHED; } @@ -247,7 +247,7 @@ void PARTICLE_OT_new_target(wmOperatorType *ot) ot->name = "New Particle Target"; ot->idname = "PARTICLE_OT_new_target"; ot->description = "Add a new particle target"; - + /* api callbacks */ ot->exec = new_particle_target_exec; @@ -285,7 +285,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); - + return OPERATOR_FINISHED; } @@ -295,7 +295,7 @@ void PARTICLE_OT_target_remove(wmOperatorType *ot) ot->name = "Remove Particle Target"; ot->idname = "PARTICLE_OT_target_remove"; ot->description = "Remove the selected particle target"; - + /* api callbacks */ ot->exec = remove_particle_target_exec; @@ -314,7 +314,7 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op)) if (!psys) return OPERATOR_CANCELLED; - + pt = psys->targets.first; for (; pt; pt=pt->next) { if (pt->flag & PTARGET_CURRENT && pt->prev) { @@ -326,7 +326,7 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -335,9 +335,9 @@ void PARTICLE_OT_target_move_up(wmOperatorType *ot) ot->name = "Move Up Target"; ot->idname = "PARTICLE_OT_target_move_up"; ot->description = "Move particle target up in the list"; - + ot->exec = target_move_up_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -364,7 +364,7 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -373,9 +373,9 @@ void PARTICLE_OT_target_move_down(wmOperatorType *ot) ot->name = "Move Down Target"; ot->idname = "PARTICLE_OT_target_move_down"; ot->description = "Move particle target down in the list"; - + ot->exec = target_move_down_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -402,7 +402,7 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -411,9 +411,9 @@ void PARTICLE_OT_dupliob_move_up(wmOperatorType *ot) ot->name = "Move Up Dupli Object"; ot->idname = "PARTICLE_OT_dupliob_move_up"; ot->description = "Move dupli object up in the list"; - + ot->exec = dupliob_move_up_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -441,7 +441,7 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -451,7 +451,7 @@ void PARTICLE_OT_dupliob_copy(wmOperatorType *ot) ot->name = "Copy Particle Dupliob"; ot->idname = "PARTICLE_OT_dupliob_copy"; ot->description = "Duplicate the current dupliobject"; - + /* api callbacks */ ot->exec = copy_particle_dupliob_exec; @@ -484,7 +484,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) dw->flag |= PART_DUPLIW_CURRENT; WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); - + return OPERATOR_FINISHED; } @@ -494,7 +494,7 @@ void PARTICLE_OT_dupliob_remove(wmOperatorType *ot) ot->name = "Remove Particle Dupliobject"; ot->idname = "PARTICLE_OT_dupliob_remove"; ot->description = "Remove the selected dupliobject"; - + /* api callbacks */ ot->exec = remove_particle_dupliob_exec; @@ -524,7 +524,7 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -533,9 +533,9 @@ void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot) ot->name = "Move Down Dupli Object"; ot->idname = "PARTICLE_OT_dupliob_move_down"; ot->description = "Move dupli object down in the list"; - + ot->exec = dupliob_move_down_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -559,7 +559,7 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) if (!psys->part || psys->part->type != PART_HAIR) return; - + edit = psys->edit; point= edit ? edit->points : NULL; @@ -573,7 +573,7 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) for (k=0, key=pa->hair; k<pa->totkey; k++, key++) { mul_m4_v3(hairmat, key->co); - + if (ekey) { ekey->flag &= ~PEK_USE_WCO; ekey++; @@ -622,9 +622,9 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot) ot->name = "Disconnect Hair"; ot->description = "Disconnect hair from the emitter mesh"; ot->idname = "PARTICLE_OT_disconnect_hair"; - + ot->exec = disconnect_hair_exec; - + /* flags */ ot->flag = OPTYPE_UNDO; /* No REGISTER, redo does not work due to missing update, see T47750. */ @@ -658,14 +658,14 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, return false; if (!target_psys->part || target_psys->part->type != PART_HAIR) return false; - + edit_point = target_edit ? target_edit->points : NULL; - + invert_m4_m4(from_ob_imat, ob->obmat); invert_m4_m4(to_ob_imat, target_ob->obmat); invert_m4_m4(from_imat, from_mat); invert_m4_m4(to_imat, to_mat); - + if (target_psmd->dm_final->deformedOnly) { /* we don't want to mess up target_psmd->dm when converting to global coordinates below */ dm = target_psmd->dm_final; @@ -729,7 +729,7 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, if (mface) { float v[4][3]; - + mf = &mface[nearest.index]; copy_v3_v3(v[0], mvert[mf->v1].co); @@ -765,7 +765,7 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, HairKey *key, *tkey; float hairmat[4][4], imat[4][4]; float offset[3]; - + if (to_global) copy_m4_m4(imat, target_ob->obmat); else { @@ -774,41 +774,41 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, invert_m4_m4(imat, hairmat); } mul_m4_m4m4(imat, imat, to_imat); - + /* offset in world space */ sub_v3_v3v3(offset, nearest.co, from_co); - + if (edit_point) { for (k=0, key=pa->hair, tkey=tpa->hair, ekey = edit_point->keys; k<tpa->totkey; k++, key++, tkey++, ekey++) { float co_orig[3]; - + if (from_global) mul_v3_m4v3(co_orig, from_ob_imat, key->co); else mul_v3_m4v3(co_orig, from_ob_imat, key->world_co); mul_m4_v3(from_mat, co_orig); - + add_v3_v3v3(tkey->co, co_orig, offset); - + mul_m4_v3(imat, tkey->co); - + ekey->flag |= PEK_USE_WCO; } - + edit_point++; } else { for (k=0, key=pa->hair, tkey=tpa->hair; k<tpa->totkey; k++, key++, tkey++) { float co_orig[3]; - + if (from_global) mul_v3_m4v3(co_orig, from_ob_imat, key->co); else mul_v3_m4v3(co_orig, from_ob_imat, key->world_co); mul_m4_v3(from_mat, co_orig); - + add_v3_v3v3(tkey->co, co_orig, offset); - + mul_m4_v3(imat, tkey->co); } } @@ -828,13 +828,13 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, static bool connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) { bool ok; - + if (!psys) return false; - + ok = remap_hair_emitter(scene, ob, psys, ob, psys, psys->edit, ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false); psys->flag &= ~PSYS_GLOBAL_HAIR; - + return ok; } @@ -876,9 +876,9 @@ void PARTICLE_OT_connect_hair(wmOperatorType *ot) ot->name = "Connect Hair"; ot->description = "Connect hair to the emitter mesh"; ot->idname = "PARTICLE_OT_connect_hair"; - + ot->exec = connect_hair_exec; - + /* flags */ ot->flag = OPTYPE_UNDO; /* No REGISTER, redo does not work due to missing update, see T47750. */ @@ -898,17 +898,17 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P ParticleData *pa; KEY_K; POINT_P; - + if (!edit_from) return; - + edit = MEM_dupallocN(edit_from); edit->psys = psys; psys->edit = edit; - + edit->pathcache = NULL; BLI_listbase_clear(&edit->pathcachebufs); - + edit->emitter_field = NULL; edit->emitter_cosnos = NULL; @@ -916,7 +916,7 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P pa = psys->particles; LOOP_POINTS { HairKey *hkey = pa->hair; - + point->keys= MEM_dupallocN(point->keys); LOOP_KEYS { key->co = hkey->co; @@ -926,17 +926,17 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P key->flag |= PEK_USE_WCO; hkey->editflag |= PEK_USE_WCO; } - + hkey++; } - + pa++; } update_world_cos(ob, edit); - + UI_GetThemeColor3ubv(TH_EDGE_SELECT, edit->sel_col); UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col); - + recalc_lengths(edit); recalc_emitter_field(ob, psys); PE_update_object(scene, ob, true); @@ -945,15 +945,15 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P static void remove_particle_systems_from_object(Object *ob_to) { ModifierData *md, *md_next; - + if (ob_to->type != OB_MESH) return; if (!ob_to->data || ID_IS_LINKED(ob_to->data)) return; - + for (md = ob_to->modifiers.first; md; md = md_next) { md_next = md->next; - + /* remove all particle system modifiers as well, * these need to sync to the particle system list */ @@ -962,7 +962,7 @@ static void remove_particle_systems_from_object(Object *ob_to) modifier_free(md); } } - + BKE_object_free_particlesystems(ob_to); } @@ -981,12 +981,12 @@ static bool copy_particle_systems_to_object(Main *bmain, DerivedMesh *final_dm; CustomDataMask cdmask; int i, totpsys; - + if (ob_to->type != OB_MESH) return false; if (!ob_to->data || ID_IS_LINKED(ob_to->data)) return false; - + /* For remapping we need a valid DM. * Because the modifiers are appended at the end it's safe to use * the final DM of the object without particles. @@ -998,9 +998,9 @@ static bool copy_particle_systems_to_object(Main *bmain, #define PSYS_FROM_FIRST (single_psys_from ? single_psys_from : ob_from->particlesystem.first) #define PSYS_FROM_NEXT(cur) (single_psys_from ? NULL : (cur)->next) totpsys = single_psys_from ? 1 : BLI_listbase_count(&ob_from->particlesystem); - + tmp_psys = MEM_mallocN(sizeof(ParticleSystem*) * totpsys, "temporary particle system array"); - + cdmask = 0; for (psys_from = PSYS_FROM_FIRST, i = 0; psys_from; @@ -1008,46 +1008,46 @@ static bool copy_particle_systems_to_object(Main *bmain, { psys = BKE_object_copy_particlesystem(psys_from, 0); tmp_psys[i] = psys; - + if (psys_start == NULL) psys_start = psys; - + cdmask |= psys_emitter_customdata_mask(psys); } /* to iterate source and target psys in sync, * we need to know where the newly added psys start */ psys_start = totpsys > 0 ? tmp_psys[0] : NULL; - + /* get the DM (psys and their modifiers have not been appended yet) */ final_dm = mesh_get_derived_final(scene, ob_to, cdmask); - + /* now append psys to the object and make modifiers */ for (i = 0, psys_from = PSYS_FROM_FIRST; i < totpsys; ++i, psys_from = PSYS_FROM_NEXT(psys_from)) { ParticleSystemModifierData *psmd; - + psys = tmp_psys[i]; - + /* append to the object */ BLI_addtail(&ob_to->particlesystem, psys); - + /* add a particle system modifier for each system */ md = modifier_new(eModifierType_ParticleSystem); psmd = (ParticleSystemModifierData *)md; /* push on top of the stack, no use trying to reproduce old stack order */ BLI_addtail(&ob_to->modifiers, md); - + BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", i); modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd); - + psmd->psys = psys; psmd->dm_final = CDDM_copy(final_dm); CDDM_calc_normals(psmd->dm_final); DM_ensure_tessface(psmd->dm_final); - + if (psys_from->edit) copy_particle_edit(scene, ob_to, psys, psys_from); @@ -1057,7 +1057,7 @@ static bool copy_particle_systems_to_object(Main *bmain, } } MEM_freeN(tmp_psys); - + /* note: do this after creating DM copies for all the particle system modifiers, * the remapping otherwise makes final_dm invalid! */ @@ -1066,7 +1066,7 @@ static bool copy_particle_systems_to_object(Main *bmain, psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), ++i) { float (*from_mat)[4], (*to_mat)[4]; - + switch (space) { case PAR_COPY_SPACE_OBJECT: from_mat = I; @@ -1085,14 +1085,14 @@ static bool copy_particle_systems_to_object(Main *bmain, if (ob_from != ob_to) { remap_hair_emitter(scene, ob_from, psys_from, ob_to, psys, psys->edit, from_mat, to_mat, psys_from->flag & PSYS_GLOBAL_HAIR, psys->flag & PSYS_GLOBAL_HAIR); } - + /* tag for recalc */ // psys->recalc |= PSYS_RECALC_RESET; } - + #undef PSYS_FROM_FIRST #undef PSYS_FROM_NEXT - + DAG_id_tag_update(&ob_to->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, ob_to); return true; @@ -1103,11 +1103,11 @@ static int copy_particle_systems_poll(bContext *C) Object *ob; if (!ED_operator_object_active_editable(C)) return false; - + ob = ED_object_active_context(C); if (BLI_listbase_is_empty(&ob->particlesystem)) return false; - + return true; } @@ -1120,10 +1120,10 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob_from = ED_object_active_context(C); ParticleSystem *psys_from = use_active ? CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data : NULL; - + int changed_tot = 0; int fail = 0; - + CTX_DATA_BEGIN (C, Object *, ob_to, selected_editable_objects) { if (ob_from != ob_to) { @@ -1136,19 +1136,19 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op) changed = true; else fail++; - + if (changed) changed_tot++; } } CTX_DATA_END; - + if ((changed_tot == 0 && fail == 0) || fail) { BKE_reportf(op->reports, RPT_ERROR, "Copy particle systems to selected: %d done, %d failed", changed_tot, fail); } - + return OPERATOR_FINISHED; } @@ -1159,17 +1159,17 @@ void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot) {PAR_COPY_SPACE_WORLD, "WORLD", 0, "World", "Copy in world space"}, {0, NULL, 0, NULL, NULL} }; - + ot->name = "Copy Particle Systems"; ot->description = "Copy particle systems from the active object to selected objects"; ot->idname = "PARTICLE_OT_copy_particle_systems"; - + ot->poll = copy_particle_systems_poll; ot->exec = copy_particle_systems_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "space", space_items, PAR_COPY_SPACE_OBJECT, "Space", "Space transform for copying from one object to another"); RNA_def_boolean(ot->srna, "remove_target_particles", true, "Remove Target Particles", "Remove particle systems on the target objects"); RNA_def_boolean(ot->srna, "use_active", false, "Use Active", "Use the active particle system from the context"); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index c050f889eee..4b9ce1ca210 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -39,7 +39,7 @@ /* types */ #include "DNA_action_types.h" #include "DNA_object_types.h" -#include "DNA_object_fluidsim_types.h" +#include "DNA_object_fluidsim_types.h" #include "BLI_blenlib.h" #include "BLI_math.h" @@ -82,12 +82,12 @@ static float get_fluid_viscosity(FluidsimSettings *settings) static float get_fluid_rate(FluidsimSettings *settings) { float rate = 1.0f; /* default rate if not animated... */ - + rate = settings->animRate; - + if (rate < 0.0f) rate = 0.0f; - + return rate; } @@ -109,10 +109,10 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * else { float dim[3]; float longest_axis; - + BKE_object_dimensions_get(domainob, dim); longest_axis = max_fff(dim[0], dim[1], dim[2]); - + return longest_axis * scene->unit.scale_length; } } @@ -138,9 +138,9 @@ void fluidsimGetGeometryObjFilename(Object *ob, char *dst) //, char *srcname) typedef struct FluidAnimChannels { int length; - + double aniFrameTime; - + float *timeAtFrame; float *DomainTime; float *DomainGravity; @@ -149,21 +149,21 @@ typedef struct FluidAnimChannels { typedef struct FluidObject { struct FluidObject *next, *prev; - + struct Object *object; - + float *Translation; float *Rotation; float *Scale; float *Active; - + float *InitialVelocity; - + float *AttractforceStrength; float *AttractforceRadius; float *VelocityforceStrength; float *VelocityforceRadius; - + float *VertexCache; int numVerts, numTris; } FluidObject; @@ -175,10 +175,10 @@ typedef struct FluidObject { // simplify channels before printing // for API this is done anyway upon init #if 0 -static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char *str, int entries) -{ +static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char *str, int entries) +{ int i, j; - int channelSize = paramsize; + int channelSize = paramsize; if (entries == 3) { elbeemSimplifyChannelVec3(channel, &channelSize); @@ -220,11 +220,11 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *channels) { int i; - + channels->timeAtFrame = MEM_callocN((channels->length + 1) * sizeof(float), "timeAtFrame channel"); - + channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1 - + for (i=2; i <= channels->length; i++) { channels->timeAtFrame[i] = channels->timeAtFrame[i - 1] + (float)channels->aniFrameTime; } @@ -254,25 +254,25 @@ static void set_vertex_channel(float *channel, float time, struct Scene *scene, int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd); int framesize = (3*fobj->numVerts) + 1; int j; - + if (channel == NULL) return; - + initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex); - + /* don't allow mesh to change number of verts in anim sequence */ if (numVerts != fobj->numVerts) { MEM_freeN(channel); channel = NULL; return; } - + /* fill frame of channel with vertex locations */ for (j=0; j < (3*numVerts); j++) { channel[i*framesize + j] = verts[j]; } channel[i*framesize + framesize-1] = time; - + MEM_freeN(verts); MEM_freeN(tris); } @@ -294,7 +294,7 @@ static void free_domain_channels(FluidAnimChannels *channels) static void free_all_fluidobject_channels(ListBase *fobjects) { FluidObject *fobj; - + for (fobj=fobjects->first; fobj; fobj=fobj->next) { if (fobj->Translation) { MEM_freeN(fobj->Translation); @@ -308,7 +308,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects) MEM_freeN(fobj->InitialVelocity); fobj->InitialVelocity = NULL; } - + if (fobj->AttractforceStrength) { MEM_freeN(fobj->AttractforceStrength); fobj->AttractforceStrength = NULL; @@ -319,7 +319,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects) MEM_freeN(fobj->VelocityforceRadius); fobj->VelocityforceRadius = NULL; } - + if (fobj->VertexCache) { MEM_freeN(fobj->VertexCache); fobj->VertexCache = NULL; @@ -334,108 +334,108 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid int i; int length = channels->length; float eval_time; - + /* init time values (assuming that time moves at a constant speed; may be overridden later) */ init_time(domainSettings, channels); - + /* allocate domain animation channels */ channels->DomainGravity = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "channel DomainGravity"); channels->DomainViscosity = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainViscosity"); channels->DomainTime = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime"); - + /* allocate fluid objects */ for (base=scene->base.first; base; base= base->next) { Object *ob = base->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - + if (fluidmd) { FluidObject *fobj = MEM_callocN(sizeof(FluidObject), "Fluid Object"); fobj->object = ob; - + if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) { BLI_addtail(fobjects, fobj); continue; } - + fobj->Translation = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Translation"); fobj->Rotation = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Rotation"); fobj->Scale = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Scale"); fobj->Active = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject Active"); fobj->InitialVelocity = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject InitialVelocity"); - + if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) { fobj->AttractforceStrength = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject AttractforceStrength"); fobj->AttractforceRadius = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject AttractforceRadius"); fobj->VelocityforceStrength = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject VelocityforceStrength"); fobj->VelocityforceRadius = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject VelocityforceRadius"); } - + if (fluid_is_animated_mesh(fluidmd->fss)) { float *verts=NULL; int *tris=NULL, modifierIndex = BLI_findindex(&ob->modifiers, (ModifierData *)fluidmd); initElbeemMesh(scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex); fobj->VertexCache = MEM_callocN(length *((fobj->numVerts*CHANNEL_VEC)+1) * sizeof(float), "fluidobject VertexCache"); - + MEM_freeN(verts); MEM_freeN(tris); } - + BLI_addtail(fobjects, fobj); } } - + /* now we loop over the frames and fill the allocated channels with data */ for (i=0; i < channels->length; i++) { FluidObject *fobj; float viscosity, gravity[3]; float timeAtFrame, time; - + eval_time = domainSettings->bakeStart + i; - + /* XXX: This can't be used due to an anim sys optimization that ignores recalc object animation, * leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ ) * --> BKE_animsys_evaluate_all_animation(G.main, eval_time); * This doesn't work with drivers: * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL); */ - - /* Modifying the global scene isn't nice, but we can do it in + + /* Modifying the global scene isn't nice, but we can do it in * this part of the process before a threaded job is created */ scene->r.cfra = (int)eval_time; ED_update_for_newframe(CTX_data_main(C), scene, 1); - + /* now scene data should be current according to animation system, so we fill the channels */ - + /* Domain time */ // TODO: have option for not running sim, time mangling, in which case second case comes in handy if (channels->DomainTime) { time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime; timeAtFrame = channels->timeAtFrame[i] + time; - + channels->timeAtFrame[i+1] = timeAtFrame; set_channel(channels->DomainTime, i, &time, i, CHANNEL_FLOAT); } else { timeAtFrame = channels->timeAtFrame[i+1]; } - + /* Domain properties - gravity/viscosity */ get_fluid_gravity(gravity, scene, domainSettings); set_channel(channels->DomainGravity, timeAtFrame, gravity, i, CHANNEL_VEC); viscosity = get_fluid_viscosity(domainSettings); set_channel(channels->DomainViscosity, timeAtFrame, &viscosity, i, CHANNEL_FLOAT); - + /* object movement */ for (fobj=fobjects->first; fobj; fobj=fobj->next) { Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); float active= (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) > 0 ? 1 : 0); float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f}; - + if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) continue; - + /* 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) { @@ -445,7 +445,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid mat4_to_compatible_eulO(rot_d, old_rot, 0, ob->obmat); mul_v3_fl(rot_d, -180.0f / (float)M_PI); - + set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC); set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC); set_channel(fobj->Scale, timeAtFrame, ob->size, i, CHANNEL_VEC); @@ -453,14 +453,14 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid set_channel(fobj->InitialVelocity, timeAtFrame, &fluidmd->fss->iniVelx, i, CHANNEL_VEC); // printf("Active: %f, Frame: %f\n", active, timeAtFrame); - + if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) { set_channel(fobj->AttractforceStrength, timeAtFrame, &fluidmd->fss->attractforceStrength, i, CHANNEL_FLOAT); set_channel(fobj->AttractforceRadius, timeAtFrame, &fluidmd->fss->attractforceRadius, i, CHANNEL_FLOAT); set_channel(fobj->VelocityforceStrength, timeAtFrame, &fluidmd->fss->velocityforceStrength, i, CHANNEL_FLOAT); set_channel(fobj->VelocityforceRadius, timeAtFrame, &fluidmd->fss->velocityforceRadius, i, CHANNEL_FLOAT); } - + if (fluid_is_animated_mesh(fluidmd->fss)) { set_vertex_channel(fobj->VertexCache, timeAtFrame, scene, fobj, i); } @@ -471,72 +471,72 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) { FluidObject *fobj; - + for (fobj=fobjects->first; fobj; fobj=fobj->next) { Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd); - + float *verts=NULL; int *tris=NULL; int numVerts=0, numTris=0; bool deform = fluid_is_animated_mesh(fluidmd->fss); - + elbeemMesh fsmesh; - + if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) continue; - + elbeemResetMesh(&fsmesh); - + fsmesh.type = fluidmd->fss->type; fsmesh.name = ob->id.name; - + initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex); - + fsmesh.numVertices = numVerts; fsmesh.numTriangles = numTris; fsmesh.vertices = verts; fsmesh.triangles = tris; - - fsmesh.channelSizeTranslation = - fsmesh.channelSizeRotation = - fsmesh.channelSizeScale = - fsmesh.channelSizeInitialVel = + + fsmesh.channelSizeTranslation = + fsmesh.channelSizeRotation = + fsmesh.channelSizeScale = + fsmesh.channelSizeInitialVel = fsmesh.channelSizeActive = length; - + fsmesh.channelTranslation = fobj->Translation; fsmesh.channelRotation = fobj->Rotation; fsmesh.channelScale = fobj->Scale; fsmesh.channelActive = fobj->Active; - + 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) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP; else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP; - + fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue; fsmesh.volumeInitType = fluidmd->fss->volumeInitType; fsmesh.obstacleImpactFactor = fluidmd->fss->surfaceSmoothing; // misused value - + if (fsmesh.type == OB_FLUIDSIM_CONTROL) { fsmesh.cpsTimeStart = fluidmd->fss->cpsTimeStart; fsmesh.cpsTimeEnd = fluidmd->fss->cpsTimeEnd; fsmesh.cpsQuality = fluidmd->fss->cpsQuality; fsmesh.obstacleType = (fluidmd->fss->flag & OB_FLUIDSIM_REVERSE); - - fsmesh.channelSizeAttractforceRadius = - fsmesh.channelSizeVelocityforceStrength = - fsmesh.channelSizeVelocityforceRadius = + + fsmesh.channelSizeAttractforceRadius = + fsmesh.channelSizeVelocityforceStrength = + fsmesh.channelSizeVelocityforceRadius = fsmesh.channelSizeAttractforceStrength = length; - + fsmesh.channelAttractforceStrength = fobj->AttractforceStrength; fsmesh.channelAttractforceRadius = fobj->AttractforceRadius; fsmesh.channelVelocityforceStrength = fobj->VelocityforceStrength; @@ -544,28 +544,28 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) } else { fsmesh.channelAttractforceStrength = - fsmesh.channelAttractforceRadius = - fsmesh.channelVelocityforceStrength = - fsmesh.channelVelocityforceRadius = NULL; + fsmesh.channelAttractforceRadius = + fsmesh.channelVelocityforceStrength = + fsmesh.channelVelocityforceRadius = NULL; } - + /* animated meshes */ if (deform) { fsmesh.channelSizeVertices = length; fsmesh.channelVertices = fobj->VertexCache; - + /* remove channels */ - fsmesh.channelTranslation = - fsmesh.channelRotation = + fsmesh.channelTranslation = + fsmesh.channelRotation = fsmesh.channelScale = NULL; - + /* Override user settings, only noslip is supported here! */ if (fsmesh.type != OB_FLUIDSIM_CONTROL) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; } - + elbeemAddMesh(&fsmesh); - + if (verts) MEM_freeN(verts); if (tris) MEM_freeN(tris); } @@ -584,7 +584,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 no initial domain object given, find another potential domain */ if (!fsDomain) { @@ -596,11 +596,11 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom return 0; } } - + /* count number of objects needed for animation channels */ if ( !ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE) ) channelObjCount++; - + /* count number of fluid input objects */ if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) fluidInputCount++; @@ -608,22 +608,22 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom if (newdomain) fsDomain = newdomain; - + if (!fsDomain) { BKE_report(reports, RPT_ERROR, "No domain object found"); return 0; } - + if (channelObjCount >= 255) { BKE_report(reports, RPT_ERROR, "Cannot bake with more than 256 objects"); return 0; } - + if (fluidInputCount == 0) { BKE_report(reports, RPT_ERROR, "No fluid input objects in the scene"); return 0; } - + return 1; } @@ -717,8 +717,8 @@ static int fluidbake_breakjob(void *customdata) if (fb->stop && *(fb->stop)) return 1; - - /* this is not nice yet, need to make the jobs list template better + + /* this is not nice yet, need to make the jobs list template better * for identifying/acting upon various different jobs */ /* but for now we'll reuse the render break... */ return (G.is_break); @@ -728,7 +728,7 @@ static int fluidbake_breakjob(void *customdata) static void fluidbake_updatejob(void *customdata, float progress) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - + *(fb->do_update) = true; *(fb->progress) = progress; } @@ -736,13 +736,13 @@ static void fluidbake_updatejob(void *customdata, float progress) static void fluidbake_startjob(void *customdata, short *stop, short *do_update, float *progress) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - + fb->stop= stop; fb->do_update = do_update; fb->progress = progress; - + G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */ - + elbeemSimulate(); *do_update = true; *stop = 0; @@ -751,7 +751,7 @@ static void fluidbake_startjob(void *customdata, short *stop, short *do_update, static void fluidbake_endjob(void *customdata) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - + if (fb->settings) { MEM_freeN(fb->settings); fb->settings = NULL; @@ -762,16 +762,16 @@ static int runSimulationCallback(void *data, int status, int frame) { FluidBakeJob *fb = (FluidBakeJob *)data; elbeemSimulationSettings *settings = fb->settings; - + if (status == FLUIDSIM_CBSTATUS_NEWFRAME) { fluidbake_updatejob(fb, frame / (float)settings->noOfFrames); //printf("elbeem blender cb s%d, f%d, domainid:%d noOfFrames: %d\n", status, frame, settings->domainId, settings->noOfFrames ); // DEBUG } - + if (fluidbake_breakjob(fb)) { return FLUIDSIM_CBRET_ABORT; } - + return FLUIDSIM_CBRET_CONTINUE; } @@ -785,12 +785,12 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects, BLI_freelistN(fobjects); MEM_freeN(fobjects); fobjects = NULL; - + if (fsset) { MEM_freeN(fsset); fsset = NULL; } - + if (fb) { MEM_freeN(fb); fb = NULL; @@ -842,7 +842,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor FluidsimSettings *domainSettings; char debugStrBuffer[256]; - + int gridlevels = 0; const char *relbase= modifier_path_relbase(bmain, fsDomain); const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp @@ -857,7 +857,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor int noFrames; int origFrame = scene->r.cfra; - + FluidAnimChannels *channels = MEM_callocN(sizeof(FluidAnimChannels), "fluid domain animation channels"); ListBase *fobjects = MEM_callocN(sizeof(ListBase), "fluid objects"); FluidsimModifierData *fluidmd = NULL; @@ -867,14 +867,14 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor elbeemSimulationSettings *fsset= MEM_callocN(sizeof(elbeemSimulationSettings), "Fluid sim settings"); fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job"); - + 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); elbeemDebugOut(debugStrBuffer); } - + /* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */; noFrames = scene->r.efra - 0; if (noFrames<=0) { @@ -882,30 +882,30 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fluidbake_free_data(channels, fobjects, fsset, fb); return 0; } - + /* check scene for sane object/modifier settings */ if (!fluid_validate_scene(reports, scene, fsDomain)) { fluidbake_free_data(channels, fobjects, fsset, fb); return 0; } - + /* these both have to be valid, otherwise we wouldn't be here */ fluidmd = (FluidsimModifierData *)modifiers_findByType(fsDomain, eModifierType_Fluidsim); domainSettings = fluidmd->fss; mesh = fsDomain->data; - + domainSettings->bakeStart = 1; domainSettings->bakeEnd = scene->r.efra; - + // calculate bounding box fluid_get_bb(mesh->mvert, mesh->totvert, fsDomain->obmat, domainSettings->bbStart, domainSettings->bbSize); - + // reset last valid frame domainSettings->lastgoodframe = -1; /* delete old baked files */ fluidsim_delete_until_lastframe(domainSettings, relbase); - + /* rough check of settings... */ if (domainSettings->previewresxyz > domainSettings->resolutionxyz) { BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz, domainSettings->resolutionxyz); @@ -932,9 +932,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor } BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name, gridlevels); elbeemDebugOut(debugStrBuffer); - - - + + + /* ******** prepare output file paths ******** */ if (!fluid_init_filepaths(bmain, reports, domainSettings, fsDomain, targetDir, targetFile)) { fluidbake_free_data(channels, fobjects, fsset, fb); @@ -943,20 +943,20 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor channels->length = scene->r.efra; // DG TODO: why using endframe and not "noFrames" here? .. because "noFrames" is buggy too? (not using sfra) channels->aniFrameTime = (double)((double)domainSettings->animEnd - (double)domainSettings->animStart) / (double)noFrames; - + /* ******** initialize and allocate animation channels ******** */ fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects); /* reset to original current frame */ scene->r.cfra = origFrame; ED_update_for_newframe(CTX_data_main(C), scene, 1); - + /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); 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"); + BKE_report(reports, RPT_ERROR, "Invalid object matrix"); fluidbake_free_data(channels, fobjects, fsset, fb); return 0; @@ -973,7 +973,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // setup global settings copy_v3_v3(fsset->geoStart, domainSettings->bbStart); copy_v3_v3(fsset->geoSize, domainSettings->bbSize); - + // simulate with 50^3 fsset->resolutionxyz = (int)domainSettings->resolutionxyz; fsset->previewresxyz = (int)domainSettings->previewresxyz; @@ -992,21 +992,21 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // defaults for compressibility and adaptive grids fsset->gstar = domainSettings->gstar; fsset->maxRefine = domainSettings->maxRefine; // check <-> gridlevels - fsset->generateParticles = domainSettings->generateParticles; - fsset->numTracerParticles = domainSettings->generateTracers; - fsset->surfaceSmoothing = domainSettings->surfaceSmoothing; - fsset->surfaceSubdivs = domainSettings->surfaceSubdivs; - fsset->farFieldSize = domainSettings->farFieldSize; + fsset->generateParticles = domainSettings->generateParticles; + fsset->numTracerParticles = domainSettings->generateTracers; + fsset->surfaceSmoothing = domainSettings->surfaceSmoothing; + fsset->surfaceSubdivs = domainSettings->surfaceSubdivs; + fsset->farFieldSize = domainSettings->farFieldSize; BLI_strncpy(fsset->outputPath, targetFile, sizeof(fsset->outputPath)); // domain channels - fsset->channelSizeFrameTime = - fsset->channelSizeViscosity = + fsset->channelSizeFrameTime = + fsset->channelSizeViscosity = fsset->channelSizeGravity = channels->length; fsset->channelFrameTime = channels->DomainTime; fsset->channelViscosity = channels->DomainViscosity; fsset->channelGravity = channels->DomainGravity; - + fsset->runsimCallback = &runSimulationCallback; fsset->runsimUserData = fb; @@ -1034,13 +1034,13 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* ******** init solver with settings ******** */ elbeemInit(); elbeemAddDomain(fsset); - + /* ******** export all fluid objects to elbeem ******** */ export_fluid_objects(fobjects, scene, channels->length); - + /* custom data for fluid bake job */ fb->settings = fsset; - + if (do_job) { wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_FLUID); @@ -1112,7 +1112,7 @@ void FLUID_OT_bake(wmOperatorType *ot) ot->name = "Fluid Simulation Bake"; ot->description = "Bake fluid simulation"; ot->idname = "FLUID_OT_bake"; - + /* api callbacks */ ot->invoke = fluid_bake_invoke; ot->exec = fluid_bake_exec; diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index cffee635199..7b86cb63f31 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -111,10 +111,10 @@ static void keymap_particle(wmKeyConfig *keyconf) { wmKeyMapItem *kmi; wmKeyMap *keymap; - + keymap = WM_keymap_find(keyconf, "Particle", 0, 0); keymap->poll = PE_poll; - + kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); @@ -166,7 +166,7 @@ static void keymap_particle(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.particle_edit.brush.strength"); WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); ED_keymap_proportional_cycle(keyconf, keymap); @@ -222,7 +222,7 @@ static void operatortypes_dynamicpaint(void) //static void keymap_pointcache(wmWindowManager *wm) //{ // wmKeyMap *keymap = WM_keymap_find(wm, "Pointcache", 0, 0); -// +// // WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0); // WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); // WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index f36ebb3715e..dadd086a774 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -264,9 +264,9 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op)) for (pid=pidlist.first; pid; pid=pid->next) { ptcache_free_bake(pid->cache); } - + BLI_freelistN(&pidlist); - + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, base->object); } @@ -281,7 +281,7 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot) ot->name = "Bake All Physics"; ot->description = "Bake all physics"; ot->idname = "PTCACHE_OT_bake_all"; - + /* api callbacks */ ot->exec = ptcache_bake_exec; ot->invoke = ptcache_bake_invoke; @@ -300,7 +300,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) ot->name = "Free All Physics Bakes"; ot->idname = "PTCACHE_OT_free_bake_all"; ot->description = "Free all baked caches of all objects in the current scene"; - + /* api callbacks */ ot->exec = ptcache_free_bake_all_exec; ot->poll = ptcache_bake_all_poll; @@ -316,7 +316,7 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ptr.id.data; ptcache_free_bake(cache); - + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; @@ -326,9 +326,9 @@ static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *UNUSED(op)) PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache); PointCache *cache= ptr.data; Object *ob= ptr.id.data; - + cache->flag |= PTCACHE_BAKED; - + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; @@ -339,7 +339,7 @@ void PTCACHE_OT_bake(wmOperatorType *ot) ot->name = "Bake Physics"; ot->description = "Bake physics"; ot->idname = "PTCACHE_OT_bake"; - + /* api callbacks */ ot->exec = ptcache_bake_exec; ot->invoke = ptcache_bake_invoke; @@ -358,7 +358,7 @@ void PTCACHE_OT_free_bake(wmOperatorType *ot) ot->name = "Free Physics Bake"; ot->description = "Free physics bake"; ot->idname = "PTCACHE_OT_free_bake"; - + /* api callbacks */ ot->exec = ptcache_free_bake_exec; ot->poll = ptcache_poll; @@ -372,7 +372,7 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) ot->name = "Bake From Cache"; ot->description = "Bake from cache"; ot->idname = "PTCACHE_OT_bake_from_cache"; - + /* api callbacks */ ot->exec = ptcache_bake_from_cache_exec; ot->poll = ptcache_poll; @@ -391,7 +391,7 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op)) ListBase pidlist; BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - + for (pid=pidlist.first; pid; pid=pid->next) { if (pid->cache == cache) { PointCache *cache_new = BKE_ptcache_add(pid->ptcaches); @@ -418,7 +418,7 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) ListBase pidlist; 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) @@ -433,7 +433,7 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) } BLI_freelistN(&pidlist); - + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; @@ -444,7 +444,7 @@ void PTCACHE_OT_add(wmOperatorType *ot) ot->name = "Add New Cache"; ot->description = "Add new cache"; ot->idname = "PTCACHE_OT_add"; - + /* api callbacks */ ot->exec = ptcache_add_new_exec; ot->poll = ptcache_poll; @@ -458,7 +458,7 @@ void PTCACHE_OT_remove(wmOperatorType *ot) ot->name = "Delete Current Cache"; ot->description = "Delete current cache"; ot->idname = "PTCACHE_OT_remove"; - + /* api callbacks */ ot->exec = ptcache_remove_exec; ot->poll = ptcache_poll; diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c index 008ab4c0554..8d5258a7522 100644 --- a/source/blender/editors/physics/rigidbody_world.c +++ b/source/blender/editors/physics/rigidbody_world.c @@ -24,7 +24,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ - + /** \file rigidbody_world.c * \ingroup editor_physics * \brief Rigid Body world editing operators @@ -174,7 +174,7 @@ static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEv // TODO: use the actual rigidbody world's name + .bullet instead of this temp crap RNA_string_set(op->ptr, "filepath", "rigidbodyworld_export.bullet"); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } |