[Bf-blender-cvs] [cb0f1591557] temp_bmesh_multires: Merge branch 'master' into temp_bmesh_multires

Joseph Eagar noreply at git.blender.org
Mon Mar 8 22:57:47 CET 2021


Commit: cb0f15915575af651d7b7d97f39337c65bf5b11d
Author: Joseph Eagar
Date:   Mon Mar 8 13:57:21 2021 -0800
Branches: temp_bmesh_multires
https://developer.blender.org/rBcb0f15915575af651d7b7d97f39337c65bf5b11d

Merge branch 'master' into temp_bmesh_multires

Merge not finished, but need to commit to move to different computer;
laptop being sent in for repairs

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



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

diff --cc intern/cycles/kernel/kernel_compat_cuda.h
index ea3b78b7cef,ea3b78b7cef..da74d6aafac
--- a/intern/cycles/kernel/kernel_compat_cuda.h
+++ b/intern/cycles/kernel/kernel_compat_cuda.h
@@@ -41,6 -41,6 +41,18 @@@ typedef unsigned long long uint64_t
  typedef unsigned short half;
  typedef unsigned long long CUtexObject;
  
++//XXX fix compiler error on windows
++#ifdef __CUDA_ARCH__
++static __device__ float myfloor(float f) {
++  float f2 = (float)((int)f);
++  f2 += (float)(f < 0.0f);
++
++  return f2;
++}
++
++#define floor myfloor
++#endif
++
  #ifdef CYCLES_CUBIN_CC
  #  define FLT_MIN 1.175494350822287507969e-38f
  #  define FLT_MAX 340282346638528859811704183484516925440.0f
diff --cc source/blender/blenkernel/BKE_paint.h
index bca23f93b5c,228b52123f3..3e5bf2570a6
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@@ -515,11 -517,12 +524,12 @@@ typedef struct SculptSession 
  
    struct StrokeCache *cache;
    struct FilterCache *filter_cache;
+   struct ExpandCache *expand_cache;
  
    /* Cursor data and active vertex for tools */
 -  int active_vertex_index;
 +  SculptVertRef active_vertex_index;
 +  SculptFaceRef active_face_index;
  
 -  int active_face_index;
    int active_grid_index;
  
    /* When active, the cursor draws with faded colors, indicating that there is an action enabled.
diff --cc source/blender/editors/sculpt_paint/sculpt.c
index b593b51c1e5,631327ddfe8..4bb9bcfdc0a
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@@ -1405,12 -1103,14 +1405,14 @@@ void SCULPT_floodfill_add_initial(Sculp
    BLI_gsqueue_push(flood->queue, &index);
  }
  
- void SCULPT_floodfill_add_initial_with_symmetry(Sculpt *sd,
-                                                 Object *ob,
-                                                 SculptSession *ss,
-                                                 SculptFloodFill *flood,
-                                                 SculptVertRef vertex,
-                                                 float radius)
+ void SCULPT_floodfill_add_and_skip_initial(SculptFloodFill *flood, int index)
+ {
+   BLI_gsqueue_push(flood->queue, &index);
+   BLI_BITMAP_ENABLE(flood->visited_vertices, index);
+ }
+ 
+ void SCULPT_floodfill_add_initial_with_symmetry(
 -    Sculpt *sd, Object *ob, SculptSession *ss, SculptFloodFill *flood, int index, float radius)
++    Sculpt *sd, Object *ob, SculptSession *ss, SculptFloodFill *flood, SculptVertRef index, float radius)
  {
    /* Add active vertex and symmetric vertices to the queue. */
    const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
diff --cc source/blender/editors/sculpt_paint/sculpt_expand.c
index 00000000000,db6d33c2700..892b30048f6
mode 000000,100644..100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@@ -1,0 -1,2258 +1,2291 @@@
+ /*
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+  * as published by the Free Software Foundation; either version 2
+  * of the License, or (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program; if not, write to the Free Software Foundation,
+  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  *
+  * The Original Code is Copyright (C) 2021 Blender Foundation.
+  * All rights reserved.
+  */
+ 
+ /** \file
+  * \ingroup edsculpt
+  */
+ 
+ #include "MEM_guardedalloc.h"
+ 
+ #include "BLI_blenlib.h"
+ #include "BLI_linklist_stack.h"
+ #include "BLI_math.h"
+ #include "BLI_task.h"
+ 
+ #include "BLT_translation.h"
+ 
+ #include "DNA_brush_types.h"
+ #include "DNA_mesh_types.h"
+ #include "DNA_meshdata_types.h"
+ #include "DNA_object_types.h"
+ 
+ #include "BKE_brush.h"
+ #include "BKE_ccg.h"
+ #include "BKE_colortools.h"
+ #include "BKE_context.h"
+ #include "BKE_image.h"
+ #include "BKE_mesh.h"
+ #include "BKE_mesh_mapping.h"
+ #include "BKE_multires.h"
+ #include "BKE_node.h"
+ #include "BKE_object.h"
+ #include "BKE_paint.h"
+ #include "BKE_pbvh.h"
+ #include "BKE_report.h"
+ #include "BKE_scene.h"
+ #include "BKE_subdiv_ccg.h"
+ 
+ #include "DEG_depsgraph.h"
+ 
+ #include "WM_api.h"
+ #include "WM_message.h"
+ #include "WM_toolsystem.h"
+ #include "WM_types.h"
+ 
+ #include "RNA_access.h"
+ #include "RNA_define.h"
+ 
+ #include "ED_object.h"
+ #include "ED_screen.h"
+ #include "ED_sculpt.h"
+ #include "ED_view3d.h"
+ #include "paint_intern.h"
+ #include "sculpt_intern.h"
+ 
+ #include "IMB_colormanagement.h"
+ #include "IMB_imbuf.h"
+ 
+ #include "bmesh.h"
+ 
+ #include <math.h>
+ #include <stdlib.h>
+ 
+ /* Sculpt Expand. */
+ /* Operator for creating selections and patterns in Sculpt Mode. Expand can create masks, face sets
+  * and fill vertex colors. */
+ /* The main functionality of the operator
+  * - The operator initializes a value per vertex, called "falloff". There are multiple algorithms
+  * to generate these falloff values which will create different patterns in the result when using
+  * the operator. These falloff values require algorithms that rely on mesh connectivity, so they
+  * are only valid on parts of the mesh that are in the same connected component as the given
+  * initial vertices. If needed, these falloff values are propagated from vertex or grids into the
+  * base mesh faces.
+  *
+  * - On each modal callback, the operator gets the active vertex and face and gets its falloff
+  *   value from its precalculated falloff. This is now the active falloff value.
+  * - Using the active falloff value and the settings of the expand operation (which can be modified
+  *   during execution using the modal key-map), the operator loops over all elements in the mesh to
+  *   check if they are enabled of not.
+  * - Based on each element state after evaluating the settings, the desired mesh data (mask, face
+  *   sets, colors...) is updated.
+  */
+ 
+ /**
+  * Used for defining an invalid vertex state (for example, when the cursor is not over the mesh).
+  */
+ #define SCULPT_EXPAND_VERTEX_NONE -1
+ 
+ /** Used for defining an uninitialized active component index for an unused symmetry pass. */
+ #define EXPAND_ACTIVE_COMPONENT_NONE -1
+ /**
+  * Defines how much each time the texture distortion is increased/decreased
+  * when using the modal key-map.
+  */
+ #define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP 0.01f
+ 
+ /**
+  * This threshold offsets the required falloff value to start a new loop. This is needed because in
+  * some situations, vertices which have the same falloff value as max_falloff will start a new
+  * loop, which is undesired.
+  */
+ #define SCULPT_EXPAND_LOOP_THRESHOLD 0.00001f
+ 
+ /**
+  * Defines how much changes in curvature in the mesh affect the falloff shape when using normal
+  * falloff. This default was found experimentally and it works well in most cases, but can be
+  * exposed for tweaking if needed.
+  */
+ #define SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY 300
+ 
+ /* Expand Modal Key-map. */
+ enum {
+   SCULPT_EXPAND_MODAL_CONFIRM = 1,
+   SCULPT_EXPAND_MODAL_CANCEL,
+   SCULPT_EXPAND_MODAL_INVERT,
+   SCULPT_EXPAND_MODAL_PRESERVE_TOGGLE,
+   SCULPT_EXPAND_MODAL_GRADIENT_TOGGLE,
+   SCULPT_EXPAND_MODAL_FALLOFF_CYCLE,
+   SCULPT_EXPAND_MODAL_RECURSION_STEP_GEODESIC,
+   SCULPT_EXPAND_MODAL_RECURSION_STEP_TOPOLOGY,
+   SCULPT_EXPAND_MODAL_MOVE_TOGGLE,
+   SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC,
+   SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY,
+   SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS,
+   SCULPT_EXPAND_MODAL_FALLOFF_SPHERICAL,
+   SCULPT_EXPAND_MODAL_SNAP_TOGGLE,
+   SCULPT_EXPAND_MODAL_LOOP_COUNT_INCREASE,
+   SCULPT_EXPAND_MODAL_LOOP_COUNT_DECREASE,
+   SCULPT_EXPAND_MODAL_BRUSH_GRADIENT_TOGGLE,
+   SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_INCREASE,
+   SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_DECREASE,
+ };
+ 
+ /* Functions for getting the state of mesh elements (vertices and base mesh faces). When the main
+  * functions for getting the state of an element return true it means that data associated to that
+  * element will be modified by expand. */
+ 
+ /**
+  * Returns true if the vertex is in a connected component with correctly initialized falloff
+  * values.
+  */
+ static bool sculpt_expand_is_vert_in_active_component(SculptSession *ss,
+                                                       ExpandCache *expand_cache,
+                                                       const int v)
+ {
+   for (int i = 0; i < EXPAND_SYMM_AREAS; i++) {
+     if (ss->vertex_info.connected_component[v] == expand_cache->active_connected_components[i]) {
+       return true;
+     }
+   }
+   return false;
+ }
+ 
+ /**
+  * Returns true if the face is in a connected component with correctly initialized falloff values.
+  */
+ static bool sculpt_expand_is_face_in_active_component(SculptSession *ss,
+                                                       ExpandCache *expand_cache,
+                                                       const int f)
+ {
+   const MLoop *loop = &ss->mloop[ss->mpoly[f].loopstart];
+   return sculpt_expand_is_vert_in_active_component(ss, expand_cache, loop->v);
+ }
+ 
+ /**
+  * Returns the falloff value of a vertex. This function includes texture distortion, which is not
+  * precomputed into the initial falloff values.
+  */
+ static float sculpt_expand_falloff_value_vertex_get(SculptSession *ss,
+                                                     ExpandCache *expand_cache,
+                                                     const int v)
+ {
+   if (expand_cache->texture_distortion_strength == 0.0f) {
+     return expand_cache->vert_falloff[v];
+   }
+ 
+   if (!expand_cache->brush->mtex.tex) {
+     return expand_cache->vert_falloff[v];
+   }
+ 
+   float rgba[4];
 -  const float *vertex_co = SCULPT_vertex_co_get(ss, v);
++  co

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list