From 52b7b978e319d7cef224601b57350cc63a99faaa Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 11 Apr 2005 17:55:20 +0000 Subject: [PATCH] Bug fix #2411 (Looks like big commit, but is mostly just change of API call!) Particle emittors now can be parented to an armature Bone, and give the correct path for each particle. Note that this doesn't work for deform! And, for each particle the entire armature is evaluated, all actions and NLA strips. It used to work a little while BTW, but the code just called ALL armatures and made ALL deforms again. Was quite slow... thats why the API call change: do_all_actions() now accepts Object * to only do that one. With a NULL it now does all still. Will disapppear in recode of course... --- source/blender/blenkernel/BKE_action.h | 3 ++- source/blender/blenkernel/intern/action.c | 16 ++++++++++------ source/blender/blenkernel/intern/effect.c | 11 ++++++++++- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/render/intern/source/initrender.c | 2 +- .../renderconverter/intern/convertBlenderScene.c | 4 ++-- source/blender/src/drawview.c | 6 +++--- source/blender/src/editaction.c | 6 +++--- source/blender/src/editipo.c | 4 ++-- source/blender/src/headerbuttons.c | 4 ++-- source/blender/src/toets.c | 2 +- 11 files changed, 37 insertions(+), 23 deletions(-) diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 5b4a0fa6c8e..2f3af8ca103 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -86,7 +86,8 @@ void free_action(struct bAction * id); void make_local_action(struct bAction *act); -void do_all_actions(void); +/* if NULL it does all, otherwise only from Object */ +void do_all_actions(struct Object *); /** * Return a pointer to the pose channel of the given name diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 27611203471..4b1f47707af 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -430,7 +430,7 @@ void get_pose_from_action(bPose **pose, bAction *act, float ctime) } } -void do_all_actions() +void do_all_actions(Object *only_this) { Base *base; bPose *apose=NULL; @@ -449,7 +449,8 @@ void do_all_actions() while(base) { - ob = base->object; + if(only_this) ob= only_this; + else ob = base->object; /* Retrieve data from the NLA */ if(ob->type==OB_ARMATURE){ @@ -471,11 +472,11 @@ void do_all_actions() copy_pose(&tpose, ob->pose, 1); rest_pose(apose, 1); - if (base->object->nlastrips.first){ - rest_pose(base->object->pose, 0); + if (ob->nlastrips.first){ + rest_pose(ob->pose, 0); } - for (strip=base->object->nlastrips.first; strip; strip=strip->next){ + for (strip=ob->nlastrips.first; strip; strip=strip->next){ doit = 0; if (strip->act){ @@ -585,7 +586,7 @@ void do_all_actions() /* Do local action (always overrides the nla actions) */ /* At the moment, only constraint ipos on the local action have any effect */ - if(base->object->action) { + if(ob->action) { get_pose_from_action (&ob->pose, ob->action, bsystem_time(ob, 0, (float) G.scene->r.cfra, 0.0)); do_pose_constraint_channels(ob->pose, ob->action, bsystem_time(ob, 0, (float) G.scene->r.cfra, 0.0)); doit = 1; @@ -595,6 +596,9 @@ void do_all_actions() apply_pose_armature(get_armature(ob), ob->pose, 1); } + + if(only_this) break; + base= base->next; if(base==0 && set==0 && G.scene->set) { set= 1; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 2b86816bb67..d76647ab608 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1300,6 +1300,10 @@ void build_particle_system(Object *ob) /* do_ob_ipo(par); */ par->ctime= -1234567.0; do_ob_key(par); + if(par->type==OB_ARMATURE) { + do_all_actions(NULL); // only does this object actions + clear_object_constraint_status(par); // mysterious call, otherwise do_actions doesnt work??? + } par= par->parent; } if(ma) do_mat_ipo(ma); @@ -1310,7 +1314,7 @@ void build_particle_system(Object *ob) } } /* get coordinates */ - if(paf->flag & PAF_FACE) give_mesh_mvert(me, dlm, a, co, no,paf->seed); + if(paf->flag & PAF_FACE) give_mesh_mvert(me, dlm, a, co, no, paf->seed); else { mvert= me->mvert + (a % me->totvert); VECCOPY(co, mvert->co); @@ -1375,6 +1379,11 @@ void build_particle_system(Object *ob) popfirst(par); /* do not do ob->ipo: keep insertkey */ do_ob_key(par); + + if(par->type==OB_ARMATURE) { + do_all_actions(NULL); // only does this object actions + clear_object_constraint_status(par); // mysterious call, otherwise do_actions doesnt work??? + } par= par->parent; } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 7839609efbc..f5916fb17b0 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -337,7 +337,7 @@ void set_scene_bg(Scene *sce) BPY_do_all_scripts(SCRIPT_FRAMECHANGED); do_all_keys(); #ifdef __NLA - do_all_actions(); + do_all_actions(NULL); rebuild_all_armature_displists(); #endif do_all_ikas(); diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index ea13922f148..c4668a9f816 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -1477,7 +1477,7 @@ void RE_animrender(struct View3D *ogl_render_view3d) if(R.r.mode & (R_FIELDS|R_MBLUR)) { do_all_ipos(); do_all_keys(); - do_all_actions(); + do_all_actions(NULL); do_all_ikas(); } diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c index 6c73044b150..eb69ab601c3 100644 --- a/source/blender/renderconverter/intern/convertBlenderScene.c +++ b/source/blender/renderconverter/intern/convertBlenderScene.c @@ -2920,10 +2920,10 @@ void RE_rotateBlenderScene(void) BPY_do_all_scripts(SCRIPT_FRAMECHANGED); do_all_keys(); #ifdef __NLA - do_all_actions(); + do_all_actions(NULL); rebuild_all_armature_displists(); /* so nice, better do it twice */ - do_all_actions(); + do_all_actions(NULL); rebuild_all_armature_displists(); #endif do_all_ikas(); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 2b6e3ea397b..65f1de263c5 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -2074,7 +2074,7 @@ void drawview3d_render(struct View3D *v3d) do_all_ipos(); BPY_do_all_scripts(SCRIPT_FRAMECHANGED); do_all_keys(); - do_all_actions(); + do_all_actions(NULL); do_all_ikas(); test_all_displists(); @@ -2305,7 +2305,7 @@ void inner_play_anim_loop(int init, int mode) //do_all_ipos(); //BPY_do_all_scripts(SCRIPT_FRAMECHANGED); //do_all_keys(); - //do_all_actions(); + //do_all_actions(NULL); //do_all_ikas(); update_for_newframe_muted(); @@ -2410,7 +2410,7 @@ int play_anim(int mode) clear_all_constraints(); do_all_ipos(); do_all_keys(); - do_all_actions(); + do_all_actions(NULL); /* set all objects on current frame... test_all_displists() needs it */ base= G.scene->base.first; diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index f1c4a31eaf6..8c908c163e0 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -1261,7 +1261,7 @@ void transform_actionchannel_keys(char mode) } if (G.saction->lock){ - do_all_actions(); + do_all_actions(NULL); force_draw_all(0); } else { @@ -1277,7 +1277,7 @@ void transform_actionchannel_keys(char mode) /* Update the curve */ /* Depending on the lock status, draw necessary views */ - do_all_actions(); + do_all_actions(NULL); remake_action_ipos(act); if(cancel==0) BIF_undo_push("Transform Action"); @@ -1444,7 +1444,7 @@ void transform_meshchannel_keys(char mode, Key *key) * future */ - do_all_actions(); + do_all_actions(NULL); allqueue (REDRAWVIEW3D, 0); allqueue (REDRAWACTION, 0); allqueue (REDRAWIPO, 0); diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index 8924cf6092d..19c18f63fa5 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -483,7 +483,7 @@ void editipo_changed(SpaceIpo *si, int doredraw) } else if(si->blocktype==ID_SEQ) clear_last_seq(); else if(si->blocktype==ID_AC){ - do_all_actions(); + do_all_actions(NULL); allqueue(REDRAWACTION, 0); allqueue(REDRAWNLA, 0); } @@ -4837,7 +4837,7 @@ void transform_ipo(int mode) force_draw_plus(SPACE_VIEW3D, 0); } else if(G.sipo->blocktype==ID_AC) { - do_all_actions(); + do_all_actions(NULL); force_draw_all(0); } else if(G.sipo->blocktype==ID_OB) { diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index 0c0483ecb52..cad0570fa8a 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -509,10 +509,10 @@ static void do_update_for_newframe(int mute) clear_all_constraints(); do_all_keys(); - do_all_actions(); + do_all_actions(NULL); rebuild_all_armature_displists(); /* so nice, better do it twice */ - do_all_actions(); + do_all_actions(NULL); rebuild_all_armature_displists(); do_all_ikas(); diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c index f5d0d7a98f9..4e940b33570 100644 --- a/source/blender/src/toets.c +++ b/source/blender/src/toets.c @@ -409,7 +409,7 @@ void persptoetsen(unsigned short event) countall(); do_all_ipos(); do_all_keys(); - do_all_actions(); + do_all_actions(NULL); do_all_ikas(); test_all_displists();