aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/BasicPhysics
diff options
context:
space:
mode:
authorDiva Canto2015-08-30 20:06:53 -0700
committerDiva Canto2015-08-30 20:06:53 -0700
commit1d6b33bc2da3b312cff1d1802a73aacdf72b0385 (patch)
tree393736b501aac3b31eb0810bb72d926c7f14fbf8 /OpenSim/Region/PhysicsModules/BasicPhysics
parentMoved instantiation of SceneCommunicationService object to inside the scene c... (diff)
downloadopensim-SC_OLD-1d6b33bc2da3b312cff1d1802a73aacdf72b0385.zip
opensim-SC_OLD-1d6b33bc2da3b312cff1d1802a73aacdf72b0385.tar.gz
opensim-SC_OLD-1d6b33bc2da3b312cff1d1802a73aacdf72b0385.tar.bz2
opensim-SC_OLD-1d6b33bc2da3b312cff1d1802a73aacdf72b0385.tar.xz
Major renaming of Physics dlls / folders. No functional changes, just renames.
Diffstat (limited to 'OpenSim/Region/PhysicsModules/BasicPhysics')
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs303
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPlugin.cs64
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs316
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs210
5 files changed, 951 insertions, 0 deletions
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs
new file mode 100644
index 0000000..7d054dd
--- /dev/null
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs
@@ -0,0 +1,58 @@
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
28using System.Reflection;
29using System.Runtime.InteropServices;
30
31// Information about this assembly is defined by the following
32// attributes.
33//
34// change them to the information which is associated with the assembly
35// you compile.
36
37[assembly : AssemblyTitle("BasicPhysicsPlugin")]
38[assembly : AssemblyDescription("")]
39[assembly : AssemblyConfiguration("")]
40[assembly : AssemblyCompany("http://opensimulator.org")]
41[assembly : AssemblyProduct("BasicPhysicsPlugin")]
42[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")]
43[assembly : AssemblyTrademark("")]
44[assembly : AssemblyCulture("")]
45
46// This sets the default COM visibility of types in the assembly to invisible.
47// If you need to expose a type to COM, use [ComVisible(true)] on that type.
48
49[assembly : ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly : AssemblyVersion("0.8.2.*")]
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs
new file mode 100644
index 0000000..43fba7b
--- /dev/null
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs
@@ -0,0 +1,303 @@
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
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager;
34
35namespace OpenSim.Region.Physics.BasicPhysicsPlugin
36{
37 public class BasicActor : PhysicsActor
38 {
39 public BasicActor(Vector3 size)
40 {
41 Size = size;
42 }
43
44 public override int PhysicsActorType
45 {
46 get { return (int) ActorTypes.Agent; }
47 set { return; }
48 }
49
50 public override Vector3 RotationalVelocity { get; set; }
51
52 public override bool SetAlwaysRun
53 {
54 get { return false; }
55 set { return; }
56 }
57
58 public override uint LocalID
59 {
60 set { return; }
61 }
62
63 public override bool Grabbed
64 {
65 set { return; }
66 }
67
68 public override bool Selected
69 {
70 set { return; }
71 }
72
73 public override float Buoyancy
74 {
75 get { return 0f; }
76 set { return; }
77 }
78
79 public override bool FloatOnWater
80 {
81 set { return; }
82 }
83
84 public override bool IsPhysical
85 {
86 get { return false; }
87 set { return; }
88 }
89
90 public override bool ThrottleUpdates
91 {
92 get { return false; }
93 set { return; }
94 }
95
96 public override bool Flying { get; set; }
97
98 public override bool IsColliding { get; set; }
99
100 public override bool CollidingGround
101 {
102 get { return false; }
103 set { return; }
104 }
105
106 public override bool CollidingObj
107 {
108 get { return false; }
109 set { return; }
110 }
111
112 public override bool Stopped
113 {
114 get { return false; }
115 }
116
117 public override Vector3 Position { get; set; }
118
119 public override Vector3 Size { get; set; }
120
121 public override PrimitiveBaseShape Shape
122 {
123 set { return; }
124 }
125
126 public override float Mass
127 {
128 get { return 0f; }
129 }
130
131 public override Vector3 Force
132 {
133 get { return Vector3.Zero; }
134 set { return; }
135 }
136
137 public override int VehicleType
138 {
139 get { return 0; }
140 set { return; }
141 }
142
143 public override void VehicleFloatParam(int param, float value)
144 {
145
146 }
147
148 public override void VehicleVectorParam(int param, Vector3 value)
149 {
150
151 }
152
153 public override void VehicleRotationParam(int param, Quaternion rotation)
154 {
155
156 }
157
158 public override void VehicleFlags(int param, bool remove)
159 {
160
161 }
162
163 public override void SetVolumeDetect(int param)
164 {
165
166 }
167
168 public override Vector3 CenterOfMass
169 {
170 get { return Vector3.Zero; }
171 }
172
173 public override Vector3 GeometricCenter
174 {
175 get { return Vector3.Zero; }
176 }
177
178 public override Vector3 Velocity { get; set; }
179
180 public override Vector3 Torque
181 {
182 get { return Vector3.Zero; }
183 set { return; }
184 }
185
186 public override float CollisionScore
187 {
188 get { return 0f; }
189 set { }
190 }
191
192 public override Quaternion Orientation
193 {
194 get { return Quaternion.Identity; }
195 set { }
196 }
197
198 public override Vector3 Acceleration { get; set; }
199
200 public override bool Kinematic
201 {
202 get { return true; }
203 set { }
204 }
205
206 public override void link(PhysicsActor obj)
207 {
208 }
209
210 public override void delink()
211 {
212 }
213
214 public override void LockAngularMotion(Vector3 axis)
215 {
216 }
217
218 public override void AddForce(Vector3 force, bool pushforce)
219 {
220 }
221
222 public override void AddAngularForce(Vector3 force, bool pushforce)
223 {
224 }
225
226 public override void SetMomentum(Vector3 momentum)
227 {
228 }
229
230 public override void CrossingFailure()
231 {
232 }
233
234 public override Vector3 PIDTarget
235 {
236 set { return; }
237 }
238
239 public override bool PIDActive
240 {
241 get { return false; }
242 set { return; }
243 }
244
245 public override float PIDTau
246 {
247 set { return; }
248 }
249
250 public override float PIDHoverHeight
251 {
252 set { return; }
253 }
254
255 public override bool PIDHoverActive
256 {
257 set { return; }
258 }
259
260 public override PIDHoverType PIDHoverType
261 {
262 set { return; }
263 }
264
265 public override float PIDHoverTau
266 {
267 set { return; }
268 }
269
270 public override Quaternion APIDTarget
271 {
272 set { return; }
273 }
274
275 public override bool APIDActive
276 {
277 set { return; }
278 }
279
280 public override float APIDStrength
281 {
282 set { return; }
283 }
284
285 public override float APIDDamping
286 {
287 set { return; }
288 }
289
290 public override void SubscribeEvents(int ms)
291 {
292 }
293
294 public override void UnSubscribeEvents()
295 {
296 }
297
298 public override bool SubscribedEvents()
299 {
300 return false;
301 }
302 }
303}
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPlugin.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPlugin.cs
new file mode 100644
index 0000000..373c7e0
--- /dev/null
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPlugin.cs
@@ -0,0 +1,64 @@
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
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33
34namespace OpenSim.Region.Physics.BasicPhysicsPlugin
35{
36 /// <summary>
37 /// Effectively a physics plugin that simulates no physics at all.
38 /// </summary>
39 public class BasicPhysicsPlugin : IPhysicsPlugin
40 {
41 public BasicPhysicsPlugin()
42 {
43 }
44
45 public bool Init()
46 {
47 return true;
48 }
49
50 public PhysicsScene GetScene(string sceneIdentifier)
51 {
52 return new BasicScene(GetName(), sceneIdentifier);
53 }
54
55 public string GetName()
56 {
57 return ("basicphysics");
58 }
59
60 public void Dispose()
61 {
62 }
63 }
64}
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs
new file mode 100644
index 0000000..dfe4c19
--- /dev/null
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs
@@ -0,0 +1,316 @@
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
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager;
34
35namespace OpenSim.Region.Physics.BasicPhysicsPlugin
36{
37 public class BasicPhysicsPrim : PhysicsActor
38 {
39 private Vector3 _size;
40// private PrimitiveBaseShape _shape;
41
42 public BasicPhysicsPrim(
43 string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape)
44 {
45 Name = name;
46 LocalID = localId;
47 Position = position;
48 Size = size;
49 Orientation = orientation;
50 Shape = shape;
51 }
52
53 public override int PhysicsActorType
54 {
55 get { return (int) ActorTypes.Agent; }
56 set { return; }
57 }
58
59 public override Vector3 RotationalVelocity { get; set; }
60
61 public override bool SetAlwaysRun
62 {
63 get { return false; }
64 set { return; }
65 }
66
67 public override uint LocalID
68 {
69 set { return; }
70 }
71
72 public override bool Grabbed
73 {
74 set { return; }
75 }
76
77 public override bool Selected
78 {
79 set { return; }
80 }
81
82 public override float Buoyancy
83 {
84 get { return 0f; }
85 set { return; }
86 }
87
88 public override bool FloatOnWater
89 {
90 set { return; }
91 }
92
93 public override bool IsPhysical
94 {
95 get { return false; }
96 set { return; }
97 }
98
99 public override bool ThrottleUpdates
100 {
101 get { return false; }
102 set { return; }
103 }
104
105 public override bool Flying { get; set; }
106
107 public override bool IsColliding { get; set; }
108
109 public override bool CollidingGround
110 {
111 get { return false; }
112 set { return; }
113 }
114
115 public override bool CollidingObj
116 {
117 get { return false; }
118 set { return; }
119 }
120
121 public override bool Stopped
122 {
123 get { return false; }
124 }
125
126 public override Vector3 Position { get; set; }
127
128 public override Vector3 Size
129 {
130 get { return _size; }
131 set {
132 _size = value;
133 _size.Z = _size.Z / 2.0f;
134 }
135 }
136
137 public override PrimitiveBaseShape Shape
138 {
139// set { _shape = value; }
140 set {}
141 }
142
143 public override float Mass
144 {
145 get { return 0f; }
146 }
147
148 public override Vector3 Force
149 {
150 get { return Vector3.Zero; }
151 set { return; }
152 }
153
154 public override int VehicleType
155 {
156 get { return 0; }
157 set { return; }
158 }
159
160 public override void VehicleFloatParam(int param, float value)
161 {
162
163 }
164
165 public override void VehicleVectorParam(int param, Vector3 value)
166 {
167
168 }
169
170 public override void VehicleRotationParam(int param, Quaternion rotation)
171 {
172
173 }
174
175 public override void VehicleFlags(int param, bool remove)
176 {
177
178 }
179
180 public override void SetVolumeDetect(int param)
181 {
182
183 }
184
185 public override Vector3 CenterOfMass
186 {
187 get { return Vector3.Zero; }
188 }
189
190 public override Vector3 GeometricCenter
191 {
192 get { return Vector3.Zero; }
193 }
194
195 public override Vector3 Velocity { get; set; }
196
197 public override Vector3 Torque
198 {
199 get { return Vector3.Zero; }
200 set { return; }
201 }
202
203 public override float CollisionScore
204 {
205 get { return 0f; }
206 set { }
207 }
208
209 public override Quaternion Orientation { get; set; }
210
211 public override Vector3 Acceleration { get; set; }
212
213 public override bool Kinematic
214 {
215 get { return true; }
216 set { }
217 }
218
219 public override void link(PhysicsActor obj)
220 {
221 }
222
223 public override void delink()
224 {
225 }
226
227 public override void LockAngularMotion(Vector3 axis)
228 {
229 }
230
231 public override void AddForce(Vector3 force, bool pushforce)
232 {
233 }
234
235 public override void AddAngularForce(Vector3 force, bool pushforce)
236 {
237 }
238
239 public override void SetMomentum(Vector3 momentum)
240 {
241 }
242
243 public override void CrossingFailure()
244 {
245 }
246
247 public override Vector3 PIDTarget
248 {
249 set { return; }
250 }
251
252 public override bool PIDActive
253 {
254 get { return false; }
255 set { return; }
256 }
257
258 public override float PIDTau
259 {
260 set { return; }
261 }
262
263 public override float PIDHoverHeight
264 {
265 set { return; }
266 }
267
268 public override bool PIDHoverActive
269 {
270 set { return; }
271 }
272
273 public override PIDHoverType PIDHoverType
274 {
275 set { return; }
276 }
277
278 public override float PIDHoverTau
279 {
280 set { return; }
281 }
282
283 public override Quaternion APIDTarget
284 {
285 set { return; }
286 }
287
288 public override bool APIDActive
289 {
290 set { return; }
291 }
292
293 public override float APIDStrength
294 {
295 set { return; }
296 }
297
298 public override float APIDDamping
299 {
300 set { return; }
301 }
302
303 public override void SubscribeEvents(int ms)
304 {
305 }
306
307 public override void UnSubscribeEvents()
308 {
309 }
310
311 public override bool SubscribedEvents()
312 {
313 return false;
314 }
315 }
316}
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs
new file mode 100644
index 0000000..06a205e
--- /dev/null
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs
@@ -0,0 +1,210 @@
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
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager;
34
35namespace OpenSim.Region.Physics.BasicPhysicsPlugin
36{
37 /// <summary>
38 /// This is an incomplete extremely basic physics implementation
39 /// </summary>
40 /// <remarks>
41 /// Not useful for anything at the moment apart from some regression testing in other components where some form
42 /// of physics plugin is needed.
43 /// </remarks>
44 public class BasicScene : PhysicsScene
45 {
46 private List<BasicActor> _actors = new List<BasicActor>();
47 private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>();
48 private float[] _heightMap;
49 private Vector3 m_regionExtent;
50
51 //protected internal string sceneIdentifier;
52
53 public BasicScene(string engineType, string _sceneIdentifier)
54 {
55 EngineType = engineType;
56 Name = EngineType + "/" + _sceneIdentifier;
57 //sceneIdentifier = _sceneIdentifier;
58 }
59
60 public override void Initialise(IMesher meshmerizer, IConfigSource config)
61 {
62 throw new Exception("Should not be called.");
63 }
64
65 public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
66 {
67 m_regionExtent = regionExtent;
68 }
69
70 public override void Dispose() {}
71
72 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
73 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
74 {
75 BasicPhysicsPrim prim = new BasicPhysicsPrim(primName, localid, position, size, rotation, pbs);
76 prim.IsPhysical = isPhysical;
77
78 _prims.Add(prim);
79
80 return prim;
81 }
82
83 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
84 {
85 BasicActor act = new BasicActor(size);
86 act.Position = position;
87 act.Velocity = velocity;
88 act.Flying = isFlying;
89 _actors.Add(act);
90 return act;
91 }
92
93 public override void RemovePrim(PhysicsActor actor)
94 {
95 BasicPhysicsPrim prim = (BasicPhysicsPrim)actor;
96 if (_prims.Contains(prim))
97 _prims.Remove(prim);
98 }
99
100 public override void RemoveAvatar(PhysicsActor actor)
101 {
102 BasicActor act = (BasicActor)actor;
103 if (_actors.Contains(act))
104 _actors.Remove(act);
105 }
106
107 public override void AddPhysicsActorTaint(PhysicsActor prim)
108 {
109 }
110
111 public override float Simulate(float timeStep)
112 {
113// Console.WriteLine("Simulating");
114
115 float fps = 0;
116 for (int i = 0; i < _actors.Count; ++i)
117 {
118 BasicActor actor = _actors[i];
119 Vector3 actorPosition = actor.Position;
120 Vector3 actorVelocity = actor.Velocity;
121
122// Console.WriteLine(
123// "Processing actor {0}, starting pos {1}, starting vel {2}", i, actorPosition, actorVelocity);
124
125 actorPosition.X += actor.Velocity.X * timeStep;
126 actorPosition.Y += actor.Velocity.Y * timeStep;
127
128 if (actor.Position.Y < 0)
129 {
130 actorPosition.Y = 0.1F;
131 }
132 else if (actor.Position.Y >= m_regionExtent.Y)
133 {
134 actorPosition.Y = (m_regionExtent.Y - 0.1f);
135 }
136
137 if (actor.Position.X < 0)
138 {
139 actorPosition.X = 0.1F;
140 }
141 else if (actor.Position.X >= m_regionExtent.X)
142 {
143 actorPosition.X = (m_regionExtent.X - 0.1f);
144 }
145
146 float terrainHeight = 0;
147 if (_heightMap != null)
148 terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X];
149
150 float height = terrainHeight + actor.Size.Z;
151// Console.WriteLine("height {0}, actorPosition {1}", height, actorPosition);
152
153 if (actor.Flying)
154 {
155 if (actor.Position.Z + (actor.Velocity.Z * timeStep) < terrainHeight + 2)
156 {
157 actorPosition.Z = height;
158 actorVelocity.Z = 0;
159 actor.IsColliding = true;
160 }
161 else
162 {
163 actorPosition.Z += actor.Velocity.Z * timeStep;
164 actor.IsColliding = false;
165 }
166 }
167 else
168 {
169 actorPosition.Z = height;
170 actorVelocity.Z = 0;
171 actor.IsColliding = true;
172 }
173
174 actor.Position = actorPosition;
175 actor.Velocity = actorVelocity;
176 }
177
178 return fps;
179 }
180
181 public override void GetResults()
182 {
183 }
184
185 public override bool IsThreaded
186 {
187 get { return (false); // for now we won't be multithreaded
188 }
189 }
190
191 public override void SetTerrain(float[] heightMap)
192 {
193 _heightMap = heightMap;
194 }
195
196 public override void DeleteTerrain()
197 {
198 }
199
200 public override void SetWaterLevel(float baseheight)
201 {
202 }
203
204 public override Dictionary<uint, float> GetTopColliders()
205 {
206 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
207 return returncolliders;
208 }
209 }
210}