From ba9b3171221e4c5072ab35a70439bf0cc2da76a5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 17 Nov 2007 06:25:41 +0000 Subject: added some POS gravity --- OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 39 ++++++++++++--------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index ef7b1f0..5b4450c 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -65,6 +65,7 @@ namespace OpenSim.Region.Physics.POSPlugin { private List _actors = new List(); private float[] _heightMap; + private const float gravity = -1.0f; public POSScene() { @@ -119,15 +120,13 @@ namespace OpenSim.Region.Physics.POSPlugin { foreach (POSActor actor in _actors) { - actor.Position.X = actor.Position.X + (actor.Velocity.X*timeStep); - actor.Position.Y = actor.Position.Y + (actor.Velocity.Y*timeStep); - if (actor.Position.Y < 0) - { - actor.Position.Y = 0.1F; - } - else if (actor.Position.Y >= 256) + actor.Position.X += actor.Velocity.X * timeStep; + actor.Position.Y += actor.Velocity.Y * timeStep; + actor.Position.Z += actor.Velocity.Z * timeStep; + + if (!actor.Flying) { - actor.Position.Y = 255.9F; + actor.Velocity.Z += gravity; } if (actor.Position.X < 0) @@ -139,23 +138,19 @@ namespace OpenSim.Region.Physics.POSPlugin actor.Position.X = 255.9F; } - float height = _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 1.0f; - if (actor.Flying) + if (actor.Position.Y < 0) { - if (actor.Position.Z + (actor.Velocity.Z*timeStep) < - _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 2) - { - actor.Position.Z = height; - actor.Velocity.Z = 0; - } - else - { - actor.Position.Z = actor.Position.Z + (actor.Velocity.Z*timeStep); - } + actor.Position.Y = 0.1F; } - else + else if (actor.Position.Y >= 256) + { + actor.Position.Y = 255.9F; + } + + float terrainheight = _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X]; + if (actor.Position.Z + (actor.Velocity.Z * timeStep) < terrainheight + 2) { - actor.Position.Z = height; + actor.Position.Z = terrainheight + 1.0f; actor.Velocity.Z = 0; } } -- cgit v1.1