Revert part of "GPencil: Invert Paste operator and make Paste to Active default"
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 23 Sep 2019 09:02:58 +0000 (11:02 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 23 Sep 2019 09:09:00 +0000 (11:09 +0200)
This commit accidentally undid a bunch of previous commits. Only the intended
changes are left now.

intern/cycles/device/device_cpu.cpp
intern/cycles/kernel/closure/bsdf_microfacet.h
intern/cycles/kernel/closure/bsdf_microfacet_multi.h
intern/cycles/kernel/svm/svm_color_util.h
source/blender/blenloader/intern/readfile.c
source/blender/draw/intern/draw_cache_impl_mesh.c

index b2d923dfdf005cbb487797714d7078b07c3abf4f..c2843a61e6d6e874eb5b91f07e87700586af4428 100644 (file)
@@ -114,6 +114,12 @@ template<typename F> class KernelFunctions {
       architecture_name = "SSE2";
       kernel = kernel_sse2;
     }
+#else
+    {
+      /* Dummy to prevent the architecture if below become
+       * conditional when WITH_CYCLES_OPTIMIZED_KERNEL_SSE2
+       * is not defined. */
+    }
 #endif
 
     if (strcmp(architecture_name, logged_architecture) != 0) {
index 7d7ccfa777400eebd3b59a454250c8c275d2bb91..2f73434706cd95f64861c6b7252efa5079286b39 100644 (file)
@@ -303,9 +303,7 @@ ccl_device int bsdf_microfacet_ggx_setup(MicrofacetBsdf *bsdf)
 
 ccl_device int bsdf_microfacet_ggx_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
 {
-  bsdf->extra->cspec0.x = saturate(bsdf->extra->cspec0.x);
-  bsdf->extra->cspec0.y = saturate(bsdf->extra->cspec0.y);
-  bsdf->extra->cspec0.z = saturate(bsdf->extra->cspec0.z);
+  bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
 
   float F0 = fresnel_dielectric_cos(1.0f, bsdf->ior);
   float F = average(interpolate_fresnel_color(sd->I, bsdf->N, bsdf->ior, F0, bsdf->extra->cspec0));
@@ -321,9 +319,7 @@ ccl_device int bsdf_microfacet_ggx_fresnel_setup(MicrofacetBsdf *bsdf, const Sha
 
 ccl_device int bsdf_microfacet_ggx_clearcoat_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
 {
-  bsdf->extra->cspec0.x = saturate(bsdf->extra->cspec0.x);
-  bsdf->extra->cspec0.y = saturate(bsdf->extra->cspec0.y);
-  bsdf->extra->cspec0.z = saturate(bsdf->extra->cspec0.z);
+  bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
 
   float F0 = fresnel_dielectric_cos(1.0f, bsdf->ior);
   float F = average(interpolate_fresnel_color(sd->I, bsdf->N, bsdf->ior, F0, bsdf->extra->cspec0));
@@ -366,9 +362,7 @@ ccl_device int bsdf_microfacet_ggx_aniso_setup(MicrofacetBsdf *bsdf)
 
 ccl_device int bsdf_microfacet_ggx_aniso_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
 {
-  bsdf->extra->cspec0.x = saturate(bsdf->extra->cspec0.x);
-  bsdf->extra->cspec0.y = saturate(bsdf->extra->cspec0.y);
-  bsdf->extra->cspec0.z = saturate(bsdf->extra->cspec0.z);
+  bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
 
   float F0 = fresnel_dielectric_cos(1.0f, bsdf->ior);
   float F = average(interpolate_fresnel_color(sd->I, bsdf->N, bsdf->ior, F0, bsdf->extra->cspec0));
index 07be33ee6b591b658a8019179614fb2e2c951969..9780dd8741591d94055943b5b35d2dff5e232a88 100644 (file)
@@ -378,12 +378,8 @@ ccl_device int bsdf_microfacet_multi_ggx_common_setup(MicrofacetBsdf *bsdf)
 {
   bsdf->alpha_x = clamp(bsdf->alpha_x, 1e-4f, 1.0f);
   bsdf->alpha_y = clamp(bsdf->alpha_y, 1e-4f, 1.0f);
-  bsdf->extra->color.x = saturate(bsdf->extra->color.x);
-  bsdf->extra->color.y = saturate(bsdf->extra->color.y);
-  bsdf->extra->color.z = saturate(bsdf->extra->color.z);
-  bsdf->extra->cspec0.x = saturate(bsdf->extra->cspec0.x);
-  bsdf->extra->cspec0.y = saturate(bsdf->extra->cspec0.y);
-  bsdf->extra->cspec0.z = saturate(bsdf->extra->cspec0.z);
+  bsdf->extra->color = saturate3(bsdf->extra->color);
+  bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
 
   return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_NEEDS_LCG;
 }
@@ -568,9 +564,7 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_setup(MicrofacetBsdf *bsdf)
   bsdf->alpha_x = clamp(bsdf->alpha_x, 1e-4f, 1.0f);
   bsdf->alpha_y = bsdf->alpha_x;
   bsdf->ior = max(0.0f, bsdf->ior);
-  bsdf->extra->color.x = saturate(bsdf->extra->color.x);
-  bsdf->extra->color.y = saturate(bsdf->extra->color.y);
-  bsdf->extra->color.z = saturate(bsdf->extra->color.z);
+  bsdf->extra->color = saturate3(bsdf->extra->color);
 
   bsdf->type = CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID;
 
@@ -583,12 +577,8 @@ ccl_device int bsdf_microfacet_multi_ggx_glass_fresnel_setup(MicrofacetBsdf *bsd
   bsdf->alpha_x = clamp(bsdf->alpha_x, 1e-4f, 1.0f);
   bsdf->alpha_y = bsdf->alpha_x;
   bsdf->ior = max(0.0f, bsdf->ior);
-  bsdf->extra->color.x = saturate(bsdf->extra->color.x);
-  bsdf->extra->color.y = saturate(bsdf->extra->color.y);
-  bsdf->extra->color.z = saturate(bsdf->extra->color.z);
-  bsdf->extra->cspec0.x = saturate(bsdf->extra->cspec0.x);
-  bsdf->extra->cspec0.y = saturate(bsdf->extra->cspec0.y);
-  bsdf->extra->cspec0.z = saturate(bsdf->extra->cspec0.z);
+  bsdf->extra->color = saturate3(bsdf->extra->color);
+  bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
 
   bsdf->type = CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID;
 
index 3a6a5ba782f551e41dc43f44d7bf8862acb26518..0f571eb7253c6f7fc92190d69f3def895b715c4b 100644 (file)
@@ -255,13 +255,7 @@ ccl_device float3 svm_mix_linear(float t, float3 col1, float3 col2)
 
 ccl_device float3 svm_mix_clamp(float3 col)
 {
-  float3 outcol = col;
-
-  outcol.x = saturate(col.x);
-  outcol.y = saturate(col.y);
-  outcol.z = saturate(col.z);
-
-  return outcol;
+  return saturate3(col);
 }
 
 ccl_device_noinline_cpu float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
index 87db0ce1ad2f357103d7b78fe0ca17953fb0267d..15203461ef4dc662cc5714e5915d12f03bfc7162 100644 (file)
@@ -7863,6 +7863,45 @@ static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map)
   BKE_sequencer_base_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map);
 }
 
+static int lib_link_main_data_restore_cb(void *user_data,
+                                         ID *UNUSED(id_self),
+                                         ID **id_pointer,
+                                         int cb_flag)
+{
+  if (cb_flag & IDWALK_CB_PRIVATE || *id_pointer == NULL) {
+    return IDWALK_RET_NOP;
+  }
+
+  /* Special ugly case here, thanks again for those non-IDs IDs... */
+  /* We probably need to add more cases here (hint: nodetrees),
+   * but will wait for changes from D5559 to get in first. */
+  if (GS((*id_pointer)->name) == ID_GR) {
+    Collection *collection = (Collection *)*id_pointer;
+    if (collection->flag & COLLECTION_IS_MASTER) {
+      return IDWALK_RET_NOP;
+    }
+  }
+
+  struct IDNameLib_Map *id_map = user_data;
+
+  /* Note: Handling of usercount here is really bad, defining its own system...
+   * Will have to be refactored at some point, but that is not top priority task for now.
+   * And all usercounts are properly recomputed at the end of the undo management code anyway. */
+  *id_pointer = restore_pointer_by_name(
+      id_map, *id_pointer, (cb_flag & IDWALK_CB_USER_ONE) ? USER_REAL : USER_IGNORE);
+
+  return IDWALK_RET_NOP;
+}
+
+static void lib_link_main_data_restore(struct IDNameLib_Map *id_map, Main *newmain)
+{
+  ID *id;
+  FOREACH_MAIN_ID_BEGIN (newmain, id) {
+    BKE_library_foreach_ID_link(newmain, id, lib_link_main_data_restore_cb, id_map, IDWALK_NOP);
+  }
+  FOREACH_MAIN_ID_END;
+}
+
 static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, ViewLayer *view_layer)
 {
   bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
@@ -8182,11 +8221,24 @@ void blo_lib_link_restore(Main *oldmain,
     /* keep cursor location through undo */
     memcpy(&win->scene->cursor, &oldscene->cursor, sizeof(win->scene->cursor));
 
+    /* Note: even though that function seems to redo part of what is done by
+     * `lib_link_workspace_layout_restore()` above, it seems to have a slightly different scope:
+     * while the former updates the whole UI pointers from Main db (going over all layouts of
+     * all workspaces), that one only focuses one current active screen, takes care of
+     * potential local view, and needs window's scene pointer to be final... */
     lib_link_window_scene_data_restore(win, win->scene, cur_view_layer);
 
     BLI_assert(win->screen == NULL);
   }
 
+  /* Restore all ID pointers in Main database itself
+   * (especially IDProperties might point to some worspace of other 'weirdly unchanged' ID
+   * pointers, see T69146).
+   * Note that this will re;ap again a few pointers in workspaces or so,
+   * but since we are remapping final ones already set above,
+   * that is just some minor harmless double-processing. */
+  lib_link_main_data_restore(id_map, newmain);
+
   /* update IDs stored in all possible clipboards */
   lib_link_clipboard_restore(id_map);
 
index 56b2b20cc0518681bdb86a8bab577d02139f9a63..e399b784145d4d49eb64573e6f29f7cf535b6c42 100644 (file)
@@ -1016,6 +1016,26 @@ void DRW_mesh_batch_cache_create_requested(
     }
   }
 
+  /* HACK: if MBC_SURF_PER_MAT is requested and ibo.tris is already available, it won't have it's
+   * index ranges initialized. So discard ibo.tris in order to recreate it.
+   * This needs to happen before saved_elem_ranges is populated. */
+  if ((batch_requested & MBC_SURF_PER_MAT) != 0 && (cache->batch_ready & MBC_SURF_PER_MAT) == 0) {
+    FOREACH_MESH_BUFFER_CACHE(cache, mbuffercache)
+    {
+      GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.tris);
+    }
+    /* Clear all batches that reference ibo.tris. */
+    GPU_BATCH_CLEAR_SAFE(cache->batch.surface);
+    GPU_BATCH_CLEAR_SAFE(cache->batch.surface_weights);
+    GPU_BATCH_CLEAR_SAFE(cache->batch.edit_mesh_analysis);
+    GPU_BATCH_CLEAR_SAFE(cache->batch.edit_triangles);
+    GPU_BATCH_CLEAR_SAFE(cache->batch.edit_lnor);
+    GPU_BATCH_CLEAR_SAFE(cache->batch.edit_selection_faces);
+
+    cache->batch_ready &= ~(MBC_SURFACE | MBC_SURFACE_WEIGHTS | MBC_EDIT_MESH_ANALYSIS |
+                            MBC_EDIT_TRIANGLES | MBC_EDIT_LNOR | MBC_EDIT_SELECTION_FACES);
+  }
+
   if (batch_requested &
       (MBC_SURFACE | MBC_SURF_PER_MAT | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRETCH_AREA |
        MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) {