diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-17 15:02:32 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-17 15:02:32 +0400 |
commit | 3d2f1fd8f9ce19ef4444c1dc84a087704cb38685 (patch) | |
tree | d8b401a34c03eab2dfce0515a96fbf5af19da4f0 /source/blender/blenkernel/intern/DerivedMesh.c | |
parent | 09f722740f3e2df4b14167260fd5e1015f087c30 (diff) |
Fix crash with texture draw in edit mode after commit 45672.
Don't create empty tesselated faces layers in edit derivedmesh, these are
being created on the fly so this will conflicted, and use loop data for
opengl attributes for edit derivedmesh drawing.
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 92 |
1 files changed, 55 insertions, 37 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3330a6596a7..94aed7c7a01 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2757,7 +2757,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, fdata = tfdata = dm->getTessFaceDataLayout(dm); /* calc auto bump scale if necessary */ - if (dm->auto_bump_scale<=0.0f) + if (dm->auto_bump_scale <= 0.0f) DM_calc_auto_bump_scale(dm); /* add a tangent layer if necessary */ @@ -2769,58 +2769,76 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, for (b = 0; b < gattribs->totlayer; b++) { if (gattribs->layer[b].type == CD_MTFACE) { /* uv coordinates */ - if (gattribs->layer[b].name[0]) - layer = CustomData_get_named_layer_index(tfdata, CD_MTFACE, - gattribs->layer[b].name); - else - layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE); + if(dm->type == DM_TYPE_EDITBMESH) { + /* exception .. */ + CustomData *ldata = dm->getLoopDataLayout(dm); - if (layer != -1) { - a = attribs->tottface++; + if (gattribs->layer[b].name[0]) + layer = CustomData_get_named_layer_index(ldata, CD_MLOOPUV, + gattribs->layer[b].name); + else + layer = CustomData_get_active_layer_index(ldata, CD_MLOOPUV); + + if (layer != -1) { + a = attribs->tottface++; - attribs->tface[a].array = tfdata->layers[layer].data; - attribs->tface[a].emOffset = tfdata->layers[layer].offset; - attribs->tface[a].glIndex = gattribs->layer[b].glindex; - attribs->tface[a].glTexco = gattribs->layer[b].gltexco; + attribs->tface[a].array = tfdata->layers[layer].data; + attribs->tface[a].emOffset = tfdata->layers[layer].offset; + attribs->tface[a].glIndex = gattribs->layer[b].glindex; + attribs->tface[a].glTexco = gattribs->layer[b].gltexco; + } } - /* BMESH_TODO - BMESH ONLY, may need to get this working?, otherwise remove */ -#if 0 else { - int player; - CustomData *pdata = dm->getPolyDataLayout(dm); - if (gattribs->layer[b].name[0]) - player = CustomData_get_named_layer_index(pdata, CD_MTEXPOLY, + layer = CustomData_get_named_layer_index(tfdata, CD_MTFACE, gattribs->layer[b].name); else - player = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY); - - if (player != -1) { + layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE); + + if (layer != -1) { a = attribs->tottface++; - - attribs->tface[a].array = NULL; - attribs->tface[a].emOffset = pdata->layers[layer].offset; + + attribs->tface[a].array = tfdata->layers[layer].data; + attribs->tface[a].emOffset = tfdata->layers[layer].offset; attribs->tface[a].glIndex = gattribs->layer[b].glindex; attribs->tface[a].glTexco = gattribs->layer[b].gltexco; - } } -#endif } else if (gattribs->layer[b].type == CD_MCOL) { - /* vertex colors */ - if (gattribs->layer[b].name[0]) - layer = CustomData_get_named_layer_index(tfdata, CD_MCOL, - gattribs->layer[b].name); - else - layer = CustomData_get_active_layer_index(tfdata, CD_MCOL); + if(dm->type == DM_TYPE_EDITBMESH) { + /* exception .. */ + CustomData *ldata = dm->getLoopDataLayout(dm); - if (layer != -1) { - a = attribs->totmcol++; + if (gattribs->layer[b].name[0]) + layer = CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, + gattribs->layer[b].name); + else + layer = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL); + + if (layer != -1) { + a = attribs->totmcol++; - attribs->mcol[a].array = tfdata->layers[layer].data; - attribs->mcol[a].emOffset = tfdata->layers[layer].offset; - attribs->mcol[a].glIndex = gattribs->layer[b].glindex; + attribs->mcol[a].array = tfdata->layers[layer].data; + attribs->mcol[a].emOffset = tfdata->layers[layer].offset; + attribs->mcol[a].glIndex = gattribs->layer[b].glindex; + } + } + else { + /* vertex colors */ + if (gattribs->layer[b].name[0]) + layer = CustomData_get_named_layer_index(tfdata, CD_MCOL, + gattribs->layer[b].name); + else + layer = CustomData_get_active_layer_index(tfdata, CD_MCOL); + + if (layer != -1) { + a = attribs->totmcol++; + + attribs->mcol[a].array = tfdata->layers[layer].data; + attribs->mcol[a].emOffset = tfdata->layers[layer].offset; + attribs->mcol[a].glIndex = gattribs->layer[b].glindex; + } } } else if (gattribs->layer[b].type == CD_TANGENT) { |