aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/physics/PhysicsManager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/physics/PhysicsManager.cs119
1 files changed, 4 insertions, 115 deletions
diff --git a/src/physics/PhysicsManager.cs b/src/physics/PhysicsManager.cs
index 1fee628..e5d5bd6 100644
--- a/src/physics/PhysicsManager.cs
+++ b/src/physics/PhysicsManager.cs
@@ -46,21 +46,15 @@ namespace PhysicsSystem
46 46
47 public PhysicsScene GetPhysicsScene(string engineName) 47 public PhysicsScene GetPhysicsScene(string engineName)
48 { 48 {
49 if( String.IsNullOrEmpty( engineName ) ) 49 if(_plugins.ContainsKey(engineName))
50 {
51 return new NullPhysicsScene();
52 }
53
54 if(_plugins.ContainsKey(engineName))
55 { 50 {
56 ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName); 51 ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName);
57 return _plugins[engineName].GetScene(); 52 return _plugins[engineName].GetScene();
58 } 53 }
59 else 54 else
60 { 55 {
61 string error = String.Format("couldn't find physicsEngine: {0}", engineName); 56 ServerConsole.MainConsole.Instance.WriteLine("couldn't find physicsEngine: "+ engineName);
62 ServerConsole.MainConsole.Instance.WriteLine( error ); 57 return null;
63 throw new ArgumentException( error );
64 } 58 }
65 } 59 }
66 60
@@ -114,14 +108,6 @@ namespace PhysicsSystem
114 108
115 public abstract class PhysicsScene 109 public abstract class PhysicsScene
116 { 110 {
117 public static PhysicsScene Null
118 {
119 get
120 {
121 return new NullPhysicsScene();
122 }
123 }
124
125 public abstract PhysicsActor AddAvatar(PhysicsVector position); 111 public abstract PhysicsActor AddAvatar(PhysicsVector position);
126 112
127 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size); 113 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
@@ -138,49 +124,8 @@ namespace PhysicsSystem
138 } 124 }
139 } 125 }
140 126
141 public class NullPhysicsScene : PhysicsScene
142 {
143 private static int m_workIndicator;
144
145 public override PhysicsActor AddAvatar(PhysicsVector position)
146 {
147 ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : AddAvatar({0})", position );
148 return PhysicsActor.Null;
149 }
150
151 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
152 {
153 ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : AddPrim({0},{1})", position, size );
154 return PhysicsActor.Null;
155 }
156
157 public override void Simulate(float timeStep)
158 {
159 m_workIndicator = ( m_workIndicator + 1 ) % 10;
160
161 ServerConsole.MainConsole.Instance.SetStatus( m_workIndicator.ToString() );
162 }
163
164 public override void GetResults()
165 {
166 ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : GetResults()" );
167 }
168
169 public override void SetTerrain(float[] heightMap)
170 {
171 ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length );
172 }
173
174 public override bool IsThreaded
175 {
176 get { return false; }
177 }
178 }
179
180 public abstract class PhysicsActor 127 public abstract class PhysicsActor
181 { 128 {
182 public static readonly PhysicsActor Null = new NullPhysicsActor();
183
184 public abstract PhysicsVector Position 129 public abstract PhysicsVector Position
185 { 130 {
186 get; 131 get;
@@ -208,61 +153,7 @@ namespace PhysicsSystem
208 public abstract void SetMomentum(PhysicsVector momentum); 153 public abstract void SetMomentum(PhysicsVector momentum);
209 } 154 }
210 155
211 public class NullPhysicsActor : PhysicsActor 156 public class PhysicsVector
212 {
213 public override PhysicsVector Position
214 {
215 get
216 {
217 return PhysicsVector.Zero;
218 }
219 set
220 {
221 return;
222 }
223 }
224
225 public override PhysicsVector Velocity
226 {
227 get
228 {
229 return PhysicsVector.Zero;
230 }
231 set
232 {
233 return;
234 }
235 }
236
237 public override PhysicsVector Acceleration
238 {
239 get { return PhysicsVector.Zero; }
240 }
241
242 public override bool Flying
243 {
244 get
245 {
246 return false;
247 }
248 set
249 {
250 return;
251 }
252 }
253
254 public override void AddForce(PhysicsVector force)
255 {
256 return;
257 }
258
259 public override void SetMomentum(PhysicsVector momentum)
260 {
261 return;
262 }
263 }
264
265 public class PhysicsVector
266 { 157 {
267 public float X; 158 public float X;
268 public float Y; 159 public float Y;
@@ -279,7 +170,5 @@ namespace PhysicsSystem
279 Y = y; 170 Y = y;
280 Z = z; 171 Z = z;
281 } 172 }
282
283 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
284 } 173 }
285} 174}