diff options
Deleting objects should now work. But beware they aren't send to your trash folder or anything so there is at the moment no way to recover deleted objects.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 386 |
1 files changed, 194 insertions, 192 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 4d0699b..b722fdf 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | |||
@@ -31,79 +31,97 @@ using OpenSim.Physics.Manager; | |||
31 | 31 | ||
32 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin | 32 | namespace 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 | public BasicPhysicsPlugin() | 39 | public BasicPhysicsPlugin() |
40 | { | 40 | { |
41 | 41 | ||
42 | } | 42 | } |
43 | 43 | ||
44 | public bool Init() | 44 | public bool Init() |
45 | { | 45 | { |
46 | return true; | 46 | return true; |
47 | } | 47 | } |
48 | 48 | ||
49 | public PhysicsScene GetScene() | 49 | public PhysicsScene GetScene() |
50 | { | 50 | { |
51 | return new BasicScene(); | 51 | return new BasicScene(); |
52 | } | 52 | } |
53 | 53 | ||
54 | public string GetName() | 54 | public string GetName() |
55 | { | 55 | { |
56 | return("basicphysics"); | 56 | return ("basicphysics"); |
57 | } | 57 | } |
58 | 58 | ||
59 | public void Dispose() | 59 | public void Dispose() |
60 | { | 60 | { |
61 | 61 | ||
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | public class BasicScene :PhysicsScene | 65 | public class BasicScene : PhysicsScene |
66 | { | 66 | { |
67 | private List<BasicActor> _actors = new List<BasicActor>(); | 67 | private List<BasicActor> _actors = new List<BasicActor>(); |
68 | private float[] _heightMap; | 68 | private float[] _heightMap; |
69 | 69 | ||
70 | public BasicScene() | 70 | public BasicScene() |
71 | { | 71 | { |
72 | 72 | ||
73 | } | 73 | } |
74 | 74 | ||
75 | public override PhysicsActor AddAvatar(PhysicsVector position) | 75 | public override PhysicsActor AddAvatar(PhysicsVector position) |
76 | { | 76 | { |
77 | BasicActor act = new BasicActor(); | 77 | BasicActor act = new BasicActor(); |
78 | act.Position = position; | 78 | act.Position = position; |
79 | _actors.Add(act); | 79 | _actors.Add(act); |
80 | return act; | 80 | return act; |
81 | } | 81 | } |
82 | 82 | ||
83 | public override void RemoveAvatar(PhysicsActor actor) | 83 | public override void RemoveAvatar(PhysicsActor actor) |
84 | { | 84 | { |
85 | BasicActor act = (BasicActor)actor; | 85 | BasicActor act = (BasicActor)actor; |
86 | if(_actors.Contains(act)) | 86 | if (_actors.Contains(act)) |
87 | { | 87 | { |
88 | _actors.Remove(act); | 88 | _actors.Remove(act); |
89 | } | 89 | } |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) | 93 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) |
94 | { | 94 | { |
95 | return null; | 95 | return null; |
96 | } | 96 | } |
97 | 97 | ||
98 | public override void Simulate(float timeStep) | 98 | public override void Simulate(float timeStep) |
99 | { | 99 | { |
100 | foreach (BasicActor actor in _actors) | 100 | foreach (BasicActor actor in _actors) |
101 | { | 101 | { |
102 | float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f; | ||
103 | actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); | 102 | actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); |
104 | actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); | 103 | actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); |
104 | if (actor.Position.Y < 0) | ||
105 | { | ||
106 | actor.Position.Y = 0; | ||
107 | } | ||
108 | else if (actor.Position.Y > 256) | ||
109 | { | ||
110 | actor.Position.Y = 256; | ||
111 | } | ||
112 | |||
113 | if (actor.Position.X < 0) | ||
114 | { | ||
115 | actor.Position.X = 0; | ||
116 | } | ||
117 | else if (actor.Position.X > 256) | ||
118 | { | ||
119 | actor.Position.X = 256; | ||
120 | } | ||
121 | |||
122 | float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f; | ||
105 | if (actor.Flying) | 123 | if (actor.Flying) |
106 | { | 124 | { |
107 | if (actor.Position.Z + (actor.Velocity.Z * timeStep) < _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2) | 125 | if (actor.Position.Z + (actor.Velocity.Z * timeStep) < _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2) |
108 | { | 126 | { |
109 | actor.Position.Z = height; | 127 | actor.Position.Z = height; |
@@ -120,145 +138,129 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
120 | actor.Velocity.Z = 0; | 138 | actor.Velocity.Z = 0; |
121 | } | 139 | } |
122 | 140 | ||
123 | if (actor.Position.Y < 0) | ||
124 | { | ||
125 | actor.Position.Y = 0; | ||
126 | } | ||
127 | else if (actor.Position.Y > 256) | ||
128 | { | ||
129 | actor.Position.Y = 256; | ||
130 | } | ||
131 | 141 | ||
132 | if (actor.Position.X < 0) | ||
133 | { | ||
134 | actor.Position.X = 0; | ||
135 | } | ||
136 | if (actor.Position.X > 256) | ||
137 | { | ||
138 | actor.Position.X = 256; | ||
139 | } | ||
140 | } | 142 | } |
141 | } | 143 | } |
142 | 144 | ||
143 | public override void GetResults() | 145 | public override void GetResults() |
144 | { | 146 | { |
145 | 147 | ||
146 | } | 148 | } |
147 | 149 | ||
148 | public override bool IsThreaded | 150 | public override bool IsThreaded |
149 | { | 151 | { |
150 | get | 152 | get |
151 | { | 153 | { |
152 | return(false); // for now we won't be multithreaded | 154 | return (false); // for now we won't be multithreaded |
153 | } | 155 | } |
154 | } | 156 | } |
155 | 157 | ||
156 | public override void SetTerrain(float[] heightMap) | 158 | public override void SetTerrain(float[] heightMap) |
157 | { | 159 | { |
158 | this._heightMap = heightMap; | 160 | this._heightMap = heightMap; |
159 | } | 161 | } |
160 | 162 | ||
161 | public override void DeleteTerrain() | 163 | public override void DeleteTerrain() |
162 | { | 164 | { |
163 | 165 | ||
164 | } | 166 | } |
165 | } | 167 | } |
166 | 168 | ||
167 | public class BasicActor : PhysicsActor | 169 | public class BasicActor : PhysicsActor |
168 | { | 170 | { |
169 | private PhysicsVector _position; | 171 | private PhysicsVector _position; |
170 | private PhysicsVector _velocity; | 172 | private PhysicsVector _velocity; |
171 | private PhysicsVector _acceleration; | 173 | private PhysicsVector _acceleration; |
172 | private bool flying; | 174 | private bool flying; |
173 | public BasicActor() | 175 | public BasicActor() |
174 | { | 176 | { |
175 | _velocity = new PhysicsVector(); | 177 | _velocity = new PhysicsVector(); |
176 | _position = new PhysicsVector(); | 178 | _position = new PhysicsVector(); |
177 | _acceleration = new PhysicsVector(); | 179 | _acceleration = new PhysicsVector(); |
178 | } | 180 | } |
179 | 181 | ||
180 | public override bool Flying | 182 | public override bool Flying |
181 | { | 183 | { |
182 | get | 184 | get |
183 | { | 185 | { |
184 | return flying; | 186 | return flying; |
185 | } | 187 | } |
186 | set | 188 | set |
187 | { | 189 | { |
188 | flying= value; | 190 | flying = value; |
189 | } | 191 | } |
190 | } | 192 | } |
191 | 193 | ||
192 | public override PhysicsVector Position | 194 | public override PhysicsVector Position |
193 | { | 195 | { |
194 | get | 196 | get |
195 | { | 197 | { |
196 | return _position; | 198 | return _position; |
197 | } | 199 | } |
198 | set | 200 | set |
199 | { | 201 | { |
200 | _position = value; | 202 | _position = value; |
201 | } | 203 | } |
202 | } | 204 | } |
203 | 205 | ||
204 | public override PhysicsVector Velocity | 206 | public override PhysicsVector Velocity |
205 | { | 207 | { |
206 | get | 208 | get |
207 | { | 209 | { |
208 | return _velocity; | 210 | return _velocity; |
209 | } | 211 | } |
210 | set | 212 | set |
211 | { | 213 | { |
212 | _velocity = value; | 214 | _velocity = value; |
213 | } | 215 | } |
214 | } | 216 | } |
215 | 217 | ||
216 | public override Quaternion Orientation | 218 | public override Quaternion Orientation |
217 | { | 219 | { |
218 | get | 220 | get |
219 | { | 221 | { |
220 | return Quaternion.Identity; | 222 | return Quaternion.Identity; |
221 | } | 223 | } |
222 | set | 224 | set |
223 | { | 225 | { |
224 | 226 | ||
225 | } | 227 | } |
226 | } | 228 | } |
227 | 229 | ||
228 | public override PhysicsVector Acceleration | 230 | public override PhysicsVector Acceleration |
229 | { | 231 | { |
230 | get | 232 | get |
231 | { | 233 | { |
232 | return _acceleration; | 234 | return _acceleration; |
233 | } | 235 | } |
234 | 236 | ||
235 | } | 237 | } |
236 | 238 | ||
237 | public override bool Kinematic | 239 | public override bool Kinematic |
238 | { | 240 | { |
239 | get | 241 | get |
240 | { | 242 | { |
241 | return true; | 243 | return true; |
242 | } | 244 | } |
243 | set | 245 | set |
244 | { | 246 | { |
245 | 247 | ||
246 | } | 248 | } |
247 | } | 249 | } |
248 | public void SetAcceleration (PhysicsVector accel) | 250 | public void SetAcceleration(PhysicsVector accel) |
249 | { | 251 | { |
250 | this._acceleration = accel; | 252 | this._acceleration = accel; |
251 | } | 253 | } |
252 | 254 | ||
253 | public override void AddForce(PhysicsVector force) | 255 | public override void AddForce(PhysicsVector force) |
254 | { | 256 | { |
255 | 257 | ||
256 | } | 258 | } |
257 | 259 | ||
258 | public override void SetMomentum(PhysicsVector momentum) | 260 | public override void SetMomentum(PhysicsVector momentum) |
259 | { | 261 | { |
260 | 262 | ||
261 | } | 263 | } |
262 | } | 264 | } |
263 | 265 | ||
264 | } | 266 | } |