[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12693] trunk/blender/source/blender:
Brecht Van Lommel
brechtvanlommel at pandora.be
Tue Nov 27 15:12:57 CET 2007
Revision: 12693
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12693
Author: blendix
Date: 2007-11-27 15:12:56 +0100 (Tue, 27 Nov 2007)
Log Message:
-----------
Particles
=========
- Fix crash with the cut tool and child particle drawing.
- Make the "Col" option to use material colors work for
the path/hair visualisation type.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/particle.c
trunk/blender/source/blender/src/drawobject.c
trunk/blender/source/blender/src/editparticle.c
Modified: trunk/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle.c 2007-11-27 13:25:07 UTC (rev 12692)
+++ trunk/blender/source/blender/blenkernel/intern/particle.c 2007-11-27 14:12:56 UTC (rev 12693)
@@ -1637,6 +1637,9 @@
else
check_path_length(0,0,0,0,pa_length,0);
}
+
+ if(part->draw & PART_DRAW_MAT_COL)
+ VECCOPY(state->col, &ma->r)
}
}
/* now let's finalise the interpolated parents that we might have left half done before */
@@ -1683,6 +1686,8 @@
SoftBody *soft = 0;
BodyPoint *bp[2] = {NULL, NULL};
+ Material *ma;
+
float birthtime = 0.0, dietime = 0.0;
float t, time, keytime, dfra = 1.0, frs_sec = G.scene->r.frs_sec;
float col[3] = {0.5f, 0.5f, 0.5f};
@@ -1738,6 +1743,9 @@
soft = psys->soft;
psys->lattice = psys_get_lattice(ob, psys);
+ ma= give_current_material(ob, psys->part->omat);
+ if(psys->part->draw & PART_DRAW_MAT_COL)
+ VECCOPY(col, &ma->r)
/*---first main loop: create all actual particles' paths---*/
for(i=0,pa=psys->particles; i<totpart; i++, pa++){
@@ -1922,7 +1930,6 @@
}
-
/* selection coloring in edit mode */
if(edit){
if(pset->brushtype==PE_BRUSH_WEIGHT){
Modified: trunk/blender/source/blender/src/drawobject.c
===================================================================
--- trunk/blender/source/blender/src/drawobject.c 2007-11-27 13:25:07 UTC (rev 12692)
+++ trunk/blender/source/blender/src/drawobject.c 2007-11-27 14:12:56 UTC (rev 12693)
@@ -3418,6 +3418,12 @@
glEnableClientState(GL_NORMAL_ARRAY);
glEnable(GL_LIGHTING);
+ if(part->draw&PART_DRAW_MAT_COL) {
+ glEnableClientState(GL_COLOR_ARRAY);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ glEnable(GL_COLOR_MATERIAL);
+ }
+
if(totchild && (part->draw&PART_DRAW_PARENT)==0)
totpart=0;
@@ -3426,6 +3432,8 @@
path=cache[a];
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
+ if(part->draw&PART_DRAW_MAT_COL)
+ glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
}
@@ -3434,8 +3442,16 @@
path=cache[a];
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
+ if(part->draw&PART_DRAW_MAT_COL)
+ glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
}
+
+ if(part->draw&PART_DRAW_MAT_COL) {
+ glDisable(GL_COLOR_ARRAY);
+ glDisable(GL_COLOR_MATERIAL);
+ }
+
if(cdata2)
MEM_freeN(cdata2);
cd2=cdata2=0;
@@ -3540,8 +3556,6 @@
ParticleCacheKey **path;
ParticleEditKey *key;
ParticleEditSettings *pset = PE_settings();
- /*Mesh *me= (Mesh*)ob->data;*/
- Material *ma;
int i, k, totpart = psys->totpart, totchild=0, timed = pset->draw_timed;
char nosel[4], sel[4];
float sel_col[3];
@@ -3590,10 +3604,10 @@
glDisable(GL_LIGHTING);
}
+ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ glEnable(GL_COLOR_MATERIAL);
+
for(i=0, pa=psys->particles, path = psys->pathcache; i<totpart; i++, pa++, path++){
- /*if(me->mface[pa->num].flag & ME_HIDE)
- continue;*/
-
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->co);
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), (*path)->vel);
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), (*path)->col);
@@ -3601,11 +3615,6 @@
glDrawArrays(GL_LINE_STRIP, 0, (int)(*path)->steps + 1);
}
- if(psys->part->draw&PART_DRAW_MAT_COL) {
- ma= give_current_material(ob,psys->part->omat);
- glColor3f(ma->r,ma->g,ma->b);
- glDisableClientState(GL_COLOR_ARRAY);
- }
glEnable(GL_LIGHTING);
for(i=0, path=psys->childcache; i<totchild; i++,path++){
@@ -3616,6 +3625,8 @@
glDrawArrays(GL_LINE_STRIP, 0, (int)(*path)->steps + 1);
}
+ glDisable(GL_COLOR_MATERIAL);
+
/* draw edit vertices */
if(G.scene->selectmode!=SCE_SELECT_PATH){
glDisableClientState(GL_NORMAL_ARRAY);
Modified: trunk/blender/source/blender/src/editparticle.c
===================================================================
--- trunk/blender/source/blender/src/editparticle.c 2007-11-27 13:25:07 UTC (rev 12692)
+++ trunk/blender/source/blender/src/editparticle.c 2007-11-27 14:12:56 UTC (rev 12693)
@@ -1616,14 +1616,14 @@
pa->flag &= ~PARS_REKEY;
}
-static void remove_tagged_elements(Object *ob, ParticleSystem *psys)
+static int remove_tagged_elements(Object *ob, ParticleSystem *psys)
{
ParticleEdit *edit = psys->edit;
ParticleEditSettings *pset = PE_settings();
ParticleData *pa, *npa=0, *new_pars=0;
ParticleEditKey **key, **nkey=0, **new_keys=0;
ParticleSystemModifierData *psmd;
- int i, totpart, new_totpart = psys->totpart;
+ int i, totpart, new_totpart = psys->totpart, removed = 0;
if(pset->flag & PE_X_MIRROR) {
/* mirror tags */
@@ -1635,9 +1635,12 @@
PE_mirror_particle(ob, psmd->dm, psys, pa, NULL);
}
- for(i=0, pa=psys->particles; i<psys->totpart; i++, pa++)
- if(pa->flag & PARS_TAG)
+ for(i=0, pa=psys->particles; i<psys->totpart; i++, pa++) {
+ if(pa->flag & PARS_TAG) {
new_totpart--;
+ removed++;
+ }
+ }
if(new_totpart != psys->totpart) {
if(new_totpart) {
@@ -1677,6 +1680,8 @@
edit->totkeys = psys_count_keys(psys);
}
+
+ return removed;
}
static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
{
@@ -2366,7 +2371,7 @@
ParticleBrushData *brush;
float vec1[3], vec2[3];
short mval[2], mvalo[2], firsttime = 1, dx, dy;
- int selected = 0, flip;
+ int selected = 0, flip, removed = 0;
if(!PE_can_edit(psys)) return 0;
@@ -2440,7 +2445,7 @@
else
PE_foreach_element(psys, brush_cut, &data);
- remove_tagged_elements(ob, psys);
+ removed= remove_tagged_elements(ob, psys);
if(pset->flag & PE_KEEP_LENGTHS)
recalc_lengths(psys);
break;
@@ -2535,8 +2540,8 @@
if((pset->flag & PE_KEEP_LENGTHS)==0)
recalc_lengths(psys);
- if(pset->brushtype == PE_BRUSH_ADD) {
- if(pset->flag & PE_X_MIRROR)
+ if(pset->brushtype == PE_BRUSH_ADD || removed) {
+ if(pset->brushtype == PE_BRUSH_ADD && (pset->flag & PE_X_MIRROR))
PE_mirror_x(1);
PE_recalc_world_cos(ob,psys);
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
More information about the Bf-blender-cvs
mailing list