[Bf-blender-cvs] [5f11695] cycles-ptex-08: WIP add ptex vertex attrib to DerivedMesh for GPU drawing
Nicholas Bishop
noreply at git.blender.org
Tue Jan 20 13:57:13 CET 2015
Commit: 5f11695cd1239e202baf0854520a3653e3cce6b0
Author: Nicholas Bishop
Date: Tue Jan 20 12:35:50 2015 +0100
Branches: cycles-ptex-08
https://developer.blender.org/rB5f11695cd1239e202baf0854520a3653e3cce6b0
WIP add ptex vertex attrib to DerivedMesh for GPU drawing
===================================================================
M source/blender/blenkernel/BKE_DerivedMesh.h
M source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index da982f8..1bdeb96 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -740,7 +740,12 @@ typedef struct DMVertexAttribs {
int em_offset, gl_index, gl_texco;
} orco;
- int tottface, totmcol, tottang, totorco;
+ struct {
+ struct MPtexTessFace *array;
+ int em_offset, gl_index, gl_texco;
+ } ptex;
+
+ int tottface, totmcol, tottang, totorco, totptex;
} DMVertexAttribs;
void DM_vertex_attributes_from_gpu(DerivedMesh *dm,
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 9b5592b..5110dd7 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -3080,6 +3080,21 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
attribs->orco.gl_index = gattribs->layer[b].glindex;
attribs->orco.gl_texco = gattribs->layer[b].gltexco;
}
+ else if (gattribs->layer[b].type == CD_PTEX_TESSFACE) {
+ layer = CustomData_get_layer_index(fdata, CD_PTEX_TESSFACE);
+ attribs->totptex = 1;
+ if (layer != -1) {
+ attribs->ptex.array = fdata->layers[layer].data;
+ attribs->ptex.em_offset = vdata->layers[layer].offset;
+ }
+ else {
+ attribs->ptex.array = NULL;
+ attribs->ptex.em_offset = -1;
+ }
+
+ attribs->ptex.gl_index = gattribs->layer[b].glindex;
+ attribs->ptex.gl_texco = gattribs->layer[b].gltexco;
+ }
}
}
@@ -3144,6 +3159,22 @@ void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert)
const float *tang = (array) ? array[a * 4 + vert] : zero;
glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
}
+
+ /* ptex texture coordinates */
+ if (attribs->totptex) {
+ MPtexTessFace *array = attribs->ptex.array;
+ float ptex[3] = {0.0f, 0.0f, 0.0f};
+ if (array) {
+ // TODO
+ copy_v2_v2(ptex, attribs->ptex.array[a].corners[vert].uv);
+ ptex[2] = attribs->ptex.array[a].corners[vert].id;
+ }
+
+ if (attribs->ptex.gl_texco)
+ glTexCoord3fv(ptex);
+ else
+ glVertexAttrib3fvARB(attribs->ptex.gl_index, ptex);
+ }
}
/* Set object's bounding box based on DerivedMesh min/max data */
More information about the Bf-blender-cvs
mailing list