[Bf-blender-cvs] [7bbdc6996a7] master: Fix T69941 Assert selecting UVs

Clément Foucault noreply at git.blender.org
Fri Sep 27 17:19:07 CEST 2019


Commit: 7bbdc6996a71612b719053e62a9f753a3852e215
Author: Clément Foucault
Date:   Fri Sep 27 16:40:18 2019 +0200
Branches: master
https://developer.blender.org/rB7bbdc6996a71612b719053e62a9f753a3852e215

Fix T69941 Assert selecting UVs

Was caused by DRW_mesh_batch_cache_get_edituv_faces_stretch_area called
after DRW_mesh_batch_cache_create_requested. So it was created on the wrong
object/mesh.

===================================================================

M	source/blender/draw/intern/draw_cache_impl.h
M	source/blender/draw/intern/draw_cache_impl_mesh.c
M	source/blender/editors/uvedit/uvedit_draw.c

===================================================================

diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 970b6053cf9..cdc1791b153 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -151,8 +151,8 @@ struct GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_wireframes_face(struct Mesh *me);
 /* edit-mesh UV editor */
 struct GPUBatch *DRW_mesh_batch_cache_get_edituv_faces_stretch_area(struct Mesh *me,
-                                                                    float *tot_area,
-                                                                    float *tot_uv_area);
+                                                                    float **tot_area,
+                                                                    float **tot_uv_area);
 struct GPUBatch *DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_edituv_faces(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_edituv_edges(struct Mesh *me);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index e399b784145..77b9daa959d 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -882,18 +882,18 @@ GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me)
  * The `cache->tot_area` and cache->tot_uv_area` update are calculation are
  * only valid after calling `DRW_mesh_batch_cache_create_requested`. */
 GPUBatch *DRW_mesh_batch_cache_get_edituv_faces_stretch_area(Mesh *me,
-                                                             float *tot_area,
-                                                             float *tot_uv_area)
+                                                             float **tot_area,
+                                                             float **tot_uv_area)
 {
   MeshBatchCache *cache = mesh_batch_cache_get(me);
   texpaint_request_active_uv(cache, me);
   mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRETCH_AREA);
 
   if (tot_area != NULL) {
-    *tot_area = cache->tot_area;
+    *tot_area = &cache->tot_area;
   }
   if (tot_uv_area != NULL) {
-    *tot_uv_area = cache->tot_uv_area;
+    *tot_uv_area = &cache->tot_uv_area;
   }
   return DRW_batch_request(&cache->batch.edituv_faces_stretch_area);
 }
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index bd941968418..fafd54804c0 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -177,6 +177,7 @@ static void uvedit_get_batches(Object *ob,
                                float *tot_area,
                                float *tot_area_uv)
 {
+  float *tmp_tot_area, *tmp_tot_area_uv;
   int drawfaces = draw_uvs_face_check(scene->toolsettings);
   const bool draw_stretch = (sima->flag & SI_DRAW_STRETCH) != 0;
   const bool draw_faces = (sima->flag & SI_NO_DRAWFACES) == 0;
@@ -193,7 +194,8 @@ static void uvedit_get_batches(Object *ob,
   }
 
   if (draw_stretch && (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA)) {
-    batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_area(ob->data, NULL, NULL);
+    batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_area(
+        ob->data, &tmp_tot_area, &tmp_tot_area_uv);
   }
   else if (draw_stretch) {
     batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(ob->data);
@@ -207,11 +209,11 @@ static void uvedit_get_batches(Object *ob,
 
   DRW_mesh_batch_cache_create_requested(ob, ob->data, scene, false, false);
 
-  /* after create_requested we can load the actual areas */
-  float tmp_tot_area, tmp_tot_area_uv;
-  DRW_mesh_batch_cache_get_edituv_faces_stretch_area(ob->data, &tmp_tot_area, &tmp_tot_area_uv);
-  *tot_area += tmp_tot_area;
-  *tot_area_uv += tmp_tot_area_uv;
+  if (draw_stretch && (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA)) {
+    /* after create_requested we can load the actual areas */
+    *tot_area += *tmp_tot_area;
+    *tot_area_uv += *tmp_tot_area_uv;
+  }
 }
 
 static void draw_uvs_shadow(SpaceImage *UNUSED(sima),



More information about the Bf-blender-cvs mailing list