From 73b7d9f80b4b6e40778c7dfdca3801738ba3be59 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 3 Dec 2004 20:22:37 +0000 Subject: [PATCH] Fixes in static particles. Result of going over details with Chris Burt, thanks for that! - static particles that are being deformed (curve/lattice/armature) now display correct in 3d window. Only updates when particle system updates normally though - static particles without "animate" set didn't deform even - static particles used as duplicators had errors with extreme low "life" value for particles. Also, still cases could happen with unrotated duplis at the end of a static particle line (with Vect option) - Added tooltip for "Step" option in particles --- source/blender/blenkernel/intern/anim.c | 6 +- source/blender/blenkernel/intern/effect.c | 67 +++++++++++-------- .../intern/convertBlenderScene.c | 5 +- source/blender/src/buttons_object.c | 3 +- 4 files changed, 46 insertions(+), 35 deletions(-) diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 4a386a737c0..f92294df3d1 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -459,7 +459,7 @@ void particle_duplilist(Scene *sce, Object *par, PartEff *paf) float mtime; where_is_particle(paf, pa, pa->time, vec1); - mtime= pa->time+pa->lifetime+paf->staticstep-1; + mtime= pa->time+pa->lifetime; for(ctime= pa->time; ctimestaticstep) { newob= new_dupli_object(&duplilist, ob, par); @@ -470,11 +470,11 @@ void particle_duplilist(Scene *sce, Object *par, PartEff *paf) /* to give ipos in object correct offset */ where_is_object_time(newob, ctime-pa->time); - where_is_particle(paf, pa, ctime-0.5, vec); // makes sure there's always a vec + where_is_particle(paf, pa, ctime, vec); // makes sure there's always a vec Mat4MulVecfl(par->obmat, vec); if(paf->stype==PAF_VECT) { - where_is_particle(paf, pa, ctime+0.5, vec1); // makes sure there's always a vec + where_is_particle(paf, pa, ctime+1.0, vec1); // makes sure there's always a vec Mat4MulVecfl(par->obmat, vec1); VecSubf(vec1, vec1, vec); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 321dd50d0c8..ed2936af034 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -53,22 +53,23 @@ #include "BLI_arithb.h" #include "BLI_rand.h" -#include "BKE_utildefines.h" +#include "BKE_action.h" #include "BKE_bad_level_calls.h" -#include "BKE_global.h" -#include "BKE_material.h" -#include "BKE_effect.h" -#include "BKE_key.h" -#include "BKE_ipo.h" -#include "BKE_screen.h" -#include "BKE_main.h" #include "BKE_blender.h" -#include "BKE_object.h" +#include "BKE_constraint.h" +#include "BKE_deform.h" #include "BKE_displist.h" +#include "BKE_effect.h" +#include "BKE_global.h" +#include "BKE_ipo.h" +#include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_mesh.h" -#include "BKE_action.h" -#include "BKE_constraint.h" +#include "BKE_material.h" +#include "BKE_main.h" +#include "BKE_object.h" +#include "BKE_screen.h" +#include "BKE_utildefines.h" #ifdef HAVE_CONFIG_H #include @@ -286,6 +287,7 @@ void where_is_particle(PartEff *paf, Particle *pa, float ctime, float *vec) /* first find the first particlekey */ a= (int)((paf->totkey-1)*(ctime-pa->time)/pa->lifetime); if(a>=paf->totkey) a= paf->totkey-1; + else if(a<0) a= 0; pa+= a; @@ -1132,7 +1134,7 @@ void build_particle_system(Object *ob) int armature_parent; float framelenont, ftime, dtime, force[3], imat[3][3], vec[3]; float fac, prevobmat[4][4], sfraont, co[3]; - int deform=0, a, b, c, cur, cfraont, cfralast, totpart; + int deform=0, a, cur, cfraont, cfralast, totpart; short no[3]; if(ob->type!=OB_MESH) return; @@ -1150,6 +1152,9 @@ void build_particle_system(Object *ob) waitcursor(1); disable_speed_curve(1); + + /* warning! we cannot call this when modifier is active! */ + mesh_modifier(ob, 's'); /* generate all particles */ if(paf->keys) MEM_freeN(paf->keys); @@ -1235,24 +1240,29 @@ void build_particle_system(Object *ob) /* init */ give_mesh_mvert(me, totpart, co, no, paf->seed); - - printf("\n"); - printf("Calculating particles......... \n"); - + + if(G.f & G_DEBUG) { + printf("\n"); + printf("Calculating particles......... \n"); + } for(a=0; atime= ftime; - c = totpart/100; - if (c==0){ - c = 1; - } + if(G.f & G_DEBUG) { + int b, c; + + c = totpart/100; + if (c==0){ + c = 1; + } - b=(a%c); - if (b==0) { - printf("\r Particle: %d / %d ", a, totpart); - fflush(stdout); + b=(a%c); + if (b==0) { + printf("\r Particle: %d / %d ", a, totpart); + fflush(stdout); + } } /* set ob at correct time */ @@ -1334,9 +1344,10 @@ void build_particle_system(Object *ob) make_particle_keys(0, a, paf, pa, force, deform, mtexmove, ob->lay); } - printf("\r Particle: %d / %d \n", totpart, totpart); - fflush(stdout); - + if(G.f & G_DEBUG) { + printf("\r Particle: %d / %d \n", totpart, totpart); + fflush(stdout); + } if(deform) end_latt_deform(); /* restore */ @@ -1373,6 +1384,8 @@ void build_particle_system(Object *ob) if(ma) do_mat_ipo(ma); // set back on current time disable_speed_curve(0); + + mesh_modifier(ob, 'e'); waitcursor(0); diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c index f612a29e93a..5727c967ff0 100644 --- a/source/blender/renderconverter/intern/convertBlenderScene.c +++ b/source/blender/renderconverter/intern/convertBlenderScene.c @@ -1285,12 +1285,9 @@ static void init_render_mesh(Object *ob) paf = give_parteff(ob); if(paf) { - mesh_modifier(ob, 's'); - + /* warning; build_particle_system does modifier calls itself */ if(paf->flag & PAF_STATIC) render_static_particle_system(ob, paf); else render_particle_system(ob, paf); - - mesh_modifier(ob, 'e'); // end return; } diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index f3150199b73..89f25888d13 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1522,6 +1522,7 @@ void object_panel_effects(Object *ob) paf= (PartEff *)eff; uiDefBut(block, BUT, B_RECALCAL, "RecalcAll", 741,187,67,27, 0, 0, 0, 0, 0, "Update the particle system"); + uiBlockBeginAlign(block); uiDefButS(block, TOG|BIT|2, B_CALCEFFECT, "Static", 825,187,67,27, &paf->flag, 0, 0, 0, 0, "Make static particles (deform only works with SubSurf)"); if(paf->flag & PAF_STATIC) uiDefButS(block, TOG|BIT|4, B_DIFF, "Animated",825,167,67,20, &paf->flag, 0, 0, 0, 0, "Static particles are recalculated each rendered frame"); @@ -1529,7 +1530,7 @@ void object_panel_effects(Object *ob) uiBlockBeginAlign(block); uiDefButI(block, NUM, B_CALCEFFECT, "Tot:", 550,146,91,20, &paf->totpart, 1.0, 100000.0, 0, 0, "Set the total number of particles"); if(paf->flag & PAF_STATIC) { - uiDefButS(block, NUM, REDRAWVIEW3D, "Step:", 644,146,84+97,20, &paf->staticstep, 1.0, 100.0, 10, 0, ""); + uiDefButS(block, NUM, REDRAWVIEW3D, "Step:", 644,146,84+97,20, &paf->staticstep, 1.0, 100.0, 10, 0, "For static duplicators, the Step value skips particles"); } else { uiDefButF(block, NUM, B_CALCEFFECT, "Sta:", 644,146,84,20, &paf->sta, -250.0, 9000.0, 100, 0, "Specify the startframe");