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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2007-11-27 20:20:35 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2007-11-27 20:20:35 +0300
commit3da97e27c6cb5e1d2a5e93c795b58d88f22196df (patch)
tree74d5d81159903c36de11350c7a5ae2b98e58ad65 /source/blender/src/editparticle.c
parentd53f147b7bbc6a171baeb45976cf5cfa666a7e16 (diff)
Particles
========= - Fix for child particles disappearing with right mouse drag translation. - Added partial cache updates for selection, should make it a bit faster.
Diffstat (limited to 'source/blender/src/editparticle.c')
-rw-r--r--source/blender/src/editparticle.c64
1 files changed, 51 insertions, 13 deletions
diff --git a/source/blender/src/editparticle.c b/source/blender/src/editparticle.c
index c62a7ea7441..e08ca3279d6 100644
--- a/source/blender/src/editparticle.c
+++ b/source/blender/src/editparticle.c
@@ -954,17 +954,25 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys)
BLI_kdtree_balance(edit->emitter_field);
}
-void PE_update_selection(Object *ob)
+void PE_update_selection(Object *ob, int useflag)
{
ParticleSystem *psys= PE_get_current(ob);
ParticleEdit *edit= psys->edit;
+ ParticleEditSettings *pset= PE_settings();
+ ParticleSettings *part= psys->part;
ParticleData *pa;
HairKey *hkey;
ParticleEditKey *key;
+ float cfra= CFRA;
int i, k, totpart;
totpart= psys->totpart;
+ /* flag all particles to be updated if not using flag */
+ if(!useflag)
+ LOOP_PARTICLES(i,pa)
+ pa->flag |= PARS_EDIT_RECALC;
+
/* flush edit key flag to hair key flag to preserve selection
* on save */
LOOP_PARTICLES(i,pa) {
@@ -974,7 +982,14 @@ void PE_update_selection(Object *ob)
hkey->editflag= key->flag;
}
- psys_cache_paths(ob, psys, CFRA, 0);
+ psys_cache_paths(ob, psys, CFRA, 1);
+
+ if(part->childtype && (pset->flag & PE_SHOW_CHILD))
+ psys_cache_child_paths(ob, psys, cfra, 1);
+
+ /* disable update flag */
+ LOOP_PARTICLES(i,pa)
+ pa->flag &= ~PARS_EDIT_RECALC;
}
void PE_update_object(Object *ob, int useflag)
@@ -1109,12 +1124,15 @@ void PE_set_particle_edit(void)
static void select_key(ParticleSystem *psys, int pa_index, int key_index, void *userData)
{
struct { short *mval; float rad; rcti* rect; int select; } *data = userData;
+ ParticleData *pa = psys->particles + pa_index;
ParticleEditKey *key = psys->edit->keys[pa_index] + key_index;
if(data->select)
key->flag|=PEK_SELECT;
else
key->flag&=~PEK_SELECT;
+
+ pa->flag |= PARS_EDIT_RECALC;
}
static void select_keys(ParticleSystem *psys, int pa_index, int key_index, void *userData)
{
@@ -1130,13 +1148,18 @@ static void select_keys(ParticleSystem *psys, int pa_index, int key_index, void
key->flag&=~PEK_SELECT;
}
+ pa->flag |= PARS_EDIT_RECALC;
}
static void toggle_key_select(ParticleSystem *psys, int pa_index, int key_index, void *userData)
{
+ ParticleData *pa = psys->particles + pa_index;
+
if(psys->edit->keys[pa_index][key_index].flag&PEK_SELECT)
psys->edit->keys[pa_index][key_index].flag&=~PEK_SELECT;
else
psys->edit->keys[pa_index][key_index].flag|=PEK_SELECT;
+
+ pa->flag |= PARS_EDIT_RECALC;
}
static void select_root(ParticleSystem *psys, int index, void *userData)
{
@@ -1234,6 +1257,7 @@ void PE_deselectall(void)
if(key->flag&PEK_SELECT){
sel = 1;
key->flag &= ~PEK_SELECT;
+ pa->flag |= PARS_EDIT_RECALC;
}
}
}
@@ -1242,12 +1266,15 @@ void PE_deselectall(void)
LOOP_PARTICLES(i,pa){
if(pa->flag & PARS_HIDE) continue;
LOOP_KEYS(k,key){
- key->flag |= PEK_SELECT;
+ if(!(key->flag & PEK_SELECT)) {
+ key->flag |= PEK_SELECT;
+ pa->flag |= PARS_EDIT_RECALC;
+ }
}
}
}
- PE_update_selection(ob);
+ PE_update_selection(ob, 1);
BIF_undo_push("(De)select all keys");
allqueue(REDRAWVIEW3D, 1);
@@ -1278,7 +1305,10 @@ void PE_mouse_particles(void)
LOOP_PARTICLES(i,pa){
if(pa->flag & PARS_HIDE) continue;
LOOP_KEYS(k,key){
- key->flag &= ~PEK_SELECT;
+ if(key->flag & PEK_SELECT) {
+ key->flag &= ~PEK_SELECT;
+ pa->flag |= PARS_EDIT_RECALC;
+ }
}
}
@@ -1291,7 +1321,7 @@ void PE_mouse_particles(void)
for_mouse_hit_keys(1,psys,toggle_key_select,&data);
- PE_update_selection(ob);
+ PE_update_selection(ob, 1);
rightmouse_transform();
@@ -1335,7 +1365,7 @@ void PE_select_linked(void)
for_mouse_hit_keys(1,psys,select_keys,&data);
- PE_update_selection(ob);
+ PE_update_selection(ob, 1);
BIF_undo_push("Select linked keys");
@@ -1364,7 +1394,7 @@ void PE_borderselect(void)
for_mouse_hit_keys(0,psys,select_key,&data);
- PE_update_selection(ob);
+ PE_update_selection(ob, 1);
BIF_undo_push("Select keys");
@@ -1417,10 +1447,14 @@ void PE_do_lasso_select(short mcords[][2], short moves, short select)
Mat4MulVecfl(mat, co);
project_short(co,vertco);
if(lasso_inside(mcords,moves,vertco[0],vertco[1])){
- if(select)
+ if(select && !(key->flag & PEK_SELECT)) {
key->flag|=PEK_SELECT;
- else
+ pa->flag |= PARS_EDIT_RECALC;
+ }
+ else if(key->flag & PEK_SELECT) {
key->flag&=~PEK_SELECT;
+ pa->flag |= PARS_EDIT_RECALC;
+ }
}
}
}
@@ -1431,15 +1465,19 @@ void PE_do_lasso_select(short mcords[][2], short moves, short select)
Mat4MulVecfl(mat, co);
project_short(co,vertco);
if(lasso_inside(mcords,moves,vertco[0],vertco[1])){
- if(select)
+ if(select && !(key->flag & PEK_SELECT)) {
key->flag|=PEK_SELECT;
- else
+ pa->flag |= PARS_EDIT_RECALC;
+ }
+ else if(key->flag & PEK_SELECT) {
key->flag&=~PEK_SELECT;
+ pa->flag |= PARS_EDIT_RECALC;
+ }
}
}
}
- PE_update_selection(ob);
+ PE_update_selection(ob, 1);
BIF_undo_push("Lasso select particles");