[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17945] branches/blender2.5/blender/source /blender: 2.5
Joshua Leung
aligorith at gmail.com
Fri Dec 19 12:45:54 CET 2008
Revision: 17945
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17945
Author: aligorith
Date: 2008-12-19 12:45:46 +0100 (Fri, 19 Dec 2008)
Log Message:
-----------
2.5
Merged 'backend' changes from AnimSys2. Many of these changes are necessary for the Dopesheet and other changes I'm currently still stabilising. Those will come in due course.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/BKE_ipo.h
branches/blender2.5/blender/source/blender/blenkernel/BKE_key.h
branches/blender2.5/blender/source/blender/blenkernel/intern/action.c
branches/blender2.5/blender/source/blender/blenkernel/intern/armature.c
branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c
branches/blender2.5/blender/source/blender/blenkernel/intern/ipo.c
branches/blender2.5/blender/source/blender/blenkernel/intern/key.c
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
branches/blender2.5/blender/source/blender/makesdna/DNA_action_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_armature_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_camera_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_curve_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_ipo_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_key_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_lamp_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_material_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_object_types.h
branches/blender2.5/blender/source/blender/makesdna/DNA_space_types.h
Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_ipo.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_ipo.h 2008-12-19 11:17:14 UTC (rev 17944)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_ipo.h 2008-12-19 11:45:46 UTC (rev 17945)
@@ -24,7 +24,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): 2008, Joshua Leung (Animation Cleanup)
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -87,6 +87,8 @@
void sort_time_ipocurve(struct IpoCurve *icu);
int test_time_ipocurve(struct IpoCurve *icu);
+void set_interpolation_ipocurve(struct IpoCurve *icu, short ipo);
+
/* -------- IPO-Curve (Bezier) Calculations ---------- */
void correct_bezpart(float *v1, float *v2, float *v3, float *v4);
@@ -101,6 +103,8 @@
float calc_ipo_time(struct Ipo *ipo, float ctime);
void calc_ipo(struct Ipo *ipo, float ctime);
+void calc_ipo_range(struct Ipo *ipo, float *start, float *end);
+
/* ------------ Keyframe Column Tools -------------- */
void add_to_cfra_elem(struct ListBase *lb, struct BezTriple *bezt);
Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_key.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_key.h 2008-12-19 11:17:14 UTC (rev 17944)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_key.h 2008-12-19 11:45:46 UTC (rev 17945)
@@ -62,6 +62,7 @@
struct Key *ob_get_key(struct Object *ob);
struct KeyBlock *ob_get_keyblock(struct Object *ob);
struct KeyBlock *key_get_keyblock(struct Key *key, int index);
+struct KeyBlock *key_get_named_keyblock(struct Key *key, const char name[]);
// needed for the GE
void do_rel_key(int start, int end, int tot, char *basispoin, struct Key *key, int mode);
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/action.c 2008-12-19 11:17:14 UTC (rev 17944)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/action.c 2008-12-19 11:45:46 UTC (rev 17945)
@@ -299,7 +299,7 @@
outPose= MEM_callocN(sizeof(bPose), "pose");
- BLI_duplicatelist (&outPose->chanbase, &src->chanbase);
+ BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
if (copycon) {
for (pchan=outPose->chanbase.first; pchan; pchan=pchan->next) {
@@ -401,7 +401,9 @@
VECCOPY(pchan->loc, chan->loc);
VECCOPY(pchan->size, chan->size);
+ VECCOPY(pchan->eul, chan->eul);
QUATCOPY(pchan->quat, chan->quat);
+ pchan->rotmode= chan->rotmode;
Mat4CpyMat4(pchan->chan_mat, (float(*)[4])chan->chan_mat);
Mat4CpyMat4(pchan->pose_mat, (float(*)[4])chan->pose_mat);
pchan->flag= chan->flag;
@@ -697,7 +699,6 @@
bPoseChannel *dchan;
const bPoseChannel *schan;
bConstraint *dcon, *scon;
- float dquat[4], squat[4];
float dstweight;
int i;
@@ -719,23 +720,34 @@
/* Do the transformation blend */
if (schan->flag & POSE_ROT) {
- QUATCOPY(dquat, dchan->quat);
- QUATCOPY(squat, schan->quat);
- if(mode==ACTSTRIPMODE_BLEND)
- QuatInterpol(dchan->quat, dquat, squat, srcweight);
- else {
- QuatMulFac(squat, srcweight);
- QuatMul(dchan->quat, dquat, squat);
+ /* quat interpolation done separate */
+ if (schan->rotmode == PCHAN_ROT_QUAT) {
+ float dquat[4], squat[4];
+
+ QUATCOPY(dquat, dchan->quat);
+ QUATCOPY(squat, schan->quat);
+ if (mode==ACTSTRIPMODE_BLEND)
+ QuatInterpol(dchan->quat, dquat, squat, srcweight);
+ else {
+ QuatMulFac(squat, srcweight);
+ QuatMul(dchan->quat, dquat, squat);
+ }
+
+ NormalQuat(dchan->quat);
}
-
- NormalQuat (dchan->quat);
}
- for (i=0; i<3; i++){
+ for (i=0; i<3; i++) {
+ /* blending for loc and scale are pretty self-explanatory... */
if (schan->flag & POSE_LOC)
dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight);
if (schan->flag & POSE_SIZE)
dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight);
+
+ /* euler-rotation interpolation done here instead... */
+ // FIXME: are these results decent?
+ if ((schan->flag & POSE_ROT) && (schan->rotmode))
+ dchan->eul[i] = (dchan->eul[i]*dstweight) + (schan->eul[i]*srcweight);
}
dchan->flag |= schan->flag;
}
@@ -749,33 +761,33 @@
dst->ctime= src->ctime;
}
-
+/* Calculate the extents of given action */
void calc_action_range(const bAction *act, float *start, float *end, int incl_hidden)
{
- const bActionChannel *chan;
- const bConstraintChannel *conchan;
- const IpoCurve *icu;
- float min=999999999.0f, max=-999999999.0;
+ bActionChannel *chan;
+ bConstraintChannel *conchan;
+ IpoCurve *icu;
+ float min=999999999.0f, max=-999999999.0f;
int foundvert=0;
- if(act) {
+ if (act) {
for (chan=act->chanbase.first; chan; chan=chan->next) {
- if(incl_hidden || (chan->flag & ACHAN_HIDDEN)==0) {
- if(chan->ipo) {
+ if ((incl_hidden) || (chan->flag & ACHAN_HIDDEN)==0) {
+ if (chan->ipo) {
for (icu=chan->ipo->curve.first; icu; icu=icu->next) {
- if(icu->totvert) {
- min= MIN2 (min, icu->bezt[0].vec[1][0]);
- max= MAX2 (max, icu->bezt[icu->totvert-1].vec[1][0]);
+ if (icu->totvert) {
+ min= MIN2(min, icu->bezt[0].vec[1][0]);
+ max= MAX2(max, icu->bezt[icu->totvert-1].vec[1][0]);
foundvert=1;
}
}
}
for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next) {
- if(conchan->ipo) {
+ if (conchan->ipo) {
for (icu=conchan->ipo->curve.first; icu; icu=icu->next) {
- if(icu->totvert) {
- min= MIN2 (min, icu->bezt[0].vec[1][0]);
- max= MAX2 (max, icu->bezt[icu->totvert-1].vec[1][0]);
+ if (icu->totvert) {
+ min= MIN2(min, icu->bezt[0].vec[1][0]);
+ max= MAX2(max, icu->bezt[icu->totvert-1].vec[1][0]);
foundvert=1;
}
}
@@ -867,6 +879,7 @@
for (i=0; i<3; i++) {
pchan->loc[i]= 0.0f;
pchan->quat[i+1]= 0.0f;
+ pchan->eul[i]= 0.0f;
pchan->size[i]= 1.0f;
}
pchan->quat[0]= 1.0f;
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/armature.c 2008-12-19 11:17:14 UTC (rev 17944)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/armature.c 2008-12-19 11:45:46 UTC (rev 17945)
@@ -180,7 +180,7 @@
Bone *curBone, *newChildBone;
/* Copy this bone's list*/
- BLI_duplicatelist (&newBone->childbase, &oldBone->childbase);
+ BLI_duplicatelist(&newBone->childbase, &oldBone->childbase);
/* For each child in the list, update it's children*/
newChildBone=newBone->childbase.first;
@@ -1216,7 +1216,10 @@
if (pchan==NULL) return;
/* get the inverse matrix of the pchan's transforms */
- LocQuatSizeToMat4(pc_trans, pchan->loc, pchan->quat, pchan->size);
+ if (pchan->rotmode)
+ LocEulSizeToMat4(pc_trans, pchan->loc, pchan->eul, pchan->size);
+ else
+ LocQuatSizeToMat4(pc_trans, pchan->loc, pchan->quat, pchan->size);
Mat4Invert(inv_trans, pc_trans);
/* Remove the pchan's transforms from it's pose_mat.
@@ -1967,22 +1970,29 @@
float rmat[3][3];
float tmat[3][3];
+ /* get scaling matrix */
SizeToMat3(chan->size, smat);
- NormalQuat(chan->quat);
-
- QuatToMat3(chan->quat, rmat);
+ /* rotations may either be quats or eulers (no rotation modes for now...) */
+ if (chan->rotmode) {
+ /* euler rotations (will cause gimble lock... no rotation order to solve that yet) */
+ EulToMat3(chan->eul, rmat);
+ }
+ else {
+ /* quats are normalised before use to eliminate scaling issues */
+ NormalQuat(chan->quat);
+ QuatToMat3(chan->quat, rmat);
+ }
+ /* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */
Mat3MulMat3(tmat, rmat, smat);
-
Mat4CpyMat3(chan->chan_mat, tmat);
/* prevent action channels breaking chains */
/* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */
- if (chan->bone==NULL || !(chan->bone->flag & BONE_CONNECTED)) {
+ if ((chan->bone==NULL) || !(chan->bone->flag & BONE_CONNECTED)) {
VECCOPY(chan->chan_mat[3], chan->loc);
}
-
}
/* transform from bone(b) to bone(b+1), store in chan_mat */
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c 2008-12-19 11:17:14 UTC (rev 17944)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c 2008-12-19 11:45:46 UTC (rev 17945)
@@ -69,6 +69,7 @@
#include "BPY_extern.h"
#endif
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -3021,44 +3022,53 @@
float len= (curveMax[clamp_axis] - curveMin[clamp_axis]);
float offset;
- /* find bounding-box range where target is located */
- if (ownLoc[clamp_axis] < curveMin[clamp_axis]) {
- /* bounding-box range is before */
- offset= curveMin[clamp_axis];
-
- while (ownLoc[clamp_axis] < offset)
- offset -= len;
-
- /* now, we calculate as per normal, except using offset instead of curveMin[clamp_axis] */
- curvetime = (ownLoc[clamp_axis] - offset) / (len);
- }
- else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) {
- /* bounding-box range is after */
- offset= curveMax[clamp_axis];
-
- while (ownLoc[clamp_axis] > offset) {
- if ((offset + len) > ownLoc[clamp_axis])
- break;
- else
- offset += len;
+ /* check to make sure len is not so close to zero that it'll cause errors */
+ if (IS_EQ(len, 0) == 0) {
+ /* find bounding-box range where target is located */
+ if (ownLoc[clamp_axis] < curveMin[clamp_axis]) {
+ /* bounding-box range is before */
+ offset= curveMin[clamp_axis];
+
+ while (ownLoc[clamp_axis] < offset)
+ offset -= len;
+
+ /* now, we calculate as per normal, except using offset instead of curveMin[clamp_axis] */
+ curvetime = (ownLoc[clamp_axis] - offset) / (len);
}
-
- /* now, we calculate as per normal, except using offset instead of curveMax[clamp_axis] */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list