Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/blenkernel/BKE_pbvh.h
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/blenkernel/BKE_pbvh.h')
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h386
1 files changed, 211 insertions, 175 deletions
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index fa779f48e79..049fc585b56 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -45,7 +45,7 @@ typedef struct PBVH PBVH;
typedef struct PBVHNode PBVHNode;
typedef struct {
- float (*co)[3];
+ float (*co)[3];
} PBVHProxyNode;
/* Callbacks */
@@ -61,16 +61,27 @@ typedef void (*BKE_pbvh_SearchNearestCallback)(PBVHNode *node, void *data, float
/* Building */
PBVH *BKE_pbvh_new(void);
-void BKE_pbvh_build_mesh(
- PBVH *bvh,
- const struct MPoly *mpoly, const struct MLoop *mloop,
- struct MVert *verts, int totvert, struct CustomData *vdata,
- const struct MLoopTri *looptri, int looptri_num);
-void BKE_pbvh_build_grids(PBVH *bvh, struct CCGElem **grid_elems,
+void BKE_pbvh_build_mesh(PBVH *bvh,
+ const struct MPoly *mpoly,
+ const struct MLoop *mloop,
+ struct MVert *verts,
+ int totvert,
+ struct CustomData *vdata,
+ const struct MLoopTri *looptri,
+ int looptri_num);
+void BKE_pbvh_build_grids(PBVH *bvh,
+ struct CCGElem **grid_elems,
int totgrid,
- struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats,
+ struct CCGKey *key,
+ void **gridfaces,
+ struct DMFlagMat *flagmats,
unsigned int **grid_hidden);
-void BKE_pbvh_build_bmesh(PBVH *bvh, struct BMesh *bm, bool smooth_shading, struct BMLog *log, const int cd_vert_node_offset, const int cd_face_node_offset);
+void BKE_pbvh_build_bmesh(PBVH *bvh,
+ struct BMesh *bm,
+ bool smooth_shading,
+ struct BMLog *log,
+ const int cd_vert_node_offset,
+ const int cd_face_node_offset);
void BKE_pbvh_free(PBVH *bvh);
void BKE_pbvh_free_layer_disp(PBVH *bvh);
@@ -79,64 +90,81 @@ void BKE_pbvh_free_layer_disp(PBVH *bvh);
* - gather nodes in an array (easy to multithread) */
void BKE_pbvh_search_callback(PBVH *bvh,
- BKE_pbvh_SearchCallback scb, void *search_data,
- BKE_pbvh_HitCallback hcb, void *hit_data);
+ BKE_pbvh_SearchCallback scb,
+ void *search_data,
+ BKE_pbvh_HitCallback hcb,
+ void *hit_data);
-void BKE_pbvh_search_gather(PBVH *bvh,
- BKE_pbvh_SearchCallback scb, void *search_data,
- PBVHNode ***array, int *tot);
+void BKE_pbvh_search_gather(
+ PBVH *bvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***array, int *tot);
/* Raycast
* the hit callback is called for all leaf nodes intersecting the ray;
* it's up to the callback to find the primitive within the leaves that is
* hit first */
-void BKE_pbvh_raycast(
- PBVH *bvh, BKE_pbvh_HitOccludedCallback cb, void *data,
- const float ray_start[3], const float ray_normal[3],
- bool original);
-
-bool BKE_pbvh_node_raycast(
- PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco,
- const float ray_start[3], const float ray_normal[3],
- float *depth);
-
-bool BKE_pbvh_bmesh_node_raycast_detail(
- PBVHNode *node,
- const float ray_start[3], const float ray_normal[3],
- float *depth, float *r_edge_length);
+void BKE_pbvh_raycast(PBVH *bvh,
+ BKE_pbvh_HitOccludedCallback cb,
+ void *data,
+ const float ray_start[3],
+ const float ray_normal[3],
+ bool original);
+
+bool BKE_pbvh_node_raycast(PBVH *bvh,
+ PBVHNode *node,
+ float (*origco)[3],
+ bool use_origco,
+ const float ray_start[3],
+ const float ray_normal[3],
+ float *depth);
+
+bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node,
+ const float ray_start[3],
+ const float ray_normal[3],
+ float *depth,
+ float *r_edge_length);
/* for orthographic cameras, project the far away ray segment points to the root node so
* we can have better precision. */
void BKE_pbvh_raycast_project_ray_root(
- PBVH *bvh, bool original,
- float ray_start[3], float ray_end[3], float ray_normal[3]);
-
-void BKE_pbvh_find_nearest_to_ray(
- PBVH *bvh, BKE_pbvh_HitOccludedCallback cb, void *data,
- const float ray_start[3], const float ray_normal[3],
- bool original);
-
-bool BKE_pbvh_node_find_nearest_to_ray(
- PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco,
- const float ray_start[3], const float ray_normal[3],
- float *depth, float *dist_sq);
+ PBVH *bvh, bool original, float ray_start[3], float ray_end[3], float ray_normal[3]);
+
+void BKE_pbvh_find_nearest_to_ray(PBVH *bvh,
+ BKE_pbvh_HitOccludedCallback cb,
+ void *data,
+ const float ray_start[3],
+ const float ray_normal[3],
+ bool original);
+
+bool BKE_pbvh_node_find_nearest_to_ray(PBVH *bvh,
+ PBVHNode *node,
+ float (*origco)[3],
+ bool use_origco,
+ const float ray_start[3],
+ const float ray_normal[3],
+ float *depth,
+ float *dist_sq);
/* Drawing */
-void BKE_pbvh_draw_cb(
- PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, bool wires, bool only_mask,
- void (*draw_fn)(void *user_data, struct GPUBatch *batch), void *user_data);
+void BKE_pbvh_draw_cb(PBVH *bvh,
+ float (*planes)[4],
+ float (*fnors)[3],
+ bool fast,
+ bool wires,
+ bool only_mask,
+ void (*draw_fn)(void *user_data, struct GPUBatch *batch),
+ void *user_data);
/* PBVH Access */
typedef enum {
- PBVH_FACES,
- PBVH_GRIDS,
- PBVH_BMESH,
+ PBVH_FACES,
+ PBVH_GRIDS,
+ PBVH_BMESH,
} PBVHType;
PBVHType BKE_pbvh_type(const PBVH *bvh);
-bool BKE_pbvh_has_faces(const PBVH *bvh);
+bool BKE_pbvh_has_faces(const PBVH *bvh);
/* Get the PBVH root's bounding box */
void BKE_pbvh_bounding_box(const PBVH *bvh, float min[3], float max[3]);
@@ -145,7 +173,8 @@ void BKE_pbvh_bounding_box(const PBVH *bvh, float min[3], float max[3]);
unsigned int **BKE_pbvh_grid_hidden(const PBVH *bvh);
int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
- int *grid_indices, int totgrid,
+ int *grid_indices,
+ int totgrid,
int gridsize);
/* multires level, only valid for type == PBVH_GRIDS */
@@ -158,29 +187,32 @@ struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh);
void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size);
typedef enum {
- PBVH_Subdivide = 1,
- PBVH_Collapse = 2,
+ PBVH_Subdivide = 1,
+ PBVH_Collapse = 2,
} PBVHTopologyUpdateMode;
-bool BKE_pbvh_bmesh_update_topology(
- PBVH *bvh, PBVHTopologyUpdateMode mode,
- const float center[3], const float view_normal[3],
- float radius, const bool use_frontface, const bool use_projected);
+bool BKE_pbvh_bmesh_update_topology(PBVH *bvh,
+ PBVHTopologyUpdateMode mode,
+ const float center[3],
+ const float view_normal[3],
+ float radius,
+ const bool use_frontface,
+ const bool use_projected);
/* Node Access */
typedef enum {
- PBVH_Leaf = 1,
+ PBVH_Leaf = 1,
- PBVH_UpdateNormals = 2,
- PBVH_UpdateBB = 4,
- PBVH_UpdateOriginalBB = 8,
- PBVH_UpdateDrawBuffers = 16,
- PBVH_UpdateRedraw = 32,
+ PBVH_UpdateNormals = 2,
+ PBVH_UpdateBB = 4,
+ PBVH_UpdateOriginalBB = 8,
+ PBVH_UpdateDrawBuffers = 16,
+ PBVH_UpdateRedraw = 32,
- PBVH_RebuildDrawBuffers = 64,
- PBVH_FullyHidden = 128,
+ PBVH_RebuildDrawBuffers = 64,
+ PBVH_FullyHidden = 128,
- PBVH_UpdateTopology = 256,
+ PBVH_UpdateTopology = 256,
} PBVHNodeFlags;
void BKE_pbvh_node_mark_update(PBVHNode *node);
@@ -190,16 +222,18 @@ void BKE_pbvh_node_mark_normals_update(PBVHNode *node);
void BKE_pbvh_node_mark_topology_update(PBVHNode *node);
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
-void BKE_pbvh_node_get_grids(
- PBVH *bvh, PBVHNode *node,
- int **grid_indices, int *totgrid, int *maxgrid, int *gridsize,
- struct CCGElem ***grid_elems);
-void BKE_pbvh_node_num_verts(
- PBVH *bvh, PBVHNode *node,
- int *r_uniquevert, int *r_totvert);
-void BKE_pbvh_node_get_verts(
- PBVH *bvh, PBVHNode *node,
- const int **r_vert_indices, struct MVert **r_verts);
+void BKE_pbvh_node_get_grids(PBVH *bvh,
+ PBVHNode *node,
+ int **grid_indices,
+ int *totgrid,
+ int *maxgrid,
+ int *gridsize,
+ struct CCGElem ***grid_elems);
+void BKE_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *r_uniquevert, int *r_totvert);
+void BKE_pbvh_node_get_verts(PBVH *bvh,
+ PBVHNode *node,
+ const int **r_vert_indices,
+ struct MVert **r_verts);
void BKE_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
void BKE_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
@@ -222,9 +256,11 @@ void BKE_pbvh_bmesh_after_stroke(PBVH *bvh);
void BKE_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]);
void BKE_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]);
void BKE_pbvh_get_grid_updates(PBVH *bvh, bool clear, void ***r_gridfaces, int *r_totface);
-void BKE_pbvh_grids_update(PBVH *bvh, struct CCGElem **grid_elems,
+void BKE_pbvh_grids_update(PBVH *bvh,
+ struct CCGElem **grid_elems,
void **gridfaces,
- struct DMFlagMat *flagmats, unsigned int **grid_hidden);
+ struct DMFlagMat *flagmats,
+ unsigned int **grid_hidden);
/* Layer displacement */
@@ -247,118 +283,118 @@ bool BKE_pbvh_isDeformed(struct PBVH *pbvh);
/* note: PBVH_ITER_ALL does not skip hidden vertices,
* PBVH_ITER_UNIQUE does */
-#define PBVH_ITER_ALL 0
-#define PBVH_ITER_UNIQUE 1
+#define PBVH_ITER_ALL 0
+#define PBVH_ITER_UNIQUE 1
typedef struct PBVHVertexIter {
- /* iteration */
- int g;
- int width;
- int height;
- int gx;
- int gy;
- int i;
-
- /* grid */
- struct CCGElem **grids;
- struct CCGElem *grid;
- struct CCGKey *key;
- BLI_bitmap **grid_hidden, *gh;
- int *grid_indices;
- int totgrid;
- int gridsize;
-
- /* mesh */
- struct MVert *mverts;
- int totvert;
- const int *vert_indices;
- float *vmask;
-
- /* bmesh */
- struct GSetIterator bm_unique_verts;
- struct GSetIterator bm_other_verts;
- struct CustomData *bm_vdata;
- int cd_vert_mask_offset;
-
- /* result: these are all computed in the macro, but we assume
- * that compiler optimization's will skip the ones we don't use */
- struct MVert *mvert;
- struct BMVert *bm_vert;
- float *co;
- short *no;
- float *fno;
- float *mask;
+ /* iteration */
+ int g;
+ int width;
+ int height;
+ int gx;
+ int gy;
+ int i;
+
+ /* grid */
+ struct CCGElem **grids;
+ struct CCGElem *grid;
+ struct CCGKey *key;
+ BLI_bitmap **grid_hidden, *gh;
+ int *grid_indices;
+ int totgrid;
+ int gridsize;
+
+ /* mesh */
+ struct MVert *mverts;
+ int totvert;
+ const int *vert_indices;
+ float *vmask;
+
+ /* bmesh */
+ struct GSetIterator bm_unique_verts;
+ struct GSetIterator bm_other_verts;
+ struct CustomData *bm_vdata;
+ int cd_vert_mask_offset;
+
+ /* result: these are all computed in the macro, but we assume
+ * that compiler optimization's will skip the ones we don't use */
+ struct MVert *mvert;
+ struct BMVert *bm_vert;
+ float *co;
+ short *no;
+ float *fno;
+ float *mask;
} PBVHVertexIter;
-void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
- PBVHVertexIter *vi, int mode);
+void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mode);
#define BKE_pbvh_vertex_iter_begin(bvh, node, vi, mode) \
- pbvh_vertex_iter_init(bvh, node, &vi, mode); \
- \
- for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
- if (vi.grids) { \
- vi.width = vi.gridsize; \
- vi.height = vi.gridsize; \
- vi.grid = vi.grids[vi.grid_indices[vi.g]]; \
- if (mode == PBVH_ITER_UNIQUE) \
- vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \
- } \
- else { \
- vi.width = vi.totvert; \
- vi.height = 1; \
- } \
- \
- for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
- for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
- if (vi.grid) { \
- vi.co = CCG_elem_co(vi.key, vi.grid); \
- vi.fno = CCG_elem_no(vi.key, vi.grid); \
- vi.mask = vi.key->has_mask ? CCG_elem_mask(vi.key, vi.grid) : NULL; \
- vi.grid = CCG_elem_next(vi.key, vi.grid); \
- if (vi.gh) { \
- if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) \
- continue; \
- } \
- } \
- else if (vi.mverts) { \
- vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \
- if (mode == PBVH_ITER_UNIQUE && vi.mvert->flag & ME_HIDE) \
- continue; \
- vi.co = vi.mvert->co; \
- vi.no = vi.mvert->no; \
- if (vi.vmask) \
- vi.mask = &vi.vmask[vi.vert_indices[vi.gx]]; \
- } \
- else { \
- if (!BLI_gsetIterator_done(&vi.bm_unique_verts)) {\
- vi.bm_vert = BLI_gsetIterator_getKey(&vi.bm_unique_verts); \
- BLI_gsetIterator_step(&vi.bm_unique_verts); \
- } \
- else { \
- vi.bm_vert = BLI_gsetIterator_getKey(&vi.bm_other_verts); \
- BLI_gsetIterator_step(&vi.bm_other_verts); \
- } \
- if (mode == PBVH_ITER_UNIQUE && \
- BM_elem_flag_test(vi.bm_vert, BM_ELEM_HIDDEN)) \
- continue; \
- vi.co = vi.bm_vert->co; \
- vi.fno = vi.bm_vert->no; \
- vi.mask = BM_ELEM_CD_GET_VOID_P(vi.bm_vert, vi.cd_vert_mask_offset); \
- }
+ pbvh_vertex_iter_init(bvh, node, &vi, mode); \
+\
+ for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
+ if (vi.grids) { \
+ vi.width = vi.gridsize; \
+ vi.height = vi.gridsize; \
+ vi.grid = vi.grids[vi.grid_indices[vi.g]]; \
+ if (mode == PBVH_ITER_UNIQUE) \
+ vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \
+ } \
+ else { \
+ vi.width = vi.totvert; \
+ vi.height = 1; \
+ } \
+\
+ for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
+ for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
+ if (vi.grid) { \
+ vi.co = CCG_elem_co(vi.key, vi.grid); \
+ vi.fno = CCG_elem_no(vi.key, vi.grid); \
+ vi.mask = vi.key->has_mask ? CCG_elem_mask(vi.key, vi.grid) : NULL; \
+ vi.grid = CCG_elem_next(vi.key, vi.grid); \
+ if (vi.gh) { \
+ if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) \
+ continue; \
+ } \
+ } \
+ else if (vi.mverts) { \
+ vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \
+ if (mode == PBVH_ITER_UNIQUE && vi.mvert->flag & ME_HIDE) \
+ continue; \
+ vi.co = vi.mvert->co; \
+ vi.no = vi.mvert->no; \
+ if (vi.vmask) \
+ vi.mask = &vi.vmask[vi.vert_indices[vi.gx]]; \
+ } \
+ else { \
+ if (!BLI_gsetIterator_done(&vi.bm_unique_verts)) { \
+ vi.bm_vert = BLI_gsetIterator_getKey(&vi.bm_unique_verts); \
+ BLI_gsetIterator_step(&vi.bm_unique_verts); \
+ } \
+ else { \
+ vi.bm_vert = BLI_gsetIterator_getKey(&vi.bm_other_verts); \
+ BLI_gsetIterator_step(&vi.bm_other_verts); \
+ } \
+ if (mode == PBVH_ITER_UNIQUE && BM_elem_flag_test(vi.bm_vert, BM_ELEM_HIDDEN)) \
+ continue; \
+ vi.co = vi.bm_vert->co; \
+ vi.fno = vi.bm_vert->no; \
+ vi.mask = BM_ELEM_CD_GET_VOID_P(vi.bm_vert, vi.cd_vert_mask_offset); \
+ }
#define BKE_pbvh_vertex_iter_end \
- } \
- } \
- } ((void)0)
+ } \
+ } \
+ } \
+ ((void)0)
void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count);
void BKE_pbvh_node_free_proxies(PBVHNode *node);
PBVHProxyNode *BKE_pbvh_node_add_proxy(PBVH *bvh, PBVHNode *node);
-void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes, int *totnode);
-void BKE_pbvh_node_get_bm_orco_data(
- PBVHNode *node,
- int (**r_orco_tris)[3], int *r_orco_tris_num, float (**r_orco_coords)[3]);
+void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes, int *totnode);
+void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node,
+ int (**r_orco_tris)[3],
+ int *r_orco_tris_num,
+ float (**r_orco_coords)[3]);
bool BKE_pbvh_node_vert_update_check_any(PBVH *bvh, PBVHNode *node);