Differential D1739 Diff 5899 extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
Changeset View
Changeset View
Standalone View
Standalone View
extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
| Show All 23 Lines | |||||
| #include "LinearMath/btDefaultMotionState.h" | #include "LinearMath/btDefaultMotionState.h" | ||||
| #include "btKinematicCharacterController.h" | #include "btKinematicCharacterController.h" | ||||
| // static helper method | // static helper method | ||||
| static btVector3 | static btVector3 | ||||
| getNormalizedVector(const btVector3& v) | getNormalizedVector(const btVector3& v) | ||||
| { | { | ||||
| btScalar l = v.length(); | btVector3 n(0, 0, 0); | ||||
| btVector3 n = v; | |||||
| if (l < SIMD_EPSILON) { | if (v.length() > SIMD_EPSILON) { | ||||
| n.setValue(0,0,0); | n = v.normalized(); | ||||
| } else { | |||||
| n /= l; | |||||
| } | } | ||||
| return n; | return n; | ||||
| } | } | ||||
| ///@todo Interact with dynamic objects, | ///@todo Interact with dynamic objects, | ||||
| ///Ride kinematicly animated platforms properly | ///Ride kinematicly animated platforms properly | ||||
| ///More realistic (or maybe just a config option) falling | ///More realistic (or maybe just a config option) falling | ||||
| /// -> Should integrate falling velocity manually and use that in stepDown() | /// -> Should integrate falling velocity manually and use that in stepDown() | ||||
| ▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | while (fraction > btScalar(0.01) && maxIter-- > 0) | ||||
| m_convexShape->setMargin(margin); | m_convexShape->setMargin(margin); | ||||
| fraction -= callback.m_closestHitFraction; | fraction -= callback.m_closestHitFraction; | ||||
| if (callback.hasHit()) | if (callback.hasHit()) | ||||
| { | { | ||||
| // we moved only a fraction | // we moved only a fraction | ||||
| btScalar hitDistance; | //btScalar hitDistance; | ||||
| hitDistance = (callback.m_hitPointWorld - m_currentPosition).length(); | //hitDistance = (callback.m_hitPointWorld - m_currentPosition).length(); | ||||
| // m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); | // m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); | ||||
| updateTargetPositionBasedOnCollision (callback.m_hitNormalWorld); | updateTargetPositionBasedOnCollision (callback.m_hitNormalWorld); | ||||
| btVector3 currentDir = m_targetPosition - m_currentPosition; | btVector3 currentDir = m_targetPosition - m_currentPosition; | ||||
| distance2 = currentDir.length2(); | distance2 = currentDir.length2(); | ||||
| if (distance2 > SIMD_EPSILON) | if (distance2 > SIMD_EPSILON) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| void btKinematicCharacterController::playerStep ( btCollisionWorld* collisionWorld, btScalar dt) | void btKinematicCharacterController::playerStep ( btCollisionWorld* collisionWorld, btScalar dt) | ||||
| { | { | ||||
| // printf("playerStep(): "); | // printf("playerStep(): "); | ||||
| // printf(" dt = %f", dt); | // printf(" dt = %f", dt); | ||||
| // quick check... | // quick check... | ||||
| if (!m_useWalkDirection && m_velocityTimeInterval <= 0.0) { | if (!m_useWalkDirection && (m_velocityTimeInterval <= 0.0 || m_walkDirection.fuzzyZero())) { | ||||
| // printf("\n"); | // printf("\n"); | ||||
| return; // no motion | return; // no motion | ||||
| } | } | ||||
| m_wasOnGround = onGround(); | m_wasOnGround = onGround(); | ||||
| // Update fall velocity. | // Update fall velocity. | ||||
| m_verticalVelocity -= m_gravity * dt; | m_verticalVelocity -= m_gravity * dt; | ||||
| ▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines | |||||