private void PerformMovesY(Entity entity)
        {
            Vec3F position  = entity.Position.Current;
            Vec3F velocityY = entity.Velocity.WithXZ(0, 0);
            Box3F box       = entity.Box;

            int   numMoves  = CalculateStepsY(velocityY, entity.HalfHeight);
            Vec3F stepDelta = velocityY / numMoves;

            for (int movesLeft = numMoves; movesLeft > 0; movesLeft--)
            {
                if (stepDelta == Vec3F.Zero)
                {
                    break;
                }

                Vec3F nextPosition = position + stepDelta;
                Box3F nextBox      = box + stepDelta;

                if (CanMoveTo(entity, nextPosition, nextBox, out CollisionData collisions))
                {
                    MoveTo(entity, nextPosition, collisions);
                    position = nextPosition;
                    box      = nextBox;
                    continue;
                }

                SetToVerticalCollidedElementY(entity, position, collisions);
                ClearVelocityY(entity);
                break;
            }
        }
Exemple #2
0
 /// <summary>Rebuild the tiles overlapped by the input box.</summary>
 public void BuildTiles(Box3F box)
 {
     box.Alloc();             InternalUnsafeMethods.BuildTiles__Args _args = new InternalUnsafeMethods.BuildTiles__Args()
     {
         box = box.internalStructPtr,
     };
     InternalUnsafeMethods.BuildTiles()(ObjectPtr, _args);
     box.Free();
 }
Exemple #3
0
        Box3F GetBoundingBox()
        {
            var minx = 1E+08f;
            var miny = 1E+08f;
            var minz = 1E+08f;
            var maxx = -1E+08f;
            var maxy = -1E+08f;
            var maxz = -1E+08f;

            foreach (var poly in polygons)
            {
                foreach (var v in poly.Vertices)
                {
                    if (v.X > maxx)
                    {
                        maxx = v.X;
                    }
                    if (v.Y > maxy)
                    {
                        maxy = v.Y;
                    }
                    if (v.Z > maxz)
                    {
                        maxz = v.Z;
                    }

                    if (v.X < minx)
                    {
                        minx = v.X;
                    }
                    if (v.Y < miny)
                    {
                        miny = v.Y;
                    }
                    if (v.Z < minz)
                    {
                        minz = v.Z;
                    }
                }
            }

            var box = new Box3F();

            box.min = new Vector3(minx, miny, minz);
            box.max = new Vector3(maxx, maxy, maxz);

            return(box);
        }
        /// <summary>
        /// Takes care of all of the horizontal movement for the entity. This
        /// may adjust the Y value if there are steps or slopes however.
        /// </summary>
        /// <param name="entity">The entity to move.</param>
        private void PerformMovesXZ(Entity entity)
        {
            int   slidesLeft = MaxSlides;
            Vec3F position   = entity.Position.Current;
            Vec3F velocityXZ = entity.Velocity.WithY(0);
            Box3F box        = entity.Box;

            // We advance in small steps that are smaller than the radius of
            // the actor so we don't skip over any lines or things due to fast
            // entity speed.
            int   numMoves  = CalculateStepsXZ(velocityXZ, entity.Radius);
            Vec3F stepDelta = velocityXZ / numMoves;

            for (int movesLeft = numMoves; movesLeft > 0; movesLeft--)
            {
                if (stepDelta == Vec3F.Zero)
                {
                    break;
                }

                Vec3F nextPosition = position + stepDelta;
                Box3F nextBox      = box + stepDelta;

                if (CanMoveTo(entity, nextPosition, nextBox, out CollisionData collisions))
                {
                    MoveTo(entity, nextPosition, collisions);
                    position = nextPosition;
                    box      = nextBox;
                    continue;
                }

                if (slidesLeft > 0 && entity.Flags.Slides)
                {
                    HandleSlideXZ(entity, collisions, ref position, ref box, ref stepDelta, ref movesLeft);
                    slidesLeft--;
                    continue;
                }

                ClearVelocityXZ(entity);
                break;
            }
        }
Exemple #5
0
 public void buildTiles(Box3F box)
 {
     pInvokes.m_ts.fnNavMesh_buildTiles(_ID, box.AsString());
 }
Exemple #6
0
 public virtual void buildTiles(Box3F box)
 {
     InternalUnsafeMethods.buildTiles(ObjectPtr, box.ToStruct());
 }