Пример #1
0
		public static RelativePosition3F FromBlock(IMyCubeBlock block, Vector3 blockPosition)
		{
			RelativePosition3F result = new RelativePosition3F(block.CubeGrid);
			result.position_block = blockPosition;
			result.CubeBlock = block;
			return result;
		}
        public static RelativePosition3F FromLocal(IMyCubeGrid grid, Vector3 localPosition)
        {
            RelativePosition3F result = new RelativePosition3F(grid);

            result.position_local = localPosition;
            return(result);
        }
        public static RelativePosition3F FromWorld(IMyCubeGrid grid, Vector3 worldPosition)
        {
            RelativePosition3F result = new RelativePosition3F(grid);

            result.position_world = worldPosition;
            return(result);
        }
        public static RelativePosition3F FromBlock(IMyCubeBlock block, Vector3 blockPosition)
        {
            RelativePosition3F result = new RelativePosition3F(block.CubeGrid);

            result.position_block = blockPosition;
            result.CubeBlock      = block;
            return(result);
        }
Пример #5
0
        public void Init(IMyCubeGrid grid, RelativePosition3F destination, Vector3 navBlockLocalPosition, bool landing)
        {
            if (grid != m_grid)
            {
                this.m_grid      = grid;
                this.m_logger    = new Logger(() => m_grid.DisplayName);
                this.m_cellCache = GridCellCache.GetCellCache(grid);
            }

            m_directNorm = Vector3.Normalize(destination.ToLocal() - navBlockLocalPosition);
            m_landing    = landing;
            Vector3 centreDestination = destination.ToLocal() + Centre - navBlockLocalPosition;

            rejectAll();
            createCapsule(centreDestination, navBlockLocalPosition);
        }
Пример #6
0
        /// <param name="centreDestination">where the centre of the grid will end up (local)</param>
        private void createCapsule(Vector3 centreDestination, Vector3 localPosition)
        {
            float longestDistanceSquared = 0;

            using (m_lock_rejcectionCells.AcquireSharedUsing())
                foreach (Vector3 rejection in m_rejectionCells)
                {
                    float distanceSquared = (rejection - m_centreRejection).LengthSquared();
                    if (distanceSquared > longestDistanceSquared)
                    {
                        longestDistanceSquared = distanceSquared;
                    }
                }
            Vector3 P0 = RelativePosition3F.FromLocal(m_grid, Centre).ToWorld();

            //Vector3D P1;
            //if (m_landing)
            //{
            Vector3 P1 = RelativePosition3F.FromLocal(m_grid, centreDestination).ToWorld();
            //}
            //else
            //{
            //	//// extend capsule past destination by distance between remote and front of grid
            //	//Ray navTowardsDest = new Ray(localPosition, m_directNorm);
            //	//float tMin, tMax;
            //	//m_grid.LocalVolume.IntersectRaySphere(navTowardsDest, out tMin, out tMax);
            //	//P1 = RelativeVector3F.createFromLocal(centreDestination + tMax * m_directNorm, m_grid).getWorldAbsolute();

            //	// extend capsule by length of grid
            //	P1 = RelativePosition3F.FromLocal(m_grid, centreDestination + m_directNorm * m_grid.GetLongestDim()).ToWorld();
            //}

            float CapsuleRadius = (float)Math.Sqrt(longestDistanceSquared) + 3f * m_grid.GridSize;            // +(m_landing ? 0f : NotLandingBuffer);

            Path = new Capsule(P0, P1, CapsuleRadius);

            m_logger.debugLog("Path capsule created from " + P0 + " to " + P1 + ", radius: " + CapsuleRadius);
        }
Пример #7
0
        public void Init(IMyCubeGrid grid, RelativePosition3F destination, Vector3 navBlockLocalPosition, bool landing)
        {
            if (grid != m_grid)
            {
                this.m_grid = grid;
                this.m_logger = new Logger("GridShapeProfiler", () => m_grid.DisplayName);
                this.m_cellCache = GridCellCache.GetCellCache(grid);
            }

            m_directNorm = Vector3.Normalize(destination.ToLocal() - navBlockLocalPosition);
            m_landing = landing;
            Vector3 centreDestination = destination.ToLocal() + Centre - navBlockLocalPosition;
            rejectAll();
            createCapsule(centreDestination, navBlockLocalPosition);
        }
Пример #8
0
		public static RelativePosition3F FromLocal(IMyCubeGrid grid, Vector3 localPosition)
		{
			RelativePosition3F result = new RelativePosition3F(grid);
			result.position_local = localPosition;
			return result;
		}
Пример #9
0
		public static RelativePosition3F FromWorld(IMyCubeGrid grid, Vector3 worldPosition)
		{
			RelativePosition3F result = new RelativePosition3F(grid);
			result.position_world = worldPosition;
			return result;
		}