Ejemplo n.º 1
0
 public override PhysicsActor AddAvatar(string avName, Vector3 position, Quaternion rotation, Vector3 size, bool isFlying, uint LocalID)
 {
     lock (BulletLock)
     {
         BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP,
                                                               avCapRadius, avStandupTensor, avDensity,
                                                               avHeightFudgeFactor, avMovementDivisorWalk,
                                                               avMovementDivisorRun);
         chr.LocalID = LocalID;
         try
         {
             lock (m_characters)
             {
                 m_characters.Add(chr);
                 m_charactersLocalID.Add(chr.m_localID, chr);
             }
         }
         catch
         {
             // noop if it's already there
             m_log.Debug("[PHYSICS] BulletDotNet: adding duplicate avatar localID");
         }
         AddPhysicsActorTaint(chr);
         return(chr);
     }
 }
Ejemplo n.º 2
0
 public void RemoveAvatarFromList(BulletDotNETCharacter chr)
 {
     lock (m_characters)
     {
         m_charactersLocalID.Remove(chr.m_localID);
         m_characters.Remove(chr);
     }
 }
Ejemplo n.º 3
0
 internal void removeFromWorld(BulletDotNETCharacter chr, btRigidBody body)
 {
     lock (m_characters)
     {
         if (m_characters.Contains(chr))
         {
             m_world.removeRigidBody(body);
             m_characters.Remove(chr);
         }
     }
 }
Ejemplo n.º 4
0
        public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying)
        {
            BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP,
                                                                  avCapRadius, avStandupTensor, avDensity,
                                                                  avHeightFudgeFactor, avMovementDivisorWalk,
                                                                  avMovementDivisorRun);

            m_characters.Add(chr);
            AddPhysicsActorTaint(chr);
            return(chr);
        }
Ejemplo n.º 5
0
        public override void RemoveAvatar(PhysicsActor actor)
        {
            BulletDotNETCharacter chr = (BulletDotNETCharacter)actor;

            m_characters.Remove(chr);
            m_world.removeRigidBody(chr.Body);
            m_world.removeCollisionObject(chr.Body);

            chr.Remove();
            AddPhysicsActorTaint(chr);
            //chr = null;
        }
Ejemplo n.º 6
0
        public override void RemoveAvatar(PhysicsActor actor)
        {
            lock (BulletLock)
            {
                BulletDotNETCharacter chr = (BulletDotNETCharacter)actor;

                if (!Locked)
                {
                    chr.Remove();
                    AddPhysicsActorTaint(chr);
                    //chr = null;
                }
                else
                {
                    RemoveQueue.Add(actor);
                }
                m_charactersLocalID.Remove(chr.m_localID);
            }
        }
Ejemplo n.º 7
0
 internal void removeFromWorld(BulletDotNETCharacter chr, btRigidBody body)
 {
     lock (m_characters)
     {
         if (m_characters.Contains(chr))
         {
             m_world.removeRigidBody(body);
             m_characters.Remove(chr);
         }
     }
 }
Ejemplo n.º 8
0
 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
 {
     lock (BulletLock)
     {
         BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP,
                                                               avCapRadius, avStandupTensor, avDensity,
                                                               avHeightFudgeFactor, avMovementDivisorWalk,
                                                               avMovementDivisorRun);
         try
         {
             lock (m_characters)
             {
                 m_characters.Add(chr);
                 m_charactersLocalID.Add(chr.m_localID, chr);
             }
         }
         catch
         {
             // noop if it's already there
             m_log.Debug("[PHYSICS] BulletDotNet: adding duplicate avatar localID");
         }
         AddPhysicsActorTaint(chr);
         return chr;
     }
 }
Ejemplo n.º 9
0
 public void RemoveAvatarFromList(BulletDotNETCharacter chr)
 {
     lock (m_characters)
     {
         m_charactersLocalID.Remove(chr.m_localID);
         m_characters.Remove(chr);
     }
 }
Ejemplo n.º 10
0
 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
 {
     BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP,
                                                           avCapRadius, avStandupTensor, avDensity,
                                                           avHeightFudgeFactor, avMovementDivisorWalk,
                                                           avMovementDivisorRun);
     m_characters.Add(chr);
     AddPhysicsActorTaint(chr);
     return chr;
 }
Ejemplo n.º 11
0
        public override float Simulate(float timeStep)
        {
            Locked = true;
            float steps = 0;

            lock (BulletLock)
            {
                lock (m_taintedActors)
                {
                    foreach (PhysicsActor act in m_taintedActors)
                    {
                        if (act is BulletDotNETCharacter)
                        {
                            ((BulletDotNETCharacter)act).ProcessTaints(timeStep);
                        }
                        if (act is BulletDotNETPrim)
                        {
                            ((BulletDotNETPrim)act).ProcessTaints(timeStep);
                        }
                    }
                    m_taintedActors.Clear();
                }

                lock (m_characters)
                {
                    foreach (BulletDotNETCharacter chr in m_characters)
                    {
                        chr.Move(timeStep);
                    }
                }

                lock (m_prims)
                {
                    foreach (BulletDotNETPrim prim in m_prims)
                    {
                        if (prim != null)
                        {
                            prim.Move(timeStep);
                        }
                    }
                }
                lock (m_world)
                {
                    steps = m_world.stepSimulation(timeStep, 10, WorldTimeComp);
                }

                foreach (BulletDotNETCharacter chr in m_characters)
                {
                    chr.UpdatePositionAndVelocity();
                }

                foreach (BulletDotNETPrim prm in m_activePrims)
                {
                    /*
                     * if (prm != null)
                     *  if (prm.Body != null)
                     */
                    prm.UpdatePositionAndVelocity();
                }

                /*if (m_CollisionInterface != null)
                 * {
                 *  List<BulletDotNETPrim> primsWithCollisions = new List<BulletDotNETPrim>();
                 *  List<BulletDotNETCharacter> charactersWithCollisions = new List<BulletDotNETCharacter>();
                 *
                 *  // get the collisions that happened this tick
                 *  List<BulletDotNET.ContactAddedCallbackHandler.ContactInfo> collisions = m_CollisionInterface.GetContactList();
                 *  // passed back the localID of the prim so we can associate the prim
                 *  foreach (BulletDotNET.ContactAddedCallbackHandler.ContactInfo ci in collisions)
                 *  {
                 *      // ContactPoint = { contactPoint, contactNormal, penetrationDepth }
                 *      ContactPoint contact = new ContactPoint(new Vector3(ci.pX, ci.pY, ci.pZ),
                 *                      new Vector3(ci.nX, ci.nY, ci.nZ), ci.depth);
                 *
                 *      ProcessContact(ci.contact, ci.contactWith, contact, ref primsWithCollisions, ref charactersWithCollisions);
                 *      ProcessContact(ci.contactWith, ci.contact, contact, ref primsWithCollisions, ref charactersWithCollisions);
                 *
                 *  }
                 *  m_CollisionInterface.Clear();
                 *  // for those prims and characters that had collisions cause collision events
                 *  foreach (BulletDotNETPrim bdnp in primsWithCollisions)
                 *  {
                 *      bdnp.SendCollisions();
                 *  }
                 *  foreach (BulletDotNETCharacter bdnc in charactersWithCollisions)
                 *  {
                 *      bdnc.SendCollisions();
                 *  }
                 * }*/
            }
            Locked = false;
            //No lock, as the lock that was adding to this was just removed
            if (RemoveQueue.Count > 0)
            {
                do
                {
                    if (RemoveQueue[0] != null)
                    {
                        if (RemoveQueue[0] is BulletDotNETPrim)
                        {
                            BulletDotNETPrim prim = RemoveQueue[0] as BulletDotNETPrim;
                            prim.Dispose();
                        }
                        else if (RemoveQueue[0] is BulletDotNETCharacter)
                        {
                            BulletDotNETCharacter chr = RemoveQueue[0] as BulletDotNETCharacter;
                            chr.Dispose();
                        }
                    }
                    RemoveQueue.RemoveAt(0);
                }while (RemoveQueue.Count > 0);
            }
            //No lock, as the lock that was adding to this was just removed
            if (m_waitingtaintedActors.Count != 0)
            {
                foreach (PhysicsActor actor in m_waitingtaintedActors)
                {
                    if (!m_taintedActors.Contains(actor))
                    {
                        m_taintedActors.Add(actor);
                    }
                }
            }
            return(steps);
        }