[Bf-blender-cvs] [28ce422] temp-derivedmesh-looptri: Correct normal drawing
Campbell Barton
noreply at git.blender.org
Sat Jul 11 22:31:46 CEST 2015
Commit: 28ce42245041d5ebfcc77ee850580e1e9ab4eb8c
Author: Campbell Barton
Date: Sun Jul 12 06:16:39 2015 +1000
Branches: temp-derivedmesh-looptri
https://developer.blender.org/rB28ce42245041d5ebfcc77ee850580e1e9ab4eb8c
Correct normal drawing
===================================================================
M source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index aa3038a..7feff9c 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -615,8 +615,8 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
const MLoop *mloop = cddm->mloop;
const MLoopTri *lt = dm->looptris.array;
const MLoopCol *mloopcol = NULL;
- const float *nors = DM_get_tessface_data_layer(dm, CD_NORMAL);
- const short (*lnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
+ const float (*nors)[3] = DM_get_poly_data_layer(dm, CD_NORMAL);
+ const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
int colType;
int i, orig;
@@ -671,14 +671,14 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
if (lnors) {
for (j = 0; j < 3; j++) {
if (mloopcol) glColor3ubv((unsigned char *)&mloopcol[ltri[j]].r);
- glNormal3sv((const GLshort *)lnors[0][j]);
+ glNormal3fv(lnors[ltri[j]]);
glVertex3fv(mvert[vtri[j]].co);
}
}
else if (!drawSmooth) {
if (nors) {
- glNormal3fv(nors);
+ glNormal3fv(nors[lt->poly]);
}
else {
float nor[3];
@@ -704,11 +704,6 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
if (draw_option == DM_DRAW_OPTION_STIPPLE)
glDisable(GL_POLYGON_STIPPLE);
}
-
- if (nors)
- nors += 3;
- if (lnors)
- lnors++;
}
}
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
@@ -807,13 +802,13 @@ static void cdDM_drawMappedFacesTex(DerivedMesh *dm,
}
static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, const MVert *mvert, int a, int index, int vert,
- const short (*lnor)[3], const bool smoothnormal)
+ const float *lnor, const bool smoothnormal)
{
DM_draw_attrib_vertex(attribs, a, index, vert);
/* vertex normal */
if (lnor) {
- glNormal3sv((const GLshort *)lnor);
+ glNormal3fv(lnor);
}
else if (smoothnormal) {
glNormal3sv(mvert[index].no);
@@ -837,7 +832,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
const MLoopTri *lt = dm->looptris.array;
/* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */
const float (*nors)[3] = dm->getPolyDataArray(dm, CD_NORMAL);
- const short (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
+ const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
int a, b, matnr, new_matnr;
bool do_draw;
int orig;
@@ -878,7 +873,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
const unsigned int *ltri = lt->tri;
const MPoly *mp = &mpoly[lt->poly];
const bool smoothnormal = lnors || (mp->flag & ME_SMOOTH);
- const short (*ln1)[3] = NULL, (*ln2)[3] = NULL, (*ln3)[3] = NULL;
+ const float *ln1 = NULL, *ln2 = NULL, *ln3 = NULL;
new_matnr = mp->mat_nr + 1;
if (new_matnr != matnr) {
@@ -919,9 +914,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
}
else if (lnors) {
- ln1 = &lnors[ltri[0]];
- ln2 = &lnors[ltri[1]];
- ln3 = &lnors[ltri[2]];
+ ln1 = lnors[ltri[0]];
+ ln2 = lnors[ltri[1]];
+ ln3 = lnors[ltri[2]];
}
cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[0], 0, ln1, smoothnormal);
@@ -1110,7 +1105,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
const MLoop *mloop = cddm->mloop;
const MLoopTri *lt = dm->looptris.array;
const float (*nors)[3] = dm->getPolyDataArray(dm, CD_NORMAL);
- const short (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
+ const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
int a, matnr, new_matnr;
int orig;
@@ -1144,7 +1139,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
const unsigned int vtri[3] = {mloop[lt->tri[0]].v, mloop[lt->tri[1]].v, mloop[lt->tri[2]].v};
const unsigned int *ltri = lt->tri;
const bool smoothnormal = lnors || (mp->flag & ME_SMOOTH);
- const short (*ln1)[3] = NULL, (*ln2)[3] = NULL, (*ln3)[3] = NULL;
+ const float *ln1 = NULL, *ln2 = NULL, *ln3 = NULL;
/* material */
new_matnr = mp->mat_nr + 1;
@@ -1179,9 +1174,9 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
}
}
else if (lnors) {
- ln1 = &lnors[ltri[0]];
- ln2 = &lnors[ltri[1]];
- ln3 = &lnors[ltri[2]];
+ ln1 = lnors[ltri[0]];
+ ln2 = lnors[ltri[1]];
+ ln3 = lnors[ltri[2]];
}
/* vertices */
More information about the Bf-blender-cvs
mailing list