Logo Search packages:      
Sourcecode: blender version File versions  Download package

void btSoftBodyTriangleCallback::processTriangle ( btVector3 *  triangle,
int  partId,
int  triangleIndex 
) [virtual]

debug drawing of the overlapping triangles

this should use the btDispatcher, so the actual registered algorithm is used

Implements btTriangleCallback.

Definition at line 89 of file btSoftBodyConcaveCollisionAlgorithm.cpp.

References btHashMap< Key, Value >::insert(), btCollisionAlgorithm::processCollision(), btCollisionShape::setUserPointer(), and btCollisionAlgorithm::~btCollisionAlgorithm().

{
      //just for debugging purposes
      //printf("triangle %d",m_triangleCount++);
      btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBody);
      btCollisionAlgorithmConstructionInfo ci;
      ci.m_dispatcher1 = m_dispatcher;

      ///debug drawing of the overlapping triangles
      if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
      {
            btVector3 color(255,255,0);
            btTransform& tr = ob->getWorldTransform();
            m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(triangle[1]),color);
            m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color);
            m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
      }

      btTriIndex  triIndex(partId,triangleIndex,0);
      btHashKey<btTriIndex> triKey(triIndex.getUid());


      btTriIndex* shapeIndex = m_shapeCache[triKey];
      if (shapeIndex)
      {
            btCollisionShape* tm = shapeIndex->m_childShape;
            btAssert(tm);

            //copy over user pointers to temporary shape
            tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());

            btCollisionShape* tmpShape = ob->getCollisionShape();
            ob->internalSetTemporaryCollisionShape( tm );


            btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);

            colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
            colAlgo->~btCollisionAlgorithm();
            ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
            ob->internalSetTemporaryCollisionShape( tmpShape);
            return;
      }

      //aabb filter is already applied!   

      //btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);

      //    if (m_softBody->getCollisionShape()->getShapeType()==
      {
            //          btVector3 other;
            btVector3 normal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]);
            normal.normalize();
            normal*= BT_SOFTBODY_TRIANGLE_EXTRUSION;
            //          other=(triangle[0]+triangle[1]+triangle[2])*0.333333f;
            //          other+=normal*22.f;
            btVector3   pts[6] = {triangle[0]+normal,
                  triangle[1]+normal,
                  triangle[2]+normal,
                  triangle[0]-normal,
                  triangle[1]-normal,
                  triangle[2]-normal};

            btConvexHullShape* tm = new btConvexHullShape(&pts[0].getX(),6);


            //          btBU_Simplex1to4 tm(triangle[0],triangle[1],triangle[2],other);

            //btTriangleShape tm(triangle[0],triangle[1],triangle[2]);  
            //    tm.setMargin(m_collisionMarginTriangle);

            //copy over user pointers to temporary shape
            tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());

            btCollisionShape* tmpShape = ob->getCollisionShape();
            ob->internalSetTemporaryCollisionShape( tm );


            btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
            ///this should use the btDispatcher, so the actual registered algorithm is used
            //          btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);

            //m_resultOut->setShapeIdentifiers(-1,-1,partId,triangleIndex);
            //    cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
            //          cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
            colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
            colAlgo->~btCollisionAlgorithm();
            ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);


            ob->internalSetTemporaryCollisionShape( tmpShape );
            triIndex.m_childShape = tm;
            m_shapeCache.insert(triKey,triIndex);

      }



}


Generated by  Doxygen 1.6.0   Back to index