[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60821] trunk/blender/source/blender: Fix #37109: missing cycles texture display in edit mode.
Brecht Van Lommel
brechtvanlommel at pandora.be
Thu Oct 17 16:04:11 CEST 2013
Revision: 60821
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60821
Author: blendix
Date: 2013-10-17 14:04:10 +0000 (Thu, 17 Oct 2013)
Log Message:
-----------
Fix #37109: missing cycles texture display in edit mode.
My previous fix for uninitialized texture coordinates was not working well,
and in fact there was a bigger issue with GLSL drawing and missing attributes
with immediate draw mode. Now it will explicitly pass zero rather than having
it use whatever value was set last.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
trunk/blender/source/blender/blenkernel/intern/editderivedmesh.c
trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
trunk/blender/source/blender/editors/space_view3d/drawmesh.c
Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2013-10-17 12:53:37 UTC (rev 60820)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2013-10-17 14:04:10 UTC (rev 60821)
@@ -2859,14 +2859,19 @@
else
layer = CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
+ a = attribs->tottface++;
+
if (layer != -1) {
- a = attribs->tottface++;
-
attribs->tface[a].array = tfdata->layers[layer].data;
attribs->tface[a].em_offset = ldata->layers[layer].offset;
- attribs->tface[a].gl_index = gattribs->layer[b].glindex;
- attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
}
+ else {
+ attribs->tface[a].array = NULL;
+ attribs->tface[a].em_offset = -1;
+ }
+
+ attribs->tface[a].gl_index = gattribs->layer[b].glindex;
+ attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
}
else {
if (gattribs->layer[b].name[0])
@@ -2875,14 +2880,19 @@
else
layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE);
+ a = attribs->tottface++;
+
if (layer != -1) {
- a = attribs->tottface++;
-
attribs->tface[a].array = tfdata->layers[layer].data;
attribs->tface[a].em_offset = tfdata->layers[layer].offset;
- attribs->tface[a].gl_index = gattribs->layer[b].glindex;
- attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
}
+ else {
+ attribs->tface[a].array = NULL;
+ attribs->tface[a].em_offset = -1;
+ }
+
+ attribs->tface[a].gl_index = gattribs->layer[b].glindex;
+ attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
}
}
else if (gattribs->layer[b].type == CD_MCOL) {
@@ -2896,14 +2906,19 @@
else
layer = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL);
+ a = attribs->totmcol++;
+
if (layer != -1) {
- a = attribs->totmcol++;
-
attribs->mcol[a].array = tfdata->layers[layer].data;
/* odd, store the offset for a different layer type here, but editmode draw code expects it */
attribs->mcol[a].em_offset = ldata->layers[layer].offset;
- attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
}
+ else {
+ attribs->mcol[a].array = NULL;
+ attribs->mcol[a].em_offset = -1;
+ }
+
+ attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
}
else {
/* vertex colors */
@@ -2913,40 +2928,54 @@
else
layer = CustomData_get_active_layer_index(tfdata, CD_MCOL);
+ a = attribs->totmcol++;
+
if (layer != -1) {
- a = attribs->totmcol++;
-
attribs->mcol[a].array = tfdata->layers[layer].data;
/* odd, store the offset for a different layer type here, but editmode draw code expects it */
attribs->mcol[a].em_offset = tfdata->layers[layer].offset;
- attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
}
+ else {
+ attribs->mcol[a].array = NULL;
+ attribs->mcol[a].em_offset = -1;
+ }
+
+ attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
}
}
else if (gattribs->layer[b].type == CD_TANGENT) {
/* tangents */
layer = CustomData_get_layer_index(fdata, CD_TANGENT);
+ attribs->tottang = 1;
+
if (layer != -1) {
- attribs->tottang = 1;
-
attribs->tang.array = fdata->layers[layer].data;
attribs->tang.em_offset = fdata->layers[layer].offset;
- attribs->tang.gl_index = gattribs->layer[b].glindex;
}
+ else {
+ attribs->tang.array = NULL;
+ attribs->tang.em_offset = -1;
+ }
+
+ attribs->tang.gl_index = gattribs->layer[b].glindex;
}
else if (gattribs->layer[b].type == CD_ORCO) {
/* original coordinates */
layer = CustomData_get_layer_index(vdata, CD_ORCO);
+ attribs->totorco = 1;
if (layer != -1) {
- attribs->totorco = 1;
-
attribs->orco.array = vdata->layers[layer].data;
attribs->orco.em_offset = vdata->layers[layer].offset;
- attribs->orco.gl_index = gattribs->layer[b].glindex;
- attribs->orco.gl_texco = gattribs->layer[b].gltexco;
}
+ else {
+ attribs->orco.array = NULL;
+ attribs->orco.em_offset = -1;
+ }
+
+ attribs->orco.gl_index = gattribs->layer[b].glindex;
+ attribs->orco.gl_texco = gattribs->layer[b].gltexco;
}
}
}
Modified: trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2013-10-17 12:53:37 UTC (rev 60820)
+++ trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2013-10-17 14:04:10 UTC (rev 60821)
@@ -1063,37 +1063,57 @@
static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert, int smoothnormal)
{
+ const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
int b;
/* orco texture coordinates */
if (attribs->totorco) {
+ const float (*array)[3] = attribs->orco.array;
+ const float *orco = (array) ? array[index] : zero;
+
if (attribs->orco.gl_texco)
- glTexCoord3fv(attribs->orco.array[index]);
+ glTexCoord3fv(orco);
else
- glVertexAttrib3fvARB(attribs->orco.gl_index, attribs->orco.array[index]);
+ glVertexAttrib3fvARB(attribs->orco.gl_index, orco);
}
/* uv texture coordinates */
for (b = 0; b < attribs->tottface; b++) {
- MTFace *tf = &attribs->tface[b].array[a];
+ const float *uv;
+ if (attribs->tface[b].array) {
+ MTFace *tf = &attribs->tface[b].array[a];
+ uv = tf->uv[vert];
+ }
+ else {
+ uv = zero;
+ }
+
if (attribs->tface[b].gl_texco)
- glTexCoord2fv(tf->uv[vert]);
+ glTexCoord2fv(uv);
else
- glVertexAttrib2fvARB(attribs->tface[b].gl_index, tf->uv[vert]);
+ glVertexAttrib2fvARB(attribs->tface[b].gl_index, uv);
}
/* vertex colors */
for (b = 0; b < attribs->totmcol; b++) {
- MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
GLubyte col[4];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+
+ if (attribs->mcol[b].array) {
+ MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ }
+ else {
+ col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0;
+ }
+
glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col);
}
/* tangent for normal mapping */
if (attribs->tottang) {
- float *tang = attribs->tang.array[a * 4 + vert];
+ const float (*array)[4] = attribs->tang.array;
+ const float *tang = (array) ? array[a * 4 + vert] : zero;
glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
}
@@ -1264,25 +1284,29 @@
if (do_draw) {
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- if (attribs.totorco) {
+ if (attribs.totorco && attribs.orco.array) {
datatypes[numdata].index = attribs.orco.gl_index;
datatypes[numdata].size = 3;
datatypes[numdata].type = GL_FLOAT;
numdata++;
}
for (b = 0; b < attribs.tottface; b++) {
- datatypes[numdata].index = attribs.tface[b].gl_index;
- datatypes[numdata].size = 2;
- datatypes[numdata].type = GL_FLOAT;
- numdata++;
+ if (attribs.tface[b].array) {
+ datatypes[numdata].index = attribs.tface[b].gl_index;
+ datatypes[numdata].size = 2;
+ datatypes[numdata].type = GL_FLOAT;
+ numdata++;
+ }
}
for (b = 0; b < attribs.totmcol; b++) {
- datatypes[numdata].index = attribs.mcol[b].gl_index;
- datatypes[numdata].size = 4;
- datatypes[numdata].type = GL_UNSIGNED_BYTE;
- numdata++;
+ if (attribs.mcol[b].array) {
+ datatypes[numdata].index = attribs.mcol[b].gl_index;
+ datatypes[numdata].size = 4;
+ datatypes[numdata].type = GL_UNSIGNED_BYTE;
+ numdata++;
+ }
}
- if (attribs.tottang) {
+ if (attribs.tottang && attribs.tang.array) {
datatypes[numdata].index = attribs.tang.gl_index;
datatypes[numdata].size = 4;
datatypes[numdata].type = GL_FLOAT;
@@ -1315,34 +1339,38 @@
if (do_draw && numdata != 0) {
offset = 0;
- if (attribs.totorco) {
+ if (attribs.totorco && attribs.orco.array) {
copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]);
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v2]);
copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v3]);
offset += sizeof(float) * 3;
}
for (b = 0; b < attribs.tottface; b++) {
- MTFace *tf = &attribs.tface[b].array[a];
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]);
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]);
+ if (attribs.tface[b].array) {
+ MTFace *tf = &attribs.tface[b].array[a];
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]);
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]);
- copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]);
- offset += sizeof(float) * 2;
+ copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]);
+ offset += sizeof(float) * 2;
+ }
}
for (b = 0; b < attribs.totmcol; b++) {
- MCol *cp = &attribs.mcol[b].array[a * 4 + 0];
- GLubyte col[4];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col);
- cp = &attribs.mcol[b].array[a * 4 + 1];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col);
- cp = &attribs.mcol[b].array[a * 4 + 2];
- col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
- copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col);
- offset += sizeof(unsigned char) * 4;
+ if (attribs.mcol[b].array) {
+ MCol *cp = &attribs.mcol[b].array[a * 4 + 0];
+ GLubyte col[4];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list