Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r--source/blender/editors/physics/CMakeLists.txt47
-rw-r--r--source/blender/editors/physics/Makefile2
-rw-r--r--source/blender/editors/physics/particle_boids.c7
-rw-r--r--source/blender/editors/physics/particle_edit.c149
-rw-r--r--source/blender/editors/physics/particle_object.c37
-rw-r--r--source/blender/editors/physics/physics_fluid.c156
-rw-r--r--source/blender/editors/physics/physics_intern.h4
-rw-r--r--source/blender/editors/physics/physics_ops.c6
-rw-r--r--source/blender/editors/physics/physics_pointcache.c42
9 files changed, 289 insertions, 161 deletions
diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt
new file mode 100644
index 00000000000..be826654311
--- /dev/null
+++ b/source/blender/editors/physics/CMakeLists.txt
@@ -0,0 +1,47 @@
+# $Id: CMakeLists.txt 12931 2007-12-17 18:20:48Z theeth $
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+FILE(GLOB SRC *.c)
+
+SET(INC
+ ../include
+ ../../blenkernel
+ ../../blenlib
+ ../../makesdna
+ ../../makesrna
+ ../../windowmanager
+ ../../../../intern/elbeem/extern
+ ../../../../intern/guardedalloc
+)
+
+IF(NOT WITH_FLUID)
+ ADD_DEFINITIONS(-DDISABLE_ELBEEM)
+ENDIF(NOT WITH_FLUID)
+
+IF(WITH_OPENMP)
+ ADD_DEFINITIONS(-DPARALLEL=1)
+ENDIF(WITH_OPENMP)
+
+IF(WIN32)
+ SET(INC ${INC} ${PTHREADS_INC})
+ENDIF(WIN32)
+
+BLENDERLIB(bf_editor_physics "${SRC}" "${INC}")
diff --git a/source/blender/editors/physics/Makefile b/source/blender/editors/physics/Makefile
index e9260b66087..9ffc3a5b372 100644
--- a/source/blender/editors/physics/Makefile
+++ b/source/blender/editors/physics/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2007 Blender Foundation
# All rights reserved.
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index 37de0d8f873..a18890881a8 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -35,6 +35,7 @@
#include "BKE_boids.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
+#include "BKE_main.h"
#include "BKE_particle.h"
#include "BLI_listbase.h"
@@ -99,6 +100,7 @@ void BOID_OT_rule_add(wmOperatorType *ot)
}
static int rule_del_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys= ptr.data;
@@ -125,7 +127,7 @@ static int rule_del_exec(bContext *C, wmOperator *op)
if(rule)
rule->flag |= BOIDRULE_CURRENT;
- DAG_scene_sort(scene);
+ DAG_scene_sort(bmain, scene);
DAG_id_flush_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
@@ -266,6 +268,7 @@ void BOID_OT_state_add(wmOperatorType *ot)
}
static int state_del_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys= ptr.data;
@@ -297,7 +300,7 @@ static int state_del_exec(bContext *C, wmOperator *op)
state->flag |= BOIDSTATE_CURRENT;
- DAG_scene_sort(scene);
+ DAG_scene_sort(bmain, scene);
DAG_id_flush_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index d20e0e87934..d491b1a9731 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -124,7 +124,7 @@ int PE_hair_poll(bContext *C)
return (edit && edit->psys);
}
-int PE_poll_3dview(bContext *C)
+int PE_poll_view3d(bContext *C)
{
return PE_poll(C) && CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
@@ -160,7 +160,7 @@ void PE_free_ptcache_edit(PTCacheEdit *edit)
edit->emitter_field= 0;
}
- psys_free_path_cache(NULL, edit);
+ psys_free_path_cache(edit->psys, edit);
MEM_freeN(edit);
}
@@ -897,13 +897,13 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
if(dot<dist_1st) {
normalize_v3(dvec);
mul_v3_fl(dvec,dist_1st-dot);
- add_v3_v3v3(key->co,key->co,dvec);
+ add_v3_v3(key->co, dvec);
}
}
else {
normalize_v3(dvec);
mul_v3_fl(dvec,dist_1st-dot);
- add_v3_v3v3(key->co,key->co,dvec);
+ add_v3_v3(key->co, dvec);
}
if(k==1)
dist_1st*=1.3333f;
@@ -989,7 +989,7 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit)
}
if(k) {
- add_v3_v3v3((key-1)->co,(key-1)->co,dv1);
+ add_v3_v3((key-1)->co, dv1);
}
VECADD(dv1,dv0,dv2);
@@ -1321,7 +1321,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
}
PE_update_selection(scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
}
@@ -1371,7 +1371,7 @@ int PE_mouse_particles(bContext *C, short *mval, int extend)
for_mouse_hit_keys(&data, toggle_key_select, 1); /* nearest only */
PE_update_selection(scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
}
@@ -1380,11 +1380,14 @@ int PE_mouse_particles(bContext *C, short *mval, int extend)
static void select_root(PEData *data, int point_index)
{
+ if (data->edit->points[point_index].flag & PEP_HIDE)
+ return;
+
data->edit->points[point_index].keys->flag |= PEK_SELECT;
data->edit->points[point_index].flag |= PEP_EDIT_RECALC; /* redraw selection only */
}
-static int select_first_exec(bContext *C, wmOperator *op)
+static int select_roots_exec(bContext *C, wmOperator *op)
{
PEData data;
@@ -1392,19 +1395,19 @@ static int select_first_exec(bContext *C, wmOperator *op)
foreach_point(&data, select_root);
PE_update_selection(data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
}
-void PARTICLE_OT_select_first(wmOperatorType *ot)
+void PARTICLE_OT_select_roots(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select First";
- ot->idname= "PARTICLE_OT_select_first";
+ ot->name= "Select Roots";
+ ot->idname= "PARTICLE_OT_select_roots";
/* api callbacks */
- ot->exec= select_first_exec;
+ ot->exec= select_roots_exec;
ot->poll= PE_poll;
/* flags */
@@ -1416,11 +1419,15 @@ void PARTICLE_OT_select_first(wmOperatorType *ot)
static void select_tip(PEData *data, int point_index)
{
PTCacheEditPoint *point = data->edit->points + point_index;
+
+ if (point->flag & PEP_HIDE)
+ return;
+
point->keys[point->totkey - 1].flag |= PEK_SELECT;
point->flag |= PEP_EDIT_RECALC; /* redraw selection only */
}
-static int select_last_exec(bContext *C, wmOperator *op)
+static int select_tips_exec(bContext *C, wmOperator *op)
{
PEData data;
@@ -1428,19 +1435,19 @@ static int select_last_exec(bContext *C, wmOperator *op)
foreach_point(&data, select_tip);
PE_update_selection(data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
}
-void PARTICLE_OT_select_last(wmOperatorType *ot)
+void PARTICLE_OT_select_tips(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select Last";
- ot->idname= "PARTICLE_OT_select_last";
+ ot->name= "Select Tips";
+ ot->idname= "PARTICLE_OT_select_tips";
/* api callbacks */
- ot->exec= select_last_exec;
+ ot->exec= select_tips_exec;
ot->poll= PE_poll;
/* flags */
@@ -1468,7 +1475,7 @@ static int select_linked_exec(bContext *C, wmOperator *op)
for_mouse_hit_keys(&data, select_keys, 1); /* nearest only */
PE_update_selection(data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
}
@@ -1494,7 +1501,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot)
/* api callbacks */
ot->exec= select_linked_exec;
ot->invoke= select_linked_invoke;
- ot->poll= PE_poll_3dview;
+ ot->poll= PE_poll_view3d;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1534,7 +1541,7 @@ int PE_border_select(bContext *C, rcti *rect, int select, int extend)
for_mouse_hit_keys(&data, select_key, 0);
PE_update_selection(scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
}
@@ -1559,7 +1566,7 @@ int PE_circle_select(bContext *C, int selecting, short *mval, float rad)
for_mouse_hit_keys(&data, select_key, 0);
PE_update_selection(scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
}
@@ -1625,7 +1632,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short select)
}
PE_update_selection(scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
}
@@ -1659,7 +1666,7 @@ static int hide_exec(bContext *C, wmOperator *op)
}
PE_update_selection(scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
}
@@ -1701,7 +1708,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
}
PE_update_selection(scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
}
@@ -1759,7 +1766,7 @@ static int select_less_exec(bContext *C, wmOperator *op)
foreach_point(&data, select_less_keys);
PE_update_selection(data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
}
@@ -1820,7 +1827,7 @@ static int select_more_exec(bContext *C, wmOperator *op)
foreach_point(&data, select_more_keys);
PE_update_selection(data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
}
@@ -1857,7 +1864,7 @@ static int select_inverse_exec(bContext *C, wmOperator *op)
}
PE_update_selection(data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
}
@@ -1948,7 +1955,7 @@ static int rekey_exec(bContext *C, wmOperator *op)
recalc_lengths(data.edit);
PE_update_object(data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
}
@@ -2091,6 +2098,7 @@ static void remove_tagged_keys(Scene *scene, Object *ob, ParticleSystem *psys)
ParticleData *pa;
HairKey *hkey, *nhkey, *new_hkeys=0;
POINT_P; KEY_K;
+ PTCacheEditKey *nkey, *new_keys;
ParticleSystemModifierData *psmd;
short new_totkey;
@@ -2126,9 +2134,10 @@ static void remove_tagged_keys(Scene *scene, Object *ob, ParticleSystem *psys)
}
if(new_totkey != pa->totkey) {
- hkey= pa->hair;
nhkey= new_hkeys= MEM_callocN(new_totkey*sizeof(HairKey), "HairKeys");
+ nkey= new_keys= MEM_callocN(new_totkey*sizeof(PTCacheEditKey), "particle edit keys");
+ hkey= pa->hair;
LOOP_KEYS {
while(key->flag & PEK_TAG && hkey < pa->hair + pa->totkey) {
key++;
@@ -2137,29 +2146,36 @@ static void remove_tagged_keys(Scene *scene, Object *ob, ParticleSystem *psys)
if(hkey < pa->hair + pa->totkey) {
VECCOPY(nhkey->co, hkey->co);
+ 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 */
+ nkey->flag = key->flag;
+ nkey->ftime = key->ftime;
+ nkey->length = key->length;
+ VECCOPY(nkey->world_co, key->world_co);
}
- hkey++;
+ nkey++;
nhkey++;
+ hkey++;
}
+
if(pa->hair)
MEM_freeN(pa->hair);
+
+ if(point->keys)
+ MEM_freeN(point->keys);
pa->hair= new_hkeys;
+ point->keys= new_keys;
point->totkey= pa->totkey= new_totkey;
- if(point->keys)
- MEM_freeN(point->keys);
- key= point->keys= MEM_callocN(new_totkey*sizeof(PTCacheEditKey), "particle edit keys");
-
- hkey = pa->hair;
- LOOP_KEYS {
- key->co= hkey->co;
- key->time= &hkey->time;
- hkey++;
- }
+ /* flag for recalculating length */
+ point->flag |= PEP_EDIT_RECALC;
}
}
}
@@ -2253,7 +2269,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
recalc_lengths(data.edit);
PE_update_object(data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
}
@@ -2341,7 +2357,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_INFO, "Remove %d double particles.", totremoved);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
return OPERATOR_FINISHED;
}
@@ -2376,21 +2392,22 @@ static int weight_set_exec(bContext *C, wmOperator *op)
HairKey *hkey;
float weight;
ParticleBrushData *brush= &pset->brush[pset->brushtype];
- edit= psys->edit;
+ float factor= RNA_float_get(op->ptr, "factor");
weight= brush->strength;
+ edit= psys->edit;
LOOP_SELECTED_POINTS {
ParticleData *pa= psys->particles + p;
LOOP_SELECTED_KEYS {
hkey= pa->hair + k;
- hkey->weight= weight;
+ hkey->weight= interpf(weight, hkey->weight, factor);
}
}
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
return OPERATOR_FINISHED;
}
@@ -2407,6 +2424,8 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", "", 0, 1);
}
/************************ cursor drawing *******************************/
@@ -2446,7 +2465,7 @@ static void toggle_particle_cursor(bContext *C, int enable)
pset->paintcursor = NULL;
}
else if(enable)
- pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_3dview, brush_drawcursor, NULL);
+ pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_view3d, brush_drawcursor, NULL);
}
/********************* radial control operator *********************/
@@ -2565,7 +2584,7 @@ static int delete_exec(bContext *C, wmOperator *op)
}
DAG_id_flush_update(&data.ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, data.ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
}
@@ -2724,7 +2743,7 @@ static int mirror_exec(bContext *C, wmOperator *op)
PE_mirror_x(scene, ob, 0);
update_world_cos(ob, edit);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
return OPERATOR_FINISHED;
@@ -3317,7 +3336,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
RNA_float_get_array(itemptr, "mouse", mousef);
mouse[0] = mousef[0];
mouse[1] = mousef[1];
- flip= RNA_boolean_get(itemptr, "flip");
+ flip= RNA_boolean_get(itemptr, "pen_flip");
if(bedit->first) {
bedit->lastmouse[0]= mouse[0];
@@ -3509,7 +3528,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
else
PE_update_object(scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
bedit->lastmouse[0]= mouse[0];
bedit->lastmouse[1]= mouse[1];
@@ -3606,7 +3625,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot)
ot->invoke= brush_edit_invoke;
ot->modal= brush_edit_modal;
ot->cancel= brush_edit_cancel;
- ot->poll= PE_poll_3dview;
+ ot->poll= PE_poll_view3d;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@ -3663,6 +3682,8 @@ static void make_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo)
for(; pm; pm=pm->next) {
for(i=0; i<BPHYS_TOT_DATA; i++)
pm->data[i] = MEM_dupallocN(pm->data[i]);
+
+ pm->index_array = MEM_dupallocN(pm->index_array);
}
}
@@ -3737,6 +3758,8 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo)
for(i=0; i<BPHYS_TOT_DATA; i++)
pm->data[i] = MEM_dupallocN(pm->data[i]);
+ pm->index_array = MEM_dupallocN(pm->index_array);
+
BKE_ptcache_mem_init_pointers(pm);
LOOP_POINTS {
@@ -4001,12 +4024,20 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache,
LOOP_POINTS {
if(psys) {
- pa = psys->particles + p;
- if((pm->next && pm->next->frame < pa->time)
- || (pm->prev && pm->prev->frame >= pa->dietime)) {
- BKE_ptcache_mem_incr_pointers(pm);
+ if(pm->index_array) {
+ if(pm->index_array[p])
+ BKE_ptcache_mem_seek_pointers(p, pm);
+ else
continue;
- }
+ }
+ else {
+ pa = psys->particles + p;
+ if((pm->next && pm->next->frame < pa->time)
+ || (pm->prev && pm->prev->frame >= pa->dietime)) {
+ BKE_ptcache_mem_incr_pointers(pm);
+ continue;
+ }
+ }
}
if(!point->totkey) {
@@ -4116,7 +4147,7 @@ static int clear_edited_exec(bContext *C, wmOperator *op)
psys->flag &= ~PSYS_EDITED;
psys_reset(psys, PSYS_RESET_DEPSGRAPH);
- WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
}
}
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index d8ca65fa8c9..ba5d1ee5250 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -69,7 +69,9 @@ static int particle_system_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
object_add_particle_system(scene, ob, NULL);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
@@ -107,7 +109,8 @@ static int particle_system_remove_exec(bContext *C, wmOperator *op)
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_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
@@ -163,10 +166,10 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op)
psys_check_boid_data(psys);
- DAG_scene_sort(scene);
+ DAG_scene_sort(bmain, scene);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
return OPERATOR_FINISHED;
}
@@ -190,6 +193,7 @@ void PARTICLE_OT_new(wmOperatorType *ot)
static int new_particle_target_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys= ptr.data;
@@ -211,10 +215,10 @@ static int new_particle_target_exec(bContext *C, wmOperator *op)
BLI_addtail(&psys->targets, pt);
- DAG_scene_sort(scene);
+ DAG_scene_sort(bmain, scene);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
return OPERATOR_FINISHED;
}
@@ -235,6 +239,7 @@ void PARTICLE_OT_new_target(wmOperatorType *ot)
static int remove_particle_target_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys= ptr.data;
@@ -259,10 +264,10 @@ static int remove_particle_target_exec(bContext *C, wmOperator *op)
if(pt)
pt->flag |= PTARGET_CURRENT;
- DAG_scene_sort(scene);
+ DAG_scene_sort(bmain, scene);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
return OPERATOR_FINISHED;
}
@@ -300,7 +305,7 @@ static int target_move_up_exec(bContext *C, wmOperator *op)
BLI_insertlink(&psys->targets, pt->prev->prev, pt);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
break;
}
}
@@ -338,7 +343,7 @@ static int target_move_down_exec(bContext *C, wmOperator *op)
BLI_insertlink(&psys->targets, pt->next, pt);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
break;
}
}
@@ -376,7 +381,7 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *op)
BLI_remlink(&part->dupliweights, dw);
BLI_insertlink(&part->dupliweights, dw->prev->prev, dw);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL);
break;
}
}
@@ -415,7 +420,7 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *op)
dw->flag |= PART_DUPLIW_CURRENT;
BLI_addhead(&part->dupliweights, dw);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL);
break;
}
}
@@ -461,7 +466,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *op)
if(dw)
dw->flag |= PART_DUPLIW_CURRENT;
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL);
return OPERATOR_FINISHED;
}
@@ -498,7 +503,7 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *op)
BLI_remlink(&part->dupliweights, dw);
BLI_insertlink(&part->dupliweights, dw->next, dw);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL);
break;
}
}
@@ -590,7 +595,7 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
disconnect_hair(scene, ob, psys);
}
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
return OPERATOR_FINISHED;
}
@@ -729,7 +734,7 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
connect_hair(scene, ob, psys);
}
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 6f5b8924a13..f411f92d395 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -77,7 +77,6 @@
#include "LBM_fluidsim.h"
-#include "BIF_gl.h"
#include "ED_screen.h"
@@ -297,6 +296,8 @@ static void set_vertex_channel(float *channel, float time, struct Scene *scene,
static void free_domain_channels(FluidAnimChannels *channels)
{
+ if (!channels->timeAtFrame)
+ return;
MEM_freeN(channels->timeAtFrame);
channels->timeAtFrame = NULL;
MEM_freeN(channels->DomainGravity);
@@ -561,7 +562,6 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
if(verts) MEM_freeN(verts);
if(tris) MEM_freeN(tris);
- if(fsmesh.channelVertices) MEM_freeN(fsmesh.channelVertices);
}
}
@@ -708,7 +708,7 @@ typedef struct FluidBakeJob {
/* from wmJob */
void *owner;
short *stop, *do_update;
-
+ float *progress;
int current_frame;
elbeemSimulationSettings *settings;
} FluidBakeJob;
@@ -732,19 +732,21 @@ static int fluidbake_breakjob(void *customdata)
}
/* called by fluidbake, wmJob sends notifier */
-static void fluidbake_updatejob(void *customdata, char *str)
+static void fluidbake_updatejob(void *customdata, float progress)
{
FluidBakeJob *fb= customdata;
*(fb->do_update)= 1;
+ *(fb->progress)= progress;
}
-static void fluidbake_startjob(void *customdata, short *stop, short *do_update)
+static void fluidbake_startjob(void *customdata, short *stop, short *do_update, float *progress)
{
FluidBakeJob *fb= customdata;
fb->stop= stop;
fb->do_update = do_update;
+ fb->progress = progress;
G.afbreek= 0; /* XXX shared with render - replace with job 'stop' switch */
@@ -753,14 +755,24 @@ static void fluidbake_startjob(void *customdata, short *stop, short *do_update)
*stop = 0;
}
+static void fluidbake_endjob(void *customdata)
+{
+ FluidBakeJob *fb= customdata;
+
+ if (fb->settings) {
+ MEM_freeN(fb->settings);
+ fb->settings = NULL;
+ }
+}
+
int runSimulationCallback(void *data, int status, int frame) {
FluidBakeJob *fb = (FluidBakeJob *)data;
+ elbeemSimulationSettings *settings = fb->settings;
- //elbeemSimulationSettings *settings = fb->settings;
- //printf("elbeem blender cb s%d, f%d, domainid:%d \n", status,frame, settings->domainId ); // DEBUG
-
- if (status == FLUIDSIM_CBSTATUS_NEWFRAME)
- fluidbake_updatejob(fb, "");
+ 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;
@@ -769,6 +781,28 @@ int runSimulationCallback(void *data, int status, int frame) {
return FLUIDSIM_CBRET_CONTINUE;
}
+static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects, elbeemSimulationSettings *fsset, FluidBakeJob *fb)
+{
+ free_domain_channels(channels);
+ MEM_freeN(channels);
+ channels = NULL;
+
+ free_all_fluidobject_channels(fobjects);
+ BLI_freelistN(fobjects);
+ MEM_freeN(fobjects);
+ fobjects = NULL;
+
+ if (fsset) {
+ MEM_freeN(fsset);
+ fsset = NULL;
+ }
+
+ if (fb) {
+ MEM_freeN(fb);
+ fb = NULL;
+ }
+}
+
int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
{
Scene *scene= CTX_data_scene(C);
@@ -799,9 +833,9 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
wmJob *steve;
FluidBakeJob *fb;
- elbeemSimulationSettings fsset;
+ elbeemSimulationSettings *fsset= MEM_callocN(sizeof(elbeemSimulationSettings), "Fluid sim settings");
- steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, 0);
+ steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS);
fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job");
if(getenv(strEnvName)) {
@@ -815,14 +849,15 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
noFrames = scene->r.efra - 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;
}
/* 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 wouldnt be here */
fluidmd = (FluidsimModifierData *)modifiers_findByType(fsDomain, eModifierType_Fluidsim);
@@ -902,7 +937,7 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
for(i=2; i<=allchannelSize; i++) {
timeAtFrame[i] = timeAtFrame[i-1]+channelDomainTime[(i-1)*2+0];
}
- } else {
+ fsset->} else {
for(i=2; i<=allchannelSize; i++) { timeAtFrame[i] = timeAtFrame[i-1]+aniFrameTime; }
}
@@ -916,12 +951,7 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
elbeemDebugOut(debugStrBuffer);
BKE_report(reports, RPT_ERROR, "Invalid object matrix.");
- free_domain_channels(channels);
- MEM_freeN(channels);
-
- free_all_fluidobject_channels(fobjects);
- BLI_freelistN(fobjects);
- MEM_freeN(fobjects);
+ fluidbake_free_data(channels, fobjects, fsset, fb);
return 0;
}
@@ -936,86 +966,82 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
}
/* ******** export domain to elbeem ******** */
- elbeemResetSettings(&fsset);
- fsset.version = 1;
+ elbeemResetSettings(fsset);
+ fsset->version = 1;
// setup global settings
- copy_v3_v3(fsset.geoStart, domainSettings->bbStart);
- copy_v3_v3(fsset.geoSize, domainSettings->bbSize);
+ 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;
+ fsset->resolutionxyz = (int)domainSettings->resolutionxyz;
+ fsset->previewresxyz = (int)domainSettings->previewresxyz;
- fsset.realsize = get_fluid_size_m(scene, fsDomain, domainSettings);
- fsset.viscosity = get_fluid_viscosity(domainSettings);
- get_fluid_gravity(fsset.gravity, scene, domainSettings);
+ fsset->realsize = get_fluid_size_m(scene, fsDomain, domainSettings);
+ fsset->viscosity = get_fluid_viscosity(domainSettings);
+ get_fluid_gravity(fsset->gravity, scene, domainSettings);
// simulate 5 frames, each 0.03 seconds, output to ./apitest_XXX.bobj.gz
- fsset.animStart = domainSettings->animStart;
- fsset.aniFrameTime = channels->aniFrameTime;
- fsset.noOfFrames = noFrames; // is otherwise subtracted in parser
+ fsset->animStart = domainSettings->animStart;
+ fsset->aniFrameTime = channels->aniFrameTime;
+ fsset->noOfFrames = noFrames; // is otherwise subtracted in parser
+
strcpy(targetFile, targetDir);
strcat(targetFile, suffixSurface);
// 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;
- strcpy( fsset.outputPath, targetFile);
+ 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;
+ strcpy( fsset->outputPath, targetFile);
// domain channels
- 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;
-
- if (domainSettings->typeFlags & OB_FSBND_NOSLIP) fsset.domainobsType = FLUIDSIM_OBSTACLE_NOSLIP;
- else if (domainSettings->typeFlags&OB_FSBND_PARTSLIP) fsset.domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP;
- else if (domainSettings->typeFlags&OB_FSBND_FREESLIP) fsset.domainobsType = FLUIDSIM_OBSTACLE_FREESLIP;
- fsset.domainobsPartslip = domainSettings->partSlipValue;
- fsset.generateVertexVectors = (domainSettings->domainNovecgen==0);
+ 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;
+
+ if (domainSettings->typeFlags & OB_FSBND_NOSLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_NOSLIP;
+ else if (domainSettings->typeFlags&OB_FSBND_PARTSLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP;
+ else if (domainSettings->typeFlags&OB_FSBND_FREESLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP;
+ fsset->domainobsPartslip = domainSettings->partSlipValue;
+ fsset->generateVertexVectors = (domainSettings->domainNovecgen==0);
// init blender domain transform matrix
{ int j;
for(i=0; i<4; i++) {
for(j=0; j<4; j++) {
- fsset.surfaceTrafo[i*4+j] = invDomMat[j][i];
+ fsset->surfaceTrafo[i*4+j] = invDomMat[j][i];
}
} }
/* ******** init solver with settings ******** */
elbeemInit();
- elbeemAddDomain(&fsset);
+ elbeemAddDomain(fsset);
/* ******** export all fluid objects to elbeem ******** */
export_fluid_objects(fobjects, scene, channels->length);
/* custom data for fluid bake job */
- fb->settings = &fsset;
+ fb->settings = fsset;
/* setup job */
WM_jobs_customdata(steve, fb, fluidbake_free);
WM_jobs_timer(steve, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME);
- WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL);
+ WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL, fluidbake_endjob);
WM_jobs_start(CTX_wm_manager(C), steve);
/* ******** free stored animation data ******** */
- free_domain_channels(channels);
- MEM_freeN(channels);
-
- free_all_fluidobject_channels(fobjects);
- BLI_freelistN(fobjects);
- MEM_freeN(fobjects);
+ fluidbake_free_data(channels, fobjects, NULL, NULL);
// elbeemFree();
return 1;
diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h
index aa3a2e22e31..b3d11810c43 100644
--- a/source/blender/editors/physics/physics_intern.h
+++ b/source/blender/editors/physics/physics_intern.h
@@ -37,8 +37,8 @@ struct wmOperatorType;
/* particle_edit.c */
void PARTICLE_OT_select_all(struct wmOperatorType *ot);
-void PARTICLE_OT_select_first(struct wmOperatorType *ot);
-void PARTICLE_OT_select_last(struct wmOperatorType *ot);
+void PARTICLE_OT_select_roots(struct wmOperatorType *ot);
+void PARTICLE_OT_select_tips(struct wmOperatorType *ot);
void PARTICLE_OT_select_linked(struct wmOperatorType *ot);
void PARTICLE_OT_select_less(struct wmOperatorType *ot);
void PARTICLE_OT_select_more(struct wmOperatorType *ot);
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 4bdac8ff3e8..2b7f8e9d5a2 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -43,8 +43,8 @@
static void operatortypes_particle(void)
{
WM_operatortype_append(PARTICLE_OT_select_all);
- WM_operatortype_append(PARTICLE_OT_select_first);
- WM_operatortype_append(PARTICLE_OT_select_last);
+ WM_operatortype_append(PARTICLE_OT_select_roots);
+ WM_operatortype_append(PARTICLE_OT_select_tips);
WM_operatortype_append(PARTICLE_OT_select_linked);
WM_operatortype_append(PARTICLE_OT_select_less);
WM_operatortype_append(PARTICLE_OT_select_more);
@@ -114,7 +114,7 @@ static void keymap_particle(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
- ED_object_generic_keymap(keyconf, keymap, 1);
+ ED_object_generic_keymap(keyconf, keymap, 2);
}
/******************************* boids *************************************/
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index 57a123d8f17..35f86a49aa7 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -33,15 +33,15 @@
#include "DNA_scene_types.h"
-#include "BKE_anim.h"
#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_modifier.h"
#include "BKE_particle.h"
+#include "BKE_pointcache.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_utildefines.h"
-#include "BKE_pointcache.h"
-#include "BKE_global.h"
-#include "BKE_modifier.h"
#include "BLI_blenlib.h"
@@ -71,7 +71,7 @@ static int ptcache_bake_all_poll(bContext *C)
static int ptcache_poll(bContext *C)
{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
return (ptr.data && ptr.id.data);
}
@@ -88,11 +88,12 @@ void bake_console_progress_end(void *arg)
static int ptcache_bake_all_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
- wmWindow *win = CTX_wm_window(C);
+ wmWindow *win = G.background ? NULL : CTX_wm_window(C);
PTCacheBaker baker;
-
+ baker.main = bmain;
baker.scene = scene;
baker.pid = NULL;
baker.bake = RNA_boolean_get(op->ptr, "bake");
@@ -115,6 +116,7 @@ static int ptcache_bake_all_exec(bContext *C, wmOperator *op)
BKE_ptcache_make_cache(&baker);
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+ WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, NULL);
return OPERATOR_FINISHED;
}
@@ -133,6 +135,8 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *op)
}
BLI_freelistN(&pidlist);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, base->object);
}
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
@@ -170,9 +174,10 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
}
static int ptcache_bake_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- wmWindow *win = CTX_wm_window(C);
- PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache);
+ wmWindow *win = G.background ? NULL : CTX_wm_window(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
Object *ob= ptr.id.data;
PointCache *cache= ptr.data;
PTCacheBaker baker;
@@ -186,6 +191,7 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op)
break;
}
+ baker.main = bmain;
baker.scene = scene;
baker.pid = pid;
baker.bake = RNA_boolean_get(op->ptr, "bake");
@@ -211,13 +217,15 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op)
BLI_freelistN(&pidlist);
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+ WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
static int ptcache_free_bake_exec(bContext *C, wmOperator *op)
{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
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?")) {
@@ -228,15 +236,20 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *op)
}
else
cache->flag &= ~PTCACHE_BAKED;
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *op)
{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache);
+ 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;
}
@@ -285,7 +298,7 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot)
static int ptcache_add_new_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
Object *ob= ptr.id.data;
PointCache *cache= ptr.data;
PTCacheID *pid;
@@ -303,12 +316,13 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *op)
BLI_freelistN(&pidlist);
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+ WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
static int ptcache_remove_exec(bContext *C, wmOperator *op)
{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
Scene *scene= CTX_data_scene(C);
Object *ob= ptr.id.data;
PointCache *cache= ptr.data;
@@ -331,6 +345,8 @@ static int ptcache_remove_exec(bContext *C, wmOperator *op)
}
BLI_freelistN(&pidlist);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}