Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2011, 5:07:42 AM (13 years ago)
Author:
rgrieder
Message:

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp

    r8351 r8393  
    22
    33#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
     4#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
    45#include "BulletCollision/CollisionShapes/btTriangleShape.h"
    56#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
     
    910
    1011//#define DEBUG_INTERNAL_EDGE
    11 
    1212
    1313#ifdef DEBUG_INTERNAL_EDGE
     
    457457                return;
    458458
    459         btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape();
    460         btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap();
     459        btBvhTriangleMeshShape* trimesh = 0;
     460       
     461        if( colObj0->getRootCollisionShape()->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE )
     462           trimesh = ((btScaledBvhTriangleMeshShape*)colObj0->getRootCollisionShape())->getChildShape();
     463   else   
     464           trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape();
     465           
     466        btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap();
    461467        if (!triangleInfoMapPtr)
    462468                return;
     
    502508        btVector3 localContactNormalOnB = colObj0->getWorldTransform().getBasis().transpose() * cp.m_normalWorldOnB;
    503509        localContactNormalOnB.normalize();//is this necessary?
    504 
    505         if ((info->m_edgeV0V1Angle)< SIMD_2_PI)
     510       
     511        // Get closest edge
     512        int      bestedge=-1;
     513        float    disttobestedge=BT_LARGE_FLOAT;
     514        //
     515        // Edge 0 -> 1
     516        if (btFabs(info->m_edgeV0V1Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
     517        {       
     518           btVector3 nearest;
     519           btNearestPointInLineSegment( cp.m_localPointB, v0, v1, nearest );
     520           float     len=(contact-nearest).length();
     521           //
     522           if( len < disttobestedge )
     523           {
     524              bestedge=0;
     525              disttobestedge=len;
     526      }       
     527   }       
     528        // Edge 1 -> 2
     529        if (btFabs(info->m_edgeV1V2Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
     530        {       
     531           btVector3 nearest;
     532           btNearestPointInLineSegment( cp.m_localPointB, v1, v2, nearest );
     533           float     len=(contact-nearest).length();
     534           //
     535           if( len < disttobestedge )
     536           {
     537              bestedge=1;
     538              disttobestedge=len;
     539      }       
     540   }       
     541        // Edge 2 -> 0
     542        if (btFabs(info->m_edgeV2V0Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
     543        {       
     544           btVector3 nearest;
     545           btNearestPointInLineSegment( cp.m_localPointB, v2, v0, nearest );
     546           float     len=(contact-nearest).length();
     547           //
     548           if( len < disttobestedge )
     549           {
     550              bestedge=2;
     551              disttobestedge=len;
     552      }       
     553   }           
     554       
     555#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     556   btVector3 upfix=tri_normal * btVector3(0.1f,0.1f,0.1f);
     557   btDebugDrawLine(tr * v0 + upfix, tr * v1 + upfix, red );
     558#endif   
     559        if (btFabs(info->m_edgeV0V1Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
    506560        {
    507561#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     
    510564                btScalar len = (contact-nearest).length();
    511565                if(len<triangleInfoMapPtr->m_edgeDistanceThreshold)
     566                if( bestedge==0 )
    512567                {
    513568                        btVector3 edge(v0-v1);
     
    578633#endif //BT_INTERNAL_EDGE_DEBUG_DRAW
    579634
    580         if ((info->m_edgeV1V2Angle)< SIMD_2_PI)
     635#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     636   btDebugDrawLine(tr * v1 + upfix, tr * v2 + upfix , green );
     637#endif   
     638
     639        if (btFabs(info->m_edgeV1V2Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
    581640        {
    582641#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     
    588647                btScalar len = (contact-nearest).length();
    589648                if(len<triangleInfoMapPtr->m_edgeDistanceThreshold)
     649                if( bestedge==1 )
    590650                {
    591651                        isNearEdge = true;
     
    659719        btDebugDrawLine(tr*nearest,tr*cp.m_localPointB,blue);
    660720#endif //BT_INTERNAL_EDGE_DEBUG_DRAW
    661 
    662         if ((info->m_edgeV2V0Angle)< SIMD_2_PI)
     721#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     722   btDebugDrawLine(tr * v2 + upfix, tr * v0 + upfix , blue );
     723#endif   
     724
     725        if (btFabs(info->m_edgeV2V0Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
    663726        {
    664727
     
    669732                btScalar len = (contact-nearest).length();
    670733                if(len<triangleInfoMapPtr->m_edgeDistanceThreshold)
     734                if( bestedge==2 )
    671735                {
    672736                        isNearEdge = true;
     
    760824                        } else
    761825                        {
     826                                btVector3 newNormal = tri_normal *frontFacing;
     827                                //if the tri_normal is pointing opposite direction as the current local contact normal, skip it
     828                                btScalar d = newNormal.dot(localContactNormalOnB) ;
     829                                if (d< 0)
     830                                {
     831                                        return;
     832                                }
    762833                                //modify the normal to be the triangle normal (or backfacing normal)
    763                                 cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() *(tri_normal *frontFacing);
    764                         }
    765                        
    766                        
     834                                cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() *newNormal;
     835                        }
     836                                               
    767837                        // Reproject collision point along normal.
    768838                        cp.m_positionWorldOnB = cp.m_positionWorldOnA - cp.m_normalWorldOnB * cp.m_distance1;
Note: See TracChangeset for help on using the changeset viewer.