aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/POSPlugin/POSScene.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSScene.cs52
1 files changed, 28 insertions, 24 deletions
diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
index fa8cc70..c3f5040 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Region.Physics.POSPlugin
56 { 56 {
57 } 57 }
58 58
59 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 59 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
60 { 60 {
61 POSCharacter act = new POSCharacter(); 61 POSCharacter act = new POSCharacter();
62 act.Position = position; 62 act.Position = position;
@@ -84,20 +84,20 @@ namespace OpenSim.Region.Physics.POSPlugin
84 } 84 }
85 85
86/* 86/*
87 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 87 public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
88 { 88 {
89 return null; 89 return null;
90 } 90 }
91*/ 91*/
92 92
93 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 93 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
94 PhysicsVector size, Quaternion rotation) 94 Vector3 size, Quaternion rotation)
95 { 95 {
96 return AddPrimShape(primName, pbs, position, size, rotation, false); 96 return AddPrimShape(primName, pbs, position, size, rotation, false);
97 } 97 }
98 98
99 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 99 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
100 PhysicsVector size, Quaternion rotation, bool isPhysical) 100 Vector3 size, Quaternion rotation, bool isPhysical)
101 { 101 {
102 POSPrim prim = new POSPrim(); 102 POSPrim prim = new POSPrim();
103 prim.Position = position; 103 prim.Position = position;
@@ -152,23 +152,25 @@ namespace OpenSim.Region.Physics.POSPlugin
152 character._target_velocity.Z += gravity * timeStep; 152 character._target_velocity.Z += gravity * timeStep;
153 } 153 }
154 154
155 character.Position.X += character._target_velocity.X * timeStep; 155 Vector3 characterPosition = character.Position;
156 character.Position.Y += character._target_velocity.Y * timeStep;
157 156
158 character.Position.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f); 157 characterPosition.X += character._target_velocity.X * timeStep;
159 character.Position.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f); 158 characterPosition.Y += character._target_velocity.Y * timeStep;
159
160 characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
161 characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
160 162
161 bool forcedZ = false; 163 bool forcedZ = false;
162 164
163 float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X]; 165 float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X];
164 if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) 166 if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2)
165 { 167 {
166 character.Position.Z = terrainheight + character.Size.Z; 168 characterPosition.Z = terrainheight + character.Size.Z;
167 forcedZ = true; 169 forcedZ = true;
168 } 170 }
169 else 171 else
170 { 172 {
171 character.Position.Z += character._target_velocity.Z*timeStep; 173 characterPosition.Z += character._target_velocity.Z*timeStep;
172 } 174 }
173 175
174 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- 176 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen --
@@ -177,29 +179,29 @@ namespace OpenSim.Region.Physics.POSPlugin
177 179
178 if (isCollidingWithPrim(character)) 180 if (isCollidingWithPrim(character))
179 { 181 {
180 character.Position.Z = oldposZ; // first try Z axis 182 characterPosition.Z = oldposZ; // first try Z axis
181 if (isCollidingWithPrim(character)) 183 if (isCollidingWithPrim(character))
182 { 184 {
183 character.Position.Z = oldposZ + character.Size.Z / 4.4f; // try harder 185 characterPosition.Z = oldposZ + character.Size.Z / 4.4f; // try harder
184 if (isCollidingWithPrim(character)) 186 if (isCollidingWithPrim(character))
185 { 187 {
186 character.Position.Z = oldposZ + character.Size.Z / 2.2f; // try very hard 188 characterPosition.Z = oldposZ + character.Size.Z / 2.2f; // try very hard
187 if (isCollidingWithPrim(character)) 189 if (isCollidingWithPrim(character))
188 { 190 {
189 character.Position.X = oldposX; 191 characterPosition.X = oldposX;
190 character.Position.Y = oldposY; 192 characterPosition.Y = oldposY;
191 character.Position.Z = oldposZ; 193 characterPosition.Z = oldposZ;
192 194
193 character.Position.X += character._target_velocity.X * timeStep; 195 characterPosition.X += character._target_velocity.X * timeStep;
194 if (isCollidingWithPrim(character)) 196 if (isCollidingWithPrim(character))
195 { 197 {
196 character.Position.X = oldposX; 198 characterPosition.X = oldposX;
197 } 199 }
198 200
199 character.Position.Y += character._target_velocity.Y * timeStep; 201 characterPosition.Y += character._target_velocity.Y * timeStep;
200 if (isCollidingWithPrim(character)) 202 if (isCollidingWithPrim(character))
201 { 203 {
202 character.Position.Y = oldposY; 204 characterPosition.Y = oldposY;
203 } 205 }
204 } 206 }
205 else 207 else
@@ -218,8 +220,10 @@ namespace OpenSim.Region.Physics.POSPlugin
218 } 220 }
219 } 221 }
220 222
221 character.Position.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f); 223 characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
222 character.Position.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f); 224 characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
225
226 character.Position = characterPosition;
223 227
224 character._velocity.X = (character.Position.X - oldposX)/timeStep; 228 character._velocity.X = (character.Position.X - oldposX)/timeStep;
225 character._velocity.Y = (character.Position.Y - oldposY)/timeStep; 229 character._velocity.Y = (character.Position.Y - oldposY)/timeStep;