# Code cleanups: units map, more obvious subdirectories in engine, automatically checked dependencies, moved various units to internal

**URL:** https://forum.castle-engine.io/t/code-cleanups-units-map-more-obvious-subdirectories-in-engine-automatically-checked-dependencies-moved-various-units-to-internal/516
**Category:** News
**Created:** [February 5, 2022, 4:05pm UTC](https://forum.castle-engine.io/t/code-cleanups-units-map-more-obvious-subdirectories-in-engine-automatically-checked-dependencies-moved-various-units-to-internal/516 "2022-02-05T16:05:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [February 5, 2022, 4:05pm UTC](https://forum.castle-engine.io/t/code-cleanups-units-map-more-obvious-subdirectories-in-engine-automatically-checked-dependencies-moved-various-units-to-internal/516/1 "2022-02-05T16:05:03Z")

</div>

| [![Dungeon map in Tiled rendered using Castle Game Engine](https://castle-engine.io/wp/wp-content/uploads/2022/02/Zrzut-ekranu-z-2022-02-04-19-24-29-200x118.png)](https://castle-engine.io/wp/wp-content/uploads/2022/02/Zrzut-ekranu-z-2022-02-04-19-24-29.png "Dungeon map in Tiled rendered using Castle Game Engine") |

Lately I’ve done a number of rearrangements in CGE units, to make the engine code cleaner (easier to understand, both for new people and seasoned devs):

1. [Units map](https://castle-engine.io/units_map) documentation is now up-to-date and more straightforward. 

2. Unit dependencies outlined in [units map](https://castle-engine.io/units_map) are (again) automatically checked by [check\_units\_dependencies internal tool](https://github.com/castle-engine/castle-engine/tree/master/tools/internal/check_units_dependencies) (using `ppudump` from FPC underneath).

3. A lot of obscure/internal units have been renamed to `CastleInternalXxx` or marked as deprecated. We’re not finished with this cleanup yet, see [more potential units that can become internal](https://trello.com/c/4w4soULz/115-various-cge-units-should-be-deprecated-or-just-renamed-to-castleinternalxxx-without-a-deprecated-bridge-if-really-low-actual-usa). But our [list of units](https://castle-engine.io/apidoc-unstable/html/AllUnits.html) is already much shorter, making CGE API smaller so simpler to learn.

4. Subdirectory `src/3d` is now [src/transform](https://github.com/castle-engine/castle-engine/tree/master/src/transform). It contains `TCastleTransform` and friends, and is suitable for both 2D and 3D.

5. Subdirectory `src/x3d` is now [src/scene](https://github.com/castle-engine/castle-engine/tree/master/src/scene). It contains `TCastleScene` and friends (like `TCastleViewport`). I moved the 2 big units that define X3D fields and nodes to a subdirectory `src/scene/x3d`. The code loading particular [model formats](https://castle-engine.io/creating_data_model_formats.php) is now in `src/scene/load`, and some formats even get their own subdirectory, like `src/scene/load/spine`.

6. I added subdirectory [src/base\_rendering](https://github.com/castle-engine/castle-engine/tree/master/src/base_rendering), that contains some base OpenGL units (and will contain in the future alternative subdirectories for OpenGL, Vulkan etc.). 

7. We no longer use `opengl` subdirectories inside various other CGE directories. Things from `base/opengl/`, `images/opengl/` mostly move to `base_rendering`. Things from `scene/opengl/`, `ui/opengl/` mostly move to parent dir, i.e. just `scene`, `ui`.

8. A few usages of `is nested` were cleaned — as it is not supported by Delphi. We previously tried to use “is nested” on FPC and anonymous methods on Delphi, but this resulted in a code complicated with `ifdef`s. It’s better to stick to a common subset of FPC and Delphi for now, which means — no “is nested”, no anonymous methods. (Of course you’re free to use them in your own projects, if you only care about using one of these compilers.)

P.S. I don’t really have any relevant screenshot to go with this post. So enjoy a screenshot with a [sample Tiled dungeon map from here](https://github.com/stefanbeller/tiled_examples), rendered of course using our [examples/tiled/map\_viewer](https://github.com/castle-engine/castle-engine/tree/master/examples/tiled/map_viewer) 🙂
