mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
fixed a physics bug in avatar body spring (forgot to use deltaTime) - and adjusted various physics constants accordingly.
This commit is contained in:
parent
85ad5601d7
commit
cb8e68f300
3 changed files with 22 additions and 14 deletions
|
@ -32,9 +32,14 @@ const float BODY_ROLL_WHILE_TURNING = 0.1;
|
||||||
const float LIN_VEL_DECAY = 5.0;
|
const float LIN_VEL_DECAY = 5.0;
|
||||||
const float MY_HAND_HOLDING_PULL = 0.2;
|
const float MY_HAND_HOLDING_PULL = 0.2;
|
||||||
const float YOUR_HAND_HOLDING_PULL = 1.0;
|
const float YOUR_HAND_HOLDING_PULL = 1.0;
|
||||||
const float BODY_SPRING_FORCE = 6.0f;
|
|
||||||
|
//const float BODY_SPRING_DEFAULT_TIGHTNESS = 20.0f;
|
||||||
|
//const float BODY_SPRING_FORCE = 6.0f;
|
||||||
|
|
||||||
|
const float BODY_SPRING_DEFAULT_TIGHTNESS = 1500.0f;
|
||||||
|
const float BODY_SPRING_FORCE = 300.0f;
|
||||||
|
|
||||||
const float BODY_SPRING_DECAY = 16.0f;
|
const float BODY_SPRING_DECAY = 16.0f;
|
||||||
const float BODY_SPRING_DEFAULT_TIGHTNESS = 20.0f;
|
|
||||||
const float COLLISION_RADIUS_SCALAR = 1.8;
|
const float COLLISION_RADIUS_SCALAR = 1.8;
|
||||||
const float COLLISION_BALL_FORCE = 1.0;
|
const float COLLISION_BALL_FORCE = 1.0;
|
||||||
const float COLLISION_BODY_FORCE = 6.0;
|
const float COLLISION_BODY_FORCE = 6.0;
|
||||||
|
@ -336,10 +341,6 @@ void Avatar::simulate(float deltaTime) {
|
||||||
//update the movement of the hand and process handshaking with other avatars...
|
//update the movement of the hand and process handshaking with other avatars...
|
||||||
updateHandMovementAndTouching(deltaTime);
|
updateHandMovementAndTouching(deltaTime);
|
||||||
|
|
||||||
// test for avatar collision response with the big sphere
|
|
||||||
if (usingBigSphereCollisionTest) {
|
|
||||||
updateCollisionWithSphere( _TEST_bigSpherePosition, _TEST_bigSphereRadius, deltaTime );
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply gravity and collision wiht the ground/floor
|
// apply gravity and collision wiht the ground/floor
|
||||||
if ( AVATAR_GRAVITY ) {
|
if ( AVATAR_GRAVITY ) {
|
||||||
|
@ -354,6 +355,11 @@ void Avatar::simulate(float deltaTime) {
|
||||||
// update body springs
|
// update body springs
|
||||||
updateBodySprings( deltaTime );
|
updateBodySprings( deltaTime );
|
||||||
|
|
||||||
|
// test for avatar collision response with the big sphere
|
||||||
|
if (usingBigSphereCollisionTest) {
|
||||||
|
updateCollisionWithSphere( _TEST_bigSpherePosition, _TEST_bigSphereRadius, deltaTime );
|
||||||
|
}
|
||||||
|
|
||||||
// driving the avatar around should only apply if this is my avatar (as opposed to an avatar being driven remotely)
|
// driving the avatar around should only apply if this is my avatar (as opposed to an avatar being driven remotely)
|
||||||
if ( _isMine ) {
|
if ( _isMine ) {
|
||||||
|
|
||||||
|
@ -670,9 +676,9 @@ void Avatar::updateCollisionWithSphere( glm::vec3 position, float radius, float
|
||||||
float penetration = 1.0 - (distanceToBigSphereCenter / combinedRadius);
|
float penetration = 1.0 - (distanceToBigSphereCenter / combinedRadius);
|
||||||
glm::vec3 collisionForce = vectorFromJointToBigSphereCenter * penetration;
|
glm::vec3 collisionForce = vectorFromJointToBigSphereCenter * penetration;
|
||||||
|
|
||||||
_joint[b].springyVelocity += collisionForce * 30.0f * deltaTime;
|
_joint[b].springyVelocity += collisionForce * 0.0f * deltaTime;
|
||||||
_velocity += collisionForce * 100.0f * deltaTime;
|
_velocity += collisionForce * 40.0f * deltaTime;
|
||||||
_joint[b].springyPosition = position + directionVector * combinedRadius;
|
_joint[b].springyPosition = position + directionVector * combinedRadius;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1292,7 +1298,7 @@ void Avatar::updateBodySprings( float deltaTime ) {
|
||||||
_joint[b].springyVelocity = glm::vec3( 0.0f, 0.0f, 0.0f );
|
_joint[b].springyVelocity = glm::vec3( 0.0f, 0.0f, 0.0f );
|
||||||
}
|
}
|
||||||
|
|
||||||
_joint[b].springyPosition += _joint[b].springyVelocity;
|
_joint[b].springyPosition += _joint[b].springyVelocity * deltaTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,12 +245,14 @@ void renderDiskShadow(glm::vec3 position, glm::vec3 upDirection, float radius, f
|
||||||
glColor4f( 0.0f, 0.0f, 0.0f, darkness );
|
glColor4f( 0.0f, 0.0f, 0.0f, darkness );
|
||||||
|
|
||||||
int num = 20;
|
int num = 20;
|
||||||
float y = 0.01f;
|
float y = 0.001f;
|
||||||
float x2 = 0.0f;
|
float x2 = 0.0f;
|
||||||
float z2 = radius;
|
float z2 = radius;
|
||||||
float x1;
|
float x1;
|
||||||
float z1;
|
float z1;
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
for (int i=1; i<num+1; i++) {
|
for (int i=1; i<num+1; i++) {
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
z1 = z2;
|
z1 = z2;
|
||||||
|
@ -258,12 +260,12 @@ void renderDiskShadow(glm::vec3 position, glm::vec3 upDirection, float radius, f
|
||||||
x2 = radius * sin(r);
|
x2 = radius * sin(r);
|
||||||
z2 = radius * cos(r);
|
z2 = radius * cos(r);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLES);
|
|
||||||
glVertex3f(position.x, y, position.z );
|
glVertex3f(position.x, y, position.z );
|
||||||
glVertex3f(position.x + x1, y, position.z + z1);
|
glVertex3f(position.x + x1, y, position.z + z1);
|
||||||
glVertex3f(position.x + x2, y, position.z + z2);
|
glVertex3f(position.x + x2, y, position.z + z2);
|
||||||
glEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ void display(void)
|
||||||
float firstPersonTightness = 100.0f;
|
float firstPersonTightness = 100.0f;
|
||||||
|
|
||||||
float thirdPersonPitch = 0.0f;
|
float thirdPersonPitch = 0.0f;
|
||||||
float thirdPersonUpShift = -0.1f;
|
float thirdPersonUpShift = -0.2f;
|
||||||
float thirdPersonDistance = 1.2f;
|
float thirdPersonDistance = 1.2f;
|
||||||
float thirdPersonTightness = 8.0f;
|
float thirdPersonTightness = 8.0f;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue