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
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2017-02-09 19:27:01 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-02-11 22:36:20 +0300
commit08c1afb088743a57eb2e9475a6e531ae27b8b4ac (patch)
treec612b1bfed5a7c3f6abb32dcf154e506d9fb3694 /source
parentfc0797142d0c94342832bbead9db40e3e6ca9186 (diff)
Clay Engine: Separate batch for Z straight line
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/intern/draw_cache.c49
-rw-r--r--source/blender/draw/intern/draw_cache.h3
2 files changed, 33 insertions, 19 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 1255a083b82..7ea6b8d0066 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -42,9 +42,9 @@ static struct DRWShapeCache{
Batch *drw_fullscreen_quad;
Batch *drw_plain_axes;
Batch *drw_single_arrow;
- Batch *drw_single_arrow_line;
Batch *drw_cube;
Batch *drw_circle;
+ Batch *drw_line;
Batch *drw_empty_sphere;
Batch *drw_empty_cone;
Batch *drw_arrows;
@@ -62,12 +62,12 @@ void DRW_shape_cache_free(void)
Batch_discard_all(SHC.drw_plain_axes);
if (SHC.drw_single_arrow)
Batch_discard_all(SHC.drw_single_arrow);
- if (SHC.drw_single_arrow_line)
- Batch_discard_all(SHC.drw_single_arrow_line);
if (SHC.drw_cube)
Batch_discard_all(SHC.drw_cube);
if (SHC.drw_circle)
Batch_discard_all(SHC.drw_circle);
+ if (SHC.drw_line)
+ Batch_discard_all(SHC.drw_line);
if (SHC.drw_empty_sphere)
Batch_discard_all(SHC.drw_empty_sphere);
if (SHC.drw_empty_cone)
@@ -149,7 +149,6 @@ Batch *DRW_cache_cube_get(void)
return SHC.drw_cube;
}
-
Batch *DRW_cache_circle_get(void)
{
#define CIRCLE_RESOL 32
@@ -184,6 +183,31 @@ Batch *DRW_cache_circle_get(void)
#undef CIRCLE_RESOL
}
+Batch *DRW_cache_single_line_get(void)
+{
+ /* Z axis line */
+ if (!SHC.drw_line) {
+ float v1[3] = {0.0f, 0.0f, 0.0f};
+ float v2[3] = {0.0f, 0.0f, 1.0f};
+
+ /* Position Only 3D format */
+ static VertexFormat format = { 0 };
+ static unsigned pos_id;
+ if (format.attrib_ct == 0) {
+ pos_id = add_attrib(&format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
+ }
+
+ VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
+ VertexBuffer_allocate_data(vbo, 2);
+
+ setAttrib(vbo, pos_id, 0, v1);
+ setAttrib(vbo, pos_id, 1, v2);
+
+ SHC.drw_line = Batch_create(GL_LINES, vbo, NULL);
+ }
+ return SHC.drw_line;
+}
+
/* Empties */
Batch *DRW_cache_plain_axes_get(void)
{
@@ -218,9 +242,9 @@ Batch *DRW_cache_plain_axes_get(void)
return SHC.drw_plain_axes;
}
-Batch *DRW_cache_single_arrow_get(Batch **line)
+Batch *DRW_cache_single_arrow_get(void)
{
- if (!SHC.drw_single_arrow_line || !SHC.drw_single_arrow) {
+ if (!SHC.drw_single_arrow) {
float v1[3] = {0.0f, 0.0f, 0.0f}, v2[3], v3[3];
/* Position Only 3D format */
@@ -230,18 +254,8 @@ Batch *DRW_cache_single_arrow_get(Batch **line)
pos_id = add_attrib(&format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
}
- /* Line */
- VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
- VertexBuffer_allocate_data(vbo, 2);
-
- setAttrib(vbo, pos_id, 0, v1);
- v1[2] = 1.0f;
- setAttrib(vbo, pos_id, 1, v1);
-
- SHC.drw_single_arrow_line = Batch_create(GL_LINES, vbo, NULL);
-
/* Square Pyramid */
- vbo = VertexBuffer_create_with_format(&format);
+ VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
VertexBuffer_allocate_data(vbo, 12);
v2[0] = 0.035f; v2[1] = 0.035f;
@@ -265,7 +279,6 @@ Batch *DRW_cache_single_arrow_get(Batch **line)
SHC.drw_single_arrow = Batch_create(GL_TRIANGLES, vbo, NULL);
}
- *line = SHC.drw_single_arrow_line;
return SHC.drw_single_arrow;
}
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index c53f3d88af3..0e467bddbfa 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -34,10 +34,11 @@ void DRW_shape_cache_free(void);
/* Common Shapes */
struct Batch *DRW_cache_fullscreen_quad_get(void);
struct Batch *DRW_cache_single_vert_get(void);
+struct Batch *DRW_cache_single_line_get(void);
/* Empties */
struct Batch *DRW_cache_plain_axes_get(void);
-struct Batch *DRW_cache_single_arrow_get(struct Batch **line);
+struct Batch *DRW_cache_single_arrow_get(void);
struct Batch *DRW_cache_cube_get(void);
struct Batch *DRW_cache_circle_get(void);
struct Batch *DRW_cache_empty_sphere_get(void);