From a41762de19ff2e26296925d932fadf6be0336a6e Mon Sep 17 00:00:00 2001 From: Date: Mon, 25 Aug 2008 15:56:34 +0000 Subject: [PATCH] Simian avatar physics update: Fixed TERMINAL_VELOCITY not adjusting for elapsed time, adjusted horizontal inertia falloff for flying and falling git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@2167 52acb1d6-8a22-11de-b505-999d5b087335 --- Programs/Simian/Extensions/Movement.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Programs/Simian/Extensions/Movement.cs b/Programs/Simian/Extensions/Movement.cs index 88377a56..5b81e406 100644 --- a/Programs/Simian/Extensions/Movement.cs +++ b/Programs/Simian/Extensions/Movement.cs @@ -120,9 +120,9 @@ namespace Simian.Extensions agent.TickJump = 0; //velocity falloff while flying - agent.Avatar.Velocity.X *= 0.4f; - agent.Avatar.Velocity.Y *= 0.4f; - agent.Avatar.Velocity.Z *= 0.2f; + agent.Avatar.Velocity.X *= 0.66f; + agent.Avatar.Velocity.Y *= 0.66f; + agent.Avatar.Velocity.Z *= 0.33f; if (move.X != 0 || move.Y != 0) { //flying horizontally @@ -164,6 +164,9 @@ namespace Simian.Extensions if (!jumping) { //falling + + agent.Avatar.Velocity *= 0.99f; + if (fallElapsed > FALL_DELAY) { //falling long enough to trigger the animation if (server.Avatars.SetDefaultAnimation(agent, Animations.FALLDOWN)) @@ -248,12 +251,12 @@ namespace Simian.Extensions if (animsChanged) server.Avatars.SendAnimations(agent); - // static acceleration when any control is held + // static acceleration when any control is held, otherwise none if (moving) agent.Avatar.Acceleration = move * speed; //FIXME - // taper off speed when no controls are held - else agent.Avatar.Acceleration *= 0.8f; + else agent.Avatar.Acceleration = Vector3.Zero; - if (gravity > AVATAR_TERMINAL_VELOCITY) gravity = AVATAR_TERMINAL_VELOCITY; + float maxVel = AVATAR_TERMINAL_VELOCITY * seconds; + if (gravity > maxVel) gravity = maxVel; agent.Avatar.Velocity += agent.Avatar.Acceleration - new Vector3(0f, 0f, gravity); agent.Avatar.Position += agent.Avatar.Velocity;