"From particles" children are again allowed for non-hair/keyed particles, although...
authorJanne Karhu <jhkarh@gmail.com>
Sun, 17 Feb 2008 18:33:20 +0000 (18:33 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Sun, 17 Feb 2008 18:33:20 +0000 (18:33 +0000)
source/blender/blenkernel/intern/particle.c
source/blender/src/buttons_object.c

index 47cd13cc79ec654174d17c3c7d0b109872cf2f25..5e45dcaa761fed69a65d09201bc788631c316cce 100644 (file)
@@ -465,6 +465,8 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
                return;
        if(psys->renderdata)
                return;
+       if(psys->part->draw_as!=PART_DRAW_PATH)
+               return;
 
        data= MEM_callocN(sizeof(ParticleRenderData), "ParticleRenderData");
 
@@ -505,6 +507,8 @@ void psys_render_restore(Object *ob, ParticleSystem *psys)
        data= psys->renderdata;
        if(!data)
                return;
+       if(psys->part->draw_as!=PART_DRAW_PATH)
+               return;
        
        if(data->elems)
                MEM_freeN(data->elems);
@@ -3580,32 +3584,34 @@ int psys_get_particle_state(Object *ob, ParticleSystem *psys, int p, ParticleKey
                return 1;
        }
        else{
-               //if(psys->totchild && p>=psys->totpart){
-               //      ChildParticle *cpa=psys->child+p-psys->totpart;
-               //      ParticleKey *key1, skey;
-               //      float t=(cfra-pa->time)/pa->lifetime, clump;
-
-               //      pa=psys->particles+cpa->parent;
-
-               //      if(pa->alive==PARS_DEAD && part->flag&PART_STICKY && pa->flag&PARS_STICKY && pa->stick_ob){
-               //              key1=&skey;
-               //              copy_particle_key(key1,&pa->state,0);
-               //              key_from_object(pa->stick_ob,key1);
-               //      }
-               //      else{
-               //              key1=&pa->state;
-               //      }
-               //      
-               //      offset_child(cpa, key1, state, part->childflat, part->childrad);
-               //      
-               //      CLAMP(t,0.0,1.0);
-               //      if(part->kink)                  /* TODO: part->kink_freq*pa_kink */
-               //              do_prekink(state,key1,t,part->kink_freq,part->kink_shape,part->kink_amp,part->kink,part->kink_axis,ob->obmat);
-               //      
-               //      /* TODO: pa_clump vgroup */
-               //      do_clump(state,key1,t,part->clumpfac,part->clumppow,0);
-               //}
-               //else{
+               if(between)
+                       return 0; /* currently not supported */
+               else if(psys->totchild && p>=psys->totpart){
+                       ChildParticle *cpa=psys->child+p-psys->totpart;
+                       ParticleKey *key1, skey;
+                       float t = (cfra - pa->time + pa->loop * pa->lifetime) / pa->lifetime, clump;
+
+                       pa = psys->particles + cpa->parent;
+
+                       if(pa->alive==PARS_DEAD && part->flag&PART_STICKY && pa->flag&PARS_STICKY && pa->stick_ob) {
+                               key1 = &skey;
+                               copy_particle_key(key1,&pa->state,0);
+                               key_from_object(pa->stick_ob,key1);
+                       }
+                       else {
+                               key1=&pa->state;
+                       }
+                       
+                       offset_child(cpa, key1, state, part->childflat, part->childrad);
+                       
+                       CLAMP(t,0.0,1.0);
+                       if(part->kink)                  /* TODO: part->kink_freq*pa_kink */
+                               do_prekink(state,key1,key1->rot,t,part->kink_freq,part->kink_shape,part->kink_amp,part->kink,part->kink_axis,ob->obmat);
+                       
+                       /* TODO: pa_clump vgroup */
+                       do_clump(state,key1,t,part->clumpfac,part->clumppow,1.0);
+               }
+               else{
                        if (pa) { /* TODO PARTICLE - should this ever be NULL? - Campbell */
                                copy_particle_key(state,&pa->state,0);
 
@@ -3616,7 +3622,7 @@ int psys_get_particle_state(Object *ob, ParticleSystem *psys, int p, ParticleKey
                                if(psys->lattice)
                                        calc_latt_deform(state->co,1.0f);
                        }
-               //}
+               }
                
                return 1;
        }
index 40172e457e22da3f5fe8d81b92a05f93296363ae..010d9bf4f32b1219c6e65941c9c91c643a35b5b2 100644 (file)
@@ -3983,7 +3983,7 @@ static void object_panel_particle_children(Object *ob)
 
        if(part->childtype==0) return;
 
-       if((psys->flag&(PSYS_HAIR_DONE|PSYS_KEYED))==0) {
+       if(part->childtype==PART_CHILD_FACES && (psys->flag&(PSYS_HAIR_DONE|PSYS_KEYED))==0) {
                uiDefBut(block, LABEL, 0, "Hair or keyed",      butx,(buty-=2*buth),butw,buth, NULL, 0.0, 0, 0, 0, "");
                uiDefBut(block, LABEL, 0, "particles needed!",  butx,(buty-=2*buth),butw,buth, NULL, 0.0, 0, 0, 0, "");
                return;
@@ -3994,7 +3994,9 @@ static void object_panel_particle_children(Object *ob)
        buty -= buth/2;
        
        uiDefButI(block, NUM, B_PART_ALLOC_CHILD, "Amount:", butx,(buty-=buth),butw,buth, &part->child_nbr, 0.0, MAX_PART_CHILDREN, 0, 0, "Amount of children/parent");
-       uiDefButI(block, NUM, B_DIFF, "Render Amount:", butx,(buty-=buth),butw,buth, &part->ren_child_nbr, 0.0, MAX_PART_CHILDREN, 0, 0, "Amount of children/parent for rendering");
+       if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED))
+               uiDefButI(block, NUM, B_DIFF, "Render Amount:", butx,(buty-=buth),butw,buth, &part->ren_child_nbr, 0.0, MAX_PART_CHILDREN, 0, 0, "Amount of children/parent for rendering");
+
        if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES) {
                uiDefButF(block, NUMSLI, B_PART_DISTR_CHILD, "VParents:",               butx,(buty-=buth),butw,buth, &part->parents, 0.0, 1.0, 1, 3, "Relative amount of virtual parents");
                }
@@ -4015,9 +4017,11 @@ static void object_panel_particle_children(Object *ob)
        buty -= buth/2;
 
        uiBlockBeginAlign(block);
-       uiDefButF(block, NUM, B_PART_REDRAW, "Size:",           butx,(buty-=buth),butw/2,buth, &part->childsize, 0.01, 100, 10, 1, "A multiplier for the child particle size");
-       uiDefButF(block, NUM, B_PART_REDRAW, "Rand:",           butx+butw/2,buty,butw/2,buth, &part->childrandsize, 0.0, 1.0, 10, 1, "Random variation to the size of the child particles");
-       if(part->childtype==PART_CHILD_FACES) {
+       if(part->draw_as != PART_DRAW_PATH) {
+               uiDefButF(block, NUM, B_PART_REDRAW, "Size:",           butx,(buty-=buth),butw/2,buth, &part->childsize, 0.01, 100, 10, 1, "A multiplier for the child particle size");
+               uiDefButF(block, NUM, B_PART_REDRAW, "Rand:",           butx+butw/2,buty,butw/2,buth, &part->childrandsize, 0.0, 1.0, 10, 1, "Random variation to the size of the child particles");
+       }
+       if(part->childtype == PART_CHILD_FACES) {
                uiDefButF(block, NUM, B_PART_REDRAW, "Spread:",butx,(buty-=buth),butw/2,buth, &part->childspread, -1.0, 1.0, 10, 1, "Spread children from the faces");
                uiDefButBitI(block, TOG, PART_CHILD_SEAMS, B_PART_DISTR_CHILD, "Use Seams",      butx+butw/2,buty,butw/2,buth, &part->flag, 0, 0, 0, 0, "Use seams to determine parents");
        }
@@ -4026,9 +4030,12 @@ static void object_panel_particle_children(Object *ob)
        butx=160;
        buty=180;
 
-       uiDefButBitS(block, TOG, 1, B_PART_REDRAW, "Kink/Branch",        butx,(buty-=buth),butw,buth, &kink_ui, 0, 0, 0, 0, "Show kink and branch options");
+       if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED))
+               uiDefButBitS(block, TOG, 1, B_PART_REDRAW, "Kink/Branch",        butx,(buty-=buth),butw,buth, &kink_ui, 0, 0, 0, 0, "Show kink and branch options");
+       else
+               buty-=buth;
 
-       if(kink_ui) {
+       if(kink_ui || (psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED)) == 0) {
                buty -= buth/2;
 
                /* kink */
@@ -4046,7 +4053,7 @@ static void object_panel_particle_children(Object *ob)
                }
                uiBlockEndAlign(block);
 
-               if(part->childtype==PART_CHILD_PARTICLES) {
+               if(part->childtype==PART_CHILD_PARTICLES && psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED)) {
                        if(part->flag & PART_BRANCHING) {
                                uiDefButBitI(block, TOG, PART_BRANCHING, B_PART_RECALC_CHILD, "Branching",      butx,(buty-=2*buth),butw,buth, &part->flag, 0, 0, 0, 0, "Branch child paths from eachother");
                                uiDefButBitI(block, TOG, PART_ANIM_BRANCHING, B_PART_RECALC_CHILD, "Animated",  butx,(buty-=buth),butw/2,buth, &part->flag, 0, 0, 0, 0, "Animate branching");
@@ -4323,7 +4330,7 @@ static void object_panel_particle_visual(Object *ob)
                                }
                        }
                        else {
-                               uiDefBut(block, LABEL, 0, "Baked or keyed",     butx,(buty-=2*buth),butw,buth, NULL, 0.0, 0, 0, 0, "");
+                               uiDefBut(block, LABEL, 0, "Hair or keyed",      butx,(buty-=2*buth),butw,buth, NULL, 0.0, 0, 0, 0, "");
                                uiDefBut(block, LABEL, 0, "particles needed!",  butx,(buty-=2*buth),butw,buth, NULL, 0.0, 0, 0, 0, "");
                        }
                        break;