aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2012-08-01 00:08:02 +0100
committerMelanie2012-08-01 00:08:02 +0100
commit8114260946be8bbe6754d497f104804d203e00e2 (patch)
treeb87ac81a06f7fffbb39d88e6bc24d4c615b05cee /OpenSim/Region
parentMerge branch 'avination' into careminster (diff)
parentResolve a deadlock between INPCModule and SensorRepeat by replacing the Senso... (diff)
downloadopensim-SC_OLD-8114260946be8bbe6754d497f104804d203e00e2.zip
opensim-SC_OLD-8114260946be8bbe6754d497f104804d203e00e2.tar.gz
opensim-SC_OLD-8114260946be8bbe6754d497f104804d203e00e2.tar.bz2
opensim-SC_OLD-8114260946be8bbe6754d497f104804d203e00e2.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/Sound/SoundModule.cs9
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs33
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs12
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs56
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs38
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs34
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs45
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs78
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs39
11 files changed, 287 insertions, 69 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index d768a1a..14c1a39 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -119,17 +119,20 @@ namespace OpenSim.Region.CoreModules.World.Sound
119 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 119 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
120 { 120 {
121 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); 121 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
122
122 if (dis > 100.0) // Max audio distance 123 if (dis > 100.0) // Max audio distance
123 return; 124 return;
124 125
126 float thisSpGain;
127
125 // Scale by distance 128 // Scale by distance
126 if (radius == 0) 129 if (radius == 0)
127 gain = (float)((double)gain * ((100.0 - dis) / 100.0)); 130 thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
128 else 131 else
129 gain = (float)((double)gain * ((radius - dis) / radius)); 132 thisSpGain = (float)((double)gain * ((radius - dis) / radius));
130 133
131 sp.ControllingClient.SendTriggeredSound( 134 sp.ControllingClient.SendTriggeredSound(
132 soundId, ownerID, objectID, parentID, handle, position, (float)gain); 135 soundId, ownerID, objectID, parentID, handle, position, thisSpGain);
133 }); 136 });
134 } 137 }
135 } 138 }
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
index bfe1e8d..ed71a95 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
@@ -67,6 +67,10 @@ namespace OpenSim.Region.Framework.Interfaces
67 /// <param name="key"></param> 67 /// <param name="key"></param>
68 void DispatchReply(UUID scriptId, int code, string text, string key); 68 void DispatchReply(UUID scriptId, int code, string text, string key);
69 69
70 /// For constants
71 void RegisterConstant(string cname, object value);
72 object LookupModConstant(string cname);
73
70 // For use ONLY by the script API 74 // For use ONLY by the script API
71 void RaiseEvent(UUID script, string id, string module, string command, string key); 75 void RaiseEvent(UUID script, string id, string module, string command, string key);
72 } 76 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 74a85e2..705a847 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -46,6 +46,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private Dictionary<string,object> m_constants = new Dictionary<string,object>();
50
49#region ScriptInvocation 51#region ScriptInvocation
50 protected class ScriptInvocationData 52 protected class ScriptInvocationData
51 { 53 {
@@ -269,6 +271,37 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
269 Delegate fn = LookupScriptInvocation(fname); 271 Delegate fn = LookupScriptInvocation(fname);
270 return fn.DynamicInvoke(olist.ToArray()); 272 return fn.DynamicInvoke(olist.ToArray());
271 } 273 }
274
275 /// <summary>
276 /// Operation to for a region module to register a constant to be used
277 /// by the script engine
278 /// </summary>
279 public void RegisterConstant(string cname, object value)
280 {
281 m_log.DebugFormat("[MODULE COMMANDS] register constant <{0}> with value {1}",cname,value.ToString());
282 lock (m_constants)
283 {
284 m_constants.Add(cname,value);
285 }
286 }
287
288 /// <summary>
289 /// Operation to check for a registered constant
290 /// </summary>
291 public object LookupModConstant(string cname)
292 {
293 // m_log.DebugFormat("[MODULE COMMANDS] lookup constant <{0}>",cname);
294
295 lock (m_constants)
296 {
297 object value = null;
298 if (m_constants.TryGetValue(cname,out value))
299 return value;
300 }
301
302 return null;
303 }
304
272#endregion 305#endregion
273 306
274 } 307 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
index fbb9e21..07f5a21 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
@@ -50,7 +50,8 @@ public class BSConstraint : IDisposable
50 m_body2 = obj2; 50 m_body2 = obj2;
51 m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, 51 m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr,
52 frame1, frame1rot, 52 frame1, frame1rot,
53 frame2, frame2rot)); 53 frame2, frame2rot,
54 true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/));
54 m_enabled = true; 55 m_enabled = true;
55 } 56 }
56 57
@@ -83,6 +84,15 @@ public class BSConstraint : IDisposable
83 return ret; 84 return ret;
84 } 85 }
85 86
87 public bool SetCFMAndERP(float cfm, float erp)
88 {
89 bool ret = false;
90 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
91 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL);
92 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
93 return ret;
94 }
95
86 public bool UseFrameOffset(bool useOffset) 96 public bool UseFrameOffset(bool useOffset)
87 { 97 {
88 bool ret = false; 98 bool ret = false;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
index a2650fb..c88e645 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
@@ -83,7 +83,8 @@ public class BSConstraintCollection : IDisposable
83 return true; 83 return true;
84 } 84 }
85 85
86 // Get the constraint between two bodies. There can be only one the way we're using them. 86 // Get the constraint between two bodies. There can be only one.
87 // Return 'true' if a constraint was found.
87 public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint) 88 public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint)
88 { 89 {
89 bool found = false; 90 bool found = false;
@@ -105,6 +106,9 @@ public class BSConstraintCollection : IDisposable
105 return found; 106 return found;
106 } 107 }
107 108
109 // Remove any constraint between the passed bodies.
110 // Presumed there is only one such constraint possible.
111 // Return 'true' if a constraint was found and destroyed.
108 public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2) 112 public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2)
109 { 113 {
110 // return BulletSimAPI.RemoveConstraint(m_world.ID, obj1.ID, obj2.ID); 114 // return BulletSimAPI.RemoveConstraint(m_world.ID, obj1.ID, obj2.ID);
@@ -125,6 +129,8 @@ public class BSConstraintCollection : IDisposable
125 return ret; 129 return ret;
126 } 130 }
127 131
132 // Remove all constraints that reference the passed body.
133 // Return 'true' if any constraints were destroyed.
128 public bool RemoveAndDestroyConstraint(BulletBody body1) 134 public bool RemoveAndDestroyConstraint(BulletBody body1)
129 { 135 {
130 // return BulletSimAPI.RemoveConstraintByID(m_world.ID, obj.ID); 136 // return BulletSimAPI.RemoveConstraintByID(m_world.ID, obj.ID);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 3bc2100..6f8430c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -117,10 +117,50 @@ public class BSLinkset
117 } 117 }
118 118
119 // An existing linkset had one of its members rebuilt or something. 119 // An existing linkset had one of its members rebuilt or something.
120 // Undo all the physical linking and rebuild the physical linkset. 120 // Go through the linkset and rebuild the pointers to the bodies of the linkset members.
121 public bool RefreshLinkset(BSPrim requestor) 121 public BSLinkset RefreshLinkset(BSPrim requestor)
122 { 122 {
123 return true; 123 BSLinkset ret = requestor.Linkset;
124
125 lock (m_linksetActivityLock)
126 {
127 System.IntPtr aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, m_linksetRoot.LocalID);
128 if (aPtr == System.IntPtr.Zero)
129 {
130 // That's odd. We can't find the root of the linkset.
131 // The linkset is somehow dead. The requestor is now a member of a linkset of one.
132 DetailLog("{0},RefreshLinkset.RemoveRoot,child={1}", m_linksetRoot.LocalID, m_linksetRoot.LocalID);
133 ret = RemoveMeFromLinkset(m_linksetRoot);
134 }
135 else
136 {
137 // Reconstruct the pointer to the body of the linkset root.
138 DetailLog("{0},RefreshLinkset.RebuildRoot,rootID={1},ptr={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, aPtr);
139 m_linksetRoot.Body = new BulletBody(m_linksetRoot.LocalID, aPtr);
140
141 List<BSPrim> toRemove = new List<BSPrim>();
142 foreach (BSPrim bsp in m_children)
143 {
144 aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, bsp.LocalID);
145 if (aPtr == System.IntPtr.Zero)
146 {
147 toRemove.Add(bsp);
148 }
149 else
150 {
151 // Reconstruct the pointer to the body of the linkset root.
152 DetailLog("{0},RefreshLinkset.RebuildChild,rootID={1},ptr={2}", bsp.LocalID, m_linksetRoot.LocalID, aPtr);
153 bsp.Body = new BulletBody(bsp.LocalID, aPtr);
154 }
155 }
156 foreach (BSPrim bsp in toRemove)
157 {
158 RemoveChildFromLinkset(bsp);
159 }
160 }
161 }
162
163 return ret;
124 } 164 }
125 165
126 166
@@ -256,10 +296,13 @@ public class BSLinkset
256 DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); 296 DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID);
257 BSConstraint constrain = m_scene.Constraints.CreateConstraint( 297 BSConstraint constrain = m_scene.Constraints.CreateConstraint(
258 m_scene.World, m_linksetRoot.Body, childPrim.Body, 298 m_scene.World, m_linksetRoot.Body, childPrim.Body,
259 childRelativePosition, 299 // childRelativePosition,
260 childRelativeRotation, 300 // childRelativeRotation,
301 OMV.Vector3.Zero,
302 OMV.Quaternion.Identity,
261 OMV.Vector3.Zero, 303 OMV.Vector3.Zero,
262 OMV.Quaternion.Identity); 304 OMV.Quaternion.Identity
305 );
263 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 306 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
264 constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 307 constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
265 308
@@ -268,6 +311,7 @@ public class BSLinkset
268 constrain.TranslationalLimitMotor(m_scene.BoolNumeric(m_scene.Params.linkConstraintEnableTransMotor), 311 constrain.TranslationalLimitMotor(m_scene.BoolNumeric(m_scene.Params.linkConstraintEnableTransMotor),
269 m_scene.Params.linkConstraintTransMotorMaxVel, 312 m_scene.Params.linkConstraintTransMotorMaxVel,
270 m_scene.Params.linkConstraintTransMotorMaxForce); 313 m_scene.Params.linkConstraintTransMotorMaxForce);
314 constrain.SetCFMAndERP(m_scene.Params.linkConstraintCFM, m_scene.Params.linkConstraintERP);
271 315
272 } 316 }
273 317
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 7590d93..50d11e6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -103,7 +103,10 @@ public sealed class BSPrim : PhysicsActor
103 long _collidingGroundStep; 103 long _collidingGroundStep;
104 104
105 private BulletBody m_body; 105 private BulletBody m_body;
106 public BulletBody Body { get { return m_body; } } 106 public BulletBody Body {
107 get { return m_body; }
108 set { m_body = value; }
109 }
107 110
108 private BSDynamics _vehicle; 111 private BSDynamics _vehicle;
109 112
@@ -477,9 +480,11 @@ public sealed class BSPrim : PhysicsActor
477 // Only called at taint time so it is save to call into Bullet. 480 // Only called at taint time so it is save to call into Bullet.
478 private void SetObjectDynamic() 481 private void SetObjectDynamic()
479 { 482 {
480 // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); 483 // RA: remove this for the moment.
481 484 // The problem is that dynamic objects are hulls so if we are becoming physical
482 RecreateGeomAndObject(); 485 // the shape has to be checked and possibly built.
486 // Maybe a VerifyCorrectPhysicalShape() routine?
487 // RecreateGeomAndObject();
483 488
484 float mass = _mass; 489 float mass = _mass;
485 // Bullet wants static objects have a mass of zero 490 // Bullet wants static objects have a mass of zero
@@ -971,21 +976,23 @@ public sealed class BSPrim : PhysicsActor
971 { 976 {
972 DetailLog("{0},CreateGeom,sphere", LocalID); 977 DetailLog("{0},CreateGeom,sphere", LocalID);
973 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; 978 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE;
974 ret = true;
975 // Bullet native objects are scaled by the Bullet engine so pass the size in 979 // Bullet native objects are scaled by the Bullet engine so pass the size in
976 _scale = _size; 980 _scale = _size;
981 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
982 ret = true;
977 } 983 }
978 } 984 }
979 } 985 }
980 else 986 else
981 { 987 {
982 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, size={2}", LogHeader, LocalID, _size); 988 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size);
983 if (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX) 989 if (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX)
984 { 990 {
985 DetailLog("{0},CreateGeom,box", LocalID); 991 DetailLog("{0},CreateGeom,box", LocalID);
986 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; 992 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX;
987 ret = true;
988 _scale = _size; 993 _scale = _size;
994 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
995 ret = true;
989 } 996 }
990 } 997 }
991 } 998 }
@@ -1203,11 +1210,9 @@ public sealed class BSPrim : PhysicsActor
1203 FillShapeInfo(out shape); 1210 FillShapeInfo(out shape);
1204 // m_log.DebugFormat("{0}: CreateObject: lID={1}, shape={2}", LogHeader, _localID, shape.Type); 1211 // m_log.DebugFormat("{0}: CreateObject: lID={1}, shape={2}", LogHeader, _localID, shape.Type);
1205 BulletSimAPI.CreateObject(_scene.WorldID, shape); 1212 BulletSimAPI.CreateObject(_scene.WorldID, shape);
1213
1206 // the CreateObject() may have recreated the rigid body. Make sure we have the latest. 1214 // the CreateObject() may have recreated the rigid body. Make sure we have the latest.
1207 m_body.Ptr = BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID); 1215 m_body.Ptr = BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID);
1208
1209 // The root object could have been recreated. Make sure everything linksety is up to date.
1210 _linkset.RefreshLinkset(this);
1211 } 1216 }
1212 1217
1213 // Copy prim's info into the BulletSim shape description structure 1218 // Copy prim's info into the BulletSim shape description structure
@@ -1236,8 +1241,8 @@ public sealed class BSPrim : PhysicsActor
1236 private void RecreateGeomAndObject() 1241 private void RecreateGeomAndObject()
1237 { 1242 {
1238 // m_log.DebugFormat("{0}: RecreateGeomAndObject. lID={1}", LogHeader, _localID); 1243 // m_log.DebugFormat("{0}: RecreateGeomAndObject. lID={1}", LogHeader, _localID);
1239 CreateGeom(true); 1244 if (CreateGeom(true))
1240 CreateObject(); 1245 CreateObject();
1241 return; 1246 return;
1242 } 1247 }
1243 1248
@@ -1322,6 +1327,15 @@ public sealed class BSPrim : PhysicsActor
1322 1327
1323 base.RequestPhysicsterseUpdate(); 1328 base.RequestPhysicsterseUpdate();
1324 } 1329 }
1330 /*
1331 else
1332 {
1333 // For debugging, we can also report the movement of children
1334 DetailLog("{0},UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
1335 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
1336 entprop.Acceleration, entprop.RotationalVelocity);
1337 }
1338 */
1325 } 1339 }
1326 1340
1327 // I've collided with something 1341 // I've collided with something
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index c6d622b..28d5cb5 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -315,6 +315,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
315 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying) 315 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying)
316 { 316 {
317 // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName); 317 // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName);
318
319 if (!m_initialized) return null;
320
318 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying); 321 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
319 lock (m_avatars) m_avatars.Add(localID, actor); 322 lock (m_avatars) m_avatars.Add(localID, actor);
320 return actor; 323 return actor;
@@ -323,6 +326,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
323 public override void RemoveAvatar(PhysicsActor actor) 326 public override void RemoveAvatar(PhysicsActor actor)
324 { 327 {
325 // m_log.DebugFormat("{0}: RemoveAvatar", LogHeader); 328 // m_log.DebugFormat("{0}: RemoveAvatar", LogHeader);
329
330 if (!m_initialized) return;
331
326 BSCharacter bsactor = actor as BSCharacter; 332 BSCharacter bsactor = actor as BSCharacter;
327 if (bsactor != null) 333 if (bsactor != null)
328 { 334 {
@@ -341,6 +347,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
341 347
342 public override void RemovePrim(PhysicsActor prim) 348 public override void RemovePrim(PhysicsActor prim)
343 { 349 {
350 if (!m_initialized) return;
351
344 BSPrim bsprim = prim as BSPrim; 352 BSPrim bsprim = prim as BSPrim;
345 if (bsprim != null) 353 if (bsprim != null)
346 { 354 {
@@ -366,6 +374,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
366 Vector3 size, Quaternion rotation, bool isPhysical, uint localID) 374 Vector3 size, Quaternion rotation, bool isPhysical, uint localID)
367 { 375 {
368 // m_log.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName); 376 // m_log.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName);
377
378 if (!m_initialized) return null;
379
369 BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical); 380 BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical);
370 lock (m_prims) m_prims.Add(localID, prim); 381 lock (m_prims) m_prims.Add(localID, prim);
371 return prim; 382 return prim;
@@ -807,6 +818,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
807 818
808 // List of all of the externally visible parameters. 819 // List of all of the externally visible parameters.
809 // For each parameter, this table maps a text name to getter and setters. 820 // For each parameter, this table maps a text name to getter and setters.
821 // To add a new externally referencable/settable parameter, add the paramter storage
822 // location somewhere in the program and make an entry in this table with the
823 // getters and setters.
824 // To add a new variable, it is easiest to find an existing definition and copy it.
825 // Parameter values are floats. Booleans are converted to a floating value.
826 //
810 // A ParameterDefn() takes the following parameters: 827 // A ParameterDefn() takes the following parameters:
811 // -- the text name of the parameter. This is used for console input and ini file. 828 // -- the text name of the parameter. This is used for console input and ini file.
812 // -- a short text description of the parameter. This shows up in the console listing. 829 // -- a short text description of the parameter. This shows up in the console listing.
@@ -815,7 +832,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
815 // -- a delegate for getting the value as a float 832 // -- a delegate for getting the value as a float
816 // -- a delegate for setting the value from a float 833 // -- a delegate for setting the value from a float
817 // 834 //
818 // To add a new variable, it is best to find an existing definition and copy it. 835 // The single letter parameters for the delegates are:
836 // s = BSScene
837 // p = string parameter name
838 // l = localID of referenced object
839 // v = float value
840 // cf = parameter configuration class (for fetching values from ini file)
819 private ParameterDefn[] ParameterDefinitions = 841 private ParameterDefn[] ParameterDefinitions =
820 { 842 {
821 new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties", 843 new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties",
@@ -1048,6 +1070,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters
1048 (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = cf.GetFloat(p, v); }, 1070 (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = cf.GetFloat(p, v); },
1049 (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; }, 1071 (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; },
1050 (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ), 1072 (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ),
1073 new ParameterDefn("LinkConstraintCFM", "Amount constraint can be violated. 0=none, 1=all. Default=0",
1074 0.0f,
1075 (s,cf,p,v) => { s.m_params[0].linkConstraintCFM = cf.GetFloat(p, v); },
1076 (s) => { return s.m_params[0].linkConstraintCFM; },
1077 (s,p,l,v) => { s.m_params[0].linkConstraintCFM = v; } ),
1078 new ParameterDefn("LinkConstraintERP", "Amount constraint is corrected each tick. 0=none, 1=all. Default = 0.2",
1079 0.2f,
1080 (s,cf,p,v) => { s.m_params[0].linkConstraintERP = cf.GetFloat(p, v); },
1081 (s) => { return s.m_params[0].linkConstraintERP; },
1082 (s,p,l,v) => { s.m_params[0].linkConstraintERP = v; } ),
1051 1083
1052 new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)", 1084 new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)",
1053 0f, 1085 0f,
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 65e3145..fe705cc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -66,13 +66,14 @@ public struct ShapeData
66{ 66{
67 public enum PhysicsShapeType 67 public enum PhysicsShapeType
68 { 68 {
69 SHAPE_AVATAR = 0, 69 SHAPE_UNKNOWN = 0,
70 SHAPE_BOX = 1, 70 SHAPE_AVATAR = 1,
71 SHAPE_CONE = 2, 71 SHAPE_BOX = 2,
72 SHAPE_CYLINDER = 3, 72 SHAPE_CONE = 3,
73 SHAPE_SPHERE = 4, 73 SHAPE_CYLINDER = 4,
74 SHAPE_MESH = 5, 74 SHAPE_SPHERE = 5,
75 SHAPE_HULL = 6 75 SHAPE_MESH = 6,
76 SHAPE_HULL = 7
76 }; 77 };
77 public uint ID; 78 public uint ID;
78 public PhysicsShapeType Type; 79 public PhysicsShapeType Type;
@@ -168,6 +169,8 @@ public struct ConfigurationParameters
168 public float linkConstraintEnableTransMotor; 169 public float linkConstraintEnableTransMotor;
169 public float linkConstraintTransMotorMaxVel; 170 public float linkConstraintTransMotorMaxVel;
170 public float linkConstraintTransMotorMaxForce; 171 public float linkConstraintTransMotorMaxForce;
172 public float linkConstraintERP;
173 public float linkConstraintCFM;
171 174
172 public const float numericTrue = 1f; 175 public const float numericTrue = 1f;
173 public const float numericFalse = 0f; 176 public const float numericFalse = 0f;
@@ -189,6 +192,28 @@ public enum CollisionFlags : uint
189 PHYSICAL_OBJECT = 1 << 12, 192 PHYSICAL_OBJECT = 1 << 12,
190}; 193};
191 194
195// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0
196// ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2.
197public enum ConstraintParams : int
198{
199 BT_CONSTRAINT_ERP = 1, // this one is not used in Bullet as of 20120730
200 BT_CONSTRAINT_STOP_ERP,
201 BT_CONSTRAINT_CFM,
202 BT_CONSTRAINT_STOP_CFM,
203};
204public enum ConstraintParamAxis : int
205{
206 AXIS_LINEAR_X = 0,
207 AXIS_LINEAR_Y,
208 AXIS_LINEAR_Z,
209 AXIS_ANGULAR_X,
210 AXIS_ANGULAR_Y,
211 AXIS_ANGULAR_Z,
212 AXIS_LINEAR_ALL = 20, // these last three added by BulletSim so we don't have to do zillions of calls
213 AXIS_ANGULAR_ALL,
214 AXIS_ALL
215};
216
192// =============================================================================== 217// ===============================================================================
193static class BulletSimAPI { 218static class BulletSimAPI {
194 219
@@ -380,7 +405,8 @@ public static extern IntPtr CreateObject2(IntPtr sim, ShapeData shapeData);
380[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 405[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
381public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2, 406public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2,
382 Vector3 frame1loc, Quaternion frame1rot, 407 Vector3 frame1loc, Quaternion frame1rot,
383 Vector3 frame2loc, Quaternion frame2rot); 408 Vector3 frame2loc, Quaternion frame2rot,
409 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
384 410
385[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 411[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
386public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi); 412public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
@@ -398,6 +424,9 @@ public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enabl
398public static extern bool CalculateTransforms2(IntPtr constrain); 424public static extern bool CalculateTransforms2(IntPtr constrain);
399 425
400[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 426[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
427public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
428
429[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
401public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain); 430public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain);
402 431
403[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 432[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 19f3ce1..f6c8e38 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -51,8 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
51 { 51 {
52 get 52 get
53 { 53 {
54 lock (SenseRepeatListLock) 54 return SenseRepeaters.Count;
55 return SenseRepeaters.Count;
56 } 55 }
57 } 56 }
58 57
@@ -115,6 +114,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
115 public double distance; 114 public double distance;
116 } 115 }
117 116
117 /// <summary>
118 /// Sensors to process.
119 /// </summary>
120 /// <remarks>
121 /// Do not add or remove sensors from this list directly. Instead, copy the list and substitute the updated
122 /// copy. This is to avoid locking the list for the duration of the sensor sweep, which increases the danger
123 /// of deadlocks with future code updates.
124 ///
125 /// Always lock SenseRepeatListLock when updating this list.
126 /// </remarks>
118 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>(); 127 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
119 private object SenseRepeatListLock = new object(); 128 private object SenseRepeatListLock = new object();
120 129
@@ -124,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
124 { 133 {
125 // Always remove first, in case this is a re-set 134 // Always remove first, in case this is a re-set
126 UnSetSenseRepeaterEvents(m_localID, m_itemID); 135 UnSetSenseRepeaterEvents(m_localID, m_itemID);
136
127 if (sec == 0) // Disabling timer 137 if (sec == 0) // Disabling timer
128 return; 138 return;
129 139
@@ -143,9 +153,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
143 ts.host = host; 153 ts.host = host;
144 154
145 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); 155 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
156
157 AddSenseRepeater(ts);
158 }
159
160 private void AddSenseRepeater(SenseRepeatClass senseRepeater)
161 {
146 lock (SenseRepeatListLock) 162 lock (SenseRepeatListLock)
147 { 163 {
148 SenseRepeaters.Add(ts); 164 List<SenseRepeatClass> newSenseRepeaters = new List<SenseRepeatClass>(SenseRepeaters);
165 newSenseRepeaters.Add(senseRepeater);
166 SenseRepeaters = newSenseRepeaters;
149 } 167 }
150 } 168 }
151 169
@@ -154,39 +172,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
154 // Remove from timer 172 // Remove from timer
155 lock (SenseRepeatListLock) 173 lock (SenseRepeatListLock)
156 { 174 {
157 List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>(); 175 List<SenseRepeatClass> newSenseRepeaters = new List<SenseRepeatClass>();
158 foreach (SenseRepeatClass ts in SenseRepeaters) 176 foreach (SenseRepeatClass ts in SenseRepeaters)
159 { 177 {
160 if (ts.localID != m_localID || ts.itemID != m_itemID) 178 if (ts.localID != m_localID || ts.itemID != m_itemID)
161 { 179 {
162 NewSensors.Add(ts); 180 newSenseRepeaters.Add(ts);
163 } 181 }
164 } 182 }
165 SenseRepeaters.Clear(); 183
166 SenseRepeaters = NewSensors; 184 SenseRepeaters = newSenseRepeaters;
167 } 185 }
168 } 186 }
169 187
170 public void CheckSenseRepeaterEvents() 188 public void CheckSenseRepeaterEvents()
171 { 189 {
172 lock (SenseRepeatListLock) 190 // Go through all timers
191 foreach (SenseRepeatClass ts in SenseRepeaters)
173 { 192 {
174 // Nothing to do here? 193 // Time has passed?
175 if (SenseRepeaters.Count == 0) 194 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
176 return;
177
178 // Go through all timers
179 foreach (SenseRepeatClass ts in SenseRepeaters)
180 { 195 {
181 // Time has passed? 196 SensorSweep(ts);
182 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) 197 // set next interval
183 { 198 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
184 SensorSweep(ts);
185 // set next interval
186 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
187 }
188 } 199 }
189 } // lock 200 }
190 } 201 }
191 202
192 public void SenseOnce(uint m_localID, UUID m_itemID, 203 public void SenseOnce(uint m_localID, UUID m_itemID,
@@ -619,21 +630,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
619 { 630 {
620 List<Object> data = new List<Object>(); 631 List<Object> data = new List<Object>();
621 632
622 lock (SenseRepeatListLock) 633 foreach (SenseRepeatClass ts in SenseRepeaters)
623 { 634 {
624 foreach (SenseRepeatClass ts in SenseRepeaters) 635 if (ts.itemID == itemID)
625 { 636 {
626 if (ts.itemID == itemID) 637 data.Add(ts.interval);
627 { 638 data.Add(ts.name);
628 data.Add(ts.interval); 639 data.Add(ts.keyID);
629 data.Add(ts.name); 640 data.Add(ts.type);
630 data.Add(ts.keyID); 641 data.Add(ts.range);
631 data.Add(ts.type); 642 data.Add(ts.arc);
632 data.Add(ts.range);
633 data.Add(ts.arc);
634 }
635 } 643 }
636 } 644 }
645
637 return data.ToArray(); 646 return data.ToArray();
638 } 647 }
639 648
@@ -667,8 +676,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
667 ts.next = 676 ts.next =
668 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); 677 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
669 678
670 lock (SenseRepeatListLock) 679 AddSenseRepeater(ts);
671 SenseRepeaters.Add(ts);
672 680
673 idx += 6; 681 idx += 6;
674 } 682 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index b24f016..97dd0f6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
38{ 38{
39 public class CSCodeGenerator : ICodeConverter 39 public class CSCodeGenerator : ICodeConverter
40 { 40 {
41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 private SYMBOL m_astRoot = null; 43 private SYMBOL m_astRoot = null;
44 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; 44 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap;
@@ -255,7 +255,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
255 else if (s is IdentDotExpression) 255 else if (s is IdentDotExpression)
256 retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s); 256 retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s);
257 else if (s is IdentExpression) 257 else if (s is IdentExpression)
258 retstr += Generate(CheckName(((IdentExpression) s).Name), s); 258 retstr += GenerateIdentifier(((IdentExpression) s).Name, s);
259 else if (s is IDENT) 259 else if (s is IDENT)
260 retstr += Generate(CheckName(((TOKEN) s).yytext), s); 260 retstr += Generate(CheckName(((TOKEN) s).yytext), s);
261 else 261 else
@@ -868,6 +868,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
868 } 868 }
869 869
870 /// <summary> 870 /// <summary>
871 /// Generates the code for an identifier
872 /// </summary>
873 /// <param name="id">The symbol name</param>
874 /// <param name="s">The Symbol node.</param>
875 /// <returns>String containing C# code for identifier reference.</returns>
876 private string GenerateIdentifier(string id, SYMBOL s)
877 {
878 if (m_comms != null)
879 {
880 object value = m_comms.LookupModConstant(id);
881 if (value != null)
882 {
883 string retval = null;
884 if (value is int)
885 retval = ((int)value).ToString();
886 else if (value is float)
887 retval = String.Format("new LSL_Types.LSLFloat({0})",((float)value).ToString());
888 else if (value is string)
889 retval = String.Format("new LSL_Types.LSLString(\"{0}\")",((string)value));
890 else if (value is OpenMetaverse.UUID)
891 retval = String.Format("new LSL_Types.key(\"{0}\")",((OpenMetaverse.UUID)value).ToString());
892 else if (value is OpenMetaverse.Vector3)
893 retval = String.Format("new LSL_Types.Vector3(\"{0}\")",((OpenMetaverse.Vector3)value).ToString());
894 else if (value is OpenMetaverse.Quaternion)
895 retval = String.Format("new LSL_Types.Quaternion(\"{0}\")",((OpenMetaverse.Quaternion)value).ToString());
896 else retval = id;
897
898 return Generate(retval, s);
899 }
900 }
901
902 return Generate(CheckName(id), s);
903 }
904
905 /// <summary>
871 /// Generates the code for a FunctionCall node. 906 /// Generates the code for a FunctionCall node.
872 /// </summary> 907 /// </summary>
873 /// <param name="fc">The FunctionCall node.</param> 908 /// <param name="fc">The FunctionCall node.</param>