? user-def.mk ? dlltool/python23.dll.def ? dlltool/python24.dll.def ? obj/windows Index: dlltool/python.def =================================================================== RCS file: /cvsroot/bf-blender/blender/dlltool/python.def,v retrieving revision 1.8 diff -u -r1.8 python.def --- dlltool/python.def 27 Nov 2005 15:36:21 -0000 1.8 +++ dlltool/python.def 3 Dec 2005 00:37:55 -0000 @@ -6,6 +6,7 @@ PyArg_UnpackTuple PyArg_VaParse PyBaseObject_Type +PyBool_FromLong PyBool_Type PyBool_FromLong PyBuffer_FromMemory Index: source/blender/blenkernel/intern/softbody.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/softbody.c,v retrieving revision 1.59 diff -u -r1.59 softbody.c --- source/blender/blenkernel/intern/softbody.c 30 Nov 2005 18:58:10 -0000 1.59 +++ source/blender/blenkernel/intern/softbody.c 3 Dec 2005 00:38:07 -0000 @@ -83,6 +83,10 @@ #include "BIF_editdeform.h" +double PIL_check_seconds_timer (void); + +double glb_colsearchcost; + /* ********** soft body engine ******* */ typedef struct BodyPoint { @@ -155,6 +159,453 @@ } /*--- frame based timing ---*/ +/*+++ collider caching and dicing +++*/ + +/* 1rst idea ******************* +for each target object/face the ortho bounding box (OBB) is stored +faces paralell to global axes +so only simple "value" in [min,max] ckecks are used +float operations still +*/ + +/* another idea pending is: +split +typedef struct ccd_Mesh { +.. + MFace *mface; +.. +}ccd_Mesh; + +to--> +typedef struct ccd_Mesh { + int totvert, totface,totface001,totface001 ..; +.. + MFace *mface; + + MFace000 *mface; + MFace001 *mface; +.. +}ccd_Mesh; + +or even--> +typedef struct ccd_Mesh { + int totvert, totface, totfacelist; +.. + MFace *mface; + MFaceLists **mface; + +.. +}ccd_Mesh; + +copy MFace pointers to lists with +if {OBB of face touches list MFaceXXX} add to MFaceXXX +in order to have reduced lists to walk through, +this however needs a decition which list(s) to walk in sb_detect_collisionCached() +--> needs to balace 'householding costs <-> benefit gained' +*/ + +/* just an ID here to reduce the prob for killing objects +** ob->sumohandle points to we should not kill :) +*/ +const int CCD_SAVETY = 190561; + +typedef struct ccdf_minmax{ +float minx,miny,minz,maxx,maxy,maxz; +}ccdf_minmax; + + + +typedef struct ccd_Mesh { + int totvert, totface; + MVert *mvert; + MFace *mface; + int savety; + ccdf_minmax *mima; + float bbmin[3]; + float bbmax[3]; + +}ccd_Mesh; + + +/* +*** +*** seems not to be worth it +*** +void setup_dices(ccd_Mesh *pccd_M, float *bbmin,float *bbmax) +{ + MFace *mface=NULL; + ccdf_minmax *mima =NULL; + int i, + xpypzp, + xpypzn, + xpynzp, + xpynzn, + + xnypzp, + xnypzn, + xnynzp, + xnynzn; + + float mx,my,mz; + + xpypzp= + xpypzn= + xpynzp= + xpynzn= + + xnypzp= + xnypzn= + xnynzp= + xnynzn=0 + ; + + mx = (bbmax[0] + bbmin[0]) /2.0f; + my = (bbmax[1] + bbmin[1]) /2.0f; + mz = (bbmax[2] + bbmin[2]) /2.0f; + + if(pccd_M->totface == 0) return; + mface = pccd_M->mface; + mima = pccd_M->mima; + for(i=0; i < pccd_M->totface; i++,mface++,mima++ ){ + if (mima->maxx >= mx) { //needs adding to xp list + if (mima->maxy >= my) { //needs adding to xpyp list + if (mima->maxz >= mz) { //needs adding to xpypzp list + xpypzp++; + } + if (mima->minz <= mz) { //needs adding to xpypzn list + xpypzn++; + } + } + if (mima->miny <= my) { //needs adding to xpyn list + if (mima->maxz >= mz) { //needs adding to xpynzp list + xpynzp++; + } + if (mima->minz <= mz) { //needs adding to xpynzn list + xpynzn++; + } + } + + } + if (mima->minx <= mx) { //needs adding to xn list + if (mima->maxy >= my) { //needs adding to xpyn list + if (mima->maxz >= mz) { //needs adding to xnypzp list + xnypzp++; + } + if (mima->minz <= mz) { //needs adding to xnypzn list + xnypzn++; + } + } + if (mima->miny <= my) { //needs adding to xnyn list + if (mima->maxz >= mz) { //needs adding to xnynzp list + xnynzp++; + } + if (mima->minz <= mz) { //needs adding to xnynzn list + xnynzn++; + } + } + } + + } + +printf("xpypzp%d xpypzn%d xpynzp%d xpynzn%d xnypzp%d xnypzn%d xnynzp%d xnynzn%d totface%d\n", + xpypzp, + xpypzn, + xpynzp, + xpynzn, + + xnypzp, + xnypzn, + xnynzp, + xnynzn, + pccd_M->totface +); +} +*/ + + +ccd_Mesh *ccd_mesh_make_self(Object *ob) +{ + SoftBody *sb; + BodyPoint *bp; + + ccd_Mesh *pccd_M = NULL; + ccdf_minmax *mima =NULL; + MFace *mface=NULL; + float v[3],hull; + int i; + + Mesh *me= ob->data; + sb=ob->soft; + + + /* first some paranoia checks */ + if (!me) return NULL; + if ((!me->totface) || (!me->totvert)) return NULL; + + pccd_M = MEM_mallocN(sizeof(ccd_Mesh),"ccd_Mesh"); + pccd_M->totvert = me->totvert; + pccd_M->totface = me->totface; + 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; + + + /* blow it up with forcefield ranges */ + hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); + + /* alloc and copy verts*/ + pccd_M->mvert = MEM_mallocN(sizeof(MVert)*pccd_M->totvert,"ccd_Mesh_Vert"); + /* ah yeah, put the verices to global coords once */ + /* and determine the ortho BB on the fly */ + bp=sb->bpoint; + for(i=0; i < pccd_M->totvert; i++,bp++){ + VECCOPY(pccd_M->mvert[i].co,bp->pos); + //Mat4MulVecfl(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); + pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); + pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2],v[2]-hull); + + pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0],v[0]+hull); + pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); + pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); + + } + /* alloc and copy faces*/ + pccd_M->mface = MEM_mallocN(sizeof(MFace)*pccd_M->totface,"ccd_Mesh_Faces"); + memcpy(pccd_M->mface,me->mface,sizeof(MFace)*pccd_M->totface); + + /* OBBs for idea1 */ + pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima"); + mima = pccd_M->mima; + mface = pccd_M->mface; + + + /* anyhoo we need to walk the list of faces and find OBB they live in */ + for(i=0; i < pccd_M->totface; i++){ + mima->minx=mima->miny=mima->minz=1e30f; + mima->maxx=mima->maxy=mima->maxz=-1e30f; + + VECCOPY(v,pccd_M->mvert[mface->v1].co); + mima->minx = MIN2(mima->minx,v[0]-hull); + mima->miny = MIN2(mima->miny,v[1]-hull); + mima->minz = MIN2(mima->minz,v[2]-hull); + mima->maxx = MAX2(mima->maxx,v[0]+hull); + mima->maxy = MAX2(mima->maxy,v[1]+hull); + mima->maxz = MAX2(mima->maxz,v[2]+hull); + + VECCOPY(v,pccd_M->mvert[mface->v2].co); + mima->minx = MIN2(mima->minx,v[0]-hull); + mima->miny = MIN2(mima->miny,v[1]-hull); + mima->minz = MIN2(mima->minz,v[2]-hull); + mima->maxx = MAX2(mima->maxx,v[0]+hull); + mima->maxy = MAX2(mima->maxy,v[1]+hull); + mima->maxz = MAX2(mima->maxz,v[2]+hull); + + VECCOPY(v,pccd_M->mvert[mface->v3].co); + mima->minx = MIN2(mima->minx,v[0]-hull); + mima->miny = MIN2(mima->miny,v[1]-hull); + mima->minz = MIN2(mima->minz,v[2]-hull); + mima->maxx = MAX2(mima->maxx,v[0]+hull); + mima->maxy = MAX2(mima->maxy,v[1]+hull); + mima->maxz = MAX2(mima->maxz,v[2]+hull); + + if(mface->v4){ + VECCOPY(v,pccd_M->mvert[mface->v4].co); + mima->minx = MIN2(mima->minx,v[0]-hull); + mima->miny = MIN2(mima->miny,v[1]-hull); + mima->minz = MIN2(mima->minz,v[2]-hull); + mima->maxx = MAX2(mima->maxx,v[0]+hull); + mima->maxy = MAX2(mima->maxy,v[1]+hull); + mima->maxz = MAX2(mima->maxz,v[2]+hull); + } + + + mima++; + mface++; + + } + return pccd_M; +} + + +ccd_Mesh *ccd_mesh_make(Object *ob, DispListMesh *dm) +{ + ccd_Mesh *pccd_M = NULL; + ccdf_minmax *mima =NULL; + MFace *mface=NULL; + float v[3],hull; + int i; + + /* first some paranoia checks */ + if (!dm) return NULL; + if ((!dm->totface) || (!dm->totvert)) return NULL; + + pccd_M = MEM_mallocN(sizeof(ccd_Mesh),"ccd_Mesh"); + pccd_M->totvert = dm->totvert; + pccd_M->totface = dm->totface; + 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; + + + /* blow it up with forcefield ranges */ + hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); + + /* alloc and copy verts*/ + pccd_M->mvert = MEM_mallocN(sizeof(MVert)*pccd_M->totvert,"ccd_Mesh_Vert"); + memcpy(pccd_M->mvert,dm->mvert,sizeof(MVert)*pccd_M->totvert); + /* ah yeah, put the verices to global coords once */ + /* and determine the ortho BB on the fly */ + for(i=0; i < pccd_M->totvert; i++){ + Mat4MulVecfl(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); + pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); + pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2],v[2]-hull); + + pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0],v[0]+hull); + pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); + pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); + + } + /* alloc and copy faces*/ + pccd_M->mface = MEM_mallocN(sizeof(MFace)*pccd_M->totface,"ccd_Mesh_Faces"); + memcpy(pccd_M->mface,dm->mface,sizeof(MFace)*pccd_M->totface); + + /* OBBs for idea1 */ + pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima"); + mima = pccd_M->mima; + mface = pccd_M->mface; + + + /* anyhoo we need to walk the list of faces and find OBB they live in */ + for(i=0; i < pccd_M->totface; i++){ + mima->minx=mima->miny=mima->minz=1e30f; + mima->maxx=mima->maxy=mima->maxz=-1e30f; + + VECCOPY(v,pccd_M->mvert[mface->v1].co); + mima->minx = MIN2(mima->minx,v[0]-hull); + mima->miny = MIN2(mima->miny,v[1]-hull); + mima->minz = MIN2(mima->minz,v[2]-hull); + mima->maxx = MAX2(mima->maxx,v[0]+hull); + mima->maxy = MAX2(mima->maxy,v[1]+hull); + mima->maxz = MAX2(mima->maxz,v[2]+hull); + + VECCOPY(v,pccd_M->mvert[mface->v2].co); + mima->minx = MIN2(mima->minx,v[0]-hull); + mima->miny = MIN2(mima->miny,v[1]-hull); + mima->minz = MIN2(mima->minz,v[2]-hull); + mima->maxx = MAX2(mima->maxx,v[0]+hull); + mima->maxy = MAX2(mima->maxy,v[1]+hull); + mima->maxz = MAX2(mima->maxz,v[2]+hull); + + VECCOPY(v,pccd_M->mvert[mface->v3].co); + mima->minx = MIN2(mima->minx,v[0]-hull); + mima->miny = MIN2(mima->miny,v[1]-hull); + mima->minz = MIN2(mima->minz,v[2]-hull); + mima->maxx = MAX2(mima->maxx,v[0]+hull); + mima->maxy = MAX2(mima->maxy,v[1]+hull); + mima->maxz = MAX2(mima->maxz,v[2]+hull); + + if(mface->v4){ + VECCOPY(v,pccd_M->mvert[mface->v4].co); + mima->minx = MIN2(mima->minx,v[0]-hull); + mima->miny = MIN2(mima->miny,v[1]-hull); + mima->minz = MIN2(mima->minz,v[2]-hull); + mima->maxx = MAX2(mima->maxx,v[0]+hull); + mima->maxy = MAX2(mima->maxy,v[1]+hull); + mima->maxz = MAX2(mima->maxz,v[2]+hull); + } + + + mima++; + mface++; + + } + return pccd_M; +} + +void ccd_mesh_free(ccd_Mesh *ccdm) +{ + if(ccdm && (ccdm->savety == CCD_SAVETY )){ /*make sure we're not nuking objects we don't know*/ + MEM_freeN(ccdm->mface); + MEM_freeN(ccdm->mvert); + MEM_freeN(ccdm->mima); + MEM_freeN(ccdm); + ccdm = NULL; + } +} + +void free_sumo_handles() +{ + Base *base; + for(base= G.scene->base.first; base; base= base->next) { + if(base->object->sumohandle) { + ccd_mesh_free(base->object->sumohandle); + base->object->sumohandle= NULL; + } + } + +} + +void ccd_build_deflector_cache(Object *vertexowner) +{ + Base *base; + Object *ob; + base= G.scene->base.first; + base= G.scene->base.first; + while (base) { + /*Only proceed for mesh object in same layer */ + if(base->object->type==OB_MESH && (base->lay & vertexowner->lay)) { + ob= base->object; + if((vertexowner) && (ob == vertexowner)){ + /* duuh thats myself! */ + /* anyhow to some clever caching with o frozen version */ + if(ob->pd && ob->pd->deflect) { + ob->sumohandle=ccd_mesh_make_self(ob); + } + /* if vertexowner is given we don't want to check collision with owner object */ + base = base->next; + continue; + } + + /*+++ only with deflecting set */ + if(ob->pd && ob->pd->deflect) { + DerivedMesh *dm= NULL; + int dmNeedsFree; + + if(1) { /* so maybe someone wants overkill to collide with subsurfed */ + dm = mesh_get_derived_deform(ob, &dmNeedsFree); + } else { + dm = mesh_get_derived_final(ob, &dmNeedsFree); + } + if(dm){ + DispListMesh *disp_mesh= NULL; + disp_mesh = dm->convertToDispListMesh(dm, 0); + ob->sumohandle=ccd_mesh_make(ob,disp_mesh); + /* we did copy & modify all we need so give 'em away again */ + if (disp_mesh) { + displistmesh_free(disp_mesh); + } + if (dm) { + if (dmNeedsFree) dm->release(dm); + } + + } + }/*--- only with deflecting set */ + + }/* mesh && layer*/ + base = base->next; + } /* while (base) */ +} + +/*--- collider caching and dicing ---*/ + static int count_mesh_quads(Mesh *me) { @@ -346,6 +797,192 @@ /* ************ dynamics ********** */ + +/* the most general (micro physics correct) way to do collision +** (only needs the current particle position) +** +** it actually checks if the particle intrudes a short range force field generated +** by the faces of the target object and returns a force to drive the particel out +** the strenght of the field grows exponetially if the particle is on the 'wrong' side of the face +** 'wrong' side : projection to the face normal is negative (all referred to a vertex in the face) +** +** flaw of this: 'fast' particles as well as 'fast' colliding faces +** give a 'tunnel' effect such that the particle passes through the force field +** without ever 'seeing' it +** this is fully compliant to heisenberg: h >= fuzzy(location) * fuzzy(time) +** besides our h is way larger than in QM because forces propagate way slower here +** we have to deal with fuzzy(time) in the range of 1/25 seconds (typical frame rate) +** yup collision targets are not known here any better +** and 1/25 second is looong compared to real collision events +** Q: why not use 'simple' collision here like bouncing back a particle +** --> reverting is velocity on the face normal +** A: because our particles are not alone here +** and need to tell their neighbours exactly what happens via spring forces +** unless sbObjectStep( .. ) is called on sub frame timing level +** BTW that also questions the use of a 'implicit' solvers on softbodies +** since that would only valid for 'slow' moving collision targets and dito particles +*/ + +int sb_detect_collisionCached(float opco[3], float facenormal[3], float *damp, + float force[3], unsigned int par_layer,struct Object *vertexowner) +{ + Base *base; + Object *ob; + float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3],d_nvect[3], dv1[3], dv2[3], + facedist,n_mag,t,force_mag_norm,minx,miny,minz,maxx,maxy,maxz, + innerfacethickness = -0.5f, outerfacethickness = 0.2f, + ee = 5.0f, ff = 0.1f, fa; + int a, deflected=0; + + base= G.scene->base.first; + while (base) { + /*Only proceed for mesh object in same layer */ + if(base->object->type==OB_MESH && (base->lay & par_layer)) { + ob= base->object; + if((vertexowner) && (ob == vertexowner)){ + /* if vertexowner is given we don't want to check collision with owner object */ + base = base->next; + continue; + } + + /* only with deflecting set */ + if(ob->pd && ob->pd->deflect) { + DerivedMesh *dm= NULL; + DispListMesh *disp_mesh= NULL; + MFace *mface= NULL; + MVert *mvert= NULL; + ccdf_minmax *mima= NULL; + + + if(ob->sumohandle){ + ccd_Mesh *ccdm=ob->sumohandle; + mface= ccdm->mface; + mvert= ccdm->mvert; + mima= ccdm->mima; + a = ccdm->totface; + + minx =ccdm->bbmin[0]; + miny =ccdm->bbmin[1]; + minz =ccdm->bbmin[2]; + + maxx =ccdm->bbmax[0]; + maxy =ccdm->bbmax[1]; + maxz =ccdm->bbmax[2]; + + if ((opco[0] < minx) || + (opco[1] < miny) || + (opco[2] < minz) || + (opco[0] > maxx) || + (opco[1] > maxy) || + (opco[2] > maxz) ) { + /* outside the padded boundbox --> collision object is too far away */ + base = base->next; + continue; + } + } + else{ + /*aye that should be cached*/ + printf("missing cache error \n"); + base = base->next; + continue; + } + + /* do object level stuff */ + /* need to have user control for that since it depends on model scale */ + innerfacethickness =-ob->pd->pdef_sbift; + outerfacethickness =ob->pd->pdef_sboft; + fa = (ff*outerfacethickness-outerfacethickness); + fa *= fa; + fa = 1.0f/fa; + + /* use mesh*/ + while (a--) { + + if ( + (opco[0] < mima->minx) || + (opco[0] > mima->maxx) || + (opco[1] < mima->miny) || + (opco[1] > mima->maxy) || + (opco[2] < mima->minz) || + (opco[2] > mima->maxz) + ) { + mface++; + mima++; + continue; + } + + if (mvert){ + + VECCOPY(nv1,mvert[mface->v1].co); + VECCOPY(nv2,mvert[mface->v2].co); + VECCOPY(nv3,mvert[mface->v3].co); + if (mface->v4){ + VECCOPY(nv4,mvert[mface->v4].co); + } + } + + + + /* switch origin to be nv2*/ + VECSUB(edge1, nv1, nv2); + VECSUB(edge2, nv3, nv2); + VECSUB(dv1,opco,nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */ + + Crossf(d_nvect, edge2, edge1); + n_mag = Normalise(d_nvect); + facedist = Inpf(dv1,d_nvect); + + if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ + dv2[0] = opco[0] - 2.0f*facedist*d_nvect[0]; + dv2[1] = opco[1] - 2.0f*facedist*d_nvect[1]; + dv2[2] = opco[2] - 2.0f*facedist*d_nvect[2]; + if ( LineIntersectsTriangle( opco, dv2, nv1, nv2, nv3, &t)){ + force_mag_norm =(float)exp(-ee*facedist); + if (facedist > outerfacethickness*ff) + force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness); + Vec3PlusStVec(force,force_mag_norm,d_nvect); + *damp=ob->pd->pdef_sbdamp; + deflected = 2; + } + } + if (mface->v4){ /* quad */ + /* switch origin to be nv4 */ + VECSUB(edge1, nv3, nv4); + VECSUB(edge2, nv1, nv4); + VECSUB(dv1,opco,nv4); /* abuse dv1 to have vertex in question at *origin* of triangle */ + + Crossf(d_nvect, edge2, edge1); + n_mag = Normalise(d_nvect); + facedist = Inpf(dv1,d_nvect); + + if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ + dv2[0] = opco[0] - 2.0f*facedist*d_nvect[0]; + dv2[1] = opco[1] - 2.0f*facedist*d_nvect[1]; + dv2[2] = opco[2] - 2.0f*facedist*d_nvect[2]; + if (LineIntersectsTriangle( opco, dv2, nv1, nv3, nv4, &t)){ + force_mag_norm =(float)exp(-ee*facedist); + if (facedist > outerfacethickness*ff) + force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness); + Vec3PlusStVec(force,force_mag_norm,d_nvect); + *damp=ob->pd->pdef_sbdamp; + deflected = 2; + } + + } + } + mface++; + mima++; + }/* while a */ + /* give it away */ + } /* if(ob->pd && ob->pd->deflect) */ + }/* if (base->object->type==OB_MESH && (base->lay & par_layer)) { */ + base = base->next; + } /* while (base) */ + + return deflected; + +} + int sb_detect_collision(float opco[3], float facenormal[3], float *damp, float force[3], unsigned int par_layer,struct Object *vertexowner) { @@ -496,16 +1133,29 @@ v[2] += s*v1[2]; } -static int sb_deflect_face(Object *ob,float *actpos, float *futurepos,float *collisionpos, float *facenormal,float *force,float *cf ) +static int sb_deflect_face(Object *ob,float *actpos, float *futurepos,float *collisionpos, float *facenormal,float *force,float *cf) { + double startX,endX; + int deflected; float s_actpos[3], s_futurepos[3]; + VECCOPY(s_actpos,actpos); if(futurepos) VECCOPY(s_futurepos,futurepos); +startX=PIL_check_seconds_timer(); + +if(G.rt !=666) + deflected= sb_detect_collisionCached(s_actpos, facenormal, cf, force , ob->lay, ob); +else deflected= sb_detect_collision(s_actpos, facenormal, cf, force , ob->lay, ob); + +endX=PIL_check_seconds_timer(); +glb_colsearchcost += endX - startX; + + return(deflected); } @@ -703,6 +1353,8 @@ } + + static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *err) { /* time evolution */ @@ -800,7 +1452,12 @@ } } - +/* care for bodypoints taken out of the 'ordinary' solver step +** because they are screwed to goal by bolts +** they just need to move along with the goal in time +** we need to adjust them on sub frame timing in solver +** so now when frame is done .. put 'em to the position at the end of frame +*/ static void softbody_apply_goalsnap(Object *ob) { SoftBody *sb= ob->soft; /* is supposed to be there */ @@ -1391,7 +2048,7 @@ BodyPoint *bp; int a; float dtime,ctime,forcetime,err; - + /* baking works with global time */ if(!(ob->softflag & OB_SB_BAKEDO) ) if(softbody_baked_step(ob, framenr, vertexCos, numVerts) ) return; @@ -1432,8 +2089,6 @@ /* still no points? go away */ if(sb->totpoint==0) return; - /* reset deflector cache, sumohandle is free, but its still sorta abuse... (ton) */ - /* we don't use that any more (BM) */ /* checking time: */ @@ -1495,15 +2150,27 @@ ob->softflag &= ~OB_SB_RESET; } else if(dtime>0.0) { + + double startX,endX; + + startX=PIL_check_seconds_timer(); + glb_colsearchcost = 0; + /* reset deflector cache, sumohandle is free, but its still sorta abuse... (ton) */ +if(G.rt !=666) +{ + free_sumo_handles(); + ccd_build_deflector_cache(ob); +} + if (TRUE) { /* */ /* special case of 2nd order Runge-Kutta type AKA Heun */ float timedone =0.0; /* how far did we get without violating error condition */ - /* loops = counter for emergency brake - * we don't want to lock up the system if physics fail - */ + /* loops = counter for emergency brake + * we don't want to lock up the system if physics fail + */ int loops =0 ; SoftHeunTol = sb->rklimit; /* humm .. this should be calculated from sb parameters and sizes */ - + forcetime = dtime; /* hope for integrating in one step */ while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) { @@ -1516,7 +2183,7 @@ softbody_calc_forces(ob, forcetime); softbody_apply_forces(ob, forcetime, 2, &err); softbody_apply_goalsnap(ob); - + if (err > SoftHeunTol){ /* error needs to be scaled to some quantity */ softbody_restore_prev_step(ob); forcetime /= 2.0; @@ -1538,24 +2205,30 @@ /* move snapped to final position */ interpolate_exciter(ob, 2, 2); softbody_apply_goalsnap(ob); - + + endX=PIL_check_seconds_timer(); + if(G.f & G_DEBUG) { if (loops > HEUNWARNLIMIT) /* monitor high loop counts say 1000 after testing */ - printf("%d heun integration loops/frame \n",loops); + printf("%d heun integration loops/frame %f %f\n",loops,endX- startX,glb_colsearchcost); } + } else{ /* do brute force explicit euler */ /* removed but left this branch for better integrators / solvers (BM) */ /* yah! Nicholas Guttenberg (NichG) here is the place to plug in */ } + /* reset deflector cache */ +if(G.rt !=666) +{ + free_sumo_handles(); +} } softbody_to_object(ob, vertexCos, numVerts); sb->ctime= ctime; - /* reset deflector cache */ - /* we don't use that any more (BM) */ if(ob->softflag & OB_SB_BAKEDO) softbody_baked_add(ob, framenr); } Index: source/blender/makesdna/DNA_space_types.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_space_types.h,v retrieving revision 1.38 diff -u -r1.38 DNA_space_types.h --- source/blender/makesdna/DNA_space_types.h 22 Nov 2005 15:00:32 -0000 1.38 +++ source/blender/makesdna/DNA_space_types.h 3 Dec 2005 00:38:09 -0000 @@ -312,7 +312,7 @@ short orgx, orgy, orgd, anim; /* same as ibuf->x...*/ char dummy[4]; /* 128 */ - char pict_rect[3968]; /* 4096 (RECT = 64 * 62) */ + char pict_rect[15872]; /* 16384 (RECT = 128 * 124) */ } OneSelectableIma; Index: source/blender/src/buttons_scene.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_scene.c,v retrieving revision 1.99 diff -u -r1.99 buttons_scene.c --- source/blender/src/buttons_scene.c 23 Nov 2005 15:20:45 -0000 1.99 +++ source/blender/src/buttons_scene.c 3 Dec 2005 00:38:13 -0000 @@ -1103,9 +1103,9 @@ uiBlockBeginAlign(block); uiDefButBitI(block, TOG, R_OSA, 0, "OSA", 369,109,122,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)"); - uiDefButS(block, ROW,B_DIFF,"5", 369,88,29,20,&G.scene->r.osa,2.0,5.0, 0, 0, "Sets oversample level to 5"); - uiDefButS(block, ROW,B_DIFF,"8", 400,88,29,20,&G.scene->r.osa,2.0,8.0, 0, 0, "Sets oversample level to 8 (Recommended)"); - uiDefButS(block, ROW,B_DIFF,"11", 431,88,29,20,&G.scene->r.osa,2.0,11.0, 0, 0, "Sets oversample level to 11"); + uiDefButS(block, ROW,B_DIFF,"1", 369,88,29,20,&G.scene->r.osa,2.0,1.0, 0, 0, "Sets oversample level to 1"); + uiDefButS(block, ROW,B_DIFF,"5", 400,88,29,20,&G.scene->r.osa,2.0,5.0, 0, 0, "Sets oversample level to 5"); + uiDefButS(block, ROW,B_DIFF,"8", 431,88,29,20,&G.scene->r.osa,2.0,8.0, 0, 0, "Sets oversample level to 8 (Recommended)"); uiDefButS(block, ROW,B_DIFF,"16", 462,88,29,20,&G.scene->r.osa,2.0,16.0, 0, 0, "Sets oversample level to 16"); uiBlockEndAlign(block); @@ -1137,11 +1137,13 @@ uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefButS(block, ROW,B_DIFF,"100%", 565,109,122,20,&G.scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size"); + + uiDefButS(block, ROW,B_DIFF,"400%", 565,109,40,20,&G.scene->r.size,1.0,400.0, 0, 0, "Set render size to defined size X4"); + uiDefButS(block, ROW,B_DIFF,"200%", 606,109,40,20,&G.scene->r.size,1.0,200.0, 0, 0, "Set render size to defined size X2"); + uiDefButS(block, ROW,B_DIFF,"100%", 647,109,40,20,&G.scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size"); uiDefButS(block, ROW,B_DIFF,"75%", 565,88,40,20,&G.scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size"); uiDefButS(block, ROW,B_DIFF,"50%", 606,88,40,20,&G.scene->r.size,1.0,50.0, 0, 0, "Set render size to 1/2 of defined size"); uiDefButS(block, ROW,B_DIFF,"25%", 647,88,40,20,&G.scene->r.size,1.0,25.0, 0, 0, "Set render size to 1/4 of defined size"); - uiBlockEndAlign(block); uiBlockBeginAlign(block); uiDefButBitI(block, TOG, R_FIELDS, 0,"Fields", 565,55,60,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering"); Index: source/blender/src/buttons_shading.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_shading.c,v retrieving revision 1.158 diff -u -r1.158 buttons_shading.c --- source/blender/src/buttons_shading.c 27 Nov 2005 12:19:12 -0000 1.158 +++ source/blender/src/buttons_shading.c 3 Dec 2005 00:38:22 -0000 @@ -1968,7 +1968,7 @@ uiDefButS(block, ROW, B_REDR, "Sky Texture", 210, 25, 100, 20, &wrld->aocolor, 2.0, (float)WO_AOSKYTEX, 0, 0, "Does full Sky texture render for diffuse energy"); uiBlockBeginAlign(block); - uiDefButF(block, NUMSLI, B_REDR, "Energy:", 10, 0, 150, 19, &wrld->aoenergy, 0.01, 3.0, 100, 0, "Sets global energy scale for AO"); + uiDefButF(block, NUMSLI, B_REDR, "Energy:", 10, 0, 150, 19, &wrld->aoenergy, 0.01, 10.0, 100, 0, "Sets global energy scale for AO"); uiDefButF(block, NUMSLI, B_REDR, "Bias:", 160, 0, 150, 19, &wrld->aobias, 0.0, 0.5, 10, 0, "Sets bias to prevent smoothed faces to show banding (in radians)"); } Index: source/blender/src/drawimasel.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/drawimasel.c,v retrieving revision 1.19 diff -u -r1.19 drawimasel.c --- source/blender/src/drawimasel.c 4 Aug 2005 22:36:21 -0000 1.19 +++ source/blender/src/drawimasel.c 3 Dec 2005 00:38:24 -0000 @@ -217,7 +217,7 @@ ima->selectable = 0; if (ima->draw_me) { - if ((mx > ima->sx) && (mx < ima->sx+76) && (my > ima->sy-16) && (my < ima->sy+76)) { + if ((mx > ima->sx) && (mx < ima->sx+152) && (my > ima->sy-32) && (my < ima->sy+152)) { ima->selectable = 1; simasel->hilite_ima = ima; simasel->mouse_move_redraw = 1; @@ -336,9 +336,9 @@ ima = simasel->first_sel_ima; - boxperline = (simasel->feex - simasel->fesx) / 80; + boxperline = (simasel->feex - simasel->fesx) / 160; if (boxperline) boxlines = 1 + (simasel->totalima / boxperline); else boxlines = 1; - boxlinesinview = (simasel->feey - simasel->fesy) / 100; + boxlinesinview = (simasel->feey - simasel->fesy) / 150; boxlinesleft = boxlines - boxlinesinview; if (boxlinesleft > 0){ @@ -362,10 +362,10 @@ simasel->imasli = 0; } - sc = simasel->image_slider * (boxlinesleft * 100); + sc = simasel->image_slider * (boxlinesleft * 150); simasel->curimax = simasel->fesx + 8; - simasel->curimay = simasel->feey - 90 + sc; + simasel->curimay = simasel->feey - 154 + sc; dm = 1; if (simasel->curimay-2 < simasel->fesy) dm = 0; @@ -385,17 +385,17 @@ ima->ex = ima->sx + ima->dw; ima->ey = ima->sy + ima->dh; - simasel->curimax += 80; - if (simasel->curimax + 72 > simasel->feex){ + simasel->curimax += 160; + if (simasel->curimax + 144 > simasel->feex){ - simasel->curimax = simasel->fesx + 8; - simasel->curimay -= 100; + simasel->curimax = simasel->fesx + 12; + simasel->curimay -= 150; dm = 1; // let icons that fall off (top/bottom) be selectable if(OLD_IMASEL) { - if (simasel->curimay+80 > simasel->feey) dm = 0; - if (simasel->curimay-8 < simasel->fesy) dm = 0; + if (simasel->curimay+160 > simasel->feey) dm = 0; + if (simasel->curimay-16 < simasel->fesy) dm = 0; } } @@ -564,7 +564,7 @@ sc = 0; sx = ima->sx- 6; sy = ima->sy-20 + sc; - ex = ima->sx+71; ey = ima->sy+70 + sc; + ex = ima->sx+133; ey = ima->sy+132 + sc; if(ima->selected == 1){ cpack(0xCC6666); @@ -599,7 +599,7 @@ strcpy(naam, ima->file_name); naam[11] = 0; - glRasterPos2i(sx+32-BMF_GetStringWidth(G.fonts, naam) / 2 , sy-16); + glRasterPos2i(sx+64-BMF_GetStringWidth(G.fonts, naam) / 2 , sy-16); BMF_DrawString(G.fonts, naam); if ((ima) && (ima->pict) && (ima->pict->rect)){ @@ -635,7 +635,7 @@ lrectwrite(sx, sy, sx+ (ima->ex - ima->sx)-1, sy+ (ima->ey - ima->sy)-1, ima->pict->rect); } else rectwrite_imasel(simasel->fesx, simasel->fesy, - curarea->winrct.xmax, curarea->winrct.ymax - 64, //simasel->feey*1.5, + curarea->winrct.xmax, curarea->winrct.ymax - 128, //simasel->feey*1.5, sx, sy, ima->pict->x, ima->pict->y, 2.0, 2.0, ima->pict->rect); glPixelZoom(1.0, 1.0); Index: source/blender/src/imasel.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/imasel.c,v retrieving revision 1.8 diff -u -r1.8 imasel.c --- source/blender/src/imasel.c 2 Apr 2005 15:36:57 -0000 1.8 +++ source/blender/src/imasel.c 3 Dec 2005 00:38:25 -0000 @@ -265,7 +265,7 @@ write_msb_short(file, ima->orgd); write_msb_short(file, ima->anim); write_msb_int(file, 0); /* pad to 128 boundary */ - write(file, ima->pict_rect, 3968); + write(file, ima->pict_rect, 15872); close(file); } @@ -510,11 +510,11 @@ // ima->orgd = ibuf->depth; if (ima->orgx > ima->orgy){ - ima->dw = 64; - ima->dh = (short)(62 * ((float)ima->orgy / (float)ima->orgx)); + ima->dw = 128; + ima->dh = (short)(124 * ((float)ima->orgy / (float)ima->orgx)); }else{ - ima->dw = (short)(64 * ((float)ima->orgx / (float)ima->orgy)); - ima->dh = 62; + ima->dw = (short)(128 * ((float)ima->orgx / (float)ima->orgy)); + ima->dh = 124; } } @@ -541,7 +541,7 @@ IMB_convert_rgba_to_abgr(ima->dw*ima->dh, ibuf->rect); ibuf->mincol = 0; - ibuf->maxcol = 256; + ibuf->maxcol = 255; ibuf->cbits = 5; ibuf->depth = 8; @@ -551,7 +551,7 @@ IMB_converttocmap(ibuf); /* copy ibuf->rect to ima->pict_rect */ - size = ima->dw * ima->dh; if (size > 3968) size = 3968; + size = ima->dw * ima->dh; if (size > 15872) size = 15872; longtochar(ima->pict_rect, ibuf->rect, size); IMB_applycmap(ibuf); @@ -601,16 +601,16 @@ ima->orgy = ibuf->y; ima->orgd = ibuf->depth; - ima->dw = 64; - ima->dh = 51; + ima->dw = 128; + ima->dh = 102; ima->cmap = 0; ima->image = 0; if (ima->orgx > ima->orgy){ - ima->dw = 64; - ima->dh = (short)(62 * ((float)ima->orgy / (float)ima->orgx)); + ima->dw = 128; + ima->dh = (short)(124 * ((float)ima->orgy / (float)ima->orgx)); }else{ - ima->dw = (short)(64 * ((float)ima->orgx / (float)ima->orgy)); - ima->dh = 62; + ima->dw = (short)(128 * ((float)ima->orgx / (float)ima->orgy)); + ima->dh = 124; } }else{ printf("%s image with no imbuf ???\n", name); @@ -622,12 +622,12 @@ ima->pict = 0; ima->anim = 1; ima->ibuf_type= 0; - ima->orgx = 64; - ima->orgy = 51; + ima->orgx = 128; + ima->orgy = 102; ima->orgd = 24; - ima->dw = 64; - ima->dh = 51; + ima->dw = 128; + ima->dh = 102; ima->cmap = 0; ima->image = 0; } @@ -769,7 +769,7 @@ rd+= read_msb_short(file, &ima->orgd); rd+= read_msb_short(file, &ima->anim); rd+= read_msb_int(file, NULL); - rd+= read(file, ima->pict_rect, 3968); + rd+= read(file, ima->pict_rect, 15872); found = 0; @@ -790,12 +790,12 @@ if (direntry->mtime == ima->mtime) { /* ima found and same, load pic */ size = ima->dw * ima->dh; - if (size > 3968) size = 3968; + if (size > 15872) size = 15872; if (size) { ima->pict = IMB_allocImBuf(ima->dw, ima->dh, 24, IB_rect | IB_cmap, 0); chartolong(ima->pict->rect, ima->pict_rect, size); ima->pict->cmap = simasel->cmap->cmap; - ima->pict->maxcol = 256; + ima->pict->maxcol = 255; IMB_applycmap(ima->pict); IMB_convert_rgba_to_abgr(size, ima->pict->rect); } Index: source/blender/src/renderwin.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/renderwin.c,v retrieving revision 1.61 diff -u -r1.61 renderwin.c --- source/blender/src/renderwin.c 28 Nov 2005 22:49:23 -0000 1.61 +++ source/blender/src/renderwin.c 3 Dec 2005 00:38:27 -0000 @@ -1,5 +1,9 @@ /** +<<<<<<< renderwin.c + * $Id: renderwin.c,v 1.59 2005/10/03 10:10:19 ton Exp $ +======= * $Id: renderwin.c,v 1.61 2005/11/28 22:49:23 ton Exp $ +>>>>>>> 1.61 * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * @@ -1072,6 +1076,8 @@ RE_initrender(ogl_render_view3d); } + scene_update_for_newframe(G.scene, G.scene->lay); // no redraw needed, this restores to view as we left it + if (render_win) window_set_cursor(render_win->win, CURSOR_STD); free_filesel_spec(G.scene->r.pic); @@ -1091,10 +1097,7 @@ allqueue(REDRAWBUTSSCENE, 0); // visualize fbuf for example } - R.flag= 0; // before scene update! - - scene_update_for_newframe(G.scene, G.scene->lay); // no redraw needed, this restores to view as we left it - + R.flag= 0; waitcursor(0); // waitcursor checks rendering R.flag... } @@ -1171,11 +1174,31 @@ G.scene->lay |= G.vd->lay; else G.scene->lay= G.vd->lay; +/*FakeProgressive*/ + if (G.displaymode==R_DISPLAYVIEW) { + G.scene->r.size= 15.0; do_render(NULL, anim, 0); - + G.scene->r.size= 40.0; + do_render(NULL, anim, 0); + G.scene->r.size= 100.0; + } +/*End FP*/ + do_render(NULL, anim, 0); + G.scene->lay= lay; } - else do_render(NULL, anim, 0); + else { + +/*FakeProgressive2*/ + if (G.displaymode==R_DISPLAYVIEW) { + G.scene->r.size= 15.0; + do_render(NULL, anim, 0); + G.scene->r.size= 40.0; + do_render(NULL, anim, 0); + G.scene->r.size= 100.0; + } +/*End FP2*/ + do_render(NULL, anim, 0);} if (slink_flag) G.f |= G_DOSCRIPTLINKS; if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_POSTRENDER);