Orange: monday merger with bf-blender (loadsa bugfixes).
authorTon Roosendaal <ton@blender.org>
Mon, 19 Dec 2005 18:56:08 +0000 (18:56 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 19 Dec 2005 18:56:08 +0000 (18:56 +0000)
ALso: a bit tidying up in editaction.c and python Object.c

15 files changed:
1  2 
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/include/BIF_resources.h
source/blender/python/api2_2x/Object.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/texture.c
source/blender/src/drawobject.c
source/blender/src/editaction.c
source/blender/src/editconstraint.c
source/blender/src/editmesh.c
source/blender/src/header_info.c
source/blender/src/header_view3d.c
source/blender/src/outliner.c
source/blender/src/transform_conversions.c
source/blender/src/transform_generics.c
source/blender/src/transform_manipulator.c

index 0530295bcec13e7dcdb9ecfa384e44af6f8c9bcf,9ed4768eedef602e5a114c99deb9c6951d867490..f74a0a176e4f16fdc036956ab808bb624ab92036
@@@ -44,6 -44,6 +44,9 @@@ struct rctf
  #include "DNA_view3d_types.h"
  #include "DNA_object_force.h"
  #include "DNA_userdef_types.h"
++#include "DNA_oops_types.h" 
++
++#include "BKE_action.h"
  #include "BKE_depsgraph.h"
  #include "BKE_effect.h"
  #include "BKE_font.h"
  #include "BKE_curve.h"
  #include "BKE_global.h"
  #include "BKE_main.h"
--#include "BIF_editview.h"
++
  #include "BSE_editipo.h"
  #include "BSE_edit.h"
++
  #include "BIF_space.h"
--#include "DNA_oops_types.h" 
++#include "BIF_editview.h"
++
  #include "BLI_arithb.h"
  #include "BLI_blenlib.h"
++
  #include "BDR_editobject.h"
++
  #include "MEM_guardedalloc.h"
++
  #include "mydevice.h"
  #include "blendef.h"
  #include "Scene.h"
@@@ -2082,215 -2055,7 +2090,213 @@@ static PyObject *Object_insertIpoKey( B
        return EXPP_incr_ret( Py_None );
  }
  
 +/*
 + * Object_insertPoseKey()
 + *  inserts a Action Pose key from a given pose (sourceaction, frame) to the active action to a given framenum
 + */
  
-       bPoseChannel *pchan;
 +static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
 +{
 +      Object *ob= self->object;
 +      BPy_Action *sourceact;
 +      char *chanName;
 +      int actframe;
 +
 +      //for debug prints
 +      bActionChannel *achan;
 +      bPoseChannel *pchan;
 +
 +      /* for doing the time trick, similar to editaction bake_action_with_client() */
 +      int oldframe;
 +      int curframe;
 +
 +      if( !PyArg_ParseTuple( args, "O!sii", &Action_Type, &sourceact, &chanName, &actframe, &curframe ) )
 +              return ( EXPP_ReturnPyObjError( PyExc_AttributeError,                                                                           "expects an action to copy poses from, a string for chan/bone name, an int argument for frame-to-extract from the action and finally another int for the frame where to put the new key in the active object.action" ) );
 +
 +      printf("%s %s %d %d, ", sourceact->action->id.name, chanName, actframe, curframe);
 +      printf("%s\n", ob->action->id.name);
 +      
 +      /*  */
 +      extract_pose_from_action(ob->pose, sourceact->action, actframe);
 +
 +      oldframe = G.scene->r.cfra;
 +      G.scene->r.cfra = curframe;
 +      
 +      //debug
 +      pchan = get_pose_channel(ob->pose, chanName);
 +      printquat(pchan->name, pchan->quat);
 +
 +      achan = get_action_channel(sourceact->action, chanName);
 +      if(achan->ipo) {
 +        IpoCurve* icu;
 +        for (icu = achan->ipo->curve.first; icu; icu=icu->next){
 +          printvecf("bezt", icu->bezt->vec[1]);
 +          }
 +      }
 +      
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y);
 +      insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z);
 +      
 +      /*
 +      for (achan = ob->action->chanbase.first; achan; achan=achan->next) {
 +        if(achan->ipo) {
 +          IpoCurve* icu;
 +          for (icu = achan->ipo->curve.first; icu; icu=icu->next){
 +            printf("result: %f %f %f %f", icu->bp->vec[0], icu->bp->vec[1], icu->bp->vec[2], icu->bp->vec[3]);
 +          }
 +        }
 +      }
 +      */
 +
 +      G.scene->r.cfra = oldframe;
 +
 +      allspace(REMAKEIPO, 0);
 +      EXPP_allqueue(REDRAWIPO, 0);
 +      EXPP_allqueue(REDRAWVIEW3D, 0);
 +      EXPP_allqueue(REDRAWACTION, 0);
 +      EXPP_allqueue(REDRAWNLA, 0);
 +
 +      /* restore, but now with the new action in place */
 +      //extract_pose_from_action(ob->pose, ob->action, G.scene->r.cfra);
 +      //where_is_pose(ob);
 +      
 +      allqueue(REDRAWACTION, 1);
 +
 +      return EXPP_incr_ret( Py_None );
 +}
 +
 +static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args )
 +{
 +  Object *ob= self->object;
 +  //bPoseChannel *pchan; //for iterating over all channels in object->pose
 +  char *chanName;
 +
 +  /* for doing the time trick, similar to editaction bake_action_with_client() */
 +  int oldframe;
 +  int curframe;
 +
 +  if( !PyArg_ParseTuple( args, "si", &chanName, &curframe ) )
 +    return ( EXPP_ReturnPyObjError( PyExc_AttributeError,                                                                             "expected chan/bone name, and a time (int) argument" ) );
 +
 +  oldframe = G.scene->r.cfra;
 +  G.scene->r.cfra = curframe;
 +  
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y);
 +  insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z);
 +
 +  G.scene->r.cfra = oldframe;
 +
 +  allspace(REMAKEIPO, 0);
 +  EXPP_allqueue(REDRAWIPO, 0);
 +  EXPP_allqueue(REDRAWVIEW3D, 0);
 +  EXPP_allqueue(REDRAWACTION, 0);
 +  EXPP_allqueue(REDRAWNLA, 0);
 +
 +  /* restore */
 +  extract_pose_from_action(ob->pose, ob->action, G.scene->r.cfra);
 +  where_is_pose(ob);
 +      
 +  allqueue(REDRAWACTION, 1);
 +
 +  return EXPP_incr_ret( Py_None );
 +}  
 +
 +static PyObject *Object_insertMatrixKey( BPy_Object * self, PyObject * args )
 +{
 +      Object *ob= self->object;
 +      char *chanName;
 +
 +      /* for doing the time trick, similar to editaction bake_action_with_client() */
 +      int oldframe;
 +      int curframe;
 +
 +      /* for copying the current object/bone matrices to the new action */
-       Object *ob= self->object;
 +      float localQuat[4];
 +      float tmat[4][4], startpos[4][4];
 +
 +      //to get the matrix
 +      bArmature *arm;
 +      Bone      *bone;
 +              
 +      if( !PyArg_ParseTuple( args, "si", &chanName,  &curframe ) )
 +        return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expects a string for chan/bone name and an int for the frame where to put the new key" ) );
 +      
 +      oldframe = G.scene->r.cfra;
 +      G.scene->r.cfra = curframe;
 +
 +      //just to get the armaturespace mat
 +      arm = get_armature(ob);
 +      for (bone = arm->bonebase.first; bone; bone=bone->next)
 +        if (bone->name == chanName) break;
 +        //XXX does not check for if-not-found
 +
 +      where_is_object(ob);
 +      world2bonespace(tmat, ob->obmat, bone->arm_mat, startpos);
 +      Mat4ToQuat(tmat, localQuat);
 +
 +      insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, tmat[3][0]);
 +      insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, tmat[3][1]);
 +      insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, tmat[3][2]);
 +      insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, localQuat[0]);
 +      insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, localQuat[1]);
 +      insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, localQuat[2]);
 +      insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, localQuat[3]);
 +      //insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, );
 +      //insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y);
 +      //insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z);
 +      
 +      allspace(REMAKEIPO, 0);
 +      EXPP_allqueue(REDRAWIPO, 0);
 +      EXPP_allqueue(REDRAWVIEW3D, 0);
 +      EXPP_allqueue(REDRAWACTION, 0);
 +      EXPP_allqueue(REDRAWNLA, 0);
 +
 +      G.scene->r.cfra = oldframe;
 +
 +      /* restore, but now with the new action in place */
 +      extract_pose_from_action(ob->pose, ob->action, G.scene->r.cfra);
 +      where_is_pose(ob);
 +      
 +      allqueue(REDRAWACTION, 1);
 +
 +      return EXPP_incr_ret( Py_None );
 +}
 +
 +static PyObject *Object_bake_to_action( BPy_Object * self, PyObject * args )
 +{
 +
 +      /* for doing the time trick, similar to editaction bake_action_with_client() */
 +      //int oldframe;
 +      //int curframe;
 +
 +      //if( !PyArg_ParseTuple( args, "i", &curframe ) )
 +      //  return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expects an int for the frame where to put the new key" ) );
 +      
 +      //oldframe = G.scene->r.cfra;
 +      //G.scene->r.cfra = curframe;
 +
 +      bake_all_to_action(); //ob);
 +
 +      //G.scene->r.cfra = oldframe;
 +
 +      return EXPP_incr_ret( Py_None );
 +}
  
  static PyObject *Object_setLocation( BPy_Object * self, PyObject * args )
  {
index 9cbd22b781e851f0c4cd10c424f1eb2c90e25bd7,75e68e57ec16ea3e21377dc40abe5126324c7eac..5b3b27b2c3e36f1eb6ffa866a158d0b0fad1b5b6
@@@ -1811,33 -1810,39 +1811,39 @@@ static void draw_mesh_fancy(Base *base
                dm->drawLooseEdges(dm);
        }
        else if(dt==OB_SHADED) {
-               if( (G.f & G_WEIGHTPAINT)) {
-                       set_gl_material(0);             /* enforce defmaterial settings */
-                       
-                       /* but set default spec */
-                       glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
-                       glEnable(GL_COLOR_MATERIAL);    /* according manpages needed */
-                       glColor3ub(120, 120, 120);
-                       glDisable(GL_COLOR_MATERIAL);
-                       /* diffuse */
-                       glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
-                       glEnable(GL_LIGHTING);
-                       glEnable(GL_COLOR_MATERIAL);
+               int do_draw= 1; /* to resolve all G.f settings below... */
+               
+               if(ob==OBACT) {
+                       do_draw= 0;
+                       if( (G.f & G_WEIGHTPAINT)) {
+                               set_gl_material(0);             /* enforce defmaterial settings */
+                               
+                               /* but set default spec */
+                               glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
+                               glEnable(GL_COLOR_MATERIAL);    /* according manpages needed */
+                               glColor3ub(120, 120, 120);
+                               glDisable(GL_COLOR_MATERIAL);
+                               /* diffuse */
+                               glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+                               glEnable(GL_LIGHTING);
+                               glEnable(GL_COLOR_MATERIAL);
  
-                       dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1);
-                       glDisable(GL_COLOR_MATERIAL);
-                       glDisable(GL_LIGHTING);
-               }
-               else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mcol) {
-                       dm->drawMappedFaces(dm, NULL, NULL, 1);
-               }
-               else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->tface) {
-                       dm->drawMappedFaces(dm, NULL, NULL, 1);
+                               dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1);
+                               glDisable(GL_COLOR_MATERIAL);
+                               glDisable(GL_LIGHTING);
+                       }
+                       else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mcol) {
+                               dm->drawMappedFaces(dm, NULL, NULL, 1);
+                       }
+                       else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->tface) {
+                               dm->drawMappedFaces(dm, NULL, NULL, 1);
+                       }
+                       else do_draw= 1;
                }
-               else {
+               if(do_draw) {
                        dl = ob->disp.first;
                        if (!dl || !dl->col1) {
 -                              shadeDispList(ob);
 +                              shadeDispList(base);
                                dl = find_displist(&ob->disp, DL_VERTCOL);
                        }
  
index ec740c5f75b1e5cdc4bbb5b27588919ca8f6a91b,77e1c7222468d705f4900cca4f8ce410c0945d3b..30df91bd09232aab03d5b3cf9b90841bdeecb0a4
@@@ -2733,169 -2684,3 +2728,161 @@@ void bottom_sel_action(
        allqueue(REDRAWIPO, 0);
        allqueue(REDRAWNLA, 0);
  }
-       bActionChannel  *achan;
 +
 +void world2bonespace(float boneSpaceMat[][4], float worldSpace[][4], float restPos[][4], float armPos[][4])
 +{
 +      float imatarm[4][4], imatbone[4][4], tmat[4][4], t2mat[4][4];
 +      
 +      Mat4Invert(imatarm, armPos);
 +      Mat4Invert(imatbone, restPos);
 +      Mat4MulMat4(tmat, imatarm, worldSpace);
 +      Mat4MulMat4(t2mat, tmat, imatbone);
 +      Mat4MulMat4(boneSpaceMat, restPos, t2mat);
 +}
 +
 +
 +bAction* bake_obIPO_to_action (Object *ob)
 +{
 +      bArmature               *arm;
 +      bAction                 *result=NULL;
-       bPoseChannel    *pchan;
 +      bAction                 *temp;
-       float                   actstart, actend;
 +      Bone                    *bone;
 +      ID                              *id;
 +      ListBase                elems;
-       int                     curframe;
 +      int                     oldframe,testframe;
-       float                   quat[4],tmat[4][4],startpos[4][4],imat[4][4],mat3[3][3];
 +      char                    newname[64];
-       bActionChannel  *achan;
++      float                   quat[4],tmat[4][4],startpos[4][4];
 +      CfraElem                *firstcfra, *lastcfra;
 +      
 +      arm = get_armature(ob);
 +      
 +      if (arm) {      
 +      
 +              oldframe = CFRA;
 +              result = add_empty_action(ID_PO);
 +              id = (ID *)ob;
 +              
 +              sprintf (newname, "TESTOBBAKE");
 +              rename_id(&result->id, newname);
 +              
 +              if(ob!=G.obedit) { // make sure object is not in edit mode
 +                      if(ob->ipo) {
 +                              /* convert the ipo to a list of 'current frame elements' */
 +                              
 +                              temp = ob->action;
 +                              ob->action = result;
 +                              
 +                              elems.first= elems.last= NULL;
 +                              make_cfra_list(ob->ipo, &elems);
 +                              /* set the beginning armature location */
 +                              firstcfra=elems.first;
 +                              lastcfra=elems.last;
 +                              CFRA=firstcfra->cfra;
 +                              
 +                              where_is_object(ob);
 +                              Mat4CpyMat4(startpos,ob->obmat);
 +                              
 +                              /* loop from first key to last, sampling every 10 */
 +                              for (testframe = firstcfra->cfra; testframe<=lastcfra->cfra; testframe=testframe+10) { 
 +                                      CFRA=testframe;
 +                                      where_is_object(ob);
 +
 +                                      for (bone = arm->bonebase.first; bone; bone=bone->next) {
 +                                              if (!bone->parent) { /* this is a root bone, so give it a key! */
 +                                                      world2bonespace(tmat,ob->obmat,bone->arm_mat,startpos);
 +                                                      Mat4ToQuat(tmat,quat);
 +                                                      printf("Frame: %i %f, %f, %f, %f\n",CFRA,quat[0],quat[1],quat[2],quat[3]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_LOC_X,tmat[3][0]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_LOC_Y,tmat[3][1]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_LOC_Z,tmat[3][2]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_QUAT_X,quat[1]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_QUAT_Y,quat[2]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_QUAT_Z,quat[3]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_QUAT_W,quat[0]);
 +                                                      //insertmatrixkey(id, ID_PO, bone->name, NULL, AC_SIZE_X,size[0]);
 +                                                      //insertmatrixkey(id, ID_PO, bone->name, NULL, AC_SIZE_Y,size[1]);
 +                                                      //insertmatrixkey(id, ID_PO, bone->name, NULL, AC_SIZE_Z,size[2]);
 +                                              }
 +                                      }
 +                              }
 +                              BLI_freelistN(&elems);  
 +                      }
 +              }
 +              CFRA = oldframe;
 +      }
 +      return result;  
 +}
 +
 +bAction* bake_everything_to_action (Object *ob)
 +{
 +      bArmature               *arm;
 +      bAction                 *result=NULL;
-       bPoseChannel    *pchan;
 +      bAction                 *temp;
-       float                   actstart, actend;
 +      Bone                    *bone;
 +      ID                              *id;
 +      ListBase                elems;
-       int                     curframe;
 +      int                     oldframe,testframe;
-       float                   quat[4],tmat[4][4],startpos[4][4],imat[4][4],mat3[3][3];
 +      char                    newname[64];
++      float                   quat[4],tmat[4][4],startpos[4][4];
 +      CfraElem                *firstcfra, *lastcfra;
 +      
 +      arm = get_armature(ob);
 +      
 +      if (arm) {      
 +      
 +              oldframe = CFRA;
 +              result = add_empty_action(ID_PO);
 +              id = (ID *)ob;
 +              
 +              sprintf (newname, "TESTOBBAKE");
 +              rename_id(&result->id, newname);
 +              
 +              if(ob!=G.obedit) { // make sure object is not in edit mode
 +                      if(ob->ipo) {
 +                              /* convert the ipo to a list of 'current frame elements' */
 +                              
 +                              temp = ob->action;
 +                              ob->action = result;
 +                              
 +                              elems.first= elems.last= NULL;
 +                              make_cfra_list(ob->ipo, &elems);
 +                              /* set the beginning armature location */
 +                              firstcfra=elems.first;
 +                              lastcfra=elems.last;
 +                              CFRA=firstcfra->cfra;
 +                              
 +                              where_is_object(ob);
 +                              Mat4CpyMat4(startpos,ob->obmat);
 +                              
 +                              /* loop from first key to last, sampling every 10 */
 +                              for (testframe = firstcfra->cfra; testframe<=lastcfra->cfra; testframe=testframe+10) { 
 +                                      CFRA=testframe;
 +                                      
 +                                      do_all_pose_actions(ob);
 +                                      where_is_object(ob);
 +                                      for (bone = arm->bonebase.first; bone; bone=bone->next) {
 +                                              if (!bone->parent) { /* this is a root bone, so give it a key! */
 +                                                      world2bonespace(tmat,ob->obmat,bone->arm_mat,startpos);
 +                                                      
 +                                                      Mat4ToQuat(tmat,quat);
 +                                                      printf("Frame: %i %f, %f, %f, %f\n",CFRA,quat[0],quat[1],quat[2],quat[3]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_LOC_X,tmat[3][0]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_LOC_Y,tmat[3][1]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_LOC_Z,tmat[3][2]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_QUAT_X,quat[1]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_QUAT_Y,quat[2]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_QUAT_Z,quat[3]);
 +                                                      insertmatrixkey(id, ID_PO, bone->name, NULL, AC_QUAT_W,quat[0]);
 +                                                      //insertmatrixkey(id, ID_PO, bone->name, NULL, AC_SIZE_X,size[0]);
 +                                                      //insertmatrixkey(id, ID_PO, bone->name, NULL, AC_SIZE_Y,size[1]);
 +                                                      //insertmatrixkey(id, ID_PO, bone->name, NULL, AC_SIZE_Z,size[2]);
 +                                              }
 +                                      }
 +                              }
 +                              BLI_freelistN(&elems);  
 +                      }
 +              }
 +              CFRA = oldframe;
 +      }
 +      return result;  
 +}
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge