aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs')
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs416
1 files changed, 1 insertions, 415 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index d3d10bf..7ab2a03 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -25,9 +25,9 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using Nini.Config; 30using Nini.Config;
30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.Physics.Manager;
33 33
@@ -61,418 +61,4 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
61 { 61 {
62 } 62 }
63 } 63 }
64
65 public class BasicScene : PhysicsScene
66 {
67 private List<BasicActor> _actors = new List<BasicActor>();
68 private float[] _heightMap;
69
70 //protected internal string sceneIdentifier;
71
72 public BasicScene(string _sceneIdentifier)
73 {
74 //sceneIdentifier = _sceneIdentifier;
75 }
76
77 public override void Initialise(IMesher meshmerizer, IConfigSource config)
78 {
79 // Does nothing right now
80 }
81
82 public override void Dispose()
83 {
84
85 }
86 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying)
87 {
88 BasicActor act = new BasicActor();
89 act.Position = position;
90 act.Flying = isFlying;
91 _actors.Add(act);
92 return act;
93 }
94
95 public override void RemovePrim(PhysicsActor prim)
96 {
97 }
98
99 public override void RemoveAvatar(PhysicsActor actor)
100 {
101 BasicActor act = (BasicActor) actor;
102 if (_actors.Contains(act))
103 {
104 _actors.Remove(act);
105 }
106 }
107
108/*
109 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation)
110 {
111 return null;
112 }
113*/
114
115 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
116 PhysicsVector size, Quaternion rotation)
117 {
118 return AddPrimShape(primName, pbs, position, size, rotation, false);
119 }
120
121 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
122 PhysicsVector size, Quaternion rotation, bool isPhysical)
123 {
124 return null;
125 }
126
127 public override void AddPhysicsActorTaint(PhysicsActor prim)
128 {
129 }
130
131 public override float Simulate(float timeStep)
132 {
133 float fps = 0;
134 for (int i = 0; i < _actors.Count; ++i)
135 {
136 BasicActor actor = _actors[i];
137
138 actor.Position.X += actor.Velocity.X*timeStep;
139 actor.Position.Y += actor.Velocity.Y*timeStep;
140
141 if (actor.Position.Y < 0)
142 {
143 actor.Position.Y = 0.1F;
144 }
145 else if (actor.Position.Y >= Constants.RegionSize)
146 {
147 actor.Position.Y = ((int)Constants.RegionSize - 0.1f);
148 }
149
150 if (actor.Position.X < 0)
151 {
152 actor.Position.X = 0.1F;
153 }
154 else if (actor.Position.X >= Constants.RegionSize)
155 {
156 actor.Position.X = ((int)Constants.RegionSize - 0.1f);
157 }
158
159 float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + actor.Size.Z;
160 if (actor.Flying)
161 {
162 if (actor.Position.Z + (actor.Velocity.Z*timeStep) <
163 _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 2)
164 {
165 actor.Position.Z = height;
166 actor.Velocity.Z = 0;
167 actor.IsColliding = true;
168 }
169 else
170 {
171 actor.Position.Z += actor.Velocity.Z*timeStep;
172 actor.IsColliding = false;
173 }
174 }
175 else
176 {
177 actor.Position.Z = height;
178 actor.Velocity.Z = 0;
179 actor.IsColliding = true;
180 }
181 }
182 return fps;
183 }
184
185 public override void GetResults()
186 {
187 }
188
189 public override bool IsThreaded
190 {
191 get { return (false); // for now we won't be multithreaded
192 }
193 }
194
195 public override void SetTerrain(float[] heightMap)
196 {
197 _heightMap = heightMap;
198 }
199
200 public override void SetWaterLevel(float baseheight)
201 {
202
203 }
204
205 public override void DeleteTerrain()
206 {
207 }
208 public override Dictionary<uint, float> GetTopColliders()
209 {
210 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
211 return returncolliders;
212 }
213
214 }
215
216 public class BasicActor : PhysicsActor
217 {
218 private PhysicsVector _position;
219 private PhysicsVector _velocity;
220 private PhysicsVector _acceleration;
221 private PhysicsVector _size;
222 private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero;
223 private bool flying;
224 private bool iscolliding;
225 public BasicActor()
226 {
227 _velocity = new PhysicsVector();
228 _position = new PhysicsVector();
229 _acceleration = new PhysicsVector();
230 _size = new PhysicsVector();
231 }
232
233 public override int PhysicsActorType
234 {
235 get { return (int) ActorTypes.Agent; }
236 set { return; }
237 }
238
239 public override PhysicsVector RotationalVelocity
240 {
241 get { return m_rotationalVelocity; }
242 set { m_rotationalVelocity = value; }
243 }
244
245 public override bool SetAlwaysRun
246 {
247 get { return false; }
248 set { return; }
249 }
250
251 public override uint LocalID
252 {
253 set { return; }
254 }
255
256 public override bool Grabbed
257 {
258 set { return; }
259 }
260
261 public override bool Selected
262 {
263 set { return; }
264 }
265
266 public override float Buoyancy
267 {
268 get { return 0f; }
269 set { return; }
270 }
271
272 public override bool FloatOnWater
273 {
274 set { return; }
275 }
276
277 public override bool IsPhysical
278 {
279 get { return false; }
280 set { return; }
281 }
282
283 public override bool ThrottleUpdates
284 {
285 get { return false; }
286 set { return; }
287 }
288
289 public override bool Flying
290 {
291 get { return flying; }
292 set { flying = value; }
293 }
294
295 public override bool IsColliding
296 {
297 get { return iscolliding; }
298 set { iscolliding = value; }
299 }
300
301 public override bool CollidingGround
302 {
303 get { return false; }
304 set { return; }
305 }
306
307 public override bool CollidingObj
308 {
309 get { return false; }
310 set { return; }
311 }
312
313 public override bool Stopped
314 {
315 get { return false; }
316 }
317
318
319 public override PhysicsVector Position
320 {
321 get { return _position; }
322 set { _position = value; }
323 }
324
325 public override PhysicsVector Size
326 {
327 get { return _size; }
328 set {
329 _size = value;
330 _size.Z = _size.Z / 2.0f;
331 }
332 }
333
334 public override PrimitiveBaseShape Shape
335 {
336 set { return; }
337 }
338
339 public override float Mass
340 {
341 get { return 0f; }
342 }
343
344 public override PhysicsVector Force
345 {
346 get { return PhysicsVector.Zero; }
347 set { return; }
348 }
349
350 public override int VehicleType
351 {
352 get { return 0; }
353 set { return; }
354 }
355
356 public override void VehicleFloatParam(int param, float value)
357 {
358
359 }
360
361 public override void VehicleVectorParam(int param, PhysicsVector value)
362 {
363
364 }
365
366 public override void VehicleRotationParam(int param, Quaternion rotation)
367 {
368
369 }
370
371 public override void SetVolumeDetect(int param)
372 {
373
374 }
375
376 public override PhysicsVector CenterOfMass
377 {
378 get { return PhysicsVector.Zero; }
379 }
380
381 public override PhysicsVector GeometricCenter
382 {
383 get { return PhysicsVector.Zero; }
384 }
385
386 public override PhysicsVector Velocity
387 {
388 get { return _velocity; }
389 set { _velocity = value; }
390 }
391
392 public override PhysicsVector Torque
393 {
394 get { return PhysicsVector.Zero; }
395 set { return; }
396 }
397
398 public override float CollisionScore
399 {
400 get { return 0f; }
401 set { }
402 }
403
404 public override Quaternion Orientation
405 {
406 get { return Quaternion.Identity; }
407 set { }
408 }
409
410 public override PhysicsVector Acceleration
411 {
412 get { return _acceleration; }
413 }
414
415 public override bool Kinematic
416 {
417 get { return true; }
418 set { }
419 }
420
421 public override void link(PhysicsActor obj)
422 {
423 }
424
425 public override void delink()
426 {
427 }
428
429 public override void LockAngularMotion(PhysicsVector axis)
430 {
431
432 }
433
434 public void SetAcceleration(PhysicsVector accel)
435 {
436 _acceleration = accel;
437 }
438
439 public override void AddForce(PhysicsVector force, bool pushforce)
440 {
441 }
442
443 public override void AddAngularForce(PhysicsVector force, bool pushforce)
444 {
445 }
446
447 public override void SetMomentum(PhysicsVector momentum)
448 {
449 }
450
451 public override void CrossingFailure()
452 {
453 }
454
455 public override PhysicsVector PIDTarget { set { return; } }
456 public override bool PIDActive { set { return; } }
457 public override float PIDTau { set { return; } }
458
459 public override float PIDHoverHeight { set { return; } }
460 public override bool PIDHoverActive { set { return; } }
461 public override PIDHoverType PIDHoverType { set { return; } }
462 public override float PIDHoverTau { set { return; } }
463
464
465 public override void SubscribeEvents(int ms)
466 {
467
468 }
469 public override void UnSubscribeEvents()
470 {
471
472 }
473 public override bool SubscribedEvents()
474 {
475 return false;
476 }
477 }
478} 64}