示例#1
0
        public void OnRenderObject(NavmeshBuild build, TileSelection selection)
        {
            if (!build)
            {
                return;
            }

            TileSetDefinition tdef = build.TileSetDefinition;

            if (!mShow || !mEnabled || build != selection.Build || tdef == null)
            {
                return;
            }

            Color color = ControlUtil.SelectionColor;

            DebugDraw.SimpleMaterial.SetPass(0);

            GL.Begin(GL.LINES);

            GL.Color(color);

            if (selection.Validate())
            {
                Vector3 bmin;
                Vector3 bmax;
                Vector3 trash;

                TileZone zone = selection.Zone;

                tdef.GetTileBounds(zone.xmin, zone.zmin, true, out bmin, out trash);
                tdef.GetTileBounds(zone.xmax, zone.zmax, true, out trash, out bmax);

                DebugDraw.AppendBounds(bmin, bmax);

                if (mIncludeRootTile)
                {
                    GL.Color(new Color(0.93f, 0.58f, 0.11f)); // Orange

                    tdef.GetTileBounds(selection.SelectedX, selection.SelectedZ, true
                                       , out bmin, out bmax);

                    DebugDraw.AppendBounds(bmin, bmax);
                }
            }
            else
            {
                Vector3 bmax     = tdef.BoundsMin;
                float   tileSize = build.Config.TileWorldSize;
                bmax.x += tileSize * tdef.Width;
                bmax.y  = tdef.BoundsMax.y;
                bmax.z += tileSize * tdef.Depth;

                DebugDraw.AppendBounds(tdef.BoundsMin, bmax);
            }

            GL.End();
        }