[Bf-blender-cvs] [b0c125bcd3] blender2.8: Clay Engine: draw Speaker
Clément Foucault
noreply at git.blender.org
Wed Feb 15 12:30:37 CET 2017
Commit: b0c125bcd30b96dd8a1fbf46249d3978b15115bf
Author: Clément Foucault
Date: Wed Feb 15 03:38:21 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBb0c125bcd30b96dd8a1fbf46249d3978b15115bf
Clay Engine: draw Speaker
===================================================================
M source/blender/draw/intern/draw_cache.c
M source/blender/draw/intern/draw_cache.h
M source/blender/draw/intern/draw_mode_pass.c
===================================================================
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 6ebb9008b6..7d5dc6e6d8 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -51,6 +51,7 @@ static struct DRWShapeCache{
Batch *drw_axis_names;
Batch *drw_lamp;
Batch *drw_lamp_sunrays;
+ Batch *drw_speaker;
} SHC = {NULL};
void DRW_shape_cache_free(void)
@@ -81,6 +82,8 @@ void DRW_shape_cache_free(void)
Batch_discard_all(SHC.drw_lamp);
if (SHC.drw_lamp_sunrays)
Batch_discard_all(SHC.drw_lamp_sunrays);
+ if (SHC.drw_speaker)
+ Batch_discard_all(SHC.drw_speaker);
}
/* Quads */
@@ -548,6 +551,64 @@ Batch *DRW_cache_lamp_sunrays_get(void)
return SHC.drw_lamp_sunrays;
}
+/* Speaker */
+Batch *DRW_cache_speaker_get(void)
+{
+ if (!SHC.drw_speaker) {
+ float v[3];
+ const int segments = 16;
+ int vidx = 0;
+
+ /* 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, 3 * segments * 2 + 4 * 4);
+
+ for (int j = 0; j < 3; j++) {
+ float z = 0.25f * j - 0.125f;
+ float r = (j == 0 ? 0.5f : 0.25f);
+
+ copy_v3_fl3(v, r, 0.0f, z);
+ setAttrib(vbo, pos_id, vidx++, v);
+ for (int i = 1; i < segments; i++) {
+ float x = cosf(2.f * (float)M_PI * i / segments) * r;
+ float y = sinf(2.f * (float)M_PI * i / segments) * r;
+ copy_v3_fl3(v, x, y, z);
+ setAttrib(vbo, pos_id, vidx++, v);
+ setAttrib(vbo, pos_id, vidx++, v);
+ }
+ copy_v3_fl3(v, r, 0.0f, z);
+ setAttrib(vbo, pos_id, vidx++, v);
+ }
+
+ for (int j = 0; j < 4; j++) {
+ float x = (((j + 1) % 2) * (j - 1)) * 0.5f;
+ float y = ((j % 2) * (j - 2)) * 0.5f;
+ for (int i = 0; i < 3; i++) {
+ if (i == 1) {
+ x *= 0.5f;
+ y *= 0.5f;
+ }
+
+ float z = 0.25f * i - 0.125f;
+ copy_v3_fl3(v, x, y, z);
+ setAttrib(vbo, pos_id, vidx++, v);
+ if (i == 1) {
+ setAttrib(vbo, pos_id, vidx++, v);
+ }
+ }
+ }
+
+ SHC.drw_speaker = Batch_create(GL_LINES, vbo, NULL);
+ }
+ return SHC.drw_speaker;
+}
+
/* Object Center */
Batch *DRW_cache_single_vert_get(void)
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index b101b00473..efcdbfcc1a 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -50,6 +50,9 @@ struct Batch *DRW_cache_axis_names_get(void);
struct Batch *DRW_cache_lamp_get(void);
struct Batch *DRW_cache_lamp_sunrays_get(void);
+/* Speaker */
+struct Batch *DRW_cache_speaker_get(void);
+
/* Meshes */
struct Batch *DRW_cache_wire_overlay_get(struct Object *ob);
struct Batch *DRW_cache_wire_outline_get(struct Object *ob);
diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c
index 7ad00fffcd..44a837e314 100644
--- a/source/blender/draw/intern/draw_mode_pass.c
+++ b/source/blender/draw/intern/draw_mode_pass.c
@@ -50,6 +50,9 @@ static DRWShadingGroup *single_arrow_line;
static DRWShadingGroup *arrows;
static DRWShadingGroup *axis_names;
+/* Speaker */
+static DRWShadingGroup *speaker;
+
/* Lamps */
static DRWShadingGroup *lamp_center;
static DRWShadingGroup *lamp_center_group;
@@ -228,6 +231,10 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa
geom = DRW_cache_axis_names_get();
axis_names = shgroup_instance_axis_names(*non_meshes, geom);
+ /* Speaker */
+ geom = DRW_cache_speaker_get();
+ speaker = shgroup_instance(*non_meshes, geom);
+
/* Lamps */
lampCenterSize = (U.obcenter_dia + 1.5f) * U.pixelsize;
lampCircleRad = U.pixelsize * 9.0f;
@@ -515,6 +522,15 @@ static void DRW_draw_empty(Object *ob)
}
}
+static void DRW_draw_speaker(Object *ob)
+{
+ float *color;
+ static float one = 1.0f;
+ draw_object_wire_theme(ob, &color);
+
+ DRW_shgroup_dynamic_call_add(speaker, color, &one, ob->obmat);
+}
+
void DRW_shgroup_non_meshes(DRWPass *UNUSED(non_meshes), Object *ob)
{
switch (ob->type) {
@@ -524,6 +540,10 @@ void DRW_shgroup_non_meshes(DRWPass *UNUSED(non_meshes), Object *ob)
case OB_CAMERA:
case OB_EMPTY:
DRW_draw_empty(ob);
+ break;
+ case OB_SPEAKER:
+ DRW_draw_speaker(ob);
+ break;
default:
break;
}
More information about the Bf-blender-cvs
mailing list