public bool AddOccupied(IMeshedObject simObject, float minZ, float maxZ)
        {
            float x = _LocalPos.X,
                  y = _LocalPos.Y;
            //float GroundLevel = GetGroundLevel();
            // if (simObject.OuterBox.MaxZ < GetGroundLevel())
            // {
            //    return false;
            //}
            List <CollisionObject> meshes = ShadowList;

            lock (meshes)
                if (!meshes.Contains(simObject))
                {
                    meshes.Add(simObject);
                    OccupiedCount++;
                    if (simObject.IsSolid)
                    {
                        IsSolid++;
#if USE_MINIAABB
                        IEnumerable <Box3Fill> mini = simObject.InnerBoxes;
                        lock (mini) foreach (var o in mini)
                            {
                                if (o.IsInsideXY(x, y))
                                {
                                    lock (InnerBoxes)
                                    {
                                        InnerBoxesSimplified = false;
                                        InnerBoxes.Add(o);
                                    }
                                }
                            }
#endif
#if COLLIDER_TRIANGLE
                        IEnumerable <CollisionObject> mini = simObject.triangles;
                        foreach (var o in mini)
                        {
                            if (o.IsInsideXY(_LocalPos.X, _LocalPos.Y))
                            {
                                InnerBoxes.Add(o);
                            }
                        }
#endif
                    }
                    TaintMatrix();
                    return(true);
                }
            return(false);
        }
Пример #2
0
        public bool AddOccupied(IMeshedObject simObject, float minZ, float maxZ)
        {
            float x = _LocalPos.X,
                  y = _LocalPos.Y;
            //float GroundLevel = GetGroundLevel();
            // if (simObject.OuterBox.MaxZ < GetGroundLevel())
            // {
            //    return false;
            //}
            List<CollisionObject> meshes = ShadowList;
            lock (meshes)
                if (!meshes.Contains(simObject))
                {
                    meshes.Add(simObject);
                    OccupiedCount++;
                    if (simObject.IsSolid)
                    {
                        IsSolid++;
#if USE_MINIAABB
                        IEnumerable<Box3Fill> mini = simObject.InnerBoxes;
                        lock (mini) foreach (var o in mini)
                        {
                            if (o.IsInsideXY(x, y))
                                lock (InnerBoxes)
                                {
                                    InnerBoxesSimplified = false;
                                    InnerBoxes.Add(o);
                                }
                        }
#endif
#if COLLIDER_TRIANGLE
                        IEnumerable<CollisionObject> mini = simObject.triangles;
                        foreach (var o in mini)
                        {
                            if (o.IsInsideXY(_LocalPos.X, _LocalPos.Y))
                                InnerBoxes.Add(o);
                        }
#endif
                    }
                    TaintMatrix();
                    return true;
                }
            return false;
        }
Пример #3
0
        //static IList<ISimObject> NOOBJECTS = new List<ISimObject>();
        //private IEnumerable<ISimObject> ObjectsAt(float x, float y)
        //{
        //    x = RangeCheck(x); y = RangeCheck(y);
        //    ///Debug("SetBlocked: {0} {1}", x, y);
        //    int ix = ARRAY_IDX(x);
        //    int iy = ARRAY_IDX(y);
        //    CollisionIndex P = mWaypoints[ix, iy];
        //    if (P == null)
        //    {
        //        return NOOBJECTS;
        //    }
        //    return P.OccupiedListObject;
        //}



        public void SetBlocked(float x, float y, float z, IMeshedObject blocker)
        {
            if (blocker != null) SetObjectAt(x, y, blocker,z,z);
            int ix = ARRAY_X(x);
            int iy = ARRAY_Y(y);
            foreach (CollisionPlane CP in CollisionPlanesFor(z))
            {
                byte[,] ByteMatrix = CP.ByteMatrix;
                ///Debug("SetBlocked: {0} {1}", x, y);
                // if was set Passable dont re-block
                if (ByteMatrix[ix, iy] == STICKY_PASSABLE)
                {
                    ByteMatrix[ix, iy] = MAYBE_BLOCKED;
                    return;
                }
                ByteMatrix[ix, iy] = BLOCKED;
            }
            //   SetBubbleBlock(ix, iy, blocker);
        }
Пример #4
0
 public bool AddCollisions(IMeshedObject MO)
 {
     return MO.UpdateOccupied(this);
 }
Пример #5
0
        public CollisionIndex SetObjectAt(float x, float y, IMeshedObject simObject, float minZ, float maxZ)
        {
            int ix = ARRAY_X((x));
            int iy = ARRAY_Y((y));

            CollisionIndex W = GetCollisionIndex(ix, iy);
            if (W.AddOccupied(simObject,minZ, maxZ))
            {
               // NeedsUpdate = true;
            }
            return W;
        }