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:
authorBastien Montagne <montagne29@wanadoo.fr>2012-10-30 15:00:06 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-10-30 15:00:06 +0400
commitb4e484e21189e4b30b20439f41f6ba1c15bb7581 (patch)
tree983a8292d6077ad946918c96f5e38e299631b386 /source/blender/gpu/intern
parent6341bc2cd0eaf5616322c77310b171e7b434b094 (diff)
Fix for own r51737.
Refactoring of draw code showed another problem: The MCol we want to draw may change without dm rebuild (e.g. when enabling solid textured option)! Also, choosing which MCol layer to use in GPU code is stupid, different draw modes use different layers/order of precedence! Solved this by adding a new colType parameter to GPU_color_setup, and removing any 'color choosing' code from gpu_buffers.c.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 98a25ebe769..0392deac148 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -792,28 +792,6 @@ static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(i
}
}
-/* get the DerivedMesh's MCols; choose (in decreasing order of
- * preference) from CD_ID_MCOL, CD_PREVIEW_MCOL, or CD_MCOL */
-static MCol *gpu_buffer_color_type(DerivedMesh *dm)
-{
- MCol *c;
- int type;
-
- type = CD_ID_MCOL;
- c = DM_get_tessface_data_layer(dm, type);
- if (!c) {
- type = CD_PREVIEW_MCOL;
- c = DM_get_tessface_data_layer(dm, type);
- if (!c) {
- type = CD_MCOL;
- c = DM_get_tessface_data_layer(dm, type);
- }
- }
-
- dm->drawObject->colType = type;
- return c;
-}
-
typedef enum {
GPU_BUFFER_VERTEX = 0,
GPU_BUFFER_NORMAL,
@@ -896,7 +874,7 @@ static GPUBuffer *gpu_buffer_setup_type(DerivedMesh *dm, GPUBufferType type)
/* special handling for MCol and UV buffers */
if (type == GPU_BUFFER_COLOR) {
- if (!(user_data = gpu_buffer_color_type(dm)))
+ if (!(user_data = DM_get_tessface_data_layer(dm, dm->drawObject->colType)))
return NULL;
}
else if (type == GPU_BUFFER_UV) {
@@ -978,15 +956,27 @@ void GPU_uv_setup(DerivedMesh *dm)
GLStates |= GPU_BUFFER_TEXCOORD_STATE;
}
-void GPU_color_setup(DerivedMesh *dm)
+void GPU_color_setup(DerivedMesh *dm, int colType)
{
- /* In paint mode, dm may stay the same during stroke, however we still want to update colors! */
- if ((dm->dirty & DM_DIRTY_MCOL_UPDATE_DRAW) && dm->drawObject) {
+ if (!dm->drawObject) {
+ /* XXX Not really nice, but we need a valid gpu draw object to set the colType...
+ * Else we would have to add a new param to gpu_buffer_setup_common. */
+ dm->drawObject = GPU_drawobject_new(dm);
+ dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW;
+ dm->drawObject->colType = colType;
+ }
+ /* In paint mode, dm may stay the same during stroke, however we still want to update colors!
+ * Also check in case we changed color type (i.e. which MCol cdlayer we use). */
+ else if ((dm->dirty & DM_DIRTY_MCOL_UPDATE_DRAW) || (colType != dm->drawObject->colType)) {
GPUBuffer **buf = gpu_drawobject_buffer_from_type(dm->drawObject, GPU_BUFFER_COLOR);
+ /* XXX Freeing this buffer is a bit stupid, as geometry has not changed, size should remain the same.
+ * Not sure though it would be worth defining a sort of gpu_buffer_update func - nor whether
+ * it is even possible ! */
GPU_buffer_free(*buf);
*buf = NULL;
+ dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW;
+ dm->drawObject->colType = colType;
}
- dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW;
if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR))
return;