[Bf-blender-cvs] [5fa8dbeacdf] sculpt-dev: Merge remote-tracking branch 'origin' into sculpt-dev

Joseph Eagar noreply at git.blender.org
Sat Jul 30 09:18:51 CEST 2022


Commit: 5fa8dbeacdfa8d7394462abf6b69ccca36d0fd66
Author: Joseph Eagar
Date:   Sat Jul 30 00:18:24 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB5fa8dbeacdfa8d7394462abf6b69ccca36d0fd66

Merge remote-tracking branch 'origin' into sculpt-dev

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



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

diff --cc intern/CMakeLists.txt
index 6a0c2691361,6387fd016ba..9ec58d273dd
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@@ -68,6 -68,9 +68,13 @@@ if(UNIX AND NOT APPLE
    add_subdirectory(libc_compat)
  endif()
  
 +if(WITH_INSTANT_MESHES)
 +  add_subdirectory(instant-meshes)
 +endif()
++
+ if(UNIX AND NOT APPLE)
+   # Important this comes after "ghost" as it uses includes defined by GHOST's CMake.
+   if(WITH_GHOST_WAYLAND AND WITH_GHOST_WAYLAND_DYNLOAD)
+     add_subdirectory(wayland_dynload)
+   endif()
+ endif()
diff --cc intern/guardedalloc/intern/mallocn_lockfree_impl.c
index bf23d63ca7a,300e2000a14..3558257a3f0
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@@ -45,10 -44,8 +45,11 @@@ enum 
  #define PTR_FROM_MEMHEAD(memhead) (memhead + 1)
  #define MEMHEAD_ALIGNED_FROM_PTR(ptr) (((MemHeadAligned *)ptr) - 1)
  #define MEMHEAD_IS_ALIGNED(memhead) ((memhead)->len & (size_t)MEMHEAD_ALIGN_FLAG)
+ #define MEMHEAD_LEN(memhead) ((memhead)->len & ~((size_t)(MEMHEAD_ALIGN_FLAG)))
  
 +#define MEM_POISON_MEMHEAD(vmemh) BLI_asan_poison(MEMHEAD_FROM_PTR(vmemh), sizeof(MemHead))
 +#define MEM_UNPOISON_MEMHEAD(vmemh) BLI_asan_unpoison(MEMHEAD_FROM_PTR(vmemh), sizeof(MemHead))
 +
  /* Uncomment this to have proper peak counter. */
  #define USE_ATOMIC_MAX
  
@@@ -82,14 -79,8 +83,14 @@@ print_error(const char *str, ...
  
  size_t MEM_lockfree_allocN_len(const void *vmemh)
  {
-   if (vmemh) {
+   if (LIKELY(vmemh)) {
 -    return MEMHEAD_LEN(MEMHEAD_FROM_PTR(vmemh));
 +    size_t ret;
 +
 +    MEM_UNPOISON_MEMHEAD(vmemh);
 +    ret = MEMHEAD_FROM_PTR(vmemh)->len & ~((size_t)(MEMHEAD_ALIGN_FLAG));
 +    MEM_POISON_MEMHEAD(vmemh);
 +
 +    return ret;
    }
  
    return 0;
diff --cc source/blender/blenkernel/BKE_customdata.h
index 33529a949e2,010fbb27172..02e55bb0c89
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@@ -576,39 -550,11 +576,26 @@@ void CustomData_validate_layer_name(con
   */
  bool CustomData_verify_versions(struct CustomData *data, int index);
  
- /* BMesh specific custom-data stuff.
-  *
-  * Needed to convert to/from different face representation (for versioning). */
+ /* BMesh specific custom-data stuff. */
  
- void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *ldata, int totloop);
- void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *ldata, int total);
  void CustomData_bmesh_update_active_layers(struct CustomData *fdata, struct CustomData *ldata);
 -void CustomData_bmesh_init_pool(struct CustomData *data, int totelem, char htype);
++
 +/**
 + * Update active indices for active/render/clone/stencil custom data layers
 + * based on indices from fdata layers
 + * used by do_versions in `readfile.c` when creating pdata and ldata for pre-bmesh
 + * meshes and needed to preserve active/render/clone/stencil flags set in pre-bmesh files.
 + */
 +void CustomData_bmesh_do_versions_update_active_layers(struct CustomData *fdata,
 +                                                       struct CustomData *ldata);
 +
 +void CustomData_bmesh_init_pool_ex(CustomData *data,
 +                                   int totelem,
 +                                   const char htype,
 +                                   const char *memtag);
 +
 +void CustomData_bmesh_init_pool(struct CustomData *data, int totelem, const char htype);
  
- #ifndef NDEBUG
- /**
-  * Debug check, used to assert when we expect layers to be in/out of sync.
-  *
-  * \param fallback: Use when there are no layers to handle,
-  * since callers may expect success or failure.
-  */
- bool CustomData_from_bmeshpoly_test(CustomData *fdata, CustomData *ldata, bool fallback);
- #endif
- 
  /**
   * Validate and fix data of \a layer,
   * if possible (needs relevant callback in layer's type to be defined).
diff --cc source/blender/blenkernel/BKE_paint.h
index 5ec0175d405,8b9deadc960..0fd92636637
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@@ -801,9 -568,9 +807,9 @@@ typedef struct SculptSession 
    struct ExpandCache *expand_cache;
  
    /* Cursor data and active vertex for tools */
-   PBVHVertRef active_vertex_index;
-   PBVHFaceRef active_face_index;
+   PBVHVertRef active_vertex;
++  PBVHFaceRef active_face;
  
 -  int active_face_index;
    int active_grid_index;
  
    /* When active, the cursor draws with faded colors, indicating that there is an action enabled.
@@@ -826,18 -592,10 +832,18 @@@
    struct RegionView3D *rv3d;
    struct View3D *v3d;
    struct Scene *scene;
 +  int cd_origvcol_offset;
 +  int cd_origco_offset;
 +  int cd_origno_offset;
 +
 +  /* Face Sets by topology. */
 +  int face_set_last_created;
 +  PBVHFaceRef face_set_last_poly;
 +  PBVHEdgeRef face_set_last_edge;
  
    /* Dynamic mesh preview */
-   PBVHVertRef *preview_vert_index_list;
-   int preview_vert_index_count;
+   PBVHVertRef *preview_vert_list;
+   int preview_vert_count;
  
    /* Pose Brush Preview */
    float pose_origin[3];
diff --cc source/blender/blenkernel/BKE_pbvh.h
index e3d026bab8c,2f4618e6f7a..2dd32e8a14c
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@@ -22,99 -21,11 +24,81 @@@
  extern "C" {
  #endif
  
 +// experimental feature to detect quad diagonals and mark (but not dissolve) them
 +//#define SCULPT_DIAGONAL_EDGE_MARKS
 +
 +/*
 +   These structs represent logical verts/edges/faces.
 +   for PBVH_GRIDS and PBVH_FACES they store integer
 +   offsets, PBVH_BMESH stores pointers.
 +
 +   The idea is to enforce stronger type checking by encapsulating
 +   intptr_t's in structs.*/
 +typedef struct PBVHVertRef {
 +  intptr_t i;
 +} PBVHVertRef;
 +
 +typedef struct PBVHEdgeRef {
 +  intptr_t i;
 +} PBVHEdgeRef;
 +
 +typedef struct PBVHFaceRef {
 +  intptr_t i;
 +} PBVHFaceRef;
 +
 +#define PBVH_REF_NONE ((intptr_t)-1)
 +
 +typedef struct SculptPMap {
 +  struct MeshElemMap *pmap;
 +  int *pmap_mem;
 +  int refcount;
 +} SculptPMap;
 +
 +#if 0
 +typedef struct SculptLoopRef {
 +  intptr_t i;
 +} SculptLoopRef;
 +#endif
 +
- BLI_INLINE PBVHVertRef BKE_pbvh_make_vref(intptr_t i)
- {
-   PBVHVertRef ret = {i};
-   return ret;
- }
- 
- BLI_INLINE PBVHEdgeRef BKE_pbvh_make_eref(intptr_t i)
- {
-   PBVHEdgeRef ret = {i};
-   return ret;
- }
- 
- BLI_INLINE PBVHFaceRef BKE_pbvh_make_fref(intptr_t i)
- {
-   PBVHFaceRef ret = {i};
-   return ret;
- }
- 
 +#ifdef DEFRAGMENT_MEMORY
 +#  include "BLI_smallhash.h"
 +#endif
 +
 +typedef struct PBVHTri {
 +  int v[3];       // references into PBVHTriBuf->verts
 +  int eflag;      // bitmask of which edges in the tri are real edges in the mesh
 +  intptr_t l[3];  // loops
 +
 +  float no[3];
 +  PBVHFaceRef f;
 +} PBVHTri;
 +
 +typedef struct PBVHTriBuf {
 +  PBVHTri *tris;
 +  PBVHVertRef *verts;
 +  int *edges;
 +  int totvert, totedge, tottri;
 +  int verts_size, edges_size, tris_size;
 +
 +  SmallHash vertmap;  // maps vertex ptrs to indices within verts
 +
 +  // private field
 +  intptr_t *loops;
 +  int totloop, mat_nr;
 +  float min[3], max[3];
 +} PBVHTriBuf;
 +
  struct BMLog;
  struct BMesh;
 +struct BMVert;
 +struct BMEdge;
 +struct BMFace;
 +struct Scene;
  struct CCGElem;
 +struct MeshElemMap;
  struct CCGKey;
  struct CustomData;
 +struct TableGSet;
  struct DMFlagMat;
  struct GPU_PBVH_Buffers;
  struct IsectRayPrecalc;
@@@ -137,79 -46,41 +121,91 @@@ struct MeshElemMap
  typedef struct PBVH PBVH;
  typedef struct PBVHNode PBVHNode;
  
 +//#define PROXY_ADVANCED
 +
 +// experimental performance test of "data-based programming" approach
 +#ifdef PROXY_ADVANCED
 +typedef struct ProxyKey {
 +  int node;
 +  int pindex;
 +} ProxyKey;
 +
 +#  define MAX_PROXY_NEIGHBORS 12
 +
 +typedef struct ProxyVertArray {
 +  float **ownerco;
 +  short **ownerno;
 +  float (*co)[3];
 +  float (*fno)[3];
 +  short (*no)[3];
 +  float *mask, **ownermask;
 +  PBVHVertRef *index;
 +  float **ownercolor, (*color)[4];
 +
 +  ProxyKey (*neighbors)[MAX_PROXY_NEIGHBORS];
 +
 +  int size;
 +  int datamask;
 +  bool neighbors_dirty;
 +
 +  GHash *indexmap;
 +} ProxyVertArray;
 +
 +typedef enum {
 +  PV_OWNERCO = 1,
 +  PV_OWNERNO = 2,
 +  PV_CO = 4,
 +  PV_NO = 8,
 +  PV_MASK = 16,
 +  PV_OWNERMASK = 32,
 +  PV_INDEX = 64,
 +  PV_OWNERCOLOR = 128,
 +  PV_COLOR = 256,
 +  PV_NEIGHBORS = 512
 +} ProxyVertField;
 +
 +typedef struct ProxyVertUpdateRec {
 +  float *co, *no, *mask, *color;
 +  PBVHVertRef index, newindex;
 +} ProxyVertUpdateRec;
 +
 +#  define PBVH_PROXY_DEFAULT CO | INDEX | MASK
 +
 +struct SculptSession;
 +
 +void BKE_pbvh_ensure_proxyarrays(
 +    struct SculptSession *ss, PBVH *pbvh, PBVHNode **nodes, int totnode, int mask);
 +void BKE_pbvh_load_proxyarrays(PBVH *pbvh, PBVHNode **nodes, int totnode, int mask);
 +
 +void BKE_pbvh_ensure_proxyarray(
 +    struct SculptSession *ss,
 +    struct PBVH *pbvh,
 +    struct PBVHNode *node,
 +    int mask,
 +    struct GHash
 +        *vert_node_map,  // vert_node_map maps vertex PBVHVertRefs to PBVHNode indices; optional
 +    bool check_indexmap,
 +    bool force_update);
 +void BKE_pbvh_gather_proxyarray(PBVH *pbvh, PBVHNode **nodes, int totnode);
 +
 +void BKE_pbvh_free_proxyarray(struct PBVH *pbvh, struct PBVHNode *node);
 +void BKE_pbvh_update_proxyvert(struct PBVH *pbvh, struct PBVHNode *node, ProxyVertUpdateRec *rec);
 +ProxyVertArray *BKE_pbvh_get_proxyarrays(struct PBVH *pbvh, struct PBVHNode *node);
 +
 +#endif
 +
+ typedef enum {
+   PBVH_FACES,
+   PBVH_GRIDS,
+   PBVH_BMESH,
+ } PBVHType;
+ 
+ /* Public members of PBVH, used for inlined functions. */
+ struct PBVHPublic {
+   PBVHType type;
+   BMesh *bm;
+ };
+ 
 -/*
 - * These structs represent logical verts/edges/faces.
 - * for PBVH_GRIDS and PBVH_FACES they store integer
 - * offsets, PBVH_BMESH stores pointers.
 - *
 - * The idea is to enforce stronger type checking by encapsulating
 - * intptr_t's in structs.
 - */
 -
 -typedef struct PBVHVertRef {
 -  intptr_t i;
 -} PBVHVertRef;
 -
 -typedef struct PBVHEdgeRef {
 -  intptr_t i;
 -} PBVHEdgeRef;
 -
 -typedef struct PBVHFaceRef {
 -  intptr_t i;
 -} PBVHFaceRef;
 -
 -#define PBVH_REF_NONE -1LL
 -
  typedef struct {
    float (*c

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list