diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-04-04 17:02:12 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-04-04 17:02:12 +0400 |
commit | 709e4b309e21a0e2b7569924446b0295382e8b82 (patch) | |
tree | de54b839b253597cdca0c3f9cb3af0a979ba2ed0 /source | |
parent | 265cdf29fb62a6dc437ccafddc33045e5b32f9cf (diff) |
Revert mesh recalculation change that gives different vertex normals based
on smooth/flat flag on faces. This does give better results for low poly
game models, but there's just too much functionality that depends on this
(modifiers, displacey, editmode tools, extrude, ...), that there's not
enough time to fix these before the release.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 47 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_lib.c | 40 |
4 files changed, 9 insertions, 82 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index f222db71455..9d122453f2a 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -44,7 +44,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather then defining with quotes */ #define BLENDER_VERSION 256 -#define BLENDER_SUBVERSION 5 +#define BLENDER_SUBVERSION 6 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 7302abe8968..f1e1b24b891 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1277,59 +1277,20 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*tnorms)[3]= MEM_callocN(numVerts*sizeof(*tnorms), "tnorms"); float (*fnors)[3]= (faceNors_r)? faceNors_r: MEM_callocN(sizeof(*fnors)*numFaces, "meshnormals"); int i; - int found_flat=0; for(i=0; i<numFaces; i++) { MFace *mf= &mfaces[i]; float *f_no= fnors[i]; + float *n4 = (mf->v4)? tnorms[mf->v4]: NULL; + float *c4 = (mf->v4)? mverts[mf->v4].co: NULL; if(mf->v4) normal_quad_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co); else normal_tri_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co); - if(mf->flag & ME_SMOOTH) { - float *n4 = (mf->v4)? tnorms[mf->v4]: NULL; - float *c4 = (mf->v4)? mverts[mf->v4].co: NULL; - - accumulate_vertex_normals(tnorms[mf->v1], tnorms[mf->v2], tnorms[mf->v3], n4, - f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4); - } - else { - found_flat=1; - } - } - - /* build smooth normals for uninitialized normals at faces set to flat */ - /* For such faces the renderer/3Dview and exporters will be using the face normal */ - /* The vertex normals built inside this if-statement are entirely to support the needs of the modeler */ - if(found_flat!=0) { - const int nr_bits= sizeof(int)*8; - const int nr_words= (numVerts+(nr_bits-1))/nr_bits; - int *bit_array= (int*)MEM_callocN(sizeof(int)*MAX2(nr_words, 1), "temp buffer"); - - for(i=0; i<numFaces; i++) { - MFace *mf= &mfaces[i]; - - if(!(mf->flag & ME_SMOOTH)) { - if(is_zero_v3(tnorms[mf->v1])) bit_array[mf->v1/nr_bits]|=(1<<(mf->v1&(nr_bits-1))); - if(is_zero_v3(tnorms[mf->v2])) bit_array[mf->v2/nr_bits]|=(1<<(mf->v2&(nr_bits-1))); - if(is_zero_v3(tnorms[mf->v3])) bit_array[mf->v3/nr_bits]|=(1<<(mf->v3&(nr_bits-1))); - if(mf->v4 && is_zero_v3(tnorms[mf->v4])) bit_array[mf->v4/nr_bits]|=(1<<(mf->v4&(nr_bits-1))); - } - } - - for(i=0; i<numFaces; i++) { - MFace *mf= &mfaces[i]; - float *f_no= fnors[i]; - - if(bit_array[mf->v1/nr_bits]&(1<<(mf->v1&(nr_bits-1)))) add_v3_v3(tnorms[mf->v1], f_no); - if(bit_array[mf->v2/nr_bits]&(1<<(mf->v2&(nr_bits-1)))) add_v3_v3(tnorms[mf->v2], f_no); - if(bit_array[mf->v3/nr_bits]&(1<<(mf->v3&(nr_bits-1)))) add_v3_v3(tnorms[mf->v3], f_no); - if(mf->v4 && bit_array[mf->v4/nr_bits]&(1<<(mf->v4&(nr_bits-1)))) add_v3_v3(tnorms[mf->v4], f_no); - } - - MEM_freeN(bit_array); + accumulate_vertex_normals(tnorms[mf->v1], tnorms[mf->v2], tnorms[mf->v3], n4, + f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4); } /* following Mesh convention; we use vertex coordinate itself for normal in this case */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a8d5968984f..54feaedc45f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11545,7 +11545,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 5)){ + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)){ Mesh *me; for(me= main->mesh.first; me; me= me->id.next) diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index d3945a53f0d..b2ff8306526 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -2001,12 +2001,14 @@ void recalc_editnormals(EditMesh *em) { EditFace *efa; EditVert *eve; - int found_flat= 0; for(eve= em->verts.first; eve; eve=eve->next) zero_v3(eve->no); for(efa= em->faces.first; efa; efa=efa->next) { + float *n4= (efa->v4)? efa->v4->no: NULL; + float *c4= (efa->v4)? efa->v4->co: NULL; + if(efa->v4) { normal_quad_v3(efa->n, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); cent_quad_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); @@ -2015,42 +2017,6 @@ void recalc_editnormals(EditMesh *em) normal_tri_v3(efa->n, efa->v1->co, efa->v2->co, efa->v3->co); cent_tri_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co); } - - if(efa->flag & ME_SMOOTH) { - float *n4= (efa->v4)? efa->v4->no: NULL; - float *c4= (efa->v4)? efa->v4->co: NULL; - - accumulate_vertex_normals(efa->v1->no, efa->v2->no, efa->v3->no, n4, - efa->n, efa->v1->co, efa->v2->co, efa->v3->co, c4); - } - else - found_flat= 1; - } - - /* build smooth normals for uninitialized normals at faces set to flat */ - /* For such faces the renderer/3Dview and exporters will be using the face normal */ - /* The vertex normals built inside this if-statement are entirely to support the needs of the modeler */ - if(found_flat!=0) { - for(efa= em->faces.first; efa; efa=efa->next) { - efa->v1->tmp.t= 0; - efa->v2->tmp.t= 0; - efa->v3->tmp.t= 0; - if(efa->v4) efa->v4->tmp.t= 0; - - if(!(efa->flag & ME_SMOOTH)) { - if(is_zero_v3(efa->v1->no)) efa->v1->tmp.t= 1; - if(is_zero_v3(efa->v2->no)) efa->v2->tmp.t= 1; - if(is_zero_v3(efa->v3->no)) efa->v3->tmp.t= 1; - if(efa->v4 && is_zero_v3(efa->v4->no)) efa->v4->tmp.t= 1; - } - } - - for(efa= em->faces.first; efa; efa=efa->next) { - if(efa->v1->tmp.t) add_v3_v3(efa->v1->no, efa->n); - if(efa->v2->tmp.t) add_v3_v3(efa->v2->no, efa->n); - if(efa->v3->tmp.t) add_v3_v3(efa->v3->no, efa->n); - if(efa->v4 && efa->v4->tmp.t) add_v3_v3(efa->v4->no, efa->n); - } } /* following Mesh convention; we use vertex coordinate itself for normal in this case */ |