[Bf-blender-cvs] [4faa2b4bc9f] temp-trimesh-sculpt: Rebase branch
Joseph Eagar
noreply at git.blender.org
Fri Oct 23 23:49:56 CEST 2020
Commit: 4faa2b4bc9f56cc2ab7260e5d464fcee27a7adbb
Author: Joseph Eagar
Date: Fri Oct 23 14:49:14 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB4faa2b4bc9f56cc2ab7260e5d464fcee27a7adbb
Rebase branch
===================================================================
M .clang-format
M source/blender/CMakeLists.txt
M source/blender/blenkernel/BKE_customdata.h
M source/blender/blenkernel/BKE_multires.h
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/CMakeLists.txt
M source/blender/blenkernel/intern/CCGSubSurf.c
M source/blender/blenkernel/intern/DerivedMesh.c
M source/blender/blenkernel/intern/anim_data.c
M source/blender/blenkernel/intern/collection.c
M source/blender/blenkernel/intern/customdata.c
M source/blender/blenkernel/intern/lib_id.c
M source/blender/blenkernel/intern/mesh_validate.cc
M source/blender/blenkernel/intern/object.c
M source/blender/blenkernel/intern/paint.c
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/blenkernel/intern/pbvh_intern.h
M source/blender/blenlib/BLI_ghash.h
M source/blender/blenlib/BLI_smallhash.h
M source/blender/blenlib/BLI_span.hh
M source/blender/blenlib/BLI_threads.h
M source/blender/blenlib/CMakeLists.txt
M source/blender/blenlib/intern/BLI_ghash.c
M source/blender/blenlib/intern/math_boolean.cc
M source/blender/blenlib/intern/smallhash.c
M source/blender/blenlib/intern/task_pool.cc
M source/blender/blenlib/intern/threads.cc
M source/blender/blenloader/intern/versioning_280.c
M source/blender/bmesh/intern/bmesh_interp.c
M source/blender/bmesh/intern/bmesh_mesh.c
M source/blender/bmesh/intern/bmesh_mesh_convert.c
M source/blender/bmesh/operators/bmo_fill_grid.c
M source/blender/bmesh/operators/bmo_hull.c
M source/blender/bmesh/tools/bmesh_decimate_collapse.c
M source/blender/draw/intern/draw_cache_impl_particles.c
M source/blender/draw/intern/draw_hair.c
M source/blender/draw/intern/draw_hair_private.h
M source/blender/draw/intern/shaders/common_hair_lib.glsl
M source/blender/editors/interface/interface_template_search_menu.c
M source/blender/editors/mesh/editmesh_select_similar.c
M source/blender/editors/object/object_remesh.c
M source/blender/editors/screen/area.c
M source/blender/editors/sculpt_paint/CMakeLists.txt
M source/blender/editors/sculpt_paint/paint_cursor.c
M source/blender/editors/sculpt_paint/paint_hide.c
M source/blender/editors/sculpt_paint/paint_mask.c
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_automasking.c
M source/blender/editors/sculpt_paint/sculpt_boundary.c
M source/blender/editors/sculpt_paint/sculpt_cloth.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_face_set.c
M source/blender/editors/sculpt_paint/sculpt_filter_color.c
M source/blender/editors/sculpt_paint/sculpt_filter_mask.c
M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_mask_expand.c
M source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
M source/blender/editors/sculpt_paint/sculpt_paint_color.c
M source/blender/editors/sculpt_paint/sculpt_pose.c
M source/blender/editors/sculpt_paint/sculpt_smooth.c
M source/blender/editors/sculpt_paint/sculpt_transform.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
M source/blender/editors/space_info/CMakeLists.txt
M source/blender/editors/space_info/info_stats.c
M source/blender/gpu/CMakeLists.txt
M source/blender/gpu/GPU_buffers.h
M source/blender/gpu/GPU_vertex_buffer.h
M source/blender/gpu/intern/gpu_buffers.c
M source/blender/makesdna/DNA_customdata_types.h
M source/blender/makesdna/DNA_scene_defaults.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_context.c
M source/blender/makesrna/intern/rna_object.c
M source/blender/makesrna/intern/rna_scene.c
M source/blender/python/gpu/gpu_py_offscreen.c
===================================================================
diff --git a/.clang-format b/.clang-format
index 8a992fea3a9..061137b6867 100644
--- a/.clang-format
+++ b/.clang-format
@@ -262,6 +262,10 @@ ForEachMacros:
- SET_SLOT_PROBING_BEGIN
- MAP_SLOT_PROBING_BEGIN
- VECTOR_SET_SLOT_PROBING_BEGIN
+ - TMS_ITER
+ - TM_ITER_VERT_TRIS
+ - TM_ITER_VERT_TRIEDGES
+ - TM_ITER_MESH
# Use once we bump the minimum version to version 8.
# # Without this string literals that in-line 'STRINGIFY' behave strangely (a bug?).
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index da6df831c0a..1335553effd 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -105,6 +105,7 @@ add_subdirectory(editors)
add_subdirectory(windowmanager)
add_subdirectory(blenkernel)
add_subdirectory(blenlib)
+add_subdirectory(trimesh)
add_subdirectory(bmesh)
add_subdirectory(draw)
add_subdirectory(render)
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 51650d161ea..48fa5304646 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -311,6 +311,15 @@ void CustomData_bmesh_interp(struct CustomData *data,
int count,
void *dst_block);
+struct TM_TriMesh;
+void CustomData_trimesh_init_pool(struct TM_TriMesh *tm, struct CustomData *data, int totelem, const char htype);
+bool CustomData_trimesh_merge(const struct CustomData *source,
+ struct CustomData *dest,
+ CustomDataMask mask,
+ eCDAllocType alloctype,
+ struct TM_TriMesh *bm,
+ const char htype);
+
/* swaps the data in the element corners, to new corners with indices as
* specified in corner_indices. for edges this is an array of length 2, for
* faces an array of length 4 */
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index fbdfc5b76a7..d1e69e68b1e 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -95,6 +95,8 @@ struct Mesh *BKE_multires_create_mesh(struct Depsgraph *depsgraph,
struct Object *object,
struct MultiresModifierData *mmd);
+void BKE_multires_bmesh_space_set(struct Object *ob, struct BMesh *bm, int mode);
+
/* Get coordinates of a deformed base mesh which is an input to the given multires modifier.
* NOTE: The modifiers will be re-evaluated. */
float (*BKE_multires_create_deformed_base_mesh_vert_coords(struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 150d0d9b011..a35dc63d9bd 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -23,6 +23,8 @@
* \ingroup bke
*/
+#include "BKE_pbvh.h"
+
#include "BLI_bitmap.h"
#include "BLI_utildefines.h"
#include "DNA_object_enums.h"
@@ -286,10 +288,10 @@ typedef struct SculptClothLengthConstraint {
* point, position for a previous state). In that case, elem_index_a and elem_index_b should be
* the same to avoid affecting two different vertices when solving the constraints.
* *elem_position points to the position which is owned by the element. */
- int elem_index_a;
+ SculptIdx elem_index_a;
float *elem_position_a;
- int elem_index_b;
+ SculptIdx elem_index_b;
float *elem_position_b;
float length;
@@ -342,7 +344,7 @@ typedef struct SculptPersistentBase {
typedef struct SculptVertexInfo {
/* Indexed by vertex, stores and ID of its topologically connected component. */
- int *connected_component;
+ SculptIdx *connected_component;
/* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
BLI_bitmap *boundary;
@@ -350,7 +352,7 @@ typedef struct SculptVertexInfo {
typedef struct SculptBoundaryEditInfo {
/* Vertex index from where the topology propagation reached this vertex. */
- int original_vertex;
+ SculptIdx original_vertex;
/* How many steps were needed to reach this vertex from the boundary. */
int num_propagation_steps;
@@ -361,13 +363,13 @@ typedef struct SculptBoundaryEditInfo {
/* Edge for drawing the boundary preview in the cursor. */
typedef struct SculptBoundaryPreviewEdge {
- int v1;
- int v2;
+ SculptIdx v1;
+ SculptIdx v2;
} SculptBoundaryPreviewEdge;
typedef struct SculptBoundary {
/* Vertex indices of the active boundary. */
- int *vertices;
+ SculptIdx *vertices;
int vertices_capacity;
int num_vertices;
@@ -385,12 +387,12 @@ typedef struct SculptBoundary {
bool forms_loop;
/* Initial vertex in the boundary which is closest to the current sculpt active vertex. */
- int initial_vertex;
+ SculptIdx initial_vertex;
/* Vertex that at max_propagation_steps from the boundary and closest to the original active
* vertex that was used to initialize the boundary. This is used as a reference to check how much
* the deformation will go into the mesh and to calculate the strength of the brushes. */
- int pivot_vertex;
+ SculptIdx pivot_vertex;
/* Stores the initial positions of the pivot and boundary initial vertex as they may be deformed
* during the brush action. This allows to use them as a reference positions and vectors for some
@@ -430,8 +432,7 @@ typedef struct SculptFakeNeighbors {
float current_max_distance;
/* Indexed by vertex, stores the vertex index of its fake neighbor if available. */
- int *fake_neighbor_index;
-
+ SculptIdx *fake_neighbor_index;
} SculptFakeNeighbors;
/* Session data (mode-specific) */
@@ -470,6 +471,9 @@ typedef struct SculptSession {
* Face Set ID. Positive IDs are visible, negative IDs are hidden. */
int *face_sets;
+ struct TM_TriMesh *tm;
+ struct TriMeshLog *tm_log;
+
/* BMesh for dynamic topology sculpting */
struct BMesh *bm;
int cd_vert_node_offset;
@@ -500,7 +504,7 @@ typedef struct SculptSession {
struct FilterCache *filter_cache;
/* Cursor data and active vertex for tools */
- int active_vertex_index;
+ SculptIdx active_vertex_index;
int active_face_index;
int active_grid_index;
@@ -522,7 +526,7 @@ typedef struct SculptSession {
struct Scene *scene;
/* Dynamic mesh preview */
- int *preview_vert_index_list;
+ SculptIdx *preview_vert_index_list;
int preview_vert_index_count;
/* Pose Brush Preview */
@@ -579,7 +583,6 @@ typedef struct SculptSession {
* Set #Main.is_memfile_undo_flush_needed when enabling.
*/
char needs_flush_to_id;
-
} SculptSession;
void BKE_sculptsession_free(struct Object *ob);
@@ -588,6 +591,10 @@ void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss);
void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
+void BKE_sculptsession_tm_to_me(struct Object *ob, bool reorder);
+void BKE_sculptsession_tm_to_me_for_render(struct Object *object);
+
+
/* Create new color layer on object if it doesn't have one and if experimental feature set has
* sculpt vertex color enabled. Returns truth if new layer has been added, false otherwise. */
void BKE_sculpt_color_layer_create_if_needed(struct Object *object);
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index cd213b49c5b..6ae99aabe9b 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -23,6 +23,11 @@
#include "BLI_bitmap.h"
#include "BLI_ghash.h"
+#include "BLI_threadsafe_mempool.h"
+
+#include "stdint.h"
+
+typedef intptr_t SculptIdx;
/* For embedding CCGKey in iterator. */
#include "BKE_ccg.h"
@@ -53,6 +58,79 @@ struct TaskParallelTLS;
typedef struct PBVH PBVH;
typedef struct PBVHNode PBVHNode;
+//#define WITH_TRIMESH
+
+//#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;
+ SculptIdx *index;
+ float **ownercolor, (*color)[4];
+
+ ProxyKey (*neighbors)[MAX_PROXY_NEIGHBORS];
+
+ int size;
+ int datamask;
+
+ 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;
+ int index, newindex;
+} ProxyVertUpdateRec;
+
+# define PBVH_PROXY_DEFAULT CO | INDEX | MASK
+
+struct SculptSession;
+
+void BKE_pbvh_ensure_proxyarrays(struct SculptSession *ss, PBVH *pbvh, 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 SculptIdxs 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 struct {
float (*co)[3];
} PBVHProxyNode;
@@ -79,6 +157,7 @@ typedef enum {
PBVH_UpdateTopology = 1 << 13,
PBVH_UpdateColor = 1 << 14,
+ PBVH_Delete = 1 << 15,
} PBVHNodeFlags;
typedef struct PBVHFrustumPlanes {
@@ -86,6 +165,32 @@ typedef struct PBVHFrustumPlanes {
int num_planes;
} PBVHFrustumPlanes;
+typedef struct TMElemSet {
+ struct GHash *ptr_to_idx;
+ void **elems;
+ int size, length;
+ int cur;
+} TMElemSet;
+
+TMElemSet *TMElemSet_new();
+void TMElemSet_free(TMElemSet *ts);
+void TMElemSet_insert(TMElemSet *ts, void *elem);
+bool TM
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list