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()iar_mods
							parent
							
								
									cead87005b
								
							
						
					
					
						commit
						898904d83d
					
				| 
						 | 
				
			
			@ -599,13 +599,11 @@ namespace OpenSim.Region.Physics.OdePlugin
 | 
			
		|||
                d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            d.GeomSetRotation(Shell, ref m_caprot);
 | 
			
		||||
            d.BodySetRotation(Body, ref m_caprot);
 | 
			
		||||
 | 
			
		||||
            d.GeomSetBody(Shell, Body);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            // The purpose of the AMotor here is to keep the avatar's physical
 | 
			
		||||
            // surrogate from rotating while moving
 | 
			
		||||
            Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
 | 
			
		||||
| 
						 | 
				
			
			@ -660,7 +658,6 @@ namespace OpenSim.Region.Physics.OdePlugin
 | 
			
		|||
            //standupStraight();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Uses the capped cyllinder volume formula to calculate the avatar's mass.
 | 
			
		||||
        /// This may be used in calculations in the scene/scenepresence
 | 
			
		||||
| 
						 | 
				
			
			@ -1162,14 +1159,12 @@ namespace OpenSim.Region.Physics.OdePlugin
 | 
			
		|||
            {
 | 
			
		||||
                //kill the body
 | 
			
		||||
                d.BodyDestroy(Body);
 | 
			
		||||
 | 
			
		||||
                Body = IntPtr.Zero;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (Shell != IntPtr.Zero)
 | 
			
		||||
            {
 | 
			
		||||
                d.GeomDestroy(Shell);
 | 
			
		||||
                _parent_scene.geom_name_map.Remove(Shell);
 | 
			
		||||
                Shell = IntPtr.Zero;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1279,10 +1274,8 @@ namespace OpenSim.Region.Physics.OdePlugin
 | 
			
		|||
                            + (Body!=IntPtr.Zero ? "Body ":"")
 | 
			
		||||
                            + (Amotor!=IntPtr.Zero ? "Amotor ":""));
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z, m_tensor);
 | 
			
		||||
                    
 | 
			
		||||
                    _parent_scene.geom_name_map[Shell] = Name;
 | 
			
		||||
                    _parent_scene.actor_name_map[Shell] = this;
 | 
			
		||||
                    _parent_scene.AddCharacter(this);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
| 
						 | 
				
			
			@ -1318,7 +1311,7 @@ namespace OpenSim.Region.Physics.OdePlugin
 | 
			
		|||
//                    Velocity = Vector3.Zero;
 | 
			
		||||
 | 
			
		||||
                    _parent_scene.geom_name_map[Shell] = Name;
 | 
			
		||||
                    _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
 | 
			
		||||
                    _parent_scene.actor_name_map[Shell] = this;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -238,8 +238,23 @@ namespace OpenSim.Region.Physics.OdePlugin
 | 
			
		|||
        private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>();
 | 
			
		||||
        
 | 
			
		||||
        private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Maps a unique geometry id (a memory location) to a physics actor name.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <remarks>
 | 
			
		||||
        /// Only actors participating in collisions have geometries.
 | 
			
		||||
        /// </remarks>
 | 
			
		||||
        public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Maps a unique geometry id (a memory location) to a physics actor.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <remarks>
 | 
			
		||||
        /// Only actors participating in collisions have geometries.
 | 
			
		||||
        /// </remarks>
 | 
			
		||||
        public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
 | 
			
		||||
 | 
			
		||||
        private bool m_NINJA_physics_joints_enabled = false;
 | 
			
		||||
        //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>();
 | 
			
		||||
        private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>();
 | 
			
		||||
| 
						 | 
				
			
			@ -1699,8 +1714,11 @@ namespace OpenSim.Region.Physics.OdePlugin
 | 
			
		|||
                if (!_characters.Contains(chr))
 | 
			
		||||
                {
 | 
			
		||||
                    _characters.Add(chr);
 | 
			
		||||
                    geom_name_map[chr.Shell] = Name;
 | 
			
		||||
                    actor_name_map[chr.Shell] = chr;
 | 
			
		||||
 | 
			
		||||
                    if (chr.bad)
 | 
			
		||||
                        m_log.DebugFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
 | 
			
		||||
                        m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1712,6 +1730,8 @@ namespace OpenSim.Region.Physics.OdePlugin
 | 
			
		|||
                if (_characters.Contains(chr))
 | 
			
		||||
                {
 | 
			
		||||
                    _characters.Remove(chr);
 | 
			
		||||
                    geom_name_map.Remove(chr.Shell);
 | 
			
		||||
                    actor_name_map.Remove(chr.Shell);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue