Exemple #1
0
        private WallData *NearestWallTest(SceneData *map, out float nearest_dist, out float nearest_hratio)
        {
            nearest_dist   = float.PositiveInfinity;
            nearest_hratio = 2f;
            WallData * nearest = null;
            WallData **pptr    = map->walls;

            while (*pptr != null)
            {
                //Medium performance impact.
                GetCollisionData(*pptr, out float cur_dist, out float cur_split);
                if (cur_dist < nearest_dist)
                {
                    nearest_hratio = cur_split;
                    nearest_dist   = cur_dist;
                    nearest        = *pptr;
                }
                pptr++;
            }
            return(nearest);
        }
Exemple #2
0
        internal WallData *NearestWall(SceneData *map, out float nearest_dist, out float nearest_ratio)
        {
            nearest_dist  = float.PositiveInfinity;
            nearest_ratio = 2f;
            int        wallcount = map->wall_count;
            WallData **cur       = map->walls;
            WallData * nearest   = null;

            for (int i = 0; i < wallcount; i++)
            {
                //walls cannot be null.
                GetCollisionData(*cur, out float cur_dist, out float cur_ratio);
                if (cur_dist < nearest_dist)
                {
                    nearest_ratio = cur_ratio;
                    nearest_dist  = cur_dist;
                    nearest       = *cur;
                }
                cur++;
            }
            return(nearest);
        }