Merging r38220 through r38236 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 8 Jul 2011 17:40:29 +0000 (17:40 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 8 Jul 2011 17:40:29 +0000 (17:40 +0000)
intern/iksolver/intern/IK_QJacobian.cpp
intern/iksolver/intern/IK_QJacobian.h
intern/iksolver/intern/IK_QTask.cpp
source/blender/blenkernel/intern/softbody.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesdna/DNA_object_force.h
source/blender/makesrna/intern/rna_object_force.c

index 6cc73e9c8085444182c39872e445a03d9a8f85d9..5a216309ceeedd304418375dd9dd13ec839d91b1 100644 (file)
@@ -59,6 +59,7 @@ void IK_QJacobian::ArmMatrices(int dof, int task_size)
 
        m_d_theta.newsize(dof);
        m_d_theta_tmp.newsize(dof);
+       m_d_norm_weight.newsize(dof);
 
        m_norm.newsize(dof);
        m_norm = 0.0;
@@ -111,11 +112,13 @@ void IK_QJacobian::SetBetas(int id, int, const MT_Vector3& v)
        m_beta[id+2] = v.z();
 }
 
-void IK_QJacobian::SetDerivatives(int id, int dof_id, const MT_Vector3& v)
+void IK_QJacobian::SetDerivatives(int id, int dof_id, const MT_Vector3& v, MT_Scalar norm_weight)
 {
        m_jacobian[id][dof_id] = v.x()*m_weight_sqrt[dof_id];
        m_jacobian[id+1][dof_id] = v.y()*m_weight_sqrt[dof_id];
        m_jacobian[id+2][dof_id] = v.z()*m_weight_sqrt[dof_id];
+
+       m_d_norm_weight[dof_id] = norm_weight;
 }
 
 void IK_QJacobian::Invert()
@@ -429,7 +432,7 @@ MT_Scalar IK_QJacobian::AngleUpdateNorm() const
        MT_Scalar mx = 0.0, dtheta_abs;
 
        for (i = 0; i < m_d_theta.size(); i++) {
-               dtheta_abs = MT_abs(m_d_theta[i]);
+               dtheta_abs = MT_abs(m_d_theta[i]*m_d_norm_weight[i]);
                if (dtheta_abs > mx)
                        mx = dtheta_abs;
        }
index 438b9a02c6796597d4d12d1aaf6d86b37c564323..ecfaee5ff972bf1616bafec8542908513744e521 100644 (file)
@@ -56,7 +56,7 @@ public:
 
        // Iteratively called
        void SetBetas(int id, int size, const MT_Vector3& v);
-       void SetDerivatives(int id, int dof_id, const MT_Vector3& v);
+       void SetDerivatives(int id, int dof_id, const MT_Vector3& v, MT_Scalar norm_weight);
 
        void Invert();
 
@@ -89,6 +89,7 @@ private:
 
        /// the vector of computed angle changes
        TVector m_d_theta;
+       TVector m_d_norm_weight;
 
        /// space required for SVD computation
 
index 32ecb833899c07545710722d83567866c4ec26ae..32143518533f61d4533780709b2991971d014b07 100644 (file)
@@ -95,10 +95,10 @@ void IK_QPositionTask::ComputeJacobian(IK_QJacobian& jacobian)
                        MT_Vector3 axis = seg->Axis(i)*m_weight;
 
                        if (seg->Translational())
-                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, axis);
+                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, axis, 1e2);
                        else {
                                MT_Vector3 pa = p.cross(axis);
-                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, pa);
+                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, pa, 1e0);
                        }
                }
        }
@@ -147,10 +147,10 @@ void IK_QOrientationTask::ComputeJacobian(IK_QJacobian& jacobian)
                for (i = 0; i < seg->NumberOfDoF(); i++) {
 
                        if (seg->Translational())
-                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, MT_Vector3(0, 0, 0));
+                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, MT_Vector3(0, 0, 0), 1e2);
                        else {
                                MT_Vector3 axis = seg->Axis(i)*m_weight;
-                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, axis);
+                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, axis, 1e0);
                        }
                }
 }
@@ -202,10 +202,10 @@ void IK_QCenterOfMassTask::JacobianSegment(IK_QJacobian& jacobian, MT_Vector3& c
                axis *= /*segment->Mass()**/m_total_mass_inv;
                
                if (segment->Translational())
-                       jacobian.SetDerivatives(m_id, segment->DoFId()+i, axis);
+                       jacobian.SetDerivatives(m_id, segment->DoFId()+i, axis, 1e2);
                else {
                        MT_Vector3 pa = axis.cross(p);
-                       jacobian.SetDerivatives(m_id, segment->DoFId()+i, pa);
+                       jacobian.SetDerivatives(m_id, segment->DoFId()+i, pa, 1e0);
                }
        }
        
index ff238678eeb9891c3cb880903e0e77d768e77e35..2960d8a41e515c80a9d1e61bc43723a59150b75e 100644 (file)
@@ -75,6 +75,7 @@ variables on the UI for now
 #include "BKE_curve.h"
 #include "BKE_effect.h"
 #include "BKE_global.h"
+#include "BKE_modifier.h"
 #include "BKE_softbody.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_pointcache.h"
@@ -289,21 +290,24 @@ typedef struct ccd_Mesh {
 
 
 
-static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
+static ccd_Mesh *ccd_mesh_make(Object *ob)
 {
+       CollisionModifierData *cmd;
        ccd_Mesh *pccd_M = NULL;
        ccdf_minmax *mima =NULL;
        MFace *mface=NULL;
        float v[3],hull;
        int i;
 
+       cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
+
        /* first some paranoia checks */
-       if (!dm) return NULL;
-       if (!dm->getNumVerts(dm) || !dm->getNumFaces(dm)) return NULL;
+       if (!cmd) return NULL;
+       if (!cmd->numverts || !cmd->numfaces) return NULL;
 
        pccd_M = MEM_mallocN(sizeof(ccd_Mesh),"ccd_Mesh");
-       pccd_M->totvert = dm->getNumVerts(dm);
-       pccd_M->totface = dm->getNumFaces(dm);
+       pccd_M->totvert = cmd->numverts;
+       pccd_M->totface = cmd->numfaces;
        pccd_M->savety  = CCD_SAVETY;
        pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f;
        pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f;
@@ -314,12 +318,10 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
        hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft);
 
        /* alloc and copy verts*/
-       pccd_M->mvert = dm->dupVertArray(dm);
-       /* ah yeah, put the verices to global coords once */
-       /* and determine the ortho BB on the fly */
+       pccd_M->mvert = MEM_dupallocN(cmd->xnew);
+       /* note that xnew coords are already in global space, */
+       /* determine the ortho BB */
        for(i=0; i < pccd_M->totvert; i++){
-               mul_m4_v3(ob->obmat, pccd_M->mvert[i].co);
-
                /* evaluate limits */
                VECCOPY(v,pccd_M->mvert[i].co);
                pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull);
@@ -332,7 +334,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
 
        }
        /* alloc and copy faces*/
-       pccd_M->mface = dm->dupFaceArray(dm);
+       pccd_M->mface = MEM_dupallocN(cmd->mfaces);
 
        /* OBBs for idea1 */
        pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima");
@@ -386,19 +388,22 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
        }
        return pccd_M;
 }
-static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm)
+static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
 {
-        ccdf_minmax *mima =NULL;
+       CollisionModifierData *cmd;
+       ccdf_minmax *mima =NULL;
        MFace *mface=NULL;
        float v[3],hull;
        int i;
 
+       cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
+
        /* first some paranoia checks */
-       if (!dm) return ;
-       if (!dm->getNumVerts(dm) || !dm->getNumFaces(dm)) return ;
+       if (!cmd) return ;
+       if (!cmd->numverts || !cmd->numfaces) return ;
 
-       if ((pccd_M->totvert != dm->getNumVerts(dm)) ||
-               (pccd_M->totface != dm->getNumFaces(dm))) return;
+       if ((pccd_M->totvert != cmd->numverts) ||
+               (pccd_M->totface != cmd->numfaces)) return;
 
        pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f;
        pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f;
@@ -411,12 +416,10 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm)
        if(pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert);
        pccd_M->mprevvert = pccd_M->mvert;
        /* alloc and copy verts*/
-       pccd_M->mvert = dm->dupVertArray(dm);
-       /* ah yeah, put the verices to global coords once */
-       /* and determine the ortho BB on the fly */
+       pccd_M->mvert = MEM_dupallocN(cmd->xnew);
+       /* note that xnew coords are already in global space, */
+       /* determine the ortho BB */
        for(i=0; i < pccd_M->totvert; i++){
-               mul_m4_v3(ob->obmat, pccd_M->mvert[i].co);
-
                /* evaluate limits */
                VECCOPY(v,pccd_M->mvert[i].co);
                pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull);
@@ -555,21 +558,8 @@ static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *h
 
                        /*+++ only with deflecting set */
                        if(ob->pd && ob->pd->deflect && BLI_ghash_lookup(hash, ob) == NULL) {
-                               DerivedMesh *dm= NULL;
-
-                               if(ob->softflag & OB_SB_COLLFINAL) /* so maybe someone wants overkill to collide with subsurfed */
-                                       dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
-                               else
-                                       dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
-
-                               if(dm){
-                                       ccd_Mesh *ccdmesh = ccd_mesh_make(ob, dm);
-                                       BLI_ghash_insert(hash, ob, ccdmesh);
-
-                                       /* we did copy & modify all we need so give 'em away again */
-                                       dm->release(dm);
-
-                               }
+                               ccd_Mesh *ccdmesh = ccd_mesh_make(ob);
+                               BLI_ghash_insert(hash, ob, ccdmesh);
                        }/*--- only with deflecting set */
 
                }/* mesh && layer*/
@@ -595,21 +585,9 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash *
 
                        /*+++ only with deflecting set */
                        if(ob->pd && ob->pd->deflect) {
-                               DerivedMesh *dm= NULL;
-
-                               if(ob->softflag & OB_SB_COLLFINAL) { /* so maybe someone wants overkill to collide with subsurfed */
-                                       dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
-                               } else {
-                                       dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
-                               }
-                               if(dm){
-                                       ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob);
-                                       if (ccdmesh)
-                                               ccd_mesh_update(ob,ccdmesh,dm);
-
-                                       /* we did copy & modify all we need so give 'em away again */
-                                       dm->release(dm);
-                               }
+                               ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob);
+                               if (ccdmesh)
+                                       ccd_mesh_update(ob,ccdmesh);
                        }/*--- only with deflecting set */
 
                }/* mesh && layer*/
index 6ff24a418fabdb951cd28d910043617e280aeb97..d705c6bebfd7381cfb7d56fb332f4394ca16ca1f 100644 (file)
@@ -4880,7 +4880,6 @@ static void lib_link_screen(FileData *fd, Main *main)
                                        else if(sl->spacetype==SPACE_FILE) {
                                                SpaceFile *sfile= (SpaceFile *)sl;
                                                sfile->files= NULL;
-                                               sfile->params= NULL;
                                                sfile->op= NULL;
                                                sfile->layout= NULL;
                                                sfile->folders_prev= NULL;
@@ -5504,7 +5503,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                sfile->files= NULL;
                                sfile->layout= NULL;
                                sfile->op= NULL;
-                               sfile->params= NULL;
+                               sfile->params= newdataadr(fd, sfile->params);
                        }
                }
                
index d004cbb4647ba5e44a1542099f57a70b711c941a..6ce84e93f49c92ed32876965fc29cf6fbb130e31 100644 (file)
@@ -2104,7 +2104,11 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
                                        writestruct(wd, DATA, "SpaceButs", 1, sl);
                                }
                                else if(sl->spacetype==SPACE_FILE) {
+                                       SpaceFile *sfile= (SpaceFile *)sl;
+
                                        writestruct(wd, DATA, "SpaceFile", 1, sl);
+                                       if(sfile->params)
+                                               writestruct(wd, DATA, "FileSelectParams", 1, sfile->params);
                                }
                                else if(sl->spacetype==SPACE_SEQ) {
                                        writestruct(wd, DATA, "SpaceSeq", 1, sl);
index aadb355f743553f66d066ed1c0f1b136f7e6da09..eeaf87757cecfd2aa4801562eb33da7db62ae624 100644 (file)
@@ -468,8 +468,9 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
 
 void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, rcti *rect)
 {
+       float modelview[4][4];
        double xs, ys, p[3];
-       short val;
+       int val, flip_sign, a;
 
        /* near zero floating point values can give issues with gluUnProject
                in side view on some implementations */
@@ -493,11 +494,21 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, rc
                VECCOPY(bb->vec[4+val], p);
        }
 
+       /* verify if we have negative scale. doing the transform before cross
+          product flips the sign of the vector compared to doing cross product
+          before transform then, so we correct for that. */
+       for(a=0; a<16; a++)
+               ((float*)modelview)[a] = mats->modelview[a];
+       flip_sign = is_negative_m4(modelview);
+
        /* then plane equations */
        for(val=0; val<4; val++) {
 
                normal_tri_v3(planes[val], bb->vec[val], bb->vec[val==3?0:val+1], bb->vec[val+4]);
 
+               if(flip_sign)
+                       negate_v3(planes[val]);
+
                planes[val][3]= - planes[val][0]*bb->vec[val][0]
                        - planes[val][1]*bb->vec[val][1]
                        - planes[val][2]*bb->vec[val][2];
index 1c24f065d2623f8f7f0d5088c2ebed618694944d..24abb6a0bc25ab74533e25059e74f865bf773e36 100644 (file)
@@ -5002,6 +5002,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
 
                /* automatic inserting of keys and unkeyed tagging - only if transform wasn't cancelled (or TFM_DUMMY) */
                if (!cancelled && (t->mode != TFM_DUMMY)) {
+                       /* set BONE_TRANSFORM flags, they get changed by manipulator draw */
+                       count_set_pose_transflags(&t->mode, t->around, ob);
                        autokeyframe_pose_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
                        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                }
index 37568a22f54e1a35a80b9cf6bf88b22fb809cb87..fc8ce1b58207ab8f4a9375164d1b23f9f67802ba 100644 (file)
@@ -420,7 +420,7 @@ typedef struct SoftBody {
 #define OB_SB_SELF             512
 #define OB_SB_FACECOLL  1024
 #define OB_SB_EDGECOLL  2048
-#define OB_SB_COLLFINAL 4096
+#define OB_SB_COLLFINAL 4096   /* deprecated */
 #define OB_SB_BIG_UI   8192
 #define OB_SB_AERO_ANGLE       16384
 
index 5d3c29b736b4d1b4d14f0eebbfbe2a0423d72f33..ca679239dd3bdffd2114ac832d3ed1e3b6df5f8c 100644 (file)
@@ -910,13 +910,6 @@ static void rna_def_collision(BlenderRNA *brna)
        RNA_def_property_range(prop, 0.0f, 1.0f);
        RNA_def_property_ui_text(prop, "Damping", "Amount of damping during collision");
        RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-       
-       /* Does this belong here?
-       prop= RNA_def_property(srna, "collision_stack", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "softflag", OB_SB_COLLFINAL);
-       RNA_def_property_ui_text(prop, "Collision from Stack", "Pick collision object from modifier stack (softbody only)");
-       RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
-       */
 
        prop= RNA_def_property(srna, "absorption", PROP_FLOAT, PROP_FACTOR);
        RNA_def_property_range(prop, 0.0f, 1.0f);