[Bf-blender-cvs] [e108318af84] sculpt-dev: Merge remote-tracking branch 'origin' into sculpt-dev
Joseph Eagar
noreply at git.blender.org
Tue Jun 14 16:53:49 CEST 2022
Commit: e108318af8494cbb20c2b857887103ebd3369bb6
Author: Joseph Eagar
Date: Tue Jun 14 02:01:58 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rBe108318af8494cbb20c2b857887103ebd3369bb6
Merge remote-tracking branch 'origin' into sculpt-dev
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_attribute.h
index ffba1fe7e25,5755ddb3018..12f793a3d02
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@@ -50,10 -50,11 +50,10 @@@ typedef enum eAttrDomainMask
/* Attributes. */
- bool BKE_id_attributes_supported(struct ID *id);
+ bool BKE_id_attributes_supported(const struct ID *id);
bool BKE_attribute_allow_procedural_access(const char *attribute_name);
-/**
- * Create a new attribute layer.
+/** Create a new attribute layer.
*/
struct CustomDataLayer *BKE_id_attribute_new(
struct ID *id, const char *name, int type, eAttrDomain domain, struct ReportList *reports);
diff --cc source/blender/blenkernel/BKE_pbvh.h
index 67fdc42601d,f517ff3a949..8e9afb0648a
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@@ -450,15 -221,13 +450,16 @@@ void BKE_pbvh_draw_cb(PBVH *pbvh
PBVHFrustumPlanes *update_frustum,
PBVHFrustumPlanes *draw_frustum,
void (*draw_fn)(void *user_data, struct GPU_PBVH_Buffers *buffers),
- void *user_data);
+ void *user_data,
+ bool full_render);
-void BKE_pbvh_draw_debug_cb(
- PBVH *pbvh,
- void (*draw_fn)(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag),
- void *user_data);
+void BKE_pbvh_draw_debug_cb(PBVH *pbvh,
+ void (*draw_fn)(void *user_data,
+ const float bmin[3],
+ const float bmax[3],
+ PBVHNodeFlags flag,
+ int depth),
+ void *user_data);
/* PBVH Access */
typedef enum {
@@@ -1087,116 -590,3 +1088,118 @@@ ATTR_NO_OPT static void MV_ADD_FLAG(MSc
#ifdef __cplusplus
}
#endif
+
+#if 0
+# include "atomic_ops.h"
+# include <float.h>
+# include <math.h>
+
+/*why is atomic_ops defining near & far macros?*/
+# ifdef near
+# undef near
+# endif
+# ifdef far
+# undef far
+# endif
+
+// static global to limit the number of reports per source file
+static int _bke_pbvh_report_count = 0;
+
+# define PBVH_NAN_REPORT_LIMIT 16
+
+// for debugging NaNs that don't appear on developer's machines
+BLI_INLINE bool _pbvh_nan_check(const float *co, const char *func, const char *file, int line)
+{
+ bool bad = false;
+
+ if (_bke_pbvh_report_count > PBVH_NAN_REPORT_LIMIT) {
+ return false;
+ }
+
+ for (int i = 0; i < 3; i++) {
+ if (isnan(co[i]) || !isfinite(co[i])) {
+ const char *type = !isfinite(co[i]) ? "infinity" : "nan";
+ printf("float corruption (vector[%d] was %s): %s:%d\n\t%s\n", i, type, func, line, file);
+ bad = true;
+ }
+ }
+
+ if (bad) {
+ atomic_add_and_fetch_int32(&_bke_pbvh_report_count, 1);
+ }
+
+ return bad;
+}
+# define PBVH_CHECK_NAN(co) _pbvh_nan_check(co, __func__, __FILE__, __LINE__)
+#else
+# define PBVH_CHECK_NAN(co)
+#endif
+
+typedef struct DynTopoState DynTopoState;
+
+typedef struct DynRemeshParams {
+ float edge_size;
+ float detail_range;
+ float relax_strength;
+} DynRemeshParams;
+
+/*
+Simple wrapper api to use the dyntopo remesher in
+non-sculpt contexts.
+
+existing_pbvh can be NULL.
+
+Note that all the sculpt customdata layers will be created
+if they don't exist, so cd_vert/face_node_offset, cd_mask_offset,
+cd_sculpt_vert, etc*/
+DynTopoState *BKE_dyntopo_init(struct BMesh *bm, PBVH *existing_pbvh);
+void BKE_dyntopo_free(DynTopoState *ds);
+void BKE_dyntopo_default_params(DynRemeshParams *params, float edge_size);
+void BKE_dyntopo_remesh(DynTopoState *ds,
+ DynRemeshParams *params,
+ int steps,
+ PBVHTopologyUpdateMode mode);
+/*
+
+use pmap to build an array of edge indices surrounding vertex
+r_edges, r_edges_size, heap_alloc define an existing array to put data in.
+
+final array is similarly put in these pointers. note that calling code
+may pass a stack allocated array (*heap_alloc should be false), and must
+check if heap_alloc is true afterwards and free *r_edges.
+
+r_polys is an array of integer pairs and must be same logical size as r_edges
+*/
+void BKE_pbvh_pmap_to_edges(PBVH *pbvh,
+ SculptVertRef vertex,
+ int **r_edges,
+ int *r_edges_size,
+ bool *heap_alloc,
+ int **r_polys);
+void BKE_pbvh_set_vemap(PBVH *pbvh, struct MeshElemMap *vemap);
+
+void BKE_pbvh_ignore_uvs_set(PBVH *pbvh, bool value);
+bool BKE_pbvh_cache_is_valid(const struct Object *ob,
+ const struct Mesh *me,
+ const PBVH *pbvh,
+ int pbvh_type);
+bool BKE_pbvh_cache(const struct Mesh *me, PBVH *pbvh);
+PBVH *BKE_pbvh_get_or_free_cached(struct Object *ob, struct Mesh *me, PBVHType pbvh_type);
+void BKE_pbvh_invalidate_cache(struct Object *ob);
+void BKE_pbvh_set_cached(struct Object *ob, PBVH *pbvh);
+void BKE_pbvh_set_face_areas(PBVH *pbvh, float *face_areas);
+void BKE_pbvh_set_sculpt_verts(PBVH *pbvh, struct MSculptVert *sverts);
+void BKE_pbvh_set_pmap(PBVH *pbvh, SculptPMap *pmap);
+SculptPMap *BKE_pbvh_get_pmap(PBVH *pbvh);
+void BKE_pbvh_cache_remove(PBVH *pbvh);
+void BKE_pbvh_set_bmesh(PBVH *pbvh, struct BMesh *bm);
+void BKE_pbvh_free_bmesh(PBVH *pbvh, struct BMesh *bm);
+void BKE_pbvh_system_init(void);
+void BKE_pbvh_system_exit(void);
+
+SculptPMap *BKE_pbvh_make_pmap(const struct Mesh *me);
+void BKE_pbvh_pmap_aquire(SculptPMap *pmap);
+bool BKE_pbvh_pmap_release(SculptPMap *pmap);
+void BKE_pbvh_clear_cache(PBVH *preserve);
++
++void BKE_pbvh_need_full_render_set(PBVH *pbvh, bool state);
diff --cc source/blender/blenkernel/intern/attribute.cc
index ea8954c5f22,b2ea8b833b3..912a3ea0a38
--- a/source/blender/blenkernel/intern/attribute.cc
+++ b/source/blender/blenkernel/intern/attribute.cc
@@@ -311,13 -344,10 +344,13 @@@ CustomDataLayer *BKE_id_attribute_searc
}
}
- return NULL;
+ return nullptr;
}
-int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomDataMask mask)
+int BKE_id_attributes_length(const ID *id,
+ eAttrDomainMask domain_mask,
+ eCustomDataMask mask,
+ bool skip_temporary)
{
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
diff --cc source/blender/blenkernel/intern/customdata.cc
index 0c15a642e6e,bb5b2ee0836..5267f3ef904
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@@ -17,11 -17,10 +17,12 @@@
#include "DNA_customdata_types.h"
#include "DNA_meshdata_types.h"
+#include "BLI_asan.h"
#include "BLI_bitmap.h"
#include "BLI_color.hh"
+#include "BLI_compiler_attrs.h"
#include "BLI_endian_switch.h"
+ #include "BLI_index_range.hh"
#include "BLI_math.h"
#include "BLI_math_color_blend.h"
#include "BLI_math_vector.hh"
@@@ -2492,31 -2240,8 +2495,31 @@@ static bool customdata_typemap_is_valid
}
#endif
+/* copies all customdata layers without allocating data,
+ * and without respect to type masks or NO_COPY/etc flags*/
+void CustomData_copy_all_layout(const struct CustomData *source, struct CustomData *dest)
+{
+ *dest = *source;
+
+ if (dest->pool) {
+ dest->pool = NULL;
+ }
+
+ if (source->layers) {
+ dest->layers = static_cast<CustomDataLayer *>(
+ MEM_mallocN(sizeof(*dest->layers) * source->totlayer, __func__));
+
+ for (int i = 0; i < source->totlayer; i++) {
+ dest->layers[i] = source->layers[i];
+ dest->layers[i].data = NULL;
+ }
+ }
+
+ CustomData_regen_active_refs(dest);
+}
+
- bool CustomData_merge(const struct CustomData *source,
- struct CustomData *dest,
+ bool CustomData_merge(const CustomData *source,
+ CustomData *dest,
eCustomDataMask mask,
eCDAllocType alloctype,
int totelem)
diff --cc source/blender/blenkernel/intern/paint.c
index adacae23a67,81c7e7f34da..85500cdb8a7
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@@ -2843,14 -2291,9 +2843,15 @@@ bool BKE_sculptsession_use_pbvh_draw(co
return false;
}
+#if 0
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ return !(v3d && (v3d->shading.type > OB_SOLID));
+ }
+#endif
+
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
/* Regular mesh only draws from PBVH without modifiers and shape keys. */
+
return !(ss->shapekey_active || ss->deform_modifiers_active);
}
diff --cc source/blender/blenkernel/intern/pbvh.c
index 6d9e4d96bf3,fab973d223f..632458019fb
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -856,14 -714,13 +856,23 @@@ void BKE_pbvh_free(PBVH *pbvh
MEM_SAFE_FREE(pbvh->vert_bitmap);
+ BKE_pbvh_pmap_release(pbvh->pmap);
+ pbvh->pmap = NULL;
+
+ pbvh->invalid = true;
+
+ if (pbvh->vbo_id) {
+ GPU_pbvh_free_format(pbvh->vbo_id);
+ }
+
MEM_freeN(pbvh);
}
++void BKE_pbvh_need_full_render_set(PBVH *pbvh, bool state)
++{
++ GPU_pbvh_need_full_render_set(pbvh->vbo_id, state);
++}
++
static void pbvh_iter_begin(PBVHIter *iter,
PBVH *pbvh,
BKE_pbvh_SearchCallback scb,
@@@ -1453,29 -1305,22 +1462,39 @@@ static void pbvh_update_draw_buffer_cb(
CustomData *vdata, *ldata;
+ if (!pbvh->bm) {
+ vdata = pbvh->vdata ? pbvh->vdata : &me->vdata;
+ ldata = pbvh->ldata ? pbvh->ldata : &me->ldata;
+ }
+ else {
+ vdata = &pbvh->bm->vdata;
+ ldata = &pbvh->bm->ldata;
+ }
+
+ Mesh me_query;
+ BKE_id_attribute_copy_domains_temp(ID_ME, vdata, NULL, ldata, NULL, NULL,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list