Revision: 17382
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17382
Author:   broken
Date:     2008-11-10 01:14:35 +0100 (Mon, 10 Nov 2008)

Log Message:
-----------
Point Density

* Fixed a stupid crash caused by last commit that worked fine on the mac
(but never should have...)

* Fix for using child particles with the new particle age color options

Modified Paths:
--------------
    branches/sim_physics/source/blender/blenkernel/intern/texture.c
    branches/sim_physics/source/blender/render/intern/source/pointdensity.c
    branches/sim_physics/source/blender/src/buttons_shading.c

Modified: branches/sim_physics/source/blender/blenkernel/intern/texture.c
===================================================================
--- branches/sim_physics/source/blender/blenkernel/intern/texture.c     
2008-11-09 21:42:30 UTC (rev 17381)
+++ branches/sim_physics/source/blender/blenkernel/intern/texture.c     
2008-11-10 00:14:35 UTC (rev 17382)
@@ -873,6 +873,7 @@
        PointDensity *pd;
        
        pd= MEM_callocN(sizeof(PointDensity), "pointdensity");
+       pd->flag = 0;
        pd->radius = 0.3f;
        pd->falloff_type = TEX_PD_FALLOFF_STD;
        pd->falloff_softness = 2.0;
@@ -886,6 +887,7 @@
        pd->coba = add_colorband(1);
        pd->speed_scale = 1.0f;
        pd->totpoints = 0;
+       pd->coba = add_colorband(1);
        return pd;
 } 
 

Modified: 
branches/sim_physics/source/blender/render/intern/source/pointdensity.c
===================================================================
--- branches/sim_physics/source/blender/render/intern/source/pointdensity.c     
2008-11-09 21:42:30 UTC (rev 17381)
+++ branches/sim_physics/source/blender/render/intern/source/pointdensity.c     
2008-11-10 00:14:35 UTC (rev 17382)
@@ -71,7 +71,7 @@
 /* additional data stored alongside the point density BVH, 
  * accessible by point index number to retrieve other information 
  * such as particle velocity or lifetime */
-static void make_point_data(PointDensity *pd, int total_particles, int 
point_data_used)
+static void alloc_point_data(PointDensity *pd, int total_particles, int 
point_data_used)
 {
        int data_size = 0;
        
@@ -123,7 +123,7 @@
        psys->lattice=psys_get_lattice(ob,psys);
        
        pd->point_tree = BLI_bvhtree_new(total_particles, 0.0, 4, 6);
-       make_point_data(pd, total_particles, data_used);
+       alloc_point_data(pd, total_particles, data_used);
        pd->totpoints = total_particles;
        if (data_used & POINT_DATA_VEL) offset = pd->totpoints*3;
        
@@ -155,7 +155,15 @@
                                pd->point_data[i*3 + 2] = state.vel[2];
                        } 
                        if (data_used & POINT_DATA_LIFE) {
-                               float pa_time = (cfra - pa->time)/pa->lifetime;
+                               float pa_time;
+                               
+                               if (i < psys->totpart) {
+                                       pa_time = (cfra - 
pa->time)/pa->lifetime;
+                               } else {
+                                       ChildParticle *cpa= (psys->child + i) - 
psys->totpart;
+                                       pa_time = psys_get_child_time(psys, 
cpa, cfra);
+                               }
+                               
                                pd->point_data[offset + i] = pa_time;
                        }
                }

Modified: branches/sim_physics/source/blender/src/buttons_shading.c
===================================================================
--- branches/sim_physics/source/blender/src/buttons_shading.c   2008-11-09 
21:42:30 UTC (rev 17381)
+++ branches/sim_physics/source/blender/src/buttons_shading.c   2008-11-10 
00:14:35 UTC (rev 17382)
@@ -840,87 +840,6 @@
        uiDefButF(block, NUMSLI, B_TEXPRV, "W4: ", 10, 10, 150, 19, 
&tex->vn_w4, -2.0, 2.0, 10, 0, "Sets feature weight 4");
 }
 
-static void texture_panel_pointdensity_modify(Tex *tex)
-{
-       uiBlock *block;
-       PointDensity *pd;
-       short yco=PANEL_YMAX, ymid;
-       
-       block= uiNewBlock(&curarea->uiblocks, 
"texture_panel_pointdensity_modify", UI_EMBOSS, UI_HELV, curarea->win);
-       if(uiNewPanel(curarea, block, "Modifiers", "Texture", PANELX, PANELY, 
PANELW, PANELH+20)==0) return;
-       uiSetButLock(tex->id.lib!=0, ERROR_LIBDATA_MESSAGE);
-
-       if(tex->pd==NULL) {
-               tex->pd= BKE_add_pointdensity();
-       }
-       if(!tex->pd) return;
-       
-       if (pd->source == TEX_PD_PSYS) {
-               uiDefBut(block, LABEL, B_NOP, "Color & Intensity By:",
-                       X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
-
-               uiBlockBeginAlign(block);
-               uiDefButS(block, MENU, B_TEXREDR_PRV, "Constant %x0|Particle 
Age %x1|Particle Speed %x2|Velocity -> RGB %x3|",
-                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &pd->color_source, 0.0, 
0.0, 0, 0, "Particle Life: Lifetime mapped as 0.0 - 1.0 intensity, Velocity: 
XYZ velocity mapped as RGB colours");
-               if (ELEM(pd->color_source, TEX_PD_COLOR_PARTSPEED, 
TEX_PD_COLOR_PARTVEL)) {
-                       uiDefButF(block, NUM, B_REDR, "Scale: ",
-                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->speed_scale), 
0.001, 100.0, 10, 2, "Multipler to bring particle speed within an acceptable 
range");
-               }
-               uiBlockEndAlign(block);
-               
-               yco-= 2*BUTH;
-               
-               if (ELEM(pd->color_source, TEX_PD_COLOR_PARTAGE, 
TEX_PD_COLOR_PARTSPEED)) {
-                       rctf rect = {X2CLM1, X2CLM1+BUTW1, yco, yco};
-                       if (tex->pd->coba == NULL) tex->pd->coba = 
add_colorband(1);
-                       draw_colorband_buts_small(block, tex->pd->coba, &rect, 
B_TEXREDR_PRV);
-               } else {
-                       /* spacer */
-                       uiDefBut(block, LABEL, B_NOP, "",
-                               X2CLM2, yco, BUTW2, BUTH*2, 0, 0, 0, 0, 0, "");
-               }
-               
-               if (!ELEM(pd->color_source, TEX_PD_COLOR_PARTSPEED, 
TEX_PD_COLOR_PARTVEL)) yco -= BUTH;
-       }
-       
-       ymid = yco -= YSPACE;
-       
-       uiDefButBitS(block, TOG, TEX_PD_TURBULENCE, B_REDR, "Turbulence",
-               X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->flag), 0, 0, 0, 0, "Add 
directed turbulence to the density estimation");
-       
-       yco -= YSPACE;
-       
-       uiBlockBeginAlign(block);
-       if (pd->flag & TEX_PD_TURBULENCE) {
-               
-               uiDefButF(block, NUM, B_REDR, "Size: ",
-                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->noise_size), 
0.001, 100.0, 10, 2, "Turbulence size");
-               uiDefButS(block, NUM, B_REDR, "Depth: ",
-                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->noise_depth), 
0.0, 100.0, 10, 2, "Turbulence depth");
-               uiDefButF(block, NUM, B_REDR, "Strength: ",
-                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->noise_fac), 
0.001, 100.0, 10, 2, "");
-               
-               uiBlockEndAlign(block);
-               
-               yco = ymid - BUTH - YSPACE;
-
-               uiDefBut(block, LABEL, B_NOP, "Noise Influence:",
-                       X2CLM2, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
-                       
-               if (pd->source == TEX_PD_PSYS) {
-                       uiDefButS(block, MENU, B_REDR, "Noise Influence 
%t|Static %x0|Velocity %x1|Particle Age %x2|Time %x3",
-                               X2CLM2, yco-=BUTH, BUTW2, BUTH, 
&(pd->noise_influence), 0.0, 0.0, 0, 0, "Noise Influence");
-               } else if (pd->source == TEX_PD_OBJECT) {
-                       uiDefButS(block, MENU, B_REDR, "Noise Influence 
%t|Static %x0|Time %x3",
-                               X2CLM2, yco-=BUTH, BUTW2, BUTH, 
&(pd->noise_influence), 0.0, 0.0, 0, 0, "Noise Influence");
-               }
-       } else {
-               uiDefBut(block, LABEL, B_NOP, "",
-                       X2CLM2, yco-=2*BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
-       }
-
-}
-
 static void texture_panel_pointdensity(Tex *tex)
 {
        uiBlock *block;
@@ -999,7 +918,88 @@
 
 }
 
+static void texture_panel_pointdensity_modify(Tex *tex)
+{
+       uiBlock *block;
+       PointDensity *pd;
+       short yco=PANEL_YMAX, ymid;
+       
+       block= uiNewBlock(&curarea->uiblocks, 
"texture_panel_pointdensity_modify", UI_EMBOSS, UI_HELV, curarea->win);
+       if(uiNewPanel(curarea, block, "Modifiers", "Texture", PANELX, PANELY, 
PANELW, PANELH+20)==0) return;
+       uiSetButLock(tex->id.lib!=0, ERROR_LIBDATA_MESSAGE);
 
+       if(tex->pd==NULL) {
+               tex->pd= BKE_add_pointdensity();
+       }
+       if(!tex->pd) return;
+       pd= tex->pd;
+       
+       if (pd->source == TEX_PD_PSYS) {
+               uiDefBut(block, LABEL, B_NOP, "Color & Intensity By:",
+                       X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+
+               uiBlockBeginAlign(block);
+               uiDefButS(block, MENU, B_TEXREDR_PRV, "Constant %x0|Particle 
Age %x1|Particle Speed %x2|Velocity -> RGB %x3|",
+                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &pd->color_source, 0.0, 
0.0, 0, 0, "Particle Life: Lifetime mapped as 0.0 - 1.0 intensity, Velocity: 
XYZ velocity mapped as RGB colours");
+               if (ELEM(pd->color_source, TEX_PD_COLOR_PARTSPEED, 
TEX_PD_COLOR_PARTVEL)) {
+                       uiDefButF(block, NUM, B_REDR, "Scale: ",
+                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->speed_scale), 
0.001, 100.0, 10, 2, "Multipler to bring particle speed within an acceptable 
range");
+               }
+               uiBlockEndAlign(block);
+               
+               yco-= 2*BUTH;
+               
+               
+               if (ELEM(pd->color_source, TEX_PD_COLOR_PARTAGE, 
TEX_PD_COLOR_PARTSPEED)) {
+                       rctf rect = {X2CLM1, X2CLM1+BUTW1, yco, yco};
+                       if (pd->coba == NULL) pd->coba = add_colorband(1);
+                       draw_colorband_buts_small(block, pd->coba, &rect, 
B_TEXREDR_PRV);
+               } else {
+                       uiDefBut(block, LABEL, B_NOP, "",
+                               X2CLM2, yco, BUTW2, BUTH*2, 0, 0, 0, 0, 0, "");
+               }
+               
+               if (!ELEM(pd->color_source, TEX_PD_COLOR_PARTSPEED, 
TEX_PD_COLOR_PARTVEL)) yco -= BUTH;
+       }
+       
+       ymid = yco -= YSPACE;
+       
+       uiDefButBitS(block, TOG, TEX_PD_TURBULENCE, B_REDR, "Turbulence",
+               X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->flag), 0, 0, 0, 0, "Add 
directed turbulence to the density estimation");
+       
+       yco -= YSPACE;
+       
+       uiBlockBeginAlign(block);
+       if (pd->flag & TEX_PD_TURBULENCE) {
+               
+               uiDefButF(block, NUM, B_REDR, "Size: ",
+                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->noise_size), 
0.001, 100.0, 10, 2, "Turbulence size");
+               uiDefButS(block, NUM, B_REDR, "Depth: ",
+                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->noise_depth), 
0.0, 100.0, 10, 2, "Turbulence depth");
+               uiDefButF(block, NUM, B_REDR, "Strength: ",
+                       X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->noise_fac), 
0.001, 100.0, 10, 2, "");
+               
+               uiBlockEndAlign(block);
+               
+               yco = ymid - BUTH - YSPACE;
+
+               uiDefBut(block, LABEL, B_NOP, "Noise Influence:",
+                       X2CLM2, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+                       
+               if (pd->source == TEX_PD_PSYS) {
+                       uiDefButS(block, MENU, B_REDR, "Noise Influence 
%t|Static %x0|Velocity %x1|Particle Age %x2|Time %x3",
+                               X2CLM2, yco-=BUTH, BUTW2, BUTH, 
&(pd->noise_influence), 0.0, 0.0, 0, 0, "Noise Influence");
+               } else if (pd->source == TEX_PD_OBJECT) {
+                       uiDefButS(block, MENU, B_REDR, "Noise Influence 
%t|Static %x0|Time %x3",
+                               X2CLM2, yco-=BUTH, BUTW2, BUTH, 
&(pd->noise_influence), 0.0, 0.0, 0, 0, "Noise Influence");
+               }
+       } else {
+               uiDefBut(block, LABEL, B_NOP, "",
+                       X2CLM2, yco-=2*BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+       }
+
+}
+
 static char *layer_menu(RenderResult *rr, short *curlay)
 {
        RenderLayer *rl;


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to