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:
authorClément Foucault <foucault.clem@gmail.com>2020-01-23 17:38:33 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-01-23 17:41:41 +0300
commit170844135aa826423394210039047070a99e8a85 (patch)
treeeba44668dbf62897ba345a4f58a496f25745db0f /source/blender
parent3cd32c376db32d4072c34b5b6a04943876d8db38 (diff)
Fix T67050 Overlay: Forcefield limits are not dashed
This adds some kind of dashing to the tube and cone limits. Although the dashing is in object space and is not a good as old dashing. But it is the least time consuming and least complex solution.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/intern/draw_cache.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 4d10e781e79..f2e43e032a9 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -1222,10 +1222,11 @@ GPUBatch *DRW_cache_field_curve_get(void)
GPUBatch *DRW_cache_field_tube_limit_get(void)
{
#define CIRCLE_RESOL 32
+#define SIDE_STIPPLE 32
if (!SHC.drw_field_tube_limit) {
GPUVertFormat format = extra_vert_format();
- int v_len = 2 * (CIRCLE_RESOL * 2 + 4);
+ int v_len = 2 * (CIRCLE_RESOL * 2 + 4 * SIDE_STIPPLE / 2);
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
GPU_vertbuf_data_alloc(vbo, v_len);
@@ -1233,14 +1234,14 @@ GPUBatch *DRW_cache_field_tube_limit_get(void)
int flag = VCLASS_EMPTY_SIZE;
/* Caps */
for (int i = 0; i < 2; i++) {
- float z = (float)i * 2.0f - 1.0f;
- circle_verts(vbo, &v, CIRCLE_RESOL, 1.0f, z, flag);
+ float z = i * 2.0f - 1.0f;
+ circle_dashed_verts(vbo, &v, CIRCLE_RESOL, 1.0f, z, flag);
}
/* Side Edges */
for (int a = 0; a < 4; a++) {
- for (int i = 0; i < 2; i++) {
- float z = (float)i * 2.0f - 1.0f;
- float angle = (2.0f * M_PI * a) / 4.0f;
+ float angle = (2.0f * M_PI * a) / 4.0f;
+ for (int i = 0; i < SIDE_STIPPLE; i++) {
+ float z = (i / (float)SIDE_STIPPLE) * 2.0f - 1.0f;
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{sinf(angle), cosf(angle), z}, flag});
}
}
@@ -1248,16 +1249,18 @@ GPUBatch *DRW_cache_field_tube_limit_get(void)
SHC.drw_field_tube_limit = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_field_tube_limit;
+#undef SIDE_STIPPLE
#undef CIRCLE_RESOL
}
GPUBatch *DRW_cache_field_cone_limit_get(void)
{
#define CIRCLE_RESOL 32
+#define SIDE_STIPPLE 32
if (!SHC.drw_field_cone_limit) {
GPUVertFormat format = extra_vert_format();
- int v_len = 2 * (CIRCLE_RESOL * 2 + 4);
+ int v_len = 2 * (CIRCLE_RESOL * 2 + 4 * SIDE_STIPPLE / 2);
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
GPU_vertbuf_data_alloc(vbo, v_len);
@@ -1265,14 +1268,14 @@ GPUBatch *DRW_cache_field_cone_limit_get(void)
int flag = VCLASS_EMPTY_SIZE;
/* Caps */
for (int i = 0; i < 2; i++) {
- float z = (float)i * 2.0f - 1.0f;
- circle_verts(vbo, &v, CIRCLE_RESOL, 1.0f, z, flag);
+ float z = i * 2.0f - 1.0f;
+ circle_dashed_verts(vbo, &v, CIRCLE_RESOL, 1.0f, z, flag);
}
/* Side Edges */
for (int a = 0; a < 4; a++) {
- for (int i = 0; i < 2; i++) {
- float z = (float)i * 2.0f - 1.0f;
- float angle = (2.0f * M_PI * a) / 4.0f;
+ float angle = (2.0f * M_PI * a) / 4.0f;
+ for (int i = 0; i < SIDE_STIPPLE; i++) {
+ float z = (i / (float)SIDE_STIPPLE) * 2.0f - 1.0f;
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{sinf(angle) * z, cosf(angle) * z, z}, flag});
}
}
@@ -1280,6 +1283,7 @@ GPUBatch *DRW_cache_field_cone_limit_get(void)
SHC.drw_field_cone_limit = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
return SHC.drw_field_cone_limit;
+#undef SIDE_STIPPLE
#undef CIRCLE_RESOL
}