/// @brief Build this Convex<Triangle> representation of this model.
/// \note this only takes the points of this model. It does not check that the
/// object is convex. It does not compute a convex hull.
voidbuildConvexRepresentation(boolshare_memory);
virtualintmemUsage(intmsg)const=0;
/// @brief This is a special acceleration: BVH_model default stores the BV's transform in world coordinate. However, we can also store each BV's transform related to its parent
/// @brief This is a special acceleration: BVH_model default stores the BV's transform in world coordinate. However, we can also store each BV's transform related to its parent
/// BV node. When traversing the BVH, this can save one matrix transformation.
voidmakeParentRelative()
{
Matrix3fI(Matrix3f::Identity());
makeParentRelativeRecurse(0,I,Vec3f());
}
virtualvoidmakeParentRelative()=0;
Vec3fcomputeCOM()const
{
...
...
@@ -267,14 +230,96 @@ public:
returnC.trace()*Matrix3f::Identity()-C;
}
private:
protected:
virtualvoiddeleteBVs()=0;
virtualboolallocateBVs()=0;
/// @brief Build the bounding volume hierarchy
virtualintbuildTree()=0;
/// @brief Refit the bounding volume hierarchy
virtualintrefitTree(boolbottomup)=0;
intnum_tris_allocated;
intnum_vertices_allocated;
intnum_bvs_allocated;
intnum_vertex_updated;/// for ccd vertex update
unsignedint*primitive_indices;
};
/// @brief A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as a degraded version of mesh)
template<typenameBV>
classBVHModel:publicBVHModelBase
{
public:
/// @brief Split rule to split one BV node into two children
boost::shared_ptr<BVSplitterBase<BV>>bv_splitter;
/// @brief Fitting rule to fit a BV node to a set of geometry primitives
/// @brief deconstruction, delete mesh data related.
~BVHModel()
{
delete[]bvs;
delete[]primitive_indices;
}
/// @brief We provide getBV() and getNumBVs() because BVH may be compressed (in future), so we must provide some flexibility here
/// @brief Access the bv giving the its index
constBVNode<BV>&getBV(intid)const
{
assert(id<num_bvs);
returnbvs[id];
}
/// @brief Access the bv giving the its index
BVNode<BV>&getBV(intid)
{
assert(id<num_bvs);
returnbvs[id];
}
/// @brief Get the number of bv in the BVH
intgetNumBVs()const
{
returnnum_bvs;
}
/// @brief Get the BV type: default is unknown
NODE_TYPEgetNodeType()const{returnBV_UNKNOWN;}
/// @brief Check the number of memory used
intmemUsage(intmsg)const;
/// @brief This is a special acceleration: BVH_model default stores the BV's transform in world coordinate. However, we can also store each BV's transform related to its parent
/// BV node. When traversing the BVH, this can save one matrix transformation.