diff options
author | Justin Clark-Casey (justincc) | 2012-04-22 19:51:51 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-04-22 19:51:51 +0100 |
commit | 8205fe79ceaeebd31509a044005bf27d226dbe07 (patch) | |
tree | ef0c0111f800e61b3365048431ed8689b922423f /OpenSim/Region/Physics/BasicPhysicsPlugin | |
parent | Comment out spurious Body != IntPtr.Zero code after disableBody(), since disa... (diff) | |
download | opensim-SC-8205fe79ceaeebd31509a044005bf27d226dbe07.zip opensim-SC-8205fe79ceaeebd31509a044005bf27d226dbe07.tar.gz opensim-SC-8205fe79ceaeebd31509a044005bf27d226dbe07.tar.bz2 opensim-SC-8205fe79ceaeebd31509a044005bf27d226dbe07.tar.xz |
Fix bug where setting phantom on a prim would result in a server log message rather than setting phantom.
This was an oversight when removing some race conditions from PhysicsActor setting recently.
Regression tests extended to probe this code path.
Extending regression tests required implementation of a BasicPhysicsPrim (there was none before). However, BasicPhysics plugin is still of no current practical use other than to fill in as a component for other parts of regression testing.
Diffstat (limited to 'OpenSim/Region/Physics/BasicPhysicsPlugin')
-rw-r--r-- | OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs | 344 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs | 41 |
2 files changed, 367 insertions, 18 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs new file mode 100644 index 0000000..ba7fe1e --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs | |||
@@ -0,0 +1,344 @@ | |||
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 BasicPhysicsPrim : PhysicsActor | ||
38 | { | ||
39 | private Vector3 _position; | ||
40 | private Vector3 _velocity; | ||
41 | private Vector3 _acceleration; | ||
42 | private Vector3 _size; | ||
43 | private PrimitiveBaseShape _shape; | ||
44 | private Vector3 m_rotationalVelocity; | ||
45 | private bool flying; | ||
46 | private bool iscolliding; | ||
47 | |||
48 | public BasicPhysicsPrim( | ||
49 | string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape) | ||
50 | { | ||
51 | Name = name; | ||
52 | LocalID = localId; | ||
53 | Position = position; | ||
54 | Size = size; | ||
55 | Orientation = orientation; | ||
56 | Shape = shape; | ||
57 | } | ||
58 | |||
59 | public override int PhysicsActorType | ||
60 | { | ||
61 | get { return (int) ActorTypes.Agent; } | ||
62 | set { return; } | ||
63 | } | ||
64 | |||
65 | public override Vector3 RotationalVelocity | ||
66 | { | ||
67 | get { return m_rotationalVelocity; } | ||
68 | set { m_rotationalVelocity = value; } | ||
69 | } | ||
70 | |||
71 | public override bool SetAlwaysRun | ||
72 | { | ||
73 | get { return false; } | ||
74 | set { return; } | ||
75 | } | ||
76 | |||
77 | public override uint LocalID | ||
78 | { | ||
79 | set { return; } | ||
80 | } | ||
81 | |||
82 | public override bool Grabbed | ||
83 | { | ||
84 | set { return; } | ||
85 | } | ||
86 | |||
87 | public override bool Selected | ||
88 | { | ||
89 | set { return; } | ||
90 | } | ||
91 | |||
92 | public override float Buoyancy | ||
93 | { | ||
94 | get { return 0f; } | ||
95 | set { return; } | ||
96 | } | ||
97 | |||
98 | public override bool FloatOnWater | ||
99 | { | ||
100 | set { return; } | ||
101 | } | ||
102 | |||
103 | public override bool IsPhysical | ||
104 | { | ||
105 | get { return false; } | ||
106 | set { return; } | ||
107 | } | ||
108 | |||
109 | public override bool ThrottleUpdates | ||
110 | { | ||
111 | get { return false; } | ||
112 | set { return; } | ||
113 | } | ||
114 | |||
115 | public override bool Flying | ||
116 | { | ||
117 | get { return flying; } | ||
118 | set { flying = value; } | ||
119 | } | ||
120 | |||
121 | public override bool IsColliding | ||
122 | { | ||
123 | get { return iscolliding; } | ||
124 | set { iscolliding = value; } | ||
125 | } | ||
126 | |||
127 | public override bool CollidingGround | ||
128 | { | ||
129 | get { return false; } | ||
130 | set { return; } | ||
131 | } | ||
132 | |||
133 | public override bool CollidingObj | ||
134 | { | ||
135 | get { return false; } | ||
136 | set { return; } | ||
137 | } | ||
138 | |||
139 | public override bool Stopped | ||
140 | { | ||
141 | get { return false; } | ||
142 | } | ||
143 | |||
144 | public override Vector3 Position | ||
145 | { | ||
146 | get { return _position; } | ||
147 | set { _position = value; } | ||
148 | } | ||
149 | |||
150 | public override Vector3 Size | ||
151 | { | ||
152 | get { return _size; } | ||
153 | set { | ||
154 | _size = value; | ||
155 | _size.Z = _size.Z / 2.0f; | ||
156 | } | ||
157 | } | ||
158 | |||
159 | public override PrimitiveBaseShape Shape | ||
160 | { | ||
161 | set { _shape = value; } | ||
162 | } | ||
163 | |||
164 | public override float Mass | ||
165 | { | ||
166 | get { return 0f; } | ||
167 | } | ||
168 | |||
169 | public override Vector3 Force | ||
170 | { | ||
171 | get { return Vector3.Zero; } | ||
172 | set { return; } | ||
173 | } | ||
174 | |||
175 | public override int VehicleType | ||
176 | { | ||
177 | get { return 0; } | ||
178 | set { return; } | ||
179 | } | ||
180 | |||
181 | public override void VehicleFloatParam(int param, float value) | ||
182 | { | ||
183 | |||
184 | } | ||
185 | |||
186 | public override void VehicleVectorParam(int param, Vector3 value) | ||
187 | { | ||
188 | |||
189 | } | ||
190 | |||
191 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
192 | { | ||
193 | |||
194 | } | ||
195 | |||
196 | public override void VehicleFlags(int param, bool remove) | ||
197 | { | ||
198 | |||
199 | } | ||
200 | |||
201 | public override void SetVolumeDetect(int param) | ||
202 | { | ||
203 | |||
204 | } | ||
205 | |||
206 | public override Vector3 CenterOfMass | ||
207 | { | ||
208 | get { return Vector3.Zero; } | ||
209 | } | ||
210 | |||
211 | public override Vector3 GeometricCenter | ||
212 | { | ||
213 | get { return Vector3.Zero; } | ||
214 | } | ||
215 | |||
216 | public override Vector3 Velocity | ||
217 | { | ||
218 | get { return _velocity; } | ||
219 | set { _velocity = value; } | ||
220 | } | ||
221 | |||
222 | public override Vector3 Torque | ||
223 | { | ||
224 | get { return Vector3.Zero; } | ||
225 | set { return; } | ||
226 | } | ||
227 | |||
228 | public override float CollisionScore | ||
229 | { | ||
230 | get { return 0f; } | ||
231 | set { } | ||
232 | } | ||
233 | |||
234 | public override Quaternion Orientation { get; set; } | ||
235 | |||
236 | public override Vector3 Acceleration | ||
237 | { | ||
238 | get { return _acceleration; } | ||
239 | set { _acceleration = value; } | ||
240 | } | ||
241 | |||
242 | public override bool Kinematic | ||
243 | { | ||
244 | get { return true; } | ||
245 | set { } | ||
246 | } | ||
247 | |||
248 | public override void link(PhysicsActor obj) | ||
249 | { | ||
250 | } | ||
251 | |||
252 | public override void delink() | ||
253 | { | ||
254 | } | ||
255 | |||
256 | public override void LockAngularMotion(Vector3 axis) | ||
257 | { | ||
258 | } | ||
259 | |||
260 | public override void AddForce(Vector3 force, bool pushforce) | ||
261 | { | ||
262 | } | ||
263 | |||
264 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
265 | { | ||
266 | } | ||
267 | |||
268 | public override void SetMomentum(Vector3 momentum) | ||
269 | { | ||
270 | } | ||
271 | |||
272 | public override void CrossingFailure() | ||
273 | { | ||
274 | } | ||
275 | |||
276 | public override Vector3 PIDTarget | ||
277 | { | ||
278 | set { return; } | ||
279 | } | ||
280 | |||
281 | public override bool PIDActive | ||
282 | { | ||
283 | set { return; } | ||
284 | } | ||
285 | |||
286 | public override float PIDTau | ||
287 | { | ||
288 | set { return; } | ||
289 | } | ||
290 | |||
291 | public override float PIDHoverHeight | ||
292 | { | ||
293 | set { return; } | ||
294 | } | ||
295 | |||
296 | public override bool PIDHoverActive | ||
297 | { | ||
298 | set { return; } | ||
299 | } | ||
300 | |||
301 | public override PIDHoverType PIDHoverType | ||
302 | { | ||
303 | set { return; } | ||
304 | } | ||
305 | |||
306 | public override float PIDHoverTau | ||
307 | { | ||
308 | set { return; } | ||
309 | } | ||
310 | |||
311 | public override Quaternion APIDTarget | ||
312 | { | ||
313 | set { return; } | ||
314 | } | ||
315 | |||
316 | public override bool APIDActive | ||
317 | { | ||
318 | set { return; } | ||
319 | } | ||
320 | |||
321 | public override float APIDStrength | ||
322 | { | ||
323 | set { return; } | ||
324 | } | ||
325 | |||
326 | public override float APIDDamping | ||
327 | { | ||
328 | set { return; } | ||
329 | } | ||
330 | |||
331 | public override void SubscribeEvents(int ms) | ||
332 | { | ||
333 | } | ||
334 | |||
335 | public override void UnSubscribeEvents() | ||
336 | { | ||
337 | } | ||
338 | |||
339 | public override bool SubscribedEvents() | ||
340 | { | ||
341 | return false; | ||
342 | } | ||
343 | } | ||
344 | } | ||
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs index 2e14216..f5826ed 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs | |||
@@ -34,9 +34,17 @@ using OpenSim.Region.Physics.Manager; | |||
34 | 34 | ||
35 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin | 35 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin |
36 | { | 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> | ||
37 | public class BasicScene : PhysicsScene | 44 | public class BasicScene : PhysicsScene |
38 | { | 45 | { |
39 | private List<BasicActor> _actors = new List<BasicActor>(); | 46 | private List<BasicActor> _actors = new List<BasicActor>(); |
47 | private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>(); | ||
40 | private float[] _heightMap; | 48 | private float[] _heightMap; |
41 | 49 | ||
42 | //protected internal string sceneIdentifier; | 50 | //protected internal string sceneIdentifier; |
@@ -50,10 +58,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
50 | { | 58 | { |
51 | } | 59 | } |
52 | 60 | ||
53 | public override void Dispose() | 61 | public override void Dispose() {} |
62 | |||
63 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
64 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) | ||
54 | { | 65 | { |
66 | BasicPhysicsPrim prim = new BasicPhysicsPrim(primName, localid, position, size, rotation, pbs); | ||
67 | prim.IsPhysical = isPhysical; | ||
68 | |||
69 | _prims.Add(prim); | ||
55 | 70 | ||
71 | return prim; | ||
56 | } | 72 | } |
73 | |||
57 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | 74 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) |
58 | { | 75 | { |
59 | BasicActor act = new BasicActor(size); | 76 | BasicActor act = new BasicActor(size); |
@@ -63,30 +80,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
63 | return act; | 80 | return act; |
64 | } | 81 | } |
65 | 82 | ||
66 | public override void RemovePrim(PhysicsActor prim) | 83 | public override void RemovePrim(PhysicsActor actor) |
67 | { | 84 | { |
85 | BasicPhysicsPrim prim = (BasicPhysicsPrim)actor; | ||
86 | if (_prims.Contains(prim)) | ||
87 | _prims.Remove(prim); | ||
68 | } | 88 | } |
69 | 89 | ||
70 | public override void RemoveAvatar(PhysicsActor actor) | 90 | public override void RemoveAvatar(PhysicsActor actor) |
71 | { | 91 | { |
72 | BasicActor act = (BasicActor) actor; | 92 | BasicActor act = (BasicActor)actor; |
73 | if (_actors.Contains(act)) | 93 | if (_actors.Contains(act)) |
74 | { | ||
75 | _actors.Remove(act); | 94 | _actors.Remove(act); |
76 | } | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation) | ||
81 | { | ||
82 | return null; | ||
83 | } | ||
84 | */ | ||
85 | |||
86 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
87 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) | ||
88 | { | ||
89 | return null; | ||
90 | } | 95 | } |
91 | 96 | ||
92 | public override void AddPhysicsActorTaint(PhysicsActor prim) | 97 | public override void AddPhysicsActorTaint(PhysicsActor prim) |