diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-09 14:25:18 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-09 15:03:55 +0300 |
commit | 62cc4bab083893a85e451ab96455c9be60c04cc1 (patch) | |
tree | dd222d25c9d4ecbbe8c1ccd9f5317a1fdd0df7fd /source/blender/blenkernel/BKE_bvhutils.h | |
parent | 17941860530693dfce76a4bf3d25e0e29610a20b (diff) |
BKE bvhutils: cleanup and refactor to make it more flexible.
You can now use lower-level '_ex' versions of bvh creators to only use part of
the mesh's elements in the BVH, and/or create bvh from non-DM sources.
Needed for transfer data.
Note edges extend version of bvh creator is not added here, not needed so far.
Diffstat (limited to 'source/blender/blenkernel/BKE_bvhutils.h')
-rw-r--r-- | source/blender/blenkernel/BKE_bvhutils.h | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index 4bc8fc44bb4..a360511dcd3 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -31,6 +31,7 @@ * \ingroup bke */ +#include "BLI_bitmap.h" #include "BLI_kdopbvh.h" /* @@ -56,8 +57,8 @@ typedef struct BVHTreeFromMesh { struct MEdge *edge; /* only used for BVHTreeFromMeshEdges */ struct MFace *face; bool vert_allocated; - bool face_allocated; bool edge_allocated; + bool face_allocated; /* radius for raycast */ float sphere_radius; @@ -69,36 +70,28 @@ typedef struct BVHTreeFromMesh { } BVHTreeFromMesh; /* - * Builds a bvh tree where nodes are the vertexs of the given mesh. + * Builds a bvh tree where nodes are the relevant elements of the given mesh. * Configures BVHTreeFromMesh. * * The tree is build in mesh space coordinates, this means special care must be made on queries * so that the coordinates and rays are first translated on the mesh local coordinates. - * Reason for this is that later bvh_from_mesh_* might use a cache system and so it becomes possible to reuse - * a BVHTree. + * Reason for this is that bvh_from_mesh_* can use a cache in some cases and so it becomes possible to reuse a BVHTree. * * free_bvhtree_from_mesh should be called when the tree is no longer needed. */ BVHTree *bvhtree_from_mesh_verts(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); - -/* - * Builds a bvh tree where nodes are the faces of the given mesh. - * Configures BVHTreeFromMesh. - * - * The tree is build in mesh space coordinates, this means special care must be made on queries - * so that the coordinates and rays are first translated on the mesh local coordinates. - * Reason for this is that later bvh_from_mesh_* might use a cache system and so it becomes possible to reuse - * a BVHTree. - * - * The returned value is the same as in data->tree, its only returned to make it easier to test - * the success - * - * free_bvhtree_from_mesh should be called when the tree is no longer needed. - */ -BVHTree *bvhtree_from_mesh_faces(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); +BVHTree *bvhtree_from_mesh_verts_ex(struct BVHTreeFromMesh *data, struct MVert *vert, const int numVerts, + const bool vert_allocated, BLI_bitmap *mask, int numVerts_active, + float epsilon, int tree_type, int axis); BVHTree *bvhtree_from_mesh_edges(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); +BVHTree *bvhtree_from_mesh_faces(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); +BVHTree *bvhtree_from_mesh_faces_ex(struct BVHTreeFromMesh *data, struct MVert *vert, const bool vert_allocated, + struct MFace *face, const int numFaces, const bool face_allocated, + BLI_bitmap *mask, int numFaces_active, + float epsilon, int tree_type, int axis); + /* * Frees data allocated by a call to bvhtree_from_mesh_*. */ @@ -114,12 +107,13 @@ float nearest_point_in_tri_surface_squared(const float v0[3], const float v1[3], * BVHCache */ -//Using local coordinates -#define BVHTREE_FROM_FACES 0 -#define BVHTREE_FROM_VERTICES 1 -#define BVHTREE_FROM_EDGES 2 - -#define BVHTREE_FROM_FACES_EDITMESH 3 +/* Using local coordinates */ +enum { + BVHTREE_FROM_VERTS = 0, + BVHTREE_FROM_EDGES = 1, + BVHTREE_FROM_FACES = 2, + BVHTREE_FROM_FACES_EDITMESH = 3, +}; typedef struct LinkNode *BVHCache; |