aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-11-21 18:27:41 +0000
committerJustin Clark-Casey (justincc)2011-11-21 18:27:41 +0000
commit898904d83d371b69d001b669588f29c2befd6aa9 (patch)
tree8a6c6722901d44c53370fd6475a370db8dc5b08b
parentHave ODECharacter and ODEPrim both use PhysicsActor.Name instead of maintaini... (diff)
downloadopensim-SC_OLD-898904d83d371b69d001b669588f29c2befd6aa9.zip
opensim-SC_OLD-898904d83d371b69d001b669588f29c2befd6aa9.tar.gz
opensim-SC_OLD-898904d83d371b69d001b669588f29c2befd6aa9.tar.bz2
opensim-SC_OLD-898904d83d371b69d001b669588f29c2befd6aa9.tar.xz
When an ODECharacter is removed (e.g. when an avatar leaves a scene), remove the actor reference in OdeScene.actor_name_map rather than leaving it dangling.
This also largely centralizes adds/removes in OdeScene.AddCharacter()/RemoveCharacter()
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs11
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs22
2 files changed, 23 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 20bc7f6..3e7fadf 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -599,13 +599,11 @@ namespace OpenSim.Region.Physics.OdePlugin
599 d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2)); 599 d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
600 } 600 }
601 601
602
603 d.GeomSetRotation(Shell, ref m_caprot); 602 d.GeomSetRotation(Shell, ref m_caprot);
604 d.BodySetRotation(Body, ref m_caprot); 603 d.BodySetRotation(Body, ref m_caprot);
605 604
606 d.GeomSetBody(Shell, Body); 605 d.GeomSetBody(Shell, Body);
607 606
608
609 // The purpose of the AMotor here is to keep the avatar's physical 607 // The purpose of the AMotor here is to keep the avatar's physical
610 // surrogate from rotating while moving 608 // surrogate from rotating while moving
611 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); 609 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
@@ -660,7 +658,6 @@ namespace OpenSim.Region.Physics.OdePlugin
660 //standupStraight(); 658 //standupStraight();
661 } 659 }
662 660
663 //
664 /// <summary> 661 /// <summary>
665 /// Uses the capped cyllinder volume formula to calculate the avatar's mass. 662 /// Uses the capped cyllinder volume formula to calculate the avatar's mass.
666 /// This may be used in calculations in the scene/scenepresence 663 /// This may be used in calculations in the scene/scenepresence
@@ -1162,14 +1159,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1162 { 1159 {
1163 //kill the body 1160 //kill the body
1164 d.BodyDestroy(Body); 1161 d.BodyDestroy(Body);
1165
1166 Body = IntPtr.Zero; 1162 Body = IntPtr.Zero;
1167 } 1163 }
1168 1164
1169 if (Shell != IntPtr.Zero) 1165 if (Shell != IntPtr.Zero)
1170 { 1166 {
1171 d.GeomDestroy(Shell); 1167 d.GeomDestroy(Shell);
1172 _parent_scene.geom_name_map.Remove(Shell);
1173 Shell = IntPtr.Zero; 1168 Shell = IntPtr.Zero;
1174 } 1169 }
1175 } 1170 }
@@ -1279,10 +1274,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1279 + (Body!=IntPtr.Zero ? "Body ":"") 1274 + (Body!=IntPtr.Zero ? "Body ":"")
1280 + (Amotor!=IntPtr.Zero ? "Amotor ":"")); 1275 + (Amotor!=IntPtr.Zero ? "Amotor ":""));
1281 } 1276 }
1277
1282 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor); 1278 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor);
1283
1284 _parent_scene.geom_name_map[Shell] = Name;
1285 _parent_scene.actor_name_map[Shell] = this;
1286 _parent_scene.AddCharacter(this); 1279 _parent_scene.AddCharacter(this);
1287 } 1280 }
1288 else 1281 else
@@ -1318,7 +1311,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1318// Velocity = Vector3.Zero; 1311// Velocity = Vector3.Zero;
1319 1312
1320 _parent_scene.geom_name_map[Shell] = Name; 1313 _parent_scene.geom_name_map[Shell] = Name;
1321 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 1314 _parent_scene.actor_name_map[Shell] = this;
1322 } 1315 }
1323 else 1316 else
1324 { 1317 {
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index fe2b2b2..9dee07b 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -238,8 +238,23 @@ namespace OpenSim.Region.Physics.OdePlugin
238 private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>(); 238 private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>();
239 239
240 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); 240 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
241
242 /// <summary>
243 /// Maps a unique geometry id (a memory location) to a physics actor name.
244 /// </summary>
245 /// <remarks>
246 /// Only actors participating in collisions have geometries.
247 /// </remarks>
241 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 248 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
249
250 /// <summary>
251 /// Maps a unique geometry id (a memory location) to a physics actor.
252 /// </summary>
253 /// <remarks>
254 /// Only actors participating in collisions have geometries.
255 /// </remarks>
242 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); 256 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
257
243 private bool m_NINJA_physics_joints_enabled = false; 258 private bool m_NINJA_physics_joints_enabled = false;
244 //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>(); 259 //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>();
245 private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>(); 260 private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>();
@@ -1699,8 +1714,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1699 if (!_characters.Contains(chr)) 1714 if (!_characters.Contains(chr))
1700 { 1715 {
1701 _characters.Add(chr); 1716 _characters.Add(chr);
1717 geom_name_map[chr.Shell] = Name;
1718 actor_name_map[chr.Shell] = chr;
1719
1702 if (chr.bad) 1720 if (chr.bad)
1703 m_log.DebugFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid); 1721 m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
1704 } 1722 }
1705 } 1723 }
1706 } 1724 }
@@ -1712,6 +1730,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1712 if (_characters.Contains(chr)) 1730 if (_characters.Contains(chr))
1713 { 1731 {
1714 _characters.Remove(chr); 1732 _characters.Remove(chr);
1733 geom_name_map.Remove(chr.Shell);
1734 actor_name_map.Remove(chr.Shell);
1715 } 1735 }
1716 } 1736 }
1717 } 1737 }