mirror of
https://github.com/overte-org/overte.git
synced 2025-08-03 23:43:30 +02:00
falling onto an object works
This commit is contained in:
parent
a254f017cc
commit
b4998e9c53
3 changed files with 27 additions and 2 deletions
|
@ -181,7 +181,11 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
{
|
||||
PerformanceTimer perfTimer("transform");
|
||||
updateOrientation(deltaTime);
|
||||
updatePosition(deltaTime);
|
||||
if (_enablePhysics) {
|
||||
updatePhysicsPosition(deltaTime);
|
||||
} else {
|
||||
updatePosition(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1391,6 +1395,26 @@ void MyAvatar::updatePosition(float deltaTime) {
|
|||
measureMotionDerivatives(deltaTime);
|
||||
}
|
||||
|
||||
|
||||
void MyAvatar::updatePhysicsPosition(float deltaTime) {
|
||||
glm::vec3 velocity = _velocity;
|
||||
|
||||
bool pushingUp = (_driveKeys[UP] - _driveKeys[DOWN] > 0.0f) || _scriptedMotorVelocity.y > 0.0f;
|
||||
|
||||
glm::quat rotation = getHead()->getCameraOrientation();
|
||||
glm::vec3 localVelocity = glm::inverse(rotation) * velocity;
|
||||
|
||||
bool hasFloor = false;
|
||||
glm::vec3 newLocalVelocity = applyKeyboardMotor(deltaTime, localVelocity, hasFloor);
|
||||
newLocalVelocity = applyScriptedMotor(deltaTime, newLocalVelocity);
|
||||
|
||||
// rotate back into world-frame
|
||||
velocity = rotation * newLocalVelocity;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MyAvatar::updateCollisionWithEnvironment(float deltaTime, float radius) {
|
||||
glm::vec3 up = getBodyUpDirection();
|
||||
const float ENVIRONMENT_SURFACE_ELASTICITY = 0.0f;
|
||||
|
|
|
@ -235,6 +235,7 @@ private:
|
|||
glm::vec3 applyKeyboardMotor(float deltaTime, const glm::vec3& velocity, bool walkingOnFloor);
|
||||
glm::vec3 applyScriptedMotor(float deltaTime, const glm::vec3& velocity);
|
||||
void updatePosition(float deltaTime);
|
||||
void updatePhysicsPosition(float deltaTime);
|
||||
void updateCollisionWithAvatars(float deltaTime);
|
||||
void updateCollisionWithEnvironment(float deltaTime, float radius);
|
||||
void updateCollisionWithVoxels(float deltaTime, float radius);
|
||||
|
|
|
@ -370,7 +370,7 @@ void PhysicsEngine::computeCollisionEvents() {
|
|||
btBroadphasePairArray& pairArray = _avatarGhostObject->getOverlappingPairCache()->getOverlappingPairArray();
|
||||
int numPairs = pairArray.size();
|
||||
|
||||
for (int i=0;i<numPairs;i++) {
|
||||
for (int i = 0; i < numPairs; i++) {
|
||||
manifoldArray.clear();
|
||||
const btBroadphasePair& pair = pairArray[i];
|
||||
// unless we manually perform collision detection on this pair, the contacts are in the dynamics world paircache:
|
||||
|
|
Loading…
Reference in a new issue