diff options
author | Jeff Ames | 2009-08-11 00:24:39 +0900 |
---|---|---|
committer | Jeff Ames | 2009-08-11 00:32:59 +0900 |
commit | 8863092f7c0e97b5ebae797c059b6c8c03e948b9 (patch) | |
tree | bf509bad1c25dd75ac0bc5a3163858cffdbfaa0c | |
parent | Removed IAssetCache. (diff) | |
download | opensim-SC-8863092f7c0e97b5ebae797c059b6c8c03e948b9.zip opensim-SC-8863092f7c0e97b5ebae797c059b6c8c03e948b9.tar.gz opensim-SC-8863092f7c0e97b5ebae797c059b6c8c03e948b9.tar.bz2 opensim-SC-8863092f7c0e97b5ebae797c059b6c8c03e948b9.tar.xz |
Split BasicPhysics classes into separate files.
Diffstat (limited to '')
3 files changed, 508 insertions, 415 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs new file mode 100644 index 0000000..a74eb0c --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs | |||
@@ -0,0 +1,322 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.Physics.Manager; | ||
34 | |||
35 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin | ||
36 | { | ||
37 | public class BasicActor : PhysicsActor | ||
38 | { | ||
39 | private PhysicsVector _position; | ||
40 | private PhysicsVector _velocity; | ||
41 | private PhysicsVector _acceleration; | ||
42 | private PhysicsVector _size; | ||
43 | private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; | ||
44 | private bool flying; | ||
45 | private bool iscolliding; | ||
46 | public BasicActor() | ||
47 | { | ||
48 | _velocity = new PhysicsVector(); | ||
49 | _position = new PhysicsVector(); | ||
50 | _acceleration = new PhysicsVector(); | ||
51 | _size = new PhysicsVector(); | ||
52 | } | ||
53 | |||
54 | public override int PhysicsActorType | ||
55 | { | ||
56 | get { return (int) ActorTypes.Agent; } | ||
57 | set { return; } | ||
58 | } | ||
59 | |||
60 | public override PhysicsVector RotationalVelocity | ||
61 | { | ||
62 | get { return m_rotationalVelocity; } | ||
63 | set { m_rotationalVelocity = value; } | ||
64 | } | ||
65 | |||
66 | public override bool SetAlwaysRun | ||
67 | { | ||
68 | get { return false; } | ||
69 | set { return; } | ||
70 | } | ||
71 | |||
72 | public override uint LocalID | ||
73 | { | ||
74 | set { return; } | ||
75 | } | ||
76 | |||
77 | public override bool Grabbed | ||
78 | { | ||
79 | set { return; } | ||
80 | } | ||
81 | |||
82 | public override bool Selected | ||
83 | { | ||
84 | set { return; } | ||
85 | } | ||
86 | |||
87 | public override float Buoyancy | ||
88 | { | ||
89 | get { return 0f; } | ||
90 | set { return; } | ||
91 | } | ||
92 | |||
93 | public override bool FloatOnWater | ||
94 | { | ||
95 | set { return; } | ||
96 | } | ||
97 | |||
98 | public override bool IsPhysical | ||
99 | { | ||
100 | get { return false; } | ||
101 | set { return; } | ||
102 | } | ||
103 | |||
104 | public override bool ThrottleUpdates | ||
105 | { | ||
106 | get { return false; } | ||
107 | set { return; } | ||
108 | } | ||
109 | |||
110 | public override bool Flying | ||
111 | { | ||
112 | get { return flying; } | ||
113 | set { flying = value; } | ||
114 | } | ||
115 | |||
116 | public override bool IsColliding | ||
117 | { | ||
118 | get { return iscolliding; } | ||
119 | set { iscolliding = value; } | ||
120 | } | ||
121 | |||
122 | public override bool CollidingGround | ||
123 | { | ||
124 | get { return false; } | ||
125 | set { return; } | ||
126 | } | ||
127 | |||
128 | public override bool CollidingObj | ||
129 | { | ||
130 | get { return false; } | ||
131 | set { return; } | ||
132 | } | ||
133 | |||
134 | public override bool Stopped | ||
135 | { | ||
136 | get { return false; } | ||
137 | } | ||
138 | |||
139 | public override PhysicsVector Position | ||
140 | { | ||
141 | get { return _position; } | ||
142 | set { _position = value; } | ||
143 | } | ||
144 | |||
145 | public override PhysicsVector Size | ||
146 | { | ||
147 | get { return _size; } | ||
148 | set { | ||
149 | _size = value; | ||
150 | _size.Z = _size.Z / 2.0f; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | public override PrimitiveBaseShape Shape | ||
155 | { | ||
156 | set { return; } | ||
157 | } | ||
158 | |||
159 | public override float Mass | ||
160 | { | ||
161 | get { return 0f; } | ||
162 | } | ||
163 | |||
164 | public override PhysicsVector Force | ||
165 | { | ||
166 | get { return PhysicsVector.Zero; } | ||
167 | set { return; } | ||
168 | } | ||
169 | |||
170 | public override int VehicleType | ||
171 | { | ||
172 | get { return 0; } | ||
173 | set { return; } | ||
174 | } | ||
175 | |||
176 | public override void VehicleFloatParam(int param, float value) | ||
177 | { | ||
178 | |||
179 | } | ||
180 | |||
181 | public override void VehicleVectorParam(int param, PhysicsVector value) | ||
182 | { | ||
183 | |||
184 | } | ||
185 | |||
186 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
187 | { | ||
188 | |||
189 | } | ||
190 | |||
191 | public override void SetVolumeDetect(int param) | ||
192 | { | ||
193 | |||
194 | } | ||
195 | |||
196 | public override PhysicsVector CenterOfMass | ||
197 | { | ||
198 | get { return PhysicsVector.Zero; } | ||
199 | } | ||
200 | |||
201 | public override PhysicsVector GeometricCenter | ||
202 | { | ||
203 | get { return PhysicsVector.Zero; } | ||
204 | } | ||
205 | |||
206 | public override PhysicsVector Velocity | ||
207 | { | ||
208 | get { return _velocity; } | ||
209 | set { _velocity = value; } | ||
210 | } | ||
211 | |||
212 | public override PhysicsVector Torque | ||
213 | { | ||
214 | get { return PhysicsVector.Zero; } | ||
215 | set { return; } | ||
216 | } | ||
217 | |||
218 | public override float CollisionScore | ||
219 | { | ||
220 | get { return 0f; } | ||
221 | set { } | ||
222 | } | ||
223 | |||
224 | public override Quaternion Orientation | ||
225 | { | ||
226 | get { return Quaternion.Identity; } | ||
227 | set { } | ||
228 | } | ||
229 | |||
230 | public override PhysicsVector Acceleration | ||
231 | { | ||
232 | get { return _acceleration; } | ||
233 | } | ||
234 | |||
235 | public override bool Kinematic | ||
236 | { | ||
237 | get { return true; } | ||
238 | set { } | ||
239 | } | ||
240 | |||
241 | public override void link(PhysicsActor obj) | ||
242 | { | ||
243 | } | ||
244 | |||
245 | public override void delink() | ||
246 | { | ||
247 | } | ||
248 | |||
249 | public override void LockAngularMotion(PhysicsVector axis) | ||
250 | { | ||
251 | } | ||
252 | |||
253 | public void SetAcceleration(PhysicsVector accel) | ||
254 | { | ||
255 | _acceleration = accel; | ||
256 | } | ||
257 | |||
258 | public override void AddForce(PhysicsVector force, bool pushforce) | ||
259 | { | ||
260 | } | ||
261 | |||
262 | public override void AddAngularForce(PhysicsVector force, bool pushforce) | ||
263 | { | ||
264 | } | ||
265 | |||
266 | public override void SetMomentum(PhysicsVector momentum) | ||
267 | { | ||
268 | } | ||
269 | |||
270 | public override void CrossingFailure() | ||
271 | { | ||
272 | } | ||
273 | |||
274 | public override PhysicsVector PIDTarget | ||
275 | { | ||
276 | set { return; } | ||
277 | } | ||
278 | |||
279 | public override bool PIDActive | ||
280 | { | ||
281 | set { return; } | ||
282 | } | ||
283 | |||
284 | public override float PIDTau | ||
285 | { | ||
286 | set { return; } | ||
287 | } | ||
288 | |||
289 | public override float PIDHoverHeight | ||
290 | { | ||
291 | set { return; } | ||
292 | } | ||
293 | |||
294 | public override bool PIDHoverActive | ||
295 | { | ||
296 | set { return; } | ||
297 | } | ||
298 | |||
299 | public override PIDHoverType PIDHoverType | ||
300 | { | ||
301 | set { return; } | ||
302 | } | ||
303 | |||
304 | public override float PIDHoverTau | ||
305 | { | ||
306 | set { return; } | ||
307 | } | ||
308 | |||
309 | public override void SubscribeEvents(int ms) | ||
310 | { | ||
311 | } | ||
312 | |||
313 | public override void UnSubscribeEvents() | ||
314 | { | ||
315 | } | ||
316 | |||
317 | public override bool SubscribedEvents() | ||
318 | { | ||
319 | return false; | ||
320 | } | ||
321 | } | ||
322 | } | ||
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 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Physics.Manager; | 32 | using 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 | } |
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs new file mode 100644 index 0000000..66bd099 --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs | |||
@@ -0,0 +1,185 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.Physics.Manager; | ||
34 | |||
35 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin | ||
36 | { | ||
37 | public class BasicScene : PhysicsScene | ||
38 | { | ||
39 | private List<BasicActor> _actors = new List<BasicActor>(); | ||
40 | private float[] _heightMap; | ||
41 | |||
42 | //protected internal string sceneIdentifier; | ||
43 | |||
44 | public BasicScene(string _sceneIdentifier) | ||
45 | { | ||
46 | //sceneIdentifier = _sceneIdentifier; | ||
47 | } | ||
48 | |||
49 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | ||
50 | { | ||
51 | } | ||
52 | |||
53 | public override void Dispose() | ||
54 | { | ||
55 | |||
56 | } | ||
57 | public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) | ||
58 | { | ||
59 | BasicActor act = new BasicActor(); | ||
60 | act.Position = position; | ||
61 | act.Flying = isFlying; | ||
62 | _actors.Add(act); | ||
63 | return act; | ||
64 | } | ||
65 | |||
66 | public override void RemovePrim(PhysicsActor prim) | ||
67 | { | ||
68 | } | ||
69 | |||
70 | public override void RemoveAvatar(PhysicsActor actor) | ||
71 | { | ||
72 | BasicActor act = (BasicActor) actor; | ||
73 | if (_actors.Contains(act)) | ||
74 | { | ||
75 | _actors.Remove(act); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) | ||
81 | { | ||
82 | return null; | ||
83 | } | ||
84 | */ | ||
85 | |||
86 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, | ||
87 | PhysicsVector size, Quaternion rotation) | ||
88 | { | ||
89 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
90 | } | ||
91 | |||
92 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, | ||
93 | PhysicsVector size, Quaternion rotation, bool isPhysical) | ||
94 | { | ||
95 | return null; | ||
96 | } | ||
97 | |||
98 | public override void AddPhysicsActorTaint(PhysicsActor prim) | ||
99 | { | ||
100 | } | ||
101 | |||
102 | public override float Simulate(float timeStep) | ||
103 | { | ||
104 | float fps = 0; | ||
105 | for (int i = 0; i < _actors.Count; ++i) | ||
106 | { | ||
107 | BasicActor actor = _actors[i]; | ||
108 | |||
109 | actor.Position.X += actor.Velocity.X*timeStep; | ||
110 | actor.Position.Y += actor.Velocity.Y*timeStep; | ||
111 | |||
112 | if (actor.Position.Y < 0) | ||
113 | { | ||
114 | actor.Position.Y = 0.1F; | ||
115 | } | ||
116 | else if (actor.Position.Y >= Constants.RegionSize) | ||
117 | { | ||
118 | actor.Position.Y = ((int)Constants.RegionSize - 0.1f); | ||
119 | } | ||
120 | |||
121 | if (actor.Position.X < 0) | ||
122 | { | ||
123 | actor.Position.X = 0.1F; | ||
124 | } | ||
125 | else if (actor.Position.X >= Constants.RegionSize) | ||
126 | { | ||
127 | actor.Position.X = ((int)Constants.RegionSize - 0.1f); | ||
128 | } | ||
129 | |||
130 | float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + actor.Size.Z; | ||
131 | if (actor.Flying) | ||
132 | { | ||
133 | if (actor.Position.Z + (actor.Velocity.Z*timeStep) < | ||
134 | _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 2) | ||
135 | { | ||
136 | actor.Position.Z = height; | ||
137 | actor.Velocity.Z = 0; | ||
138 | actor.IsColliding = true; | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | actor.Position.Z += actor.Velocity.Z*timeStep; | ||
143 | actor.IsColliding = false; | ||
144 | } | ||
145 | } | ||
146 | else | ||
147 | { | ||
148 | actor.Position.Z = height; | ||
149 | actor.Velocity.Z = 0; | ||
150 | actor.IsColliding = true; | ||
151 | } | ||
152 | } | ||
153 | return fps; | ||
154 | } | ||
155 | |||
156 | public override void GetResults() | ||
157 | { | ||
158 | } | ||
159 | |||
160 | public override bool IsThreaded | ||
161 | { | ||
162 | get { return (false); // for now we won't be multithreaded | ||
163 | } | ||
164 | } | ||
165 | |||
166 | public override void SetTerrain(float[] heightMap) | ||
167 | { | ||
168 | _heightMap = heightMap; | ||
169 | } | ||
170 | |||
171 | public override void DeleteTerrain() | ||
172 | { | ||
173 | } | ||
174 | |||
175 | public override void SetWaterLevel(float baseheight) | ||
176 | { | ||
177 | } | ||
178 | |||
179 | public override Dictionary<uint, float> GetTopColliders() | ||
180 | { | ||
181 | Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); | ||
182 | return returncolliders; | ||
183 | } | ||
184 | } | ||
185 | } | ||