diff options
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index 57c1308..f63d83c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | |||
@@ -1821,7 +1821,7 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1821 | IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB(); | 1821 | IndexedVector3 contactPoint = manifoldPoint.GetPositionWorldOnB(); |
1822 | IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A | 1822 | IndexedVector3 contactNormal = -manifoldPoint.m_normalWorldOnB; // make relative to A |
1823 | 1823 | ||
1824 | RecordCollision(this, objA, objB, contactPoint, contactNormal); | 1824 | RecordCollision(this, objA, objB, contactPoint, contactNormal,manifoldPoint.GetDistance()); |
1825 | m_collisionsThisFrame ++; | 1825 | m_collisionsThisFrame ++; |
1826 | if (m_collisionsThisFrame >= 9999999) | 1826 | if (m_collisionsThisFrame >= 9999999) |
1827 | break; | 1827 | break; |
@@ -1858,8 +1858,64 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1858 | } | 1858 | } |
1859 | return numSimSteps; | 1859 | return numSimSteps; |
1860 | } | 1860 | } |
1861 | 1861 | public void RecordGhostCollisions(PairCachingGhostObject obj) | |
1862 | private static void RecordCollision(BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm) | 1862 | { |
1863 | /* | ||
1864 | *void BulletSim::RecordGhostCollisions(btPairCachingGhostObject* obj) | ||
1865 | { | ||
1866 | btManifoldArray manifoldArray; | ||
1867 | btBroadphasePairArray& pairArray = obj->getOverlappingPairCache()->getOverlappingPairArray(); | ||
1868 | int numPairs = pairArray.size(); | ||
1869 | |||
1870 | // For all the pairs of sets of contact points | ||
1871 | for (int i=0; i < numPairs; i++) | ||
1872 | { | ||
1873 | if (m_collisionsThisFrame >= m_maxCollisionsPerFrame) | ||
1874 | break; | ||
1875 | |||
1876 | manifoldArray.clear(); | ||
1877 | const btBroadphasePair& pair = pairArray[i]; | ||
1878 | |||
1879 | // The real representation is over in the world pair cache | ||
1880 | btBroadphasePair* collisionPair = m_worldData.dynamicsWorld->getPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1); | ||
1881 | if (!collisionPair) | ||
1882 | continue; | ||
1883 | |||
1884 | if (collisionPair->m_algorithm) | ||
1885 | collisionPair->m_algorithm->getAllContactManifolds(manifoldArray); | ||
1886 | |||
1887 | // The collision pair has sets of collision points (manifolds) | ||
1888 | for (int j=0; j < manifoldArray.size(); j++) | ||
1889 | { | ||
1890 | btPersistentManifold* contactManifold = manifoldArray[j]; | ||
1891 | int numContacts = contactManifold->getNumContacts(); | ||
1892 | |||
1893 | const btCollisionObject* objA = static_cast<const btCollisionObject*>(contactManifold->getBody0()); | ||
1894 | const btCollisionObject* objB = static_cast<const btCollisionObject*>(contactManifold->getBody1()); | ||
1895 | |||
1896 | // TODO: this is a more thurough check than the regular collision code -- | ||
1897 | // here we find the penetrating contact in the manifold but for regular | ||
1898 | // collisions we assume the first point in the manifold is good enough. | ||
1899 | // Decide of this extra checking is required or if first point is good enough. | ||
1900 | for (int p=0; p < numContacts; p++) | ||
1901 | { | ||
1902 | const btManifoldPoint& pt = contactManifold->getContactPoint(p); | ||
1903 | // If a penetrating contact, this is a hit | ||
1904 | if (pt.getDistance()<0.f) | ||
1905 | { | ||
1906 | const btVector3& contactPoint = pt.getPositionWorldOnA(); | ||
1907 | const btVector3& normalOnA = -pt.m_normalWorldOnB; | ||
1908 | RecordCollision(objA, objB, contactPoint, normalOnA, pt.getDistance()); | ||
1909 | // Only one contact point for each set of colliding objects | ||
1910 | break; | ||
1911 | } | ||
1912 | } | ||
1913 | } | ||
1914 | } | ||
1915 | } | ||
1916 | */ | ||
1917 | } | ||
1918 | private static void RecordCollision(BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm, float penetration) | ||
1863 | { | 1919 | { |
1864 | 1920 | ||
1865 | IndexedVector3 contactNormal = norm; | 1921 | IndexedVector3 contactNormal = norm; |
@@ -1885,7 +1941,9 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1885 | aID = idA, | 1941 | aID = idA, |
1886 | bID = idB, | 1942 | bID = idB, |
1887 | point = new Vector3(contact.X,contact.Y,contact.Z), | 1943 | point = new Vector3(contact.X,contact.Y,contact.Z), |
1888 | normal = new Vector3(contactNormal.X,contactNormal.Y,contactNormal.Z) | 1944 | normal = new Vector3(contactNormal.X,contactNormal.Y,contactNormal.Z), |
1945 | penetration = penetration | ||
1946 | |||
1889 | }; | 1947 | }; |
1890 | if (world.LastCollisionDesc < world.UpdatedCollisions.Length) | 1948 | if (world.LastCollisionDesc < world.UpdatedCollisions.Length) |
1891 | world.UpdatedCollisions[world.LastCollisionDesc++] = (cDesc); | 1949 | world.UpdatedCollisions[world.LastCollisionDesc++] = (cDesc); |
@@ -1911,7 +1969,8 @@ private sealed class BulletConstraintXNA : BulletConstraint | |||
1911 | return ent; | 1969 | return ent; |
1912 | } | 1970 | } |
1913 | 1971 | ||
1914 | public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value) { /* TODO */ return false; } | 1972 | public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value) { /* TODO */ |
1973 | return false; } | ||
1915 | 1974 | ||
1916 | public override Vector3 GetLocalScaling(BulletShape pShape) | 1975 | public override Vector3 GetLocalScaling(BulletShape pShape) |
1917 | { | 1976 | { |