Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2011-03-24 20:15:43 +0300
committerJanne Karhu <jhkarh@gmail.com>2011-03-24 20:15:43 +0300
commit3e9293f1a1821336cd1f8e784793d021b52145b7 (patch)
treea022f52321949bf144b24e935c8b95aabf03b742 /source
parentdb421408ce3eb21be3e04cae3e1c987e9b747311 (diff)
Further fix for parented fluidsim objects
* The rotation values determined from ob->obmat have to be continuous as fluidsim interpolates between these values internally.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/physics/physics_fluid.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 210b2480d85..67d2184dc69 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -349,6 +349,16 @@ static void free_all_fluidobject_channels(ListBase *fobjects)
}
}
+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 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
/* 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);