38 #ifndef FCL_BVH_MODEL_H 39 #define FCL_BVH_MODEL_H 44 #include "fcl/math/bv/OBB.h" 45 #include "fcl/math/bv/kDOP.h" 46 #include "fcl/geometry/collision_geometry.h" 47 #include "fcl/geometry/bvh/BVH_internal.h" 48 #include "fcl/geometry/bvh/BV_node.h" 49 #include "fcl/geometry/bvh/detail/BV_splitter.h" 50 #include "fcl/geometry/bvh/detail/BV_fitter.h" 56 template <
typename BV>
61 using S =
typename BV::S;
103 int addTriangle(
const Vector3<S>& p1,
const Vector3<S>& p2,
const Vector3<S>& p3);
106 int addSubModel(
const std::vector<Vector3<S>>& ps,
const std::vector<Triangle>& ts);
109 int addSubModel(
const std::vector<Vector3<S>>& ps);
122 int replaceTriangle(
const Vector3<S>& p1,
const Vector3<S>& p2,
const Vector3<S>& p3);
139 int updateTriangle(
const Vector3<S>& p1,
const Vector3<S>& p2,
const Vector3<S>& p3);
187 int num_tris_allocated;
188 int num_vertices_allocated;
189 int num_bvs_allocated;
190 int num_vertex_updated;
191 unsigned int* primitive_indices;
203 int refitTree(
bool bottomup);
206 int refitTree_topdown();
209 int refitTree_bottomup();
212 int recursiveBuildTree(
int bv_id,
int first_primitive,
int num_primitives);
215 int recursiveRefitTree_bottomup(
int bv_id);
220 void makeParentRelativeRecurse(
222 const Matrix3<S>& parent_axis,
223 const Vector3<S>& parent_c);
225 template <
typename,
typename>
231 #include "fcl/geometry/bvh/BVH_model-inl.h" void computeLocalAABB() override
Compute the AABB for the BVH, used for broad-phase collision.
Definition: BVH_model-inl.h:1063
int beginModel(int num_tris=0, int num_vertices=0)
Begin a new BVH model.
Definition: BVH_model-inl.h:205
int updateSubModel(const std::vector< Vector3< S >> &ps)
Update a set of points in the old BVH model.
Definition: BVH_model-inl.h:668
NODE_TYPE
traversal node type: bounding volume (AABB, OBB, RSS, kIOS, OBBRSS, KDOP16, KDOP18, kDOP24), basic shape (box, sphere, ellipsoid, capsule, cone, cylinder, convex, plane, halfspace, triangle), and octree
Definition: collision_geometry.h:54
Matrix3< S > computeMomentofInertia() const override
compute the inertia matrix, related to the origin
Definition: BVH_model-inl.h:781
int addVertex(const Vector3< S > &p)
Add one point in the new BVH model.
Definition: BVH_model-inl.h:252
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
int replaceSubModel(const std::vector< Vector3< S >> &ps)
Replace a set of points in the old BVH model.
Definition: BVH_model-inl.h:559
int replaceVertex(const Vector3< S > &p)
Replace one point in the old BVH model.
Definition: BVH_model-inl.h:527
BVHBuildState
States for BVH construction empty->begun->processed ->replace_begun->processed -> ...
Definition: BVH_internal.h:50
int getNumBVs() const
Get the number of bv in the BVH.
Definition: BVH_model-inl.h:174
int beginReplaceModel()
Replace the geometry information of current frame (i.e. should have the same mesh topology with the p...
Definition: BVH_model-inl.h:508
BVHModelType getModelType() const
Model type described by the instance.
Definition: BVH_model-inl.h:48
OBJECT_TYPE getObjectType() const override
Get the object type: it is a BVH.
Definition: BVH_model-inl.h:181
BVHModelType
BVH model type.
Definition: BVH_internal.h:75
BVHModel()
Constructing an empty BVH.
Definition: BVH_model-inl.h:60
const BVNode< BV > & getBV(int id) const
We provide getBV() and getNumBVs() because BVH may be compressed (in future), so we must provide some...
Definition: BVH_model-inl.h:160
Vector3< S > * prev_vertices
Geometry point data in previous frame.
Definition: BVH_model.h:168
Vector3< S > * vertices
Geometry point data.
Definition: BVH_model.h:162
int num_vertices
Number of points.
Definition: BVH_model.h:174
void makeParentRelative()
This is a special acceleration: BVH_model default stores the BV's transform in world coordinate...
Definition: BVH_model-inl.h:741
int addSubModel(const std::vector< Vector3< S >> &ps, const std::vector< Triangle > &ts)
Add a set of triangles in the new BVH model.
Definition: BVH_model-inl.h:374
int addTriangle(const Vector3< S > &p1, const Vector3< S > &p2, const Vector3< S > &p3)
Add one triangle in the new BVH model.
Definition: BVH_model-inl.h:283
The geometry for the object for collision or distance computation.
Definition: collision_geometry.h:59
Triangle * tri_indices
Geometry triangle index data, will be nullptr for point clouds.
Definition: BVH_model.h:165
Triangle with 3 indices for points.
Definition: triangle.h:47
int num_tris
Number of triangles.
Definition: BVH_model.h:171
std::shared_ptr< detail::BVFitterBase< BV > > bv_fitter
Fitting rule to fit a BV node to a set of geometry primitives.
Definition: BVH_model.h:183
S computeVolume() const override
compute the volume
Definition: BVH_model-inl.h:766
int updateTriangle(const Vector3< S > &p1, const Vector3< S > &p2, const Vector3< S > &p3)
Update one triangle in the old BVH model.
Definition: BVH_model-inl.h:652
int memUsage(int msg) const
Check the number of memory used.
Definition: BVH_model-inl.h:721
OBJECT_TYPE
object type: BVH (mesh, points), basic geometry, octree
Definition: collision_geometry.h:51
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: BVH_model.h:57
int replaceTriangle(const Vector3< S > &p1, const Vector3< S > &p2, const Vector3< S > &p3)
Replace one triangle in the old BVH model.
Definition: BVH_model-inl.h:543
int updateVertex(const Vector3< S > &p)
Update one point in the old BVH model.
Definition: BVH_model-inl.h:636
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
Definition: BV_node.h:52
Definition: BVH_model-inl.h:1014
int endModel()
End BVH model construction, will build the bounding volume hierarchy.
Definition: BVH_model-inl.h:437
NODE_TYPE getNodeType() const override
Get the BV type: default is unknown.
Definition: BVH_model-inl.h:198
int endUpdateModel(bool refit=true, bool bottomup=true)
End BVH model update, will also refit or rebuild the bounding volume hierarchy.
Definition: BVH_model-inl.h:686
Vector3< S > computeCOM() const override
compute center of mass
Definition: BVH_model-inl.h:749
std::shared_ptr< detail::BVSplitterBase< BV > > bv_splitter
Split rule to split one BV node into two children.
Definition: BVH_model.h:180
int endReplaceModel(bool refit=true, bool bottomup=true)
End BVH model replacement, will also refit or rebuild the bounding volume hierarchy.
Definition: BVH_model-inl.h:577
BVHBuildState build_state
The state of BVH building process.
Definition: BVH_model.h:177
~BVHModel()
deconstruction, delete mesh data related.
Definition: BVH_model-inl.h:148
int beginUpdateModel()
Replace the geometry information of current frame (i.e. should have the same mesh topology with the p...
Definition: BVH_model-inl.h:607