Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-07-25 14:51:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-07-25 14:51:24 +0400
commit9e134507a78a1bf467e6157b26a282cc67ce27dd (patch)
tree240fba4e3795947af7d854b46c5754fa965bd8e3 /source/blender/blenkernel/intern
parentaed306f2197d4cbf1738db46b88eb30646c2cbbf (diff)
sync with r37500, fix for merge, bmesh builds again.
also some compiler warning fix.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/displist.c502
-rw-r--r--source/blender/blenkernel/intern/object.c38
-rw-r--r--source/blender/blenkernel/intern/particle_system.c30
3 files changed, 539 insertions, 31 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 8f57490d057..eda18baf8fa 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -65,6 +65,9 @@
#include "BKE_lattice.h"
#include "BKE_modifier.h"
+#include "RE_pipeline.h"
+#include "RE_shader_ext.h"
+
#include "BLO_sys_types.h" // for intptr_t support
#include "ED_curve.h" /* for BKE_curve_nurbs */
@@ -283,6 +286,499 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i
return 1;
}
+/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */
+
+/* create default shade input... save cpu cycles with ugly global */
+/* XXXX bad code warning: local ShadeInput initialize... */
+static ShadeInput shi;
+static void init_fastshade_shadeinput(Render *re)
+{
+ memset(&shi, 0, sizeof(ShadeInput));
+ shi.lay= RE_GetScene(re)->lay;
+ shi.view[2]= -1.0f;
+ shi.passflag= SCE_PASS_COMBINED;
+ shi.combinedflag= -1;
+}
+
+static Render *fastshade_get_render(Scene *UNUSED(scene))
+{
+ // XXX 2.5: this crashes combined with previewrender
+ // due to global R so disabled for now
+#if 0
+ /* XXX ugly global still, but we can't do preview while rendering */
+ if(G.rendering==0) {
+
+ Render *re= RE_GetRender("_Shade View_");
+ if(re==NULL) {
+ re= RE_NewRender("_Shade View_");
+
+ RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */
+ }
+ return re;
+ }
+#endif
+
+ return NULL;
+}
+
+/* called on file reading */
+void fastshade_free_render(void)
+{
+ Render *re= RE_GetRender("_Shade View_");
+
+ if(re) {
+ RE_Database_Free(re);
+ RE_FreeRender(re);
+ }
+}
+
+
+static void fastshade_customdata(CustomData *fdata, int a, int j, Material *ma)
+{
+ CustomDataLayer *layer;
+ MTFace *mtface;
+ int index, needuv= ma->texco & TEXCO_UV;
+ char *vertcol;
+
+ shi.totuv= 0;
+ shi.totcol= 0;
+
+ for(index=0; index<fdata->totlayer; index++) {
+ layer= &fdata->layers[index];
+
+ if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) {
+ mtface= &((MTFace*)layer->data)[a];
+
+ shi.uv[shi.totuv].uv[0]= 2.0f*mtface->uv[j][0]-1.0f;
+ shi.uv[shi.totuv].uv[1]= 2.0f*mtface->uv[j][1]-1.0f;
+ shi.uv[shi.totuv].uv[2]= 1.0f;
+
+ shi.uv[shi.totuv].name= layer->name;
+ shi.totuv++;
+ }
+ else if(layer->type == CD_MCOL && shi.totcol < MAX_MCOL) {
+ vertcol= (char*)&((MCol*)layer->data)[a*4 + j];
+
+ shi.col[shi.totcol].col[0]= ((float)vertcol[3])/255.0f;
+ shi.col[shi.totcol].col[1]= ((float)vertcol[2])/255.0f;
+ shi.col[shi.totcol].col[2]= ((float)vertcol[1])/255.0f;
+
+ shi.col[shi.totcol].name= layer->name;
+ shi.totcol++;
+ }
+ }
+
+ if(needuv && shi.totuv == 0)
+ VECCOPY(shi.uv[0].uv, shi.lo);
+
+ if(shi.totcol)
+ VECCOPY(shi.vcol, shi.col[0].col);
+}
+
+static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2)
+{
+ ShadeResult shr;
+ int a;
+
+ VECCOPY(shi.co, co);
+ shi.vn[0]= -nor[0];
+ shi.vn[1]= -nor[1];
+ shi.vn[2]= -nor[2];
+ VECCOPY(shi.vno, shi.vn);
+ VECCOPY(shi.facenor, shi.vn);
+
+ if(ma->texco) {
+ VECCOPY(shi.lo, orco);
+
+ if(ma->texco & TEXCO_GLOB) {
+ VECCOPY(shi.gl, shi.lo);
+ }
+ if(ma->texco & TEXCO_WINDOW) {
+ VECCOPY(shi.winco, shi.lo);
+ }
+ if(ma->texco & TEXCO_STICKY) {
+ VECCOPY(shi.sticky, shi.lo);
+ }
+ if(ma->texco & TEXCO_OBJECT) {
+ VECCOPY(shi.co, shi.lo);
+ }
+ if(ma->texco & TEXCO_NORM) {
+ VECCOPY(shi.orn, shi.vn);
+ }
+ if(ma->texco & TEXCO_REFL) {
+ float inp= 2.0f * (shi.vn[2]);
+ shi.ref[0]= (inp*shi.vn[0]);
+ shi.ref[1]= (inp*shi.vn[1]);
+ shi.ref[2]= (-1.0f + inp*shi.vn[2]);
+ }
+ }
+
+ shi.mat= ma; /* set each time... node shaders change it */
+ // RE_shade_external(NULL, &shi, &shr);
+
+ a= 256.0f*(shr.combined[0]);
+ col1[0]= CLAMPIS(a, 0, 255);
+ a= 256.0f*(shr.combined[1]);
+ col1[1]= CLAMPIS(a, 0, 255);
+ a= 256.0f*(shr.combined[2]);
+ col1[2]= CLAMPIS(a, 0, 255);
+
+ if(col2) {
+ shi.vn[0]= -shi.vn[0];
+ shi.vn[1]= -shi.vn[1];
+ shi.vn[2]= -shi.vn[2];
+
+ shi.mat= ma; /* set each time... node shaders change it */
+ // RE_shade_external(NULL, &shi, &shr);
+
+ a= 256.0f*(shr.combined[0]);
+ col2[0]= CLAMPIS(a, 0, 255);
+ a= 256.0f*(shr.combined[1]);
+ col2[1]= CLAMPIS(a, 0, 255);
+ a= 256.0f*(shr.combined[2]);
+ col2[2]= CLAMPIS(a, 0, 255);
+ }
+}
+
+static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3])
+{
+ float tmat[4][4];
+ float amb[3]= {0.0f, 0.0f, 0.0f};
+ int a;
+
+ /* initialize globals in render */
+ // RE_shade_external(re, NULL, NULL);
+
+ /* initialize global here */
+ init_fastshade_shadeinput(re);
+
+ RE_DataBase_GetView(re, tmat);
+ mul_m4_m4m4(mat, ob->obmat, tmat);
+
+ invert_m4_m4(tmat, mat);
+ copy_m3_m4(imat, tmat);
+ if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0);
+
+ if (need_orco_r) *need_orco_r= 0;
+ for(a=0; a<ob->totcol; a++) {
+ Material *ma= give_current_material(ob, a+1);
+ if(ma) {
+ init_render_material(ma, 0, amb);
+
+ if(ma->texco & TEXCO_ORCO) {
+ if (need_orco_r) *need_orco_r= 1;
+ }
+ }
+ }
+}
+
+static void end_fastshade_for_ob(Object *ob)
+{
+ int a;
+
+ for(a=0; a<ob->totcol; a++) {
+ Material *ma= give_current_material(ob, a+1);
+ if(ma)
+ end_render_material(ma);
+ }
+}
+
+
+static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r)
+{
+ Mesh *me= ob->data;
+ DerivedMesh *dm;
+ MVert *mvert;
+ MFace *mface;
+ unsigned int *col1, *col2;
+ float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3];
+ int a, i, need_orco, totface, totvert;
+ CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL
+ | CD_MASK_MTFACE | CD_MASK_NORMAL;
+
+
+ init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
+
+ if(need_orco)
+ dataMask |= CD_MASK_ORCO;
+
+ if (onlyForMesh)
+ dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask);
+ else
+ dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask);
+
+ mvert = dm->getVertArray(dm);
+ // mface = dm->getFaceArray(dm);
+ // nors = dm->getFaceDataArray(dm, CD_NORMAL);
+ totvert = dm->getNumVerts(dm);
+ totface = dm->getNumFaces(dm);
+ orco= dm->getVertDataArray(dm, CD_ORCO);
+
+ if (onlyForMesh) {
+ col1 = *col1_r;
+ col2 = NULL;
+ } else {
+ *col1_r = col1 = MEM_mallocN(sizeof(*col1)*totface*4, "col1");
+
+ if (col2_r && (me->flag & ME_TWOSIDED))
+ col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2");
+ else
+ col2 = NULL;
+
+ if (col2_r) *col2_r = col2;
+ }
+
+ /* vertexnormals */
+ vnors= MEM_mallocN(totvert*3*sizeof(float), "vnors disp");
+ for (a=0; a<totvert; a++) {
+ MVert *mv = &mvert[a];
+ float *vn= &vnors[a*3];
+ float xn= mv->no[0];
+ float yn= mv->no[1];
+ float zn= mv->no[2];
+
+ /* transpose ! */
+ vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
+ vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
+ vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
+ normalize_v3(vn);
+ }
+
+ for (i=0; i<totface; i++) {
+ MFace *mf= &mface[i];
+ Material *ma= give_current_material(ob, mf->mat_nr+1);
+ int j, vidx[4], nverts= mf->v4?4:3;
+ unsigned char *col1base= (unsigned char*) &col1[i*4];
+ unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL);
+ float nor[3], n1[3];
+
+ if(ma==NULL) ma= &defmaterial;
+
+ vidx[0]= mf->v1;
+ vidx[1]= mf->v2;
+ vidx[2]= mf->v3;
+ vidx[3]= mf->v4;
+
+ if (nors) {
+ VECCOPY(nor, &nors[i*3]);
+ } else {
+ if (mf->v4)
+ normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
+ else
+ normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
+ }
+
+ n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
+ n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
+ n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
+ normalize_v3(n1);
+
+ for (j=0; j<nverts; j++) {
+ MVert *mv= &mvert[vidx[j]];
+ char *col1= (char*)&col1base[j*4];
+ char *col2= (char*)(col2base?&col2base[j*4]:NULL);
+ float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
+
+ mul_v3_m4v3(vec, mat, mv->co);
+
+ mul_v3_v3fl(vec, vn, 0.001f);
+
+ fastshade_customdata(&dm->faceData, i, j, ma);
+ fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2);
+ }
+ }
+ MEM_freeN(vnors);
+
+ dm->release(dm);
+
+ end_fastshade_for_ob(ob);
+}
+
+void shadeMeshMCol(Scene *scene, Object *ob, Mesh *me)
+{
+ Render *re= fastshade_get_render(scene);
+ int a;
+ char *cp;
+ unsigned int *mcol= (unsigned int*)me->mcol;
+
+ if(re) {
+ mesh_create_shadedColors(re, ob, 1, &mcol, NULL);
+ me->mcol= (MCol*)mcol;
+
+ /* swap bytes */
+ for(cp= (char *)me->mcol, a= 4*me->totface; a>0; a--, cp+=4) {
+ SWAP(char, cp[0], cp[3]);
+ SWAP(char, cp[1], cp[2]);
+ }
+ }
+}
+
+/* has base pointer, to check for layer */
+/* called from drawobject.c */
+void shadeDispList(Scene *scene, Base *base)
+{
+ Object *ob= base->object;
+ DispList *dl, *dlob;
+ Material *ma = NULL;
+ Render *re;
+ float imat[3][3], mat[4][4], vec[3];
+ float *fp, *nor, n1[3];
+ unsigned int *col1;
+ int a, need_orco;
+
+ re= fastshade_get_render(scene);
+ if(re==NULL)
+ return;
+
+ dl = find_displist(&ob->disp, DL_VERTCOL);
+ if (dl) {
+ BLI_remlink(&ob->disp, dl);
+ free_disp_elem(dl);
+ }
+
+ if(ob->type==OB_MESH) {
+ dl= MEM_callocN(sizeof(DispList), "displistshade");
+ dl->type= DL_VERTCOL;
+
+ mesh_create_shadedColors(re, ob, 0, &dl->col1, &dl->col2);
+
+ /* add dl to ob->disp after mesh_create_shadedColors, because it
+ might indirectly free ob->disp */
+ BLI_addtail(&ob->disp, dl);
+ }
+ else {
+
+ init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
+
+ if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
+
+ /* now we need the normals */
+ dl= ob->disp.first;
+
+ while(dl) {
+ dlob= MEM_callocN(sizeof(DispList), "displistshade");
+ BLI_addtail(&ob->disp, dlob);
+ dlob->type= DL_VERTCOL;
+ dlob->parts= dl->parts;
+ dlob->nr= dl->nr;
+
+ if(dl->type==DL_INDEX3) {
+ col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
+ }
+ else {
+ col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->parts*dl->nr, "col1");
+ }
+
+
+ ma= give_current_material(ob, dl->col+1);
+ if(ma==NULL) ma= &defmaterial;
+
+ if(dl->type==DL_INDEX3) {
+ if(dl->nors) {
+ /* there's just one normal */
+ n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2];
+ n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2];
+ n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2];
+ normalize_v3(n1);
+
+ fp= dl->verts;
+
+ a= dl->nr;
+ while(a--) {
+ mul_v3_m4v3(vec, mat, fp);
+
+ fastshade(vec, n1, fp, ma, (char *)col1, NULL);
+
+ fp+= 3; col1++;
+ }
+ }
+ }
+ else if(dl->type==DL_SURF) {
+ if(dl->nors) {
+ a= dl->nr*dl->parts;
+ fp= dl->verts;
+ nor= dl->nors;
+
+ while(a--) {
+ mul_v3_m4v3(vec, mat, fp);
+
+ n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
+ n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
+ n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
+ normalize_v3(n1);
+
+ fastshade(vec, n1, fp, ma, (char *)col1, NULL);
+
+ fp+= 3; nor+= 3; col1++;
+ }
+ }
+ }
+ dl= dl->next;
+ }
+ }
+ else if(ob->type==OB_MBALL) {
+ /* there are normals already */
+ dl= ob->disp.first;
+
+ while(dl) {
+
+ if(dl->type==DL_INDEX4) {
+ if(dl->nors) {
+ if(dl->col1) MEM_freeN(dl->col1);
+ col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
+
+ ma= give_current_material(ob, dl->col+1);
+ if(ma==NULL) ma= &defmaterial;
+
+ fp= dl->verts;
+ nor= dl->nors;
+
+ a= dl->nr;
+ while(a--) {
+ mul_v3_m4v3(vec, mat, fp);
+
+ /* transpose ! */
+ n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
+ n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
+ n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
+ normalize_v3(n1);
+
+ fastshade(vec, n1, fp, ma, (char *)col1, NULL);
+
+ fp+= 3; col1++; nor+= 3;
+ }
+ }
+ }
+ dl= dl->next;
+ }
+ }
+
+ end_fastshade_for_ob(ob);
+ }
+}
+
+/* frees render and shade part of displists */
+/* note: dont do a shade again, until a redraw happens */
+void reshadeall_displist(Scene *scene)
+{
+ Base *base;
+ Object *ob;
+
+ fastshade_free_render();
+
+ for(base= scene->base.first; base; base= base->next) {
+ ob= base->object;
+
+ if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
+ freedisplist(&ob->disp);
+
+ if(base->lay & scene->lay) {
+ /* Metaballs have standard displist at the Object */
+ if(ob->type==OB_MBALL) shadeDispList(scene, base);
+ }
+ }
+}
+
/* ****************** make displists ********************* */
static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender)
@@ -438,6 +934,8 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
totvert= 0;
nextcol= 0;
+ BLI_begin_edgefill();
+
dl= dispbase->first;
while(dl) {
@@ -890,7 +1388,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
if (dm) {
if (vertCos) {
- DerivedMesh *tdm = CDDM_copy(dm);
+ DerivedMesh *tdm = CDDM_copy(dm, 0);
dm->release(dm);
dm = tdm;
@@ -931,7 +1429,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
if (vertCos) {
if (dm) {
- DerivedMesh *tdm = CDDM_copy(dm);
+ DerivedMesh *tdm = CDDM_copy(dm, 0);
dm->release(dm);
dm = tdm;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index dff62b05bd3..9945027708b 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -86,6 +86,7 @@
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_mesh.h"
+#include "BKE_tessmesh.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
@@ -1925,7 +1926,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
static void give_parvert(Object *par, int nr, float *vec)
{
- EditMesh *em;
+ BMEditMesh *em;
int a, count;
vec[0]=vec[1]=vec[2]= 0.0f;
@@ -1934,7 +1935,22 @@ static void give_parvert(Object *par, int nr, float *vec)
Mesh *me= par->data;
DerivedMesh *dm;
- em = BKE_mesh_get_editmesh(me);
+ em = me->edit_btmesh;
+
+ if(em) {
+ BMVert *eve;
+ BMIter iter;
+
+ BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+ int *keyindex = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
+
+ if(keyindex && *keyindex==nr) {
+ memcpy(vec, eve->co, sizeof(float)*3);
+ break;
+ }
+ }
+ }
+
dm = (em)? em->derivedFinal: par->derivedFinal;
if(dm) {
@@ -1962,9 +1978,6 @@ static void give_parvert(Object *par, int nr, float *vec)
dm->getVertCo(dm, 0, vec);
}
}
-
- if(em)
- BKE_mesh_end_editmesh(me, em);
}
else if (ELEM(par->type, OB_CURVE, OB_SURF)) {
Nurb *nu;
@@ -2631,22 +2644,19 @@ void object_handle_update(Scene *scene, Object *ob)
case OB_MESH:
{
#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask'
- EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
+ BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH);
if(em) {
- makeDerivedMesh(scene, ob, em, scene->customdata_mask); /* was CD_MASK_BAREMESH */
- BKE_mesh_end_editmesh(ob->data, em);
+ makeDerivedMesh(scene, ob, em, scene->customdata_mask, 0); /* was CD_MASK_BAREMESH */
} else
- makeDerivedMesh(scene, ob, NULL, scene->customdata_mask);
+ makeDerivedMesh(scene, ob, NULL, scene->customdata_mask, 0);
#else /* ensure CD_MASK_BAREMESH for now */
- EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
- unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
+ BMEditMesh *em = (ob == scene->obedit)? ((Mesh*)ob->data)->edit_btmesh : NULL;
if(em) {
- makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */
- BKE_mesh_end_editmesh(ob->data, em);
+ makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH, 0); /* was CD_MASK_BAREMESH */
} else
- makeDerivedMesh(scene, ob, NULL, data_mask);
+ makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH, 0);
#endif
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 4e3840832bb..451e576979a 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -59,7 +59,6 @@
#include "DNA_ipo_types.h" // XXX old animation system stuff... to be removed!
#include "DNA_listBase.h"
-#include "BLI_edgehash.h"
#include "BLI_rand.h"
#include "BLI_jitter.h"
#include "BLI_math.h"
@@ -70,6 +69,7 @@
#include "BLI_threads.h"
#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */
#include "BLI_utildefines.h"
+#include "BLI_edgehash.h"
#include "BKE_main.h"
#include "BKE_animsys.h"
@@ -356,9 +356,9 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
origindex= dm->getVertDataArray(dm, CD_ORIGINDEX);
}
else { /* FROM_FACE/FROM_VOLUME */
- totdmelem= dm->getNumFaces(dm);
+ totdmelem= dm->getNumTessFaces(dm);
totelem= me->totface;
- origindex= dm->getFaceDataArray(dm, CD_ORIGINDEX);
+ origindex= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
}
nodedmelem= MEM_callocN(sizeof(LinkNode)*totdmelem, "psys node elems");
@@ -527,8 +527,8 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
int a, a1, a2, a0mul, a1mul, a2mul, totface;
int amax= from==PART_FROM_FACE ? 3 : 1;
- totface=dm->getNumFaces(dm);
- mface_array= dm->getFaceDataArray(dm,CD_MFACE);
+ totface=dm->getNumTessFaces(dm);
+ mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE);
for(a=0; a<amax; a++){
if(a==0){ a0mul=res*res; a1mul=res; a2mul=1; }
@@ -787,7 +787,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
MFace *mface;
pa->num = i = ctx->index[p];
- mface = dm->getFaceData(dm,i,CD_MFACE);
+ mface = dm->getTessFaceData(dm,i,CD_MFACE);
switch(distr){
case PART_DISTR_JIT:
@@ -817,7 +817,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
if(from==PART_FROM_VOLUME){
MVert *mvert=dm->getVertDataArray(dm,CD_MVERT);
- tot=dm->getNumFaces(dm);
+ tot=dm->getNumTessFaces(dm);
psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0);
@@ -829,7 +829,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
min_d=2.0;
intersect=0;
- for(i=0,mface=dm->getFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++){
+ for(i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++){
if(i==pa->num) continue;
v1=mvert[mface->v1].co;
@@ -877,7 +877,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
return;
}
- mf= dm->getFaceData(dm, ctx->index[p], CD_MFACE);
+ mf= dm->getTessFaceData(dm, ctx->index[p], CD_MFACE);
randu= rng_getFloat(thread->rng);
randv= rng_getFloat(thread->rng);
@@ -1044,7 +1044,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
if(totpart==0)
return 0;
- if (!finaldm->deformedOnly && !finaldm->getFaceDataArray(finaldm, CD_ORIGINDEX)) {
+ if (!finaldm->deformedOnly && !finaldm->getTessFaceDataArray(finaldm, CD_ORIGINDEX)) {
printf("Can't create particles with the current modifier stack, disable destructive modifiers\n");
// XXX error("Can't paint with the current modifier stack, disable destructive modifiers");
return 0;
@@ -1121,7 +1121,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
}
/* Get total number of emission elements and allocate needed arrays */
- totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumFaces(dm);
+ totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumTessFaces(dm);
if(totelem == 0){
distribute_invalid(scene, psys, children ? PART_FROM_CHILD : 0);
@@ -1147,7 +1147,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
orcodata= dm->getVertDataArray(dm, CD_ORCO);
for(i=0; i<totelem; i++){
- MFace *mf=dm->getFaceData(dm,i,CD_MFACE);
+ MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE);
if(orcodata) {
VECCOPY(co1, orcodata[mf->v1]);
@@ -1205,7 +1205,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
}
else { /* PART_FROM_FACE / PART_FROM_VOLUME */
for(i=0;i<totelem; i++){
- MFace *mf=dm->getFaceData(dm,i,CD_MFACE);
+ MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE);
tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3];
if(mf->v4) {
@@ -1280,7 +1280,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
}
else {
if(dm->numFaceData)
- COMPARE_ORIG_INDEX= dm->getFaceDataArray(dm, CD_ORIGINDEX);
+ COMPARE_ORIG_INDEX= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
}
if(COMPARE_ORIG_INDEX) {
@@ -3431,7 +3431,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
}
if(!dm) {
- dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0);
+ dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0, 0, 0);
DM_add_vert_layer(dm, CD_MDEFORMVERT, CD_CALLOC, NULL);
}