Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions

pbvh.c File Reference

#include "DNA_meshdata_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_pbvh.h"
#include "BKE_DerivedMesh.h"
#include "BKE_mesh.h"
#include "BKE_global.h"
#include "GPU_buffers.h"

Go to the source code of this file.

Classes

struct  BB
struct  BBC
struct  PBVHNode
struct  PBVH
struct  PBVHStack
struct  PBVHIter
struct  node_tree
struct  RaycastData

Defines

#define LEAF_LIMIT   10000
#define STACK_FIXED_DEPTH   100

Typedefs

typedef char * BLI_bitmap
typedef struct PBVHStack PBVHStack
typedef struct PBVHIter PBVHIter
typedef struct node_tree node_tree

Functions

static BLI_bitmap BLI_bitmap_new (int tot)
static int BLI_bitmap_get (BLI_bitmap b, int index)
static void BLI_bitmap_set (BLI_bitmap b, int index)
static void BB_reset (BB *bb)
static void BB_expand (BB *bb, float co[3])
static void BB_expand_with_bb (BB *bb, BB *bb2)
static int BB_widest_axis (BB *bb)
static void BBC_update_centroid (BBC *bbc)
static void update_node_vb (PBVH *bvh, PBVHNode *node)
static int partition_indices (int *prim_indices, int lo, int hi, int axis, float mid, BBC *prim_bbc)
static void check_partitioning (int *prim_indices, int lo, int hi, int axis, float mid, BBC *prim_bbc, int index_of_2nd_partition)
static void grow_nodes (PBVH *bvh, int totnode)
static int map_insert_vert (PBVH *bvh, GHash *map, unsigned int *face_verts, unsigned int *uniq_verts, int vertex)
static void build_mesh_leaf_node (PBVH *bvh, PBVHNode *node)
static void build_grids_leaf_node (PBVH *bvh, PBVHNode *node)
static void build_sub (PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc, int offset, int count)
static void pbvh_build (PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim)
void BLI_pbvh_build_mesh (PBVH *bvh, MFace *faces, MVert *verts, int totface, int totvert)
void BLI_pbvh_build_grids (PBVH *bvh, DMGridData **grids, DMGridAdjacency *gridadj, int totgrid, int gridsize, void **gridfaces)
PBVHBLI_pbvh_new (void)
void BLI_pbvh_free (PBVH *bvh)
static void pbvh_iter_begin (PBVHIter *iter, PBVH *bvh, BLI_pbvh_SearchCallback scb, void *search_data)
static void pbvh_iter_end (PBVHIter *iter)
static void pbvh_stack_push (PBVHIter *iter, PBVHNode *node, int revisiting)
static PBVHNodepbvh_iter_next (PBVHIter *iter)
static PBVHNodepbvh_iter_next_occluded (PBVHIter *iter)
void BLI_pbvh_search_gather (PBVH *bvh, BLI_pbvh_SearchCallback scb, void *search_data, PBVHNode ***r_array, int *r_tot)
void BLI_pbvh_search_callback (PBVH *bvh, BLI_pbvh_SearchCallback scb, void *search_data, BLI_pbvh_HitCallback hcb, void *hit_data)
static void node_tree_insert (node_tree *tree, node_tree *new_node)
static void traverse_tree (node_tree *tree, BLI_pbvh_HitOccludedCallback hcb, void *hit_data, float *tmin)
static void free_tree (node_tree *tree)
float BLI_pbvh_node_get_tmin (PBVHNode *node)
static void BLI_pbvh_search_callback_occluded (PBVH *bvh, BLI_pbvh_SearchCallback scb, void *search_data, BLI_pbvh_HitOccludedCallback hcb, void *hit_data)
static int update_search_cb (PBVHNode *node, void *data_v)
static void pbvh_update_normals (PBVH *bvh, PBVHNode **nodes, int totnode, float(*face_nors)[3])
static void pbvh_update_BB_redraw (PBVH *bvh, PBVHNode **nodes, int totnode, int flag)
static void pbvh_update_draw_buffers (PBVH *bvh, PBVHNode **nodes, int totnode, int smooth)
static int pbvh_flush_bb (PBVH *bvh, PBVHNode *node, int flag)
void BLI_pbvh_update (PBVH *bvh, int flag, float(*face_nors)[3])
void BLI_pbvh_redraw_BB (PBVH *bvh, float bb_min[3], float bb_max[3])
void BLI_pbvh_get_grid_updates (PBVH *bvh, int clear, void ***gridfaces, int *totface)
void BLI_pbvh_node_mark_update (PBVHNode *node)
void BLI_pbvh_node_get_verts (PBVH *bvh, PBVHNode *node, int **vert_indices, MVert **verts)
void BLI_pbvh_node_num_verts (PBVH *bvh, PBVHNode *node, int *uniquevert, int *totvert)
void BLI_pbvh_node_get_grids (PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, DMGridData ***griddata, DMGridAdjacency **gridadj)
void BLI_pbvh_node_get_BB (PBVHNode *node, float bb_min[3], float bb_max[3])
void BLI_pbvh_node_get_original_BB (PBVHNode *node, float bb_min[3], float bb_max[3])
void BLI_pbvh_node_get_proxies (PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count)
static int ray_aabb_intersect (PBVHNode *node, void *data_v)
void BLI_pbvh_raycast (PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data, float ray_start[3], float ray_normal[3], int original)
static int ray_face_intersection (float ray_start[3], float ray_normal[3], float *t0, float *t1, float *t2, float *t3, float *fdist)
int BLI_pbvh_node_raycast (PBVH *bvh, PBVHNode *node, float(*origco)[3], float ray_start[3], float ray_normal[3], float *dist)
void BLI_pbvh_node_draw (PBVHNode *node, void *UNUSED(data))
int BLI_pbvh_node_planes_contain_AABB (PBVHNode *node, void *data)
void BLI_pbvh_draw (PBVH *bvh, float(*planes)[4], float(*face_nors)[3], int smooth)
void BLI_pbvh_grids_update (PBVH *bvh, DMGridData **grids, DMGridAdjacency *gridadj, void **gridfaces)
float(* BLI_pbvh_get_vertCos (PBVH *pbvh))[3]
void BLI_pbvh_apply_vertCos (PBVH *pbvh, float(*vertCos)[3])
int BLI_pbvh_isDeformed (PBVH *pbvh)
PBVHProxyNodeBLI_pbvh_node_add_proxy (PBVH *bvh, PBVHNode *node)
void BLI_pbvh_node_free_proxies (PBVHNode *node)
void BLI_pbvh_gather_proxies (PBVH *pbvh, PBVHNode ***r_array, int *r_tot)

Detailed Description

Definition in file pbvh.c.


Define Documentation

#define LEAF_LIMIT   10000

Definition at line 42 of file pbvh.c.

Referenced by BLI_pbvh_build_grids(), and BLI_pbvh_build_mesh().

#define STACK_FIXED_DEPTH   100

Definition at line 178 of file pbvh.c.

Referenced by pbvh_iter_begin(), pbvh_iter_end(), and pbvh_stack_push().


Typedef Documentation

typedef char* BLI_bitmap

Definition at line 47 of file pbvh.c.

typedef struct node_tree node_tree
typedef struct PBVHIter PBVHIter
typedef struct PBVHStack PBVHStack

Function Documentation

static void BB_expand ( BB bb,
float  co[3] 
) [static]

Definition at line 204 of file pbvh.c.

References BB::bmax, BB::bmin, i, MAX2, and MIN2.

Referenced by BLI_pbvh_build_grids(), BLI_pbvh_build_mesh(), build_sub(), and update_node_vb().

static void BB_expand_with_bb ( BB bb,
BB bb2 
) [static]

Definition at line 214 of file pbvh.c.

References BB::bmax, BB::bmin, i, MAX2, and MIN2.

Referenced by BLI_pbvh_redraw_BB(), build_sub(), and update_node_vb().

static void BB_reset ( BB bb) [static]
static int BB_widest_axis ( BB bb) [static]

Definition at line 224 of file pbvh.c.

References BB::bmax, BB::bmin, and i.

Referenced by build_sub().

static void BBC_update_centroid ( BBC bbc) [static]

Definition at line 246 of file pbvh.c.

References BBC::bcentroid, BBC::bmax, BBC::bmin, and i.

Referenced by BLI_pbvh_build_grids(), and BLI_pbvh_build_mesh().

static int BLI_bitmap_get ( BLI_bitmap  b,
int  index 
) [static]

Definition at line 54 of file pbvh.c.

Referenced by map_insert_vert().

static BLI_bitmap BLI_bitmap_new ( int  tot) [static]

Definition at line 49 of file pbvh.c.

References MEM_callocN().

Referenced by BLI_pbvh_build_mesh().

static void BLI_bitmap_set ( BLI_bitmap  b,
int  index 
) [static]

Definition at line 59 of file pbvh.c.

Referenced by map_insert_vert().

void BLI_pbvh_apply_vertCos ( PBVH pbvh,
float(*)  vertCos[3] 
)
void BLI_pbvh_build_grids ( PBVH bvh,
DMGridData **  grids,
DMGridAdjacency gridadj,
int  totgrid,
int  gridsize,
void **  gridfaces 
)
void BLI_pbvh_build_mesh ( PBVH bvh,
MFace faces,
MVert verts,
int  totface,
int  totvert 
)
void BLI_pbvh_draw ( PBVH bvh,
float(*)  planes[4],
float(*)  face_nors[3],
int  smooth 
)
void BLI_pbvh_free ( PBVH bvh)
void BLI_pbvh_gather_proxies ( PBVH pbvh,
PBVHNode ***  r_array,
int *  r_tot 
)

Definition at line 1650 of file pbvh.c.

References MEM_callocN(), MEM_freeN(), PBVH::nodes, NULL, and PBVH::totnode.

Referenced by sculpt_combine_proxies().

void BLI_pbvh_get_grid_updates ( PBVH bvh,
int  clear,
void ***  gridfaces,
int *  totface 
)
float(* BLI_pbvh_get_vertCos ( PBVH pbvh) )[3]

Definition at line 1542 of file pbvh.c.

References co, copy_v3_v3(), MEM_callocN(), and NULL.

Referenced by sculpt_update_keyblock().

void BLI_pbvh_grids_update ( PBVH bvh,
DMGridData **  grids,
DMGridAdjacency gridadj,
void **  gridfaces 
)

Definition at line 1535 of file pbvh.c.

References PBVH::gridadj, PBVH::gridfaces, and PBVH::grids.

Referenced by ccgDM_getPBVH().

int BLI_pbvh_isDeformed ( PBVH pbvh)

Definition at line 1599 of file pbvh.c.

References PBVH::deformed.

Referenced by sculpt_update_mesh_elements().

PBVH* BLI_pbvh_new ( void  )

Definition at line 629 of file pbvh.c.

References MEM_callocN().

Referenced by ccgDM_getPBVH(), and cdDM_getPBVH().

PBVHProxyNode* BLI_pbvh_node_add_proxy ( PBVH bvh,
PBVHNode node 
)
void BLI_pbvh_node_draw ( PBVHNode node,
void *  UNUSEDdata 
)

Definition at line 1460 of file pbvh.c.

References PBVHNode::draw_buffers, GPU_draw_buffers(), and i.

void BLI_pbvh_node_free_proxies ( PBVHNode node)

Definition at line 1632 of file pbvh.c.

References PBVHProxyNode::co, MEM_freeN(), p, PBVHNode::proxies, and PBVHNode::proxy_count.

Referenced by sculpt_combine_proxies().

void BLI_pbvh_node_get_BB ( PBVHNode node,
float  bb_min[3],
float  bb_max[3] 
)
void BLI_pbvh_node_get_grids ( PBVH bvh,
PBVHNode node,
int **  grid_indices,
int *  totgrid,
int *  maxgrid,
int *  gridsize,
DMGridData ***  griddata,
DMGridAdjacency **  gridadj 
)
void BLI_pbvh_node_get_original_BB ( PBVHNode node,
float  bb_min[3],
float  bb_max[3] 
)

Definition at line 1277 of file pbvh.c.

References BB::bmax, BB::bmin, copy_v3_v3(), and PBVHNode::orig_vb.

Referenced by ray_aabb_intersect(), and sculpt_search_sphere_cb().

void BLI_pbvh_node_get_proxies ( PBVHNode node,
PBVHProxyNode **  proxies,
int *  proxy_count 
)

Definition at line 1283 of file pbvh.c.

References PBVHNode::proxies, and PBVHNode::proxy_count.

Referenced by sculpt_combine_proxies().

float BLI_pbvh_node_get_tmin ( PBVHNode node)

Definition at line 892 of file pbvh.c.

References PBVHNode::tmin.

Referenced by sculpt_raycast_cb().

void BLI_pbvh_node_get_verts ( PBVH bvh,
PBVHNode node,
int **  vert_indices,
MVert **  verts 
)

Definition at line 1232 of file pbvh.c.

References PBVHNode::vert_indices, and PBVH::verts.

void BLI_pbvh_node_mark_update ( PBVHNode node)
void BLI_pbvh_node_num_verts ( PBVH bvh,
PBVHNode node,
int *  uniquevert,
int *  totvert 
)
int BLI_pbvh_node_planes_contain_AABB ( PBVHNode node,
void *  data 
)

Definition at line 1486 of file pbvh.c.

References BLI_pbvh_node_get_BB(), data, dot_v3v3(), and i.

Referenced by BLI_pbvh_draw().

int BLI_pbvh_node_raycast ( PBVH bvh,
PBVHNode node,
float(*)  origco[3],
float  ray_start[3],
float  ray_normal[3],
float *  dist 
)
void BLI_pbvh_raycast ( PBVH bvh,
BLI_pbvh_HitOccludedCallback  cb,
void *  data,
float  ray_start[3],
float  ray_normal[3],
int  original 
)
void BLI_pbvh_redraw_BB ( PBVH bvh,
float  bb_min[3],
float  bb_max[3] 
)
void BLI_pbvh_search_callback ( PBVH bvh,
BLI_pbvh_SearchCallback  scb,
void *  search_data,
BLI_pbvh_HitCallback  hcb,
void *  hit_data 
)

Definition at line 825 of file pbvh.c.

References PBVHNode::flag, pbvh_iter_begin(), pbvh_iter_end(), pbvh_iter_next(), and PBVH_Leaf.

Referenced by BLI_pbvh_draw(), and sculpt_undo_restore().

static void BLI_pbvh_search_callback_occluded ( PBVH bvh,
BLI_pbvh_SearchCallback  scb,
void *  search_data,
BLI_pbvh_HitOccludedCallback  hcb,
void *  hit_data 
) [static]
void BLI_pbvh_search_gather ( PBVH bvh,
BLI_pbvh_SearchCallback  scb,
void *  search_data,
PBVHNode ***  r_array,
int *  r_tot 
)
void BLI_pbvh_update ( PBVH bvh,
int  flag,
float(*)  face_nors[3] 
)
static void build_grids_leaf_node ( PBVH bvh,
PBVHNode node 
) [static]
static void build_mesh_leaf_node ( PBVH bvh,
PBVHNode node 
) [static]
static void build_sub ( PBVH bvh,
int  node_index,
BB cb,
BBC prim_bbc,
int  offset,
int  count 
) [static]
static void check_partitioning ( int *  prim_indices,
int  lo,
int  hi,
int  axis,
float  mid,
BBC prim_bbc,
int  index_of_2nd_partition 
) [static]

Definition at line 307 of file pbvh.c.

References BBC::bcentroid, and i.

Referenced by build_sub().

static void free_tree ( node_tree tree) [static]

Definition at line 877 of file pbvh.c.

References addon::engine::free(), node_tree::left, and node_tree::right.

Referenced by BLI_pbvh_search_callback_occluded().

static void grow_nodes ( PBVH bvh,
int  totnode 
) [static]

Definition at line 321 of file pbvh.c.

References MEM_callocN(), MEM_freeN(), PBVH::node_mem_count, PBVH::nodes, and PBVH::totnode.

Referenced by build_sub().

static int map_insert_vert ( PBVH bvh,
GHash map,
unsigned int *  face_verts,
unsigned int *  uniq_verts,
int  vertex 
) [static]
static void node_tree_insert ( node_tree tree,
node_tree new_node 
) [static]

Definition at line 848 of file pbvh.c.

References node_tree::data, node_tree::left, node_tree::right, and PBVHNode::tmin.

Referenced by BLI_pbvh_search_callback_occluded().

static int partition_indices ( int *  prim_indices,
int  lo,
int  hi,
int  axis,
float  mid,
BBC prim_bbc 
) [static]

Definition at line 291 of file pbvh.c.

References BBC::bcentroid, i, and SWAP.

Referenced by build_sub().

static void pbvh_build ( PBVH bvh,
BB cb,
BBC prim_bbc,
int  totprim 
) [static]
static int pbvh_flush_bb ( PBVH bvh,
PBVHNode node,
int  flag 
) [static]
static void pbvh_iter_begin ( PBVHIter iter,
PBVH bvh,
BLI_pbvh_SearchCallback  scb,
void *  search_data 
) [static]
static void pbvh_iter_end ( PBVHIter iter) [static]
static PBVHNode* pbvh_iter_next ( PBVHIter iter) [static]
static PBVHNode* pbvh_iter_next_occluded ( PBVHIter iter) [static]
static void pbvh_stack_push ( PBVHIter iter,
PBVHNode node,
int  revisiting 
) [static]
static void pbvh_update_BB_redraw ( PBVH bvh,
PBVHNode **  nodes,
int  totnode,
int  flag 
) [static]
static void pbvh_update_draw_buffers ( PBVH bvh,
PBVHNode **  nodes,
int  totnode,
int  smooth 
) [static]
static void pbvh_update_normals ( PBVH bvh,
PBVHNode **  nodes,
int  totnode,
float(*)  face_nors[3] 
) [static]
static int ray_aabb_intersect ( PBVHNode node,
void *  data_v 
) [static]
static int ray_face_intersection ( float  ray_start[3],
float  ray_normal[3],
float *  t0,
float *  t1,
float *  t2,
float *  t3,
float *  fdist 
) [static]

Definition at line 1367 of file pbvh.c.

References isect_ray_tri_epsilon_v3(), and NULL.

Referenced by BLI_pbvh_node_raycast().

static void traverse_tree ( node_tree tree,
BLI_pbvh_HitOccludedCallback  hcb,
void *  hit_data,
float *  tmin 
) [static]

Definition at line 868 of file pbvh.c.

References node_tree::data, node_tree::left, and node_tree::right.

Referenced by BLI_pbvh_search_callback_occluded().

static void update_node_vb ( PBVH bvh,
PBVHNode node 
) [static]
static int update_search_cb ( PBVHNode node,
void *  data_v 
) [static]

Definition at line 934 of file pbvh.c.

References PBVHNode::flag, GET_INT_FROM_POINTER, and PBVH_Leaf.

Referenced by BLI_pbvh_draw(), and BLI_pbvh_update().