[Bf-blender-cvs] [9d02e2eb1d7] temp-trimesh-sculpt: * Trimesh sculpt now exposes actual pointers for vert "indices."
Joseph Eagar
noreply at git.blender.org
Wed Oct 14 04:05:50 CEST 2020
Commit: 9d02e2eb1d7bc3287e62b0a3148e012adb098cf6
Author: Joseph Eagar
Date: Tue Oct 13 16:14:33 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB9d02e2eb1d7bc3287e62b0a3148e012adb098cf6
* Trimesh sculpt now exposes actual pointers for vert "indices."
===================================================================
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/pbvh_trimesh.c
M source/blender/editors/sculpt_paint/paint_cursor.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_intern.h
M source/blender/editors/sculpt_paint/sculpt_mask_expand.c
M source/blender/editors/sculpt_paint/sculpt_pose.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index cd6127512bc..248b53d3015 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -287,10 +287,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;
@@ -341,7 +341,7 @@ typedef struct SculptPersistentBase {
typedef struct SculptVertexInfo {
/* Idexed by vertex, stores and ID of its topologycally connected component. */
- int *connected_component;
+ SculptIdx *connected_component;
/* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
BLI_bitmap *boundary;
@@ -349,7 +349,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;
@@ -360,13 +360,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;
@@ -384,12 +384,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
@@ -429,7 +429,7 @@ typedef struct SculptFakeNeighbors {
float current_max_distance;
/* Idexed by vertex, stores the vertex index of its fake neighbor if available. */
- int *fake_neighbor_index;
+ SculptIdx *fake_neighbor_index;
} SculptFakeNeighbors;
@@ -519,7 +519,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 */
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index fb5f14eb8a6..2fd0e34e0e1 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -26,7 +26,7 @@
#include "stdint.h"
-typedef uintptr_t SculptIdx;
+typedef intptr_t SculptIdx;
/* For embedding CCGKey in iterator. */
#include "BKE_ccg.h"
@@ -491,7 +491,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
} \
vi.co = vi.tm_vert->co; \
vi.fno = vi.tm_vert->no; \
- vi.index = vi.tm_vert->index; \
+ vi.index = (SculptIdx)vi.tm_vert; \
vi.mask = TM_ELEM_CD_GET_VOID_P(vi.tm_vert, vi.cd_vert_mask_offset); \
}\
else { \
diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c b/source/blender/blenkernel/intern/pbvh_trimesh.c
index e26267dc004..89c2601a305 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -1519,7 +1519,7 @@ bool pbvh_trimesh_node_raycast(PBVHNode *node,
if (len_squared_v3v3(location, v_tri[j]->co) <
len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, v_tri[j]->co);
- *r_active_vertex_index = v_tri[j]->index;
+ *r_active_vertex_index = (SculptIdx)v_tri[j];
}
}
}
@@ -1997,7 +1997,7 @@ bool BKE_pbvh_trimesh_update_topology(PBVH *bvh,
pbvh_trimesh_verify(bvh);
#endif
- if (modified) {
+ if (0 && modified) {
bvh->tm->elem_table_dirty |= TM_VERTEX|TM_EDGE|TM_TRI;
bvh->tm->elem_index_dirty |= TM_VERTEX|TM_EDGE|TM_TRI;
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 2e24c2533c5..18431ce6502 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1214,7 +1214,7 @@ typedef struct PaintCursorContext {
/* Sculpt related data. */
Sculpt *sd;
SculptSession *ss;
- int prev_active_vertex_index;
+ SculptIdx prev_active_vertex_index;
bool is_stroke_active;
bool is_cursor_over_mesh;
bool is_multires;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index ac2887d0409..eaba39cc751 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -137,7 +137,7 @@ int SCULPT_vertex_count_get(SculptSession *ss)
return 0;
}
-const float *SCULPT_vertex_co_get(SculptSession *ss, int index)
+const float *SCULPT_vertex_co_get(SculptSession *ss, SculptIdx index)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES: {
@@ -149,8 +149,10 @@ const float *SCULPT_vertex_co_get(SculptSession *ss, int index)
}
case PBVH_BMESH:
return BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->co;
- case PBVH_TRIMESH:
- return TM_vert_at_index(BKE_pbvh_get_trimesh(ss->pbvh), index)->co;
+ case PBVH_TRIMESH: {
+ TMVert *v = (TMVert*) index;
+ return v->co;
+ }
case PBVH_GRIDS: {
const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
const int grid_index = index / key->grid_area;
@@ -162,7 +164,7 @@ const float *SCULPT_vertex_co_get(SculptSession *ss, int index)
return NULL;
}
-const float *SCULPT_vertex_color_get(SculptSession *ss, int index)
+const float *SCULPT_vertex_color_get(SculptSession *ss, SculptIdx index)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
@@ -178,7 +180,7 @@ const float *SCULPT_vertex_color_get(SculptSession *ss, int index)
return NULL;
}
-void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
+void SCULPT_vertex_normal_get(SculptSession *ss, SculptIdx index, float no[3])
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES: {
@@ -194,9 +196,11 @@ void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
case PBVH_BMESH:
copy_v3_v3(no, BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->no);
break;
- case PBVH_TRIMESH:
- copy_v3_v3(no, TM_vert_at_index(BKE_pbvh_get_trimesh(ss->pbvh), index)->no);
+ case PBVH_TRIMESH: {
+ TMVert *v = (TMVert*) index;
+ copy_v3_v3(no, v->no);
break;
+ }
case PBVH_GRIDS: {
const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
const int grid_index = index / key->grid_area;
@@ -208,7 +212,7 @@ void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
}
}
-const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, int index)
+const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, SculptIdx index)
{
if (ss->persistent_base) {
return ss->persistent_base[index].co;
@@ -216,7 +220,7 @@ const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, int index)
return SCULPT_vertex_co_get(ss, index);
}
-const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, int index)
+const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, SculptIdx index)
{
/* Always grab active shape key if the sculpt happens on shapekey. */
if (ss->shapekey_active) {
@@ -233,7 +237,7 @@ const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, int index)
return SCULPT_vertex_co_get(ss, index);
}
-void SCULPT_vertex_limit_surface_get(SculptSession *ss, int index, float r_co[3])
+void SCULPT_vertex_limit_surface_get(SculptSession *ss, SculptIdx index, float r_co[3])
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
@@ -255,7 +259,7 @@ void SCULPT_vertex_limit_surface_get(SculptSession *ss, int index, float r_co[3]
}
}
-void SCULPT_vertex_persistent_normal_get(SculptSession *ss, int index, float no[3])
+void SCULPT_vertex_persistent_normal_get(SculptSession *ss, SculptIdx index, float no[3])
{
if (ss->persistent_base) {
copy_v3_v3(no, ss->persistent_base[index].no);
@@ -264,7 +268,7 @@ void SCULPT_vertex_persistent_normal_get(SculptSession *ss, int index, float no[
SCULPT_vertex_normal_get(ss, index, no);
}
-float SCULPT_vertex_mask_get(SculptSession *ss, int index)
+float SCULPT_vertex_mask_get(SculptSession *ss, SculptIdx index)
{
BMVert *v;
float *mask;
@@ -277,7 +281,7 @@ float SCULPT_vertex_mask_get(SculptSession *ss, int index)
mask = BM_ELEM_CD_GET_VOID_P(v, CustomData_get_offset(&ss->bm->vdata, CD_PAINT_MASK));
return *mask;
case PBVH_TRIMESH: {
- TMVert *tv = TM_vert_at_index(ss->tm, index);
+ TMVert *tv = (TMVert*) index;
mask = TM_ELEM_CD_GET_VOID_P(tv, CustomData_get_offset(&ss->tm->vdata, CD_PAINT_MASK));
return *mask;
}
@@ -360,9 +364,11 @@ void SCULPT_vertex_visible_set(SculptSession *ss, SculptIdx index, bool visible)
case PBVH_BMESH:
BM_elem_flag_set(BM_vert_at_index(ss->bm, index), BM_ELEM_HIDDEN, !visible);
break;
- case PBVH_TRIMESH:
- TM_elem_flag_set(TM_vert_at_index(ss->tm, index), BM_ELEM_HIDDEN, !visible);
+ case PBVH_TRIMESH: {
+ TMVert *v = (TMVert*)index;
+ TM_elem_flag_set(v, TM_ELEM_HIDDEN, !visible)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list