[Bf-blender-cvs] [7664d94] blender2.8: Gawain: allow partial vertex specification
Mike Erwin
noreply at git.blender.org
Thu Aug 11 07:06:51 CEST 2016
Commit: 7664d947b38e1451b973deb7488ec881bedf5dcc
Author: Mike Erwin
Date: Thu Aug 11 00:11:48 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB7664d947b38e1451b973deb7488ec881bedf5dcc
Gawain: allow partial vertex specification
If you don’t specify a vertex’s color, it will use the color of the
previous vertex. Similar for all other attributes.
This matches the legacy behavior of glColor, glNormal, etc. *except* in
Gawain the first vertex of each immBegin must be fully specified. There
is no “current” color in the new system.
===================================================================
M source/blender/gpu/intern/gpu_immediate.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 628c8d1..5912570 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -621,14 +621,33 @@ void immEndVertex()
{
#if TRUST_NO_ONE
assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+ assert(imm.vertex_idx < imm.vertex_ct);
+#endif
// have all attribs been assigned values?
+ // if not, copy value from previous vertex
const unsigned short all_bits = ~(0xFFFFU << imm.vertex_format.attrib_ct);
- assert(imm.attrib_value_bits == all_bits);
-
- assert(imm.vertex_idx < imm.vertex_ct);
+ if (imm.attrib_value_bits != all_bits)
+ {
+#if TRUST_NO_ONE
+ assert(imm.vertex_idx > 0); // first vertex must have all attribs specified
#endif
+ for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx)
+ {
+ const uint16_t mask = 1 << a_idx;
+ if ((imm.attrib_value_bits & mask) == 0)
+ {
+ const Attrib* a = imm.vertex_format.attribs + a_idx;
+
+// printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx);
+
+ GLubyte* data = imm.vertex_data + a->offset;
+ memcpy(data, data - imm.vertex_format.stride, a->sz);
+ }
+ }
+ }
+
imm.vertex_idx++;
imm.vertex_data += imm.vertex_format.stride;
imm.attrib_value_bits = 0;
More information about the Bf-blender-cvs
mailing list