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:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-07-12 20:08:22 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-07-12 20:08:22 +0400
commit152675db1a49646aac0f739c903dbd60145cc28b (patch)
tree867fe095eb68b9d6565386c8a193bc5978d3c33b
parentba44250a23b817b69bc59f61eefc0ea890dfe84d (diff)
Fix #31988: VBOs Textured solid : no update of material in 3Dview
Issue was caused by VBOs using CD_TEXTURE_MCOL for faces colors. This layer was creating on mesh display (from draw_tface_mapped__set_draw) in cases there's no such a layer. If material settings are changing, this layer wasn't updated and old colors were used. Fixed by performing an update of this layer in cases it's already exists. This would give some % of slowdown, but don't think it'll be dramatically bad. Would be nice to find a nice way to update such a layer in cases material is actually changes only, or get completely rid of it/
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 41d69030e1a..112f41278b7 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -466,7 +466,8 @@ static DMDrawOption draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr)
return DM_DRAW_OPTION_NORMAL; /* Set color from mcol */
}
}
-static void add_tface_color_layer(DerivedMesh *dm)
+
+static void update_tface_color_layer(DerivedMesh *dm)
{
MTFace *tface = DM_get_tessface_data_layer(dm, CD_MTFACE);
MFace *mface = dm->getTessFaceArray(dm);
@@ -476,7 +477,15 @@ static void add_tface_color_layer(DerivedMesh *dm)
if (!mcol)
mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
- finalCol = MEM_mallocN(sizeof(MCol) * 4 * dm->getNumTessFaces(dm), "add_tface_color_layer");
+ if (CustomData_has_layer(&dm->faceData, CD_TEXTURE_MCOL)) {
+ finalCol = CustomData_get_layer(&dm->faceData, CD_TEXTURE_MCOL);
+ }
+ else {
+ finalCol = MEM_mallocN(sizeof(MCol) * 4 * dm->getNumTessFaces(dm), "add_tface_color_layer");
+
+ CustomData_add_layer(&dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData);
+ }
+
for (i = 0; i < dm->getNumTessFaces(dm); i++) {
Material *ma = give_current_material(Gtexdraw.ob, mface[i].mat_nr + 1);
@@ -542,7 +551,6 @@ static void add_tface_color_layer(DerivedMesh *dm)
}
}
}
- CustomData_add_layer(&dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData);
}
static DMDrawOption draw_tface_mapped__set_draw(void *userData, int index)
@@ -797,8 +805,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
else {
drawTFace_userData userData;
- if (!CustomData_has_layer(&dm->faceData, CD_TEXTURE_MCOL))
- add_tface_color_layer(dm);
+ update_tface_color_layer(dm);
userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);