OpenSim/Region/Physics/OdePlugin/OdeScene.cs
/// <summary>
/// This is our collision testing routine in ODE
/// </summary>
This is our collision testing routine in ODE
This is our collision testing routine in ODE
private void collision_optimized()
        {
            _perloopContact.Clear();
            foreach (OdeCharacter chr in _characters)
            {
                if (chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero)
                    continue;
                chr.IsColliding = false;
                chr.CollidingGround = false;
                chr.CollidingObj = false;
                try
                {
                    CollideSpaces(space, chr.Shell, IntPtr.Zero);
                }
                catch (AccessViolationException)
                {
                    m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", Name);
                }
            }
            if (CollectStats)
            {
                m_tempAvatarCollisionsThisFrame = _perloopContact.Count;
                m_stats[ODEAvatarContactsStatsName] += m_tempAvatarCollisionsThisFrame;
            }
            List<OdePrim> removeprims = null;
            foreach (OdePrim chr in _activeprims)
            {
                if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled))
                {
                    try
                    {
                        lock (chr)
                        {
                            if (space != IntPtr.Zero && chr.prim_geom != IntPtr.Zero && chr.m_taintremove == false)
                            {
                                CollideSpaces(space, chr.prim_geom, IntPtr.Zero);
                            }
                            else
                            {
                                if (removeprims == null)
                                {
                                    removeprims = new List<OdePrim>();
                                }
                                removeprims.Add(chr);
                                m_log.Error(
                                    "[ODE SCENE]: unable to collide test active prim against space.  The space was zero, the geom was zero or it was in the process of being removed.  Removed it from the active prim list.  This needs to be fixed!");
                            }
                        }
                    }
                    catch (AccessViolationException)
                    {
                        m_log.Error("[ODE SCENE]: Unable to space collide");
                    }
                }
            }
            if (CollectStats)
                m_stats[ODEPrimContactsStatName] += _perloopContact.Count - m_tempAvatarCollisionsThisFrame;
            if (removeprims != null)
            {
                foreach (OdePrim chr in removeprims)
                {
                    _activeprims.Remove(chr);
                }
            }
        }
private void collision_optimized ( ) { _perloopContact . Clear ( ) ; foreach ( OdeCharacter chr in _characters ) { if ( chr . Shell == IntPtr . Zero || chr . Body == IntPtr . Zero ) continue ; chr . IsColliding = false ; chr . CollidingGround = false ; chr . CollidingObj = false ; try { CollideSpaces ( space , chr . Shell , IntPtr . Zero ) ; } catch ( AccessViolationException ) { m_log . ErrorFormat ( " " , Name ) ; } } if ( CollectStats ) { m_tempAvatarCollisionsThisFrame = _perloopContact . Count ; m_stats [ ODEAvatarContactsStatsName ] += m_tempAvatarCollisionsThisFrame ; } List < OdePrim > removeprims = null ; foreach ( OdePrim chr in _activeprims ) { if ( chr . Body != IntPtr . Zero && d . BodyIsEnabled ( chr . Body ) && ( ! chr . m_disabled ) ) { try { lock ( chr ) { if ( space != IntPtr . Zero && chr . prim_geom != IntPtr . Zero && chr . m_taintremove == false ) { CollideSpaces ( space , chr . prim_geom , IntPtr . Zero ) ; } else { if ( removeprims == null ) { removeprims = new List < OdePrim > ( ) ; } removeprims . Add ( chr ) ; m_log . Error ( " " ) ; } } } catch ( AccessViolationException ) { m_log . Error ( " " ) ; } } } if ( CollectStats ) m_stats [ ODEPrimContactsStatName ] += _perloopContact . Count - m_tempAvatarCollisionsThisFrame ; if ( removeprims != null ) { foreach ( OdePrim chr in removeprims ) { _activeprims . Remove ( chr ) ; } } }
This is our collision testing routine in ODE
This is our collision testing routine in ODE
// Reset the collision values to false // since we don't know if we're colliding yet // Test the avatar's geometry for collision with the space // This will return near and the space that they are the closest to // And we'll run this again against the avatar and the space segment // This will return with a bunch of possible objects in the space segment // and we'll run it again on all of them. //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); //if (chr.Position.Z + (chr.Velocity.Z * timeStep) < terrainheight + 10) //{ //chr.Position.Z = terrainheight + 10.0f; //forcedZ = true; //}