From c33b29a105c2491f7c2e9f6747499ea7213ed4a5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 29 Jul 2007 06:23:07 +0000 Subject: * Applying issue#230 - Avatar stuck at region edge (Thanks Babblefrog!) * Fix for issue #237 - Sim startup cannot read a terrain file (Reported by CutterRubio) --- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 62 ++++++++++------------ .../Region/Terrain.BasicTerrain/TerrainEngine.cs | 2 +- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 81e2ea3..4d0699b 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -99,49 +99,43 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { foreach (BasicActor actor in _actors) { - if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256)) - { - float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f; - actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); - actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); - if (actor.Flying) + float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f; + actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); + actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); + if (actor.Flying) { - 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); - } - } - else + 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); + } } else { - if (actor.Position.Y < 0) - { - actor.Position.Y = 0; - } - else if (actor.Position.Y > 256) - { - actor.Position.Y = 256; - } + actor.Position.Z = height; + actor.Velocity.Z = 0; + } - if (actor.Position.X < 0) - { - actor.Position.X = 0; - } - if (actor.Position.X > 256) - { - actor.Position.X = 256; - } + if (actor.Position.Y < 0) + { + actor.Position.Y = 0; + } + else if (actor.Position.Y > 256) + { + actor.Position.Y = 256; + } + + if (actor.Position.X < 0) + { + actor.Position.X = 0; + } + if (actor.Position.X > 256) + { + actor.Position.X = 256; } } } diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index f52d25a..f37d625 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs @@ -1010,7 +1010,7 @@ namespace OpenSim.Region.Terrain for (int y = 0; y < copy.h; y++) { // 512 is the largest possible height before colours clamp - int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(copy.h - y, x) / 512.0), 0.0) * pallete); + int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(copy.h - y, x) / 512.0), 0.0) * (pallete - 1)); bmp.SetPixel(x, y, colours[colorindex]); } } -- cgit v1.1