diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
commit | bdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch) | |
tree | d00eb50b749cb001e2b08272c91791e66740b05d /extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp | |
parent | 78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff) | |
parent | 7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff) |
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
Diffstat (limited to 'extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp')
-rw-r--r-- | extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp b/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp index d53de7f3687..fe65245c2a1 100644 --- a/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp +++ b/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp @@ -23,12 +23,11 @@ #include "BulletDynamics/ConstraintSolver/btContactConstraint.h" - - static btRigidBody s_fixedObject( 0,0,0); btRaycastVehicle::btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster ) -:m_vehicleRaycaster(raycaster), +: btTypedConstraint(VEHICLE_CONSTRAINT_TYPE), +m_vehicleRaycaster(raycaster), m_pitchControl(btScalar(0.)) { m_chassisBody = chassis; @@ -487,6 +486,7 @@ struct btWheelContactPoint }; +btScalar calcRollingFriction(btWheelContactPoint& contactPoint); btScalar calcRollingFriction(btWheelContactPoint& contactPoint) { @@ -507,8 +507,8 @@ btScalar calcRollingFriction(btWheelContactPoint& contactPoint) // calculate j that moves us to zero relative velocity j1 = -vrel * contactPoint.m_jacDiagABInv; - GEN_set_min(j1, maxImpulse); - GEN_set_max(j1, -maxImpulse); + btSetMin(j1, maxImpulse); + btSetMax(j1, -maxImpulse); return j1; } @@ -525,11 +525,10 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) if (!numWheel) return; - - btVector3* forwardWS = new btVector3[numWheel]; - btVector3* axle = new btVector3[numWheel]; - btScalar* forwardImpulse = new btScalar[numWheel]; - btScalar* sideImpulse = new btScalar[numWheel]; + m_forwardWS.resize(numWheel); + m_axle.resize(numWheel); + m_forwardImpulse.resize(numWheel); + m_sideImpulse.resize(numWheel); int numWheelsOnGround = 0; @@ -541,8 +540,8 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) class btRigidBody* groundObject = (class btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject; if (groundObject) numWheelsOnGround++; - sideImpulse[i] = btScalar(0.); - forwardImpulse[i] = btScalar(0.); + m_sideImpulse[i] = btScalar(0.); + m_forwardImpulse[i] = btScalar(0.); } @@ -561,25 +560,25 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) const btTransform& wheelTrans = getWheelTransformWS( i ); btMatrix3x3 wheelBasis0 = wheelTrans.getBasis(); - axle[i] = btVector3( + m_axle[i] = btVector3( wheelBasis0[0][m_indexRightAxis], wheelBasis0[1][m_indexRightAxis], wheelBasis0[2][m_indexRightAxis]); const btVector3& surfNormalWS = wheelInfo.m_raycastInfo.m_contactNormalWS; - btScalar proj = axle[i].dot(surfNormalWS); - axle[i] -= surfNormalWS * proj; - axle[i] = axle[i].normalize(); + btScalar proj = m_axle[i].dot(surfNormalWS); + m_axle[i] -= surfNormalWS * proj; + m_axle[i] = m_axle[i].normalize(); - forwardWS[i] = surfNormalWS.cross(axle[i]); - forwardWS[i].normalize(); + m_forwardWS[i] = surfNormalWS.cross(m_axle[i]); + m_forwardWS[i].normalize(); resolveSingleBilateral(*m_chassisBody, wheelInfo.m_raycastInfo.m_contactPointWS, *groundObject, wheelInfo.m_raycastInfo.m_contactPointWS, - btScalar(0.), axle[i],sideImpulse[i],timeStep); + btScalar(0.), m_axle[i],m_sideImpulse[i],timeStep); - sideImpulse[i] *= sideFrictionStiffness2; + m_sideImpulse[i] *= sideFrictionStiffness2; } @@ -608,7 +607,7 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) { btScalar defaultRollingFrictionImpulse = 0.f; btScalar maxImpulse = wheelInfo.m_brake ? wheelInfo.m_brake : defaultRollingFrictionImpulse; - btWheelContactPoint contactPt(m_chassisBody,groundObject,wheelInfo.m_raycastInfo.m_contactPointWS,forwardWS[wheel],maxImpulse); + btWheelContactPoint contactPt(m_chassisBody,groundObject,wheelInfo.m_raycastInfo.m_contactPointWS,m_forwardWS[wheel],maxImpulse); rollingFriction = calcRollingFriction(contactPt); } } @@ -618,7 +617,7 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) - forwardImpulse[wheel] = btScalar(0.); + m_forwardImpulse[wheel] = btScalar(0.); m_wheelInfo[wheel].m_skidInfo= btScalar(1.); if (groundObject) @@ -631,10 +630,10 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) btScalar maximpSquared = maximp * maximpSide; - forwardImpulse[wheel] = rollingFriction;//wheelInfo.m_engineForce* timeStep; + m_forwardImpulse[wheel] = rollingFriction;//wheelInfo.m_engineForce* timeStep; - btScalar x = (forwardImpulse[wheel] ) * fwdFactor; - btScalar y = (sideImpulse[wheel] ) * sideFactor; + btScalar x = (m_forwardImpulse[wheel] ) * fwdFactor; + btScalar y = (m_sideImpulse[wheel] ) * sideFactor; btScalar impulseSquared = (x*x + y*y); @@ -658,12 +657,12 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) { for (int wheel = 0;wheel < getNumWheels(); wheel++) { - if (sideImpulse[wheel] != btScalar(0.)) + if (m_sideImpulse[wheel] != btScalar(0.)) { if (m_wheelInfo[wheel].m_skidInfo< btScalar(1.)) { - forwardImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo; - sideImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo; + m_forwardImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo; + m_sideImpulse[wheel] *= m_wheelInfo[wheel].m_skidInfo; } } } @@ -678,11 +677,11 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) btVector3 rel_pos = wheelInfo.m_raycastInfo.m_contactPointWS - m_chassisBody->getCenterOfMassPosition(); - if (forwardImpulse[wheel] != btScalar(0.)) + if (m_forwardImpulse[wheel] != btScalar(0.)) { - m_chassisBody->applyImpulse(forwardWS[wheel]*(forwardImpulse[wheel]),rel_pos); + m_chassisBody->applyImpulse(m_forwardWS[wheel]*(m_forwardImpulse[wheel]),rel_pos); } - if (sideImpulse[wheel] != btScalar(0.)) + if (m_sideImpulse[wheel] != btScalar(0.)) { class btRigidBody* groundObject = (class btRigidBody*) m_wheelInfo[wheel].m_raycastInfo.m_groundObject; @@ -690,7 +689,7 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) groundObject->getCenterOfMassPosition(); - btVector3 sideImp = axle[wheel] * sideImpulse[wheel]; + btVector3 sideImp = m_axle[wheel] * m_sideImpulse[wheel]; rel_pos[2] *= wheelInfo.m_rollInfluence; m_chassisBody->applyImpulse(sideImp,rel_pos); @@ -701,10 +700,7 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) } } - delete []forwardWS; - delete [] axle; - delete[]forwardImpulse; - delete[] sideImpulse; + } @@ -716,11 +712,11 @@ void* btDefaultVehicleRaycaster::castRay(const btVector3& from,const btVector3& m_dynamicsWorld->rayTest(from, to, rayCallback); - if (rayCallback.HasHit()) + if (rayCallback.hasHit()) { btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject); - if (body) + if (body && body->hasContactResponse()) { result.m_hitPointInWorld = rayCallback.m_hitPointWorld; result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld; |