[Bf-blender-cvs] [8ad5241778c] blender-v3.1-release: Fix T95250: bake margin adjacent faces uses stale UV map in edit mode

Martijn Versteegh noreply at git.blender.org
Mon Jan 31 18:26:52 CET 2022


Commit: 8ad5241778ccad18754b333b804b6898f108b087
Author: Martijn Versteegh
Date:   Mon Jan 31 13:56:51 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB8ad5241778ccad18754b333b804b6898f108b087

Fix T95250: bake margin adjacent faces uses stale UV map in edit mode

Use the evaluated mesh to generate the Adjacent Faces margin.

Baking used the evaluated mesh, but generating the margin used the base
mesh. This would lead to generating the margin from a stale UV map when the
UV editor was open and the UV map was changed. Fix it by passing the same
mesh as used for baking through to the margin generation.

Differential Revision: https://developer.blender.org/D13938

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

M	source/blender/editors/object/object_bake_api.c

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

diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index d56d0edd5a2..f52d2103fff 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -188,7 +188,7 @@ static bool write_internal_bake_pixels(Image *image,
                                        const char margin_type,
                                        const bool is_clear,
                                        const bool is_noncolor,
-                                       Mesh const *mesh,
+                                       Mesh const *mesh_eval,
                                        char const *uv_layer)
 {
   ImBuf *ibuf;
@@ -285,7 +285,7 @@ static bool write_internal_bake_pixels(Image *image,
 
   /* margins */
   if (margin > 0) {
-    RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh, uv_layer);
+    RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh_eval, uv_layer);
   }
 
   ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
@@ -334,7 +334,7 @@ static bool write_external_bake_pixels(const char *filepath,
                                        const int margin_type,
                                        ImageFormatData *im_format,
                                        const bool is_noncolor,
-                                       Mesh const *mesh,
+                                       Mesh const *mesh_eval,
                                        char const *uv_layer)
 {
   ImBuf *ibuf = NULL;
@@ -392,7 +392,7 @@ static bool write_external_bake_pixels(const char *filepath,
 
     mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");
     RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
-    RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh, uv_layer);
+    RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh_eval, uv_layer);
 
     if (mask_buffer) {
       MEM_freeN(mask_buffer);
@@ -774,10 +774,10 @@ static bool bake_targets_output_internal(const BakeAPIRender *bkr,
                                          BakeTargets *targets,
                                          Object *ob,
                                          BakePixel *pixel_array,
-                                         ReportList *reports)
+                                         ReportList *reports,
+                                         Mesh *mesh_eval)
 {
   bool all_ok = true;
-  const Mesh *me = (Mesh *)ob->data;
 
   for (int i = 0; i < targets->num_images; i++) {
     BakeImage *bk_image = &targets->images[i];
@@ -791,7 +791,7 @@ static bool bake_targets_output_internal(const BakeAPIRender *bkr,
                                                bkr->margin_type,
                                                bkr->is_clear,
                                                targets->is_noncolor,
-                                               me,
+                                               mesh_eval,
                                                bkr->uv_layer);
 
     /* might be read by UI to set active image for display */
@@ -852,7 +852,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr,
                                          BakeTargets *targets,
                                          Object *ob,
                                          Object *ob_eval,
-                                         Mesh *me,
+                                         Mesh *mesh_eval,
                                          BakePixel *pixel_array,
                                          ReportList *reports)
 {
@@ -886,8 +886,8 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr,
         if (ob_eval->mat[i]) {
           BLI_path_suffix(name, FILE_MAX, ob_eval->mat[i]->id.name + 2, "_");
         }
-        else if (me->mat[i]) {
-          BLI_path_suffix(name, FILE_MAX, me->mat[i]->id.name + 2, "_");
+        else if (mesh_eval->mat[i]) {
+          BLI_path_suffix(name, FILE_MAX, mesh_eval->mat[i]->id.name + 2, "_");
         }
         else {
           /* if everything else fails, use the material index */
@@ -909,7 +909,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr,
                                                bkr->margin_type,
                                                &bake->im_format,
                                                targets->is_noncolor,
-                                               me,
+                                               mesh_eval,
                                                bkr->uv_layer);
 
     if (!ok) {
@@ -1211,7 +1211,7 @@ static bool bake_targets_output(const BakeAPIRender *bkr,
 {
   if (bkr->target == R_BAKE_TARGET_IMAGE_TEXTURES) {
     if (bkr->save_mode == R_BAKE_SAVE_INTERNAL) {
-      return bake_targets_output_internal(bkr, targets, ob, pixel_array, reports);
+      return bake_targets_output_internal(bkr, targets, ob, pixel_array, reports, me_eval);
     }
     if (bkr->save_mode == R_BAKE_SAVE_EXTERNAL) {
       return bake_targets_output_external(



More information about the Bf-blender-cvs mailing list