![]() |
TAPs 0.7.7.3
|
Functions | |
| template<typename T > | |
| bool | CD (TAPs::OpenGL::ModelStrand< T > *pStrandObj, TAPs::BVHTree< T > const *const pObjBVH, TAPs::TransformationSupport< T > const *const pTransform, std::vector< BVHNode< T > * > *listOfSutureCollidedNodes, std::vector< BVHNode< T > * > *listOfObjectCollidedNodes) |
| Collision Detection of a strand with another object's bounding volume hierarchy tree. | |
| template<typename T > | |
| bool | CR (TAPs::OpenGL::ModelStrand< T > *pStrandObj, TAPs::BVHTree< T > const *const pObjBVH, TAPs::TransformationSupport< T > const *const pTransform, std::vector< BVHNode< T > * > *listOfSutureCollidedNodes, std::vector< BVHNode< T > * > *listOfObjectCollidedNodes) |
| Collision Detection of a strand with another object's bounding volume hierarchy tree. | |
| bool Private::CD | ( | TAPs::OpenGL::ModelStrand< T > * | pStrandObj, |
| TAPs::BVHTree< T > const *const | pObjBVH, | ||
| TAPs::TransformationSupport< T > const *const | pTransform, | ||
| std::vector< BVHNode< T > * > * | listOfSutureCollidedNodes, | ||
| std::vector< BVHNode< T > * > * | listOfObjectCollidedNodes | ||
| ) |
Collision Detection of a strand with another object's bounding volume hierarchy tree.
| pStrandObj | a strand object |
| pObjBVH | the BVH tree of an object |
| pTransform | an extra transformation for the object |
| listOfSutureCollidedNodes | list of suture collided nodes |
| listOfObjectCollidedNodes | list of object collided nodes |
Definition at line 194 of file TAPsColDetFns.cpp.
References BVHNode< T >::GetAPrimitiveHalfEdgeFace(), BVHNode< T >::GetID(), BVHTree< T >::GetListOfCollidedNodes(), BVHTree< T >::GetListOfCollidedNodesThat(), HEFace< T >::GetPtrsToVertices(), and BVHTree< T >::TestOverlapWithTillLeafNodes().
Referenced by CDR().
{
//--------------------------------------------------------------------
BVHTree<T> * strandBVH = pStrandObj->GetBVHTree();
bool result = strandBVH->TestOverlapWithTillLeafNodes( pObjBVH );
if ( !result ) return result;
//--------------------------------------------------------------------
BVHNode<T> * cylinder;
BVHNode<T> * triangle;
//--------------------------------------------------------------------
// HAVE TO CORPORATE pTransform for collision detection !!!
int size = static_cast<int>( pStrandObj->GetBVHTree()->GetListOfCollidedNodes().size() );
int linkNo;
for ( int i = 0; i < size; ++i ) {
cylinder = strandBVH->GetListOfCollidedNodes()[i];
triangle = strandBVH->GetListOfCollidedNodesThat()[i];
linkNo = cylinder->GetID();
HEFace<T> * heFace = triangle->GetAPrimitiveHalfEdgeFace();
std::vector< HEVertex<T> * const > vertices = heFace->GetPtrsToVertices();
result = CGMath<T>::FindIntersectionCylinderTriangle(
pStrandObj->GetPointPosition( linkNo ),
pStrandObj->GetPointPosition( linkNo+1 ),
pStrandObj->GetRadius(),
vertices[0]->GetPosition(),
vertices[1]->GetPosition(),
vertices[2]->GetPosition() );
if ( result ) {
listOfSutureCollidedNodes->push_back( strandBVH->GetListOfCollidedNodes()[i] );
listOfObjectCollidedNodes->push_back( strandBVH->GetListOfCollidedNodesThat()[i] );
}
}
//--------------------------------------------------------------------
if ( static_cast<int>( listOfSutureCollidedNodes->size() ) > 0 ) return true;
else return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| bool Private::CR | ( | TAPs::OpenGL::ModelStrand< T > * | pStrandObj, |
| TAPs::BVHTree< T > const *const | pObjBVH, | ||
| TAPs::TransformationSupport< T > const *const | pTransform, | ||
| std::vector< BVHNode< T > * > * | listOfSutureCollidedNodes, | ||
| std::vector< BVHNode< T > * > * | listOfObjectCollidedNodes | ||
| ) |
Collision Detection of a strand with another object's bounding volume hierarchy tree.
| pStrandObj | a suture object |
| pObjBVH | the BVH tree of an object |
| pTransform | an extra transformation for the object |
| listOfSutureCollidedNodes | list of suture collided nodes |
| listOfObjectCollidedNodes | list of object collided nodes |
Definition at line 242 of file TAPsColDetFns.cpp.
References HEFace< T >::GetPtrsToVerticesAndNumberOfVertices(), Vector3< T >::Length(), and Vector3< T >::Normalized().
Referenced by CDR().
{
// HAVE TO CORPORATE pTransform for collision detection !!!
std::set< BVHNode<T> * > strandNodeSet;
std::set< BVHNode<T> * > objectNodeSet;
//--------------------------------------------------------------------
Vector3<T> N, V1, V2;
T value;
//T offset = pStrandObj->GetRadius() * 2;
//T offset = pStrandObj->GetRadius();
T offset = 0;
HEFace<T> * primB;
std::vector< HEVertex<T> * const > vertexList;
int noOfVertices;
//--------------------------------------------------------------------
// Deform Object away from Strand Object
for ( int i = 0; i < static_cast<int>( listOfObjectCollidedNodes->size() ); ++i ) {
assert( (*listOfObjectCollidedNodes)[i]->GetAPrimitiveHalfEdgeFace() != NULL );
N = (*listOfObjectCollidedNodes)[i]->GetAPrimitiveHalfEdgeFace()->GetNormal();
assert( N.Length() > 0.5 );
// This is an ad hoc algorithm
if ( true ) {
//if ( separateDistance > Math<T>::ZERO ) {
primB = (*listOfObjectCollidedNodes)[i]->GetAPrimitiveHalfEdgeFace();
vertexList = primB->GetPtrsToVerticesAndNumberOfVertices( noOfVertices );
//-------------------------------------------------------
// Set Positions of the stand link away from the triangle
int linkNo = (*listOfSutureCollidedNodes)[i]->GetID();
#ifdef TAPs_ADVANCED_SIMULATION
if (
pStrandObj->RetSimulationFlagsOfVertexNo( linkNo ).AreSimulationFlagsCleared()
&&
pStrandObj->RetSimulationFlagsOfVertexNo( linkNo+1 ).AreSimulationFlagsCleared()
)
#endif//TAPs_ADVANCED_SIMULATION
{
// Limit the link length, to prevent the non-stop move of point(s).
// Here the length is limited to not be over 8 * pStrandObj->GetLength().
//Real length = ( pStrandObj->GetPointPosition( linkNo ) - pStrandObj->GetPointPosition( linkNo+1 ) ).Length();
//if ( length > 4 * pStrandObj->GetLength() ) return;
// Use triangle centroid to determine the depth of the intersection
Vector3<T> triCentroid( ( vertexList[0]->GetPosition() + vertexList[1]->GetPosition() + vertexList[2]->GetPosition() ) / 3.0 );
V1 = pStrandObj->GetPointPosition( linkNo ) - triCentroid;
V2 = pStrandObj->GetPointPosition( linkNo+1 ) - triCentroid;
N.Normalized();
value = V1 * N;
if ( value < 0.0 ) {
pStrandObj->ChangeOnlyPointPositionByAddedWithThisVector( linkNo , N * (offset - value) );
}
value = V2 * N;
if ( value < 0.0 ) {
pStrandObj->ChangeOnlyPointPositionByAddedWithThisVector( linkNo+1, N * (offset - value) );
}
//-------------------------------------------------------
// Set Positions of the stand link away from the triangle
//N.Normalized();
//N *= pStrandObj->GetRadius() * 2;
//int linkNo = (*listOfSutureCollidedNodes)[i]->GetID();
//pStrandObj->ChangeOnlyPointPositionByAddedWithThisVector( linkNo , N );
//pStrandObj->ChangeOnlyPointPositionByAddedWithThisVector( linkNo+1, N );
}
}
}
pStrandObj->UpdateBVHTree();
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function: