[Bf-blender-cvs] [95ca1ed] GPU_data_request: Compilation fixes for C90 - still getting link errors related to buffer generation routines.
Antony Riakiotakis
noreply at git.blender.org
Mon May 11 11:04:39 CEST 2015
Commit: 95ca1ed75d8586985a4076e67b496fc519473016
Author: Antony Riakiotakis
Date: Mon May 11 11:04:19 2015 +0200
Branches: GPU_data_request
https://developer.blender.org/rB95ca1ed75d8586985a4076e67b496fc519473016
Compilation fixes for C90 - still getting link errors related to buffer
generation routines.
===================================================================
M source/blender/editors/space_view3d/drawobject.c
===================================================================
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 3d2f3c8..4772dc7 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4890,19 +4890,21 @@ static bool draw_mesh_object_new_new(Scene *scene, ARegion *ar, View3D *v3d, Reg
normal_float_to_short_v3(poly_normal, f_no);
}
- const int v1 = loop_index_from_ngon(f->v1, poly, loops),
- v2 = loop_index_from_ngon(f->v2, poly, loops),
- v3 = loop_index_from_ngon(f->v3, poly, loops);
+ {
+ const int v1 = loop_index_from_ngon(f->v1, poly, loops),
+ v2 = loop_index_from_ngon(f->v2, poly, loops),
+ v3 = loop_index_from_ngon(f->v3, poly, loops);
- /* set only provoking vertex's normal */
- GPUx_set_attrib(verts, 1, v3, poly_normal);
- GPUx_set_triangle_vertices(elem, t++, v1, v2, v3);
-
- if (f->v4) {
- const int v4 = loop_index_from_ngon(f->v4, poly, loops);
/* set only provoking vertex's normal */
- GPUx_set_attrib(verts, 1, v4, poly_normal);
- GPUx_set_triangle_vertices(elem, t++, v1, v3, v4);
+ GPUx_set_attrib(verts, 1, v3, poly_normal);
+ GPUx_set_triangle_vertices(elem, t++, v1, v2, v3);
+
+ if (f->v4) {
+ const int v4 = loop_index_from_ngon(f->v4, poly, loops);
+ /* set only provoking vertex's normal */
+ GPUx_set_attrib(verts, 1, v4, poly_normal);
+ GPUx_set_triangle_vertices(elem, t++, v1, v3, v4);
+ }
}
}
@@ -4941,15 +4943,17 @@ static bool draw_mesh_object_new_new(Scene *scene, ARegion *ar, View3D *v3d, Reg
if (!tessface_in_poly(f, poly, loops))
poly++;
- const int v1 = loop_index_from_ngon(f->v1, poly, loops),
- v2 = loop_index_from_ngon(f->v2, poly, loops),
- v3 = loop_index_from_ngon(f->v3, poly, loops);
+ {
+ const int v1 = loop_index_from_ngon(f->v1, poly, loops),
+ v2 = loop_index_from_ngon(f->v2, poly, loops),
+ v3 = loop_index_from_ngon(f->v3, poly, loops);
- GPUx_set_triangle_vertices(elem, t++, v1, v2, v3);
+ GPUx_set_triangle_vertices(elem, t++, v1, v2, v3);
- if (f->v4) {
- const int v4 = loop_index_from_ngon(f->v4, poly, loops);
- GPUx_set_triangle_vertices(elem, t++, v1, v3, v4);
+ if (f->v4) {
+ const int v4 = loop_index_from_ngon(f->v4, poly, loops);
+ GPUx_set_triangle_vertices(elem, t++, v1, v3, v4);
+ }
}
}
@@ -4982,125 +4986,128 @@ static bool draw_mesh_object_new_new(Scene *scene, ARegion *ar, View3D *v3d, Reg
GPUx_set_line_vertices(elem, i, edge->v1, edge->v2);
}
#else
- /* draw wireframe with color based on angle */
- const MPoly *polys = dm->getPolyArray(dm);
- const MLoop *loops = dm->getLoopArray(dm);
-
- float (*face_normal)[3] = MEM_mallocN(poly_ct * 3 * sizeof(float), "face_normal");
-
- /* TODO: rename? FacesAdjacentToEdge, FacesJoinedByEdge, FacesMeetingAtEdge */
- typedef struct {
- int count;
- int face_index[2];
- } AdjacentFaces;
-
- AdjacentFaces *adj_faces = MEM_callocN(edge_ct * sizeof(AdjacentFaces), "adj_faces");
-
- for (i = 0; i < poly_ct; ++i) {
- const MPoly *poly = polys + i;
- int j;
-
- BKE_mesh_calc_poly_normal(poly, loops + poly->loopstart, mverts, face_normal[i]);
- for (j = poly->loopstart; j < (poly->loopstart + poly->totloop); ++j) {
- AdjacentFaces *adj = adj_faces + loops[j].e;
- if (adj->count < 2)
- adj->face_index[adj->count] = i;
- adj->count++;
+ {
+ /* draw wireframe with color based on angle */
+ const MPoly *polys = dm->getPolyArray(dm);
+ const MLoop *loops = dm->getLoopArray(dm);
+ /* color by how many faces join at this edge */
+ const float line_color[4][3] = {
+ {0.0f, 1.0f, 0.4f}, /* 0, loose edge */
+ {1.0f, 1.0f, 1.0f}, /* 1, perimeter edge */
+ {0.0f /*ignored*/}, /* 2, regular edge */
+ {1.0f, 0.0f, 0.0f}, /* 3 or more, overbooked (legal but weird) */
+ };
+ const float max_angle = M_PI;
+ const float nowhere[3] = {0.0f};
+
+ const float min_angle_color[3] = {0.2f, 0.2f, 0.2f};
+ const float max_angle_color[3] = {0.0f, 0.6f, 1.5f};
+ const float min_angle = 0.0f; /* don't draw lines with angle < this */
+
+ typedef struct {
+ int count;
+ int face_index[2];
+ } AdjacentFaces;
+
+ float (*face_normal)[3] = MEM_mallocN(poly_ct * 3 * sizeof(float), "face_normal");
+
+ /* TODO: rename? FacesAdjacentToEdge, FacesJoinedByEdge, FacesMeetingAtEdge */
+
+ AdjacentFaces *adj_faces = MEM_callocN(edge_ct * sizeof(AdjacentFaces), "adj_faces");
+
+ for (i = 0; i < poly_ct; ++i) {
+ const MPoly *poly = polys + i;
+ int j;
+
+ BKE_mesh_calc_poly_normal(poly, loops + poly->loopstart, mverts, face_normal[i]);
+
+ for (j = poly->loopstart; j < (poly->loopstart + poly->totloop); ++j) {
+ AdjacentFaces *adj = adj_faces + loops[j].e;
+ if (adj->count < 2)
+ adj->face_index[adj->count] = i;
+ adj->count++;
+ }
}
- }
-
- /* color by how many faces join at this edge */
- const float line_color[4][3] = {
- {0.0f, 1.0f, 0.4f}, /* 0, loose edge */
- {1.0f, 1.0f, 1.0f}, /* 1, perimeter edge */
- {0.0f /*ignored*/}, /* 2, regular edge */
- {1.0f, 0.0f, 0.0f}, /* 3 or more, overbooked (legal but weird) */
- };
-
- const float min_angle_color[3] = {0.2f, 0.2f, 0.2f};
- const float max_angle_color[3] = {0.0f, 0.6f, 1.5f};
- const float min_angle = 0.0f; /* don't draw lines with angle < this */
- #if 1 /* CPU edition */
- const float max_angle = M_PI;
- const float nowhere[3] = {0.0f};
- verts = GPUx_vertex_buffer_create(2, 2 * edge_ct);
-
- GPUx_specify_attrib(verts, 0, GL_VERTEX_ARRAY, GL_FLOAT, 3, KEEP_FLOAT);
- GPUx_specify_attrib(verts, 1, GL_COLOR_ARRAY, GL_FLOAT, 3, KEEP_FLOAT);
-
- for (i = 0; i < edge_ct; ++i) {
- const MEdge *edge = edges + i;
- const AdjacentFaces *adj = adj_faces + i;
- const int v1 = 2 * i,
- v2 = 2 * i + 1;
-
- GPUx_set_attrib(verts, 0, v1, &mverts[edge->v1].co);
- GPUx_set_attrib(verts, 0, v2, &mverts[edge->v2].co);
-
- if (adj->count == 2) {
- const int f1 = adj->face_index[0],
- f2 = adj->face_index[1];
-// float angle = acosf(dot_v3v3(face_normal[adj->f[0]], face_normal[adj->f[1]]));
- const float angle = angle_normalized_v3v3(face_normal[f1], face_normal[f2]);
- if (angle < min_angle) {
- /* rasterize no fragments (essentially discards the line) */
- GPUx_set_attrib(verts, 0, v1, nowhere);
- GPUx_set_attrib(verts, 0, v2, nowhere);
+#if 1 /* CPU edition */
+ verts = GPUx_vertex_buffer_create(2, 2 * edge_ct);
+
+ GPUx_specify_attrib(verts, 0, GL_VERTEX_ARRAY, GL_FLOAT, 3, KEEP_FLOAT);
+ GPUx_specify_attrib(verts, 1, GL_COLOR_ARRAY, GL_FLOAT, 3, KEEP_FLOAT);
+
+ for (i = 0; i < edge_ct; ++i) {
+ const MEdge *edge = edges + i;
+ const AdjacentFaces *adj = adj_faces + i;
+ const int v1 = 2 * i,
+ v2 = 2 * i + 1;
+
+ GPUx_set_attrib(verts, 0, v1, &mverts[edge->v1].co);
+ GPUx_set_attrib(verts, 0, v2, &mverts[edge->v2].co);
+
+ if (adj->count == 2) {
+ const int f1 = adj->face_index[0],
+ f2 = adj->face_index[1];
+ // float angle = acosf(dot_v3v3(face_normal[adj->f[0]], face_normal[adj->f[1]]));
+ const float angle = angle_normalized_v3v3(face_normal[f1], face_normal[f2]);
+ if (angle < min_angle) {
+ /* rasterize no fragments (essentially discards the line) */
+ GPUx_set_attrib(verts, 0, v1, nowhere);
+ GPUx_set_attrib(verts, 0, v2, nowhere);
+ }
+ else {
+ /* calculate color based on angle */
+ const float factor = (angle - min_angle) / (max_angle - min_angle);
+ float angle_color[3];
+ blend_color_interpolate_float(angle_color, min_angle_color, max_angle_color, factor);
+ GPUx_set_attrib(verts, 1, v2, angle_color);
+ }
}
else {
- /* calculate color based on angle */
- const float factor = (angle - min_angle) / (max_angle - min_angle);
- float angle_color[3];
- blend_color_interpolate_float(angle_color, min_angle_color, max_angle_color, factor);
- GPUx_set_attrib(verts, 1, v2, angle_color);
+ GPUx_set_attrib(verts, 1, v2, adj->count > 2 ? line_color[3] : line_color[adj->count]);
}
}
- else {
- GPUx_set_attrib(verts, 1, v2, adj->count > 2 ? line_color[3] : line_color[adj->count]);
+#else /* shader edition */
+ /* -- uniforms -- */
+
+ /* vec3 adj_0_color
+ * vec3 adj_1_color
+ * vec3 adj_many_color
+ * vec3 min_angle_color
+ * vec3 max_angle_color
+ * float min_angle
+ */
+
+ /* -- attributes -- */
+ verts = GPUx_vertex_buffer_create(3, 2 * edge_ct);
+
+ GPUx_specify_attrib(verts, 0, "pos", GL_FLOAT, 3, KEEP_FLOAT);
+ GPUx_specify_attrib(verts, 1, "adj_count", GL_INT, 1, KEEP_INT);
+ GPUx_specify_attrib(verts, 2, "angle", GL_FLOAT, 1, KEEP_FLOAT);
+
+ for (i = 0; i < edge_ct; ++i) {
+ const MEdge *edge = edges + i;
+ const AdjacentFaces *adj = adj_faces + i;
+ const int v1 = 2 * i,
+ v2 = 2 * i + 1;
+
+ GPUx_set_attrib(verts, 0, v1, &mverts[edge->v1].co);
+ GPUx_set_attrib(verts, 0, v2, &mverts[edge->v2].co);
+
+ GPUx_set_attrib(verts, 1, v2, &adj->count);
+
+ if (adj->count == 2) {
+ const int f1 = adj->face_index[0],
+ f2 = adj->face_index[1];
+ const float angle = angle_normalized_v3v3(face_normal[f1], face_normal[f2]);
+ GPUx_set_attrib(verts, 2, v2, &angle);
+ }
}
- }
- #else /* shader edition */
- /* -- uniforms -- */
-
- /* vec3 adj_0_color
- * vec3 adj_1_color
- * vec3 adj_many_color
- * vec3 min_angle_color
- * vec3 max_angle_color
- * floa
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list