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:
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r--source/blender/draw/intern/draw_cache.c10
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.c4
-rw-r--r--source/blender/draw/intern/draw_common.h2
-rw-r--r--source/blender/draw/intern/draw_manager.c3
-rw-r--r--source/blender/draw/intern/draw_manager_data.c56
-rw-r--r--source/blender/draw/intern/draw_manager_text.c50
-rw-r--r--source/blender/draw/intern/draw_manager_text.h4
7 files changed, 55 insertions, 74 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 90b5e08f994..69135f8ade3 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -68,6 +68,12 @@ typedef struct Vert {
int class;
} Vert;
+typedef struct VertShaded {
+ float pos[3];
+ int class;
+ float nor[3];
+} VertShaded;
+
/* Batch's only (free'd as an array) */
static struct DRWShapeCache {
GPUBatch *drw_procedural_verts;
@@ -471,7 +477,7 @@ static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lo
float x = sinf(lat) * cosf(lon);
float y = cosf(lat);
float z = sinf(lat) * sinf(lon);
- GPU_vertbuf_vert_set(vbo, *v_ofs, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED});
+ GPU_vertbuf_vert_set(vbo, *v_ofs, &(VertShaded){{x, y, z}, VCLASS_EMPTY_SCALED, {x, y, z}});
(*v_ofs)++;
}
@@ -482,6 +488,8 @@ GPUBatch *DRW_cache_sphere_get(void)
const int lon_res = 24;
GPUVertFormat format = extra_vert_format();
+ GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
int v_len = (lat_res - 1) * lon_res * 6;
GPU_vertbuf_data_alloc(vbo, v_len);
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index 7d0cb7c7076..4bd0aac1ecc 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -2721,7 +2721,7 @@ static void *extract_stretch_area_init(const MeshRenderData *mr, void *buf)
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_U16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
GPUVertBuf *vbo = buf;
@@ -2788,7 +2788,7 @@ static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void *
/* Convert in place to avoid an extra allocation */
uint16_t *poly_stretch = (uint16_t *)area_ratio;
for (int p = 0; p < mr->poly_len; p++) {
- poly_stretch[p] = area_ratio[p] * 65534.0f;
+ poly_stretch[p] = area_ratio[p] * SHRT_MAX;
}
/* Copy face data for each loop. */
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index a486eb6ba77..97afb5e6aa4 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -23,10 +23,8 @@
#ifndef __DRAW_COMMON_H__
#define __DRAW_COMMON_H__
-struct DRWCallBuffer;
struct DRWPass;
struct DRWShadingGroup;
-struct GPUBatch;
struct GPUMaterial;
struct ModifierData;
struct Object;
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index cc3af48e4fe..b580ad21652 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2472,6 +2472,9 @@ void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
/* Get list of enabled engines */
{
+ /* Required by `DRW_state_draw_support()` */
+ DST.draw_ctx.v3d = v3d;
+
drw_engines_enable_basic();
if (DRW_state_draw_support()) {
drw_engines_enable_overlays();
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 83b764317a9..98474c81209 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -1416,53 +1416,19 @@ static void draw_frustum_boundbox_calc(const float (*viewinv)[4],
}
}
-static void draw_frustum_culling_planes_calc(const BoundBox *bbox, float (*frustum_planes)[4])
+static void draw_frustum_culling_planes_calc(const float (*persmat)[4], float (*frustum_planes)[4])
{
- /* TODO See if planes_from_projmat cannot do the job. */
+ planes_from_projmat(persmat,
+ frustum_planes[0],
+ frustum_planes[5],
+ frustum_planes[3],
+ frustum_planes[1],
+ frustum_planes[4],
+ frustum_planes[2]);
- /* Compute clip planes using the world space frustum corners. */
+ /* Normalize. */
for (int p = 0; p < 6; p++) {
- int q, r, s;
- switch (p) {
- case 0:
- q = 1;
- r = 2;
- s = 3;
- break; /* -X */
- case 1:
- q = 0;
- r = 4;
- s = 5;
- break; /* -Y */
- case 2:
- q = 1;
- r = 5;
- s = 6;
- break; /* +Z (far) */
- case 3:
- q = 2;
- r = 6;
- s = 7;
- break; /* +Y */
- case 4:
- q = 0;
- r = 3;
- s = 7;
- break; /* -Z (near) */
- default:
- q = 4;
- r = 7;
- s = 6;
- break; /* +X */
- }
-
- normal_quad_v3(frustum_planes[p], bbox->vec[p], bbox->vec[q], bbox->vec[r], bbox->vec[s]);
- /* Increase precision and use the mean of all 4 corners. */
- frustum_planes[p][3] = -dot_v3v3(frustum_planes[p], bbox->vec[p]);
- frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[q]);
- frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[r]);
- frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[s]);
- frustum_planes[p][3] *= 0.25f;
+ frustum_planes[p][3] /= normalize_v3(frustum_planes[p]);
}
}
@@ -1720,7 +1686,7 @@ void DRW_view_update(DRWView *view,
}
draw_frustum_boundbox_calc(viewinv, winmat, &view->frustum_corners);
- draw_frustum_culling_planes_calc(&view->frustum_corners, view->frustum_planes);
+ draw_frustum_culling_planes_calc(view->storage.persmat, view->frustum_planes);
draw_frustum_bound_sphere_calc(
&view->frustum_corners, viewinv, winmat, wininv, &view->frustum_bsphere);
diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c
index 9462a0d8072..47fafbdcbd8 100644
--- a/source/blender/draw/intern/draw_manager_text.c
+++ b/source/blender/draw/intern/draw_manager_text.c
@@ -213,14 +213,23 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
float grid = unit->system ? unit->scale_length : v3d->grid;
const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0;
const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0;
- /* when 2 edge-info options are enabled, space apart */
- const bool do_edge_textpair = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) &&
- (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG);
- const short edge_texpair_sep = (short)(5.0f * U.dpi_fac);
float clip_planes[4][4];
/* allow for displaying shape keys and deform mods */
BMIter iter;
+ /* when 2 or more edge-info options are enabled, space apart */
+ short edge_tex_count = 0;
+ if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) {
+ edge_tex_count += 1;
+ }
+ if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG) {
+ edge_tex_count += 1;
+ }
+ if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) && (em->selectmode & SCE_SELECT_EDGE)) {
+ edge_tex_count += 1;
+ }
+ const short edge_tex_sep = (short)((edge_tex_count - 1) * 5.0f * U.dpi_fac);
+
/* make the precision of the display value proportionate to the gridsize */
if (grid <= 0.01f) {
@@ -285,14 +294,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
}
- DRW_text_cache_add(dt,
- vmid,
- numstr,
- numstr_len,
- 0,
- (do_edge_textpair) ? edge_texpair_sep : 0,
- txt_flag,
- col);
+ DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, edge_tex_sep, txt_flag, col);
}
}
}
@@ -347,14 +349,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
(is_rad) ? angle : RAD2DEGF(angle),
(is_rad) ? "r" : "°");
- DRW_text_cache_add(dt,
- vmid,
- numstr,
- numstr_len,
- 0,
- (do_edge_textpair) ? -edge_texpair_sep : 0,
- txt_flag,
- col);
+ DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, -edge_tex_sep, txt_flag, col);
}
}
}
@@ -494,6 +489,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
if (em->selectmode & SCE_SELECT_EDGE) {
BMEdge *e;
+ const bool use_edge_tex_sep = (edge_tex_count == 2);
+ const bool use_edge_tex_len = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN);
+
BM_ITER_MESH_INDEX (e, &iter, em->bm, BM_EDGES_OF_MESH, i) {
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
float v1_clip[3], v2_clip[3];
@@ -506,7 +504,15 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
mul_m4_v3(ob->obmat, vmid);
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
- DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, 0, txt_flag, col);
+ DRW_text_cache_add(
+ dt,
+ vmid,
+ numstr,
+ numstr_len,
+ 0,
+ (use_edge_tex_sep) ? (use_edge_tex_len) ? -edge_tex_sep : edge_tex_sep : 0,
+ txt_flag,
+ col);
}
}
}
@@ -526,4 +532,4 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
}
}
}
-} \ No newline at end of file
+}
diff --git a/source/blender/draw/intern/draw_manager_text.h b/source/blender/draw/intern/draw_manager_text.h
index a8eb45ee8f5..393645e614a 100644
--- a/source/blender/draw/intern/draw_manager_text.h
+++ b/source/blender/draw/intern/draw_manager_text.h
@@ -23,11 +23,11 @@
#ifndef __DRAW_MANAGER_TEXT_H__
#define __DRAW_MANAGER_TEXT_H__
-struct DRWTextStore;
struct ARegion;
-struct View3D;
+struct DRWTextStore;
struct Object;
struct UnitSettings;
+struct View3D;
struct DRWTextStore *DRW_text_cache_create(void);
void DRW_text_cache_destroy(struct DRWTextStore *dt);