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:
authorNicholas Bishop <nicholasbishop@gmail.com>2015-01-20 16:17:08 +0300
committerNicholas Bishop <nicholasbishop@gmail.com>2015-01-20 16:17:08 +0300
commit8604ec9053c14178a9c06feda1b9688741b124a0 (patch)
tree60198cd0efb575314d54a032718a424b5155b863 /source/blender/blenkernel/intern/DerivedMesh.c
parent58e5509da0dbc9eea8af908e5fa38b3ec0b311ed (diff)
De-duplicate large block of shared code for GL vert attribs
Code in ccgdm_draw_attrib_vertex() was entirely the same as the top portion of the code in cddm_draw_attrib_vertex(). Moved this code to a new function, DM_draw_attrib_vertex(). ccgdm_draw_attrib_vertex() was removed in favor of calling DM_draw_attrib_vertex(). cddm_draw_attrib_vertex() still does a couple extra things, so it still exists but calls DM_draw_attrib_vertex(). In the interest of easy code review, no changes made to the code in DM_draw_attrib_vertex() other than the new name and an added comment. Reviewers: campbellbarton Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D1010
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.c')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 8fbb2937809..ad316e55d85 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -3080,6 +3080,69 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
}
}
+/* Set vertex shader attribute inputs for a particular tessface vert
+ *
+ * a: tessface index
+ * index: vertex index
+ * vert: corner index (0, 1, 2, 3)
+ */
+void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert)
+{
+ const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ int b;
+
+ /* orco texture coordinates */
+ if (attribs->totorco) {
+ /*const*/ float (*array)[3] = attribs->orco.array;
+ const float *orco = (array) ? array[index] : zero;
+
+ if (attribs->orco.gl_texco)
+ glTexCoord3fv(orco);
+ else
+ glVertexAttrib3fvARB(attribs->orco.gl_index, orco);
+ }
+
+ /* uv texture coordinates */
+ for (b = 0; b < attribs->tottface; b++) {
+ const float *uv;
+
+ if (attribs->tface[b].array) {
+ MTFace *tf = &attribs->tface[b].array[a];
+ uv = tf->uv[vert];
+ }
+ else {
+ uv = zero;
+ }
+
+ if (attribs->tface[b].gl_texco)
+ glTexCoord2fv(uv);
+ else
+ glVertexAttrib2fvARB(attribs->tface[b].gl_index, uv);
+ }
+
+ /* vertex colors */
+ for (b = 0; b < attribs->totmcol; b++) {
+ GLubyte col[4];
+
+ if (attribs->mcol[b].array) {
+ MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
+ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+ }
+ else {
+ col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0;
+ }
+
+ glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col);
+ }
+
+ /* tangent for normal mapping */
+ if (attribs->tottang) {
+ /*const*/ float (*array)[4] = attribs->tang.array;
+ const float *tang = (array) ? array[a * 4 + vert] : zero;
+ glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
+ }
+}
+
/* Set object's bounding box based on DerivedMesh min/max data */
void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
{