diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-07-28 15:01:34 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-07-28 15:01:34 +0400 |
commit | 48b7f16d7630a7f6c66668e341f41cdb378754bf (patch) | |
tree | 0c924bf974c37a37ddf245a9a32d2dc7dea51fe9 /source/blender/blenkernel | |
parent | 1a370eaafc37df56881abf606d98f28ea3a85260 (diff) |
Phase1: fluidsim obstacles/control objects are grabbed from the specific position in modifier stack now (introducing new funciton in DerivedMesh.c), fixed some UI glitches.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_DerivedMesh.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_fluidsim.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 42 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fluidsim.c | 112 |
4 files changed, 41 insertions, 126 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index f61b300f708..e6162c7ff65 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -412,7 +412,10 @@ DerivedMesh *mesh_create_derived_for_modifier(struct Object *ob, struct Modifier DerivedMesh *mesh_create_derived_render(struct Object *ob, CustomDataMask dataMask); -/* same as above but wont use render settings */ + +DerivedMesh *mesh_create_derived_index_render(struct Object *ob, CustomDataMask dataMask, int index); + + /* same as above but wont use render settings */ DerivedMesh *mesh_create_derived_view(struct Object *ob, CustomDataMask dataMask); DerivedMesh *mesh_create_derived_no_deform(struct Object *ob, diff --git a/source/blender/blenkernel/BKE_fluidsim.h b/source/blender/blenkernel/BKE_fluidsim.h index a3a109a1aa6..33c706da82b 100644 --- a/source/blender/blenkernel/BKE_fluidsim.h +++ b/source/blender/blenkernel/BKE_fluidsim.h @@ -35,12 +35,9 @@ #include "BKE_DerivedMesh.h" /* old interface */ -FluidsimSettings *fluidsimSettingsNew(struct Object *srcob); +FluidsimSettings *fluidsimSettingsNew(Object *srcob); - -void initElbeemMesh(Object *ob, int *numVertices, float **vertices, int *numTriangles, int **triangles, int useGlobalCoords); - -void loadFluidsimMesh(Object *srcob, int useRenderParams); +void initElbeemMesh(Object *ob, int *numVertices, float **vertices, int *numTriangles, int **triangles, int useGlobalCoords, int modifierIndex); /* new fluid-modifier interface */ @@ -50,6 +47,7 @@ void fluidsim_free(FluidsimModifierData *fluidmd); DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams); DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc); +// get bounding box of mesh void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], /*RET*/ float start[3], /*RET*/ float size[3] ); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index bfd47f14009..7c0d73085eb 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1856,7 +1856,7 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm) static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform, - int needMapping, CustomDataMask dataMask) + int needMapping, CustomDataMask dataMask, int index) { Mesh *me = ob->data; ModifierData *firstmd, *md; @@ -1865,7 +1865,7 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], float (*deformedVerts)[3] = NULL; DerivedMesh *dm, *orcodm, *finaldm; int numVerts = me->totvert; - int required_mode; + int required_mode, i; md = firstmd = modifiers_getVirtualModifierList(ob); @@ -1888,7 +1888,7 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], deformedVerts = mesh_getVertexCos(me, &numVerts); /* Apply all leading deforming modifiers */ - for(; md; md = md->next, curr = curr->next) { + for(i = 0; md; md = md->next, curr = curr->next, i++) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if((md->mode & required_mode) != required_mode) continue; @@ -1902,6 +1902,10 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], } else { break; } + + /* grab modifiers until index i */ + if(i==index) + break; } /* Result of all leading deforming modifiers is cached for @@ -1948,7 +1952,7 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], if(me->vnode) dm = derivedmesh_from_versemesh(me->vnode, deformedVerts); #endif - for(; md; md = md->next, curr = curr->next) { + for(i = 0; md; md = md->next, curr = curr->next, i++) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if((md->mode & required_mode) != required_mode) continue; @@ -2054,6 +2058,10 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], } } } + + /* grab modifiers until index i */ + if(i==index) + break; } for(md=firstmd; md; md=md->next) @@ -2428,13 +2436,13 @@ static void mesh_build_data(Object *ob, CustomDataMask dataMask) mesh_calc_modifiers(ob, NULL, &ob->derivedDeform, &ob->derivedFinal, 0, 1, - needMapping, dataMask); + needMapping, dataMask, -1); CustomData_free_layer_active(&me->fdata, CD_MCOL, me->totface); } else { mesh_calc_modifiers(ob, NULL, &ob->derivedDeform, &ob->derivedFinal, G.rendering, 1, - needMapping, dataMask); + needMapping, dataMask, -1); } INIT_MINMAX(min, max); @@ -2605,7 +2613,21 @@ DerivedMesh *mesh_create_derived_render(Object *ob, CustomDataMask dataMask) int orig_lvl= 0; vert_copy= multires_render_pin(ob, me, &orig_lvl); - mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1, 0, dataMask); + mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1, 0, dataMask, -1); + multires_render_final(ob, me, &final, vert_copy, orig_lvl, dataMask); + + return final; +} + +DerivedMesh *mesh_create_derived_index_render(Object *ob, CustomDataMask dataMask, int index) +{ + DerivedMesh *final; + Mesh *me= get_mesh(ob); + float *vert_copy= NULL; + int orig_lvl= 0; + + vert_copy= multires_render_pin(ob, me, &orig_lvl); + mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1, 0, dataMask, index); multires_render_final(ob, me, &final, vert_copy, orig_lvl, dataMask); return final; @@ -2615,7 +2637,7 @@ DerivedMesh *mesh_create_derived_view(Object *ob, CustomDataMask dataMask) { DerivedMesh *final; - mesh_calc_modifiers(ob, NULL, NULL, &final, 0, 1, 0, dataMask); + mesh_calc_modifiers(ob, NULL, NULL, &final, 0, 1, 0, dataMask, -1); return final; } @@ -2625,7 +2647,7 @@ DerivedMesh *mesh_create_derived_no_deform(Object *ob, float (*vertCos)[3], { DerivedMesh *final; - mesh_calc_modifiers(ob, vertCos, NULL, &final, 0, 0, 0, dataMask); + mesh_calc_modifiers(ob, vertCos, NULL, &final, 0, 0, 0, dataMask, -1); return final; } @@ -2640,7 +2662,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(Object *ob, int orig_lvl= 0; vert_copy= multires_render_pin(ob, me, &orig_lvl); - mesh_calc_modifiers(ob, vertCos, NULL, &final, 1, 0, 0, dataMask); + mesh_calc_modifiers(ob, vertCos, NULL, &final, 1, 0, 0, dataMask, -1); multires_render_final(ob, me, &final, vert_copy, orig_lvl, dataMask); return final; diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 032dc7f44ed..fb0f3975529 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -511,118 +511,10 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], // file handling //------------------------------------------------------------------------------- - -/* write .bobj.gz file for a mesh object */ -void writeBobjgz(char *filename, struct Object *ob, int useGlobalCoords, int append, float time) -{ - int wri,i,j,totvert,totface; - float wrf; - gzFile gzf; - DerivedMesh *dm; - float vec[3]; - float rotmat[3][3]; - MVert *mvert; - MFace *mface; - //if(append)return; // DEBUG - - if(!ob->data || (ob->type!=OB_MESH)) - { - return; - } - if((ob->size[0]<0.0) || (ob->size[0]<0.0) || (ob->size[0]<0.0) ) - { - return; - } - - if(append) gzf = gzopen(filename, "a+b9"); - else gzf = gzopen(filename, "wb9"); - - if (!gzf) - return; - - dm = mesh_create_derived_render(ob, CD_MASK_BAREMESH); - //dm = mesh_create_derived_no_deform(ob,NULL); - - mvert = dm->getVertArray(dm); - mface = dm->getFaceArray(dm); - totvert = dm->getNumVerts(dm); - totface = dm->getNumFaces(dm); - - // write time value for appended anim mesh - if(append) - { - gzwrite(gzf, &time, sizeof(time)); - } - - // continue with verts/norms - if(sizeof(wri)!=4) { return; } // paranoia check - wri = dm->getNumVerts(dm); - mvert = dm->getVertArray(dm); - gzwrite(gzf, &wri, sizeof(wri)); - for(i=0; i<wri;i++) - { - VECCOPY(vec, mvert[i].co); - if(useGlobalCoords) { Mat4MulVecfl(ob->obmat, vec); } - for(j=0; j<3; j++) { - wrf = vec[j]; - gzwrite(gzf, &wrf, sizeof( wrf )); - } - } - - // should be the same as Vertices.size - wri = totvert; - gzwrite(gzf, &wri, sizeof(wri)); - EulToMat3(ob->rot, rotmat); - for(i=0; i<wri;i++) - { - VECCOPY(vec, mvert[i].no); - Normalize(vec); - if(useGlobalCoords) { Mat3MulVecfl(rotmat, vec); } - for(j=0; j<3; j++) { - wrf = vec[j]; - gzwrite(gzf, &wrf, sizeof( wrf )); - } - } - - // append only writes verts&norms - if(!append) { - // compute no. of triangles - wri = 0; - for(i=0; i<totface; i++) - { - wri++; - if(mface[i].v4) { wri++; } - } - gzwrite(gzf, &wri, sizeof(wri)); - for(i=0; i<totface; i++) - { - - int face[4]; - face[0] = mface[i].v1; - face[1] = mface[i].v2; - face[2] = mface[i].v3; - face[3] = mface[i].v4; - - gzwrite(gzf, &(face[0]), sizeof( face[0] )); - gzwrite(gzf, &(face[1]), sizeof( face[1] )); - gzwrite(gzf, &(face[2]), sizeof( face[2] )); - if(face[3]) - { - gzwrite(gzf, &(face[0]), sizeof( face[0] )); - gzwrite(gzf, &(face[2]), sizeof( face[2] )); - gzwrite(gzf, &(face[3]), sizeof( face[3] )); - } // quad - } - } - - gzclose( gzf ); - dm->release(dm); -} - void initElbeemMesh(struct Object *ob, int *numVertices, float **vertices, int *numTriangles, int **triangles, - int useGlobalCoords) + int useGlobalCoords, int modifierIndex) { DerivedMesh *dm = NULL; MVert *mvert; @@ -631,7 +523,7 @@ void initElbeemMesh(struct Object *ob, float *verts; int *tris; - dm = mesh_create_derived_render(ob, CD_MASK_BAREMESH); + dm = mesh_create_derived_index_render(ob, CD_MASK_BAREMESH, modifierIndex); //dm = mesh_create_derived_no_deform(ob,NULL); mvert = dm->getVertArray(dm); |