OSDN Git Service

Turn off contact normal direction fix, which inverts some polygon normals incorrectly
[skyscrapersim/skyscraper.git] / bullet-changes.patch
1 diff -urN bullet.orig/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp bullet.new/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
2 --- bullet.orig/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp  2014-01-10 15:49:31.000000000 -0600
3 +++ bullet.new/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp   2015-03-26 20:16:59.766935213 -0500
4 @@ -51,7 +51,7 @@
5  m_ignoreMargin(false),
6  m_lastUsedMethod(-1),
7  m_catchDegeneracies(1),
8 -m_fixContactNormalDirection(1)
9 +m_fixContactNormalDirection(0)
10  {
11  }
12  btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver*       penetrationDepthSolver)
13 @@ -67,7 +67,7 @@
14  m_ignoreMargin(false),
15  m_lastUsedMethod(-1),
16  m_catchDegeneracies(1),
17 -m_fixContactNormalDirection(1)
18 +m_fixContactNormalDirection(0)
19  {
20  }
21  
22 diff -urN bullet.orig/src/BulletDynamics/Character/btKinematicCharacterController.cpp bullet.new/src/BulletDynamics/Character/btKinematicCharacterController.cpp
23 --- bullet.orig/src/BulletDynamics/Character/btKinematicCharacterController.cpp 2015-03-26 13:15:36.992897379 -0500
24 +++ bullet.new/src/BulletDynamics/Character/btKinematicCharacterController.cpp  2015-03-26 01:38:09.802905314 -0500
25 @@ -234,10 +234,13 @@
26                         //manifold->clearManifold();
27                 }
28         }
29 -       btTransform newTrans = m_ghostObject->getWorldTransform();
30 -       newTrans.setOrigin(m_currentPosition);
31 -       m_ghostObject->setWorldTransform(newTrans);
32 -//     printf("m_touchingNormal = %f,%f,%f\n",m_touchingNormal[0],m_touchingNormal[1],m_touchingNormal[2]);
33 +       if (penetration == true)
34 +       {
35 +               btTransform newTrans = m_ghostObject->getWorldTransform();
36 +               newTrans.setOrigin(m_currentPosition);
37 +               m_ghostObject->setWorldTransform(newTrans);
38 +               //printf("m_touchingNormal = %f,%f,%f\n",m_touchingNormal[0],m_touchingNormal[1],m_touchingNormal[2]);
39 +       }
40         return penetration;
41  }
42  
43 @@ -338,17 +341,19 @@
44         btScalar distance2 = (m_currentPosition-m_targetPosition).length2();
45  //     printf("distance2=%f\n",distance2);
46  
47 -       if (m_touchingContact)
48 +       /*if (m_touchingContact)
49         {
50                 if (m_normalizedDirection.dot(m_touchingNormal) > btScalar(0.0))
51                 {
52                         //interferes with step movement
53 -                       //updateTargetPositionBasedOnCollision (m_touchingNormal);
54 +                       updateTargetPositionBasedOnCollision (m_touchingNormal);
55                 }
56 -       }
57 +       }*/
58  
59         int maxIter = 10;
60  
61 +       doPenetrationRecovery(collisionWorld);
62 +
63         while (fraction > btScalar(0.01) && maxIter-- > 0)
64         {
65                 start.setOrigin (m_currentPosition);
66 @@ -607,24 +612,9 @@
67  void btKinematicCharacterController::preStep (  btCollisionWorld* collisionWorld)
68  {
69         
70 -       int numPenetrationLoops = 0;
71 -       m_touchingContact = false;
72 -       while (recoverFromPenetration (collisionWorld))
73 -       {
74 -               numPenetrationLoops++;
75 -               m_touchingContact = true;
76 -               if (numPenetrationLoops > 4)
77 -               {
78 -                       //printf("character could not recover from penetration = %d\n", numPenetrationLoops);
79 -                       break;
80 -               }
81 -       }
82 -
83         m_currentPosition = m_ghostObject->getWorldTransform().getOrigin();
84         m_targetPosition = m_currentPosition;
85  //     printf("m_targetPosition=%f,%f,%f\n",m_targetPosition[0],m_targetPosition[1],m_targetPosition[2]);
86 -
87 -       
88  }
89  
90  #include <stdio.h>
91 @@ -768,3 +758,20 @@
92  {
93         m_interpolateUp = value;
94  }
95 +
96 +void btKinematicCharacterController::doPenetrationRecovery(btCollisionWorld* collisionWorld)
97 +{
98 +       int numPenetrationLoops = 0;
99 +       m_touchingContact = false;
100 +
101 +       while (recoverFromPenetration (collisionWorld))
102 +       {
103 +               numPenetrationLoops++;
104 +               m_touchingContact = true;
105 +               if (numPenetrationLoops > 4)
106 +               {
107 +                       //printf("character could not recover from penetration = %d\n", numPenetrationLoops);
108 +                       break;
109 +               }
110 +       }
111 +}
112 diff -urN bullet.orig/src/BulletDynamics/Character/btKinematicCharacterController.h bullet.new/src/BulletDynamics/Character/btKinematicCharacterController.h
113 --- bullet.orig/src/BulletDynamics/Character/btKinematicCharacterController.h   2015-03-26 13:15:36.992897379 -0500
114 +++ bullet.new/src/BulletDynamics/Character/btKinematicCharacterController.h    2015-03-26 01:23:54.895928312 -0500
115 @@ -94,6 +94,7 @@
116         void updateTargetPositionBasedOnCollision (const btVector3& hit_normal, btScalar tangentMag = btScalar(0.0), btScalar normalMag = btScalar(1.0));
117         void stepForwardAndStrafe (btCollisionWorld* collisionWorld, const btVector3& walkMove);
118         void stepDown (btCollisionWorld* collisionWorld, btScalar dt);
119 +       void doPenetrationRecovery(btCollisionWorld* collisionWorld);
120  public:
121  
122         BT_DECLARE_ALIGNED_ALLOCATOR();