diff options
Diffstat (limited to 'OpenSim/Region/Physics/POSPlugin')
-rw-r--r-- | OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 39 |
1 files changed, 17 insertions, 22 deletions
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 | |||
65 | { | 65 | { |
66 | private List<POSActor> _actors = new List<POSActor>(); | 66 | private List<POSActor> _actors = new List<POSActor>(); |
67 | private float[] _heightMap; | 67 | private float[] _heightMap; |
68 | private const float gravity = -1.0f; | ||
68 | 69 | ||
69 | public POSScene() | 70 | public POSScene() |
70 | { | 71 | { |
@@ -119,15 +120,13 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
119 | { | 120 | { |
120 | foreach (POSActor actor in _actors) | 121 | foreach (POSActor actor in _actors) |
121 | { | 122 | { |
122 | actor.Position.X = actor.Position.X + (actor.Velocity.X*timeStep); | 123 | actor.Position.X += actor.Velocity.X * timeStep; |
123 | actor.Position.Y = actor.Position.Y + (actor.Velocity.Y*timeStep); | 124 | actor.Position.Y += actor.Velocity.Y * timeStep; |
124 | if (actor.Position.Y < 0) | 125 | actor.Position.Z += actor.Velocity.Z * timeStep; |
125 | { | 126 | |
126 | actor.Position.Y = 0.1F; | 127 | if (!actor.Flying) |
127 | } | ||
128 | else if (actor.Position.Y >= 256) | ||
129 | { | 128 | { |
130 | actor.Position.Y = 255.9F; | 129 | actor.Velocity.Z += gravity; |
131 | } | 130 | } |
132 | 131 | ||
133 | if (actor.Position.X < 0) | 132 | if (actor.Position.X < 0) |
@@ -139,23 +138,19 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
139 | actor.Position.X = 255.9F; | 138 | actor.Position.X = 255.9F; |
140 | } | 139 | } |
141 | 140 | ||
142 | float height = _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 1.0f; | 141 | if (actor.Position.Y < 0) |
143 | if (actor.Flying) | ||
144 | { | 142 | { |
145 | if (actor.Position.Z + (actor.Velocity.Z*timeStep) < | 143 | actor.Position.Y = 0.1F; |
146 | _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 2) | ||
147 | { | ||
148 | actor.Position.Z = height; | ||
149 | actor.Velocity.Z = 0; | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | actor.Position.Z = actor.Position.Z + (actor.Velocity.Z*timeStep); | ||
154 | } | ||
155 | } | 144 | } |
156 | else | 145 | else if (actor.Position.Y >= 256) |
146 | { | ||
147 | actor.Position.Y = 255.9F; | ||
148 | } | ||
149 | |||
150 | float terrainheight = _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X]; | ||
151 | if (actor.Position.Z + (actor.Velocity.Z * timeStep) < terrainheight + 2) | ||
157 | { | 152 | { |
158 | actor.Position.Z = height; | 153 | actor.Position.Z = terrainheight + 1.0f; |
159 | actor.Velocity.Z = 0; | 154 | actor.Velocity.Z = 0; |
160 | } | 155 | } |
161 | } | 156 | } |