svn merge -r 12653:12664 https://svn.blender.org/svnroot/bf-blender/trunk/blender
authorDaniel Genrich <daniel.genrich@gmx.net>
Sat, 24 Nov 2007 22:49:56 +0000 (22:49 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Sat, 24 Nov 2007 22:49:56 +0000 (22:49 +0000)
16 files changed:
intern/elbeem/intern/paraloopend.h
release/scripts/mesh_edges2curves.py
source/blender/blenkernel/intern/action.c
source/blender/blenlib/BLI_arithb.h
source/blender/blenlib/intern/arithb.c
source/blender/python/api2_2x/Curve.c
source/blender/python/api2_2x/Mesh.c
source/blender/python/api2_2x/doc/Curve.py
source/blender/python/api2_2x/doc/Mesh.py
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/imagetexture.c
source/blender/render/intern/source/rendercore.c
source/blender/src/drawipo.c
source/blender/src/transform.c
source/blender/src/usiblender.c
source/creator/creator.c

index 81fc329d159a07d7cb2ae76b6e5400cea7ec2fff..54f5a529ea439d7ef07aa33fb9a0bebba19d35aa 100644 (file)
@@ -1,13 +1,41 @@
-// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-} /* i */ 
-       int i=0; 
-       ADVANCE_POINTERS(2*gridLoopBound); 
-} /* j */ 
-#pragma omp barrier 
-       /* COMPRESSGRIDS!=1 */ 
-       /* int i=0;  */ 
-       /* ADVANCE_POINTERS(mLevel[lev].lSizex*2);  */ 
-} /* all cell loop k,j,i */
-       if(doReduce) { } /* dummy remove warning */ 
-} /* main_region */ 
+// same as grid loop_end + barrier
+
+                       } // i
+               int i=0; //dummy
+               ADVANCE_POINTERS(2*gridLoopBound);
+       } // j
+
+#      if COMPRESSGRIDS==1
+#      if PARALLEL==1
+       //frintf(stderr," (id=%d k=%d) ",id,k);
+#pragma omp barrier
+#      endif // PARALLEL==1
+#      else // COMPRESSGRIDS==1
+       int i=0; //dummy
+       ADVANCE_POINTERS(mLevel[lev].lSizex*2);
+#      endif // COMPRESSGRIDS==1
+
+} // all cell loop k,j,i
+
+#pragma omp critical
+{
+       if(doReduce) {
+               // synchronize global vars
+               for(int j=0; j<calcListFull.size() ; j++) mListFull.push_back( calcListFull[j] ); 
+               for(int j=0; j<calcListEmpty.size(); j++) mListEmpty.push_back( calcListEmpty[j] ); 
+               for(int j=0; j<calcListParts.size(); j++) mpParticles->addFullParticle( calcListParts[j] );
+               if(calcMaxVlen>mMaxVlen) {  
+                       mMxvx = calcMxvx;  
+                       mMxvy = calcMxvy;  
+                       mMxvz = calcMxvz;  
+                       mMaxVlen = calcMaxVlen;  
+               }  
+               if(0) {debMsgStd("OMP_CRIT",DM_MSG,     "reduce id"<<id<<" curr: "<<mMaxVlen<<"|"<<mMxvx<<","<<mMxvy<<","<<mMxvz<< 
+                                                                                                                                                               "      calc[ "<<calcMaxVlen<<"|"<<calcMxvx<<","<<calcMxvy<<","<<calcMxvz<<"]  " ,4 ); }
+       }
+} // critical
+
+
+} /* main_region */  
+       //?lobOutstrForce = true;
 
index fdf61298ebcc373bfc5345df6e76650cb81312ae..84f3cc41779771ab62e6e9d38e065a7e0a16e1b7 100644 (file)
@@ -39,17 +39,8 @@ Supported:<br>
 # ***** END GPL LICENCE BLOCK *****
 # --------------------------------------------------------------------------
 
-
 from Blender import *
 
-def edkey(ed):
-       i1 = ed.v1.index
-       i2 = ed.v2.index
-       if i1>i2:
-               return (i2,i1), ed
-       else:
-               return (i1,i2), ed
-
 def polysFromMesh(me):
        # a polyline is 2 
        #polylines are a list
index bd5e5d612c6c7a6a37cf3cc1538edbeb3804197c..e30d7dd4ac9dc8615a73b59daa21b5fcc41f34d8 100644 (file)
@@ -607,8 +607,10 @@ void blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
                                QUATCOPY(squat, schan->quat);
                                if(mode==ACTSTRIPMODE_BLEND)
                                        QuatInterpol(dchan->quat, dquat, squat, srcweight);
-                               else
-                                       QuatAdd(dchan->quat, dquat, squat, srcweight);
+                               else {
+                                       QuatMulFac(squat, srcweight);
+                                       QuatMul(dchan->quat, dquat, squat);
+                               }
                                
                                NormalQuat (dchan->quat);
                        }
index 9e4412d3cd38915c7c880e50c7612eeea47b4798..32308f89a151eb614a852c57431b092daa3bd580 100644 (file)
@@ -119,6 +119,8 @@ void QuatToEul(float *quat, float *eul);
 void QuatOne(float *);
 void QuatMul(float *, float *, float *);
 void QuatMulVecf(float *q, float *v);
+void QuatMulf(float *q, float f);
+void QuatMulFac(float *q, float fac);
 
 void NormalQuat(float *);
 void VecRotToQuat(float *vec, float phi, float *quat);
@@ -126,7 +128,6 @@ void VecRotToQuat(float *vec, float phi, float *quat);
 void QuatSub(float *q, float *q1, float *q2);
 void QuatConj(float *q);
 void QuatInv(float *q);
-void QuatMulf(float *q, float f);
 float QuatDot(float *q1, float *q2);
 void QuatCopy(float *q1, float *q2);
 
index 5a37205af011d0719590f42e7fa3a3f777df58cc..2888a684af12b9e2548949e5b49cc4caac8781ba 100644 (file)
@@ -1109,6 +1109,7 @@ void QuatInv(float *q)
        QuatMulf(q, 1.0f/f);
 }
 
+/* simple mult */
 void QuatMulf(float *q, float f)
 {
        q[0] *= f;
@@ -1124,6 +1125,20 @@ void QuatSub(float *q, float *q1, float *q2)
        q2[0]= -q2[0];
 }
 
+/* angular mult factor */
+void QuatMulFac(float *q, float fac)
+{
+       float angle= fac*saacos(q[0]);  /* quat[0]= cos(0.5*angle), but now the 0.5 and 2.0 rule out */
+       
+       float co= (float)cos(angle);
+       float si= (float)sin(angle);
+       q[0]= co;
+       Normalize(q+1);
+       q[1]*= si;
+       q[2]*= si;
+       q[3]*= si;
+       
+}
 
 void QuatToMat3( float *q, float m[][3])
 {
index e849522ef00a3e0e5a299a6399a0a7b1e0ec9c0b..e88ab0eeeff00671bf535e432d56bb9bcd0df151 100644 (file)
@@ -124,6 +124,7 @@ static PyObject *Curve_getIter( BPy_Curve * self );
 static PyObject *Curve_iterNext( BPy_Curve * self );
 
 PyObject *Curve_getNurb( BPy_Curve * self, int n );
+static int Curve_setNurb( BPy_Curve * self, int n, PyObject * value );
 static int Curve_length( PyInstanceObject * inst );
 
 
@@ -1111,6 +1112,42 @@ PyObject *Curve_getNurb( BPy_Curve * self, int n )
 
 }
 
+/*
+ * Curve_setNurb
+ * In this case only remove the item, we could allow adding later.
+ */
+static int Curve_setNurb( BPy_Curve * self, int n, PyObject * value )
+{
+       Nurb *pNurb;
+       int i;
+
+       /* bail if index < 0 */
+       if( n < 0 )
+               return ( EXPP_ReturnIntError( PyExc_IndexError,
+                                "index less than 0" ) );
+       /* bail if no Nurbs in Curve */
+       if( self->curve->nurb.first == 0 )
+               return ( EXPP_ReturnIntError( PyExc_IndexError,
+                                "no Nurbs in this Curve" ) );
+       /* set pointer to nth Nurb */
+       for( pNurb = self->curve->nurb.first, i = 0;
+                       pNurb != 0 && i < n; pNurb = pNurb->next, ++i )
+               /**/;
+
+       if( !pNurb )            /* we came to the end of the list */
+               return ( EXPP_ReturnIntError( PyExc_IndexError,
+                                "index out of range" ) );
+       
+       if (value) {
+               return ( EXPP_ReturnIntError( PyExc_RuntimeError,
+                                "assigning curves is not yet supported" ) );
+       } else {
+               BLI_remlink(&self->curve->nurb, pNurb);
+               freeNurb(pNurb);
+       }
+       return 0;
+}
+
 /*****************************************************************************/
 /* Function:    Curve_compare                                                   */
 /* Description: This compares 2 curve python types, == or != only.                      */
@@ -1430,7 +1467,7 @@ static PySequenceMethods Curve_as_sequence = {
        ( intargfunc ) 0,       /* sq_repeat */
        ( intargfunc ) Curve_getNurb,   /* sq_item */
        ( intintargfunc ) 0,    /* sq_slice */
-       0,                      /* sq_ass_item */
+       ( intobjargproc ) Curve_setNurb,        /* sq_ass_item - only so you can do del curve[i] */
        0,                      /* sq_ass_slice */
        ( objobjproc ) 0,       /* sq_contains */
        0,
index 8a832d0deeb5fe6d63143ccd4307226516caa5f1..8248816bc3d46f178130d0a3c24db6ef0641def0 100644 (file)
@@ -7429,28 +7429,34 @@ static short pointInside_internal(float *vec, float *v1, float *v2, float  *v3 )
        return 0;
 }
 
-static PyObject *Mesh_pointInside( BPy_Mesh * self, VectorObject * vec )
+static PyObject *Mesh_pointInside( BPy_Mesh * self, PyObject * args, PyObject *kwd )
 {
        Mesh *mesh = self->mesh;
        MFace *mf = mesh->mface;
        MVert *mvert = mesh->mvert;
        int i;
        int isect_count=0;
+       int selected_only = 0;
+       VectorObject *vec;
+       static char *kwlist[] = {"point", "selected_only", NULL};
        
-       if(!VectorObject_Check(vec))
-                       return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                       "expected one vector type" );
+       if( !PyArg_ParseTupleAndKeywords(args, kwd, "|O!i", kwlist,
+                &vector_Type, &vec, &selected_only) ) {
+                        return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a vector and an optional bool argument");
+       }
        
        if(vec->size < 3)
                return EXPP_ReturnPyObjError(PyExc_AttributeError, 
                        "Mesh.pointInside(vec) expects a 3D vector object\n");
        
        for( i = 0; i < mesh->totface; mf++, i++ ) {
-               if (pointInside_internal(vec->vec, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co)) {
-                       isect_count++;
-               } else if (mf->v4 && pointInside_internal(vec->vec,mvert[mf->v1].co, mvert[mf->v3].co, mvert[mf->v4].co)) {
-                       
-                       isect_count++;
+               if (!selected_only || mf->flag & ME_FACE_SEL) {
+                       if (pointInside_internal(vec->vec, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co)) {
+                               isect_count++;
+                       } else if (mf->v4 && pointInside_internal(vec->vec,mvert[mf->v1].co, mvert[mf->v3].co, mvert[mf->v4].co)) {
+                               
+                               isect_count++;
+                       }
                }
        }
        
@@ -7536,7 +7542,7 @@ static struct PyMethodDef BPy_Mesh_methods[] = {
                "Removes duplicates from selected vertices (experimental)"},
        {"recalcNormals", (PyCFunction)Mesh_recalcNormals, METH_VARARGS,
                "Recalculates inside or outside normals (experimental)"},
-       {"pointInside", (PyCFunction)Mesh_pointInside, METH_O,
+       {"pointInside", (PyCFunction)Mesh_pointInside, METH_VARARGS|METH_KEYWORDS,
                "Recalculates inside or outside normals (experimental)"},
        
        /* mesh custom data layers */
index 5ccf5834ebd6771954a5426ecf8e0dfb95a84f60..c3760bc2c1deb8b872d1dfc9a2039d2c749c2b18 100644 (file)
@@ -10,7 +10,7 @@ This module provides access to B{Curve Data} objects in Blender.
 
 A Blender Curve Data consists of multiple L{CurNurb}(s). Try converting a Text object to a Curve to see an example of this.   Each curve is of
 type Bezier or Nurb.  The underlying L{CurNurb}(s) can be accessed with
-the [] operator.  Operator [] returns an object of type L{CurNurb}.
+the [] operator.  Operator [] returns an object of type L{CurNurb}. Removing a L{CurNurb} can be done this way too. del curve[0] removes the first curve.
 
 Note that L{CurNurb} can be used to acces a curve of any type (Poly, Bezier or Nurb)
 
index e572d6a91ae5ef2db1378fc2ed20b93c2089abfd..7e7514e8b3aa8f09c002d6b2e3617e0f6e792e46 100644 (file)
@@ -834,10 +834,15 @@ class Mesh:
                Recalculates the vertex normals using face data.
                """
        
-       def pointInside(vector):
+       def pointInside(point, selected_only=False):
                """
+               @type point: vector
+               @param point: Test if this point is inside the mesh
+               @type selected_only: bool
+               @param selected_only: if True or 1, only the selected faces are taken into account.
                Returns true if vector is inside the mesh.
                @note: Only returns a valid result for mesh data that has no holes.
+               @note: Bubbles in the mesh work as expect.
                """
        
        def transform(matrix, recalc_normals = False, selected_only=False):
@@ -869,7 +874,7 @@ class Mesh:
                @param matrix: 4x4 Matrix which can contain location, scale and rotation. 
                @type recalc_normals: int
                @param recalc_normals: if True or 1, also transform vertex normals.
-               @type selected_only: int
+               @type selected_only: bool
                @param selected_only: if True or 1, only the selected verts will be transformed.
                @warn: unlike L{NMesh.transform()<NMesh.NMesh.transform>}, this method
                I{will immediately modify the mesh data} when it is used.  If you
index 29b48413ca730bb55ef86e096fc2d8baacf3a0d2..ca9c7652441bc241f486bcd242ad0cec5e80a274 100644 (file)
@@ -1883,9 +1883,10 @@ static void init_render_mesh(Render *re, Object *ob, Object *par, int only_verts
                                MTC_Mat4MulVecfl(mat, ver->co);
 
                        if(useFluidmeshNormals) {
-                               xn = mvert->no[0]/ 32767.0;
-                               yn = mvert->no[1]/ 32767.0;
-                               zn = mvert->no[2]/ 32767.0;
+                               /* normals are inverted in render */
+                               xn = -mvert->no[0]/ 32767.0;
+                               yn = -mvert->no[1]/ 32767.0;
+                               zn = -mvert->no[2]/ 32767.0;
                                /* transfor to cam  space */
                                ver->n[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
                                ver->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
index 82abab626371311dacb75a207033242bde0c5a8e..ff0b5f3d3cbc726e137b34a200d002e728c430b3 100644 (file)
@@ -968,5 +968,14 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *dxt, f
                texres->nor[2] = 2.f*(texres->tb - 0.5f);
        }
        
+       /* de-premul, this is being premulled in shade_input_do_shade() */
+       if(texres->ta!=1.0f && texres->ta!=0.0f) {
+               fx= 1.0f/texres->ta;
+               texres->tr*= fx;
+               texres->tg*= fx;
+               texres->tb*= fx;
+       }
+
+       
        return retval;
 }
index b12d6094f2b925d0ae813500e43f7ac0d8d63693..0f91a92fe9c1c7f37a3c6d55d3cdba5819dd9342 100644 (file)
@@ -1182,11 +1182,8 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, VlakRen *vlr, in
                shade_input_set_triangle_i(shi, vlr, 0, 1, 2);
 
        /* we don't want flipped normals, they screw up back scattering */
-       if(vlr->noflag & R_FLIPPED_NO) {
-               shi->facenor[0]= -shi->facenor[0];
-               shi->facenor[1]= -shi->facenor[1];
-               shi->facenor[2]= -shi->facenor[2];
-       }
+       if(vlr->noflag & R_FLIPPED_NO)
+               VecMulf(shi->facenor, -1.0f);
 
        /* center pixel */
        x += 0.5f;
@@ -1214,6 +1211,12 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, VlakRen *vlr, in
        shade_input_set_uv(shi);
        shade_input_set_normals(shi);
 
+       /* not a pretty solution, but fixes common cases */
+       if(vlr->ob && vlr->ob->transflag & OB_NEG_SCALE) {
+               VecMulf(shi->vn, -1.0f);
+               VecMulf(shi->vno, -1.0f);
+       }
+
        /* if nodetree, use the material that we are currently preprocessing
           instead of the node material */
        if(shi->mat->nodetree && shi->mat->use_nodes)
index d9ef3349ec1d867d751f3ebc48ab0783d0f9202c..9b64d350b9ff09466b528693e6b76d2ebb101fa0 100644 (file)
@@ -2014,7 +2014,7 @@ static char *ipodriver_modeselect_pup(Object *ob)
        return (string);
 }
 
-static char *ipodriver_channelselect_pup(void)
+static char *ipodriver_channelselect_pup(int is_armature)
 {
        static char string[1024];
        char *tmp;
@@ -2031,7 +2031,8 @@ static char *ipodriver_channelselect_pup(void)
        tmp+= sprintf(tmp, "|Scale X %%x%d", OB_SIZE_X);
        tmp+= sprintf(tmp, "|Scale Y %%x%d", OB_SIZE_Y);
        tmp+= sprintf(tmp, "|Scale Z %%x%d", OB_SIZE_Z);
-       tmp+= sprintf(tmp, "|Rotation Differance %%x%d", OB_ROT_DIFF);
+       if(is_armature)
+               tmp+= sprintf(tmp, "|Rotation Differance %%x%d", OB_ROT_DIFF);
        
        return (string);
 }
@@ -2094,7 +2095,8 @@ static void ipo_panel_properties(short cntrl)     // IPO_HANDLER_PROPERTIES
                                                                          ipodriver_modeselect_pup(driver->ob), 165,240,145,20, &(driver->blocktype), 0, 0, 0, 0, "Driver type");
 
                                        uiDefButS(block, MENU, B_IPO_REDR, 
-                                                               ipodriver_channelselect_pup(),                  165,220,145,20, &(driver->adrcode), 0, 0, 0, 0, "Driver channel");
+                                                               ipodriver_channelselect_pup(driver->ob->type==OB_ARMATURE && driver->blocktype==ID_AR),                 
+                                                                                                               165,220,145,20, &(driver->adrcode), 0, 0, 0, 0, "Driver channel");
                                }
                                uiBlockEndAlign(block);
                        }
index 2a7f744f219e1a55086c35eded7d7e299b33cb3b..99276cdad59d4183dbe03589d6d938dde6c42c6c 100644 (file)
@@ -3536,18 +3536,6 @@ static void headerTimeTranslate(TransInfo *t, char *str)
                double secf= FPS;
                float val= t->fac;
                
-               /* take into account scaling (for Action Editor only) */
-               if ((t->spacetype == SPACE_ACTION) && (NLA_ACTION_SCALED)) {
-                       float cval, sval[2];
-                       
-                       /* recalculate the delta based on 'visual' times */
-                       areamouseco_to_ipoco(G.v2d, t->imval, &sval[0], &sval[1]);
-                       cval= sval[0] + t->fac;
-                       
-                       val = get_action_frame_inv(OBACT, cval);
-                       val -= get_action_frame_inv(OBACT, sval[0]);
-               }       
-               
                /* apply snapping + frame->seconds conversions */
                if (autosnap == SACTSNAP_STEP) {
                        if (doTime)
@@ -3575,7 +3563,6 @@ static void applyTimeTranslate(TransInfo *t, float sval)
        double secf= FPS;
        
        short autosnap= getAnimEdit_SnapMode(t);
-       float cval= sval + t->fac;
        
        float deltax, val;
        
@@ -3588,8 +3575,7 @@ static void applyTimeTranslate(TransInfo *t, float sval)
                
                /* check if any need to apply nla-scaling */
                if (ob) {
-                       deltax = get_action_frame_inv(ob, cval);
-                       deltax -= get_action_frame_inv(ob, sval);
+                       deltax = t->fac;
                        
                        if (autosnap == SACTSNAP_STEP) {
                                if (doTime) 
index c9db00401af400271bf7e1ba0a3fca1530560575..16d55202a39089d86b539d003bbb13024e9e5009 100644 (file)
@@ -458,7 +458,7 @@ void BIF_read_file(char *name)
 
                if(retval==2) init_userdef_file();      // in case a userdef is read from regular .blend
                
-               G.relbase_valid = 1;
+               if (retval!=0) G.relbase_valid = 1;
 
                undo_editmode_clear();
                BKE_reset_undo();
index 8588dc9db9c240c5d3c25c841fd226ffdbf804a4..1feaf075e1cb49929557fe62486f0538c5156441 100644 (file)
@@ -686,13 +686,19 @@ int main(int argc, char **argv)
                                break;
                        }
                }
-               else {
-                       BKE_read_file(argv[a], NULL);
-                       sound_initialize_sounds();
-                       
-                       /* happens for the UI on file reading too */
-                       BKE_reset_undo();
-                       BKE_write_undo("original");     /* save current state */
+               else {                  
+                       if (G.background) {
+                               BKE_read_file(argv[a], NULL);
+                               sound_initialize_sounds();
+
+                               /* happens for the UI on file reading too */
+                               BKE_reset_undo();
+                               BKE_write_undo("original");     /* save current state */
+                       } else {
+                               /* we are not running in background mode here, but start blender in UI mode with 
+                                  a file - this should do everything a 'load file' does */
+                               BIF_read_file(argv[a]);
+                       }                       
                }
        }