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:
authorDaniel Dunbar <daniel@zuster.org>2004-01-07 08:50:17 +0300
committerDaniel Dunbar <daniel@zuster.org>2004-01-07 08:50:17 +0300
commit8e9e9e6e357539caee8bbdc337b3369ffb574c14 (patch)
tree170ccb1b0ab1953d9e612280902d90671c95e74f /source/blender/blenkernel/intern/displist.c
parente2a2ceb6e539f46cd8a0e742c1e52a9dc0ef16d6 (diff)
- migrated a subsurf routine to displist.c: displistmesh_calc_vert_normals()
- removed some vertice tweaking for subsurf->displist conversion - replaced stupid way of doing edcode calculation for ME_OPT_EDGES flag
Diffstat (limited to 'source/blender/blenkernel/intern/displist.c')
-rw-r--r--source/blender/blenkernel/intern/displist.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index a825b5adcb9..ecb12386da4 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -125,6 +125,45 @@ static DispListMesh *displistmesh_copy(DispListMesh *odlm) {
return ndlm;
}
+void displistmesh_calc_vert_normals(DispListMesh *dlm) {
+ MVert *mverts= dlm->mvert;
+ int nmverts= dlm->totvert;
+ MFaceInt *mfaces= dlm->mface;
+ int nmfaces= dlm->totface;
+ float (*tnorms)[3]= MEM_callocN(nmverts*sizeof(*tnorms), "tnorms");
+ int i;
+
+ for (i=0; i<nmfaces; i++) {
+ MFaceInt *mf= &mfaces[i];
+ float f_no[3];
+
+ if (!mf->v3)
+ continue;
+
+ if (mf->v4)
+ CalcNormFloat4(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co, f_no);
+ else
+ CalcNormFloat(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, f_no);
+
+ VecAddf(tnorms[mf->v1], tnorms[mf->v1], f_no);
+ VecAddf(tnorms[mf->v2], tnorms[mf->v2], f_no);
+ VecAddf(tnorms[mf->v3], tnorms[mf->v3], f_no);
+ if (mf->v4)
+ VecAddf(tnorms[mf->v4], tnorms[mf->v4], f_no);
+ }
+ for (i=0; i<nmverts; i++) {
+ MVert *mv= &mverts[i];
+ float *no= tnorms[i];
+
+ Normalise(no);
+ mv->no[0]= (short)(no[0]*32767.0);
+ mv->no[1]= (short)(no[1]*32767.0);
+ mv->no[2]= (short)(no[2]*32767.0);
+ }
+
+ MEM_freeN(tnorms);
+}
+
void free_disp_elem(DispList *dl)
{
if(dl) {