2.5:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 25 Jul 2009 22:20:26 +0000 (22:20 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 25 Jul 2009 22:20:26 +0000 (22:20 +0000)
* Fix crash entering particle mode, and particles not showing.
  Janne, please check the changes I made in psys_cache_paths,
  I'm not confident they are correct.
* Fix some warnings

source/blender/blenkernel/intern/boids.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenlib/BLI_kdtree.h
source/blender/editors/space_view3d/space_view3d.c

index 931ad0b3043959399a0c19ab368b33a46aa514e0..d8926fc57536a4c47b4a16d290bad9d2315a72ca 100644 (file)
@@ -399,7 +399,7 @@ static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
        KDTreeNearest ptn[11];
        float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f};
        int neighbors = BLI_kdtree_find_n_nearest(bbd->psys->tree, 11, pa->state.co, pa->prev_state.ave, ptn);
-       int n, nearest = 1;
+       int n;
        int ret = 0;
 
        if(neighbors > 1) {
@@ -898,8 +898,6 @@ static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa) {
 /* determines the velocity the boid wants to have */
 void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
 {
-       ParticleData *pars=bbd->psys->particles;
-       ParticleEffectorCache *ec=0;
        BoidRule *rule;
        BoidSettings *boids = bbd->part->boids;
        BoidValues val;
@@ -1259,7 +1257,6 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                }
                case eBoidMode_Falling:
                {
-                       float zvec[3] = {0.0f,0.0f,1.0f};
                        float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f};
 
                        /* gather apparent gravity to r_ve */
@@ -1523,4 +1520,5 @@ BoidState *boid_get_current_state(BoidSettings *boids)
        }
 
        return state;
-}
\ No newline at end of file
+}
+
index 6e8f9ee213cfa5dc771526bc08096d435305354a..e4f8a484061057e91851ae8ccc1befed1203bb2d 100644 (file)
@@ -2568,8 +2568,7 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
        ParticleSettings *part = psys->part;
        
        ParticleData *pa;
-       ParticleKey result, *kkey[2] = {NULL, NULL};
-       HairKey *hkey[2] = {NULL, NULL};
+       ParticleKey result;
 
        ParticleEdit *edit = 0;
        ParticleEditKey *ekey = 0;
@@ -2709,6 +2708,10 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
 
                        dietime = birthtime + pa_length * (dietime - birthtime);
                }
+               else
+                       /* XXX brecht: don't know if this code from 2.4 is correct
+                        * still, but makes hair appear again in particle mode */
+                       dietime= pind.hkey[0][pa->totkey-1].time;
 
                /*--interpolate actual path from data points--*/
                for(k=0, ca=cache[i]; k<=steps; k++, ca++){
@@ -2731,14 +2734,14 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
                        if(edit){
                                if(pset->brushtype==PE_BRUSH_WEIGHT){
                                        if(k==steps)
-                                               VecLerpf(ca->col, nosel_col, sel_col, hkey[0]->weight);
+                                               VecLerpf(ca->col, nosel_col, sel_col, pind.hkey[0]->weight);
                                        else
                                                VecLerpf(ca->col, nosel_col, sel_col,
-                                               (1.0f - keytime) * hkey[0]->weight + keytime * hkey[1]->weight);
+                                               (1.0f - keytime) * pind.hkey[0]->weight + keytime * pind.hkey[1]->weight);
                                }
                                else{
-                                       if((ekey + (hkey[0] - pa->hair))->flag & PEK_SELECT){
-                                               if((ekey + (hkey[1] - pa->hair))->flag & PEK_SELECT){
+                                       if((ekey + (pind.hkey[0] - pa->hair))->flag & PEK_SELECT){
+                                               if((ekey + (pind.hkey[1] - pa->hair))->flag & PEK_SELECT){
                                                        VECCOPY(ca->col, sel_col);
                                                }
                                                else{
@@ -2746,7 +2749,7 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
                                                }
                                        }
                                        else{
-                                               if((ekey + (hkey[1] - pa->hair))->flag & PEK_SELECT){
+                                               if((ekey + (pind.hkey[1] - pa->hair))->flag & PEK_SELECT){
                                                        VecLerpf(ca->col, nosel_col, sel_col, keytime);
                                                }
                                                else{
@@ -3627,8 +3630,6 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
        ParticleData *pa;
        ChildParticle *cpa;
        ParticleTexture ptex;
-       ParticleKey *kkey[2] = {NULL, NULL};
-       HairKey *hkey[2] = {NULL, NULL};
        ParticleKey *par=0, keys[4], tstate;
        ParticleThreadContext ctx; /* fake thread context for child modifiers */
        ParticleInterpolationData pind;
index 43174343302fb407fe2bc5c70e0dcce438219940..b5d58e9db8c69c4412bd2a03acd7c2fd3384a699 100644 (file)
@@ -2065,7 +2065,6 @@ void psys_count_keyed_targets(Object *ob, ParticleSystem *psys)
 {
        ParticleSystem *kpsys;
        ParticleTarget *pt = psys->targets.first;
-       int psys_num = BLI_findindex(&ob->particlesystem, psys);
        int keys_valid = 1;
        psys->totkeyed = 0;
 
@@ -2087,7 +2086,6 @@ void psys_count_keyed_targets(Object *ob, ParticleSystem *psys)
 
 static void set_keyed_keys(Scene *scene, Object *ob, ParticleSystem *psys)
 {
-       Object *kob = ob;
        ParticleSystem *kpsys = psys;
        ParticleTarget *pt;
        ParticleData *pa;
@@ -2143,7 +2141,7 @@ static void set_keyed_keys(Scene *scene, Object *ob, ParticleSystem *psys)
                if(psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f)
                        k++;
 
-               pt = (pt->next && pt->next->flag & PTARGET_VALID) ? pt = pt->next : psys->targets.first;
+               pt = (pt->next && pt->next->flag & PTARGET_VALID)? pt->next : psys->targets.first;
        }
 
        psys->flag |= PSYS_KEYED;
index 585107b0c4a684ba8c2dd3a900495b34ce9faac2..3b1947cf0c924f7b8600c358cfe797fdecab7b27 100644 (file)
@@ -52,7 +52,7 @@ void BLI_kdtree_balance(KDTree *tree);
 
 /* Find nearest returns index, and -1 if no node is found.
  * Find n nearest returns number of points found, with results in nearest.
-/* Normal is optional, but if given will limit results to points in normal direction from co. */
+ * Normal is optional, but if given will limit results to points in normal direction from co. */
 int    BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest *nearest);
 int    BLI_kdtree_find_n_nearest(KDTree *tree, int n, float *co, float *nor, KDTreeNearest *nearest);
 
index 2b162f9574d36090b602cec40acdb66762df45cd..a99c227ae1f937033f0a6e00ceb508f0ff92da9d 100644 (file)
@@ -280,7 +280,7 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
        
        /* copy last mode, then we can re-init the region maps */
        rv3d->lastmode= stype;
-       
+
        keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0);
        if(ELEM(stype, 0, NS_MODE_OBJECT))
                WM_event_add_keymap_handler(&ar->handlers, keymap);