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

Joseph Eagar noreply at git.blender.org
Thu Sep 2 20:05:38 CEST 2021


Commit: 2b209317073359e4b03cf069a788ee5b5eff8a7a
Author: Joseph Eagar
Date:   Thu Sep 2 00:02:20 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB2b209317073359e4b03cf069a788ee5b5eff8a7a

Merge branch 'master' into temp_bmesh_multires

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



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

diff --cc source/blender/blenkernel/intern/collection.c
index d7ffcab9f19,2d172f23428..d088d4a4ed2
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@@ -689,11 -688,11 +688,14 @@@ static Collection *collection_duplicate
  Collection *BKE_collection_duplicate(Main *bmain,
                                       Collection *parent,
                                       Collection *collection,
-                                      const uint duplicate_flags_in, //it's not const!! - joeedh
-                                      const uint duplicate_options)
 -                                     eDupli_ID_Flags duplicate_flags,
 -                                     eLibIDDuplicateFlags duplicate_options)
++                                     const uint duplicate_flags_in,    // it's not const!! - joeedh
++                                     const uint duplicate_options_in)  // not const!
  {
++  uint duplicate_flags = duplicate_flags_in;
++  uint duplicate_options = duplicate_options_in;
++
    const bool is_subprocess = (duplicate_options & LIB_ID_DUPLICATE_IS_SUBPROCESS) != 0;
-   uint duplicate_flags = duplicate_flags_in; 
+   const bool is_root_id = (duplicate_options & LIB_ID_DUPLICATE_IS_ROOT_ID) != 0;
  
    if (!is_subprocess) {
      BKE_main_id_newptr_and_tag_clear(bmain);
diff --cc source/blender/blenkernel/intern/dyntopo.c
index 1f9c0dd290d,00000000000..65411abb552
mode 100644,000000..100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@@ -1,4945 -1,0 +1,4939 @@@
 +#include "MEM_guardedalloc.h"
 +
 +#include "DNA_customdata_types.h"
 +#include "DNA_mesh_types.h"
 +#include "DNA_meshdata_types.h"
 +#include "DNA_modifier_types.h"
 +
 +#include "BLI_alloca.h"
 +#include "BLI_array.h"
 +#include "BLI_bitmap.h"
 +#include "BLI_buffer.h"
 +#include "BLI_compiler_attrs.h"
 +#include "BLI_compiler_compat.h"
 +#include "BLI_ghash.h"
 +#include "BLI_heap.h"
 +#include "BLI_heap_simple.h"
 +#include "BLI_linklist.h"
 +#include "BLI_math.h"
 +#include "BLI_memarena.h"
 +#include "BLI_rand.h"
 +#include "BLI_task.h"
 +#include "BLI_utildefines.h"
 +#include "PIL_time.h"
 +#include "atomic_ops.h"
 +
 +#include "BKE_customdata.h"
 +#include "BKE_dyntopo.h"
 +#include "BKE_pbvh.h"
 +
 +#include "bmesh.h"
 +#include "pbvh_intern.h"
 +
 +#include <stdio.h>
 +
 +#define DYNVERT_VALENCE_TEMP (1 << 14)
 +
 +#define USE_NEW_SPLIT
 +#define DYNVERT_SMOOTH_BOUNDARY (DYNVERT_BOUNDARY | DYNVERT_FSET_BOUNDARY | DYNVERT_SHARP_BOUNDARY)
 +#define DYNVERT_ALL_BOUNDARY \
 +  (DYNVERT_BOUNDARY | DYNVERT_FSET_BOUNDARY | DYNVERT_SHARP_BOUNDARY | DYNVERT_SEAM_BOUNDARY)
 +#define DYNVERT_SMOOTH_CORNER (DYNVERT_CORNER | DYNVERT_FSET_CORNER | DYNVERT_SHARP_CORNER)
 +#define DYNVERT_ALL_CORNER \
 +  (DYNVERT_CORNER | DYNVERT_FSET_CORNER | DYNVERT_SHARP_CORNER | DYNVERT_SEAM_CORNER)
 +
 +#define DYNTOPO_MAX_ITER 4096
 +
 +#define DYNTOPO_USE_HEAP
 +
 +#ifndef DYNTOPO_USE_HEAP
 +/* don't add edges into the queue multiple times */
 +#  define USE_EDGEQUEUE_TAG
 +#endif
 +
 +/* Avoid skinny faces */
 +#define USE_EDGEQUEUE_EVEN_SUBDIV
 +
 +/* How much longer we need to be to consider for subdividing
 + * (avoids subdividing faces which are only *slightly* skinny) */
 +#define EVEN_EDGELEN_THRESHOLD 1.2f
 +/* How much the limit increases per recursion
 + * (avoids performing subdivisions too far away). */
 +#define EVEN_GENERATION_SCALE 1.1f
 +
 +/* recursion depth to start applying front face test */
 +#define DEPTH_START_LIMIT 5
 +
 +//#define FANCY_EDGE_WEIGHTS <= too slow
 +//#define SKINNY_EDGE_FIX
 +
 +/* slightly relax geometry by this factor along surface tangents
 +   to improve convergence of remesher */
 +#define DYNTOPO_SAFE_SMOOTH_FAC 0.05f
 +
 +#define DYNTOPO_SAFE_SMOOTH_SUBD_ONLY_FAC 0.75f
 +
 +#ifdef USE_EDGEQUEUE_EVEN_SUBDIV
 +#  include "BKE_global.h"
 +#endif
 +
 +/* Support for only operating on front-faces */
 +#define USE_EDGEQUEUE_FRONTFACE
 +
 +/**
 + * Ensure we don't have dirty tags for the edge queue, and that they are left cleared.
 + * (slow, even for debug mode, so leave disabled for now).
 + */
 +#if defined(USE_EDGEQUEUE_TAG) && 0
 +#  if !defined(NDEBUG)
 +#    define USE_EDGEQUEUE_TAG_VERIFY
 +#  endif
 +#endif
 +
 +// #define USE_VERIFY
 +
 +#define DYNTOPO_MASK(cd_mask_offset, v) BM_ELEM_CD_GET_FLOAT(v, cd_mask_offset)
 +
 +#ifdef USE_VERIFY
 +static void pbvh_bmesh_verify(PBVH *pbvh);
 +#endif
 +
 +/* -------------------------------------------------------------------- */
 +/** \name BMesh Utility API
 + *
 + * Use some local functions which assume triangles.
 + * \{ */
 +
 +/**
 + * Typically using BM_LOOPS_OF_VERT and BM_FACES_OF_VERT iterators are fine,
 + * however this is an area where performance matters so do it in-line.
 + *
 + * Take care since 'break' won't works as expected within these macros!
 + */
 +
 +#define BM_DISK_EDGE(e, v) (&((&(e)->v1_disk_link)[(v) == (e)->v2]))
 +
 +#define BM_LOOPS_OF_VERT_ITER_BEGIN(l_iter_radial_, v_) \
 +  { \
 +    struct { \
 +      BMVert *v; \
 +      BMEdge *e_iter, *e_first; \
 +      BMLoop *l_iter_radial; \
 +    } _iter; \
 +    _iter.v = v_; \
 +    if (_iter.v->e) { \
 +      _iter.e_iter = _iter.e_first = _iter.v->e; \
 +      do { \
 +        if (_iter.e_iter->l) { \
 +          _iter.l_iter_radial = _iter.e_iter->l; \
 +          do { \
 +            if (_iter.l_iter_radial->v == _iter.v) { \
 +              l_iter_radial_ = _iter.l_iter_radial;
 +
 +#define BM_LOOPS_OF_VERT_ITER_END \
 +  } \
 +  } \
 +  while ((_iter.l_iter_radial = _iter.l_iter_radial->radial_next) != _iter.e_iter->l) \
 +    ; \
 +  } \
 +  } \
 +  while ((_iter.e_iter = BM_DISK_EDGE_NEXT(_iter.e_iter, _iter.v)) != _iter.e_first) \
 +    ; \
 +  } \
 +  } \
 +  ((void)0)
 +
 +#define BM_FACES_OF_VERT_ITER_BEGIN(f_iter_, v_) \
 +  { \
 +    BMLoop *l_iter_radial_; \
 +    BM_LOOPS_OF_VERT_ITER_BEGIN (l_iter_radial_, v_) { \
 +      f_iter_ = l_iter_radial_->f;
 +
 +#define BM_FACES_OF_VERT_ITER_END \
 +  } \
 +  BM_LOOPS_OF_VERT_ITER_END; \
 +  } \
 +  ((void)0)
 +
 +struct EdgeQueueContext;
 +
 +static bool check_face_is_tri(PBVH *pbvh, BMFace *f);
 +static bool check_vert_fan_are_tris(PBVH *pbvh, BMVert *v);
 +static void pbvh_split_edges(struct EdgeQueueContext *eq_ctx,
 +                             PBVH *pbvh,
 +                             BMesh *bm,
 +                             BMEdge **edges,
 +                             int totedge,
 +                             bool ignore_isolated_edges);
 +void bm_log_message(const char *fmt, ...);
 +void pbvh_bmesh_check_nodes_simple(PBVH *pbvh);
 +static void edge_queue_create_local(struct EdgeQueueContext *eq_ctx,
 +                                    PBVH *pbvh,
 +                                    const float center[3],
 +                                    const float view_normal[3],
 +                                    float radius,
 +                                    const bool use_frontface,
 +                                    const bool use_projected,
 +                                    bool is_collapse);
 +
 +//#define CHECKMESH
 +//#define TEST_INVALID_NORMALS
 +
 +#ifndef CHECKMESH
 +#  define fix_mesh(bm)
 +#  define validate_vert(bm, v, autofix, check_manifold) true
 +#  define validate_edge(bm, e, autofix, check_manifold) true
 +#  define validate_face(bm, f, autofix, check_manifold) true
 +#  define validate_vert_faces(bm, v, autofix, check_manifold) true
 +#  define check_face_is_manifold(bm, f) true
 +#else
 +
 +#  define CHECKMESH_ATTR ATTR_NO_OPT
 +
 +CHECKMESH_ATTR static void _debugprint(const char *fmt, ...)
 +{
 +  va_list args;
 +  va_start(args, fmt);
 +  vprintf(fmt, args);
 +  va_end(args);
 +}
 +
 +void bmesh_disk_edge_append(BMEdge *e, BMVert *v);
 +void bmesh_radial_loop_append(BMEdge *e, BMLoop *l);
 +
 +CHECKMESH_ATTR static bool check_face_is_manifold(BMesh *bm, BMFace *f)
 +{
 +  BMLoop *l = f->l_first;
 +
 +  do {
 +    if (l->radial_next != l && l->radial_next->radial_next != l) {
 +      _debugprint("non-manifold edge in loop\n");
 +      return false;
 +    }
 +
 +#  ifdef TEST_INVALID_NORMALS
 +    if (l != l->radial_next && l->v == l->radial_next->v) {
 +      _debugprint("invalid normals\n");
 +      return false;
 +    }
 +#  endif
 +  } while ((l = l->next) != f->l_first);
 +
 +  return true;
 +}
 +
 +CHECKMESH_ATTR
 +static void fix_mesh(BMesh *bm)
 +{
 +  BMIter iter;
 +  BMVert *v;
 +  BMEdge *e;
 +  BMFace *f;
 +
 +  _debugprint("fixing mesh. . .\n");
 +
 +  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
 +    v->e = NULL;
 +  }
 +
 +  BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
 +    e->v1_disk_link.next = e->v1_disk_link.prev = NULL;
 +    e->v2_disk_link.next = e->v2_disk_link.prev = NULL;
 +  }
 +
 +  // rebuild disk cycles
 +  BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
 +    e->l = NULL;
 +
 +    bmesh_disk_edge_append(e, e->v1);
 +    bmesh_disk_edge_append(e, e->v2);
 +  }
 +
 +  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
 +    BMLoop *l = f->l_first;
 +
 +    do {
 +      l->e = BM_edge_exists(l->v, l->next->v);
 +
 +      bmesh_radial_loop_append(l->e, l);
 +    } while ((l = l->next) != f->l_first);
 +  }
 +  _debugprint("done fixing mesh.\n");
 +}
 +
 +CHECKMESH_ATTR
 +static bool validate_vert(BMesh *bm, BMVert *v, bool autofix, bool check_manifold)
 +{
 +  if (v->head.htype != BM_VERT) {
 +    _debugprint("bad vertex\n");
 +    return false;
 +  }
 +
 +  BMEdge *e = v->e;
 +  int i = 0;
 +
 +  if (!e) {
 +    return true;
 +  }
 +
 +  do {
 +    if (e->v1 != v && e->v2 != v) {
 +      _debugprint("edge does not contain v\n");
 +      goto error;
 +    }
 +
 +    if (e->l) {
 +      int j = 0;
 +
 +      BMLoop *l = e->l;
 +      do {
 +        if (l->e->v1 != v && l->e->v2 != v) {
 +          _debugprint("loop's edges doesn't contain v\n");
 +          goto error;
 +        }
 +
 +        if (l->v != v && l->next->v != v) {
 +          _debugprint("loop and loop->next don't contain v\n");
 +          goto error;
 +        }
 +
 +        j++;
 +        if (j > 1000) {
 +          _debugprint("corrupted radial cycle\n");
 +          goto error;
 +        }
 +
 +        if 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list