PhysicsScene.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) OpenSim project, http://sim.opensecondlife.org/
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above copyright
  9. * notice, this list of conditions and the following disclaimer in the
  10. * documentation and/or other materials provided with the distribution.
  11. * * Neither the name of the <organization> nor the
  12. * names of its contributors may be used to endorse or promote products
  13. * derived from this software without specific prior written permission.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
  16. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  19. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Text;
  30. namespace OpenSim.Physics.Manager
  31. {
  32. public abstract class PhysicsScene
  33. {
  34. public static PhysicsScene Null
  35. {
  36. get
  37. {
  38. return new NullPhysicsScene();
  39. }
  40. }
  41. public abstract PhysicsActor AddAvatar(PhysicsVector position);
  42. public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
  43. public abstract void Simulate(float timeStep);
  44. public abstract void GetResults();
  45. public abstract void SetTerrain(float[] heightMap);
  46. public abstract void DeleteTerrain();
  47. public abstract bool IsThreaded
  48. {
  49. get;
  50. }
  51. }
  52. public class NullPhysicsScene : PhysicsScene
  53. {
  54. private static int m_workIndicator;
  55. public override PhysicsActor AddAvatar(PhysicsVector position)
  56. {
  57. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : AddAvatar({0})", position);
  58. return PhysicsActor.Null;
  59. }
  60. public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
  61. {
  62. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : AddPrim({0},{1})", position, size);
  63. return PhysicsActor.Null;
  64. }
  65. public override void Simulate(float timeStep)
  66. {
  67. m_workIndicator = (m_workIndicator + 1) % 10;
  68. //OpenSim.Framework.Console.MainConsole.Instance.SetStatus(m_workIndicator.ToString());
  69. }
  70. public override void GetResults()
  71. {
  72. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : GetResults()");
  73. }
  74. public override void SetTerrain(float[] heightMap)
  75. {
  76. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length);
  77. }
  78. public override void DeleteTerrain()
  79. {
  80. }
  81. public override bool IsThreaded
  82. {
  83. get { return false; }
  84. }
  85. }
  86. }