Exemple #1
0
        public CollisionEventUpdate Copy()
        {
            CollisionEventUpdate c = new CollisionEventUpdate();

            lock (m_objCollisionList)
            {
                foreach (KeyValuePair <uint, ContactPoint> kvp in m_objCollisionList)
                {
                    c.m_objCollisionList.Add(kvp.Key, kvp.Value);
                }
            }
            return(c);
        }
        // Send the collected collisions into the simulator.
        // Called at taint time from within the Step() function thus no locking problems
        //      with CollisionCollection and ObjectsWithNoMoreCollisions.
        // Return 'true' if there were some actual collisions passed up
        public override bool SendCollisions()
        {
            bool ret = true;

            // If the 'no collision' call, force it to happen right now so quick collision_end
            bool force = (CollisionCollection.Count == 0 && CollisionsLastTick.Count != 0);

            // throttle the collisions to the number of milliseconds specified in the subscription
            if (force || (PhysicsScene.SimulationNowTime >= NextCollisionOkTime))
            {
            NextCollisionOkTime = PhysicsScene.SimulationNowTime + SubscribedEventsMs;

            // We are called if we previously had collisions. If there are no collisions
            //   this time, send up one last empty event so OpenSim can sense collision end.
            if (CollisionCollection.Count == 0)
            {
                // If I have no collisions this time, remove me from the list of objects with collisions.
                ret = false;
            }

            DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count);
            base.SendCollisionUpdate(CollisionCollection);

            // Remember the collisions from this tick for some collision specific processing.
            CollisionsLastTick = CollisionCollection;

            // The CollisionCollection instance is passed around in the simulator.
            // Make sure we don't have a handle to that one and that a new one is used for next time.
            //    This fixes an interesting 'gotcha'. If we call CollisionCollection.Clear() here,
            //    a race condition is created for the other users of this instance.
            CollisionCollection = new CollisionEventUpdate();
            }
            return ret;
        }
        protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName)
        {
            PhysicsScene = parentScene;
            LocalID = localID;
            PhysObjectName = name;
            Name = name;    // PhysicsActor also has the name of the object. Someday consolidate.
            TypeName = typeName;

            // The collection of things that push me around
            PhysicalActors = new BSActorCollection(PhysicsScene);

            // Initialize variables kept in base.
            GravityMultiplier = 1.0f;
            Gravity = new OMV.Vector3(0f, 0f, BSParam.Gravity);
            //HoverActive = false;

            // We don't have any physical representation yet.
            PhysBody = new BulletBody(localID);
            PhysShape = new BulletShape();

            PrimAssetState = PrimAssetCondition.Unknown;

            // Default material type. Also sets Friction, Restitution and Density.
            SetMaterial((int)MaterialAttributes.Material.Wood);

            CollisionCollection = new CollisionEventUpdate();
            CollisionsLastTick = CollisionCollection;
            SubscribedEventsMs = 0;
            CollidingStep = 0;
            TrueCollidingStep = 0;
            CollisionAccumulation = 0;
            ColliderIsMoving = false;
            CollisionScore = 0;

            // All axis free.
            LockedAxis = LockedAxisFree;
        }
 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
 {
     if (base.SubscribedToCollisions() && SubscribedEvents())
         //If we don't have anything that we are going to trigger, don't even add
     {
         if (CollisionEventsThisFrame == null)
             CollisionEventsThisFrame = new CollisionEventUpdate();
         CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
     }
 }
 public override bool SendCollisions()
 {
     if (CollisionEventsThisFrame == null || m_frozen) //No collisions or frozen, don't mess with it
         return false;
     base.SendCollisionUpdate(CollisionEventsThisFrame.Copy());
     CollisionEventsThisFrame = CollisionEventsThisFrame.Count == 0 ? null : new CollisionEventUpdate();
     return true;
 }
 public CollisionEventUpdate Copy()
 {
     CollisionEventUpdate c = new CollisionEventUpdate();
     lock (m_objCollisionList)
     {
         foreach (KeyValuePair<uint, ContactPoint> kvp in m_objCollisionList)
             c.m_objCollisionList.Add(kvp.Key, kvp.Value);
     }
     return c;
 }