PhysicsScene.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. using OpenSim.Framework.Console;
  31. namespace OpenSim.Physics.Manager
  32. {
  33. public abstract class PhysicsScene
  34. {
  35. public static PhysicsScene Null
  36. {
  37. get
  38. {
  39. return new NullPhysicsScene();
  40. }
  41. }
  42. public abstract PhysicsActor AddAvatar(PhysicsVector position);
  43. public abstract void RemoveAvatar(PhysicsActor actor);
  44. public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
  45. public abstract void Simulate(float timeStep);
  46. public abstract void GetResults();
  47. public abstract void SetTerrain(float[] heightMap);
  48. public abstract void DeleteTerrain();
  49. public abstract bool IsThreaded
  50. {
  51. get;
  52. }
  53. }
  54. public class NullPhysicsScene : PhysicsScene
  55. {
  56. private static int m_workIndicator;
  57. public override PhysicsActor AddAvatar(PhysicsVector position)
  58. {
  59. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE,"NullPhysicsScene : AddAvatar({0})", position);
  60. return PhysicsActor.Null;
  61. }
  62. public override void RemoveAvatar(PhysicsActor actor)
  63. {
  64. }
  65. public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
  66. {
  67. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE, "NullPhysicsScene : AddPrim({0},{1})", position, size);
  68. return PhysicsActor.Null;
  69. }
  70. public override void Simulate(float timeStep)
  71. {
  72. m_workIndicator = (m_workIndicator + 1) % 10;
  73. //OpenSim.Framework.Console.MainConsole.Instance.SetStatus(m_workIndicator.ToString());
  74. }
  75. public override void GetResults()
  76. {
  77. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE, "NullPhysicsScene : GetResults()");
  78. }
  79. public override void SetTerrain(float[] heightMap)
  80. {
  81. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.VERBOSE, "NullPhysicsScene : SetTerrain({0} items)", heightMap.Length);
  82. }
  83. public override void DeleteTerrain()
  84. {
  85. }
  86. public override bool IsThreaded
  87. {
  88. get { return false; }
  89. }
  90. }
  91. }