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:
authorJeroen Bakker <j.bakker@atmind.nl>2019-09-03 14:42:11 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2019-09-04 09:08:27 +0300
commit64f8f7db7cce0c8923afcabb523f7400f744387e (patch)
treec60fe2a51846a9b19860fbe016d1d64cea098880 /source/blender/draw/intern/draw_cache_extract_mesh.c
parent0cb730146b09b4a38abcc04e9d4660d6c2f43945 (diff)
Fix T63755: Area Stretching Overlay
Support for UV Stretching overlay during multi object editing. The VBO now holds the ratios per fase. In the shader these ratios will be compared against the global ratios. The global rations are created from all selected objects. The current implementation does not fit well with the draw module. The plan is to move the drawing of other spaces towards the draw manager what leads to a better fit. Currently the details on this solution is unclear but this requirement will become an attentionpoint in the future design. Reviewed By: fclem Differential Revision: https://developer.blender.org/D5665
Diffstat (limited to 'source/blender/draw/intern/draw_cache_extract_mesh.c')
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index d952965de35..8bca2ad2c45 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -2676,7 +2676,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, "stretch", GPU_COMP_U16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_U16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
GPUVertBuf *vbo = buf;
@@ -2703,7 +2703,7 @@ BLI_INLINE float area_ratio_to_stretch(float ratio, float tot_ratio, float inv_t
static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void *UNUSED(data))
{
- float totarea = 0, totuvarea = 0;
+ float tot_area = 0.0f, tot_uv_area = 0.0f;
float *area_ratio = MEM_mallocN(sizeof(float) * mr->poly_len, __func__);
if (mr->extract_type == MR_EXTRACT_BMESH) {
@@ -2716,8 +2716,8 @@ static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void *
BM_ITER_MESH_INDEX (efa, &f_iter, mr->bm, BM_FACES_OF_MESH, f) {
float area = BM_face_calc_area(efa);
float uvarea = BM_face_calc_area_uv(efa, uv_ofs);
- totarea += area;
- totuvarea += uvarea;
+ tot_area += area;
+ tot_uv_area += uvarea;
area_ratio[f] = area_ratio_get(area, uvarea);
}
}
@@ -2727,8 +2727,8 @@ static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void *
for (int p = 0; p < mr->poly_len; p++, mpoly++) {
float area = BKE_mesh_calc_poly_area(mpoly, &mr->mloop[mpoly->loopstart], mr->mvert);
float uvarea = BKE_mesh_calc_poly_uv_area(mpoly, uv_data);
- totarea += area;
- totuvarea += uvarea;
+ tot_area += area;
+ tot_uv_area += uvarea;
area_ratio[p] = area_ratio_get(area, uvarea);
}
}
@@ -2737,21 +2737,13 @@ static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void *
BLI_assert(0);
}
- float tot_ratio, inv_tot_ratio;
- if (totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) {
- tot_ratio = 0.0f;
- inv_tot_ratio = 0.0f;
- }
- else {
- tot_ratio = totarea / totuvarea;
- inv_tot_ratio = totuvarea / totarea;
- }
+ mr->cache->tot_area = tot_area;
+ mr->cache->tot_uv_area = tot_uv_area;
/* 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++) {
- float stretch = area_ratio_to_stretch(area_ratio[p], tot_ratio, inv_tot_ratio);
- poly_stretch[p] = (1.0f - stretch) * 65534.0f;
+ poly_stretch[p] = area_ratio[p] * 65534.0f;
}
/* Copy face data for each loop. */