aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs2
-rwxr-xr-xOpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs335
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs20
3 files changed, 338 insertions, 19 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index a96c8b4..373ed41 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -908,7 +908,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
908 908
909 public void Start() 909 public void Start()
910 { 910 {
911 m_scene.AddNewClient(this, PresenceType.User); 911 m_scene.AddNewAgent(this, PresenceType.User);
912 912
913 // Mimicking LLClientView which gets always set appearance from client. 913 // Mimicking LLClientView which gets always set appearance from client.
914 AvatarAppearance appearance; 914 AvatarAppearance appearance;
diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
index d1d318c..9daf9d7 100755
--- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs
@@ -29,12 +29,14 @@ using System.Collections.Generic;
29using System.Linq; 29using System.Linq;
30using System.Reflection; 30using System.Reflection;
31using System.Text; 31using System.Text;
32using System.Threading;
32 33
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Region.CoreModules; 35using OpenSim.Region.CoreModules;
35using OpenSim.Region.Framework; 36using OpenSim.Region.Framework;
36using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Physics.Manager;
38 40
39using Mono.Addins; 41using Mono.Addins;
40using Nini.Config; 42using Nini.Config;
@@ -60,6 +62,10 @@ public class ExtendedPhysics : INonSharedRegionModule
60 // Per prim functions. See BSPrim. 62 // Per prim functions. See BSPrim.
61 public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; 63 public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType";
62 public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; 64 public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType";
65 public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed";
66 public const string PhysFunctChangeLinkType = "BulletSim.ChangeLinkType";
67 public const string PhysFunctGetLinkType = "BulletSim.GetLinkType";
68 public const string PhysFunctChangeLinkParams = "BulletSim.ChangeLinkParams";
63 69
64 // ============================================================= 70 // =============================================================
65 71
@@ -155,7 +161,7 @@ public class ExtendedPhysics : INonSharedRegionModule
155 } 161 }
156 162
157 [ScriptConstant] 163 [ScriptConstant]
158 public static int PHYS_CENTER_OF_MASS = 1 << 0; 164 public const int PHYS_CENTER_OF_MASS = 1 << 0;
159 165
160 [ScriptInvocation] 166 [ScriptInvocation]
161 public string physGetEngineType(UUID hostID, UUID scriptID) 167 public string physGetEngineType(UUID hostID, UUID scriptID)
@@ -171,11 +177,11 @@ public class ExtendedPhysics : INonSharedRegionModule
171 } 177 }
172 178
173 [ScriptConstant] 179 [ScriptConstant]
174 public static int PHYS_LINKSET_TYPE_CONSTRAINT = 0; 180 public const int PHYS_LINKSET_TYPE_CONSTRAINT = 0;
175 [ScriptConstant] 181 [ScriptConstant]
176 public static int PHYS_LINKSET_TYPE_COMPOUND = 1; 182 public const int PHYS_LINKSET_TYPE_COMPOUND = 1;
177 [ScriptConstant] 183 [ScriptConstant]
178 public static int PHYS_LINKSET_TYPE_MANUAL = 2; 184 public const int PHYS_LINKSET_TYPE_MANUAL = 2;
179 185
180 [ScriptInvocation] 186 [ScriptInvocation]
181 public int physSetLinksetType(UUID hostID, UUID scriptID, int linksetType) 187 public int physSetLinksetType(UUID hostID, UUID scriptID, int linksetType)
@@ -195,10 +201,38 @@ public class ExtendedPhysics : INonSharedRegionModule
195 201
196 if (rootPart != null) 202 if (rootPart != null)
197 { 203 {
198 Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; 204 PhysicsActor rootPhysActor = rootPart.PhysActor;
199 if (rootPhysActor != null) 205 if (rootPhysActor != null)
200 { 206 {
201 ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); 207 if (rootPhysActor.IsPhysical)
208 {
209 // Change a physical linkset by making non-physical, waiting for one heartbeat so all
210 // the prim and linkset state is updated, changing the type and making the
211 // linkset physical again.
212 containingGroup.ScriptSetPhysicsStatus(false);
213 Thread.Sleep(150); // longer than one heartbeat tick
214
215 // A kludge for the moment.
216 // Since compound linksets move the children but don't generate position updates to the
217 // simulator, it is possible for compound linkset children to have out-of-sync simulator
218 // and physical positions. The following causes the simulator to push the real child positions
219 // down into the physics engine to get everything synced.
220 containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition);
221 containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation);
222
223 object[] parms2 = { rootPhysActor, null, linksetType };
224 ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2));
225 Thread.Sleep(150); // longer than one heartbeat tick
226
227 containingGroup.ScriptSetPhysicsStatus(true);
228 }
229 else
230 {
231 // Non-physical linksets don't have a physical instantiation so there is no state to
232 // worry about being updated.
233 object[] parms2 = { rootPhysActor, null, linksetType };
234 ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2));
235 }
202 } 236 }
203 else 237 else
204 { 238 {
@@ -223,7 +257,6 @@ public class ExtendedPhysics : INonSharedRegionModule
223 public int physGetLinksetType(UUID hostID, UUID scriptID) 257 public int physGetLinksetType(UUID hostID, UUID scriptID)
224 { 258 {
225 int ret = -1; 259 int ret = -1;
226
227 if (!Enabled) return ret; 260 if (!Enabled) return ret;
228 261
229 // The part that is requesting the change. 262 // The part that is requesting the change.
@@ -237,10 +270,11 @@ public class ExtendedPhysics : INonSharedRegionModule
237 270
238 if (rootPart != null) 271 if (rootPart != null)
239 { 272 {
240 Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; 273 PhysicsActor rootPhysActor = rootPart.PhysActor;
241 if (rootPhysActor != null) 274 if (rootPhysActor != null)
242 { 275 {
243 ret = (int)rootPhysActor.Extension(PhysFunctGetLinksetType); 276 object[] parms2 = { rootPhysActor, null };
277 ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType, parms2));
244 } 278 }
245 else 279 else
246 { 280 {
@@ -260,5 +294,288 @@ public class ExtendedPhysics : INonSharedRegionModule
260 } 294 }
261 return ret; 295 return ret;
262 } 296 }
297
298 [ScriptConstant]
299 public const int PHYS_LINK_TYPE_FIXED = 1234;
300 [ScriptConstant]
301 public const int PHYS_LINK_TYPE_HINGE = 4;
302 [ScriptConstant]
303 public const int PHYS_LINK_TYPE_SPRING = 9;
304 [ScriptConstant]
305 public const int PHYS_LINK_TYPE_6DOF = 6;
306 [ScriptConstant]
307 public const int PHYS_LINK_TYPE_SLIDER = 7;
308
309 // physChangeLinkType(integer linkNum, integer typeCode)
310 [ScriptInvocation]
311 public int physChangeLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode)
312 {
313 int ret = -1;
314 if (!Enabled) return ret;
315
316 PhysicsActor rootPhysActor;
317 PhysicsActor childPhysActor;
318
319 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
320 {
321 object[] parms2 = { rootPhysActor, childPhysActor, typeCode };
322 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2));
323 }
324
325 return ret;
326 }
327
328 // physGetLinkType(integer linkNum)
329 [ScriptInvocation]
330 public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum)
331 {
332 int ret = -1;
333 if (!Enabled) return ret;
334
335 PhysicsActor rootPhysActor;
336 PhysicsActor childPhysActor;
337
338 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
339 {
340 object[] parms2 = { rootPhysActor, childPhysActor };
341 ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms2));
342 }
343
344 return ret;
345 }
346
347 // physChangeLinkFixed(integer linkNum)
348 // Change the link between the root and the linkNum into a fixed, static physical connection.
349 [ScriptInvocation]
350 public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum)
351 {
352 int ret = -1;
353 if (!Enabled) return ret;
354
355 PhysicsActor rootPhysActor;
356 PhysicsActor childPhysActor;
357
358 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
359 {
360 object[] parms2 = { rootPhysActor, childPhysActor , PHYS_LINK_TYPE_FIXED };
361 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2));
362 }
363
364 return ret;
365 }
366
367 // Code for specifying params.
368 // The choice if 14400 is arbitrary and only serves to catch parameter code misuse.
369 public const int PHYS_PARAM_MIN = 14401;
370
371 [ScriptConstant]
372 public const int PHYS_PARAM_FRAMEINA_LOC = 14401;
373 [ScriptConstant]
374 public const int PHYS_PARAM_FRAMEINA_ROT = 14402;
375 [ScriptConstant]
376 public const int PHYS_PARAM_FRAMEINB_LOC = 14403;
377 [ScriptConstant]
378 public const int PHYS_PARAM_FRAMEINB_ROT = 14404;
379 [ScriptConstant]
380 public const int PHYS_PARAM_LINEAR_LIMIT_LOW = 14405;
381 [ScriptConstant]
382 public const int PHYS_PARAM_LINEAR_LIMIT_HIGH = 14406;
383 [ScriptConstant]
384 public const int PHYS_PARAM_ANGULAR_LIMIT_LOW = 14407;
385 [ScriptConstant]
386 public const int PHYS_PARAM_ANGULAR_LIMIT_HIGH = 14408;
387 [ScriptConstant]
388 public const int PHYS_PARAM_USE_FRAME_OFFSET = 14409;
389 [ScriptConstant]
390 public const int PHYS_PARAM_ENABLE_TRANSMOTOR = 14410;
391 [ScriptConstant]
392 public const int PHYS_PARAM_TRANSMOTOR_MAXVEL = 14411;
393 [ScriptConstant]
394 public const int PHYS_PARAM_TRANSMOTOR_MAXFORCE = 14412;
395 [ScriptConstant]
396 public const int PHYS_PARAM_CFM = 14413;
397 [ScriptConstant]
398 public const int PHYS_PARAM_ERP = 14414;
399 [ScriptConstant]
400 public const int PHYS_PARAM_SOLVER_ITERATIONS = 14415;
401 [ScriptConstant]
402 public const int PHYS_PARAM_SPRING_AXIS_ENABLE = 14416;
403 [ScriptConstant]
404 public const int PHYS_PARAM_SPRING_DAMPING = 14417;
405 [ScriptConstant]
406 public const int PHYS_PARAM_SPRING_STIFFNESS = 14418;
407 [ScriptConstant]
408 public const int PHYS_PARAM_LINK_TYPE = 14419;
409 [ScriptConstant]
410 public const int PHYS_PARAM_USE_LINEAR_FRAMEA = 14420;
411 [ScriptConstant]
412 public const int PHYS_PARAM_SPRING_EQUILIBRIUM_POINT = 14421;
413
414 public const int PHYS_PARAM_MAX = 14421;
415
416 // Used when specifying a parameter that has settings for the three linear and three angular axis
417 [ScriptConstant]
418 public const int PHYS_AXIS_ALL = -1;
419 [ScriptConstant]
420 public const int PHYS_AXIS_LINEAR_ALL = -2;
421 [ScriptConstant]
422 public const int PHYS_AXIS_ANGULAR_ALL = -3;
423 [ScriptConstant]
424 public const int PHYS_AXIS_LINEAR_X = 0;
425 [ScriptConstant]
426 public const int PHYS_AXIS_LINEAR_Y = 1;
427 [ScriptConstant]
428 public const int PHYS_AXIS_LINEAR_Z = 2;
429 [ScriptConstant]
430 public const int PHYS_AXIS_ANGULAR_X = 3;
431 [ScriptConstant]
432 public const int PHYS_AXIS_ANGULAR_Y = 4;
433 [ScriptConstant]
434 public const int PHYS_AXIS_ANGULAR_Z = 5;
435
436 // physChangeLinkParams(integer linkNum, [ PHYS_PARAM_*, value, PHYS_PARAM_*, value, ...])
437 [ScriptInvocation]
438 public int physChangeLinkParams(UUID hostID, UUID scriptID, int linkNum, object[] parms)
439 {
440 int ret = -1;
441 if (!Enabled) return ret;
442
443 PhysicsActor rootPhysActor;
444 PhysicsActor childPhysActor;
445
446 if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
447 {
448 object[] parms2 = AddToBeginningOfArray(rootPhysActor, childPhysActor, parms);
449 ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, parms2));
450 }
451
452 return ret;
453 }
454
455 private bool GetRootPhysActor(UUID hostID, out PhysicsActor rootPhysActor)
456 {
457 SceneObjectGroup containingGroup;
458 SceneObjectPart rootPart;
459 return GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor);
460 }
461
462 private bool GetRootPhysActor(UUID hostID, out SceneObjectGroup containingGroup, out SceneObjectPart rootPart, out PhysicsActor rootPhysActor)
463 {
464 bool ret = false;
465 rootPhysActor = null;
466 containingGroup = null;
467 rootPart = null;
468
469 SceneObjectPart requestingPart;
470
471 requestingPart = BaseScene.GetSceneObjectPart(hostID);
472 if (requestingPart != null)
473 {
474 // The type is is always on the root of a linkset.
475 containingGroup = requestingPart.ParentGroup;
476 if (containingGroup != null && !containingGroup.IsDeleted)
477 {
478 rootPart = containingGroup.RootPart;
479 if (rootPart != null)
480 {
481 rootPhysActor = rootPart.PhysActor;
482 if (rootPhysActor != null)
483 {
484 ret = true;
485 }
486 else
487 {
488 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
489 LogHeader, rootPart.Name, hostID);
490 }
491 }
492 else
493 {
494 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not exist. RequestingPartName={1}, hostID={2}",
495 LogHeader, requestingPart.Name, hostID);
496 }
497 }
498 else
499 {
500 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Containing group missing or deleted. hostID={1}", LogHeader, hostID);
501 }
502 }
503 else
504 {
505 m_log.WarnFormat("{0} GetRootAndChildPhysActors: cannot find script object in scene. hostID={1}", LogHeader, hostID);
506 }
507
508 return ret;
509 }
510
511 // Find the root and child PhysActors based on the linkNum.
512 // Return 'true' if both are found and returned.
513 private bool GetRootAndChildPhysActors(UUID hostID, int linkNum, out PhysicsActor rootPhysActor, out PhysicsActor childPhysActor)
514 {
515 bool ret = false;
516 rootPhysActor = null;
517 childPhysActor = null;
518
519 SceneObjectGroup containingGroup;
520 SceneObjectPart rootPart;
521
522 if (GetRootPhysActor(hostID, out containingGroup, out rootPart, out rootPhysActor))
523 {
524 SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
525 if (linkPart != null)
526 {
527 childPhysActor = linkPart.PhysActor;
528 if (childPhysActor != null)
529 {
530 ret = true;
531 }
532 else
533 {
534 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
535 LogHeader, rootPart.Name, hostID, linkNum);
536 }
537 }
538 else
539 {
540 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
541 LogHeader, rootPart.Name, hostID, linkNum);
542 }
543 }
544 else
545 {
546 m_log.WarnFormat("{0} GetRootAndChildPhysActors: Root part does not have a physics actor. rootName={1}, hostID={2}",
547 LogHeader, rootPart.Name, hostID);
548 }
549
550 return ret;
551 }
552
553 // Return an array of objects with the passed object as the first object of a new array
554 private object[] AddToBeginningOfArray(object firstOne, object secondOne, object[] prevArray)
555 {
556 object[] newArray = new object[2 + prevArray.Length];
557 newArray[0] = firstOne;
558 newArray[1] = secondOne;
559 prevArray.CopyTo(newArray, 2);
560 return newArray;
561 }
562
563 // Extension() returns an object. Convert that object into the integer error we expect to return.
564 private int MakeIntError(object extensionRet)
565 {
566 int ret = -1;
567 if (extensionRet != null)
568 {
569 try
570 {
571 ret = (int)extensionRet;
572 }
573 catch
574 {
575 ret = -1;
576 }
577 }
578 return ret;
579 }
263} 580}
264} 581}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 78fe096..9ec4740 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -176,7 +176,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
176 lock (m_avatars) 176 lock (m_avatars)
177 { 177 {
178 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); 178 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
179 scene.AddNewClient(npcAvatar, PresenceType.Npc); 179 scene.AddNewAgent(npcAvatar, PresenceType.Npc);
180 180
181 ScenePresence sp; 181 ScenePresence sp;
182 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) 182 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
@@ -207,8 +207,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
207 if (scene.TryGetScenePresence(agentID, out sp)) 207 if (scene.TryGetScenePresence(agentID, out sp))
208 { 208 {
209// m_log.DebugFormat( 209// m_log.DebugFormat(
210// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", 210// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
211// sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); 211// sp.Name, pos, scene.RegionInfo.RegionName,
212// noFly, landAtTarget);
212 213
213 sp.MoveToTarget(pos, noFly, landAtTarget); 214 sp.MoveToTarget(pos, noFly, landAtTarget);
214 sp.SetAlwaysRun = running; 215 sp.SetAlwaysRun = running;
@@ -285,9 +286,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
285 ScenePresence sp; 286 ScenePresence sp;
286 if (scene.TryGetScenePresence(agentID, out sp)) 287 if (scene.TryGetScenePresence(agentID, out sp))
287 { 288 {
288 sp.HandleAgentRequestSit(m_avatars[agentID], agentID, 289 sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero);
289 partID, Vector3.Zero);
290 //sp.HandleAgentSit(m_avatars[agentID], agentID);
291 290
292 return true; 291 return true;
293 } 292 }
@@ -378,11 +377,14 @@ namespace OpenSim.Region.OptionalModules.World.NPC
378 agentID, av.Name); 377 agentID, av.Name);
379 */ 378 */
380 379
381 scene.IncomingCloseAgent(agentID, false); 380 scene.CloseAgent(agentID, false);
382// scene.RemoveClient(agentID, false); 381
383 m_avatars.Remove(agentID); 382 m_avatars.Remove(agentID);
384 383
385// m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); 384 /*
385 m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}",
386 agentID, av.Name);
387 */
386 return true; 388 return true;
387 } 389 }
388 } 390 }