aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/physics
diff options
context:
space:
mode:
authorlbsa712007-03-13 08:55:47 +0000
committerlbsa712007-03-13 08:55:47 +0000
commit0587158f9208ecf9f39a6dd0ef7cb7c5663a39f8 (patch)
treebf86015426ec54fa1f1b5902236670f752473497 /src/physics
parent(no commit message) (diff)
downloadopensim-SC_OLD-0587158f9208ecf9f39a6dd0ef7cb7c5663a39f8.zip
opensim-SC_OLD-0587158f9208ecf9f39a6dd0ef7cb7c5663a39f8.tar.gz
opensim-SC_OLD-0587158f9208ecf9f39a6dd0ef7cb7c5663a39f8.tar.bz2
opensim-SC_OLD-0587158f9208ecf9f39a6dd0ef7cb7c5663a39f8.tar.xz
-- Trying to get trunk to run from first build
* Collected required dll's into /bin * Moved timer start for great justice * Added some Writes to Console, and a Status field * Added dumb NullPhysicsScene and NullPhysicsActor that kicks in if Physics Plugin not specified * Svn-ignored a shitload
Diffstat (limited to 'src/physics')
-rw-r--r--src/physics/PhysicsManager.cs119
1 files changed, 115 insertions, 4 deletions
diff --git a/src/physics/PhysicsManager.cs b/src/physics/PhysicsManager.cs
index e5d5bd6..1fee628 100644
--- a/src/physics/PhysicsManager.cs
+++ b/src/physics/PhysicsManager.cs
@@ -46,15 +46,21 @@ namespace PhysicsSystem
46 46
47 public PhysicsScene GetPhysicsScene(string engineName) 47 public PhysicsScene GetPhysicsScene(string engineName)
48 { 48 {
49 if(_plugins.ContainsKey(engineName)) 49 if( String.IsNullOrEmpty( engineName ) )
50 {
51 return new NullPhysicsScene();
52 }
53
54 if(_plugins.ContainsKey(engineName))
50 { 55 {
51 ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName); 56 ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName);
52 return _plugins[engineName].GetScene(); 57 return _plugins[engineName].GetScene();
53 } 58 }
54 else 59 else
55 { 60 {
56 ServerConsole.MainConsole.Instance.WriteLine("couldn't find physicsEngine: "+ engineName); 61 string error = String.Format("couldn't find physicsEngine: {0}", engineName);
57 return null; 62 ServerConsole.MainConsole.Instance.WriteLine( error );
63 throw new ArgumentException( error );
58 } 64 }
59 } 65 }
60 66
@@ -108,6 +114,14 @@ namespace PhysicsSystem
108 114
109 public abstract class PhysicsScene 115 public abstract class PhysicsScene
110 { 116 {
117 public static PhysicsScene Null
118 {
119 get
120 {
121 return new NullPhysicsScene();
122 }
123 }
124
111 public abstract PhysicsActor AddAvatar(PhysicsVector position); 125 public abstract PhysicsActor AddAvatar(PhysicsVector position);
112 126
113 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size); 127 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
@@ -124,8 +138,49 @@ namespace PhysicsSystem
124 } 138 }
125 } 139 }
126 140
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
127 public abstract class PhysicsActor 180 public abstract class PhysicsActor
128 { 181 {
182 public static readonly PhysicsActor Null = new NullPhysicsActor();
183
129 public abstract PhysicsVector Position 184 public abstract PhysicsVector Position
130 { 185 {
131 get; 186 get;
@@ -153,7 +208,61 @@ namespace PhysicsSystem
153 public abstract void SetMomentum(PhysicsVector momentum); 208 public abstract void SetMomentum(PhysicsVector momentum);
154 } 209 }
155 210
156 public class PhysicsVector 211 public class NullPhysicsActor : PhysicsActor
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
157 { 266 {
158 public float X; 267 public float X;
159 public float Y; 268 public float Y;
@@ -170,5 +279,7 @@ namespace PhysicsSystem
170 Y = y; 279 Y = y;
171 Z = z; 280 Z = z;
172 } 281 }
282
283 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
173 } 284 }
174} 285}