This commit is contained in:
Daniel Genrich
2007-11-24 22:49:56 +00:00
16 changed files with 164 additions and 72 deletions

View 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;

View 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

View 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);
}

View 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);

View 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])
{

View 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,

View 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 */

View 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)

View 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

View 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;

View 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;
}

View 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)

View 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);
}

View 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)

View 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();

View 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]);
}
}
}