aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BasicPhysicsPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BasicPhysicsPlugin')
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs112
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs602
2 files changed, 357 insertions, 357 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
index ce567a9..ecf8e68 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following 30// Information about this assembly is defined by the following
31// attributes. 31// attributes.
32// 32//
33// change them to the information which is associated with the assembly 33// change them to the information which is associated with the assembly
34// you compile. 34// you compile.
35 35
36[assembly: AssemblyTitle("PhysXplugin")] 36[assembly: AssemblyTitle("PhysXplugin")]
37[assembly: AssemblyDescription("")] 37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")] 38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("")] 39[assembly: AssemblyCompany("")]
40[assembly: AssemblyProduct("PhysXplugin")] 40[assembly: AssemblyProduct("PhysXplugin")]
41[assembly: AssemblyCopyright("")] 41[assembly: AssemblyCopyright("")]
42[assembly: AssemblyTrademark("")] 42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")] 43[assembly: AssemblyCulture("")]
44 44
45// This sets the default COM visibility of types in the assembly to invisible. 45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type. 46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)] 47[assembly: ComVisible(false)]
48 48
49// The assembly version has following format : 49// The assembly version has following format :
50// 50//
51// Major.Minor.Build.Revision 51// Major.Minor.Build.Revision
52// 52//
53// You can specify all values by your own or you can build default build and revision 53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default): 54// numbers with the '*' character (the default):
55 55
56[assembly: AssemblyVersion("1.0.*")] 56[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index f133045..ec406f1 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -1,301 +1,301 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using Axiom.Math; 29using Axiom.Math;
30using OpenSim.Physics.Manager; 30using OpenSim.Physics.Manager;
31 31
32namespace OpenSim.Region.Physics.BasicPhysicsPlugin 32namespace OpenSim.Region.Physics.BasicPhysicsPlugin
33{ 33{
34 /// <summary> 34 /// <summary>
35 /// Will be the PhysX plugin but for now will be a very basic physics engine 35 /// Will be the PhysX plugin but for now will be a very basic physics engine
36 /// </summary> 36 /// </summary>
37 public class BasicPhysicsPlugin : IPhysicsPlugin 37 public class BasicPhysicsPlugin : IPhysicsPlugin
38 { 38 {
39 private BasicScene _mScene; 39 private BasicScene _mScene;
40 40
41 public BasicPhysicsPlugin() 41 public BasicPhysicsPlugin()
42 { 42 {
43 43
44 } 44 }
45 45
46 public bool Init() 46 public bool Init()
47 { 47 {
48 return true; 48 return true;
49 } 49 }
50 50
51 public PhysicsScene GetScene() 51 public PhysicsScene GetScene()
52 { 52 {
53 return new BasicScene(); 53 return new BasicScene();
54 } 54 }
55 55
56 public string GetName() 56 public string GetName()
57 { 57 {
58 return("basicphysics"); 58 return("basicphysics");
59 } 59 }
60 60
61 public void Dispose() 61 public void Dispose()
62 { 62 {
63 63
64 } 64 }
65 } 65 }
66 66
67 public class BasicScene :PhysicsScene 67 public class BasicScene :PhysicsScene
68 { 68 {
69 private List<BasicActor> _actors = new List<BasicActor>(); 69 private List<BasicActor> _actors = new List<BasicActor>();
70 private float[] _heightMap; 70 private float[] _heightMap;
71 71
72 public BasicScene() 72 public BasicScene()
73 { 73 {
74 74
75 } 75 }
76 76
77 public override PhysicsActor AddAvatar(PhysicsVector position) 77 public override PhysicsActor AddAvatar(PhysicsVector position)
78 { 78 {
79 BasicActor act = new BasicActor(); 79 BasicActor act = new BasicActor();
80 act.Position = position; 80 act.Position = position;
81 _actors.Add(act); 81 _actors.Add(act);
82 return act; 82 return act;
83 } 83 }
84 84
85 public override void RemoveAvatar(PhysicsActor actor) 85 public override void RemoveAvatar(PhysicsActor actor)
86 { 86 {
87 BasicActor act = (BasicActor)actor; 87 BasicActor act = (BasicActor)actor;
88 if(_actors.Contains(act)) 88 if(_actors.Contains(act))
89 { 89 {
90 _actors.Remove(act); 90 _actors.Remove(act);
91 } 91 }
92 92
93 } 93 }
94 94
95 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) 95 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
96 { 96 {
97 return null; 97 return null;
98 } 98 }
99 99
100 public override void Simulate(float timeStep) 100 public override void Simulate(float timeStep)
101 { 101 {
102 foreach (BasicActor actor in _actors) 102 foreach (BasicActor actor in _actors)
103 { 103 {
104 if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256)) 104 if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256))
105 { 105 {
106 float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f; 106 float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f;
107 actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); 107 actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
108 actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); 108 actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
109 if (actor.Flying) 109 if (actor.Flying)
110 { 110 {
111 if (actor.Position.Z + (actor.Velocity.Z * timeStep) < 111 if (actor.Position.Z + (actor.Velocity.Z * timeStep) <
112 _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2) 112 _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2)
113 { 113 {
114 actor.Position.Z = height; 114 actor.Position.Z = height;
115 actor.Velocity.Z = 0; 115 actor.Velocity.Z = 0;
116 } 116 }
117 else 117 else
118 { 118 {
119 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep); 119 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
120 } 120 }
121 } 121 }
122 else 122 else
123 { 123 {
124 actor.Position.Z = height; 124 actor.Position.Z = height;
125 actor.Velocity.Z = 0; 125 actor.Velocity.Z = 0;
126 } 126 }
127 } 127 }
128 else 128 else
129 { 129 {
130 if (actor.Position.Y < 0) 130 if (actor.Position.Y < 0)
131 { 131 {
132 actor.Position.Y = 0; 132 actor.Position.Y = 0;
133 } 133 }
134 else if (actor.Position.Y > 256) 134 else if (actor.Position.Y > 256)
135 { 135 {
136 actor.Position.Y = 256; 136 actor.Position.Y = 256;
137 } 137 }
138 138
139 if (actor.Position.X < 0) 139 if (actor.Position.X < 0)
140 { 140 {
141 actor.Position.X = 0; 141 actor.Position.X = 0;
142 } 142 }
143 if (actor.Position.X > 256) 143 if (actor.Position.X > 256)
144 { 144 {
145 actor.Position.X = 256; 145 actor.Position.X = 256;
146 } 146 }
147 } 147 }
148 //} 148 //}
149 149
150 150
151 151
152 // This code needs sorting out - border crossings etc 152 // This code needs sorting out - border crossings etc
153/* if(actor.Position.X<0) 153/* if(actor.Position.X<0)
154 { 154 {
155 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); 155 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
156 actor.Position.X = 0; 156 actor.Position.X = 0;
157 actor.Velocity.X = 0; 157 actor.Velocity.X = 0;
158 } 158 }
159 if(actor.Position.Y < 0) 159 if(actor.Position.Y < 0)
160 { 160 {
161 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); 161 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
162 actor.Position.Y = 0; 162 actor.Position.Y = 0;
163 actor.Velocity.Y = 0; 163 actor.Velocity.Y = 0;
164 } 164 }
165 if(actor.Position.X > 255) 165 if(actor.Position.X > 255)
166 { 166 {
167 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); 167 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
168 actor.Position.X = 255; 168 actor.Position.X = 255;
169 actor.Velocity.X = 0; 169 actor.Velocity.X = 0;
170 } 170 }
171 if(actor.Position.Y > 255) 171 if(actor.Position.Y > 255)
172 { 172 {
173 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z)); 173 ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
174 actor.Position.Y = 255; 174 actor.Position.Y = 255;
175 actor.Velocity.X = 0; 175 actor.Velocity.X = 0;
176 }*/ 176 }*/
177 } 177 }
178 } 178 }
179 179
180 public override void GetResults() 180 public override void GetResults()
181 { 181 {
182 182
183 } 183 }
184 184
185 public override bool IsThreaded 185 public override bool IsThreaded
186 { 186 {
187 get 187 get
188 { 188 {
189 return(false); // for now we won't be multithreaded 189 return(false); // for now we won't be multithreaded
190 } 190 }
191 } 191 }
192 192
193 public override void SetTerrain(float[] heightMap) 193 public override void SetTerrain(float[] heightMap)
194 { 194 {
195 this._heightMap = heightMap; 195 this._heightMap = heightMap;
196 } 196 }
197 197
198 public override void DeleteTerrain() 198 public override void DeleteTerrain()
199 { 199 {
200 200
201 } 201 }
202 } 202 }
203 203
204 public class BasicActor : PhysicsActor 204 public class BasicActor : PhysicsActor
205 { 205 {
206 private PhysicsVector _position; 206 private PhysicsVector _position;
207 private PhysicsVector _velocity; 207 private PhysicsVector _velocity;
208 private PhysicsVector _acceleration; 208 private PhysicsVector _acceleration;
209 private bool flying; 209 private bool flying;
210 public BasicActor() 210 public BasicActor()
211 { 211 {
212 _velocity = new PhysicsVector(); 212 _velocity = new PhysicsVector();
213 _position = new PhysicsVector(); 213 _position = new PhysicsVector();
214 _acceleration = new PhysicsVector(); 214 _acceleration = new PhysicsVector();
215 } 215 }
216 216
217 public override bool Flying 217 public override bool Flying
218 { 218 {
219 get 219 get
220 { 220 {
221 return flying; 221 return flying;
222 } 222 }
223 set 223 set
224 { 224 {
225 flying= value; 225 flying= value;
226 } 226 }
227 } 227 }
228 228
229 public override PhysicsVector Position 229 public override PhysicsVector Position
230 { 230 {
231 get 231 get
232 { 232 {
233 return _position; 233 return _position;
234 } 234 }
235 set 235 set
236 { 236 {
237 _position = value; 237 _position = value;
238 } 238 }
239 } 239 }
240 240
241 public override PhysicsVector Velocity 241 public override PhysicsVector Velocity
242 { 242 {
243 get 243 get
244 { 244 {
245 return _velocity; 245 return _velocity;
246 } 246 }
247 set 247 set
248 { 248 {
249 _velocity = value; 249 _velocity = value;
250 } 250 }
251 } 251 }
252 252
253 public override Quaternion Orientation 253 public override Quaternion Orientation
254 { 254 {
255 get 255 get
256 { 256 {
257 return Quaternion.Identity; 257 return Quaternion.Identity;
258 } 258 }
259 set 259 set
260 { 260 {
261 261
262 } 262 }
263 } 263 }
264 264
265 public override PhysicsVector Acceleration 265 public override PhysicsVector Acceleration
266 { 266 {
267 get 267 get
268 { 268 {
269 return _acceleration; 269 return _acceleration;
270 } 270 }
271 271
272 } 272 }
273 273
274 public override bool Kinematic 274 public override bool Kinematic
275 { 275 {
276 get 276 get
277 { 277 {
278 return true; 278 return true;
279 } 279 }
280 set 280 set
281 { 281 {
282 282
283 } 283 }
284 } 284 }
285 public void SetAcceleration (PhysicsVector accel) 285 public void SetAcceleration (PhysicsVector accel)
286 { 286 {
287 this._acceleration = accel; 287 this._acceleration = accel;
288 } 288 }
289 289
290 public override void AddForce(PhysicsVector force) 290 public override void AddForce(PhysicsVector force)
291 { 291 {
292 292
293 } 293 }
294 294
295 public override void SetMomentum(PhysicsVector momentum) 295 public override void SetMomentum(PhysicsVector momentum)
296 { 296 {
297 297
298 } 298 }
299 } 299 }
300 300
301} 301}