sculpt-dev: Rename SculptVertRef -> PBVHVertRef
Should make merging easier.
This commit is contained in:
parent
ed8ffec61f
commit
1ed1fc0f57
|
@ -478,7 +478,7 @@ typedef struct SculptVertexInfo {
|
|||
|
||||
typedef struct SculptBoundaryEditInfo {
|
||||
/* Vertex index from where the topology propagation reached this vertex. */
|
||||
SculptVertRef original_vertex;
|
||||
PBVHVertRef original_vertex;
|
||||
int original_vertex_i;
|
||||
|
||||
/* How many steps were needed to reach this vertex from the boundary. */
|
||||
|
@ -490,8 +490,8 @@ typedef struct SculptBoundaryEditInfo {
|
|||
|
||||
/* Edge for drawing the boundary preview in the cursor. */
|
||||
typedef struct SculptBoundaryPreviewEdge {
|
||||
SculptVertRef v1;
|
||||
SculptVertRef v2;
|
||||
PBVHVertRef v1;
|
||||
PBVHVertRef v2;
|
||||
} SculptBoundaryPreviewEdge;
|
||||
|
||||
#define MAX_STORED_COTANGENTW_EDGES 7
|
||||
|
@ -504,7 +504,7 @@ typedef struct StoredCotangentW {
|
|||
|
||||
typedef struct SculptBoundary {
|
||||
/* Vertex indices of the active boundary. */
|
||||
SculptVertRef *vertices;
|
||||
PBVHVertRef *vertices;
|
||||
int *vertex_indices;
|
||||
|
||||
int vertices_capacity;
|
||||
|
@ -520,7 +520,7 @@ typedef struct SculptBoundary {
|
|||
float (*boundary_tangents)[3];
|
||||
|
||||
StoredCotangentW *boundary_cotangents;
|
||||
SculptVertRef *boundary_closest;
|
||||
PBVHVertRef *boundary_closest;
|
||||
int sculpt_totvert;
|
||||
|
||||
/* Data for drawing the preview. */
|
||||
|
@ -532,12 +532,12 @@ typedef struct SculptBoundary {
|
|||
bool forms_loop;
|
||||
|
||||
/* Initial vertex in the boundary which is closest to the current sculpt active vertex. */
|
||||
SculptVertRef initial_vertex;
|
||||
PBVHVertRef 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. */
|
||||
SculptVertRef pivot_vertex;
|
||||
PBVHVertRef 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
|
||||
|
@ -632,7 +632,7 @@ typedef struct SculptFakeNeighbors {
|
|||
float current_max_distance;
|
||||
|
||||
/* Indexed by vertex, stores the vertex index of its fake neighbor if available. */
|
||||
SculptVertRef *fake_neighbor_index;
|
||||
PBVHVertRef *fake_neighbor_index;
|
||||
|
||||
} SculptFakeNeighbors;
|
||||
|
||||
|
@ -801,8 +801,8 @@ typedef struct SculptSession {
|
|||
struct ExpandCache *expand_cache;
|
||||
|
||||
/* Cursor data and active vertex for tools */
|
||||
SculptVertRef active_vertex_index;
|
||||
SculptFaceRef active_face_index;
|
||||
PBVHVertRef active_vertex_index;
|
||||
PBVHFaceRef active_face_index;
|
||||
|
||||
int active_grid_index;
|
||||
|
||||
|
@ -832,11 +832,11 @@ typedef struct SculptSession {
|
|||
|
||||
/* Face Sets by topology. */
|
||||
int face_set_last_created;
|
||||
SculptFaceRef face_set_last_poly;
|
||||
SculptEdgeRef face_set_last_edge;
|
||||
PBVHFaceRef face_set_last_poly;
|
||||
PBVHEdgeRef face_set_last_edge;
|
||||
|
||||
/* Dynamic mesh preview */
|
||||
SculptVertRef *preview_vert_index_list;
|
||||
PBVHVertRef *preview_vert_index_list;
|
||||
int preview_vert_index_count;
|
||||
|
||||
/* Pose Brush Preview */
|
||||
|
|
|
@ -32,23 +32,19 @@ extern "C" {
|
|||
|
||||
The idea is to enforce stronger type checking by encapsulating
|
||||
intptr_t's in structs.*/
|
||||
typedef struct SculptElemRef {
|
||||
typedef struct PBVHVertRef {
|
||||
intptr_t i;
|
||||
} SculptElemRef;
|
||||
} PBVHVertRef;
|
||||
|
||||
typedef struct SculptVertRef {
|
||||
typedef struct PBVHEdgeRef {
|
||||
intptr_t i;
|
||||
} SculptVertRef;
|
||||
} PBVHEdgeRef;
|
||||
|
||||
typedef struct SculptEdgeRef {
|
||||
typedef struct PBVHFaceRef {
|
||||
intptr_t i;
|
||||
} SculptEdgeRef;
|
||||
} PBVHFaceRef;
|
||||
|
||||
typedef struct SculptFaceRef {
|
||||
intptr_t i;
|
||||
} SculptFaceRef;
|
||||
|
||||
#define SCULPT_REF_NONE ((intptr_t)-1)
|
||||
#define PBVH_REF_NONE ((intptr_t)-1)
|
||||
|
||||
typedef struct SculptPMap {
|
||||
struct MeshElemMap *pmap;
|
||||
|
@ -62,21 +58,21 @@ typedef struct SculptLoopRef {
|
|||
} SculptLoopRef;
|
||||
#endif
|
||||
|
||||
BLI_INLINE SculptVertRef BKE_pbvh_make_vref(intptr_t i)
|
||||
BLI_INLINE PBVHVertRef BKE_pbvh_make_vref(intptr_t i)
|
||||
{
|
||||
SculptVertRef ret = {i};
|
||||
PBVHVertRef ret = {i};
|
||||
return ret;
|
||||
}
|
||||
|
||||
BLI_INLINE SculptEdgeRef BKE_pbvh_make_eref(intptr_t i)
|
||||
BLI_INLINE PBVHEdgeRef BKE_pbvh_make_eref(intptr_t i)
|
||||
{
|
||||
SculptEdgeRef ret = {i};
|
||||
PBVHEdgeRef ret = {i};
|
||||
return ret;
|
||||
}
|
||||
|
||||
BLI_INLINE SculptFaceRef BKE_pbvh_make_fref(intptr_t i)
|
||||
BLI_INLINE PBVHFaceRef BKE_pbvh_make_fref(intptr_t i)
|
||||
{
|
||||
SculptFaceRef ret = {i};
|
||||
PBVHFaceRef ret = {i};
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -90,12 +86,12 @@ typedef struct PBVHTri {
|
|||
intptr_t l[3]; // loops
|
||||
|
||||
float no[3];
|
||||
SculptFaceRef f;
|
||||
PBVHFaceRef f;
|
||||
} PBVHTri;
|
||||
|
||||
typedef struct PBVHTriBuf {
|
||||
PBVHTri *tris;
|
||||
SculptVertRef *verts;
|
||||
PBVHVertRef *verts;
|
||||
int *edges;
|
||||
int totvert, totedge, tottri;
|
||||
int verts_size, edges_size, tris_size;
|
||||
|
@ -159,7 +155,7 @@ typedef struct ProxyVertArray {
|
|||
float (*fno)[3];
|
||||
short (*no)[3];
|
||||
float *mask, **ownermask;
|
||||
SculptVertRef *index;
|
||||
PBVHVertRef *index;
|
||||
float **ownercolor, (*color)[4];
|
||||
|
||||
ProxyKey (*neighbors)[MAX_PROXY_NEIGHBORS];
|
||||
|
@ -186,7 +182,7 @@ typedef enum {
|
|||
|
||||
typedef struct ProxyVertUpdateRec {
|
||||
float *co, *no, *mask, *color;
|
||||
SculptVertRef index, newindex;
|
||||
PBVHVertRef index, newindex;
|
||||
} ProxyVertUpdateRec;
|
||||
|
||||
# define PBVH_PROXY_DEFAULT CO | INDEX | MASK
|
||||
|
@ -203,7 +199,7 @@ void BKE_pbvh_ensure_proxyarray(
|
|||
struct PBVHNode *node,
|
||||
int mask,
|
||||
struct GHash
|
||||
*vert_node_map, // vert_node_map maps vertex SculptVertRefs to PBVHNode indices; optional
|
||||
*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);
|
||||
|
@ -357,7 +353,7 @@ void BKE_pbvh_update_sculpt_verts(PBVH *pbvh);
|
|||
|
||||
/** update original data, only data whose r_** parameters are passed in will be updated*/
|
||||
bool BKE_pbvh_get_origvert(
|
||||
PBVH *pbvh, SculptVertRef vertex, const float **r_co, float **r_no, float **r_color);
|
||||
PBVH *pbvh, PBVHVertRef vertex, const float **r_co, float **r_no, float **r_color);
|
||||
|
||||
/**
|
||||
checks if original data needs to be updated for v, and if so updates it. Stroke_id
|
||||
|
@ -406,8 +402,8 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
|
|||
int *hit_count,
|
||||
float *depth,
|
||||
float *back_depth,
|
||||
SculptVertRef *active_vertex_index,
|
||||
SculptFaceRef *active_face_grid_index,
|
||||
PBVHVertRef *active_vertex_index,
|
||||
PBVHFaceRef *active_face_grid_index,
|
||||
float *face_normal,
|
||||
int stroke_id);
|
||||
|
||||
|
@ -515,7 +511,7 @@ typedef enum {
|
|||
PBVH_LocalCollapse = 1 << 4
|
||||
} PBVHTopologyUpdateMode;
|
||||
|
||||
typedef float (*DyntopoMaskCB)(SculptVertRef vertex, void *userdata);
|
||||
typedef float (*DyntopoMaskCB)(PBVHVertRef vertex, void *userdata);
|
||||
|
||||
bool BKE_pbvh_bmesh_update_topology(
|
||||
PBVH *pbvh,
|
||||
|
@ -556,11 +552,11 @@ void BKE_pbvh_face_areas_begin(PBVH *pbvh);
|
|||
|
||||
// updates boundaries and valences for whole mesh
|
||||
void BKE_pbvh_bmesh_on_mesh_change(PBVH *pbvh);
|
||||
bool BKE_pbvh_bmesh_check_valence(PBVH *pbvh, SculptVertRef vertex);
|
||||
void BKE_pbvh_bmesh_update_valence(int cd_sculpt_vert, SculptVertRef vertex);
|
||||
bool BKE_pbvh_bmesh_check_valence(PBVH *pbvh, PBVHVertRef vertex);
|
||||
void BKE_pbvh_bmesh_update_valence(int cd_sculpt_vert, PBVHVertRef vertex);
|
||||
void BKE_pbvh_bmesh_update_all_valence(PBVH *pbvh);
|
||||
void BKE_pbvh_bmesh_flag_all_disk_sort(PBVH *pbvh);
|
||||
bool BKE_pbvh_bmesh_mark_update_valence(PBVH *pbvh, SculptVertRef vertex);
|
||||
bool BKE_pbvh_bmesh_mark_update_valence(PBVH *pbvh, PBVHVertRef vertex);
|
||||
|
||||
/* if pbvh uses a split index buffer, will call BKE_pbvh_node_mark_update_triangulation;
|
||||
otherwise does nothing. returns true if BKE_pbvh_node_mark_update_triangulation was
|
||||
|
@ -587,7 +583,7 @@ bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node);
|
|||
void BKE_pbvh_node_mark_curvature_update(PBVHNode *node);
|
||||
|
||||
void BKE_pbvh_mark_rebuild_pixels(PBVH *pbvh);
|
||||
void BKE_pbvh_vert_mark_update(PBVH *pbvh, SculptVertRef vertex);
|
||||
void BKE_pbvh_vert_mark_update(PBVH *pbvh, PBVHVertRef vertex);
|
||||
|
||||
void BKE_pbvh_node_get_grids(PBVH *pbvh,
|
||||
PBVHNode *node,
|
||||
|
@ -675,7 +671,7 @@ typedef struct PBVHVertexIter {
|
|||
int gy;
|
||||
int i;
|
||||
int index;
|
||||
SculptVertRef vertex;
|
||||
PBVHVertRef vertex;
|
||||
bool respect_hide;
|
||||
|
||||
/* grid */
|
||||
|
@ -812,17 +808,17 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
|
|||
} \
|
||||
((void)0)
|
||||
|
||||
#define BKE_pbvh_vertex_index_to_table(pbvh, v) \
|
||||
#define BKE_pbvh_vertex_to_index(pbvh, v) \
|
||||
(BKE_pbvh_type(pbvh) == PBVH_BMESH && v.i != -1 ? BM_elem_index_get((BMVert *)(v.i)) : (v.i))
|
||||
SculptVertRef BKE_pbvh_table_index_to_vertex(PBVH *pbvh, int idx);
|
||||
PBVHVertRef BKE_pbvh_index_to_vertex(PBVH *pbvh, int idx);
|
||||
|
||||
#define BKE_pbvh_edge_index_to_table(pbvh, v) \
|
||||
#define BKE_pbvh_edge_to_index(pbvh, v) \
|
||||
(BKE_pbvh_type(pbvh) == PBVH_BMESH && v.i != -1 ? BM_elem_index_get((BMEdge *)(v.i)) : (v.i))
|
||||
SculptEdgeRef BKE_pbvh_table_index_to_edge(PBVH *pbvh, int idx);
|
||||
PBVHEdgeRef BKE_pbvh_index_to_edge(PBVH *pbvh, int idx);
|
||||
|
||||
#define BKE_pbvh_face_index_to_table(pbvh, v) \
|
||||
#define BKE_pbvh_face_to_index(pbvh, v) \
|
||||
(BKE_pbvh_type(pbvh) == PBVH_BMESH && v.i != -1 ? BM_elem_index_get((BMFace *)(v.i)) : (v.i))
|
||||
SculptFaceRef BKE_pbvh_table_index_to_face(PBVH *pbvh, int idx);
|
||||
PBVHFaceRef BKE_pbvh_index_to_face(PBVH *pbvh, int idx);
|
||||
|
||||
void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count);
|
||||
void BKE_pbvh_node_free_proxies(PBVHNode *node);
|
||||
|
@ -886,8 +882,8 @@ void BKE_pbvh_node_num_loops(PBVH *pbvh, PBVHNode *node, int *r_totloop);
|
|||
|
||||
void BKE_pbvh_update_active_vcol(PBVH *pbvh, const struct Mesh *mesh);
|
||||
|
||||
void BKE_pbvh_vertex_color_set(PBVH *pbvh, SculptVertRef vertex, const float color[4]);
|
||||
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, SculptVertRef vertex, float r_color[4]);
|
||||
void BKE_pbvh_vertex_color_set(PBVH *pbvh, PBVHVertRef vertex, const float color[4]);
|
||||
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, PBVHVertRef vertex, float r_color[4]);
|
||||
|
||||
void BKE_pbvh_ensure_node_loops(PBVH *pbvh);
|
||||
bool BKE_pbvh_draw_cache_invalid(const PBVH *pbvh);
|
||||
|
@ -957,7 +953,7 @@ void BKE_pbvh_update_vert_boundary(int cd_sculpt_vert,
|
|||
|
||||
PBVHNode *BKE_pbvh_get_node_leaf_safe(PBVH *pbvh, int i);
|
||||
|
||||
void BKE_pbvh_get_vert_face_areas(PBVH *pbvh, SculptVertRef vertex, float *r_areas, int valence);
|
||||
void BKE_pbvh_get_vert_face_areas(PBVH *pbvh, PBVHVertRef vertex, float *r_areas, int valence);
|
||||
void BKE_pbvh_set_symmetry(PBVH *pbvh, int symmetry, int boundary_symmetry);
|
||||
|
||||
#if 0
|
||||
|
@ -993,7 +989,7 @@ typedef struct SculptTextureDef {
|
|||
void *(*buildNodeData)(PBVH *pbvh, PBVHNode *node);
|
||||
bool (*validate)(PBVH *pbvh, TexLayerRef vdm);
|
||||
|
||||
void (*setVertexCos)(PBVH *pbvh, PBVHNode *node, SculptVertRef *verts, int totvert, TexLayerRef vdm);
|
||||
void (*setVertexCos)(PBVH *pbvh, PBVHNode *node, PBVHVertRef *verts, int totvert, TexLayerRef vdm);
|
||||
|
||||
void (*getPointsFromNode)(PBVH *pbvh,
|
||||
PBVHNode *node,
|
||||
|
@ -1065,10 +1061,10 @@ void BKE_pbvh_update_vert_boundary_faces(int *face_sets,
|
|||
struct MPoly *mpoly,
|
||||
struct MSculptVert *mdyntopo_verts,
|
||||
struct MeshElemMap *pmap,
|
||||
SculptVertRef vertex);
|
||||
PBVHVertRef vertex);
|
||||
void BKE_pbvh_update_vert_boundary_grids(PBVH *pbvh,
|
||||
struct SubdivCCG *subdiv_ccg,
|
||||
SculptVertRef vertex);
|
||||
PBVHVertRef vertex);
|
||||
|
||||
void BKE_pbvh_set_mdyntopo_verts(PBVH *pbvh, struct MSculptVert *mdyntopoverts);
|
||||
|
||||
|
@ -1171,7 +1167,7 @@ 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,
|
||||
PBVHVertRef vertex,
|
||||
int **r_edges,
|
||||
int *r_edges_size,
|
||||
bool *heap_alloc,
|
||||
|
|
|
@ -1475,8 +1475,8 @@ typedef struct EdgeQueueContext {
|
|||
static float maskcb_get(EdgeQueueContext *eq_ctx, BMVert *v1, BMVert *v2)
|
||||
{
|
||||
if (eq_ctx->mask_cb) {
|
||||
SculptVertRef sv1 = {(intptr_t)v1};
|
||||
SculptVertRef sv2 = {(intptr_t)v2};
|
||||
PBVHVertRef sv1 = {(intptr_t)v1};
|
||||
PBVHVertRef sv2 = {(intptr_t)v2};
|
||||
|
||||
float w1 = eq_ctx->mask_cb(sv1, eq_ctx->mask_cb_data);
|
||||
float w2 = eq_ctx->mask_cb(sv2, eq_ctx->mask_cb_data);
|
||||
|
@ -2058,7 +2058,7 @@ static void unified_edge_queue_task_cb(void *__restrict userdata,
|
|||
int randval = (seed = dyntopo_thread_rand(seed)) & 255;
|
||||
|
||||
if (do_smooth && randval > 127) {
|
||||
SculptVertRef sv = {.i = (intptr_t)l_iter->v};
|
||||
PBVHVertRef sv = {.i = (intptr_t)l_iter->v};
|
||||
surface_smooth_v_safe(tdata->pbvh,
|
||||
l_iter->v,
|
||||
eq_ctx->surface_smooth_fac *
|
||||
|
@ -2657,11 +2657,11 @@ static void unified_edge_queue_create(EdgeQueueContext *eq_ctx,
|
|||
MSculptVert *mv2 = BKE_PBVH_SCULPTVERT(cd_sculpt_vert, e->v2);
|
||||
|
||||
if (mv1->flag & SCULPTVERT_NEED_VALENCE) {
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (SculptVertRef){.i = (intptr_t)e->v1});
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)e->v1});
|
||||
}
|
||||
|
||||
if (mv2->flag & SCULPTVERT_NEED_VALENCE) {
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (SculptVertRef){.i = (intptr_t)e->v2});
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)e->v2});
|
||||
}
|
||||
|
||||
// check_vert_fan_are_tris(pbvh, e->v1);
|
||||
|
@ -2840,7 +2840,7 @@ static void edge_queue_create_local(EdgeQueueContext *eq_ctx,
|
|||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
|
||||
|
||||
if (mv->flag & SCULPTVERT_NEED_VALENCE) {
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (SculptVertRef){.i = (intptr_t)v});
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)v});
|
||||
}
|
||||
|
||||
edge_queue_insert_val34_vert(eq_ctx, v);
|
||||
|
@ -4018,14 +4018,14 @@ cleanup_valence_3_4(EdgeQueueContext *ectx,
|
|||
|
||||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
|
||||
|
||||
BKE_pbvh_bmesh_check_valence(pbvh, (SculptVertRef){.i = (intptr_t)v});
|
||||
BKE_pbvh_bmesh_check_valence(pbvh, (PBVHVertRef){.i = (intptr_t)v});
|
||||
|
||||
int val = mv->valence;
|
||||
if (val != 4 && val != 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef sv = {.i = (intptr_t)v};
|
||||
PBVHVertRef sv = {.i = (intptr_t)v};
|
||||
|
||||
if (len_squared_v3v3(v->co, center) >= rsqr || !v->e ||
|
||||
ectx->mask_cb(sv, ectx->mask_cb_data) < 0.5f) {
|
||||
|
@ -4444,7 +4444,7 @@ static bool do_cleanup_3_4(EdgeQueueContext *eq_ctx,
|
|||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
|
||||
|
||||
if (mv->flag & SCULPTVERT_NEED_VALENCE) {
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (SculptVertRef){.i = (intptr_t)v});
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)v});
|
||||
}
|
||||
|
||||
if (mv->valence < 5) {
|
||||
|
@ -4467,7 +4467,7 @@ static bool do_cleanup_3_4(EdgeQueueContext *eq_ctx,
|
|||
return modified;
|
||||
}
|
||||
|
||||
float mask_cb_nop(SculptVertRef vertex, void *userdata)
|
||||
float mask_cb_nop(PBVHVertRef vertex, void *userdata)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
|
|
@ -2681,7 +2681,7 @@ static void init_mdyntopo_layer_faces(SculptSession *ss, PBVH *pbvh, int totvert
|
|||
SCULPTVERT_NEED_BOUNDARY | SCULPTVERT_NEED_VALENCE | SCULPTVERT_NEED_DISK_SORT);
|
||||
mv->stroke_id = -1;
|
||||
|
||||
SculptVertRef vertex = {.i = i};
|
||||
PBVHVertRef vertex = {.i = i};
|
||||
|
||||
copy_v3_v3(mv->origco, ss->mvert[i].co);
|
||||
|
||||
|
@ -2717,7 +2717,7 @@ static void init_mdyntopo_layer_grids(SculptSession *ss, PBVH *pbvh, int totvert
|
|||
SCULPTVERT_NEED_BOUNDARY | SCULPTVERT_NEED_VALENCE | SCULPTVERT_NEED_DISK_SORT);
|
||||
mv->stroke_id = -1;
|
||||
|
||||
SculptVertRef vertex = {.i = i};
|
||||
PBVHVertRef vertex = {.i = i};
|
||||
|
||||
BKE_pbvh_update_vert_boundary_grids(pbvh, ss->subdiv_ccg, vertex);
|
||||
|
||||
|
|
|
@ -2233,7 +2233,7 @@ bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node)
|
|||
return (node->flag & PBVH_Leaf) && (node->flag & PBVH_FullyUnmasked);
|
||||
}
|
||||
|
||||
void BKE_pbvh_vert_mark_update(PBVH *pbvh, SculptVertRef vertex)
|
||||
void BKE_pbvh_vert_mark_update(PBVH *pbvh, PBVHVertRef vertex)
|
||||
{
|
||||
BLI_assert(pbvh->type == PBVH_FACES);
|
||||
pbvh->vert_bitmap[vertex.i] = true;
|
||||
|
@ -2640,8 +2640,8 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
|
|||
float *depth,
|
||||
|
||||
float *depth_back,
|
||||
SculptVertRef *r_active_vertex_index,
|
||||
SculptFaceRef *r_active_face_index,
|
||||
PBVHVertRef *r_active_vertex_index,
|
||||
PBVHFaceRef *r_active_face_index,
|
||||
float *r_face_normal,
|
||||
int stroke_id)
|
||||
{
|
||||
|
@ -2695,8 +2695,8 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
|
|||
if (j == 0 ||
|
||||
len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) {
|
||||
copy_v3_v3(nearest_vertex_co, co[j]);
|
||||
*r_active_vertex_index = (SculptVertRef){.i = mloop[lt->tri[j]].v};
|
||||
*r_active_face_index = (SculptFaceRef){.i = lt->poly};
|
||||
*r_active_vertex_index = (PBVHVertRef){.i = mloop[lt->tri[j]].v};
|
||||
*r_active_face_index = (PBVHFaceRef){.i = lt->poly};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2715,8 +2715,8 @@ static bool pbvh_grids_node_raycast(PBVH *pbvh,
|
|||
float *depth,
|
||||
float *back_depth,
|
||||
|
||||
SculptVertRef *r_active_vertex_index,
|
||||
SculptFaceRef *r_active_grid_index,
|
||||
PBVHVertRef *r_active_vertex_index,
|
||||
PBVHFaceRef *r_active_grid_index,
|
||||
float *r_face_normal)
|
||||
{
|
||||
const int totgrid = node->totprim;
|
||||
|
@ -2820,8 +2820,8 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
|
|||
int *hit_count,
|
||||
float *depth,
|
||||
float *back_depth,
|
||||
SculptVertRef *active_vertex_index,
|
||||
SculptFaceRef *active_face_grid_index,
|
||||
PBVHVertRef *active_vertex_index,
|
||||
PBVHFaceRef *active_face_grid_index,
|
||||
float *face_normal,
|
||||
int stroke_id)
|
||||
{
|
||||
|
@ -3597,30 +3597,30 @@ bool BKE_pbvh_draw_mask(const PBVH *pbvh)
|
|||
return false;
|
||||
}
|
||||
|
||||
SculptVertRef BKE_pbvh_table_index_to_vertex(PBVH *pbvh, int idx)
|
||||
PBVHVertRef BKE_pbvh_index_to_vertex(PBVH *pbvh, int idx)
|
||||
{
|
||||
if (pbvh->type == PBVH_BMESH) {
|
||||
SculptVertRef ref = {(intptr_t)pbvh->bm->vtable[idx]};
|
||||
PBVHVertRef ref = {(intptr_t)pbvh->bm->vtable[idx]};
|
||||
return ref;
|
||||
}
|
||||
|
||||
return BKE_pbvh_make_vref(idx);
|
||||
}
|
||||
|
||||
SculptEdgeRef BKE_pbvh_table_index_to_edge(PBVH *pbvh, int idx)
|
||||
PBVHEdgeRef BKE_pbvh_index_to_edge(PBVH *pbvh, int idx)
|
||||
{
|
||||
if (pbvh->type == PBVH_BMESH) {
|
||||
SculptEdgeRef ref = {(intptr_t)pbvh->bm->etable[idx]};
|
||||
PBVHEdgeRef ref = {(intptr_t)pbvh->bm->etable[idx]};
|
||||
return ref;
|
||||
}
|
||||
|
||||
return BKE_pbvh_make_eref(idx);
|
||||
}
|
||||
|
||||
SculptFaceRef BKE_pbvh_table_index_to_face(PBVH *pbvh, int idx)
|
||||
PBVHFaceRef BKE_pbvh_index_to_face(PBVH *pbvh, int idx)
|
||||
{
|
||||
if (pbvh->type == PBVH_BMESH) {
|
||||
SculptFaceRef ref = {(intptr_t)pbvh->bm->ftable[idx]};
|
||||
PBVHFaceRef ref = {(intptr_t)pbvh->bm->ftable[idx]};
|
||||
return ref;
|
||||
}
|
||||
|
||||
|
@ -3908,7 +3908,7 @@ void BKE_pbvh_ensure_proxyarray(SculptSession *ss,
|
|||
UPDATETEST(fno, PV_NO, sizeof(float) * 3)
|
||||
UPDATETEST(mask, PV_MASK, sizeof(float))
|
||||
UPDATETEST(color, PV_COLOR, sizeof(float) * 4)
|
||||
UPDATETEST(index, PV_INDEX, sizeof(SculptVertRef))
|
||||
UPDATETEST(index, PV_INDEX, sizeof(PBVHVertRef))
|
||||
UPDATETEST(neighbors, PV_NEIGHBORS, sizeof(ProxyKey) * MAX_PROXY_NEIGHBORS)
|
||||
|
||||
p->size = totvert;
|
||||
|
@ -4336,7 +4336,7 @@ void BKE_pbvh_check_tri_areas(PBVH *pbvh, PBVHNode *node)
|
|||
}
|
||||
|
||||
static void pbvh_pmap_to_edges_add(PBVH *pbvh,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
int **r_edges,
|
||||
int *r_edges_size,
|
||||
bool *heap_alloc,
|
||||
|
@ -4384,7 +4384,7 @@ static void pbvh_pmap_to_edges_add(PBVH *pbvh,
|
|||
}
|
||||
|
||||
void BKE_pbvh_pmap_to_edges(PBVH *pbvh,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
int **r_edges,
|
||||
int *r_edges_size,
|
||||
bool *r_heap_alloc,
|
||||
|
@ -4434,7 +4434,7 @@ void BKE_pbvh_set_vemap(PBVH *pbvh, MeshElemMap *vemap)
|
|||
pbvh->vemap = vemap;
|
||||
}
|
||||
|
||||
void BKE_pbvh_get_vert_face_areas(PBVH *pbvh, SculptVertRef vertex, float *r_areas, int valence)
|
||||
void BKE_pbvh_get_vert_face_areas(PBVH *pbvh, PBVHVertRef vertex, float *r_areas, int valence)
|
||||
{
|
||||
const int cur_i = pbvh->face_area_i;
|
||||
|
||||
|
@ -4629,7 +4629,7 @@ void BKE_pbvh_set_mdyntopo_verts(PBVH *pbvh, struct MSculptVert *mdyntopoverts)
|
|||
|
||||
void BKE_pbvh_update_vert_boundary_grids(PBVH *pbvh,
|
||||
struct SubdivCCG *subdiv_ccg,
|
||||
SculptVertRef vertex)
|
||||
PBVHVertRef vertex)
|
||||
{
|
||||
MSculptVert *mv = pbvh->mdyntopo_verts + vertex.i;
|
||||
|
||||
|
@ -4664,7 +4664,7 @@ void BKE_pbvh_update_vert_boundary_faces(int *face_sets,
|
|||
MPoly *mpoly,
|
||||
MSculptVert *mdyntopo_verts,
|
||||
MeshElemMap *pmap,
|
||||
SculptVertRef vertex)
|
||||
PBVHVertRef vertex)
|
||||
{
|
||||
MSculptVert *mv = mdyntopo_verts + vertex.i;
|
||||
MeshElemMap *vert_map = &pmap[vertex.i];
|
||||
|
@ -5308,7 +5308,7 @@ void BKE_pbvh_ensure_node_loops(PBVH *pbvh)
|
|||
}
|
||||
|
||||
bool BKE_pbvh_get_origvert(
|
||||
PBVH *pbvh, SculptVertRef vertex, const float **r_co, float **r_no, float **r_color)
|
||||
PBVH *pbvh, PBVHVertRef vertex, const float **r_co, float **r_no, float **r_color)
|
||||
{
|
||||
MSculptVert *mv;
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ template<> void from_float(const float src[4], MPropCol &dst)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static void pbvh_vertex_color_get_faces(const PBVH &pbvh, SculptVertRef vertex, float r_color[4])
|
||||
static void pbvh_vertex_color_get_faces(const PBVH &pbvh, PBVHVertRef vertex, float r_color[4])
|
||||
{
|
||||
if (pbvh.color_domain == ATTR_DOMAIN_CORNER) {
|
||||
const MeshElemMap &melem = pbvh.pmap->pmap[vertex.i];
|
||||
|
@ -120,7 +120,7 @@ static void pbvh_vertex_color_get_faces(const PBVH &pbvh, SculptVertRef vertex,
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static void pbvh_vertex_color_get_bmesh(const PBVH &pbvh, SculptVertRef vertex, float r_color[4])
|
||||
static void pbvh_vertex_color_get_bmesh(const PBVH &pbvh, PBVHVertRef vertex, float r_color[4])
|
||||
{
|
||||
BMVert *v = reinterpret_cast<BMVert *>(vertex.i);
|
||||
|
||||
|
@ -152,7 +152,7 @@ static void pbvh_vertex_color_get_bmesh(const PBVH &pbvh, SculptVertRef vertex,
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static void pbvh_vertex_color_get(const PBVH &pbvh, SculptVertRef vertex, float r_color[4])
|
||||
static void pbvh_vertex_color_get(const PBVH &pbvh, PBVHVertRef vertex, float r_color[4])
|
||||
{
|
||||
switch (pbvh.type) {
|
||||
case PBVH_FACES:
|
||||
|
@ -167,7 +167,7 @@ static void pbvh_vertex_color_get(const PBVH &pbvh, SculptVertRef vertex, float
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static void pbvh_vertex_color_set_faces(PBVH &pbvh, SculptVertRef vertex, const float color[4])
|
||||
static void pbvh_vertex_color_set_faces(PBVH &pbvh, PBVHVertRef vertex, const float color[4])
|
||||
{
|
||||
if (pbvh.color_domain == ATTR_DOMAIN_CORNER) {
|
||||
const MeshElemMap &melem = pbvh.pmap->pmap[vertex.i];
|
||||
|
@ -190,7 +190,7 @@ static void pbvh_vertex_color_set_faces(PBVH &pbvh, SculptVertRef vertex, const
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static void pbvh_vertex_color_set_bmesh(PBVH &pbvh, SculptVertRef vertex, const float color[4])
|
||||
static void pbvh_vertex_color_set_bmesh(PBVH &pbvh, PBVHVertRef vertex, const float color[4])
|
||||
{
|
||||
BMVert *v = reinterpret_cast<BMVert *>(vertex.i);
|
||||
|
||||
|
@ -210,7 +210,7 @@ static void pbvh_vertex_color_set_bmesh(PBVH &pbvh, SculptVertRef vertex, const
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static void pbvh_vertex_color_set(PBVH &pbvh, SculptVertRef vertex, const float color[4])
|
||||
static void pbvh_vertex_color_set(PBVH &pbvh, PBVHVertRef vertex, const float color[4])
|
||||
{
|
||||
switch (pbvh.type) {
|
||||
case PBVH_FACES:
|
||||
|
@ -227,7 +227,7 @@ static void pbvh_vertex_color_set(PBVH &pbvh, SculptVertRef vertex, const float
|
|||
} // namespace blender::bke
|
||||
|
||||
extern "C" {
|
||||
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, SculptVertRef vertex, float r_color[4])
|
||||
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, PBVHVertRef vertex, float r_color[4])
|
||||
{
|
||||
blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) {
|
||||
using T = decltype(dummy);
|
||||
|
@ -235,7 +235,7 @@ void BKE_pbvh_vertex_color_get(const PBVH *pbvh, SculptVertRef vertex, float r_c
|
|||
});
|
||||
}
|
||||
|
||||
void BKE_pbvh_vertex_color_set(PBVH *pbvh, SculptVertRef vertex, const float color[4])
|
||||
void BKE_pbvh_vertex_color_set(PBVH *pbvh, PBVHVertRef vertex, const float color[4])
|
||||
{
|
||||
blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) {
|
||||
using T = decltype(dummy);
|
||||
|
@ -285,7 +285,7 @@ void BKE_pbvh_store_colors_vertex(PBVH *pbvh,
|
|||
blender::bke::to_static_color_type(eCustomDataType(pbvh->color_layer->type), [&](auto dummy) {
|
||||
using T = decltype(dummy);
|
||||
for (const int i : IndexRange(indices_num)) {
|
||||
SculptVertRef vertex = {(intptr_t)indices[i]};
|
||||
PBVHVertRef vertex = {(intptr_t)indices[i]};
|
||||
|
||||
blender::bke::pbvh_vertex_color_get<T>(*pbvh, vertex, r_colors[i]);
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ ATTR_NO_OPT void pbvh_bmesh_check_nodes(PBVH *pbvh)
|
|||
}
|
||||
|
||||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
|
||||
BKE_pbvh_bmesh_check_valence(pbvh, (SculptVertRef){.i = (intptr_t)v});
|
||||
BKE_pbvh_bmesh_check_valence(pbvh, (PBVHVertRef){.i = (intptr_t)v});
|
||||
|
||||
if (BM_vert_edge_count(v) != mv->valence) {
|
||||
_debugprint("cached vertex valence mismatch; old: %d, should be: %d\n",
|
||||
|
@ -872,7 +872,7 @@ void BKE_pbvh_bmesh_regen_node_verts(PBVH *pbvh)
|
|||
|
||||
bool BKE_pbvh_bmesh_check_origdata(PBVH *pbvh, BMVert *v, int stroke_id)
|
||||
{
|
||||
SculptVertRef vertex = {(intptr_t)v};
|
||||
PBVHVertRef vertex = {(intptr_t)v};
|
||||
|
||||
return BKE_pbvh_get_origvert(pbvh, vertex, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -886,8 +886,8 @@ bool pbvh_bmesh_node_raycast(PBVH *pbvh,
|
|||
float *depth,
|
||||
float *back_depth,
|
||||
bool use_original,
|
||||
SculptVertRef *r_active_vertex_index,
|
||||
SculptFaceRef *r_active_face_index,
|
||||
PBVHVertRef *r_active_vertex_index,
|
||||
PBVHFaceRef *r_active_face_index,
|
||||
float *r_face_normal,
|
||||
int stroke_id)
|
||||
{
|
||||
|
@ -2211,7 +2211,7 @@ void BKE_pbvh_update_sculpt_verts(PBVH *pbvh)
|
|||
int totvert = pbvh->totvert;
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(pbvh, i);
|
||||
|
||||
BKE_pbvh_get_origvert(pbvh, vertex, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -2549,7 +2549,7 @@ static bool pbvh_bmesh_split_tris(PBVH *pbvh, PBVHNode *node)
|
|||
const int cd_uv = pbvh->bm->ldata.layers[layeri].offset;
|
||||
const int cd_size = CustomData_sizeof(CD_MLOOPUV);
|
||||
|
||||
SculptVertRef *verts = NULL;
|
||||
PBVHVertRef *verts = NULL;
|
||||
PBVHTri *tris = NULL;
|
||||
intptr_t *loops = NULL;
|
||||
|
||||
|
@ -2580,7 +2580,7 @@ static bool pbvh_bmesh_split_tris(PBVH *pbvh, PBVHNode *node)
|
|||
l->head.index = vi++;
|
||||
BLI_array_append(loops, (intptr_t)l);
|
||||
|
||||
SculptVertRef sv = {(intptr_t)l->v};
|
||||
PBVHVertRef sv = {(intptr_t)l->v};
|
||||
BLI_array_append(verts, sv);
|
||||
|
||||
BMIter iter;
|
||||
|
@ -2660,7 +2660,7 @@ BLI_INLINE PBVHTri *pbvh_tribuf_add_tri(PBVHTriBuf *tribuf)
|
|||
return tribuf->tris + tribuf->tottri - 1;
|
||||
}
|
||||
|
||||
BLI_INLINE void pbvh_tribuf_add_vert(PBVHTriBuf *tribuf, SculptVertRef vertex, BMLoop *l)
|
||||
BLI_INLINE void pbvh_tribuf_add_vert(PBVHTriBuf *tribuf, PBVHVertRef vertex, BMLoop *l)
|
||||
{
|
||||
tribuf->totvert++;
|
||||
tribuf->totloop++;
|
||||
|
@ -2906,7 +2906,7 @@ bool BKE_pbvh_bmesh_check_tris(PBVH *pbvh, PBVHNode *node)
|
|||
uintptr_t loopkey = tri_loopkey(l, mat_nr, pbvh->cd_faceset_offset, cd_uvs, totuv);
|
||||
|
||||
if (!BLI_smallhash_ensure_p(&node->tribuf->vertmap, loopkey, &val)) {
|
||||
SculptVertRef sv = {(intptr_t)l->v};
|
||||
PBVHVertRef sv = {(intptr_t)l->v};
|
||||
|
||||
minmax_v3v3_v3(min, max, l->v->co);
|
||||
|
||||
|
@ -2919,7 +2919,7 @@ bool BKE_pbvh_bmesh_check_tris(PBVH *pbvh, PBVHNode *node)
|
|||
|
||||
val = NULL;
|
||||
if (!BLI_smallhash_ensure_p(&mat_tribuf->vertmap, loopkey, &val)) {
|
||||
SculptVertRef sv = {(intptr_t)l->v};
|
||||
PBVHVertRef sv = {(intptr_t)l->v};
|
||||
|
||||
minmax_v3v3_v3(min, max, l->v->co);
|
||||
|
||||
|
@ -2948,7 +2948,7 @@ bool BKE_pbvh_bmesh_check_tris(PBVH *pbvh, PBVHNode *node)
|
|||
void **val = NULL;
|
||||
|
||||
if (!BLI_ghash_ensure_p(vmap, l->v, &val)) {
|
||||
SculptVertRef sv = {(intptr_t)l->v};
|
||||
PBVHVertRef sv = {(intptr_t)l->v};
|
||||
|
||||
minmax_v3v3_v3(min, max, l->v->co);
|
||||
|
||||
|
@ -2961,7 +2961,7 @@ bool BKE_pbvh_bmesh_check_tris(PBVH *pbvh, PBVHNode *node)
|
|||
|
||||
val = NULL;
|
||||
if (!BLI_ghash_ensure_p(mat_vmaps[mat_nr], l->v, &val)) {
|
||||
SculptVertRef sv = {(intptr_t)l->v};
|
||||
PBVHVertRef sv = {(intptr_t)l->v};
|
||||
|
||||
minmax_v3v3_v3(min, max, l->v->co);
|
||||
|
||||
|
@ -3071,7 +3071,7 @@ void BKE_pbvh_bmesh_update_all_valence(PBVH *pbvh)
|
|||
BMVert *v;
|
||||
|
||||
BM_ITER_MESH (v, &iter, pbvh->bm, BM_VERTS_OF_MESH) {
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (SculptVertRef){(intptr_t)v});
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){(intptr_t)v});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3095,11 +3095,11 @@ void BKE_pbvh_bmesh_on_mesh_change(PBVH *pbvh)
|
|||
|
||||
MV_ADD_FLAG(
|
||||
mv, SCULPTVERT_NEED_BOUNDARY | SCULPTVERT_NEED_DISK_SORT | SCULPTVERT_NEED_TRIANGULATE);
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (SculptVertRef){.i = (intptr_t)v});
|
||||
BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)v});
|
||||
}
|
||||
}
|
||||
|
||||
bool BKE_pbvh_bmesh_mark_update_valence(PBVH *pbvh, SculptVertRef vertex)
|
||||
bool BKE_pbvh_bmesh_mark_update_valence(PBVH *pbvh, PBVHVertRef vertex)
|
||||
{
|
||||
BMVert *v = (BMVert *)vertex.i;
|
||||
MSculptVert *mv = BM_ELEM_CD_GET_VOID_P(v, pbvh->cd_sculpt_vert);
|
||||
|
@ -3111,7 +3111,7 @@ bool BKE_pbvh_bmesh_mark_update_valence(PBVH *pbvh, SculptVertRef vertex)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool BKE_pbvh_bmesh_check_valence(PBVH *pbvh, SculptVertRef vertex)
|
||||
bool BKE_pbvh_bmesh_check_valence(PBVH *pbvh, PBVHVertRef vertex)
|
||||
{
|
||||
BMVert *v = (BMVert *)vertex.i;
|
||||
MSculptVert *mv = BM_ELEM_CD_GET_VOID_P(v, pbvh->cd_sculpt_vert);
|
||||
|
@ -3124,7 +3124,7 @@ bool BKE_pbvh_bmesh_check_valence(PBVH *pbvh, SculptVertRef vertex)
|
|||
return false;
|
||||
}
|
||||
|
||||
void BKE_pbvh_bmesh_update_valence(int cd_sculpt_vert, SculptVertRef vertex)
|
||||
void BKE_pbvh_bmesh_update_valence(int cd_sculpt_vert, PBVHVertRef vertex)
|
||||
{
|
||||
BMVert *v = (BMVert *)vertex.i;
|
||||
BMEdge *e;
|
||||
|
|
|
@ -348,8 +348,8 @@ bool pbvh_bmesh_node_raycast(PBVH *pbvh,
|
|||
float *depth,
|
||||
float *back_depth,
|
||||
bool use_original,
|
||||
SculptVertRef *r_active_vertex_index,
|
||||
SculptFaceRef *r_active_face_index,
|
||||
PBVHVertRef *r_active_vertex_index,
|
||||
PBVHFaceRef *r_active_face_index,
|
||||
float *r_face_normal,
|
||||
int stroke_id);
|
||||
|
||||
|
|
|
@ -1225,7 +1225,7 @@ typedef struct PaintCursorContext {
|
|||
/* Sculpt related data. */
|
||||
Sculpt *sd;
|
||||
SculptSession *ss;
|
||||
SculptVertRef prev_active_vertex_index;
|
||||
PBVHVertRef prev_active_vertex_index;
|
||||
bool is_stroke_active;
|
||||
bool is_cursor_over_mesh;
|
||||
bool is_multires;
|
||||
|
|
|
@ -1047,7 +1047,7 @@ static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext)
|
|||
trim_operation->depth_back = -FLT_MAX;
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
const float *vco = SCULPT_vertex_co_get(ss, BKE_pbvh_table_index_to_vertex(ss->pbvh, i));
|
||||
const float *vco = SCULPT_vertex_co_get(ss, BKE_pbvh_index_to_vertex(ss->pbvh, i));
|
||||
/* Convert the coordinates to world space to calculate the depth. When generating the trimming
|
||||
* mesh, coordinates are first calculated in world space, then converted to object space to
|
||||
* store them. */
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
#include <string.h>
|
||||
|
||||
static bool sculpt_check_boundary_vertex_in_base_mesh(const SculptSession *ss,
|
||||
const SculptVertRef index);
|
||||
const PBVHVertRef index);
|
||||
typedef void (*BrushActionFunc)(Sculpt *sd,
|
||||
Object *ob,
|
||||
Brush *brush,
|
||||
|
@ -281,7 +281,7 @@ void SCULPT_vertex_random_access_ensure(SculptSession *ss)
|
|||
}
|
||||
}
|
||||
|
||||
void SCULPT_face_normal_get(SculptSession *ss, SculptFaceRef face, float no[3])
|
||||
void SCULPT_face_normal_get(SculptSession *ss, PBVHFaceRef face, float no[3])
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
|
@ -327,7 +327,7 @@ int SCULPT_vertex_count_get(const SculptSession *ss)
|
|||
return BKE_sculptsession_get_totvert(ss);
|
||||
}
|
||||
|
||||
MSculptVert *SCULPT_vertex_get_sculptvert(const SculptSession *ss, SculptVertRef vertex)
|
||||
MSculptVert *SCULPT_vertex_get_sculptvert(const SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
|
@ -344,7 +344,7 @@ MSculptVert *SCULPT_vertex_get_sculptvert(const SculptSession *ss, SculptVertRef
|
|||
return NULL;
|
||||
}
|
||||
|
||||
float *SCULPT_vertex_origco_get(SculptSession *ss, SculptVertRef vertex)
|
||||
float *SCULPT_vertex_origco_get(SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
|
@ -361,7 +361,7 @@ float *SCULPT_vertex_origco_get(SculptSession *ss, SculptVertRef vertex)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
float *SCULPT_vertex_origno_get(SculptSession *ss, SculptVertRef vertex)
|
||||
float *SCULPT_vertex_origno_get(SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
|
@ -378,7 +378,7 @@ float *SCULPT_vertex_origno_get(SculptSession *ss, SculptVertRef vertex)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const float *SCULPT_vertex_co_get(SculptSession *ss, SculptVertRef index)
|
||||
const float *SCULPT_vertex_co_get(SculptSession *ss, PBVHVertRef index)
|
||||
{
|
||||
if (ss->bm) {
|
||||
return ((BMVert *)index.i)->co;
|
||||
|
@ -420,17 +420,17 @@ bool SCULPT_has_colors(const SculptSession *ss)
|
|||
return ss->vcol || ss->mcol;
|
||||
}
|
||||
|
||||
void SCULPT_vertex_color_get(const SculptSession *ss, SculptVertRef vertex, float r_color[4])
|
||||
void SCULPT_vertex_color_get(const SculptSession *ss, PBVHVertRef vertex, float r_color[4])
|
||||
{
|
||||
BKE_pbvh_vertex_color_get(ss->pbvh, vertex, r_color);
|
||||
}
|
||||
|
||||
void SCULPT_vertex_color_set(SculptSession *ss, SculptVertRef vertex, const float color[4])
|
||||
void SCULPT_vertex_color_set(SculptSession *ss, PBVHVertRef vertex, const float color[4])
|
||||
{
|
||||
BKE_pbvh_vertex_color_set(ss->pbvh, vertex, color);
|
||||
}
|
||||
|
||||
void SCULPT_vertex_normal_get(SculptSession *ss, SculptVertRef vertex, float no[3])
|
||||
void SCULPT_vertex_normal_get(SculptSession *ss, PBVHVertRef vertex, float no[3])
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
|
@ -477,7 +477,7 @@ bool SCULPT_has_persistent_base(SculptSession *ss)
|
|||
return idx >= 0;
|
||||
}
|
||||
|
||||
const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, SculptVertRef index)
|
||||
const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, PBVHVertRef index)
|
||||
{
|
||||
if (ss->scl.persistent_co) {
|
||||
return (float *)SCULPT_attr_vertex_data(index, ss->scl.persistent_co);
|
||||
|
@ -486,24 +486,24 @@ const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, SculptVertRef in
|
|||
return SCULPT_vertex_co_get(ss, index);
|
||||
}
|
||||
|
||||
const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, SculptVertRef vertex)
|
||||
const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
/* Always grab active shape key if the sculpt happens on shapekey. */
|
||||
if (ss->shapekey_active) {
|
||||
const MVert *mverts = BKE_pbvh_get_verts(ss->pbvh);
|
||||
return mverts[BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex)].co;
|
||||
return mverts[BKE_pbvh_vertex_to_index(ss->pbvh, vertex)].co;
|
||||
}
|
||||
|
||||
/* Sculpting on the base mesh. */
|
||||
if (ss->mvert) {
|
||||
return ss->mvert[BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex)].co;
|
||||
return ss->mvert[BKE_pbvh_vertex_to_index(ss->pbvh, vertex)].co;
|
||||
}
|
||||
|
||||
/* Everything else, such as sculpting on multires. */
|
||||
return SCULPT_vertex_co_get(ss, vertex);
|
||||
}
|
||||
|
||||
void SCULPT_vertex_limit_surface_get(SculptSession *ss, SculptVertRef vertex, float r_co[3])
|
||||
void SCULPT_vertex_limit_surface_get(SculptSession *ss, PBVHVertRef vertex, float r_co[3])
|
||||
{
|
||||
if (BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS) {
|
||||
if (ss->scl.limit_surface) {
|
||||
|
@ -527,7 +527,7 @@ void SCULPT_vertex_limit_surface_get(SculptSession *ss, SculptVertRef vertex, fl
|
|||
BKE_subdiv_ccg_eval_limit_point(ss->subdiv_ccg, &coord, r_co);
|
||||
}
|
||||
|
||||
void SCULPT_vertex_persistent_normal_get(SculptSession *ss, SculptVertRef vertex, float no[3])
|
||||
void SCULPT_vertex_persistent_normal_get(SculptSession *ss, PBVHVertRef vertex, float no[3])
|
||||
{
|
||||
if (ss->scl.persistent_no) {
|
||||
float *no2 = SCULPT_attr_vertex_data(vertex, ss->scl.persistent_no);
|
||||
|
@ -543,7 +543,7 @@ void SCULPT_update_customdata_refs(SculptSession *ss, Object *ob)
|
|||
BKE_sculptsession_update_attr_refs(ob);
|
||||
}
|
||||
|
||||
float SCULPT_vertex_mask_get(SculptSession *ss, SculptVertRef index)
|
||||
float SCULPT_vertex_mask_get(SculptSession *ss, PBVHVertRef index)
|
||||
{
|
||||
BMVert *v;
|
||||
float *mask;
|
||||
|
@ -631,12 +631,12 @@ SculptCustomLayer *SCULPT_attr_get_layer(SculptSession *ss,
|
|||
return BKE_sculptsession_attr_layer_get(ob, domain, proptype, name, params, NULL);
|
||||
}
|
||||
|
||||
SculptVertRef SCULPT_active_vertex_get(SculptSession *ss)
|
||||
PBVHVertRef SCULPT_active_vertex_get(SculptSession *ss)
|
||||
{
|
||||
if (ELEM(BKE_pbvh_type(ss->pbvh), PBVH_FACES, PBVH_BMESH, PBVH_GRIDS)) {
|
||||
return ss->active_vertex_index;
|
||||
}
|
||||
return BKE_pbvh_make_vref(SCULPT_REF_NONE);
|
||||
return BKE_pbvh_make_vref(PBVH_REF_NONE);
|
||||
}
|
||||
|
||||
const float *SCULPT_active_vertex_co_get(SculptSession *ss)
|
||||
|
@ -687,7 +687,7 @@ char SCULPT_mesh_symmetry_xyz_get(Object *object)
|
|||
|
||||
int SCULPT_active_face_set_get(SculptSession *ss)
|
||||
{
|
||||
if (ss->active_face_index.i == SCULPT_REF_NONE) {
|
||||
if (ss->active_face_index.i == PBVH_REF_NONE) {
|
||||
return SCULPT_FACE_SET_NONE;
|
||||
}
|
||||
|
||||
|
@ -710,7 +710,7 @@ int SCULPT_active_face_set_get(SculptSession *ss)
|
|||
return SCULPT_FACE_SET_NONE;
|
||||
}
|
||||
|
||||
void SCULPT_vertex_visible_set(SculptSession *ss, SculptVertRef vertex, bool visible)
|
||||
void SCULPT_vertex_visible_set(SculptSession *ss, PBVHVertRef vertex, bool visible)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES:
|
||||
|
@ -725,7 +725,7 @@ void SCULPT_vertex_visible_set(SculptSession *ss, SculptVertRef vertex, bool vis
|
|||
}
|
||||
}
|
||||
|
||||
bool SCULPT_vertex_visible_get(SculptSession *ss, SculptVertRef index)
|
||||
bool SCULPT_vertex_visible_get(SculptSession *ss, PBVHVertRef index)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES:
|
||||
|
@ -884,7 +884,7 @@ void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible)
|
|||
}
|
||||
}
|
||||
|
||||
bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, SculptVertRef index)
|
||||
bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, PBVHVertRef index)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
|
@ -916,7 +916,7 @@ bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, SculptVertRef ind
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SCULPT_vertex_all_face_sets_visible_get(const SculptSession *ss, SculptVertRef index)
|
||||
bool SCULPT_vertex_all_face_sets_visible_get(const SculptSession *ss, PBVHVertRef index)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
|
@ -952,7 +952,7 @@ bool SCULPT_vertex_all_face_sets_visible_get(const SculptSession *ss, SculptVert
|
|||
return true;
|
||||
}
|
||||
|
||||
void SCULPT_vertex_face_set_set(SculptSession *ss, SculptVertRef index, int face_set)
|
||||
void SCULPT_vertex_face_set_set(SculptSession *ss, PBVHVertRef index, int face_set)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
|
@ -1007,7 +1007,7 @@ void SCULPT_vertex_face_set_set(SculptSession *ss, SculptVertRef index, int face
|
|||
}
|
||||
}
|
||||
|
||||
void SCULPT_vertex_face_set_increase(SculptSession *ss, SculptVertRef vertex, const int increase)
|
||||
void SCULPT_vertex_face_set_increase(SculptSession *ss, PBVHVertRef vertex, const int increase)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
|
@ -1050,7 +1050,7 @@ void SCULPT_vertex_face_set_increase(SculptSession *ss, SculptVertRef vertex, co
|
|||
}
|
||||
}
|
||||
|
||||
int SCULPT_vertex_face_set_get(SculptSession *ss, SculptVertRef index)
|
||||
int SCULPT_vertex_face_set_get(SculptSession *ss, PBVHVertRef index)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
|
@ -1090,7 +1090,7 @@ int SCULPT_vertex_face_set_get(SculptSession *ss, SculptVertRef index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool SCULPT_vertex_has_face_set(SculptSession *ss, SculptVertRef index, int face_set)
|
||||
bool SCULPT_vertex_has_face_set(SculptSession *ss, PBVHVertRef index, int face_set)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
|
@ -1148,7 +1148,7 @@ bool SCULPT_vertex_has_face_set(SculptSession *ss, SculptVertRef index, int face
|
|||
calcs visibility state based on face sets.
|
||||
todo: also calc a face set boundary flag.
|
||||
*/
|
||||
void sculpt_vertex_faceset_update_bmesh(SculptSession *ss, SculptVertRef vert)
|
||||
void sculpt_vertex_faceset_update_bmesh(SculptSession *ss, PBVHVertRef vert)
|
||||
{
|
||||
if (!ss->bm) {
|
||||
return;
|
||||
|
@ -1252,7 +1252,7 @@ void SCULPT_visibility_sync_all_face_sets_to_vertices(Object *ob)
|
|||
}
|
||||
|
||||
static void UNUSED_FUNCTION(sculpt_visibility_sync_vertex_to_face_sets)(SculptSession *ss,
|
||||
SculptVertRef vertex)
|
||||
PBVHVertRef vertex)
|
||||
{
|
||||
int index = (int)vertex.i;
|
||||
MeshElemMap *vert_map = &ss->pmap->pmap[index];
|
||||
|
@ -1329,51 +1329,9 @@ void SCULPT_visibility_sync_all_vertex_to_face_sets(SculptSession *ss)
|
|||
}
|
||||
}
|
||||
|
||||
static SculptCornerType sculpt_check_corner_in_base_mesh(const SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
bool check_facesets)
|
||||
static bool sculpt_check_unique_face_set_in_base_mesh(const SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
int index = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
|
||||
MeshElemMap *vert_map = &ss->pmap->pmap[index];
|
||||
int face_set = -1;
|
||||
int last1 = -1;
|
||||
int last2 = -1;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
if (sculpt_check_boundary_vertex_in_base_mesh(ss, vertex) && ss->pmap->pmap[index].count < 4) {
|
||||
ret |= SCULPT_CORNER_MESH;
|
||||
}
|
||||
|
||||
if (check_facesets) {
|
||||
for (int i = 0; i < ss->pmap->pmap[index].count; i++) {
|
||||
if (check_facesets) {
|
||||
if (last2 != last1) {
|
||||
last2 = last1;
|
||||
}
|
||||
if (last1 != face_set) {
|
||||
last1 = face_set;
|
||||
}
|
||||
face_set = abs(ss->face_sets[vert_map->indices[i]]);
|
||||
|
||||
bool corner = last1 != -1 && last2 != -1 && face_set != -1;
|
||||
corner = corner && last1 != last2 && last1 != face_set;
|
||||
|
||||
if (corner) {
|
||||
ret |= SCULPT_CORNER_FACE_SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool sculpt_check_unique_face_set_in_base_mesh(const SculptSession *ss,
|
||||
SculptVertRef vertex)
|
||||
{
|
||||
int index = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int index = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
MeshElemMap *vert_map = &ss->pmap->pmap[index];
|
||||
int face_set = -1;
|
||||
|
@ -1424,7 +1382,7 @@ static bool sculpt_check_unique_face_set_for_edge_in_base_mesh(const SculptSessi
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SCULPT_vertex_has_unique_face_set(const SculptSession *ss, SculptVertRef vertex)
|
||||
bool SCULPT_vertex_has_unique_face_set(const SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
return !SCULPT_vertex_is_boundary(ss, vertex, SCULPT_BOUNDARY_FACE_SET);
|
||||
}
|
||||
|
@ -1468,8 +1426,8 @@ int SCULPT_face_set_next_available_get(SculptSession *ss)
|
|||
/* Sculpt Neighbor Iterators */
|
||||
|
||||
static void sculpt_vertex_neighbor_add(SculptVertexNeighborIter *iter,
|
||||
SculptVertRef neighbor,
|
||||
SculptEdgeRef edge,
|
||||
PBVHVertRef neighbor,
|
||||
PBVHEdgeRef edge,
|
||||
int neighbor_index)
|
||||
{
|
||||
for (int i = 0; i < iter->size; i++) {
|
||||
|
@ -1507,8 +1465,8 @@ static void sculpt_vertex_neighbor_add(SculptVertexNeighborIter *iter,
|
|||
}
|
||||
|
||||
static void sculpt_vertex_neighbor_add_nocheck(SculptVertexNeighborIter *iter,
|
||||
SculptVertRef neighbor,
|
||||
SculptEdgeRef edge,
|
||||
PBVHVertRef neighbor,
|
||||
PBVHEdgeRef edge,
|
||||
int neighbor_index)
|
||||
{
|
||||
if (iter->size >= iter->capacity) {
|
||||
|
@ -1541,7 +1499,7 @@ static void sculpt_vertex_neighbor_add_nocheck(SculptVertexNeighborIter *iter,
|
|||
}
|
||||
|
||||
static void sculpt_vertex_neighbors_get_bmesh(const SculptSession *ss,
|
||||
SculptVertRef index,
|
||||
PBVHVertRef index,
|
||||
SculptVertexNeighborIter *iter)
|
||||
{
|
||||
BMVert *v = (BMVert *)index.i;
|
||||
|
@ -1587,17 +1545,17 @@ static void sculpt_vertex_neighbors_get_bmesh(const SculptSession *ss,
|
|||
if (ss->fake_neighbors.fake_neighbor_index[index].i != FAKE_NEIGHBOR_NONE) {
|
||||
sculpt_vertex_neighbor_add(iter,
|
||||
ss->fake_neighbors.fake_neighbor_index[index],
|
||||
BKE_pbvh_make_eref(SCULPT_REF_NONE),
|
||||
BKE_pbvh_make_eref(PBVH_REF_NONE),
|
||||
ss->fake_neighbors.fake_neighbor_index[index].i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sculpt_vertex_neighbors_get_faces(const SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
SculptVertexNeighborIter *iter)
|
||||
{
|
||||
int index = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int index = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
iter->size = 0;
|
||||
iter->num_duplicates = 0;
|
||||
|
@ -1669,17 +1627,17 @@ static void sculpt_vertex_neighbors_get_faces(const SculptSession *ss,
|
|||
if (ss->fake_neighbors.fake_neighbor_index[index].i != FAKE_NEIGHBOR_NONE) {
|
||||
sculpt_vertex_neighbor_add(iter,
|
||||
ss->fake_neighbors.fake_neighbor_index[index],
|
||||
BKE_pbvh_make_eref(SCULPT_REF_NONE),
|
||||
BKE_pbvh_make_eref(PBVH_REF_NONE),
|
||||
ss->fake_neighbors.fake_neighbor_index[index].i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sculpt_vertex_neighbors_get_faces_vemap(const SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
SculptVertexNeighborIter *iter)
|
||||
{
|
||||
int index = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int index = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
MeshElemMap *vert_map = &ss->vemap[index];
|
||||
iter->size = 0;
|
||||
|
@ -1710,14 +1668,14 @@ static void sculpt_vertex_neighbors_get_faces_vemap(const SculptSession *ss,
|
|||
if (ss->fake_neighbors.fake_neighbor_index[index].i != FAKE_NEIGHBOR_NONE) {
|
||||
sculpt_vertex_neighbor_add(iter,
|
||||
ss->fake_neighbors.fake_neighbor_index[index],
|
||||
BKE_pbvh_make_eref(SCULPT_REF_NONE),
|
||||
BKE_pbvh_make_eref(PBVH_REF_NONE),
|
||||
ss->fake_neighbors.fake_neighbor_index[index].i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sculpt_vertex_neighbors_get_grids(const SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const bool include_duplicates,
|
||||
SculptVertexNeighborIter *iter)
|
||||
{
|
||||
|
@ -1751,7 +1709,7 @@ static void sculpt_vertex_neighbors_get_grids(const SculptSession *ss,
|
|||
neighbors.coords[i].y * key->grid_size + neighbors.coords[i].x;
|
||||
|
||||
sculpt_vertex_neighbor_add(
|
||||
iter, BKE_pbvh_make_vref(idx), BKE_pbvh_make_eref(SCULPT_REF_NONE), idx);
|
||||
iter, BKE_pbvh_make_vref(idx), BKE_pbvh_make_eref(PBVH_REF_NONE), idx);
|
||||
}
|
||||
|
||||
if (ss->fake_neighbors.use_fake_neighbors) {
|
||||
|
@ -1759,7 +1717,7 @@ static void sculpt_vertex_neighbors_get_grids(const SculptSession *ss,
|
|||
if (ss->fake_neighbors.fake_neighbor_index[index].i != FAKE_NEIGHBOR_NONE) {
|
||||
sculpt_vertex_neighbor_add(iter,
|
||||
ss->fake_neighbors.fake_neighbor_index[index],
|
||||
BKE_pbvh_make_eref(SCULPT_REF_NONE),
|
||||
BKE_pbvh_make_eref(PBVH_REF_NONE),
|
||||
ss->fake_neighbors.fake_neighbor_index[index].i);
|
||||
}
|
||||
}
|
||||
|
@ -1847,10 +1805,10 @@ static bool neighbor_cache_begin(const SculptSession *ss)
|
|||
}
|
||||
|
||||
static NeighborCacheItem *neighbor_cache_get(const SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
const bool include_duplicates)
|
||||
{
|
||||
int i = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int i = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
NeighborCache *ncache = ss->cache->ncache;
|
||||
|
||||
|
@ -1919,7 +1877,7 @@ static NeighborCacheItem *neighbor_cache_get(const SculptSession *ss,
|
|||
#endif
|
||||
|
||||
void SCULPT_vertex_neighbors_get(const SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const bool include_duplicates,
|
||||
SculptVertexNeighborIter *iter)
|
||||
{
|
||||
|
@ -1964,7 +1922,7 @@ void SCULPT_vertex_neighbors_get(const SculptSession *ss,
|
|||
}
|
||||
|
||||
SculptBoundaryType SCULPT_edge_is_boundary(const SculptSession *ss,
|
||||
const SculptEdgeRef edge,
|
||||
const PBVHEdgeRef edge,
|
||||
SculptBoundaryType typemask)
|
||||
{
|
||||
|
||||
|
@ -2020,7 +1978,7 @@ SculptBoundaryType SCULPT_edge_is_boundary(const SculptSession *ss,
|
|||
}
|
||||
case PBVH_FACES: {
|
||||
int mask = typemask & (SCULPT_BOUNDARY_MESH | SCULPT_BOUNDARY_FACE_SET);
|
||||
SculptVertRef v1, v2;
|
||||
PBVHVertRef v1, v2;
|
||||
|
||||
SCULPT_edge_get_verts(ss, edge, &v1, &v2);
|
||||
|
||||
|
@ -2051,9 +2009,9 @@ SculptBoundaryType SCULPT_edge_is_boundary(const SculptSession *ss,
|
|||
}
|
||||
|
||||
void SCULPT_edge_get_verts(const SculptSession *ss,
|
||||
const SculptEdgeRef edge,
|
||||
SculptVertRef *r_v1,
|
||||
SculptVertRef *r_v2)
|
||||
const PBVHEdgeRef edge,
|
||||
PBVHVertRef *r_v1,
|
||||
PBVHVertRef *r_v2)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
|
@ -2070,16 +2028,16 @@ void SCULPT_edge_get_verts(const SculptSession *ss,
|
|||
}
|
||||
case PBVH_GRIDS:
|
||||
// not supported yet
|
||||
r_v1->i = r_v2->i = SCULPT_REF_NONE;
|
||||
r_v1->i = r_v2->i = PBVH_REF_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SculptVertRef SCULPT_edge_other_vertex(const SculptSession *ss,
|
||||
const SculptEdgeRef edge,
|
||||
const SculptVertRef vertex)
|
||||
PBVHVertRef SCULPT_edge_other_vertex(const SculptSession *ss,
|
||||
const PBVHEdgeRef edge,
|
||||
const PBVHVertRef vertex)
|
||||
{
|
||||
SculptVertRef v1, v2;
|
||||
PBVHVertRef v1, v2;
|
||||
|
||||
SCULPT_edge_get_verts(ss, edge, &v1, &v2);
|
||||
|
||||
|
@ -2087,14 +2045,13 @@ SculptVertRef SCULPT_edge_other_vertex(const SculptSession *ss,
|
|||
}
|
||||
|
||||
static bool sculpt_check_boundary_vertex_in_base_mesh(const SculptSession *ss,
|
||||
const SculptVertRef index)
|
||||
const PBVHVertRef index)
|
||||
{
|
||||
BLI_assert(ss->vertex_info.boundary);
|
||||
return BLI_BITMAP_TEST(ss->vertex_info.boundary,
|
||||
BKE_pbvh_vertex_index_to_table(ss->pbvh, index));
|
||||
return BLI_BITMAP_TEST(ss->vertex_info.boundary, BKE_pbvh_vertex_to_index(ss->pbvh, index));
|
||||
}
|
||||
|
||||
static void grids_update_boundary_flags(const SculptSession *ss, SculptVertRef vertex)
|
||||
static void grids_update_boundary_flags(const SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
MSculptVert *mv = ss->mdyntopo_verts + vertex.i;
|
||||
|
||||
|
@ -2136,7 +2093,7 @@ static void grids_update_boundary_flags(const SculptSession *ss, SculptVertRef v
|
|||
}
|
||||
}
|
||||
|
||||
static void faces_update_boundary_flags(const SculptSession *ss, const SculptVertRef vertex)
|
||||
static void faces_update_boundary_flags(const SculptSession *ss, const PBVHVertRef vertex)
|
||||
{
|
||||
BKE_pbvh_update_vert_boundary_faces(ss->face_sets,
|
||||
ss->mvert,
|
||||
|
@ -2173,7 +2130,7 @@ static void faces_update_boundary_flags(const SculptSession *ss, const SculptVer
|
|||
}
|
||||
}
|
||||
SculptCornerType SCULPT_vertex_is_corner(const SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
SculptCornerType cornertype)
|
||||
{
|
||||
SculptCornerType ret = 0;
|
||||
|
@ -2238,7 +2195,7 @@ SculptCornerType SCULPT_vertex_is_corner(const SculptSession *ss,
|
|||
}
|
||||
|
||||
SculptBoundaryType SCULPT_vertex_is_boundary(const SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
SculptBoundaryType boundary_types)
|
||||
{
|
||||
MSculptVert *mv = NULL;
|
||||
|
@ -2317,7 +2274,6 @@ SculptBoundaryType SCULPT_vertex_is_boundary(const SculptSession *ss,
|
|||
}
|
||||
|
||||
return flag;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Utilities */
|
||||
|
@ -2367,7 +2323,7 @@ bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3],
|
|||
|
||||
typedef struct NearestVertexTLSData {
|
||||
int nearest_vertex_index;
|
||||
SculptVertRef nearest_vertex;
|
||||
PBVHVertRef nearest_vertex;
|
||||
float nearest_vertex_distance_squared;
|
||||
} NearestVertexTLSData;
|
||||
|
||||
|
@ -2410,7 +2366,7 @@ static void nearest_vertex_get_reduce(const void *__restrict UNUSED(userdata),
|
|||
}
|
||||
}
|
||||
|
||||
SculptVertRef SCULPT_nearest_vertex_get(
|
||||
PBVHVertRef SCULPT_nearest_vertex_get(
|
||||
Sculpt *sd, Object *ob, const float co[3], float max_distance, bool use_original)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -2504,28 +2460,28 @@ void SCULPT_floodfill_init(SculptSession *ss, SculptFloodFill *flood)
|
|||
int vertex_count = SCULPT_vertex_count_get(ss);
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
|
||||
flood->queue = BLI_gsqueue_new(sizeof(SculptVertRef));
|
||||
flood->queue = BLI_gsqueue_new(sizeof(PBVHVertRef));
|
||||
flood->visited_vertices = BLI_BITMAP_NEW(vertex_count, "visited vertices");
|
||||
}
|
||||
|
||||
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, SculptVertRef vertex)
|
||||
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, PBVHVertRef vertex)
|
||||
{
|
||||
BLI_gsqueue_push(flood->queue, &vertex);
|
||||
}
|
||||
|
||||
void SCULPT_floodfill_add_and_skip_initial(SculptSession *ss,
|
||||
SculptFloodFill *flood,
|
||||
SculptVertRef vertex)
|
||||
PBVHVertRef vertex)
|
||||
{
|
||||
BLI_gsqueue_push(flood->queue, &vertex);
|
||||
BLI_BITMAP_ENABLE(flood->visited_vertices, BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex));
|
||||
BLI_BITMAP_ENABLE(flood->visited_vertices, BKE_pbvh_vertex_to_index(ss->pbvh, vertex));
|
||||
}
|
||||
|
||||
void SCULPT_floodfill_add_initial_with_symmetry(Sculpt *sd,
|
||||
Object *ob,
|
||||
SculptSession *ss,
|
||||
SculptFloodFill *flood,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float radius)
|
||||
{
|
||||
/* Add active vertex and symmetric vertices to the queue. */
|
||||
|
@ -2534,7 +2490,7 @@ void SCULPT_floodfill_add_initial_with_symmetry(Sculpt *sd,
|
|||
if (!SCULPT_is_symmetry_iteration_valid(i, symm)) {
|
||||
continue;
|
||||
}
|
||||
SculptVertRef v = {-1};
|
||||
PBVHVertRef v = {-1};
|
||||
if (i == 0) {
|
||||
v = vertex;
|
||||
}
|
||||
|
@ -2561,7 +2517,7 @@ void SCULPT_floodfill_add_active(
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef v = {-1};
|
||||
PBVHVertRef v = {-1};
|
||||
|
||||
if (i == 0) {
|
||||
v = SCULPT_active_vertex_get(ss);
|
||||
|
@ -2581,20 +2537,20 @@ void SCULPT_floodfill_add_active(
|
|||
void SCULPT_floodfill_execute(SculptSession *ss,
|
||||
SculptFloodFill *flood,
|
||||
bool (*func)(SculptSession *ss,
|
||||
SculptVertRef from_v,
|
||||
SculptVertRef to_v,
|
||||
PBVHVertRef from_v,
|
||||
PBVHVertRef to_v,
|
||||
bool is_duplicate,
|
||||
void *userdata),
|
||||
void *userdata)
|
||||
{
|
||||
while (!BLI_gsqueue_is_empty(flood->queue)) {
|
||||
SculptVertRef from_v;
|
||||
PBVHVertRef from_v;
|
||||
BLI_gsqueue_pop(flood->queue, &from_v);
|
||||
SculptVertexNeighborIter ni;
|
||||
SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, from_v, ni) {
|
||||
const SculptVertRef to_v = ni.vertex;
|
||||
const PBVHVertRef to_v = ni.vertex;
|
||||
|
||||
const int to_index = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v);
|
||||
const int to_index = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
|
||||
if (BLI_BITMAP_TEST(flood->visited_vertices, to_index)) {
|
||||
continue;
|
||||
|
@ -2760,7 +2716,7 @@ void SCULPT_orig_vert_data_init(SculptOrigVertData *data,
|
|||
data->datatype = type;
|
||||
}
|
||||
|
||||
bool SCULPT_vertex_check_origdata(SculptSession *ss, SculptVertRef vertex)
|
||||
bool SCULPT_vertex_check_origdata(SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
return BKE_pbvh_get_origvert(ss->pbvh, vertex, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -2768,7 +2724,7 @@ bool SCULPT_vertex_check_origdata(SculptSession *ss, SculptVertRef vertex)
|
|||
/**
|
||||
* DEPRECATED use Update a #SculptOrigVertData for a particular vertex from the PBVH iterator.
|
||||
*/
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, SculptVertRef vertex)
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertRef vertex)
|
||||
{
|
||||
// check if we need to update original data for current stroke
|
||||
MSculptVert *mv = SCULPT_vertex_get_sculptvert(orig_data->ss, vertex);
|
||||
|
@ -3509,11 +3465,11 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
|
|||
|
||||
for (int i = 0; i < tribuf->tottri; i++) {
|
||||
PBVHTri *tri = tribuf->tris + i;
|
||||
SculptVertRef v1 = tribuf->verts[tri->v[0]];
|
||||
SculptVertRef v2 = tribuf->verts[tri->v[1]];
|
||||
SculptVertRef v3 = tribuf->verts[tri->v[2]];
|
||||
PBVHVertRef v1 = tribuf->verts[tri->v[0]];
|
||||
PBVHVertRef v2 = tribuf->verts[tri->v[1]];
|
||||
PBVHVertRef v3 = tribuf->verts[tri->v[2]];
|
||||
|
||||
const float(*co_tri[3]) = {
|
||||
const float *co_tri[3] = {
|
||||
SCULPT_vertex_origco_get(ss, v1),
|
||||
SCULPT_vertex_origco_get(ss, v2),
|
||||
SCULPT_vertex_origco_get(ss, v3),
|
||||
|
@ -4197,7 +4153,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
|
|||
const float vno[3],
|
||||
const float fno[3],
|
||||
const float mask,
|
||||
const SculptVertRef vertex_index,
|
||||
const PBVHVertRef vertex_index,
|
||||
const int thread_id)
|
||||
{
|
||||
StrokeCache *cache = ss->cache;
|
||||
|
@ -4725,10 +4681,10 @@ typedef struct {
|
|||
* nodes. */
|
||||
bool use_back_depth;
|
||||
|
||||
SculptVertRef active_vertex_index;
|
||||
PBVHVertRef active_vertex_index;
|
||||
float *face_normal;
|
||||
|
||||
SculptFaceRef active_face_grid_index;
|
||||
PBVHFaceRef active_face_grid_index;
|
||||
|
||||
struct IsectRayPrecalc isect_precalc;
|
||||
} SculptRaycastData;
|
||||
|
@ -5054,7 +5010,7 @@ typedef struct DynTopoAutomaskState {
|
|||
bool free_automasking;
|
||||
} DynTopoAutomaskState;
|
||||
|
||||
static float sculpt_topology_automasking_cb(SculptVertRef vertex, void *vdata)
|
||||
static float sculpt_topology_automasking_cb(PBVHVertRef vertex, void *vdata)
|
||||
{
|
||||
DynTopoAutomaskState *state = (DynTopoAutomaskState *)vdata;
|
||||
float mask = SCULPT_automasking_factor_get(state->cache, state->ss, vertex);
|
||||
|
@ -5063,7 +5019,7 @@ static float sculpt_topology_automasking_cb(SculptVertRef vertex, void *vdata)
|
|||
return mask * mask2;
|
||||
}
|
||||
|
||||
static float sculpt_topology_automasking_mask_cb(SculptVertRef vertex, void *vdata)
|
||||
static float sculpt_topology_automasking_mask_cb(PBVHVertRef vertex, void *vdata)
|
||||
{
|
||||
DynTopoAutomaskState *state = (DynTopoAutomaskState *)vdata;
|
||||
return 1.0f - SCULPT_vertex_mask_get(state->ss, vertex);
|
||||
|
@ -5197,11 +5153,11 @@ static void sculpt_topology_update(Sculpt *sd,
|
|||
|
||||
int actv = -1, actf = -1;
|
||||
|
||||
if (ss->active_vertex_index.i != SCULPT_REF_NONE) {
|
||||
if (ss->active_vertex_index.i != PBVH_REF_NONE) {
|
||||
actv = BM_ELEM_GET_ID(ss->bm, (BMElem *)ss->active_vertex_index.i);
|
||||
}
|
||||
|
||||
if (ss->active_face_index.i != SCULPT_REF_NONE) {
|
||||
if (ss->active_face_index.i != PBVH_REF_NONE) {
|
||||
actf = BM_ELEM_GET_ID(ss->bm, (BMElem *)ss->active_face_index.i);
|
||||
}
|
||||
|
||||
|
@ -5232,7 +5188,7 @@ static void sculpt_topology_update(Sculpt *sd,
|
|||
ss->active_vertex_index.i = (intptr_t)v;
|
||||
}
|
||||
else {
|
||||
ss->active_vertex_index.i = SCULPT_REF_NONE;
|
||||
ss->active_vertex_index.i = PBVH_REF_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5243,7 +5199,7 @@ static void sculpt_topology_update(Sculpt *sd,
|
|||
ss->active_face_index.i = (intptr_t)f;
|
||||
}
|
||||
else {
|
||||
ss->active_face_index.i = SCULPT_REF_NONE;
|
||||
ss->active_face_index.i = PBVH_REF_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5880,7 +5836,7 @@ static void SCULPT_run_commandlist(Sculpt *sd,
|
|||
SCULPT_face_ensure_original(ss, ob);
|
||||
|
||||
for (int i = 0; i < ss->totfaces; i++) {
|
||||
SculptFaceRef face = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef face = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
SCULPT_face_check_origdata(ss, face);
|
||||
}
|
||||
}
|
||||
|
@ -6353,8 +6309,8 @@ static void do_tiled(Sculpt *sd,
|
|||
|
||||
for (int dim = 0; dim < 3; dim++) {
|
||||
if ((sd->paint.symmetry_flags & (PAINT_TILE_X << dim)) && step[dim] > 0) {
|
||||
start[dim] = (bbMin[dim] - orgLoc[dim] - radius) / step[dim];
|
||||
end[dim] = (bbMax[dim] - orgLoc[dim] + radius) / step[dim];
|
||||
start[dim] = (int)((bbMin[dim] - orgLoc[dim] - radius) / step[dim]);
|
||||
end[dim] = (int)((bbMax[dim] - orgLoc[dim] + radius) / step[dim]);
|
||||
}
|
||||
else {
|
||||
start[dim] = end[dim] = 0;
|
||||
|
@ -7135,7 +7091,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
|
|||
normalize_v3(tmp2);
|
||||
|
||||
bool bad = len_v3v3(grab_location, cache->old_grab_location) < 0.0001f;
|
||||
bad = bad || saacos(dot_v3v3(tmp1, tmp2) > 0.35f);
|
||||
bad = bad || saacos(dot_v3v3(tmp1, tmp2)) > 0.35f;
|
||||
|
||||
float t = bad ? 0.1f : 0.5f;
|
||||
|
||||
|
@ -7186,7 +7142,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
|
|||
|
||||
ups->draw_anchored = true;
|
||||
copy_v2_v2(ups->anchored_initial_mouse, cache->initial_mouse);
|
||||
ups->anchored_size = ups->pixel_radius;
|
||||
ups->anchored_size = (int)ups->pixel_radius;
|
||||
}
|
||||
|
||||
/* Handle 'rake' */
|
||||
|
@ -7529,7 +7485,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
|
|||
ups->draw_anchored = true;
|
||||
copy_v2_v2(ups->anchored_initial_mouse, cache->initial_mouse);
|
||||
copy_v3_v3(cache->anchored_location, cache->true_location);
|
||||
ups->anchored_size = ups->pixel_radius;
|
||||
ups->anchored_size = (int)ups->pixel_radius;
|
||||
}
|
||||
|
||||
cache->special_rotation = ups->brush_rotation;
|
||||
|
@ -8038,7 +7994,7 @@ static void sculpt_restore_mesh(Scene *scene, Sculpt *sd, Object *ob)
|
|||
SCULPT_face_random_access_ensure(ss);
|
||||
|
||||
for (int i = 0; i < ss->totfaces; i++) {
|
||||
SculptFaceRef face = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef face = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
int origf = SCULPT_face_set_original_get(ss, face);
|
||||
|
||||
SCULPT_face_set_set(ss, face, origf);
|
||||
|
@ -8898,24 +8854,24 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
|
|||
const int max_preview_vertices = SCULPT_vertex_count_get(ss) * 3 * 2;
|
||||
|
||||
if (ss->preview_vert_index_list == NULL) {
|
||||
ss->preview_vert_index_list = MEM_callocN(max_preview_vertices * sizeof(SculptVertRef),
|
||||
ss->preview_vert_index_list = MEM_callocN(max_preview_vertices * sizeof(PBVHVertRef),
|
||||
"preview lines");
|
||||
}
|
||||
|
||||
GSQueue *not_visited_vertices = BLI_gsqueue_new(sizeof(SculptVertRef));
|
||||
SculptVertRef active_v = SCULPT_active_vertex_get(ss);
|
||||
GSQueue *not_visited_vertices = BLI_gsqueue_new(sizeof(PBVHVertRef));
|
||||
PBVHVertRef active_v = SCULPT_active_vertex_get(ss);
|
||||
BLI_gsqueue_push(not_visited_vertices, &active_v);
|
||||
|
||||
while (!BLI_gsqueue_is_empty(not_visited_vertices)) {
|
||||
SculptVertRef from_v;
|
||||
PBVHVertRef from_v;
|
||||
|
||||
BLI_gsqueue_pop(not_visited_vertices, &from_v);
|
||||
|
||||
SculptVertexNeighborIter ni;
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, from_v, ni) {
|
||||
if (totpoints + (ni.size * 2) < max_preview_vertices) {
|
||||
SculptVertRef to_v = ni.vertex;
|
||||
int to_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v);
|
||||
PBVHVertRef to_v = ni.vertex;
|
||||
int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
|
||||
ss->preview_vert_index_list[totpoints] = from_v;
|
||||
totpoints++;
|
||||
|
@ -8972,7 +8928,7 @@ enum {
|
|||
SCULPT_TOPOLOGY_ID_DEFAULT,
|
||||
};
|
||||
|
||||
static int SCULPT_vertex_get_connected_component(SculptSession *ss, SculptVertRef vertex)
|
||||
static int SCULPT_vertex_get_connected_component(SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
|
||||
vertex.i = BM_elem_index_get((BMVert *)vertex.i);
|
||||
|
@ -8988,7 +8944,7 @@ static void SCULPT_fake_neighbor_init(SculptSession *ss, const float max_dist)
|
|||
{
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
ss->fake_neighbors.fake_neighbor_index = MEM_malloc_arrayN(
|
||||
totvert, sizeof(SculptVertRef), "fake neighbor");
|
||||
totvert, sizeof(PBVHVertRef), "fake neighbor");
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
ss->fake_neighbors.fake_neighbor_index[i].i = FAKE_NEIGHBOR_NONE;
|
||||
}
|
||||
|
@ -8997,8 +8953,8 @@ static void SCULPT_fake_neighbor_init(SculptSession *ss, const float max_dist)
|
|||
}
|
||||
|
||||
static void SCULPT_fake_neighbor_add(SculptSession *ss,
|
||||
SculptVertRef v_index_a,
|
||||
SculptVertRef v_index_b)
|
||||
PBVHVertRef v_index_a,
|
||||
PBVHVertRef v_index_b)
|
||||
{
|
||||
int tablea = (int)v_index_a.i, tableb = (int)v_index_b.i;
|
||||
|
||||
|
@ -9020,7 +8976,7 @@ static void sculpt_pose_fake_neighbors_free(SculptSession *ss)
|
|||
|
||||
typedef struct NearestVertexFakeNeighborTLSData {
|
||||
int nearest_vertex_index;
|
||||
SculptVertRef nearest_vertex;
|
||||
PBVHVertRef nearest_vertex;
|
||||
float nearest_vertex_distance_squared;
|
||||
int current_topology_id;
|
||||
} NearestVertexFakeNeighborTLSData;
|
||||
|
@ -9071,10 +9027,10 @@ static void fake_neighbor_search_reduce(const void *__restrict UNUSED(userdata),
|
|||
}
|
||||
}
|
||||
|
||||
static SculptVertRef SCULPT_fake_neighbor_search(Sculpt *sd,
|
||||
Object *ob,
|
||||
const SculptVertRef index,
|
||||
float max_distance)
|
||||
static PBVHVertRef SCULPT_fake_neighbor_search(Sculpt *sd,
|
||||
Object *ob,
|
||||
const PBVHVertRef index,
|
||||
float max_distance)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
PBVHNode **nodes = NULL;
|
||||
|
@ -9124,16 +9080,14 @@ typedef struct SculptTopologyIDFloodFillData {
|
|||
} SculptTopologyIDFloodFillData;
|
||||
|
||||
static bool SCULPT_connected_components_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef from_v,
|
||||
SculptVertRef to_v,
|
||||
PBVHVertRef from_v,
|
||||
PBVHVertRef to_v,
|
||||
bool UNUSED(is_duplicate),
|
||||
void *userdata)
|
||||
{
|
||||
SculptTopologyIDFloodFillData *data = userdata;
|
||||
ss->vertex_info.connected_component[BKE_pbvh_vertex_index_to_table(ss->pbvh, from_v)] =
|
||||
data->next_id;
|
||||
ss->vertex_info.connected_component[BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v)] =
|
||||
data->next_id;
|
||||
ss->vertex_info.connected_component[BKE_pbvh_vertex_to_index(ss->pbvh, from_v)] = data->next_id;
|
||||
ss->vertex_info.connected_component[BKE_pbvh_vertex_to_index(ss->pbvh, to_v)] = data->next_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -9159,7 +9113,7 @@ void SCULPT_connected_components_ensure(Object *ob)
|
|||
|
||||
int next_id = 0;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!SCULPT_vertex_visible_get(ss, vertex)) {
|
||||
continue;
|
||||
|
@ -9235,11 +9189,11 @@ void SCULPT_fake_neighbors_ensure(Sculpt *sd, Object *ob, const float max_dist)
|
|||
SCULPT_fake_neighbor_init(ss, max_dist);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
const SculptVertRef from_v = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
const PBVHVertRef from_v = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
/* This vertex does not have a fake neighbor yet, seach one for it. */
|
||||
if (ss->fake_neighbors.fake_neighbor_index[i].i == FAKE_NEIGHBOR_NONE) {
|
||||
const SculptVertRef to_v = SCULPT_fake_neighbor_search(sd, ob, from_v, max_dist);
|
||||
const PBVHVertRef to_v = SCULPT_fake_neighbor_search(sd, ob, from_v, max_dist);
|
||||
|
||||
if (to_v.i != -1) {
|
||||
/* Add the fake neighbor if available. */
|
||||
|
@ -9425,7 +9379,7 @@ static void dyntopo_detail_size_sample_from_surface(Object *ob,
|
|||
DyntopoDetailSizeEditCustomData *cd)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const SculptVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
const PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
|
||||
float len_accum = 0;
|
||||
int num_neighbors = 0;
|
||||
|
@ -9616,7 +9570,7 @@ static void SCULPT_OT_dyntopo_detail_size_edit(wmOperatorType *ot)
|
|||
|
||||
#endif
|
||||
|
||||
int SCULPT_vertex_valence_get(const struct SculptSession *ss, SculptVertRef vertex)
|
||||
int SCULPT_vertex_valence_get(const struct SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
SculptVertexNeighborIter ni;
|
||||
MSculptVert *mv = SCULPT_vertex_get_sculptvert(ss, vertex);
|
||||
|
|
|
@ -216,9 +216,9 @@ typedef struct BMesh {
|
|||
int totvert, totedge, totloop, totface;
|
||||
} BMesh;
|
||||
|
||||
typedef struct SculptVertRef {
|
||||
typedef struct PBVHVertRef {
|
||||
intptr_t i;
|
||||
} SculptVertRef;
|
||||
} PBVHVertRef;
|
||||
|
||||
typedef struct SculptBrushTest {
|
||||
int value;
|
||||
|
@ -254,7 +254,7 @@ float SCULPT_brush_strength_factor(struct SculptSession *ss,
|
|||
const short vno[3],
|
||||
const float fno[3],
|
||||
const float mask,
|
||||
const SculptVertRef vertex_index,
|
||||
const PBVHVertRef vertex_index,
|
||||
const int thread_id);
|
||||
extern PBVHNode *the_fake_node;
|
||||
# endif
|
||||
|
@ -398,7 +398,7 @@ class BMeshPBVH {
|
|||
return *this;
|
||||
}
|
||||
|
||||
SculptVertRef deprecated_vertref;
|
||||
PBVHVertRef deprecated_vertref;
|
||||
|
||||
int i;
|
||||
int index;
|
||||
|
|
|
@ -101,7 +101,7 @@ static void sculpt_array_datalayers_add(SculptArray *array, SculptSession *ss, M
|
|||
const SculptCustomLayer *scl = array->scl_inst;
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
*(int *)SCULPT_attr_vertex_data(vertex, scl) = ARRAY_INSTANCE_ORIGINAL;
|
||||
*(int *)SCULPT_attr_vertex_data(vertex, array->scl_sym) = 0;
|
||||
|
@ -220,7 +220,7 @@ static BMesh *sculpt_array_source_build(Object *ob, Brush *brush, SculptArray *a
|
|||
|
||||
SculptSession *ss = ob->sculpt;
|
||||
for (int i = 0; i < srcbm->totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
const float automask = SCULPT_automasking_factor_get(ss->cache->automasking, ss, vertex);
|
||||
const float mask = 1.0f - SCULPT_vertex_mask_get(ss, vertex);
|
||||
|
@ -330,7 +330,7 @@ static void sculpt_array_ensure_geometry_indices(Object *ob, SculptArray *array)
|
|||
array->symmetry_pass = MEM_malloc_arrayN(totvert, sizeof(int), "array symmetry pass index");
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
array->copy_index[i] = *(int *)SCULPT_attr_vertex_data(vertex, array->scl_inst);
|
||||
array->symmetry_pass[i] = *(int *)SCULPT_attr_vertex_data(vertex, array->scl_sym);
|
||||
|
@ -805,7 +805,7 @@ static void sculpt_array_ensure_original_coordinates(Object *ob, SculptArray *ar
|
|||
array->orco = MEM_malloc_arrayN(totvert, sizeof(float) * 3, "array orco");
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
copy_v3_v3(array->orco[i], SCULPT_vertex_co_get(ss, vertex));
|
||||
}
|
||||
|
@ -912,7 +912,7 @@ void SCULPT_do_array_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
|
|||
array->smooth_strength = MEM_calloc_arrayN(sizeof(float), totvert, "smooth_strength");
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
int array_index = ARRAY_INSTANCE_ORIGINAL;
|
||||
int array_symm_pass = 0;
|
||||
|
@ -939,7 +939,7 @@ void SCULPT_do_array_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
|
|||
|
||||
for (int smooth_iterations = 0; smooth_iterations < 4; smooth_iterations++) {
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
float avg = array->smooth_strength[i];
|
||||
int count = 1;
|
||||
|
@ -962,7 +962,7 @@ void SCULPT_do_array_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
|
|||
|
||||
/* Update Geometry Orco. */
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
int array_index = ARRAY_INSTANCE_ORIGINAL;
|
||||
int array_symm_pass = 0;
|
||||
|
|
|
@ -137,7 +137,7 @@ bool SCULPT_automasking_needs_normal(const SculptSession *ss, const Brush *brush
|
|||
|
||||
static float sculpt_automasking_normal_calc(AutomaskingCache *automasking,
|
||||
SculptSession *ss,
|
||||
SculptVertRef vert,
|
||||
PBVHVertRef vert,
|
||||
float normal[3],
|
||||
float limit,
|
||||
float falloff)
|
||||
|
@ -174,7 +174,7 @@ static float sculpt_automasking_normal_calc(AutomaskingCache *automasking,
|
|||
|
||||
float SCULPT_automasking_factor_get(AutomaskingCache *automasking,
|
||||
SculptSession *ss,
|
||||
SculptVertRef vert)
|
||||
PBVHVertRef vert)
|
||||
{
|
||||
float mask = 1.0f;
|
||||
bool do_concave;
|
||||
|
@ -291,8 +291,8 @@ struct AutomaskFloodFillData {
|
|||
};
|
||||
|
||||
static bool automask_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef from_vref,
|
||||
SculptVertRef to_vref,
|
||||
PBVHVertRef from_vref,
|
||||
PBVHVertRef to_vref,
|
||||
bool UNUSED(is_duplicate),
|
||||
void *userdata)
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ static void SCULPT_topology_automasking_init(Sculpt *sd,
|
|||
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
float *fac = (float *)SCULPT_attr_vertex_data(vertex, factorlayer);
|
||||
*fac = 0.0f;
|
||||
|
@ -371,7 +371,7 @@ static void sculpt_face_sets_automasking_init(Sculpt *sd,
|
|||
int active_face_set = SCULPT_active_face_set_get(ss);
|
||||
|
||||
for (int i : IndexRange(tot_vert)) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!SCULPT_vertex_has_face_set(ss, vertex, active_face_set)) {
|
||||
*(float *)SCULPT_attr_vertex_data(vertex, factorlayer) = 0.0f;
|
||||
|
@ -397,7 +397,7 @@ void SCULPT_boundary_automasking_init(Object *ob,
|
|||
int *edge_distance = (int *)MEM_callocN(sizeof(int) * totvert, "automask_factor");
|
||||
|
||||
for (int i : IndexRange(totvert)) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
edge_distance[i] = EDGE_DISTANCE_INF;
|
||||
|
||||
|
@ -417,7 +417,7 @@ void SCULPT_boundary_automasking_init(Object *ob,
|
|||
|
||||
for (int propagation_it : IndexRange(propagation_steps)) {
|
||||
for (int i : IndexRange(totvert)) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (edge_distance[i] != EDGE_DISTANCE_INF) {
|
||||
continue;
|
||||
|
@ -433,7 +433,7 @@ void SCULPT_boundary_automasking_init(Object *ob,
|
|||
}
|
||||
|
||||
for (int i : IndexRange(totvert)) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (edge_distance[i] == EDGE_DISTANCE_INF) {
|
||||
continue;
|
||||
|
@ -479,7 +479,7 @@ void SCULPT_automasking_step_update(AutomaskingCache *automasking,
|
|||
automasking->settings.concave_factor = SCULPT_get_float(ss, concave_mask_factor, sd, brush);
|
||||
}
|
||||
|
||||
float SCULPT_calc_concavity(SculptSession *ss, SculptVertRef vref)
|
||||
float SCULPT_calc_concavity(SculptSession *ss, PBVHVertRef vref)
|
||||
{
|
||||
SculptVertexNeighborIter ni;
|
||||
float co[3], tot = 0.0, elen = 0.0;
|
||||
|
@ -526,7 +526,7 @@ static void SCULPT_concavity_automasking_init(Object *ob,
|
|||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
float f = SCULPT_calc_concavity(ss, vref);
|
||||
f = sculpt_concavity_factor(automasking, f);
|
||||
|
||||
|
@ -573,7 +573,7 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, const Brush *brush,
|
|||
automasking->factorlayer = ss->scl.automasking_factor;
|
||||
|
||||
for (int i : IndexRange(totvert)) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
float *f = (float *)SCULPT_attr_vertex_data(vertex, automasking->factorlayer);
|
||||
|
||||
*f = 1.0f;
|
||||
|
|
|
@ -78,26 +78,26 @@ static void boundary_color_vis(SculptSession *ss, SculptBoundary *boundary);
|
|||
static void SCULPT_boundary_build_smoothco(SculptSession *ss, SculptBoundary *boundary);
|
||||
|
||||
typedef struct BoundaryInitialVertexFloodFillData {
|
||||
SculptVertRef initial_vertex;
|
||||
PBVHVertRef initial_vertex;
|
||||
int initial_vertex_index;
|
||||
int boundary_initial_vertex_steps;
|
||||
|
||||
SculptVertRef boundary_initial_vertex;
|
||||
PBVHVertRef boundary_initial_vertex;
|
||||
|
||||
int *floodfill_steps;
|
||||
float radius_sq;
|
||||
} BoundaryInitialVertexFloodFillData;
|
||||
|
||||
static bool boundary_initial_vertex_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef from_vref,
|
||||
SculptVertRef to_vref,
|
||||
PBVHVertRef from_vref,
|
||||
PBVHVertRef to_vref,
|
||||
bool is_duplicate,
|
||||
void *userdata)
|
||||
{
|
||||
BoundaryInitialVertexFloodFillData *data = userdata;
|
||||
|
||||
int to_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_vref);
|
||||
int from_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_vref);
|
||||
int to_v = BKE_pbvh_vertex_to_index(ss->pbvh, to_vref);
|
||||
int from_v = BKE_pbvh_vertex_to_index(ss->pbvh, from_vref);
|
||||
|
||||
if (!SCULPT_vertex_visible_get(ss, to_vref)) {
|
||||
return false;
|
||||
|
@ -124,11 +124,10 @@ static bool boundary_initial_vertex_floodfill_cb(SculptSession *ss,
|
|||
|
||||
/* From a vertex index anywhere in the mesh, returns the closest vertex in a mesh boundary inside
|
||||
* the given radius, if it exists. */
|
||||
static SculptVertRef sculpt_boundary_get_closest_boundary_vertex(
|
||||
SculptSession *ss,
|
||||
const SculptVertRef initial_vertex,
|
||||
const int initial_vertex_index,
|
||||
const float radius)
|
||||
static PBVHVertRef sculpt_boundary_get_closest_boundary_vertex(SculptSession *ss,
|
||||
const PBVHVertRef initial_vertex,
|
||||
const int initial_vertex_index,
|
||||
const float radius)
|
||||
{
|
||||
if (SCULPT_vertex_is_boundary(ss, initial_vertex, SCULPT_BOUNDARY_MESH)) {
|
||||
return initial_vertex;
|
||||
|
@ -163,17 +162,16 @@ static int BOUNDARY_INDICES_BLOCK_SIZE = 300;
|
|||
|
||||
static void sculpt_boundary_index_add(SculptSession *ss,
|
||||
SculptBoundary *boundary,
|
||||
const SculptVertRef new_index,
|
||||
const PBVHVertRef new_index,
|
||||
const float distance,
|
||||
GSet *included_vertices)
|
||||
{
|
||||
|
||||
boundary->vertices[boundary->num_vertices] = new_index;
|
||||
boundary->vertex_indices[boundary->num_vertices] = BKE_pbvh_vertex_index_to_table(ss->pbvh,
|
||||
new_index);
|
||||
boundary->vertex_indices[boundary->num_vertices] = BKE_pbvh_vertex_to_index(ss->pbvh, new_index);
|
||||
|
||||
if (boundary->distance) {
|
||||
boundary->distance[BKE_pbvh_vertex_index_to_table(ss->pbvh, new_index)] = distance;
|
||||
boundary->distance[BKE_pbvh_vertex_to_index(ss->pbvh, new_index)] = distance;
|
||||
}
|
||||
if (included_vertices) {
|
||||
BLI_gset_add(included_vertices, POINTER_FROM_INT(new_index.i));
|
||||
|
@ -182,8 +180,7 @@ static void sculpt_boundary_index_add(SculptSession *ss,
|
|||
if (boundary->num_vertices >= boundary->vertices_capacity) {
|
||||
boundary->vertices_capacity += BOUNDARY_INDICES_BLOCK_SIZE;
|
||||
boundary->vertices = MEM_reallocN_id(boundary->vertices,
|
||||
boundary->vertices_capacity * sizeof(SculptVertRef) *
|
||||
TSTN,
|
||||
boundary->vertices_capacity * sizeof(PBVHVertRef) * TSTN,
|
||||
"boundary vertrefs");
|
||||
boundary->vertex_indices = MEM_reallocN_id(boundary->vertex_indices,
|
||||
boundary->vertices_capacity * sizeof(int) * TSTN,
|
||||
|
@ -192,8 +189,8 @@ static void sculpt_boundary_index_add(SculptSession *ss,
|
|||
};
|
||||
|
||||
static void sculpt_boundary_preview_edge_add(SculptBoundary *boundary,
|
||||
const SculptVertRef v1,
|
||||
const SculptVertRef v2)
|
||||
const PBVHVertRef v1,
|
||||
const PBVHVertRef v2)
|
||||
{
|
||||
|
||||
boundary->edges[boundary->num_edges].v1 = v1;
|
||||
|
@ -214,7 +211,7 @@ static void sculpt_boundary_preview_edge_add(SculptBoundary *boundary,
|
|||
* as well as to check if the initial vertex is valid.
|
||||
*/
|
||||
static bool sculpt_boundary_is_vertex_in_editable_boundary(SculptSession *ss,
|
||||
const SculptVertRef initial_vertex)
|
||||
const PBVHVertRef initial_vertex)
|
||||
{
|
||||
|
||||
if (!SCULPT_vertex_visible_get(ss, initial_vertex)) {
|
||||
|
@ -257,16 +254,16 @@ typedef struct BoundaryFloodFillData {
|
|||
GSet *included_vertices;
|
||||
EdgeSet *preview_edges;
|
||||
|
||||
SculptVertRef last_visited_vertex;
|
||||
PBVHVertRef last_visited_vertex;
|
||||
|
||||
} BoundaryFloodFillData;
|
||||
|
||||
static bool boundary_floodfill_cb(
|
||||
SculptSession *ss, SculptVertRef from_v, SculptVertRef to_v, bool is_duplicate, void *userdata)
|
||||
SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool is_duplicate, void *userdata)
|
||||
{
|
||||
BoundaryFloodFillData *data = userdata;
|
||||
SculptBoundary *boundary = data->boundary;
|
||||
int from_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_v);
|
||||
int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
|
||||
|
||||
if (!SCULPT_vertex_is_boundary(ss, to_v, SCULPT_BOUNDARY_MESH)) {
|
||||
return false;
|
||||
|
@ -299,7 +296,7 @@ static float *calc_boundary_tangent(SculptSession *ss, SculptBoundary *boundary)
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
const float *co1 = SCULPT_vertex_co_get(ss, vertex);
|
||||
|
||||
zero_v3(dir);
|
||||
|
@ -371,7 +368,7 @@ static float *calc_boundary_tangent(SculptSession *ss, SculptBoundary *boundary)
|
|||
|
||||
SCULPT_vertex_normal_get(ss, ni.vertex, no2);
|
||||
|
||||
// int i2 = BKE_pbvh_vertex_index_to_table(ss->pbvh, ni.vertex);
|
||||
// int i2 = BKE_pbvh_vertex_to_index(ss->pbvh, ni.vertex);
|
||||
int i2 = ni.index;
|
||||
|
||||
float f2 = boundary->boundary_dist[i2];
|
||||
|
@ -419,7 +416,7 @@ static void sculpt_boundary_cotan_init(SculptSession *ss, SculptBoundary *bounda
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
const int val = SCULPT_vertex_valence_get(ss, vertex);
|
||||
|
||||
cotw->length = val;
|
||||
|
@ -439,13 +436,13 @@ static void sculpt_boundary_indices_init(Object *ob,
|
|||
SculptSession *ss,
|
||||
SculptBoundary *boundary,
|
||||
const bool init_boundary_distances,
|
||||
const SculptVertRef initial_boundary_index,
|
||||
const PBVHVertRef initial_boundary_index,
|
||||
const float radius)
|
||||
{
|
||||
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
boundary->vertices = MEM_malloc_arrayN(
|
||||
BOUNDARY_INDICES_BLOCK_SIZE, sizeof(SculptVertRef) * TSTN, "boundary vrefs");
|
||||
BOUNDARY_INDICES_BLOCK_SIZE, sizeof(PBVHVertRef) * TSTN, "boundary vrefs");
|
||||
boundary->vertex_indices = MEM_malloc_arrayN(
|
||||
BOUNDARY_INDICES_BLOCK_SIZE, sizeof(int) * TSTN, "boundary indices");
|
||||
|
||||
|
@ -493,8 +490,7 @@ static void sculpt_boundary_indices_init(Object *ob,
|
|||
boundary_verts = included_vertices;
|
||||
}
|
||||
|
||||
boundary->boundary_closest = MEM_calloc_arrayN(
|
||||
totvert, sizeof(SculptVertRef), "boundary_closest");
|
||||
boundary->boundary_closest = MEM_calloc_arrayN(totvert, sizeof(PBVHVertRef), "boundary_closest");
|
||||
boundary->boundary_dist = SCULPT_geodesic_distances_create(
|
||||
ob, boundary_verts, radius, boundary->boundary_closest, NULL);
|
||||
|
||||
|
@ -510,7 +506,7 @@ static void sculpt_boundary_indices_init(Object *ob,
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
float tot = 0.0f;
|
||||
|
||||
StoredCotangentW *cotw = boundary->boundary_cotangents + i;
|
||||
|
@ -560,7 +556,7 @@ static void sculpt_boundary_indices_init(Object *ob,
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
float tot = 0.0f;
|
||||
|
||||
// StoredCotangentW *cotw = boundary->boundary_cotangents + i;
|
||||
|
@ -677,7 +673,7 @@ static void boundary_color_vis(SculptSession *ss, SculptBoundary *boundary)
|
|||
*/
|
||||
static void sculpt_boundary_edit_data_init(SculptSession *ss,
|
||||
SculptBoundary *boundary,
|
||||
const SculptVertRef initial_vertex,
|
||||
const PBVHVertRef initial_vertex,
|
||||
const float radius)
|
||||
{
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
@ -693,8 +689,8 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
|
|||
boundary->edit_info[i].num_propagation_steps = BOUNDARY_STEPS_NONE;
|
||||
}
|
||||
|
||||
GSQueue *current_iteration = BLI_gsqueue_new(sizeof(SculptVertRef));
|
||||
GSQueue *next_iteration = BLI_gsqueue_new(sizeof(SculptVertRef));
|
||||
GSQueue *current_iteration = BLI_gsqueue_new(sizeof(PBVHVertRef));
|
||||
GSQueue *next_iteration = BLI_gsqueue_new(sizeof(PBVHVertRef));
|
||||
|
||||
/* Initialized the first iteration with the vertices already in the boundary. This is propagation
|
||||
* step 0. */
|
||||
|
@ -735,9 +731,9 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
|
|||
}
|
||||
|
||||
while (!BLI_gsqueue_is_empty(current_iteration)) {
|
||||
SculptVertRef from_v;
|
||||
PBVHVertRef from_v;
|
||||
BLI_gsqueue_pop(current_iteration, &from_v);
|
||||
const int from_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_v);
|
||||
const int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
|
||||
|
||||
SculptVertexNeighborIter ni;
|
||||
SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, from_v, ni) {
|
||||
|
@ -800,7 +796,7 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
|
|||
|
||||
/* Copy the new vertices to the queue to be processed in the next iteration. */
|
||||
while (!BLI_gsqueue_is_empty(next_iteration)) {
|
||||
SculptVertRef next_v;
|
||||
PBVHVertRef next_v;
|
||||
BLI_gsqueue_pop(next_iteration, &next_v);
|
||||
BLI_gsqueue_push(current_iteration, &next_v);
|
||||
}
|
||||
|
@ -843,7 +839,7 @@ static void sculpt_boundary_falloff_factor_init(
|
|||
continue;
|
||||
}
|
||||
|
||||
const float boundary_distance = boundary->distance[BKE_pbvh_vertex_index_to_table(
|
||||
const float boundary_distance = boundary->distance[BKE_pbvh_vertex_to_index(
|
||||
ss->pbvh, boundary->edit_info[i].original_vertex)];
|
||||
float falloff_distance = 0.0f;
|
||||
float direction = 1.0f;
|
||||
|
@ -878,11 +874,8 @@ static void sculpt_boundary_falloff_factor_init(
|
|||
|
||||
/* Main function to get SculptBoundary data both for brush deformation and viewport preview. Can
|
||||
* return NULL if there is no boundary from the given vertex using the given radius. */
|
||||
SculptBoundary *SCULPT_boundary_data_init(Sculpt *sd,
|
||||
Object *object,
|
||||
Brush *brush,
|
||||
const SculptVertRef initial_vertex,
|
||||
const float radius)
|
||||
SculptBoundary *SCULPT_boundary_data_init(
|
||||
Sculpt *sd, Object *object, Brush *brush, const PBVHVertRef initial_vertex, const float radius)
|
||||
{
|
||||
SculptSession *ss = object->sculpt;
|
||||
|
||||
|
@ -898,8 +891,8 @@ SculptBoundary *SCULPT_boundary_data_init(Sculpt *sd,
|
|||
SCULPT_vertex_random_access_ensure(ss);
|
||||
SCULPT_boundary_info_ensure(object);
|
||||
|
||||
const SculptVertRef boundary_initial_vertex = sculpt_boundary_get_closest_boundary_vertex(
|
||||
ss, initial_vertex, BKE_pbvh_vertex_index_to_table(ss->pbvh, initial_vertex), radius);
|
||||
const PBVHVertRef boundary_initial_vertex = sculpt_boundary_get_closest_boundary_vertex(
|
||||
ss, initial_vertex, BKE_pbvh_vertex_to_index(ss->pbvh, initial_vertex), radius);
|
||||
|
||||
if (boundary_initial_vertex.i == BOUNDARY_VERTEX_NONE) {
|
||||
return NULL;
|
||||
|
@ -970,11 +963,11 @@ void SCULPT_boundary_data_free(SculptBoundary *boundary)
|
|||
}
|
||||
|
||||
typedef struct ScalarFieldWalkData {
|
||||
SculptVertRef v;
|
||||
PBVHVertRef v;
|
||||
float co[3];
|
||||
|
||||
struct {
|
||||
SculptVertRef v1, v2;
|
||||
PBVHVertRef v1, v2;
|
||||
} edge;
|
||||
|
||||
float t, f;
|
||||
|
@ -982,7 +975,7 @@ typedef struct ScalarFieldWalkData {
|
|||
} ScalarFieldWalkData;
|
||||
|
||||
static void sculpt_walk_scalar_field_init(SculptSession *ss,
|
||||
SculptVertRef v,
|
||||
PBVHVertRef v,
|
||||
ScalarFieldWalkData *wd,
|
||||
float *field)
|
||||
{
|
||||
|
@ -991,7 +984,7 @@ static void sculpt_walk_scalar_field_init(SculptSession *ss,
|
|||
wd->has_edge = false;
|
||||
wd->t = 0.0f;
|
||||
|
||||
int i = BKE_pbvh_vertex_index_to_table(ss->pbvh, v);
|
||||
int i = BKE_pbvh_vertex_to_index(ss->pbvh, v);
|
||||
wd->f = field[i];
|
||||
}
|
||||
|
||||
|
@ -1003,7 +996,7 @@ static bool sculpt_walk_scalar_field(SculptSession *ss,
|
|||
{
|
||||
SculptVertexNeighborIter ni;
|
||||
SculptVertexNeighborIter ni2;
|
||||
SculptVertRef v = wd->v, minv1 = {-1LL}, minv2 = {-1LL};
|
||||
PBVHVertRef v = wd->v, minv1 = {-1LL}, minv2 = {-1LL};
|
||||
float mindis1 = FLT_MAX, mindis2 = FLT_MAX;
|
||||
float minf1 = 0.0, minf2 = 0.0;
|
||||
float minl1 = 0.0, minl2 = 0.0;
|
||||
|
@ -1300,7 +1293,7 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss,
|
|||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
#ifdef VISBM
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (boundary->boundary_dist[i] != FLT_MAX) {
|
||||
const float *co1 = SCULPT_vertex_co_get(ss, vertex);
|
||||
|
@ -1318,9 +1311,9 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss,
|
|||
#endif
|
||||
|
||||
if (boundary->boundary_closest[i].i != -1LL) {
|
||||
SculptVertRef v = boundary->boundary_closest[i];
|
||||
PBVHVertRef v = boundary->boundary_closest[i];
|
||||
boundary->edit_info[i].original_vertex = v;
|
||||
boundary->edit_info[i].original_vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, v);
|
||||
boundary->edit_info[i].original_vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, v);
|
||||
}
|
||||
|
||||
if (boundary->edit_info[i].num_propagation_steps != boundary->max_propagation_steps) {
|
||||
|
@ -1329,7 +1322,7 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss,
|
|||
}
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (boundary->edit_info[i].original_vertex_i == BOUNDARY_VERTEX_NONE) {
|
||||
continue;
|
||||
|
@ -1386,9 +1379,9 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss,
|
|||
|
||||
// fix any remaining boundaries without pivots
|
||||
for (int vi = 0; vi < boundary->num_vertices; vi++) {
|
||||
SculptVertRef v = boundary->vertices[vi];
|
||||
PBVHVertRef v = boundary->vertices[vi];
|
||||
const float *co1 = SCULPT_vertex_co_get(ss, v);
|
||||
int i = BKE_pbvh_vertex_index_to_table(ss->pbvh, v);
|
||||
int i = BKE_pbvh_vertex_to_index(ss->pbvh, v);
|
||||
|
||||
if (boundary->bend.pivot_positions[i][3] != 0.0f) {
|
||||
continue;
|
||||
|
@ -1402,7 +1395,7 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss,
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef v2 = BKE_pbvh_table_index_to_vertex(ss->pbvh, j);
|
||||
PBVHVertRef v2 = BKE_pbvh_index_to_vertex(ss->pbvh, j);
|
||||
const float *co2 = SCULPT_vertex_co_get(ss, v2);
|
||||
|
||||
float len = len_v3v3(co2, co1);
|
||||
|
@ -1416,7 +1409,7 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss,
|
|||
}
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
const float *co1 = SCULPT_vertex_co_get(ss, vertex);
|
||||
float dir[3];
|
||||
|
||||
|
@ -1490,7 +1483,7 @@ static void sculpt_boundary_slide_data_init(SculptSession *ss, SculptBoundary *b
|
|||
totvert, 3 * sizeof(float) * TSTN, "slide directions");
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (boundary->edit_info[i].num_propagation_steps != boundary->max_propagation_steps) {
|
||||
continue;
|
||||
|
@ -1550,7 +1543,7 @@ static void sculpt_boundary_circle_data_init(SculptSession *ss, SculptBoundary *
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
add_v3_v3(boundary->circle.origin[propagation_step_index], SCULPT_vertex_co_get(ss, vertex));
|
||||
count[propagation_step_index]++;
|
||||
|
@ -1566,7 +1559,7 @@ static void sculpt_boundary_circle_data_init(SculptSession *ss, SculptBoundary *
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
boundary->circle.radius[propagation_step_index] += len_v3v3(
|
||||
boundary->circle.origin[propagation_step_index], SCULPT_vertex_co_get(ss, vertex));
|
||||
|
@ -2092,7 +2085,7 @@ void SCULPT_do_boundary_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totn
|
|||
const int symm_area = ss->cache->mirror_symmetry_pass;
|
||||
if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) {
|
||||
|
||||
SculptVertRef initial_vertex;
|
||||
PBVHVertRef initial_vertex;
|
||||
|
||||
if (ss->cache->mirror_symmetry_pass == 0) {
|
||||
initial_vertex = SCULPT_active_vertex_get(ss);
|
||||
|
|
|
@ -2526,7 +2526,7 @@ void SCULPT_do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
|
|||
const int symm_pass = ss->cache->mirror_symmetry_pass;
|
||||
float location[3];
|
||||
flip_v3_v3(location, SCULPT_active_vertex_co_get(ss), symm_pass);
|
||||
SculptVertRef v = SCULPT_nearest_vertex_get(sd, ob, location, ss->cache->radius, false);
|
||||
PBVHVertRef v = SCULPT_nearest_vertex_get(sd, ob, location, ss->cache->radius, false);
|
||||
ss->cache->geodesic_dists[symm_pass] = SCULPT_geodesic_from_vertex(
|
||||
ob, v, ss->cache->initial_radius);
|
||||
}
|
||||
|
@ -2665,7 +2665,7 @@ void SCULPT_do_elastic_deform_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in
|
|||
const int symm_pass = ss->cache->mirror_symmetry_pass;
|
||||
float location[3];
|
||||
flip_v3_v3(location, SCULPT_active_vertex_co_get(ss), symm_pass);
|
||||
SculptVertRef v = SCULPT_nearest_vertex_get(
|
||||
PBVHVertRef v = SCULPT_nearest_vertex_get(
|
||||
sd, ob, location, ss->cache->initial_radius, false);
|
||||
ss->cache->geodesic_dists[symm_pass] = SCULPT_geodesic_from_vertex(ob, v, FLT_MAX);
|
||||
}
|
||||
|
@ -2886,7 +2886,7 @@ void SCULPT_stroke_cache_snap_context_init(bContext *C, Object *ob)
|
|||
}
|
||||
|
||||
static void sculpt_scene_project_view_ray_init(Object *ob,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float r_ray_normal[3],
|
||||
float r_ray_origin[3])
|
||||
{
|
||||
|
@ -2906,7 +2906,7 @@ static void sculpt_scene_project_view_ray_init(Object *ob,
|
|||
}
|
||||
|
||||
static void sculpt_scene_project_vertex_normal_ray_init(Object *ob,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const float original_normal[3],
|
||||
float r_ray_normal[3],
|
||||
float r_ray_origin[3])
|
||||
|
@ -2919,7 +2919,7 @@ static void sculpt_scene_project_vertex_normal_ray_init(Object *ob,
|
|||
}
|
||||
|
||||
static void sculpt_scene_project_brush_normal_ray_init(Object *ob,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float r_ray_normal[3],
|
||||
float r_ray_origin[3])
|
||||
{
|
||||
|
@ -3475,7 +3475,7 @@ void SCULPT_do_fairing_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
|
|||
|
||||
if (SCULPT_stroke_is_main_symmetry_pass(ss->cache)) {
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
*(uchar *)SCULPT_attr_vertex_data(vertex, ss->scl.fairing_mask) = false;
|
||||
*(float *)SCULPT_attr_vertex_data(vertex, ss->scl.fairing_fade) = 0.0f;
|
||||
|
@ -3833,7 +3833,7 @@ void SCULPT_do_displacement_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes
|
|||
ss->cache->limit_surface_co = MEM_malloc_arrayN(totvert, sizeof(float[3]), "limit surface co");
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
SCULPT_vertex_limit_surface_get(ss, vref, ss->cache->limit_surface_co[i]);
|
||||
sub_v3_v3v3(ss->cache->prev_displacement[i],
|
||||
|
@ -4179,9 +4179,9 @@ void SCULPT_do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
|
|||
}
|
||||
}
|
||||
|
||||
BLI_INLINE SculptVertRef grid_xy_to_vertex(int x, int y, int grid_i, int gridsize)
|
||||
BLI_INLINE PBVHVertRef grid_xy_to_vertex(int x, int y, int grid_i, int gridsize)
|
||||
{
|
||||
return (SculptVertRef){.i = grid_i * gridsize * gridsize + y * gridsize + x};
|
||||
return (PBVHVertRef){.i = grid_i * gridsize * gridsize + y * gridsize + x};
|
||||
}
|
||||
|
||||
typedef struct DisplacementHealTaskData {
|
||||
|
@ -4221,7 +4221,7 @@ static void do_displacement_heal_cb(void *__restrict userdata,
|
|||
|
||||
for (int x = 0; x < gridsize; x++) {
|
||||
for (int y = 0; y < gridsize; y++) {
|
||||
SculptVertRef vertex = grid_xy_to_vertex(x, y, grid_i, gridsize);
|
||||
PBVHVertRef vertex = grid_xy_to_vertex(x, y, grid_i, gridsize);
|
||||
|
||||
SubdivCCGCoord coord = {.grid_index = grid_i, .x = x, .y = y};
|
||||
int locali = y * gridsize + x;
|
||||
|
@ -4246,7 +4246,7 @@ static void do_displacement_heal_cb(void *__restrict userdata,
|
|||
for (int y = 0; y < gridsize; y++) {
|
||||
int locali = y * gridsize + x;
|
||||
|
||||
SculptVertRef vertex = grid_xy_to_vertex(x, y, grid_i, gridsize);
|
||||
PBVHVertRef vertex = grid_xy_to_vertex(x, y, grid_i, gridsize);
|
||||
float *disp = disps[locali];
|
||||
float avg[3] = {0.0f, 0.0f, 0.0f};
|
||||
float tot = 0.0f;
|
||||
|
|
|
@ -635,12 +635,12 @@ static void cloth_brush_add_bend_constraint(SculptSession *ss,
|
|||
SculptClothBendConstraint *bend_constraint = (SculptClothBendConstraint *)cloth_add_constraint(
|
||||
cloth_sim, CON_BEND);
|
||||
|
||||
SculptVertRef v1, v2, v3, v4;
|
||||
PBVHVertRef v1, v2, v3, v4;
|
||||
|
||||
v1 = BKE_pbvh_table_index_to_vertex(ss->pbvh, v1i);
|
||||
v2 = BKE_pbvh_table_index_to_vertex(ss->pbvh, v2i);
|
||||
v3 = BKE_pbvh_table_index_to_vertex(ss->pbvh, v3i);
|
||||
v4 = BKE_pbvh_table_index_to_vertex(ss->pbvh, v4i);
|
||||
v1 = BKE_pbvh_index_to_vertex(ss->pbvh, v1i);
|
||||
v2 = BKE_pbvh_index_to_vertex(ss->pbvh, v2i);
|
||||
v3 = BKE_pbvh_index_to_vertex(ss->pbvh, v3i);
|
||||
v4 = BKE_pbvh_index_to_vertex(ss->pbvh, v4i);
|
||||
|
||||
bend_constraint->elems[0].index = PACK_POS_TYPE(v1i, CLOTH_POS_POS);
|
||||
bend_constraint->elems[1].index = PACK_POS_TYPE(v2i, CLOTH_POS_POS);
|
||||
|
@ -692,10 +692,10 @@ static void cloth_brush_add_length_constraint(SculptSession *ss,
|
|||
const bool use_persistent)
|
||||
{
|
||||
SculptClothLengthConstraint *length_constraint = cloth_add_constraint(cloth_sim, CON_LENGTH);
|
||||
SculptVertRef v1, v2;
|
||||
PBVHVertRef v1, v2;
|
||||
|
||||
v1 = BKE_pbvh_table_index_to_vertex(ss->pbvh, v1i);
|
||||
v2 = BKE_pbvh_table_index_to_vertex(ss->pbvh, v2i);
|
||||
v1 = BKE_pbvh_index_to_vertex(ss->pbvh, v1i);
|
||||
v2 = BKE_pbvh_index_to_vertex(ss->pbvh, v2i);
|
||||
|
||||
length_constraint->elems[0].index = PACK_POS_TYPE(v1i, CLOTH_POS_POS);
|
||||
length_constraint->elems[1].index = PACK_POS_TYPE(v2i, CLOTH_POS_POS);
|
||||
|
@ -853,7 +853,7 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
|
|||
|
||||
SculptVertexNeighborIter ni;
|
||||
int build_indices[CLOTH_MAX_CONSTRAINTS_PER_VERTEX];
|
||||
SculptEdgeRef build_edges[CLOTH_MAX_CONSTRAINTS_PER_VERTEX];
|
||||
PBVHEdgeRef build_edges[CLOTH_MAX_CONSTRAINTS_PER_VERTEX];
|
||||
|
||||
int tot_indices = 0;
|
||||
bool have_edges = false;
|
||||
|
@ -869,7 +869,7 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
|
|||
build_edges[tot_indices - 1] = ni.edge;
|
||||
}
|
||||
else {
|
||||
build_edges[tot_indices - 1].i = SCULPT_REF_NONE;
|
||||
build_edges[tot_indices - 1].i = PBVH_REF_NONE;
|
||||
}
|
||||
|
||||
tot_indices++;
|
||||
|
@ -883,8 +883,8 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
|
|||
#ifdef BENDING_CONSTRAINTS
|
||||
|
||||
for (int c_i = 0; use_bending && c_i < tot_indices - 1; c_i++) {
|
||||
if (have_edges && build_edges[c_i].i && build_edges[c_i].i != SCULPT_REF_NONE) {
|
||||
SculptEdgeRef edge = build_edges[c_i];
|
||||
if (have_edges && build_edges[c_i].i && build_edges[c_i].i != PBVH_REF_NONE) {
|
||||
PBVHEdgeRef edge = build_edges[c_i];
|
||||
|
||||
if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
|
||||
BMEdge *e = (BMEdge *)edge.i;
|
||||
|
@ -1113,7 +1113,7 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
|
|||
|
||||
memset(&ni, 0, sizeof(ni));
|
||||
|
||||
SculptVertRef vertex2 = BKE_pbvh_table_index_to_vertex(ss->pbvh, v2i);
|
||||
PBVHVertRef vertex2 = BKE_pbvh_index_to_vertex(ss->pbvh, v2i);
|
||||
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.vertex, ni) {
|
||||
if (ni.vertex.i == vertex2.i) {
|
||||
|
@ -1561,7 +1561,7 @@ static void cloth_brush_solve_collision(Object *object,
|
|||
}
|
||||
static void cloth_simulation_noise_get(float *r_noise,
|
||||
SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const float strength)
|
||||
{
|
||||
const uint *hash_co = (const uint *)SCULPT_vertex_co_get(ss, vertex);
|
||||
|
@ -1741,7 +1741,7 @@ static void cloth_sort_constraints_for_tasks(SculptSession *ss,
|
|||
for (int step = 0; not_dynamic && step < totelem; step++) {
|
||||
int v = UNPACK_POS_INDEX(con->elems[step].index);
|
||||
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, v);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, v);
|
||||
SculptVertexNeighborIter ni;
|
||||
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
|
||||
|
@ -1863,7 +1863,7 @@ static void cloth_brush_satisfy_constraints_intern(SculptSession *ss,
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, vi);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, vi);
|
||||
|
||||
sim_factor *= SCULPT_automasking_factor_get(automasking, ss, vref) * 1.0f -
|
||||
SCULPT_vertex_mask_get(ss, vref);
|
||||
|
@ -1896,8 +1896,8 @@ static void cloth_brush_satisfy_constraints_intern(SculptSession *ss,
|
|||
const int v1 = UNPACK_POS_INDEX(constraint->elems[0].index);
|
||||
const int v2 = UNPACK_POS_INDEX(constraint->elems[1].index);
|
||||
|
||||
const SculptVertRef v1ref = BKE_pbvh_table_index_to_vertex(ss->pbvh, v1);
|
||||
const SculptVertRef v2ref = BKE_pbvh_table_index_to_vertex(ss->pbvh, v2);
|
||||
const PBVHVertRef v1ref = BKE_pbvh_index_to_vertex(ss->pbvh, v1);
|
||||
const PBVHVertRef v2ref = BKE_pbvh_index_to_vertex(ss->pbvh, v2);
|
||||
|
||||
float v1_to_v2[3];
|
||||
sub_v3_v3v3(v1_to_v2, pos2, pos1);
|
||||
|
@ -2227,7 +2227,7 @@ SculptClothSimulation *SCULPT_cloth_brush_simulation_create(SculptSession *ss,
|
|||
if (USE_SOLVER_RIPPLE_CONSTRAINT) {
|
||||
cloth_sim->init_normal = MEM_calloc_arrayN(totverts, sizeof(float) * 3, "init noramls");
|
||||
for (int i = 0; i < totverts; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
SCULPT_vertex_normal_get(ss, vertex, cloth_sim->init_normal[i]);
|
||||
}
|
||||
|
@ -2298,7 +2298,7 @@ void SCULPT_cloth_brush_simulation_init(SculptSession *ss, SculptClothSimulation
|
|||
SCULPT_vertex_random_access_ensure(ss);
|
||||
|
||||
for (int i = 0; i < totverts; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
copy_v3_v3(cloth_sim->last_iteration_pos[i], SCULPT_vertex_co_get(ss, vertex));
|
||||
copy_v3_v3(cloth_sim->init_pos[i], SCULPT_vertex_co_get(ss, vertex));
|
||||
|
@ -2317,7 +2317,7 @@ void SCULPT_cloth_brush_store_simulation_state(SculptSession *ss, SculptClothSim
|
|||
{
|
||||
const int totverts = SCULPT_vertex_count_get(ss);
|
||||
for (int i = 0; i < totverts; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
copy_v3_v3(cloth_sim->pos[i], SCULPT_vertex_co_get(ss, vertex));
|
||||
}
|
||||
|
@ -2751,7 +2751,7 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
|
|||
const int totverts = SCULPT_vertex_count_get(ss);
|
||||
|
||||
for (int i = 0; i < totverts; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
copy_v3_v3(ss->filter_cache->cloth_sim->pos[i], SCULPT_vertex_co_get(ss, vertex));
|
||||
}
|
||||
|
@ -2792,7 +2792,7 @@ static void sculpt_cloth_filter_face_set_pinch_origin_calculate(float r_pinch_or
|
|||
float accum[3] = {0.0f};
|
||||
int tot = 0;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!SCULPT_vertex_has_face_set(ss, vertex, active_face_set)) {
|
||||
continue;
|
||||
|
|
|
@ -140,7 +140,7 @@ BLI_INLINE void normal_covariance(float mat[3][3], float no[3])
|
|||
}
|
||||
|
||||
bool SCULPT_calc_principle_curvatures(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
SculptCurvatureData *out,
|
||||
bool useAccurateSolver)
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ bool SCULPT_calc_principle_curvatures(SculptSession *ss,
|
|||
}
|
||||
|
||||
void SCULPT_curvature_dir_get(SculptSession *ss,
|
||||
SculptVertRef v,
|
||||
PBVHVertRef v,
|
||||
float dir[3],
|
||||
bool useAccurateSolver)
|
||||
{
|
||||
|
|
|
@ -261,7 +261,7 @@ static void sample_detail_voxel(bContext *C, ViewContext *vc, const int mval[2])
|
|||
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false);
|
||||
|
||||
/* Average the edge length of the connected edges to the active vertex. */
|
||||
SculptVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
const float *active_vertex_co = SCULPT_active_vertex_co_get(ss);
|
||||
float edge_length = 0.0f;
|
||||
int tot = 0;
|
||||
|
@ -686,7 +686,7 @@ static void dyntopo_detail_size_sample_from_surface(Object *ob,
|
|||
DyntopoDetailSizeEditCustomData *cd)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const SculptVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
const PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
|
||||
float len_accum = 0;
|
||||
int num_neighbors = 0;
|
||||
|
|
|
@ -131,7 +131,7 @@ static float cotangent_tri_weight_v3_proj(const float n[3],
|
|||
}
|
||||
|
||||
void SCULPT_dyntopo_get_cotangents(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float *r_ws,
|
||||
float *r_cot1,
|
||||
float *r_cot2,
|
||||
|
@ -199,7 +199,7 @@ void SCULPT_dyntopo_get_cotangents(SculptSession *ss,
|
|||
}
|
||||
|
||||
void SCULPT_faces_get_cotangents(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float *r_ws,
|
||||
float *r_cot1,
|
||||
float *r_cot2,
|
||||
|
@ -268,7 +268,7 @@ void SCULPT_cotangents_begin(Object *ob, SculptSession *ss)
|
|||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
SCULPT_dyntopo_check_disk_sort(ss, vertex);
|
||||
}
|
||||
break;
|
||||
|
@ -294,7 +294,7 @@ void SCULPT_cotangents_begin(Object *ob, SculptSession *ss)
|
|||
}
|
||||
|
||||
void SCULPT_get_cotangents(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float *r_ws,
|
||||
float *r_cot1,
|
||||
float *r_cot2,
|
||||
|
@ -329,7 +329,7 @@ void SCULT_dyntopo_flag_all_disk_sort(SculptSession *ss)
|
|||
}
|
||||
|
||||
// returns true if edge disk list around vertex was sorted
|
||||
bool SCULPT_dyntopo_check_disk_sort(SculptSession *ss, SculptVertRef vertex)
|
||||
bool SCULPT_dyntopo_check_disk_sort(SculptSession *ss, PBVHVertRef vertex)
|
||||
{
|
||||
BMVert *v = (BMVert *)vertex.i;
|
||||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(ss->cd_sculpt_vert, v);
|
||||
|
@ -356,10 +356,10 @@ void SCULPT_reorder_bmesh(SculptSession *ss)
|
|||
SCULPT_vertex_random_access_ensure(ss);
|
||||
|
||||
int actv = ss->active_vertex_index.i ?
|
||||
BKE_pbvh_vertex_index_to_table(ss->pbvh, ss->active_vertex_index) :
|
||||
BKE_pbvh_vertex_to_index(ss->pbvh, ss->active_vertex_index) :
|
||||
-1;
|
||||
int actf = ss->active_face_index.i ?
|
||||
BKE_pbvh_face_index_to_table(ss->pbvh, ss->active_face_index) :
|
||||
BKE_pbvh_face_to_index(ss->pbvh, ss->active_face_index) :
|
||||
-1;
|
||||
|
||||
if (ss->bm_log) {
|
||||
|
@ -372,10 +372,10 @@ void SCULPT_reorder_bmesh(SculptSession *ss)
|
|||
SCULPT_vertex_random_access_ensure(ss);
|
||||
|
||||
if (actv >= 0) {
|
||||
ss->active_vertex_index = BKE_pbvh_table_index_to_vertex(ss->pbvh, actv);
|
||||
ss->active_vertex_index = BKE_pbvh_index_to_vertex(ss->pbvh, actv);
|
||||
}
|
||||
if (actf >= 0) {
|
||||
ss->active_face_index = BKE_pbvh_table_index_to_face(ss->pbvh, actf);
|
||||
ss->active_face_index = BKE_pbvh_index_to_face(ss->pbvh, actf);
|
||||
}
|
||||
|
||||
SCULPT_dyntopo_node_layers_update_offsets(ss, ob);
|
||||
|
@ -1707,7 +1707,7 @@ static void sculpt_uv_brush_cb(void *__restrict userdata,
|
|||
mask = BM_ELEM_CD_GET_FLOAT(l->v, cd_mask);
|
||||
}
|
||||
|
||||
SculptVertRef vertex = {(intptr_t)l->v};
|
||||
PBVHVertRef vertex = {(intptr_t)l->v};
|
||||
|
||||
float direction2[3];
|
||||
const float fade =
|
||||
|
@ -1787,7 +1787,7 @@ void SCULPT_uv_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
|
|||
NULL,
|
||||
sv->v->no,
|
||||
0.0f,
|
||||
(SculptVertRef){.i = (intptr_t)sv->v},
|
||||
(PBVHVertRef){.i = (intptr_t)sv->v},
|
||||
0);
|
||||
}
|
||||
|
||||
|
|
|
@ -141,9 +141,9 @@ enum {
|
|||
*/
|
||||
static bool sculpt_expand_is_vert_in_active_component(SculptSession *ss,
|
||||
ExpandCache *expand_cache,
|
||||
const SculptVertRef v)
|
||||
const PBVHVertRef v)
|
||||
{
|
||||
const int v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, v);
|
||||
const int v_i = BKE_pbvh_vertex_to_index(ss->pbvh, v);
|
||||
|
||||
for (int i = 0; i < EXPAND_SYMM_AREAS; i++) {
|
||||
if (ss->vertex_info.connected_component[v_i] == expand_cache->active_connected_components[i]) {
|
||||
|
@ -158,19 +158,19 @@ static bool sculpt_expand_is_vert_in_active_component(SculptSession *ss,
|
|||
*/
|
||||
static bool sculpt_expand_is_face_in_active_component(SculptSession *ss,
|
||||
ExpandCache *expand_cache,
|
||||
const SculptFaceRef f)
|
||||
const PBVHFaceRef f)
|
||||
{
|
||||
if (ss->bm) {
|
||||
BMFace *bf = (BMFace *)f.i;
|
||||
BMLoop *l = bf->l_first;
|
||||
SculptVertRef v = {(intptr_t)l->v};
|
||||
PBVHVertRef v = {(intptr_t)l->v};
|
||||
|
||||
return sculpt_expand_is_vert_in_active_component(ss, expand_cache, v);
|
||||
}
|
||||
else {
|
||||
const MLoop *loop = &ss->mloop[ss->mpoly[f.i].loopstart];
|
||||
return sculpt_expand_is_vert_in_active_component(
|
||||
ss, expand_cache, BKE_pbvh_table_index_to_vertex(ss->pbvh, loop->v));
|
||||
ss, expand_cache, BKE_pbvh_index_to_vertex(ss->pbvh, loop->v));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,9 +180,9 @@ static bool sculpt_expand_is_face_in_active_component(SculptSession *ss,
|
|||
*/
|
||||
static float sculpt_expand_falloff_value_vertex_get(SculptSession *ss,
|
||||
ExpandCache *expand_cache,
|
||||
const SculptVertRef v)
|
||||
const PBVHVertRef v)
|
||||
{
|
||||
const int v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, v);
|
||||
const int v_i = BKE_pbvh_vertex_to_index(ss->pbvh, v);
|
||||
|
||||
if (expand_cache->texture_distortion_strength == 0.0f) {
|
||||
return expand_cache->vert_falloff[v_i];
|
||||
|
@ -226,7 +226,7 @@ static float sculpt_expand_max_vertex_falloff_get(ExpandCache *expand_cache)
|
|||
*/
|
||||
static bool sculpt_expand_state_get(SculptSession *ss,
|
||||
ExpandCache *expand_cache,
|
||||
const SculptVertRef v)
|
||||
const PBVHVertRef v)
|
||||
{
|
||||
if (!SCULPT_vertex_visible_get(ss, v)) {
|
||||
return false;
|
||||
|
@ -274,9 +274,9 @@ static bool sculpt_expand_state_get(SculptSession *ss,
|
|||
*/
|
||||
static bool sculpt_expand_face_state_get(SculptSession *ss,
|
||||
ExpandCache *expand_cache,
|
||||
const SculptFaceRef f)
|
||||
const PBVHFaceRef f)
|
||||
{
|
||||
const int f_i = BKE_pbvh_face_index_to_table(ss->pbvh, f);
|
||||
const int f_i = BKE_pbvh_face_to_index(ss->pbvh, f);
|
||||
|
||||
if (expand_cache->original_face_sets[f_i] <= 0) {
|
||||
return false;
|
||||
|
@ -324,7 +324,7 @@ static bool sculpt_expand_face_state_get(SculptSession *ss,
|
|||
*/
|
||||
static float sculpt_expand_gradient_value_get(SculptSession *ss,
|
||||
ExpandCache *expand_cache,
|
||||
const SculptVertRef v)
|
||||
const PBVHVertRef v)
|
||||
{
|
||||
if (!expand_cache->falloff_gradient) {
|
||||
return 1.0f;
|
||||
|
@ -369,7 +369,7 @@ static BLI_bitmap *sculpt_expand_bitmap_from_enabled(SculptSession *ss, ExpandCa
|
|||
BLI_bitmap *enabled_vertices = BLI_BITMAP_NEW(totvert, "enabled vertices");
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
const bool enabled = sculpt_expand_state_get(
|
||||
ss, expand_cache, BKE_pbvh_table_index_to_vertex(ss->pbvh, i));
|
||||
ss, expand_cache, BKE_pbvh_index_to_vertex(ss->pbvh, i));
|
||||
BLI_BITMAP_SET(enabled_vertices, i, enabled);
|
||||
}
|
||||
return enabled_vertices;
|
||||
|
@ -387,7 +387,7 @@ static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
|
|||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
BLI_bitmap *boundary_vertices = BLI_BITMAP_NEW(totvert, "boundary vertices");
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!BLI_BITMAP_TEST(enabled_vertices, i)) {
|
||||
continue;
|
||||
|
@ -418,11 +418,11 @@ static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
|
|||
* Utility function to get the closet vertex after flipping an original vertex position based on
|
||||
* an symmetry pass iteration index.
|
||||
*/
|
||||
static SculptVertRef sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
Object *ob, const char symm_it, const SculptVertRef original_vertex)
|
||||
static PBVHVertRef sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
Object *ob, const char symm_it, const PBVHVertRef original_vertex)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptVertRef symm_vertex = {SCULPT_EXPAND_VERTEX_NONE};
|
||||
PBVHVertRef symm_vertex = {SCULPT_EXPAND_VERTEX_NONE};
|
||||
|
||||
if (symm_it == 0) {
|
||||
symm_vertex = original_vertex;
|
||||
|
@ -439,7 +439,7 @@ static SculptVertRef sculpt_expand_get_vertex_index_for_symmetry_pass(
|
|||
* Geodesic: Initializes the falloff with geodesic distances from the given active vertex, taking
|
||||
* symmetry into account.
|
||||
*/
|
||||
static float *sculpt_expand_geodesic_falloff_create(Sculpt *sd, Object *ob, const SculptVertRef v)
|
||||
static float *sculpt_expand_geodesic_falloff_create(Sculpt *sd, Object *ob, const PBVHVertRef v)
|
||||
{
|
||||
return SCULPT_geodesic_from_vertex_and_symm(sd, ob, v, FLT_MAX);
|
||||
}
|
||||
|
@ -456,11 +456,11 @@ typedef struct ExpandFloodFillData {
|
|||
} ExpandFloodFillData;
|
||||
|
||||
static bool expand_topology_floodfill_cb(
|
||||
SculptSession *ss, SculptVertRef from_v, SculptVertRef to_v, bool is_duplicate, void *userdata)
|
||||
SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool is_duplicate, void *userdata)
|
||||
{
|
||||
ExpandFloodFillData *data = userdata;
|
||||
int from_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_v);
|
||||
int to_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v);
|
||||
int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
|
||||
int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
|
||||
if (!is_duplicate) {
|
||||
const float to_it = data->dists[from_v_i] + 1.0f;
|
||||
|
@ -472,7 +472,7 @@ static bool expand_topology_floodfill_cb(
|
|||
return true;
|
||||
}
|
||||
|
||||
static float *sculpt_expand_topology_falloff_create(Sculpt *sd, Object *ob, const SculptVertRef v)
|
||||
static float *sculpt_expand_topology_falloff_create(Sculpt *sd, Object *ob, const PBVHVertRef v)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
@ -497,11 +497,11 @@ static float *sculpt_expand_topology_falloff_create(Sculpt *sd, Object *ob, cons
|
|||
* This creates falloff patterns that follow and snap to the hard edges of the object.
|
||||
*/
|
||||
static bool mask_expand_normal_floodfill_cb(
|
||||
SculptSession *ss, SculptVertRef from_v, SculptVertRef to_v, bool is_duplicate, void *userdata)
|
||||
SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool is_duplicate, void *userdata)
|
||||
{
|
||||
ExpandFloodFillData *data = userdata;
|
||||
int from_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_v);
|
||||
int to_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v);
|
||||
int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
|
||||
int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
|
||||
if (!is_duplicate) {
|
||||
float current_normal[3], prev_normal[3];
|
||||
|
@ -524,7 +524,7 @@ static bool mask_expand_normal_floodfill_cb(
|
|||
|
||||
static float *sculpt_expand_normal_falloff_create(Sculpt *sd,
|
||||
Object *ob,
|
||||
const SculptVertRef v,
|
||||
const PBVHVertRef v,
|
||||
const float edge_sensitivity)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -551,7 +551,7 @@ static float *sculpt_expand_normal_falloff_create(Sculpt *sd,
|
|||
for (int repeat = 0; repeat < 2; repeat++) {
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
float avg = 0.0f;
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
SculptVertexNeighborIter ni;
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vref, ni) {
|
||||
|
@ -571,7 +571,7 @@ static float *sculpt_expand_normal_falloff_create(Sculpt *sd,
|
|||
* Spherical: Initializes the falloff based on the distance from a vertex, taking symmetry into
|
||||
* account.
|
||||
*/
|
||||
static float *sculpt_expand_spherical_falloff_create(Object *ob, const SculptVertRef v)
|
||||
static float *sculpt_expand_spherical_falloff_create(Object *ob, const PBVHVertRef v)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
@ -586,14 +586,14 @@ static float *sculpt_expand_spherical_falloff_create(Object *ob, const SculptVer
|
|||
if (!SCULPT_is_symmetry_iteration_valid(symm_it, symm)) {
|
||||
continue;
|
||||
}
|
||||
const SculptVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
const PBVHVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
ob, symm_it, v);
|
||||
if (symm_vertex.i != -1) {
|
||||
const float *co = SCULPT_vertex_co_get(ss, symm_vertex);
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
dists[i] = min_ff(
|
||||
dists[i],
|
||||
len_v3v3(co, SCULPT_vertex_co_get(ss, BKE_pbvh_table_index_to_vertex(ss->pbvh, i))));
|
||||
len_v3v3(co, SCULPT_vertex_co_get(ss, BKE_pbvh_index_to_vertex(ss->pbvh, i))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -608,13 +608,13 @@ static float *sculpt_expand_spherical_falloff_create(Object *ob, const SculptVer
|
|||
*/
|
||||
static float *sculpt_expand_boundary_topology_falloff_create(Sculpt *sd,
|
||||
Object *ob,
|
||||
const SculptVertRef v)
|
||||
const PBVHVertRef v)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
float *dists = MEM_calloc_arrayN(totvert, sizeof(float), "spherical dist");
|
||||
BLI_bitmap *visited_vertices = BLI_BITMAP_NEW(totvert, "visited vertices");
|
||||
GSQueue *queue = BLI_gsqueue_new(sizeof(SculptVertRef));
|
||||
GSQueue *queue = BLI_gsqueue_new(sizeof(PBVHVertRef));
|
||||
|
||||
/* Search and initialize a boundary per symmetry pass, then mark those vertices as visited. */
|
||||
const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
|
||||
|
@ -623,7 +623,7 @@ static float *sculpt_expand_boundary_topology_falloff_create(Sculpt *sd,
|
|||
continue;
|
||||
}
|
||||
|
||||
const SculptVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
const PBVHVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
ob, symm_it, v);
|
||||
|
||||
SculptBoundary *boundary = SCULPT_boundary_data_init(sd, ob, NULL, symm_vertex, FLT_MAX);
|
||||
|
@ -634,7 +634,7 @@ static float *sculpt_expand_boundary_topology_falloff_create(Sculpt *sd,
|
|||
for (int i = 0; i < boundary->num_vertices; i++) {
|
||||
BLI_gsqueue_push(queue, &boundary->vertices[i]);
|
||||
BLI_BITMAP_ENABLE(visited_vertices,
|
||||
BKE_pbvh_vertex_index_to_table(ss->pbvh, boundary->vertices[i]));
|
||||
BKE_pbvh_vertex_to_index(ss->pbvh, boundary->vertices[i]));
|
||||
}
|
||||
SCULPT_boundary_data_free(boundary);
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ static float *sculpt_expand_boundary_topology_falloff_create(Sculpt *sd,
|
|||
|
||||
/* Propagate the values from the boundaries to the rest of the mesh. */
|
||||
while (!BLI_gsqueue_is_empty(queue)) {
|
||||
SculptVertRef v_next;
|
||||
PBVHVertRef v_next;
|
||||
BLI_gsqueue_pop(queue, &v_next);
|
||||
|
||||
SculptVertexNeighborIter ni;
|
||||
|
@ -655,7 +655,7 @@ static float *sculpt_expand_boundary_topology_falloff_create(Sculpt *sd,
|
|||
continue;
|
||||
}
|
||||
|
||||
const int v_next_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, v_next);
|
||||
const int v_next_i = BKE_pbvh_vertex_to_index(ss->pbvh, v_next);
|
||||
|
||||
dists[ni.index] = dists[v_next_i] + 1.0f;
|
||||
BLI_BITMAP_ENABLE(visited_vertices, ni.index);
|
||||
|
@ -674,7 +674,7 @@ static float *sculpt_expand_boundary_topology_falloff_create(Sculpt *sd,
|
|||
* the base mesh faces when checking a vertex neighbor. For this reason, this is not implement
|
||||
* using the general flood-fill and sculpt neighbors accessors.
|
||||
*/
|
||||
static float *sculpt_expand_diagonals_falloff_create(Object *ob, const SculptVertRef v)
|
||||
static float *sculpt_expand_diagonals_falloff_create(Object *ob, const PBVHVertRef v)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
@ -694,18 +694,18 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const SculptVer
|
|||
|
||||
/* Search and mask as visited the initial vertices using the enabled symmetry passes. */
|
||||
BLI_bitmap *visited_vertices = BLI_BITMAP_NEW(totvert, "visited vertices");
|
||||
GSQueue *queue = BLI_gsqueue_new(sizeof(SculptVertRef));
|
||||
GSQueue *queue = BLI_gsqueue_new(sizeof(PBVHVertRef));
|
||||
const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
|
||||
for (char symm_it = 0; symm_it <= symm; symm_it++) {
|
||||
if (!SCULPT_is_symmetry_iteration_valid(symm_it, symm)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const SculptVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
const PBVHVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
ob, symm_it, v);
|
||||
|
||||
BLI_gsqueue_push(queue, &symm_vertex);
|
||||
BLI_BITMAP_ENABLE(visited_vertices, BKE_pbvh_vertex_index_to_table(ss->pbvh, symm_vertex));
|
||||
BLI_BITMAP_ENABLE(visited_vertices, BKE_pbvh_vertex_to_index(ss->pbvh, symm_vertex));
|
||||
}
|
||||
|
||||
if (BLI_gsqueue_is_empty(queue)) {
|
||||
|
@ -715,10 +715,10 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const SculptVer
|
|||
/* Propagate the falloff increasing the value by 1 each time a new vertex is visited. */
|
||||
Mesh *mesh = ob->data;
|
||||
while (!BLI_gsqueue_is_empty(queue)) {
|
||||
SculptVertRef v_next;
|
||||
PBVHVertRef v_next;
|
||||
BLI_gsqueue_pop(queue, &v_next);
|
||||
|
||||
int v_next_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, v_next);
|
||||
int v_next_i = BKE_pbvh_vertex_to_index(ss->pbvh, v_next);
|
||||
|
||||
if (ss->bm) {
|
||||
BMIter iter;
|
||||
|
@ -771,7 +771,7 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const SculptVer
|
|||
/**
|
||||
* Poly Loop:
|
||||
*/
|
||||
static float *sculpt_expand_poly_loop_falloff_create(Object *ob, const SculptVertRef v)
|
||||
static float *sculpt_expand_poly_loop_falloff_create(Object *ob, const PBVHVertRef v)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
@ -814,7 +814,7 @@ static float *sculpt_expand_poly_loop_falloff_create(Object *ob, const SculptVer
|
|||
int v_next_i;
|
||||
BLI_gsqueue_pop(queue, &v_next_i);
|
||||
|
||||
SculptVertRef v_next = BKE_pbvh_table_index_to_vertex(ss->pbvh, v_next_i);
|
||||
PBVHVertRef v_next = BKE_pbvh_index_to_vertex(ss->pbvh, v_next_i);
|
||||
|
||||
SculptVertexNeighborIter ni;
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, v_next, ni) {
|
||||
|
@ -851,7 +851,7 @@ static void sculpt_expand_update_max_vert_falloff_value(SculptSession *ss,
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef v = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef v = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!sculpt_expand_is_vert_in_active_component(ss, expand_cache, v)) {
|
||||
continue;
|
||||
|
@ -872,7 +872,7 @@ static void sculpt_expand_update_max_face_falloff_factor(SculptSession *ss,
|
|||
const int totface = ss->totfaces;
|
||||
expand_cache->max_face_falloff = -FLT_MAX;
|
||||
for (int i = 0; i < totface; i++) {
|
||||
SculptFaceRef f = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef f = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
|
||||
if (expand_cache->face_falloff[i] == FLT_MAX) {
|
||||
continue;
|
||||
|
@ -1027,7 +1027,7 @@ static void sculpt_expand_topology_from_state_boundary(Object *ob,
|
|||
continue;
|
||||
}
|
||||
|
||||
SCULPT_floodfill_add_and_skip_initial(ss, &flood, BKE_pbvh_table_index_to_vertex(ss->pbvh, i));
|
||||
SCULPT_floodfill_add_and_skip_initial(ss, &flood, BKE_pbvh_index_to_vertex(ss->pbvh, i));
|
||||
}
|
||||
MEM_freeN(boundary_vertices);
|
||||
|
||||
|
@ -1092,7 +1092,7 @@ static void sculpt_expand_initialize_from_face_set_boundary(Object *ob,
|
|||
|
||||
BLI_bitmap *enabled_vertices = BLI_BITMAP_NEW(totvert, "enabled vertices");
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!SCULPT_vertex_has_unique_face_set(ss, vref)) {
|
||||
continue;
|
||||
|
@ -1115,7 +1115,7 @@ static void sculpt_expand_initialize_from_face_set_boundary(Object *ob,
|
|||
|
||||
if (internal_falloff) {
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!(SCULPT_vertex_has_face_set(ss, vref, active_face_set) &&
|
||||
SCULPT_vertex_has_unique_face_set(ss, vref))) {
|
||||
|
@ -1136,7 +1136,7 @@ static void sculpt_expand_initialize_from_face_set_boundary(Object *ob,
|
|||
}
|
||||
else {
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!SCULPT_vertex_has_face_set(ss, vref, active_face_set)) {
|
||||
continue;
|
||||
|
@ -1154,7 +1154,7 @@ static void sculpt_expand_falloff_factors_from_vertex_and_symm_create(
|
|||
ExpandCache *expand_cache,
|
||||
Sculpt *sd,
|
||||
Object *ob,
|
||||
const SculptVertRef v,
|
||||
const PBVHVertRef v,
|
||||
eSculptExpandFalloffType falloff_type)
|
||||
{
|
||||
MEM_SAFE_FREE(expand_cache->vert_falloff);
|
||||
|
@ -1301,7 +1301,7 @@ static void sculpt_expand_restore_face_set_data(SculptSession *ss, ExpandCache *
|
|||
}
|
||||
MEM_freeN(nodes);
|
||||
for (int i = 0; i < ss->totfaces; i++) {
|
||||
SculptFaceRef f = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef f = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
|
||||
SCULPT_face_set_set(ss, f, expand_cache->original_face_sets[i]);
|
||||
}
|
||||
|
@ -1447,7 +1447,7 @@ static void sculpt_expand_face_sets_update(SculptSession *ss, ExpandCache *expan
|
|||
const int totface = ss->totfaces;
|
||||
|
||||
for (int f_i = 0; f_i < totface; f_i++) {
|
||||
SculptFaceRef f = BKE_pbvh_table_index_to_face(ss->pbvh, f_i);
|
||||
PBVHFaceRef f = BKE_pbvh_index_to_face(ss->pbvh, f_i);
|
||||
int fset = SCULPT_face_set_get(ss, f);
|
||||
|
||||
const bool enabled = sculpt_expand_face_state_get(ss, expand_cache, f);
|
||||
|
@ -1557,7 +1557,7 @@ static void sculpt_expand_original_state_store(Object *ob, ExpandCache *expand_c
|
|||
expand_cache->original_face_sets = MEM_malloc_arrayN(totface, sizeof(int), "original face set");
|
||||
|
||||
for (int i = 0; i < totface; i++) {
|
||||
const SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
const PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
const int fset = SCULPT_face_set_get(ss, fref);
|
||||
|
||||
expand_cache->initial_face_sets[i] = fset;
|
||||
|
@ -1568,14 +1568,14 @@ static void sculpt_expand_original_state_store(Object *ob, ExpandCache *expand_c
|
|||
expand_cache->original_mask = MEM_malloc_arrayN(totvert, sizeof(float), "initial mask");
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
expand_cache->original_mask[i] = SCULPT_vertex_mask_get(
|
||||
ss, BKE_pbvh_table_index_to_vertex(ss->pbvh, i));
|
||||
ss, BKE_pbvh_index_to_vertex(ss->pbvh, i));
|
||||
}
|
||||
}
|
||||
|
||||
if (expand_cache->target == SCULPT_EXPAND_TARGET_COLORS) {
|
||||
expand_cache->original_colors = MEM_malloc_arrayN(totvert, sizeof(float[4]), "initial colors");
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
SCULPT_vertex_color_get(ss, vertex, expand_cache->original_colors[i]);
|
||||
}
|
||||
|
@ -1590,7 +1590,7 @@ static void sculpt_expand_face_sets_restore(SculptSession *ss, ExpandCache *expa
|
|||
const int totfaces = ss->totfaces;
|
||||
|
||||
for (int i = 0; i < totfaces; i++) {
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
|
||||
if (expand_cache->original_face_sets[i] <= 0) {
|
||||
/* Do not modify hidden Face Sets, even when restoring the IDs state. */
|
||||
|
@ -1604,10 +1604,10 @@ static void sculpt_expand_face_sets_restore(SculptSession *ss, ExpandCache *expa
|
|||
}
|
||||
}
|
||||
|
||||
static void sculpt_expand_update_for_vertex(bContext *C, Object *ob, const SculptVertRef vertex)
|
||||
static void sculpt_expand_update_for_vertex(bContext *C, Object *ob, const PBVHVertRef vertex)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
const int vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
const int vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
|
||||
ExpandCache *expand_cache = ss->expand_cache;
|
||||
|
@ -1662,9 +1662,9 @@ static void sculpt_expand_update_for_vertex(bContext *C, Object *ob, const Sculp
|
|||
* Updates the #SculptSession cursor data and gets the active vertex
|
||||
* if the cursor is over the mesh.
|
||||
*/
|
||||
static SculptVertRef sculpt_expand_target_vertex_update_and_get(bContext *C,
|
||||
Object *ob,
|
||||
const float mval[2])
|
||||
static PBVHVertRef sculpt_expand_target_vertex_update_and_get(bContext *C,
|
||||
Object *ob,
|
||||
const float mval[2])
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptCursorGeometryInfo sgi;
|
||||
|
@ -1672,7 +1672,7 @@ static SculptVertRef sculpt_expand_target_vertex_update_and_get(bContext *C,
|
|||
return SCULPT_active_vertex_get(ss);
|
||||
}
|
||||
|
||||
SculptVertRef ret = {SCULPT_EXPAND_VERTEX_NONE};
|
||||
PBVHVertRef ret = {SCULPT_EXPAND_VERTEX_NONE};
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1713,7 +1713,7 @@ static void sculpt_expand_reposition_pivot(bContext *C, Object *ob, ExpandCache
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef v = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef v = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!sculpt_expand_is_vert_in_active_component(ss, expand_cache, v)) {
|
||||
continue;
|
||||
|
@ -1775,7 +1775,7 @@ static void sculpt_expand_finish(bContext *C)
|
|||
* needed for expand.
|
||||
*/
|
||||
static void sculpt_expand_find_active_connected_components_from_vert(
|
||||
Object *ob, ExpandCache *expand_cache, const SculptVertRef initial_vertex)
|
||||
Object *ob, ExpandCache *expand_cache, const PBVHVertRef initial_vertex)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
for (int i = 0; i < EXPAND_SYMM_AREAS; i++) {
|
||||
|
@ -1788,9 +1788,9 @@ static void sculpt_expand_find_active_connected_components_from_vert(
|
|||
continue;
|
||||
}
|
||||
|
||||
const SculptVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
const PBVHVertRef symm_vertex = sculpt_expand_get_vertex_index_for_symmetry_pass(
|
||||
ob, symm_it, initial_vertex);
|
||||
const int symm_vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, symm_vertex);
|
||||
const int symm_vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, symm_vertex);
|
||||
|
||||
expand_cache->active_connected_components[(int)symm_it] =
|
||||
ss->vertex_info.connected_component[symm_vertex_i];
|
||||
|
@ -1807,7 +1807,7 @@ static void sculpt_expand_set_initial_components_for_mouse(bContext *C,
|
|||
const float mval[2])
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptVertRef initial_vertex = sculpt_expand_target_vertex_update_and_get(C, ob, mval);
|
||||
PBVHVertRef initial_vertex = sculpt_expand_target_vertex_update_and_get(C, ob, mval);
|
||||
|
||||
if (initial_vertex.i == SCULPT_EXPAND_VERTEX_NONE) {
|
||||
/* Cursor not over the mesh, for creating valid initial falloffs, fallback to the last active
|
||||
|
@ -1885,7 +1885,7 @@ static int sculpt_expand_active_face_set_id_get(SculptSession *ss, ExpandCache *
|
|||
case PBVH_BMESH:
|
||||
case PBVH_FACES:
|
||||
return expand_cache
|
||||
->original_face_sets[BKE_pbvh_vertex_index_to_table(ss->pbvh, ss->active_face_index)];
|
||||
->original_face_sets[BKE_pbvh_vertex_to_index(ss->pbvh, ss->active_face_index)];
|
||||
case PBVH_GRIDS: {
|
||||
const int face_index = BKE_subdiv_ccg_grid_to_face_index(ss->subdiv_ccg,
|
||||
ss->active_grid_index);
|
||||
|
@ -1913,8 +1913,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
|
|||
|
||||
/* Update and get the active vertex (and face) from the cursor. */
|
||||
const float mval[2] = {event->mval[0], event->mval[1]};
|
||||
const SculptVertRef target_expand_vertex = sculpt_expand_target_vertex_update_and_get(
|
||||
C, ob, mval);
|
||||
const PBVHVertRef target_expand_vertex = sculpt_expand_target_vertex_update_and_get(C, ob, mval);
|
||||
|
||||
/* Handle the modal keymap state changes. */
|
||||
ExpandCache *expand_cache = ss->expand_cache;
|
||||
|
@ -2111,7 +2110,7 @@ static void sculpt_expand_delete_face_set_id_bmesh(int *r_face_sets,
|
|||
bool all_same_id = true;
|
||||
|
||||
BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) {
|
||||
SculptFaceRef fref = {(intptr_t)f};
|
||||
PBVHFaceRef fref = {(intptr_t)f};
|
||||
i++;
|
||||
|
||||
if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, fref)) {
|
||||
|
@ -2135,7 +2134,7 @@ static void sculpt_expand_delete_face_set_id_bmesh(int *r_face_sets,
|
|||
BLI_LINKSTACK_INIT(queue_next);
|
||||
|
||||
for (int i = 0; i < totface; i++) {
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
|
||||
if (r_face_sets[i] == delete_id) {
|
||||
BLI_LINKSTACK_PUSH(queue, (BMFace *)(fref.i));
|
||||
|
@ -2146,7 +2145,7 @@ static void sculpt_expand_delete_face_set_id_bmesh(int *r_face_sets,
|
|||
bool any_updated = false;
|
||||
|
||||
while (BLI_LINKSTACK_SIZE(queue)) {
|
||||
const SculptFaceRef f = {(intptr_t)(BLI_LINKSTACK_POP(queue))};
|
||||
const PBVHFaceRef f = {(intptr_t)(BLI_LINKSTACK_POP(queue))};
|
||||
BMFace *bf = (BMFace *)f.i;
|
||||
const int f_index = BM_elem_index_get(bf);
|
||||
|
||||
|
@ -2231,7 +2230,7 @@ static void sculpt_expand_delete_face_set_id(int *r_face_sets,
|
|||
bool all_same_id = true;
|
||||
for (int i = 0; i < totface; i++) {
|
||||
if (!sculpt_expand_is_face_in_active_component(
|
||||
ss, expand_cache, BKE_pbvh_table_index_to_face(ss->pbvh, i))) {
|
||||
ss, expand_cache, BKE_pbvh_index_to_face(ss->pbvh, i))) {
|
||||
continue;
|
||||
}
|
||||
if (r_face_sets[i] != delete_id) {
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int sculpt_face_material_get(SculptSession *ss, SculptFaceRef face)
|
||||
static int sculpt_face_material_get(SculptSession *ss, PBVHFaceRef face)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
|
@ -76,7 +76,7 @@ static int sculpt_face_material_get(SculptSession *ss, SculptFaceRef face)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int SCULPT_face_set_get(SculptSession *ss, SculptFaceRef face)
|
||||
int SCULPT_face_set_get(SculptSession *ss, PBVHFaceRef face)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
|
@ -91,7 +91,7 @@ int SCULPT_face_set_get(SculptSession *ss, SculptFaceRef face)
|
|||
}
|
||||
|
||||
// returns previous face set
|
||||
int SCULPT_face_set_set(SculptSession *ss, SculptFaceRef face, int fset)
|
||||
int SCULPT_face_set_set(SculptSession *ss, PBVHFaceRef face, int fset)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
@ -115,7 +115,7 @@ int SCULPT_face_set_set(SculptSession *ss, SculptFaceRef face, int fset)
|
|||
|
||||
const char orig_faceset_attr_name[] = "_sculpt_original_fsets";
|
||||
|
||||
void SCULPT_face_check_origdata(SculptSession *ss, SculptFaceRef face)
|
||||
void SCULPT_face_check_origdata(SculptSession *ss, PBVHFaceRef face)
|
||||
{
|
||||
if (!ss->scl.orig_fsets) {
|
||||
return;
|
||||
|
@ -130,7 +130,7 @@ void SCULPT_face_check_origdata(SculptSession *ss, SculptFaceRef face)
|
|||
}
|
||||
}
|
||||
|
||||
int SCULPT_face_set_original_get(SculptSession *ss, SculptFaceRef face)
|
||||
int SCULPT_face_set_original_get(SculptSession *ss, PBVHFaceRef face)
|
||||
{
|
||||
if (!ss->scl.orig_fsets) {
|
||||
return SCULPT_face_set_get(ss, face);
|
||||
|
@ -157,7 +157,7 @@ void SCULPT_face_ensure_original(SculptSession *ss, Object *ob)
|
|||
&((SculptLayerParams){.permanent = false, .simple_array = false}));
|
||||
}
|
||||
|
||||
int SCULPT_face_set_flag_get(SculptSession *ss, SculptFaceRef face, char flag)
|
||||
int SCULPT_face_set_flag_get(SculptSession *ss, PBVHFaceRef face, char flag)
|
||||
{
|
||||
if (ss->bm) {
|
||||
BMFace *f = (BMFace *)face.i;
|
||||
|
@ -170,7 +170,7 @@ int SCULPT_face_set_flag_get(SculptSession *ss, SculptFaceRef face, char flag)
|
|||
}
|
||||
}
|
||||
|
||||
int SCULPT_face_set_flag_set(SculptSession *ss, SculptFaceRef face, char flag, bool state)
|
||||
int SCULPT_face_set_flag_set(SculptSession *ss, PBVHFaceRef face, char flag, bool state)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -462,16 +462,15 @@ void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
|
|||
copy_v3_v3(fno, ss->vert_normals[ml->v]);
|
||||
float mask = ss->vmask ? ss->vmask[ml->v] : 0.0f;
|
||||
|
||||
const float fade2 = bstrength *
|
||||
SCULPT_brush_strength_factor(ss,
|
||||
brush,
|
||||
v->co,
|
||||
sqrtf(test.dist),
|
||||
ss->vert_normals[ml->v],
|
||||
fno,
|
||||
mask,
|
||||
(SculptVertRef){.i = ml->v},
|
||||
thread_id);
|
||||
const float fade2 = bstrength * SCULPT_brush_strength_factor(ss,
|
||||
brush,
|
||||
v->co,
|
||||
sqrtf(test.dist),
|
||||
ss->vert_normals[ml->v],
|
||||
fno,
|
||||
mask,
|
||||
(PBVHVertRef){.i = ml->v},
|
||||
thread_id);
|
||||
|
||||
if (fade2 < test_limit) {
|
||||
ok = false;
|
||||
|
@ -546,16 +545,16 @@ void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
|
|||
do {
|
||||
float mask = cd_mask >= 0 ? BM_ELEM_CD_GET_FLOAT(l->v, cd_mask) : 0.0f;
|
||||
|
||||
const float fade2 = bstrength * SCULPT_brush_strength_factor(
|
||||
ss,
|
||||
brush,
|
||||
l->v->co,
|
||||
sqrtf(test.dist),
|
||||
l->v->no,
|
||||
l->f->no,
|
||||
mask,
|
||||
(SculptVertRef){.i = (intptr_t)l->v},
|
||||
thread_id);
|
||||
const float fade2 = bstrength *
|
||||
SCULPT_brush_strength_factor(ss,
|
||||
brush,
|
||||
l->v->co,
|
||||
sqrtf(test.dist),
|
||||
l->v->no,
|
||||
l->f->no,
|
||||
mask,
|
||||
(PBVHVertRef){.i = (intptr_t)l->v},
|
||||
thread_id);
|
||||
|
||||
if (fade2 < test_limit) {
|
||||
ok = false;
|
||||
|
@ -804,7 +803,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
|
|||
|
||||
if (mode == SCULPT_FACE_SET_MASKED) {
|
||||
for (int i = 0; i < tot_vert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (SCULPT_vertex_mask_get(ss, vertex) >= threshold &&
|
||||
SCULPT_vertex_visible_get(ss, vertex)) {
|
||||
|
@ -820,7 +819,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
|
|||
* sets and the performance hit of rendering the overlay. */
|
||||
bool all_visible = true;
|
||||
for (int i = 0; i < tot_vert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!SCULPT_vertex_visible_get(ss, vertex)) {
|
||||
all_visible = false;
|
||||
|
@ -836,7 +835,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
for (int i = 0; i < tot_vert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (SCULPT_vertex_visible_get(ss, vertex)) {
|
||||
SCULPT_vertex_face_set_set(ss, vertex, next_face_set);
|
||||
|
@ -846,7 +845,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
|
|||
|
||||
if (mode == SCULPT_FACE_SET_ALL) {
|
||||
for (int i = 0; i < tot_vert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
SCULPT_vertex_face_set_set(ss, vertex, next_face_set);
|
||||
}
|
||||
|
@ -856,7 +855,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
|
|||
const int totface = ss->totfaces;
|
||||
|
||||
for (int i = 0; i < totface; i++) {
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
|
||||
// XXX check hidden?
|
||||
int ok = !SCULPT_face_set_flag_get(ss, fref, ME_HIDE);
|
||||
|
@ -1063,7 +1062,7 @@ static void sculpt_face_sets_init_flood_fill(Object *ob,
|
|||
GSQueue *queue;
|
||||
queue = BLI_gsqueue_new(sizeof(int));
|
||||
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
SCULPT_face_set_set(ss, fref, next_face_set);
|
||||
|
||||
BLI_BITMAP_ENABLE(visited_faces, i);
|
||||
|
@ -1092,7 +1091,7 @@ static void sculpt_face_sets_init_flood_fill(Object *ob,
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptFaceRef fref2 = BKE_pbvh_table_index_to_face(ss->pbvh, neighbor_face_index);
|
||||
PBVHFaceRef fref2 = BKE_pbvh_index_to_face(ss->pbvh, neighbor_face_index);
|
||||
SCULPT_face_set_set(ss, fref2, next_face_set);
|
||||
|
||||
BLI_BITMAP_ENABLE(visited_faces, neighbor_face_index);
|
||||
|
@ -1134,7 +1133,7 @@ static void sculpt_face_sets_init_loop(Object *ob, const int mode)
|
|||
}
|
||||
|
||||
for (int i = 0; i < ss->totfaces; i++) {
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
|
||||
if (mode == SCULPT_FACE_SETS_FROM_MATERIALS) {
|
||||
SCULPT_face_set_set(ss, fref, (int)(sculpt_face_material_get(ss, fref) + 1));
|
||||
|
@ -1351,7 +1350,7 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
|
|||
* be synced from face sets to non-manifold vertices. */
|
||||
if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
|
||||
for (int i = 0; i < tot_vert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!SCULPT_vertex_visible_get(ss, vertex)) {
|
||||
hidden_vertex = true;
|
||||
|
@ -1493,7 +1492,7 @@ static int sculpt_face_sets_randomize_colors_exec(bContext *C, wmOperator *UNUSE
|
|||
0,
|
||||
max_ii(0, ss->totfaces - 1));
|
||||
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, random_index);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, random_index);
|
||||
mesh->face_sets_color_default = SCULPT_face_set_get(ss, fref);
|
||||
}
|
||||
BKE_pbvh_face_sets_color_set(pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default);
|
||||
|
@ -1694,7 +1693,7 @@ static void sculpt_face_set_fill_component(Object *ob,
|
|||
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (!SCULPT_vertex_has_face_set(ss, vertex, active_face_set_id)) {
|
||||
continue;
|
||||
|
@ -1707,7 +1706,7 @@ static void sculpt_face_set_fill_component(Object *ob,
|
|||
}
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
const int vertex_connected_component = ss->vertex_info.connected_component[i];
|
||||
if (!BLI_gset_haskey(connected_components, POINTER_FROM_INT(vertex_connected_component))) {
|
||||
|
@ -1818,7 +1817,7 @@ static bool check_single_face_set(SculptSession *ss, const bool check_visible_on
|
|||
|
||||
if (check_visible_only) {
|
||||
for (int f = 0; f < ss->totfaces; f++) {
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, f);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, f);
|
||||
int fset = SCULPT_face_set_get(ss, fref);
|
||||
|
||||
if (fset > 0) {
|
||||
|
@ -1828,7 +1827,7 @@ static bool check_single_face_set(SculptSession *ss, const bool check_visible_on
|
|||
}
|
||||
}
|
||||
else {
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, 0);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, 0);
|
||||
first_face_set = abs(SCULPT_face_set_get(ss, fref));
|
||||
}
|
||||
|
||||
|
@ -1837,7 +1836,7 @@ static bool check_single_face_set(SculptSession *ss, const bool check_visible_on
|
|||
}
|
||||
|
||||
for (int f = 0; f < ss->totfaces; f++) {
|
||||
SculptFaceRef fref = BKE_pbvh_table_index_to_face(ss->pbvh, f);
|
||||
PBVHFaceRef fref = BKE_pbvh_index_to_face(ss->pbvh, f);
|
||||
|
||||
int fset = SCULPT_face_set_get(ss, fref);
|
||||
fset = check_visible_only ? abs(fset) : fset;
|
||||
|
@ -1936,7 +1935,7 @@ static void sculpt_face_set_edit_fair_face_set(Object *ob,
|
|||
SCULPT_boundary_info_ensure(ob);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
fair_vertices[i] = !SCULPT_vertex_is_boundary(ss, vref, SCULPT_BOUNDARY_MESH) &&
|
||||
SCULPT_vertex_has_face_set(ss, vref, active_face_set_id) &&
|
||||
|
@ -2169,10 +2168,10 @@ static void sculpt_face_set_extrude_id(Object *ob,
|
|||
|
||||
SculptFaceSetIsland *island = NULL;
|
||||
|
||||
if (no_islands && ss->active_face_index.i != SCULPT_REF_NONE) {
|
||||
if (no_islands && ss->active_face_index.i != PBVH_REF_NONE) {
|
||||
island = SCULPT_face_set_island_get(ss, ss->active_face_index, active_face_set_id);
|
||||
|
||||
/* convert SculptFaceRef list into simple integers, only need to do for pbvh_bmesh*/
|
||||
/* convert PBVHFaceRef list into simple integers, only need to do for pbvh_bmesh*/
|
||||
if (island && ss->bm) {
|
||||
SCULPT_face_random_access_ensure(ss);
|
||||
|
||||
|
@ -2612,8 +2611,8 @@ static void sculpt_face_set_extrude_id(Object *ob,
|
|||
|
||||
static void island_stack_bmesh_do(SculptSession *ss,
|
||||
int fset,
|
||||
SculptFaceRef face,
|
||||
SculptFaceRef **r_faces,
|
||||
PBVHFaceRef face,
|
||||
PBVHFaceRef **r_faces,
|
||||
int *r_totfaces,
|
||||
BLI_bitmap *visit)
|
||||
{
|
||||
|
@ -2641,17 +2640,17 @@ static void island_stack_bmesh_do(SculptSession *ss,
|
|||
} while ((l = l->next) != f->l_first);
|
||||
|
||||
*r_totfaces = BLI_array_len(faces);
|
||||
*r_faces = (SculptFaceRef *)faces;
|
||||
*r_faces = (PBVHFaceRef *)faces;
|
||||
}
|
||||
|
||||
static void island_stack_mesh_do(SculptSession *ss,
|
||||
int fset,
|
||||
SculptFaceRef face,
|
||||
SculptFaceRef **r_faces,
|
||||
PBVHFaceRef face,
|
||||
PBVHFaceRef **r_faces,
|
||||
int *r_totfaces,
|
||||
BLI_bitmap *visit)
|
||||
{
|
||||
SculptFaceRef *faces = *r_faces;
|
||||
PBVHFaceRef *faces = *r_faces;
|
||||
BLI_array_declare(faces);
|
||||
BLI_array_len_set(faces, *r_totfaces);
|
||||
|
||||
|
@ -2666,7 +2665,7 @@ static void island_stack_mesh_do(SculptSession *ss,
|
|||
|
||||
if (abs(ss->face_sets[f2]) == fset && !BLI_BITMAP_TEST(visit, f2)) {
|
||||
BLI_BITMAP_SET(visit, f2, true);
|
||||
SculptFaceRef face2 = {f2};
|
||||
PBVHFaceRef face2 = {f2};
|
||||
|
||||
BLI_array_append(faces, face2);
|
||||
}
|
||||
|
@ -2674,7 +2673,7 @@ static void island_stack_mesh_do(SculptSession *ss,
|
|||
}
|
||||
|
||||
*r_totfaces = BLI_array_len(faces);
|
||||
*r_faces = (SculptFaceRef *)faces;
|
||||
*r_faces = (PBVHFaceRef *)faces;
|
||||
}
|
||||
SculptFaceSetIslands *SCULPT_face_set_islands_get(SculptSession *ss, int fset)
|
||||
{
|
||||
|
@ -2696,13 +2695,13 @@ SculptFaceSetIslands *SCULPT_face_set_islands_get(SculptSession *ss, int fset)
|
|||
|
||||
int totface = ss->totfaces;
|
||||
BLI_bitmap *visit = BLI_BITMAP_NEW(totface, __func__);
|
||||
SculptFaceRef *stack = NULL;
|
||||
PBVHFaceRef *stack = NULL;
|
||||
BLI_array_declare(stack);
|
||||
|
||||
SCULPT_face_random_access_ensure(ss);
|
||||
|
||||
for (int i = 0; i < totface; i++) {
|
||||
SculptFaceRef face = BKE_pbvh_table_index_to_face(ss->pbvh, i);
|
||||
PBVHFaceRef face = BKE_pbvh_index_to_face(ss->pbvh, i);
|
||||
|
||||
if (abs(SCULPT_face_set_get(ss, face)) != fset) {
|
||||
continue;
|
||||
|
@ -2717,12 +2716,12 @@ SculptFaceSetIslands *SCULPT_face_set_islands_get(SculptSession *ss, int fset)
|
|||
BLI_array_clear(stack);
|
||||
BLI_array_append(stack, face);
|
||||
|
||||
SculptFaceRef *faces = NULL;
|
||||
PBVHFaceRef *faces = NULL;
|
||||
BLI_array_declare(faces);
|
||||
|
||||
while (BLI_array_len(stack) > 0) {
|
||||
// can't use BLI_array_pop since it doesn't work with popping structures
|
||||
SculptFaceRef face2 = stack[BLI_array_len(stack) - 1];
|
||||
PBVHFaceRef face2 = stack[BLI_array_len(stack) - 1];
|
||||
BLI_array_len_set(stack, BLI_array_len(stack) - 1);
|
||||
|
||||
BLI_array_append(faces, face2);
|
||||
|
@ -2761,7 +2760,7 @@ void SCULPT_face_set_islands_free(SculptSession *ss, SculptFaceSetIslands *islan
|
|||
MEM_SAFE_FREE(islands);
|
||||
}
|
||||
|
||||
SculptFaceSetIsland *SCULPT_face_set_island_get(SculptSession *ss, SculptFaceRef face, int fset)
|
||||
SculptFaceSetIsland *SCULPT_face_set_island_get(SculptSession *ss, PBVHFaceRef face, int fset)
|
||||
{
|
||||
SculptFaceSetIslands *islands = SCULPT_face_set_islands_get(ss, fset);
|
||||
|
||||
|
@ -2843,7 +2842,7 @@ static int sculpt_face_set_edit_modal(bContext *C, wmOperator *op, const wmEvent
|
|||
SCULPT_face_random_access_ensure(ss);
|
||||
|
||||
if (dot_v3v3(fsecd->start_no, fsecd->start_no) == 0.0f &&
|
||||
ss->active_face_index.i != SCULPT_REF_NONE) {
|
||||
ss->active_face_index.i != PBVH_REF_NONE) {
|
||||
float fno[4];
|
||||
|
||||
SCULPT_face_normal_get(ss, ss->active_face_index, fno);
|
||||
|
@ -2882,7 +2881,7 @@ static int sculpt_face_set_edit_modal(bContext *C, wmOperator *op, const wmEvent
|
|||
BM_mesh_elem_index_ensure(ss->bm, BM_VERT | BM_EDGE | BM_FACE);
|
||||
|
||||
for (int i = 0; i < fsecd->totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, fsecd->verts[i]);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, fsecd->verts[i]);
|
||||
|
||||
BMVert *v = (BMVert *)vertex.i;
|
||||
|
||||
|
|
|
@ -133,8 +133,8 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
|
|||
SCULPT_undo_push_begin(ob, "face set edit");
|
||||
SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
|
||||
|
||||
const SculptFaceRef initial_poly = ss->active_face_index;
|
||||
const SculptEdgeRef initial_edge = sculpt_poly_loop_initial_edge_from_cursor(ob);
|
||||
const PBVHFaceRef initial_poly = ss->active_face_index;
|
||||
const PBVHEdgeRef initial_edge = sculpt_poly_loop_initial_edge_from_cursor(ob);
|
||||
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
int new_face_set = SCULPT_FACE_SET_NONE;
|
||||
|
|
|
@ -297,7 +297,7 @@ static void sculpt_color_presmooth_init(SculptSession *ss)
|
|||
}
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
SCULPT_vertex_color_get(ss, vertex, ss->filter_cache->pre_smoothed_color[i]);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ static void sculpt_color_presmooth_init(SculptSession *ss)
|
|||
for (int i = 0; i < totvert; i++) {
|
||||
float avg[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
int total = 0;
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
SculptVertexNeighborIter ni;
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
|
||||
|
|
|
@ -217,7 +217,7 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
|
|||
if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) {
|
||||
prev_mask = MEM_mallocN(num_verts * sizeof(float), "prevmask");
|
||||
for (int j = 0; j < num_verts; j++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, j);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, j);
|
||||
|
||||
prev_mask[j] = SCULPT_vertex_mask_get(ss, vertex);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ typedef enum MaskFilterStepDirectionType {
|
|||
|
||||
/* Grown/Shrink vertex callbacks. */
|
||||
static float sculpt_ipmask_vertex_grow_cb(SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float *current_mask)
|
||||
{
|
||||
float max = 0.0f;
|
||||
|
@ -344,7 +344,7 @@ static float sculpt_ipmask_vertex_grow_cb(SculptSession *ss,
|
|||
}
|
||||
|
||||
static float sculpt_ipmask_vertex_shrink_cb(SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float *current_mask)
|
||||
{
|
||||
float min = 1.0f;
|
||||
|
@ -361,10 +361,10 @@ static float sculpt_ipmask_vertex_shrink_cb(SculptSession *ss,
|
|||
|
||||
/* Smooth/Sharpen vertex callbacks. */
|
||||
static float sculpt_ipmask_vertex_smooth_cb(SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float *current_mask)
|
||||
{
|
||||
int vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
float accum = current_mask[vertex_i];
|
||||
int total = 1;
|
||||
|
@ -378,10 +378,10 @@ static float sculpt_ipmask_vertex_smooth_cb(SculptSession *ss,
|
|||
}
|
||||
|
||||
static float sculpt_ipmask_vertex_sharpen_cb(SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float *current_mask)
|
||||
{
|
||||
int vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
float accum = 0.0f;
|
||||
int total = 0;
|
||||
|
@ -430,10 +430,10 @@ static float sculpt_ipmask_vertex_sharpen_cb(SculptSession *ss,
|
|||
/* Harder/Softer callbacks. */
|
||||
#define SCULPT_IPMASK_FILTER_HARDER_SOFTER_STEP 0.01f
|
||||
static float sculpt_ipmask_vertex_harder_cb(SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float *current_mask)
|
||||
{
|
||||
int vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
return clamp_f(current_mask[vertex_i] += current_mask[vertex_i] *
|
||||
SCULPT_IPMASK_FILTER_HARDER_SOFTER_STEP,
|
||||
|
@ -442,10 +442,10 @@ static float sculpt_ipmask_vertex_harder_cb(SculptSession *ss,
|
|||
}
|
||||
|
||||
static float sculpt_ipmask_vertex_softer_cb(SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float *current_mask)
|
||||
{
|
||||
int vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
return clamp_f(current_mask[vertex_i] -= current_mask[vertex_i] *
|
||||
SCULPT_IPMASK_FILTER_HARDER_SOFTER_STEP,
|
||||
|
@ -473,19 +473,19 @@ static float sculpt_ipmask_filter_contrast(const float mask, const float contras
|
|||
}
|
||||
|
||||
static float sculpt_ipmask_vertex_contrast_increase_cb(SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float *current_mask)
|
||||
{
|
||||
int vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
return sculpt_ipmask_filter_contrast(current_mask[vertex_i], SCULPT_IPMASK_FILTER_CONTRAST_STEP);
|
||||
}
|
||||
|
||||
static float sculpt_ipmask_vertex_contrast_decrease_cb(SculptSession *ss,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
float *current_mask)
|
||||
{
|
||||
int vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex);
|
||||
int vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, vertex);
|
||||
|
||||
return sculpt_ipmask_filter_contrast(current_mask[vertex_i],
|
||||
-1.0f * SCULPT_IPMASK_FILTER_CONTRAST_STEP);
|
||||
|
@ -533,7 +533,7 @@ static void ipmask_filter_compute_step_task_cb(void *__restrict userdata,
|
|||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
{
|
||||
SculptIPMaskFilterTaskData *data = userdata;
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(data->ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(data->ss->pbvh, i);
|
||||
|
||||
if (data->direction == MASK_FILTER_STEP_DIRECTION_FORWARD) {
|
||||
data->next_mask[i] = data->ss->filter_cache->mask_filter_step_forward(
|
||||
|
@ -588,7 +588,7 @@ static void sculpt_ipmask_store_reference_step(SculptSession *ss)
|
|||
}
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
ss->filter_cache->mask_filter_ref[i] = SCULPT_vertex_mask_get(ss, vertex);
|
||||
}
|
||||
|
|
|
@ -572,7 +572,7 @@ static void mesh_filter_enhance_details_init_directions(SculptSession *ss)
|
|||
filter_cache->detail_directions = MEM_malloc_arrayN(
|
||||
totvert, sizeof(float[3]), "detail directions");
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
float avg[3];
|
||||
SCULPT_neighbor_coords_average(ss, avg, vertex, 0.0f, false, weighted);
|
||||
|
@ -589,7 +589,7 @@ static void mesh_filter_sphere_center_calculate(
|
|||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
float center_accum[3] = {0.0f};
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
add_v3_v3(center_accum, SCULPT_vertex_co_get(ss, vertex));
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ static void mesh_filter_sphere_radius_calculate(SculptSession *ss)
|
|||
FilterCache *filter_cache = ss->filter_cache;
|
||||
float accum = 0.0f;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
accum += len_v3v3(filter_cache->sphere_center, SCULPT_vertex_co_get(ss, vertex));
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ static void mesh_filter_init_limit_surface_co(SculptSession *ss)
|
|||
filter_cache->limit_surface_co = MEM_malloc_arrayN(
|
||||
totvert, sizeof(float[3]), "limit surface co");
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
SCULPT_vertex_limit_surface_get(ss, vertex, filter_cache->limit_surface_co[i]);
|
||||
}
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ static void mesh_filter_sharpen_init(SculptSession *ss,
|
|||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
float avg[3];
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
SCULPT_neighbor_coords_average(ss, avg, vertex, 0.0f, false, weighted);
|
||||
sub_v3_v3v3(filter_cache->detail_directions[i], avg, SCULPT_vertex_co_get(ss, vertex));
|
||||
|
@ -685,7 +685,7 @@ static void mesh_filter_sharpen_init(SculptSession *ss,
|
|||
smooth_iterations++) {
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
float direction_avg[3] = {0.0f, 0.0f, 0.0f};
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
float sharpen_avg = 0;
|
||||
int total = 0;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ static bool sculpt_geodesic_mesh_test_dist_add(MVert *mvert,
|
|||
const int v2,
|
||||
float *dists,
|
||||
GSet *initial_vertices,
|
||||
SculptVertRef *r_closest_verts,
|
||||
PBVHVertRef *r_closest_verts,
|
||||
float (*cos)[3])
|
||||
{
|
||||
if (BLI_gset_haskey(initial_vertices, POINTER_FROM_INT(v0))) {
|
||||
|
@ -141,7 +141,7 @@ static bool sculpt_geodesic_grids_test_dist_add(SculptSession *ss,
|
|||
const int v2,
|
||||
float *dists,
|
||||
GSet *initial_vertices,
|
||||
SculptVertRef *r_closest_verts,
|
||||
PBVHVertRef *r_closest_verts,
|
||||
float (*cos)[3])
|
||||
{
|
||||
if (BLI_gset_haskey(initial_vertices, POINTER_FROM_INT(v0))) {
|
||||
|
@ -154,13 +154,12 @@ static bool sculpt_geodesic_grids_test_dist_add(SculptSession *ss,
|
|||
}
|
||||
|
||||
const float *co0 = cos ? cos[v0] :
|
||||
SCULPT_vertex_co_get(ss, BKE_pbvh_table_index_to_vertex(ss->pbvh, v0));
|
||||
SCULPT_vertex_co_get(ss, BKE_pbvh_index_to_vertex(ss->pbvh, v0));
|
||||
const float *co1 = cos ? cos[v1] :
|
||||
SCULPT_vertex_co_get(ss, BKE_pbvh_table_index_to_vertex(ss->pbvh, v1));
|
||||
SCULPT_vertex_co_get(ss, BKE_pbvh_index_to_vertex(ss->pbvh, v1));
|
||||
const float *co2 = v2 != SCULPT_GEODESIC_VERTEX_NONE ?
|
||||
(cos ? cos[v2] :
|
||||
SCULPT_vertex_co_get(
|
||||
ss, BKE_pbvh_table_index_to_vertex(ss->pbvh, v2))) :
|
||||
SCULPT_vertex_co_get(ss, BKE_pbvh_index_to_vertex(ss->pbvh, v2))) :
|
||||
NULL;
|
||||
|
||||
float dist0;
|
||||
|
@ -215,7 +214,7 @@ static bool sculpt_geodesic_mesh_test_dist_add_bmesh(BMVert *v0,
|
|||
BMVert *v2,
|
||||
float *dists,
|
||||
GSet *initial_vertices,
|
||||
SculptVertRef *r_closest_verts,
|
||||
PBVHVertRef *r_closest_verts,
|
||||
float (*cos)[3])
|
||||
{
|
||||
const int v0_i = BM_elem_index_get(v0);
|
||||
|
@ -290,7 +289,7 @@ static bool sculpt_geodesic_mesh_test_dist_add_bmesh(BMVert *v0,
|
|||
static float *SCULPT_geodesic_mesh_create(Object *ob,
|
||||
GSet *initial_vertices,
|
||||
const float limit_radius,
|
||||
SculptVertRef *r_closest_verts,
|
||||
PBVHVertRef *r_closest_verts,
|
||||
float (*cos)[3])
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -332,7 +331,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
|
|||
for (int i = 0; i < totvert; i++) {
|
||||
if (BLI_gset_haskey(initial_vertices, POINTER_FROM_INT(i))) {
|
||||
if (r_closest_verts) {
|
||||
r_closest_verts[i] = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
r_closest_verts[i] = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
}
|
||||
|
||||
dists[i] = 0.0f;
|
||||
|
@ -466,7 +465,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
|
|||
static float *SCULPT_geodesic_bmesh_create(Object *ob,
|
||||
GSet *initial_vertices,
|
||||
const float limit_radius,
|
||||
SculptVertRef *r_closest_verts,
|
||||
PBVHVertRef *r_closest_verts,
|
||||
float (*cos)[3])
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -502,7 +501,7 @@ static float *SCULPT_geodesic_bmesh_create(Object *ob,
|
|||
dists[i] = 0.0f;
|
||||
|
||||
if (r_closest_verts) {
|
||||
r_closest_verts[i] = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
r_closest_verts[i] = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -533,13 +532,13 @@ static float *SCULPT_geodesic_bmesh_create(Object *ob,
|
|||
* number of vertices (usually just 1 or 2). */
|
||||
GSET_ITER (gs_iter, initial_vertices) {
|
||||
const int v_i = POINTER_AS_INT(BLI_gsetIterator_getKey(&gs_iter));
|
||||
BMVert *v = (BMVert *)BKE_pbvh_table_index_to_vertex(ss->pbvh, v_i).i;
|
||||
BMVert *v = (BMVert *)BKE_pbvh_index_to_vertex(ss->pbvh, v_i).i;
|
||||
float *co1 = cos ? cos[BM_elem_index_get(v)] : v->co;
|
||||
|
||||
BM_elem_flag_enable(v, BMESH_INITIAL_VERT_TAG);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
BMVert *v2 = (BMVert *)BKE_pbvh_table_index_to_vertex(ss->pbvh, i).i;
|
||||
BMVert *v2 = (BMVert *)BKE_pbvh_index_to_vertex(ss->pbvh, i).i;
|
||||
float *co2 = cos ? cos[BM_elem_index_get(v2)] : v2->co;
|
||||
|
||||
if (len_squared_v3v3(co1, co2) <= limit_radius_sq) {
|
||||
|
@ -702,7 +701,7 @@ int find_quad(TempEdge *edges, MeshElemMap *vmap, int v1, int v2, int v3)
|
|||
static float *SCULPT_geodesic_grids_create(Object *ob,
|
||||
GSet *initial_vertices,
|
||||
const float limit_radius,
|
||||
SculptVertRef *r_closest_verts,
|
||||
PBVHVertRef *r_closest_verts,
|
||||
float (*cos)[3])
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -723,7 +722,7 @@ static float *SCULPT_geodesic_grids_create(Object *ob,
|
|||
for (int i = 0; i < totvert; i++) {
|
||||
if (BLI_gset_haskey(initial_vertices, POINTER_FROM_INT(i))) {
|
||||
if (r_closest_verts) {
|
||||
r_closest_verts[i] = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
r_closest_verts[i] = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
}
|
||||
|
||||
dists[i] = 0.0f;
|
||||
|
@ -753,13 +752,12 @@ static float *SCULPT_geodesic_grids_create(Object *ob,
|
|||
* number of vertices (usually just 1 or 2). */
|
||||
GSET_ITER (gs_iter, initial_vertices) {
|
||||
const int v = POINTER_AS_INT(BLI_gsetIterator_getKey(&gs_iter));
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, v);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, v);
|
||||
const float *v_co = cos ? cos[v] : SCULPT_vertex_co_get(ss, vertex);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
const float *v_co2 = cos ? cos[i] :
|
||||
SCULPT_vertex_co_get(
|
||||
ss, BKE_pbvh_table_index_to_vertex(ss->pbvh, i));
|
||||
SCULPT_vertex_co_get(ss, BKE_pbvh_index_to_vertex(ss->pbvh, i));
|
||||
if (len_squared_v3v3(v_co, v_co2) <= limit_radius_sq) {
|
||||
BLI_BITMAP_ENABLE(affected_vertex, i);
|
||||
}
|
||||
|
@ -779,7 +777,7 @@ static float *SCULPT_geodesic_grids_create(Object *ob,
|
|||
MemArena *ma = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "geodesic grids memarena");
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
MeshElemMap *map = vmap + i;
|
||||
|
||||
int val = SCULPT_vertex_valence_get(ss, vertex);
|
||||
|
@ -963,7 +961,7 @@ static float *SCULPT_geodesic_fallback_create(Object *ob, GSet *initial_vertices
|
|||
SculptSession *ss = ob->sculpt;
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
float *dists = MEM_malloc_arrayN(totvert, sizeof(float), "distances");
|
||||
SculptVertRef first_affected = {SCULPT_GEODESIC_VERTEX_NONE};
|
||||
PBVHVertRef first_affected = {SCULPT_GEODESIC_VERTEX_NONE};
|
||||
|
||||
GSetIterator gs_iter;
|
||||
GSET_ITER (gs_iter, initial_vertices) {
|
||||
|
@ -981,7 +979,7 @@ static float *SCULPT_geodesic_fallback_create(Object *ob, GSet *initial_vertices
|
|||
const float *first_affected_co = SCULPT_vertex_co_get(ss, first_affected);
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
dists[i] = len_v3v3(first_affected_co,
|
||||
SCULPT_vertex_co_get(ss, BKE_pbvh_table_index_to_vertex(ss->pbvh, i)));
|
||||
SCULPT_vertex_co_get(ss, BKE_pbvh_index_to_vertex(ss->pbvh, i)));
|
||||
}
|
||||
|
||||
return dists;
|
||||
|
@ -990,7 +988,7 @@ static float *SCULPT_geodesic_fallback_create(Object *ob, GSet *initial_vertices
|
|||
float *SCULPT_geodesic_distances_create(Object *ob,
|
||||
GSet *initial_vertices,
|
||||
const float limit_radius,
|
||||
SculptVertRef *r_closest_verts,
|
||||
PBVHVertRef *r_closest_verts,
|
||||
float (*vertco_override)[3])
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -1012,7 +1010,7 @@ float *SCULPT_geodesic_distances_create(Object *ob,
|
|||
|
||||
float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
|
||||
Object *ob,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const float limit_radius)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -1021,7 +1019,7 @@ float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
|
|||
const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
|
||||
for (char i = 0; i <= symm; ++i) {
|
||||
if (SCULPT_is_symmetry_iteration_valid(i, symm)) {
|
||||
SculptVertRef v = {-1};
|
||||
PBVHVertRef v = {-1};
|
||||
|
||||
if (i == 0) {
|
||||
v = vertex;
|
||||
|
@ -1032,7 +1030,7 @@ float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
|
|||
v = SCULPT_nearest_vertex_get(sd, ob, location, FLT_MAX, false);
|
||||
}
|
||||
|
||||
const int v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, v);
|
||||
const int v_i = BKE_pbvh_vertex_to_index(ss->pbvh, v);
|
||||
|
||||
if (v_i != -1) {
|
||||
BLI_gset_add(initial_vertices, POINTER_FROM_INT(v_i));
|
||||
|
@ -1045,9 +1043,7 @@ float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
|
|||
return dists;
|
||||
}
|
||||
|
||||
float *SCULPT_geodesic_from_vertex(Object *ob,
|
||||
const SculptVertRef vertex,
|
||||
const float limit_radius)
|
||||
float *SCULPT_geodesic_from_vertex(Object *ob, const PBVHVertRef vertex, const float limit_radius)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
|
@ -1055,8 +1051,7 @@ float *SCULPT_geodesic_from_vertex(Object *ob,
|
|||
|
||||
GSet *initial_vertices = BLI_gset_int_new("initial_vertices");
|
||||
|
||||
BLI_gset_add(initial_vertices,
|
||||
POINTER_FROM_INT(BKE_pbvh_vertex_index_to_table(ss->pbvh, vertex)));
|
||||
BLI_gset_add(initial_vertices, POINTER_FROM_INT(BKE_pbvh_vertex_to_index(ss->pbvh, vertex)));
|
||||
|
||||
float *dists = SCULPT_geodesic_distances_create(ob, initial_vertices, limit_radius, NULL, NULL);
|
||||
BLI_gset_free(initial_vertices, NULL);
|
||||
|
|
|
@ -78,8 +78,8 @@ typedef struct SculptCursorGeometryInfo {
|
|||
} SculptCursorGeometryInfo;
|
||||
|
||||
struct _SculptNeighborRef {
|
||||
SculptVertRef vertex;
|
||||
SculptEdgeRef edge;
|
||||
PBVHVertRef vertex;
|
||||
PBVHEdgeRef edge;
|
||||
};
|
||||
|
||||
#define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 12
|
||||
|
@ -99,8 +99,8 @@ typedef struct SculptVertexNeighborIter {
|
|||
int i;
|
||||
|
||||
/* Public */
|
||||
SculptVertRef vertex;
|
||||
SculptEdgeRef edge;
|
||||
PBVHVertRef vertex;
|
||||
PBVHEdgeRef edge;
|
||||
int index;
|
||||
bool has_edge; // does this iteration step have an edge, fake neighbors do not
|
||||
bool is_duplicate;
|
||||
|
@ -128,7 +128,7 @@ typedef enum SculptBoundaryType {
|
|||
} SculptBoundaryType;
|
||||
|
||||
typedef struct SculptFaceSetIsland {
|
||||
SculptFaceRef *faces;
|
||||
PBVHFaceRef *faces;
|
||||
int totface;
|
||||
} SculptFaceSetIsland;
|
||||
|
||||
|
@ -230,7 +230,7 @@ typedef struct SculptUndoNode {
|
|||
|
||||
/* non-multires */
|
||||
int maxvert; /* to verify if totvert it still the same */
|
||||
SculptVertRef *index; /* to restore into right location */
|
||||
PBVHVertRef *index; /* to restore into right location */
|
||||
int maxloop;
|
||||
int *loop_index;
|
||||
|
||||
|
@ -407,7 +407,7 @@ typedef struct SculptThreadedTaskData {
|
|||
bool mask_by_color_preserve_mask;
|
||||
|
||||
/* Index of the vertex that is going to be used as a reference for the colors. */
|
||||
SculptVertRef mask_by_color_vertex;
|
||||
PBVHVertRef mask_by_color_vertex;
|
||||
float *mask_by_color_floodfill;
|
||||
|
||||
int face_set, face_set2;
|
||||
|
@ -561,7 +561,7 @@ typedef struct SculptGradientContext {
|
|||
} SculptGradientContext;
|
||||
|
||||
/* IPMask filter vertex callback function. */
|
||||
typedef float(SculptIPMaskFilterStepVertexCB)(struct SculptSession *, SculptVertRef, float *);
|
||||
typedef float(SculptIPMaskFilterStepVertexCB)(struct SculptSession *, PBVHVertRef, float *);
|
||||
|
||||
typedef struct FilterCache {
|
||||
bool enabled_axis[3];
|
||||
|
@ -930,7 +930,7 @@ typedef struct ExpandCache {
|
|||
* changed during the execution of Expand by moving the origin. */
|
||||
float initial_mouse_move[2];
|
||||
float initial_mouse[2];
|
||||
SculptVertRef initial_active_vertex;
|
||||
PBVHVertRef initial_active_vertex;
|
||||
int initial_active_face_set;
|
||||
|
||||
/* Maximum number of vertices allowed in the SculptSession for previewing the falloff using
|
||||
|
@ -1182,20 +1182,20 @@ void SCULPT_vertex_random_access_ensure(struct SculptSession *ss);
|
|||
/** Ensure random access; required for PBVH_BMESH */
|
||||
void SCULPT_face_random_access_ensure(struct SculptSession *ss);
|
||||
|
||||
int SCULPT_vertex_valence_get(const struct SculptSession *ss, SculptVertRef vertex);
|
||||
int SCULPT_vertex_valence_get(const struct SculptSession *ss, PBVHVertRef vertex);
|
||||
int SCULPT_vertex_count_get(const struct SculptSession *ss);
|
||||
|
||||
const float *SCULPT_vertex_co_get(struct SculptSession *ss, SculptVertRef vertex);
|
||||
void SCULPT_vertex_normal_get(SculptSession *ss, SculptVertRef vertex, float no[3]);
|
||||
float *SCULPT_vertex_origco_get(SculptSession *ss, SculptVertRef vertex);
|
||||
float *SCULPT_vertex_origno_get(SculptSession *ss, SculptVertRef vertex);
|
||||
const float *SCULPT_vertex_co_get(struct SculptSession *ss, PBVHVertRef vertex);
|
||||
void SCULPT_vertex_normal_get(SculptSession *ss, PBVHVertRef vertex, float no[3]);
|
||||
float *SCULPT_vertex_origco_get(SculptSession *ss, PBVHVertRef vertex);
|
||||
float *SCULPT_vertex_origno_get(SculptSession *ss, PBVHVertRef vertex);
|
||||
|
||||
const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, SculptVertRef vertex);
|
||||
void SCULPT_vertex_persistent_normal_get(SculptSession *ss, SculptVertRef vertex, float no[3]);
|
||||
const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, PBVHVertRef vertex);
|
||||
void SCULPT_vertex_persistent_normal_get(SculptSession *ss, PBVHVertRef vertex, float no[3]);
|
||||
|
||||
float SCULPT_vertex_mask_get(struct SculptSession *ss, SculptVertRef vertex);
|
||||
void SCULPT_vertex_color_get(const SculptSession *ss, SculptVertRef vertex, float r_color[4]);
|
||||
void SCULPT_vertex_color_set(SculptSession *ss, SculptVertRef vertex, const float color[4]);
|
||||
float SCULPT_vertex_mask_get(struct SculptSession *ss, PBVHVertRef vertex);
|
||||
void SCULPT_vertex_color_get(const SculptSession *ss, PBVHVertRef vertex, float r_color[4]);
|
||||
void SCULPT_vertex_color_set(SculptSession *ss, PBVHVertRef vertex, const float color[4]);
|
||||
|
||||
/** Returns true if a color attribute exists in the current sculpt session. */
|
||||
bool SCULPT_has_colors(const SculptSession *ss);
|
||||
|
@ -1208,13 +1208,13 @@ bool SCULPT_has_persistent_base(SculptSession *ss);
|
|||
/**
|
||||
* Coordinates used for manipulating the base mesh when Grab Active Vertex is enabled.
|
||||
*/
|
||||
const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, SculptVertRef vertex);
|
||||
const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, PBVHVertRef vertex);
|
||||
|
||||
/**
|
||||
* Returns the info of the limit surface when multi-res is available,
|
||||
* otherwise it returns the current coordinate of the vertex.
|
||||
*/
|
||||
void SCULPT_vertex_limit_surface_get(SculptSession *ss, SculptVertRef vertex, float r_co[3]);
|
||||
void SCULPT_vertex_limit_surface_get(SculptSession *ss, PBVHVertRef vertex, float r_co[3]);
|
||||
|
||||
/**
|
||||
* Returns the pointer to the coordinates that should be edited from a brush tool iterator
|
||||
|
@ -1225,7 +1225,7 @@ float *SCULPT_brush_deform_target_vertex_co_get(SculptSession *ss,
|
|||
PBVHVertexIter *iter);
|
||||
|
||||
void SCULPT_vertex_neighbors_get(const struct SculptSession *ss,
|
||||
const SculptVertRef vref,
|
||||
const PBVHVertRef vref,
|
||||
const bool include_duplicates,
|
||||
SculptVertexNeighborIter *iter);
|
||||
|
||||
|
@ -1235,7 +1235,7 @@ void SCULPT_vertex_neighbors_get(const struct SculptSession *ss,
|
|||
for (neighbor_iterator.i = 0; neighbor_iterator.i < neighbor_iterator.size; \
|
||||
neighbor_iterator.i++) { \
|
||||
neighbor_iterator.has_edge = neighbor_iterator.neighbors[neighbor_iterator.i].edge.i != \
|
||||
SCULPT_REF_NONE; \
|
||||
PBVH_REF_NONE; \
|
||||
neighbor_iterator.vertex = neighbor_iterator.neighbors[neighbor_iterator.i].vertex; \
|
||||
neighbor_iterator.edge = neighbor_iterator.neighbors[neighbor_iterator.i].edge; \
|
||||
neighbor_iterator.index = neighbor_iterator.neighbor_indices[neighbor_iterator.i];
|
||||
|
@ -1247,7 +1247,7 @@ void SCULPT_vertex_neighbors_get(const struct SculptSession *ss,
|
|||
for (neighbor_iterator.i = neighbor_iterator.size - 1; neighbor_iterator.i >= 0; \
|
||||
neighbor_iterator.i--) { \
|
||||
neighbor_iterator.has_edge = neighbor_iterator.neighbors[neighbor_iterator.i].edge.i != \
|
||||
SCULPT_REF_NONE; \
|
||||
PBVH_REF_NONE; \
|
||||
neighbor_iterator.vertex = neighbor_iterator.neighbors[neighbor_iterator.i].vertex; \
|
||||
neighbor_iterator.edge = neighbor_iterator.neighbors[neighbor_iterator.i].edge; \
|
||||
neighbor_iterator.index = neighbor_iterator.neighbor_indices[neighbor_iterator.i]; \
|
||||
|
@ -1271,7 +1271,7 @@ void SCULPT_vertex_neighbors_get(const struct SculptSession *ss,
|
|||
} \
|
||||
((void)0)
|
||||
|
||||
SculptVertRef SCULPT_active_vertex_get(SculptSession *ss);
|
||||
PBVHVertRef SCULPT_active_vertex_get(SculptSession *ss);
|
||||
const float *SCULPT_active_vertex_co_get(SculptSession *ss);
|
||||
void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]);
|
||||
|
||||
|
@ -1293,12 +1293,12 @@ void SCULPT_boundary_info_ensure(Object *object);
|
|||
|
||||
/* Boundary Info needs to be initialized in order to use this function. */
|
||||
SculptCornerType SCULPT_vertex_is_corner(const SculptSession *ss,
|
||||
const SculptVertRef index,
|
||||
const PBVHVertRef index,
|
||||
SculptCornerType cornertype);
|
||||
|
||||
/* Boundary Info needs to be initialized in order to use this function. */
|
||||
SculptBoundaryType SCULPT_vertex_is_boundary(const SculptSession *ss,
|
||||
const SculptVertRef index,
|
||||
const PBVHVertRef index,
|
||||
SculptBoundaryType boundary_types);
|
||||
|
||||
void SCULPT_connected_components_ensure(Object *ob);
|
||||
|
@ -1309,8 +1309,8 @@ void SCULPT_connected_components_ensure(Object *ob);
|
|||
/** \name Sculpt Visibility API
|
||||
* \{ */
|
||||
|
||||
void SCULPT_vertex_visible_set(SculptSession *ss, SculptVertRef vertex, bool visible);
|
||||
bool SCULPT_vertex_visible_get(SculptSession *ss, SculptVertRef vertex);
|
||||
void SCULPT_vertex_visible_set(SculptSession *ss, PBVHVertRef vertex, bool visible);
|
||||
bool SCULPT_vertex_visible_get(SculptSession *ss, PBVHVertRef vertex);
|
||||
|
||||
void SCULPT_visibility_sync_all_face_sets_to_vertices(struct Object *ob);
|
||||
void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss);
|
||||
|
@ -1321,16 +1321,16 @@ void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss);
|
|||
/** \name Face API
|
||||
* \{ */
|
||||
|
||||
SculptEdgeRef sculpt_poly_loop_initial_edge_from_cursor(Object *ob);
|
||||
PBVHEdgeRef sculpt_poly_loop_initial_edge_from_cursor(Object *ob);
|
||||
BLI_bitmap *sculpt_poly_loop_from_cursor(struct Object *ob);
|
||||
|
||||
SculptFaceSetIslands *SCULPT_face_set_islands_get(SculptSession *ss, int fset);
|
||||
void SCULPT_face_set_islands_free(SculptSession *ss, SculptFaceSetIslands *islands);
|
||||
|
||||
SculptFaceSetIsland *SCULPT_face_set_island_get(SculptSession *ss, SculptFaceRef face, int fset);
|
||||
SculptFaceSetIsland *SCULPT_face_set_island_get(SculptSession *ss, PBVHFaceRef face, int fset);
|
||||
void SCULPT_face_set_island_free(SculptFaceSetIsland *island);
|
||||
|
||||
void SCULPT_face_normal_get(SculptSession *ss, SculptFaceRef face, float no[3]);
|
||||
void SCULPT_face_normal_get(SculptSession *ss, PBVHFaceRef face, float no[3]);
|
||||
|
||||
/** \} */
|
||||
|
||||
|
@ -1339,28 +1339,28 @@ void SCULPT_face_normal_get(SculptSession *ss, SculptFaceRef face, float no[3]);
|
|||
* \{ */
|
||||
|
||||
int SCULPT_active_face_set_get(SculptSession *ss);
|
||||
int SCULPT_vertex_face_set_get(SculptSession *ss, SculptVertRef vertex);
|
||||
void SCULPT_vertex_face_set_set(SculptSession *ss, SculptVertRef vertex, int face_set);
|
||||
int SCULPT_vertex_face_set_get(SculptSession *ss, PBVHVertRef vertex);
|
||||
void SCULPT_vertex_face_set_set(SculptSession *ss, PBVHVertRef vertex, int face_set);
|
||||
|
||||
bool SCULPT_vertex_has_face_set(SculptSession *ss, SculptVertRef vertex, int face_set);
|
||||
bool SCULPT_vertex_has_unique_face_set(const SculptSession *ss, SculptVertRef vertex);
|
||||
bool SCULPT_vertex_has_face_set(SculptSession *ss, PBVHVertRef vertex, int face_set);
|
||||
bool SCULPT_vertex_has_unique_face_set(const SculptSession *ss, PBVHVertRef vertex);
|
||||
|
||||
int SCULPT_face_set_next_available_get(SculptSession *ss);
|
||||
|
||||
void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible);
|
||||
bool SCULPT_vertex_all_face_sets_visible_get(const SculptSession *ss, SculptVertRef vertex);
|
||||
bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, SculptVertRef vertex);
|
||||
bool SCULPT_vertex_all_face_sets_visible_get(const SculptSession *ss, PBVHVertRef vertex);
|
||||
bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, PBVHVertRef vertex);
|
||||
|
||||
void SCULPT_face_sets_visibility_invert(SculptSession *ss);
|
||||
void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible);
|
||||
|
||||
int SCULPT_face_set_get(SculptSession *ss, SculptFaceRef face);
|
||||
int SCULPT_face_set_set(SculptSession *ss, SculptFaceRef face, int fset);
|
||||
int SCULPT_face_set_get(SculptSession *ss, PBVHFaceRef face);
|
||||
int SCULPT_face_set_set(SculptSession *ss, PBVHFaceRef face, int fset);
|
||||
|
||||
int SCULPT_face_set_original_get(SculptSession *ss, SculptFaceRef face);
|
||||
int SCULPT_face_set_original_get(SculptSession *ss, PBVHFaceRef face);
|
||||
|
||||
int SCULPT_face_set_flag_get(SculptSession *ss, SculptFaceRef face, char flag);
|
||||
int SCULPT_face_set_flag_set(SculptSession *ss, SculptFaceRef face, char flag, bool state);
|
||||
int SCULPT_face_set_flag_get(SculptSession *ss, PBVHFaceRef face, char flag);
|
||||
int SCULPT_face_set_flag_set(SculptSession *ss, PBVHFaceRef face, char flag, bool state);
|
||||
|
||||
/** \} */
|
||||
|
||||
|
@ -1368,7 +1368,7 @@ int SCULPT_face_set_flag_set(SculptSession *ss, SculptFaceRef face, char flag, b
|
|||
/** \name Original Data API
|
||||
* \{ */
|
||||
|
||||
MSculptVert *SCULPT_vertex_get_sculptvert(const SculptSession *ss, SculptVertRef vertex);
|
||||
MSculptVert *SCULPT_vertex_get_sculptvert(const SculptSession *ss, PBVHVertRef vertex);
|
||||
|
||||
/**
|
||||
* DEPRECATED: use SCULPT_vertex_check_origdata and SCULPT_vertex_get_sculptvert
|
||||
|
@ -1383,7 +1383,7 @@ void SCULPT_orig_vert_data_init(SculptOrigVertData *data,
|
|||
* DEPRECATED: use SCULPT_vertex_check_origdata and SCULPT_vertex_get_sculptvert
|
||||
* Update a #SculptOrigVertData for a particular vertex from the PBVH iterator.
|
||||
*/
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, SculptVertRef vertex);
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertRef vertex);
|
||||
|
||||
/**
|
||||
* DEPRECATED: use SCULPT_vertex_check_origdata and SCULPT_vertex_get_sculptvert
|
||||
|
@ -1394,8 +1394,8 @@ void SCULPT_orig_vert_data_unode_init(SculptOrigVertData *data,
|
|||
Object *ob,
|
||||
struct SculptUndoNode *unode);
|
||||
|
||||
void SCULPT_face_check_origdata(SculptSession *ss, SculptFaceRef face);
|
||||
bool SCULPT_vertex_check_origdata(SculptSession *ss, SculptVertRef vertex);
|
||||
void SCULPT_face_check_origdata(SculptSession *ss, PBVHFaceRef face);
|
||||
bool SCULPT_vertex_check_origdata(SculptSession *ss, PBVHVertRef vertex);
|
||||
|
||||
/** check that original face set values are up to date
|
||||
* TODO: rename to SCULPT_face_set_original_ensure
|
||||
|
@ -1458,7 +1458,7 @@ void SCULPT_calc_area_normal_and_center(
|
|||
void SCULPT_calc_area_center(
|
||||
Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_co[3]);
|
||||
|
||||
SculptVertRef SCULPT_nearest_vertex_get(struct Sculpt *sd,
|
||||
PBVHVertRef SCULPT_nearest_vertex_get(struct Sculpt *sd,
|
||||
struct Object *ob,
|
||||
const float co[3],
|
||||
float max_distance,
|
||||
|
@ -1553,7 +1553,7 @@ float SCULPT_brush_strength_factor(struct SculptSession *ss,
|
|||
const float vno[3],
|
||||
const float fno[3],
|
||||
const float mask,
|
||||
const SculptVertRef vertex_index,
|
||||
const PBVHVertRef vertex_index,
|
||||
const int thread_id);
|
||||
|
||||
/**
|
||||
|
@ -1584,18 +1584,18 @@ void SCULPT_floodfill_add_initial_with_symmetry(struct Sculpt *sd,
|
|||
struct Object *ob,
|
||||
struct SculptSession *ss,
|
||||
SculptFloodFill *flood,
|
||||
SculptVertRef index,
|
||||
PBVHVertRef index,
|
||||
float radius);
|
||||
|
||||
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, SculptVertRef index);
|
||||
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, PBVHVertRef index);
|
||||
void SCULPT_floodfill_add_and_skip_initial(struct SculptSession *ss,
|
||||
SculptFloodFill *flood,
|
||||
SculptVertRef vertex);
|
||||
PBVHVertRef vertex);
|
||||
void SCULPT_floodfill_execute(struct SculptSession *ss,
|
||||
SculptFloodFill *flood,
|
||||
bool (*func)(SculptSession *ss,
|
||||
SculptVertRef from_v,
|
||||
SculptVertRef to_v,
|
||||
PBVHVertRef from_v,
|
||||
PBVHVertRef to_v,
|
||||
bool is_duplicate,
|
||||
void *userdata),
|
||||
void *userdata);
|
||||
|
@ -1645,7 +1645,7 @@ void SCULPT_combine_transform_proxies(Sculpt *sd, Object *ob);
|
|||
|
||||
float SCULPT_automasking_factor_get(struct AutomaskingCache *automasking,
|
||||
SculptSession *ss,
|
||||
SculptVertRef vert);
|
||||
PBVHVertRef vert);
|
||||
bool SCULPT_automasking_needs_normal(const SculptSession *ss, const Brush *brush);
|
||||
|
||||
/* Returns the automasking cache depending on the active tool. Used for code that can run both
|
||||
|
@ -1686,14 +1686,14 @@ void SCULPT_boundary_automasking_init(Object *ob,
|
|||
float *SCULPT_geodesic_distances_create(struct Object *ob,
|
||||
struct GSet *initial_vertices,
|
||||
const float limit_radius,
|
||||
SculptVertRef *r_closest_verts,
|
||||
PBVHVertRef *r_closest_verts,
|
||||
float (*vertco_override)[3]);
|
||||
float *SCULPT_geodesic_from_vertex_and_symm(struct Sculpt *sd,
|
||||
struct Object *ob,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const float limit_radius);
|
||||
float *SCULPT_geodesic_from_vertex(Object *ob,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const float limit_radius);
|
||||
|
||||
/** \} */
|
||||
|
@ -1820,18 +1820,18 @@ void SCULPT_bmesh_four_neighbor_average(SculptSession *ss,
|
|||
|
||||
void SCULPT_neighbor_coords_average(SculptSession *ss,
|
||||
float result[3],
|
||||
SculptVertRef index,
|
||||
PBVHVertRef index,
|
||||
float projection,
|
||||
bool check_fsets,
|
||||
bool weighted);
|
||||
float SCULPT_neighbor_mask_average(SculptSession *ss, SculptVertRef index);
|
||||
void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], SculptVertRef index);
|
||||
float SCULPT_neighbor_mask_average(SculptSession *ss, PBVHVertRef index);
|
||||
void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], PBVHVertRef index);
|
||||
|
||||
/* Mask the mesh boundaries smoothing only the mesh surface without using automasking. */
|
||||
|
||||
void SCULPT_neighbor_coords_average_interior(SculptSession *ss,
|
||||
float result[3],
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
SculptSmoothArgs *args);
|
||||
|
||||
BLI_INLINE bool SCULPT_need_reproject(SculptSession *ss)
|
||||
|
@ -1840,7 +1840,7 @@ BLI_INLINE bool SCULPT_need_reproject(SculptSession *ss)
|
|||
}
|
||||
|
||||
void SCULPT_reproject_cdata(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float origco[3],
|
||||
float origno[3]);
|
||||
|
||||
|
@ -1863,7 +1863,7 @@ void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
|
|||
float *disp,
|
||||
const float co[3],
|
||||
struct SculptCustomLayer *scl,
|
||||
const SculptVertRef v_index,
|
||||
const PBVHVertRef v_index,
|
||||
const float origco[3],
|
||||
const float alpha,
|
||||
const float projection,
|
||||
|
@ -1873,7 +1873,7 @@ void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
|
|||
void SCULPT_surface_smooth_displace_step(SculptSession *ss,
|
||||
float *co,
|
||||
struct SculptCustomLayer *scl,
|
||||
const SculptVertRef v_index,
|
||||
const PBVHVertRef v_index,
|
||||
const float beta,
|
||||
const float fade);
|
||||
|
||||
|
@ -2098,7 +2098,7 @@ void SCULPT_pose_ik_chain_free(struct SculptPoseIKChain *ik_chain);
|
|||
struct SculptBoundary *SCULPT_boundary_data_init(struct Sculpt *sd,
|
||||
Object *object,
|
||||
Brush *brush,
|
||||
const SculptVertRef initial_vertex,
|
||||
const PBVHVertRef initial_vertex,
|
||||
const float radius);
|
||||
void SCULPT_boundary_data_free(struct SculptBoundary *boundary);
|
||||
|
||||
|
@ -2320,15 +2320,15 @@ void SCULPT_OT_brush_stroke(struct wmOperatorType *ot);
|
|||
/* end sculpt_ops.c */
|
||||
|
||||
SculptBoundaryType SCULPT_edge_is_boundary(const SculptSession *ss,
|
||||
const SculptEdgeRef edge,
|
||||
const PBVHEdgeRef edge,
|
||||
SculptBoundaryType typemask);
|
||||
void SCULPT_edge_get_verts(const SculptSession *ss,
|
||||
const SculptEdgeRef edge,
|
||||
SculptVertRef *r_v1,
|
||||
SculptVertRef *r_v2);
|
||||
SculptVertRef SCULPT_edge_other_vertex(const SculptSession *ss,
|
||||
const SculptEdgeRef edge,
|
||||
const SculptVertRef vertex);
|
||||
const PBVHEdgeRef edge,
|
||||
PBVHVertRef *r_v1,
|
||||
PBVHVertRef *r_v2);
|
||||
PBVHVertRef SCULPT_edge_other_vertex(const SculptSession *ss,
|
||||
const PBVHEdgeRef edge,
|
||||
const PBVHVertRef vertex);
|
||||
|
||||
#define SCULPT_REPLAY
|
||||
#ifdef SCULPT_REPLAY
|
||||
|
@ -2420,7 +2420,7 @@ void SCULPT_update_customdata_refs(SculptSession *ss, Object *ob);
|
|||
* layer is actually freed */
|
||||
void SCULPT_clear_scl_pointers(SculptSession *ss);
|
||||
|
||||
static inline void *SCULPT_attr_vertex_data(const SculptVertRef vertex,
|
||||
static inline void *SCULPT_attr_vertex_data(const PBVHVertRef vertex,
|
||||
const SculptCustomLayer *scl)
|
||||
{
|
||||
if (scl->data) {
|
||||
|
@ -2443,7 +2443,7 @@ static inline void *SCULPT_attr_vertex_data(const SculptVertRef vertex,
|
|||
}
|
||||
|
||||
// arg, duplicate functions!
|
||||
static inline void *SCULPT_attr_face_data(const SculptFaceRef vertex, const SculptCustomLayer *scl)
|
||||
static inline void *SCULPT_attr_face_data(const PBVHFaceRef vertex, const SculptCustomLayer *scl)
|
||||
{
|
||||
if (scl->data) {
|
||||
char *p = (char *)scl->data;
|
||||
|
@ -2533,7 +2533,7 @@ BrushChannel *SCULPT_get_final_channel_intern(const SculptSession *ss,
|
|||
|
||||
/** \} */
|
||||
|
||||
float SCULPT_calc_concavity(SculptSession *ss, SculptVertRef vref);
|
||||
float SCULPT_calc_concavity(SculptSession *ss, PBVHVertRef vref);
|
||||
|
||||
/*
|
||||
If useAccurateSolver is false, a faster but less accurate
|
||||
|
@ -2541,13 +2541,13 @@ power solver will be used. If true then BLI_eigen_solve_selfadjoint_m3
|
|||
will be called.
|
||||
*/
|
||||
bool SCULPT_calc_principle_curvatures(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
SculptCurvatureData *out,
|
||||
bool useAccurateSolver);
|
||||
|
||||
void SCULPT_curvature_begin(SculptSession *ss, struct PBVHNode *node, bool useAccurateSolver);
|
||||
void SCULPT_curvature_dir_get(SculptSession *ss,
|
||||
SculptVertRef v,
|
||||
PBVHVertRef v,
|
||||
float dir[3],
|
||||
bool useAccurateSolver);
|
||||
|
||||
|
@ -2555,12 +2555,12 @@ void SCULPT_curvature_dir_get(SculptSession *ss,
|
|||
/** \name Cotangent API
|
||||
* \{ */
|
||||
|
||||
bool SCULPT_dyntopo_check_disk_sort(SculptSession *ss, SculptVertRef vertex);
|
||||
bool SCULPT_dyntopo_check_disk_sort(SculptSession *ss, PBVHVertRef vertex);
|
||||
void SCULT_dyntopo_flag_all_disk_sort(SculptSession *ss);
|
||||
|
||||
// call SCULPT_cotangents_begin in the main thread before any calls to this function
|
||||
void SCULPT_dyntopo_get_cotangents(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float *r_ws,
|
||||
float *r_cot1,
|
||||
float *r_cot2,
|
||||
|
@ -2569,7 +2569,7 @@ void SCULPT_dyntopo_get_cotangents(SculptSession *ss,
|
|||
|
||||
/** call SCULPT_cotangents_begin in the main thread before any calls to this function */
|
||||
void SCULPT_get_cotangents(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float *r_ws,
|
||||
float *r_cot1,
|
||||
float *r_cot2,
|
||||
|
|
|
@ -101,8 +101,8 @@ static void sculpt_expand_task_cb(void *__restrict userdata,
|
|||
int vi = vd.index;
|
||||
float final_mask = *vd.mask;
|
||||
if (data->mask_expand_use_normals) {
|
||||
if (ss->filter_cache->normal_factor[BKE_pbvh_vertex_index_to_table(
|
||||
ss->pbvh, SCULPT_active_vertex_get(ss))] <
|
||||
if (ss->filter_cache
|
||||
->normal_factor[BKE_pbvh_vertex_to_index(ss->pbvh, SCULPT_active_vertex_get(ss))] <
|
||||
ss->filter_cache->normal_factor[vd.index]) {
|
||||
final_mask = 1.0f;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *
|
|||
const float mval_fl[2] = {UNPACK2(event->mval)};
|
||||
if (SCULPT_cursor_geometry_info_update(C, &sgi, mval_fl, false, false)) {
|
||||
/* The cursor is over the mesh, get the update iteration from the updated active vertex. */
|
||||
int vi = BKE_pbvh_vertex_index_to_table(ss->pbvh, SCULPT_active_vertex_get(ss));
|
||||
int vi = BKE_pbvh_vertex_to_index(ss->pbvh, SCULPT_active_vertex_get(ss));
|
||||
mask_expand_update_it = ss->filter_cache->mask_update_it[vi];
|
||||
}
|
||||
else {
|
||||
|
@ -293,15 +293,15 @@ typedef struct MaskExpandFloodFillData {
|
|||
} MaskExpandFloodFillData;
|
||||
|
||||
static bool mask_expand_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef from_vref,
|
||||
SculptVertRef to_vref,
|
||||
PBVHVertRef from_vref,
|
||||
PBVHVertRef to_vref,
|
||||
bool is_duplicate,
|
||||
void *userdata)
|
||||
{
|
||||
MaskExpandFloodFillData *data = userdata;
|
||||
|
||||
int to_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_vref);
|
||||
int from_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_vref);
|
||||
int to_v = BKE_pbvh_vertex_to_index(ss->pbvh, to_vref);
|
||||
int from_v = BKE_pbvh_vertex_to_index(ss->pbvh, from_vref);
|
||||
|
||||
if (!is_duplicate) {
|
||||
int to_it = ss->filter_cache->mask_update_it[from_v] + 1;
|
||||
|
@ -400,7 +400,7 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
else {
|
||||
ss->filter_cache->prev_mask = MEM_callocN(sizeof(float) * vertex_count, "prev mask");
|
||||
for (int i = 0; i < vertex_count; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
ss->filter_cache->prev_mask[i] = SCULPT_vertex_mask_get(ss, vertex);
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
ss->filter_cache->mask_update_last_it = 1;
|
||||
ss->filter_cache->mask_update_current_it = 1;
|
||||
ss->filter_cache
|
||||
->mask_update_it[BKE_pbvh_vertex_index_to_table(ss->pbvh, SCULPT_active_vertex_get(ss))] = 0;
|
||||
->mask_update_it[BKE_pbvh_vertex_to_index(ss->pbvh, SCULPT_active_vertex_get(ss))] = 0;
|
||||
|
||||
copy_v3_v3(ss->filter_cache->mask_expand_initial_co, SCULPT_active_vertex_co_get(ss));
|
||||
|
||||
|
@ -428,7 +428,7 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
if (use_normals) {
|
||||
for (int repeat = 0; repeat < 2; repeat++) {
|
||||
for (int i = 0; i < vertex_count; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
float avg = 0.0f;
|
||||
SculptVertexNeighborIter ni;
|
||||
|
|
|
@ -134,7 +134,7 @@ static int sculpt_set_persistent_base_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
float *co = SCULPT_attr_vertex_data(vertex, scl_co);
|
||||
float *no = SCULPT_attr_vertex_data(vertex, scl_no);
|
||||
|
@ -379,8 +379,8 @@ static void sculpt_init_session(Main *bmain, Depsgraph *depsgraph, Scene *scene,
|
|||
BKE_object_sculpt_data_create(ob);
|
||||
|
||||
ob->sculpt->mode_type = OB_MODE_SCULPT;
|
||||
ob->sculpt->active_face_index.i = SCULPT_REF_NONE;
|
||||
ob->sculpt->active_vertex_index.i = SCULPT_REF_NONE;
|
||||
ob->sculpt->active_face_index.i = PBVH_REF_NONE;
|
||||
ob->sculpt->active_vertex_index.i = PBVH_REF_NONE;
|
||||
|
||||
CustomData_reset(&ob->sculpt->temp_vdata);
|
||||
CustomData_reset(&ob->sculpt->temp_pdata);
|
||||
|
@ -915,7 +915,7 @@ static int sculpt_sample_color_modal(bContext *C, wmOperator *op, const wmEvent
|
|||
|
||||
const bool over_mesh = SCULPT_cursor_geometry_info_update(C, &sgi, sccd->mval, false, false);
|
||||
if (over_mesh) {
|
||||
SculptVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
SCULPT_vertex_color_get(ss, active_vertex, sccd->sampled_color);
|
||||
IMB_colormanagement_scene_linear_to_srgb_v3(sccd->sampled_color, sccd->sampled_color);
|
||||
}
|
||||
|
@ -944,7 +944,7 @@ static int sculpt_sample_color_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
|
||||
BKE_sculpt_update_object_for_edit(CTX_data_depsgraph_pointer(C), ob, true, false, false);
|
||||
|
||||
const SculptVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
const PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
float active_vertex_color[4];
|
||||
|
||||
SCULPT_vertex_color_get(ss, active_vertex, active_vertex_color);
|
||||
|
@ -1073,11 +1073,11 @@ static void do_mask_by_color_contiguous_update_nodes_cb(
|
|||
}
|
||||
|
||||
static bool sculpt_mask_by_color_contiguous_floodfill_cb(
|
||||
SculptSession *ss, SculptVertRef from_v, SculptVertRef to_v, bool is_duplicate, void *userdata)
|
||||
SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool is_duplicate, void *userdata)
|
||||
{
|
||||
MaskByColorContiguousFloodFillData *data = userdata;
|
||||
int to_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v);
|
||||
int from_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_v);
|
||||
int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
|
||||
|
||||
float current_color[4];
|
||||
|
||||
|
@ -1097,7 +1097,7 @@ static bool sculpt_mask_by_color_contiguous_floodfill_cb(
|
|||
}
|
||||
|
||||
static void sculpt_mask_by_color_contiguous(Object *object,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const float threshold,
|
||||
const bool invert,
|
||||
const bool preserve_mask)
|
||||
|
@ -1196,7 +1196,7 @@ static void do_mask_by_color_task_cb(void *__restrict userdata,
|
|||
}
|
||||
|
||||
static void sculpt_mask_by_color_full_mesh(Object *object,
|
||||
const SculptVertRef vertex,
|
||||
const PBVHVertRef vertex,
|
||||
const float threshold,
|
||||
const bool invert,
|
||||
const bool preserve_mask)
|
||||
|
@ -1251,7 +1251,7 @@ static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEven
|
|||
SCULPT_undo_push_begin(ob, "Mask by color");
|
||||
BKE_sculpt_color_layer_create_if_needed(ob);
|
||||
|
||||
const SculptVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
const PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
const float threshold = RNA_float_get(op->ptr, "threshold");
|
||||
const bool invert = RNA_boolean_get(op->ptr, "invert");
|
||||
const bool preserve_mask = RNA_boolean_get(op->ptr, "preserve_previous_mask");
|
||||
|
@ -1367,7 +1367,7 @@ static int sculpt_set_limit_surface_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
const bool weighted = false;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
float *f = SCULPT_attr_vertex_data(vertex, scl);
|
||||
|
||||
SCULPT_neighbor_coords_average(ss, f, vertex, 0.0, true, weighted);
|
||||
|
@ -1537,7 +1537,7 @@ static int sculpt_regularize_rake_exec(bContext *C, wmOperator *op)
|
|||
float tanco[3];
|
||||
add_v3_v3v3(tanco, v2->co, dir2);
|
||||
|
||||
SCULPT_dyntopo_check_disk_sort(ss, (SculptVertRef){.i = (intptr_t)v2});
|
||||
SCULPT_dyntopo_check_disk_sort(ss, (PBVHVertRef){.i = (intptr_t)v2});
|
||||
|
||||
float lastdir3[3];
|
||||
float firstdir3[3];
|
||||
|
|
|
@ -167,7 +167,7 @@ template<typename ImageBuffer> class PaintingKernel {
|
|||
continue;
|
||||
}
|
||||
|
||||
SculptVertRef fakevert = BKE_pbvh_make_vref(0LL);
|
||||
PBVHVertRef fakevert = BKE_pbvh_make_vref(0LL);
|
||||
|
||||
float4 color = image_accessor.read_pixel(image_buffer);
|
||||
const float3 normal(0.0f, 0.0f, 0.0f);
|
||||
|
|
|
@ -138,7 +138,7 @@ static int sculpt_poly_loop_opposite_edge_in_quad(SculptSession *ss,
|
|||
return ss->mloop[ss->mpoly[poly].loopstart + next_edge_index_in_poly].e;
|
||||
}
|
||||
|
||||
SculptEdgeRef sculpt_poly_loop_initial_edge_from_cursor(Object *ob)
|
||||
PBVHEdgeRef sculpt_poly_loop_initial_edge_from_cursor(Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
|
@ -151,7 +151,7 @@ SculptEdgeRef sculpt_poly_loop_initial_edge_from_cursor(Object *ob)
|
|||
MPoly *initial_poly = &mesh->mpoly[ss->active_face_index.i];
|
||||
|
||||
if (initial_poly->totloop != 4) {
|
||||
return (SculptEdgeRef){.i = SCULPT_REF_NONE};
|
||||
return (PBVHEdgeRef){.i = PBVH_REF_NONE};
|
||||
}
|
||||
|
||||
int closest_vert = mesh->mloop[initial_poly->loopstart].v;
|
||||
|
@ -178,7 +178,7 @@ SculptEdgeRef sculpt_poly_loop_initial_edge_from_cursor(Object *ob)
|
|||
closest_vert_on_initial_edge = other_vert;
|
||||
}
|
||||
}
|
||||
return (SculptEdgeRef){.i = initial_edge};
|
||||
return (PBVHEdgeRef){.i = initial_edge};
|
||||
}
|
||||
|
||||
static void sculpt_poly_loop_iterate_and_fill(SculptSession *ss,
|
||||
|
@ -285,11 +285,11 @@ BLI_bitmap *sculpt_poly_loop_from_cursor(Object *ob)
|
|||
BLI_bitmap *poly_loop = BLI_BITMAP_NEW(mesh->totpoly, "poly loop");
|
||||
|
||||
sculpt_poly_loop_topology_data_ensure(ob);
|
||||
const SculptEdgeRef initial_edge = sculpt_poly_loop_initial_edge_from_cursor(ob);
|
||||
const SculptFaceRef initial_poly = ss->active_face_index;
|
||||
const PBVHEdgeRef initial_edge = sculpt_poly_loop_initial_edge_from_cursor(ob);
|
||||
const PBVHFaceRef initial_poly = ss->active_face_index;
|
||||
|
||||
const int initial_edge_i = BKE_pbvh_edge_index_to_table(ss->pbvh, initial_edge);
|
||||
const int initial_poly_i = BKE_pbvh_face_index_to_table(ss->pbvh, initial_poly);
|
||||
const int initial_edge_i = BKE_pbvh_edge_to_index(ss->pbvh, initial_edge);
|
||||
const int initial_poly_i = BKE_pbvh_face_to_index(ss->pbvh, initial_poly);
|
||||
|
||||
const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
|
||||
for (char symm_it = 0; symm_it <= symm; symm_it++) {
|
||||
|
|
|
@ -436,7 +436,7 @@ typedef struct PoseFloodFillData {
|
|||
int current_face_set;
|
||||
int next_face_set;
|
||||
int prev_face_set;
|
||||
SculptVertRef next_vertex;
|
||||
PBVHVertRef next_vertex;
|
||||
int next_vertex_index;
|
||||
|
||||
bool next_face_set_found;
|
||||
|
@ -468,13 +468,13 @@ typedef struct PoseFloodFillData {
|
|||
} PoseFloodFillData;
|
||||
|
||||
static bool pose_topology_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef UNUSED(from_v),
|
||||
SculptVertRef to_vref,
|
||||
PBVHVertRef UNUSED(from_v),
|
||||
PBVHVertRef to_vref,
|
||||
bool is_duplicate,
|
||||
void *userdata)
|
||||
{
|
||||
PoseFloodFillData *data = userdata;
|
||||
int to_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_vref);
|
||||
int to_v = BKE_pbvh_vertex_to_index(ss->pbvh, to_vref);
|
||||
|
||||
const float *co = SCULPT_vertex_co_get(ss, to_vref);
|
||||
|
||||
|
@ -502,14 +502,14 @@ static bool pose_topology_floodfill_cb(SculptSession *ss,
|
|||
}
|
||||
|
||||
static bool pose_face_sets_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef UNUSED(from_v),
|
||||
SculptVertRef to_v,
|
||||
PBVHVertRef UNUSED(from_v),
|
||||
PBVHVertRef to_v,
|
||||
bool is_duplicate,
|
||||
void *userdata)
|
||||
{
|
||||
PoseFloodFillData *data = userdata;
|
||||
|
||||
const int index = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v);
|
||||
const int index = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
|
||||
bool visit_next = false;
|
||||
|
||||
const float *co = SCULPT_vertex_co_get(ss, to_v);
|
||||
|
@ -738,9 +738,8 @@ static SculptPoseIKChain *pose_ik_chain_init_topology(Sculpt *sd,
|
|||
float next_chain_segment_target[3];
|
||||
|
||||
int totvert = SCULPT_vertex_count_get(ss);
|
||||
SculptVertRef nearest_vertex = SCULPT_nearest_vertex_get(
|
||||
sd, ob, initial_location, FLT_MAX, true);
|
||||
int nearest_vertex_index = BKE_pbvh_vertex_index_to_table(ss->pbvh, nearest_vertex);
|
||||
PBVHVertRef nearest_vertex = SCULPT_nearest_vertex_get(sd, ob, initial_location, FLT_MAX, true);
|
||||
int nearest_vertex_index = BKE_pbvh_vertex_to_index(ss->pbvh, nearest_vertex);
|
||||
|
||||
/* Init the buffers used to keep track of the changes in the pose factors as more segments are
|
||||
* added to the IK chain. */
|
||||
|
@ -825,7 +824,7 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets(
|
|||
int current_face_set = SCULPT_FACE_SET_NONE;
|
||||
int prev_face_set = SCULPT_FACE_SET_NONE;
|
||||
|
||||
SculptVertRef current_vertex = SCULPT_active_vertex_get(ss);
|
||||
PBVHVertRef current_vertex = SCULPT_active_vertex_get(ss);
|
||||
|
||||
for (int s = 0; s < ik_chain->tot_segments; s++) {
|
||||
|
||||
|
@ -887,15 +886,12 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets(
|
|||
return ik_chain;
|
||||
}
|
||||
|
||||
static bool pose_face_sets_fk_find_masked_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef from_vr,
|
||||
SculptVertRef to_vr,
|
||||
bool is_duplicate,
|
||||
void *userdata)
|
||||
static bool pose_face_sets_fk_find_masked_floodfill_cb(
|
||||
SculptSession *ss, PBVHVertRef from_vr, PBVHVertRef to_vr, bool is_duplicate, void *userdata)
|
||||
{
|
||||
PoseFloodFillData *data = userdata;
|
||||
int from_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_vr);
|
||||
int to_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_vr);
|
||||
int from_v = BKE_pbvh_vertex_to_index(ss->pbvh, from_vr);
|
||||
int to_v = BKE_pbvh_vertex_to_index(ss->pbvh, to_vr);
|
||||
|
||||
if (!is_duplicate) {
|
||||
data->floodfill_it[to_v] = data->floodfill_it[from_v] + 1;
|
||||
|
@ -927,13 +923,13 @@ static bool pose_face_sets_fk_find_masked_floodfill_cb(SculptSession *ss,
|
|||
}
|
||||
|
||||
static bool pose_face_sets_fk_set_weights_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef UNUSED(from_v),
|
||||
SculptVertRef to_v,
|
||||
PBVHVertRef UNUSED(from_v),
|
||||
PBVHVertRef to_v,
|
||||
bool UNUSED(is_duplicate),
|
||||
void *userdata)
|
||||
{
|
||||
PoseFloodFillData *data = userdata;
|
||||
data->fk_weights[BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v)] = 1.0f;
|
||||
data->fk_weights[BKE_pbvh_vertex_to_index(ss->pbvh, to_v)] = 1.0f;
|
||||
return !SCULPT_vertex_has_face_set(ss, to_v, data->masked_face_set);
|
||||
}
|
||||
|
||||
|
@ -944,8 +940,8 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
|
|||
|
||||
SculptPoseIKChain *ik_chain = pose_ik_chain_new(1, totvert);
|
||||
|
||||
const SculptVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
const int active_vertex_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, active_vertex);
|
||||
const PBVHVertRef active_vertex = SCULPT_active_vertex_get(ss);
|
||||
const int active_vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, active_vertex);
|
||||
|
||||
const int active_face_set = SCULPT_active_face_set_get(ss);
|
||||
|
||||
|
@ -967,7 +963,7 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
|
|||
int origin_count = 0;
|
||||
float origin_acc[3] = {0.0f};
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (fdata.floodfill_it[i] != 0 &&
|
||||
SCULPT_vertex_has_face_set(ss, vref, fdata.initial_face_set) &&
|
||||
|
@ -981,7 +977,7 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
|
|||
float target_acc[3] = {0.0f};
|
||||
if (fdata.target_face_set != fdata.masked_face_set) {
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vref = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (fdata.floodfill_it[i] != 0 &&
|
||||
SCULPT_vertex_has_face_set(ss, vref, fdata.initial_face_set) &&
|
||||
|
@ -1214,7 +1210,7 @@ static void sculpt_pose_do_bend_deform(SculptSession *ss, Brush *UNUSED(brush))
|
|||
float smd_limit[2];
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (ik_chain->segments[0].weights[i] == 0.0f) {
|
||||
continue;
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
#include "BLI_utildefines.h"
|
||||
|
||||
void SCULPT_reproject_cdata(SculptSession *ss,
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float origco[3],
|
||||
float origno[3])
|
||||
{
|
||||
|
@ -266,7 +266,7 @@ void SCULPT_reproject_cdata(SculptSession *ss,
|
|||
*fakev = *l2->v;
|
||||
fakel->v = fakev;
|
||||
|
||||
SCULPT_vertex_check_origdata(ss, (SculptVertRef){.i = (intptr_t)l2->v});
|
||||
SCULPT_vertex_check_origdata(ss, (PBVHVertRef){.i = (intptr_t)l2->v});
|
||||
|
||||
if (l2->v == v) {
|
||||
copy_v3_v3(fakev->co, origco);
|
||||
|
@ -378,7 +378,7 @@ MINLINE float safe_shell_angle_to_dist(const float angle)
|
|||
|
||||
static void SCULPT_neighbor_coords_average_interior_boundary(SculptSession *ss,
|
||||
float result[3],
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
SculptSmoothArgs *args)
|
||||
{
|
||||
float avg[3] = {0.0f, 0.0f, 0.0f};
|
||||
|
@ -723,7 +723,7 @@ static void SCULPT_neighbor_coords_average_interior_boundary(SculptSession *ss,
|
|||
|
||||
void SCULPT_neighbor_coords_average_interior(SculptSession *ss,
|
||||
float result[3],
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
SculptSmoothArgs *args)
|
||||
{
|
||||
if (args->bound_smooth > 0.0f && args->bound_scl) {
|
||||
|
@ -1064,10 +1064,10 @@ void SCULPT_bmesh_four_neighbor_average(SculptSession *ss,
|
|||
const bool weighted = (ss->cache->brush->flag2 & BRUSH_SMOOTH_USE_AREA_WEIGHT);
|
||||
float *areas;
|
||||
|
||||
SCULPT_vertex_check_origdata(ss, (SculptVertRef){.i = (intptr_t)v});
|
||||
SCULPT_vertex_check_origdata(ss, (PBVHVertRef){.i = (intptr_t)v});
|
||||
|
||||
if (do_origco) {
|
||||
// SCULPT_vertex_check_origdata(ss, (SculptVertRef){.i = (intptr_t)v});
|
||||
// SCULPT_vertex_check_origdata(ss, (PBVHVertRef){.i = (intptr_t)v});
|
||||
madd_v3_v3fl(direction, mv->origno, -dot_v3v3(mv->origno, direction));
|
||||
normalize_v3(direction);
|
||||
}
|
||||
|
@ -1076,7 +1076,7 @@ void SCULPT_bmesh_four_neighbor_average(SculptSession *ss,
|
|||
float *no1 = do_origco ? mv->origno : v->no;
|
||||
|
||||
if (weighted) {
|
||||
SculptVertRef vertex = {.i = (intptr_t)v};
|
||||
PBVHVertRef vertex = {.i = (intptr_t)v};
|
||||
|
||||
int val = SCULPT_vertex_valence_get(ss, vertex);
|
||||
areas = BLI_array_alloca(areas, val * 2);
|
||||
|
@ -1137,7 +1137,7 @@ void SCULPT_bmesh_four_neighbor_average(SculptSession *ss,
|
|||
SculptBoundaryType bflag = SCULPT_BOUNDARY_FACE_SET | SCULPT_BOUNDARY_MESH |
|
||||
SCULPT_BOUNDARY_SHARP | SCULPT_BOUNDARY_SEAM | SCULPT_BOUNDARY_UV;
|
||||
|
||||
int bound = SCULPT_edge_is_boundary(ss, (SculptEdgeRef){.i = (intptr_t)e}, bflag);
|
||||
int bound = SCULPT_edge_is_boundary(ss, (PBVHEdgeRef){.i = (intptr_t)e}, bflag);
|
||||
float dirw = 1.0f;
|
||||
|
||||
if (bound) {
|
||||
|
@ -1261,7 +1261,7 @@ void SCULPT_bmesh_four_neighbor_average(SculptSession *ss,
|
|||
}
|
||||
|
||||
static void sculpt_neighbor_coords_average_fset(
|
||||
SculptSession *ss, float result[3], SculptVertRef vertex, float projection, bool weighted)
|
||||
SculptSession *ss, float result[3], PBVHVertRef vertex, float projection, bool weighted)
|
||||
{
|
||||
float avg[3] = {0.0f, 0.0f, 0.0f};
|
||||
float *co, no[3];
|
||||
|
@ -1331,7 +1331,7 @@ static void sculpt_neighbor_coords_average_fset(
|
|||
|
||||
void SCULPT_neighbor_coords_average(SculptSession *ss,
|
||||
float result[3],
|
||||
SculptVertRef vertex,
|
||||
PBVHVertRef vertex,
|
||||
float projection,
|
||||
bool check_fsets,
|
||||
bool weighted)
|
||||
|
@ -1420,7 +1420,7 @@ void SCULPT_neighbor_coords_average(SculptSession *ss,
|
|||
}
|
||||
}
|
||||
|
||||
float SCULPT_neighbor_mask_average(SculptSession *ss, SculptVertRef index)
|
||||
float SCULPT_neighbor_mask_average(SculptSession *ss, PBVHVertRef index)
|
||||
{
|
||||
float avg = 0.0f;
|
||||
int total = 0;
|
||||
|
@ -1438,7 +1438,7 @@ float SCULPT_neighbor_mask_average(SculptSession *ss, SculptVertRef index)
|
|||
return SCULPT_vertex_mask_get(ss, index);
|
||||
}
|
||||
|
||||
void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], SculptVertRef vertex)
|
||||
void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], PBVHVertRef vertex)
|
||||
{
|
||||
float avg[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
float total = 0.0f;
|
||||
|
@ -1703,7 +1703,7 @@ void SCULPT_enhance_details_brush(
|
|||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
float avg[3];
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
float *dir = SCULPT_attr_vertex_data(vertex, &scl);
|
||||
float no[3];
|
||||
|
||||
|
@ -1726,7 +1726,7 @@ void SCULPT_enhance_details_brush(
|
|||
for (int i = 0; i < totvert; i++) {
|
||||
float avg[3] = {0.0f, 0.0f, 0.0f};
|
||||
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
|
||||
float *dir = SCULPT_attr_vertex_data(vertex, &scl);
|
||||
float tot = 0.0f;
|
||||
float *areas = NULL;
|
||||
|
@ -2171,7 +2171,7 @@ void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
|
|||
float *disp,
|
||||
const float co[3],
|
||||
SculptCustomLayer *scl,
|
||||
const SculptVertRef v_index,
|
||||
const PBVHVertRef v_index,
|
||||
const float origco[3],
|
||||
const float alpha,
|
||||
const float projection,
|
||||
|
@ -2183,7 +2183,7 @@ void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
|
|||
SCULPT_neighbor_coords_average(
|
||||
ss, laplacian_smooth_co, v_index, projection, check_fsets, weighted);
|
||||
|
||||
// int index = BKE_pbvh_vertex_index_to_table(ss->pbvh, v_index);
|
||||
// int index = BKE_pbvh_vertex_to_index(ss->pbvh, v_index);
|
||||
|
||||
mul_v3_v3fl(weigthed_o, origco, alpha);
|
||||
mul_v3_v3fl(weigthed_q, co, 1.0f - alpha);
|
||||
|
@ -2196,14 +2196,14 @@ void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
|
|||
void SCULPT_surface_smooth_displace_step(SculptSession *ss,
|
||||
float *co,
|
||||
SculptCustomLayer *scl,
|
||||
const SculptVertRef v_index,
|
||||
const PBVHVertRef v_index,
|
||||
const float beta,
|
||||
const float fade)
|
||||
{
|
||||
float b_avg[3] = {0.0f, 0.0f, 0.0f};
|
||||
float b_current_vertex[3];
|
||||
int total = 0;
|
||||
// int index = BKE_pbvh_vertex_index_to_table(ss->pbvh, v_index);
|
||||
// int index = BKE_pbvh_vertex_to_index(ss->pbvh, v_index);
|
||||
|
||||
SculptVertexNeighborIter ni;
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, v_index, ni) {
|
||||
|
|
|
@ -231,8 +231,7 @@ static void do_shape_symmetrize_brush_task_cb(void *__restrict userdata,
|
|||
}
|
||||
|
||||
const int symmetrical_index = ss->vertex_info.symmetrize_map[vd.index];
|
||||
const SculptVertRef symmetrical_vertex = BKE_pbvh_table_index_to_vertex(ss->pbvh,
|
||||
symmetrical_index);
|
||||
const PBVHVertRef symmetrical_vertex = BKE_pbvh_index_to_vertex(ss->pbvh, symmetrical_index);
|
||||
|
||||
if (symmetrical_index == -1) {
|
||||
continue;
|
||||
|
|
|
@ -221,7 +221,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
|||
SculptSession *ss = ob->sculpt;
|
||||
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
|
||||
MVert *mvert;
|
||||
SculptVertRef *index;
|
||||
PBVHVertRef *index;
|
||||
|
||||
if (unode->maxvert) {
|
||||
/* Regular mesh restore. */
|
||||
|
@ -410,7 +410,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
|
|||
SculptSession *ss = ob->sculpt;
|
||||
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
|
||||
float *vmask;
|
||||
SculptVertRef *index;
|
||||
PBVHVertRef *index;
|
||||
|
||||
if (unode->maxvert) {
|
||||
/* Regular mesh restore. */
|
||||
|
|
Loading…
Reference in New Issue