diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-08-06 13:56:14 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-08-06 13:56:14 +0400 |
commit | 38de6d14e4e7a55a4109313942df3ae9211b1aeb (patch) | |
tree | 83288d248bc7a4794b8b34e607f3e319e905b381 /source/blender/editors/physics | |
parent | 416a3bf4a14a951642cace5ee8033c4c20dd9f66 (diff) | |
parent | 1e4fb484001994f4e164aab7b44c9578df59f67d (diff) |
merge with 2.5 (not trunk, last merge message said that on accident) at r22252
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/ed_fluidsim.c | 2 | ||||
-rw-r--r-- | source/blender/editors/physics/ed_pointcache.c | 110 | ||||
-rw-r--r-- | source/blender/editors/physics/editparticle.c | 23 |
3 files changed, 121 insertions, 14 deletions
diff --git a/source/blender/editors/physics/ed_fluidsim.c b/source/blender/editors/physics/ed_fluidsim.c index a8862eb17de..907d3f99f77 100644 --- a/source/blender/editors/physics/ed_fluidsim.c +++ b/source/blender/editors/physics/ed_fluidsim.c @@ -100,7 +100,7 @@ /* from header info.c */ static int start_progress_bar(void) {return 0;}; static void end_progress_bar(void) {}; -static void waitcursor() {}; +static void waitcursor(int val) {}; static int progress_bar(float done, char *busy_info) {return 0;} static int pupmenu() {return 0;} /* XXX */ diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c index 4bf6612df67..5d0a6d21fac 100644 --- a/source/blender/editors/physics/ed_pointcache.c +++ b/source/blender/editors/physics/ed_pointcache.c @@ -146,6 +146,113 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/**************************** softbody **********************************/ +static int ptcache_bake_softbody_poll(bContext *C) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); + SoftBody *sb = ob->soft; + + if(!scene || !ob || ob->id.lib || !sb) + return 0; + + return 1; +} + +static int ptcache_bake_softbody_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); + SoftBody *sb = ob->soft; + PTCacheID pid; + PTCacheBaker baker; + + BKE_ptcache_id_from_softbody(&pid, ob, sb); + + baker.scene = scene; + baker.pid = &pid; + baker.bake = RNA_boolean_get(op->ptr, "bake"); + baker.render = 0; + baker.anim_init = 0; + baker.quick_step = 1; + baker.break_test = cache_break_test; + baker.break_data = NULL; + baker.progressbar = (void (*)(void *, int))WM_timecursor; + baker.progresscontext = CTX_wm_window(C); + + BKE_ptcache_make_cache(&baker); + + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + + return OPERATOR_FINISHED; +} +static int ptcache_free_bake_softbody_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); + SoftBody *sb = ob->soft; + PTCacheID pid; + + BKE_ptcache_id_from_softbody(&pid, ob, sb); + pid.cache->flag &= ~PTCACHE_BAKED; + + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + + return OPERATOR_FINISHED; +} +void PTCACHE_OT_cache_softbody(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Bake Softbody"; + ot->idname= "PTCACHE_OT_cache_softbody"; + + /* api callbacks */ + ot->exec= ptcache_bake_softbody_exec; + ot->poll= ptcache_bake_softbody_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); +} +void PTCACHE_OT_free_bake_softbody(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Free SoftBody Bake"; + ot->idname= "PTCACHE_OT_free_bake_softbody"; + + /* api callbacks */ + ot->exec= ptcache_free_bake_softbody_exec; + ot->poll= ptcache_bake_softbody_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} +static int ptcache_bake_from_softbody_cache_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_active_object(C); + SoftBody *sb = ob->soft; + PTCacheID pid; + + BKE_ptcache_id_from_softbody(&pid, ob, sb); + pid.cache->flag |= PTCACHE_BAKED; + + return OPERATOR_FINISHED; +} +void PTCACHE_OT_bake_from_softbody_cache(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Bake From Cache"; + ot->idname= "PTCACHE_OT_bake_from_softbody_cache"; + + /* api callbacks */ + ot->exec= ptcache_bake_from_softbody_cache_exec; + ot->poll= ptcache_bake_softbody_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /**************************** cloth **********************************/ static int ptcache_bake_cloth_poll(bContext *C) { @@ -371,6 +478,9 @@ void ED_operatortypes_pointcache(void) WM_operatortype_append(PTCACHE_OT_cache_cloth); WM_operatortype_append(PTCACHE_OT_free_bake_cloth); WM_operatortype_append(PTCACHE_OT_bake_from_cloth_cache); + WM_operatortype_append(PTCACHE_OT_cache_softbody); + WM_operatortype_append(PTCACHE_OT_free_bake_softbody); + WM_operatortype_append(PTCACHE_OT_bake_from_softbody_cache); } //void ED_keymap_pointcache(wmWindowManager *wm) diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c index 54578755e27..499162ecdb8 100644 --- a/source/blender/editors/physics/editparticle.c +++ b/source/blender/editors/physics/editparticle.c @@ -271,6 +271,7 @@ typedef struct PEData { float smoothfac; float weightfac; float growfac; + int totrekey; int invert; int tot; @@ -1748,7 +1749,6 @@ static void rekey_particle(PEData *data, int pa_index) ParticleSystem *psys= data->psys; ParticleData *pa= &psys->particles[pa_index]; ParticleEdit *edit= psys->edit; - ParticleEditSettings *pset= PE_settings(data->scene); ParticleKey state; HairKey *key, *new_keys; ParticleEditKey *ekey; @@ -1757,19 +1757,19 @@ static void rekey_particle(PEData *data, int pa_index) pa->flag |= PARS_REKEY; - key= new_keys= MEM_callocN(pset->totrekey * sizeof(HairKey),"Hair re-key keys"); + key= new_keys= MEM_callocN(data->totrekey * sizeof(HairKey),"Hair re-key keys"); /* root and tip stay the same */ VECCOPY(key->co, pa->hair->co); - VECCOPY((key + pset->totrekey - 1)->co, (pa->hair + pa->totkey - 1)->co); + VECCOPY((key + data->totrekey - 1)->co, (pa->hair + pa->totkey - 1)->co); sta= key->time= pa->hair->time; - end= (key + pset->totrekey - 1)->time= (pa->hair + pa->totkey - 1)->time; - dval= (end - sta) / (float)(pset->totrekey - 1); + end= (key + data->totrekey - 1)->time= (pa->hair + pa->totkey - 1)->time; + dval= (end - sta) / (float)(data->totrekey - 1); /* interpolate new keys from old ones */ - for(k=1,key++; k<pset->totrekey-1; k++,key++) { - state.time= (float)k / (float)(pset->totrekey-1); + for(k=1,key++; k<data->totrekey-1; k++,key++) { + state.time= (float)k / (float)(data->totrekey-1); psys_get_particle_on_path(data->scene, data->ob, psys, pa_index, &state, 0); VECCOPY(key->co, state.co); key->time= sta + k * dval; @@ -1780,7 +1780,7 @@ static void rekey_particle(PEData *data, int pa_index) MEM_freeN(pa->hair); pa->hair= new_keys; - pa->totkey=pset->totrekey; + pa->totkey=data->totrekey; if(edit->keys[pa_index]) MEM_freeN(edit->keys[pa_index]); @@ -1798,14 +1798,11 @@ static void rekey_particle(PEData *data, int pa_index) static int rekey_exec(bContext *C, wmOperator *op) { PEData data; - ParticleEditSettings *pset; PE_set_data(C, &data); - pset= PE_settings(data.scene); - pset->totrekey= RNA_int_get(op->ptr, "keys"); - - data.dval= 1.0f / (float)(pset->totrekey-1); + data.dval= 1.0f / (float)(data.totrekey-1); + data.totrekey= RNA_int_get(op->ptr, "keys"); foreach_selected_particle(&data, rekey_particle); |