mat4_to_compatible_eulO should be able to do this (rather then own function continuous_rotation).
On Thu, Mar 24, 2011 at 5:15 PM, Janne Karhu <jhk...@gmail.com> wrote: > Revision: 35755 > > http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35755 > Author: jhk > Date: 2011-03-24 17:15:43 +0000 (Thu, 24 Mar 2011) > Log Message: > ----------- > Further fix for parented fluidsim objects > * The rotation values determined from ob->obmat have to be continuous as > fluidsim interpolates between these values internally. > > Modified Paths: > -------------- > trunk/blender/source/blender/editors/physics/physics_fluid.c > > Modified: trunk/blender/source/blender/editors/physics/physics_fluid.c > =================================================================== > --- trunk/blender/source/blender/editors/physics/physics_fluid.c > 2011-03-24 14:31:58 UTC (rev 35754) > +++ trunk/blender/source/blender/editors/physics/physics_fluid.c > 2011-03-24 17:15:43 UTC (rev 35755) > @@ -349,6 +349,16 @@ > } > } > > +static void continuous_rotation(float *rot, const float *old_rot) > +{ > + *rot += (int)(*old_rot/360.f)*360.f; > + > + if(*old_rot - *rot > 180.f) > + *rot += 360.f; > + else if(*old_rot - *rot < -180.f) > + *rot -= 360.f; > +} > + > static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), > FluidsimSettings *domainSettings, FluidAnimChannels *channels, ListBase > *fobjects) > { > Scene *scene = CTX_data_scene(C); > @@ -451,8 +461,14 @@ > /* init euler rotation values and convert to elbeem > format */ > /* get the rotation from ob->obmat rather than ob->rot > to account for parent animations */ > mat4_to_eul(rot_d, ob->obmat); > - mul_v3_fl(rot_d, 180.f/M_PI); > - sub_v3_v3v3(rot_d, rot_360, rot_d); > + mul_v3_fl(rot_d, -180.f/M_PI); > + if(i) { > + /* the rotation values have to be continuous, > so compare with previous rotation and adjust accordingly */ > + /* note: the unfortunate side effect of this > is that it filters out rotations of over 180 degrees/frame */ > + continuous_rotation(rot_d, fobj->Rotation + > 4*(i-1)); > + continuous_rotation(rot_d+1, fobj->Rotation + > 4*(i-1)+1); > + continuous_rotation(rot_d+2, fobj->Rotation + > 4*(i-1)+2); > + } > > set_channel(fobj->Translation, timeAtFrame, ob->loc, > i, CHANNEL_VEC); > set_channel(fobj->Rotation, timeAtFrame, rot_d, i, > CHANNEL_VEC); > > _______________________________________________ > Bf-blender-cvs mailing list > bf-blender-...@blender.org > http://lists.blender.org/mailman/listinfo/bf-blender-cvs > -- - Campbell _______________________________________________ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers