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-29 20:26:18 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-10-29 20:26:18 +0400
commitf139377a1a096582e5a7367696f307b1de7b8026 (patch)
treedaeb9b0e6a55e8f65ec6accf8e1471ee61ab67f6 /source/blender/gpu
parentc75b6c854cd1c7c7a63e2bcd9fa48eeed7039a09 (diff)
Complete fix for [#33002] Wrong vertex color.
Appart from the color glitch, there was several problems with vpaint: * "fast_update" mode was never on, because of wrong testing code; * drawing refresh during stroke in "fast_update" (i.e. no dm rebuild) mode was broken in VBO mode, because updated (tess data) mcol wasn't moved to colors GPUBuffer. Solved the later point by adding a new DM_DIRTY_MCOL_UPDATE_DRAW flag to DerivedMesh dirty var, which is set each time vpaint stroke directly update me->mcol, and forces GPU_color_setup() to refresh the gpu's colors buffer. Also got rid of the uggly GPU_color3_upload(), which basically did the same thing, but with an additional intermediate buffer !
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_buffers.h2
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c52
2 files changed, 9 insertions, 45 deletions
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index de83a717bce..f9183afd3ef 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -141,8 +141,6 @@ void *GPU_buffer_lock( GPUBuffer *buffer );
void *GPU_buffer_lock_stream( GPUBuffer *buffer );
void GPU_buffer_unlock( GPUBuffer *buffer );
-/* upload three unsigned chars, representing RGB colors, for each vertex. Resets dm->drawObject->colType to -1 */
-void GPU_color3_upload(struct DerivedMesh *dm, unsigned char *data );
/* switch color rendering on=1/off=0 */
void GPU_color_switch( int mode );
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 3f04de91900..98a25ebe769 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -708,34 +708,6 @@ static void GPU_buffer_copy_uv(DerivedMesh *dm, float *varray, int *index, int *
}
}
-
-static void GPU_buffer_copy_color3(DerivedMesh *dm, float *varray_, int *index, int *mat_orig_to_new, void *user)
-{
- int i, totface;
- char *varray = (char *)varray_;
- char *mcol = (char *)user;
- MFace *f = dm->getTessFaceArray(dm);
-
- totface = dm->getNumTessFaces(dm);
- for (i = 0; i < totface; i++, f++) {
- int start = index[mat_orig_to_new[f->mat_nr]];
-
- /* v1 v2 v3 */
- copy_v3_v3_char(&varray[start], &mcol[i * 12]);
- copy_v3_v3_char(&varray[start + 3], &mcol[i * 12 + 3]);
- copy_v3_v3_char(&varray[start + 6], &mcol[i * 12 + 6]);
- index[mat_orig_to_new[f->mat_nr]] += 9;
-
- if (f->v4) {
- /* v3 v4 v1 */
- copy_v3_v3_char(&varray[start + 9], &mcol[i * 12 + 6]);
- copy_v3_v3_char(&varray[start + 12], &mcol[i * 12 + 9]);
- copy_v3_v3_char(&varray[start + 15], &mcol[i * 12]);
- index[mat_orig_to_new[f->mat_nr]] += 9;
- }
- }
-}
-
static void copy_mcol_uc3(unsigned char *v, unsigned char *col)
{
v[0] = col[3];
@@ -944,7 +916,7 @@ static GPUBuffer *gpu_buffer_setup_type(DerivedMesh *dm, GPUBufferType type)
static GPUBuffer *gpu_buffer_setup_common(DerivedMesh *dm, GPUBufferType type)
{
GPUBuffer **buf;
-
+
if (!dm->drawObject)
dm->drawObject = GPU_drawobject_new(dm);
@@ -1008,6 +980,14 @@ void GPU_uv_setup(DerivedMesh *dm)
void GPU_color_setup(DerivedMesh *dm)
{
+ /* 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) {
+ GPUBuffer **buf = gpu_drawobject_buffer_from_type(dm->drawObject, GPU_BUFFER_COLOR);
+ GPU_buffer_free(*buf);
+ *buf = NULL;
+ }
+ dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW;
+
if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR))
return;
@@ -1168,20 +1148,6 @@ void GPU_buffer_unbind(void)
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}
-/* confusion: code in cdderivedmesh calls both GPU_color_setup and
- * GPU_color3_upload; both of these set the `colors' buffer, so seems
- * like it will just needlessly overwrite? --nicholas */
-void GPU_color3_upload(DerivedMesh *dm, unsigned char *data)
-{
- if (dm->drawObject == 0)
- dm->drawObject = GPU_drawobject_new(dm);
- GPU_buffer_free(dm->drawObject->colors);
-
- dm->drawObject->colors = gpu_buffer_setup(dm, dm->drawObject, 3,
- sizeof(char) * 3 * dm->drawObject->tot_triangle_point,
- GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3);
-}
-
void GPU_color_switch(int mode)
{
if (mode) {