I’ll be exploring the possibility of engine cleanup for the HGE. The topics include a replacement all in one module for pooling as well as module independence, utility and math library reworks.
As the engine grows, it becomes considerably more difficult to mantain. At the moment, due to almost a year of added features on the engine has created a very large codebase of almost 21k LOC, in order to ensure that the codebase can be easilly maintained and new features easilly added a rework will be required. Below I’ll be discussing possible rework modules, modules that will require a rewrite aswell as new modules.
The cleanup/rewrites are needed for preparation into 3D games, aswell as advanced rendering for the PC games.
- Modules that require a clean rewrite
- Math Library
- Collision Sub Classes
- Renderer
- Scene Manager
- Public Accessor
- Pooling
- Modules that require a cleanup
- Android Core
- PC Core
- Common Core
- GUI System
- Particle System
- New Modules
- AI Module
- Networking Module
- Threading Module
- 3D Scene Manager
- Utility support for 3D
- Save/Load Module
- Iterations
- Generic Container Optimisations
- New Generic Container (HashMap)
- New Generic Container (BST)
REWRITES
Possibly the easiest rewrite of them all, Math Library is unfortunately a mess, mainly due to poor design desisions that were made in the earlier engine development. Math Library is possibly one of the oldest modules and requires a cleanup, which will replace its Vector with more consistant Vector2 and Vector3 classes and a function cleanup of Matrix2x2, Matrix3x3, Matrix4x4 and Quaternion classes. These classes will have the added benefit of also being able to communicate with openGL for loading and saving of native openGL transform matrices for software transforms. The MathLibrary that holds static functions for math operations will also need to be rewritten. A proposal for a new name is “MathUtils” instead.
The collision system is somewhat working fine, however due to continued addition of new features the whole thing is a mess. A clean abstraction will need to be found for the Collider interface which defines ALL collidable types including Circle, AABB2, AABB3, Sphere, OBB2 and OBB3. OBB2 and OBB3 types will be required to undergo a complete rewrite, a more stable continuous collision module is also proposed to replace the old method. Finally, the Broadhphase detectors GRID and QTREE will also undergo a few changes needed to make continuous collision detection to work. A proposal for GJK is to be added for 3D and Collision module to include a reference to global object list for fast addition and removal.
The renderer will also be going for a rewrite, which will include a more advanced sprite batcher, backed by native java Buffers which will also be pooled. The overall renderer will include modules for expandability, to be able to cast shadows and provide lighting support. Proposal for Renderer to hold references to the global object list for fast addition and removal. The new renderer will support both old rendering aswell as new rendering techniques with direct shader support.
Scene Manager is plagued by inconsistency, mainly because it was expanded by demand while engine was developed. The new Scene Manager will include a dedicated 2D and 3D managers for both Android and PC and will include support for instantiating and reading/requesting from a server architecture. A new Scene Manager will be created as part of engine dedicated for hosting a server, which the engine can easilly connect to.
Public Accessor is inconsistant, and its very small, only 30 or so line of code. The current accessor “World” will be replaced by acronyms “hge” which will be used for accessing all needed subsystems of the engine, including Scene Managers, Renderers, Collision Modules and core Engine functions.
An article was written to provide the implementation idea for a new pooling solution called Bitmap Pool. This new all in one pooling is to replace three pooling solutions currently found in engine, including the Generic Pool, the Stack Pool and the Pointer Pool.
CLEANUPS
The Android core has not been touched since the first iteration of the engine was developed, it will be getting a much needed cleanup and added functionality. The core by definition will be responsible for communicating with the operating system and includes all Android specific modules, which includes the Input/Output streams aswell as the Input System.
Following the suit of the Android core, the PC core was developed later to support deployment of the PC Platform. It will share the same function interface as the Android Core and it will house all PC specific modules, which include the Input/Output streams aswell as the Input System.
Common core was developed later to bridge the gap between android and pc. It includes a simple yet powerful Graphics interface which allows openGL across both Android and PC. The cleanup will add to the existing functionality aswell as depreciate some undeeded modules/interfaces. All engine interfaces will now by definition be part of the common core, including the Android/PC core interfaces.
The GUI system will be recieving some much needed cleanup, which will include the depreciation of some un-needed functions/variables. The new GUI system will also recieve its own Camera which will make it compatible with a 3D scene. So instead of emulating its own scene space with current camera system, it will work independent of current scene as an additional 2D scene for interaction purposes. It will directly communicate with core for quick-fetching and processing of input events.
Particle System and all its utility functions/classes will recieve a cleanup which will implement the new Particle System named “State Based Particle System”. The cleanup will also include new modules for performing 3D particle effects needed for a 3D game.
NEW MODULES
The AI Module will be a attachable/detachable module which can be used with GameObjects. It will include methods for both programming AI logic externally, and automatic pathfinding. AI module will also be network aware and may make use of the new Threading Module for independent execution.
The goal of the networking module is quite simple, to provide an interface to be able to host/create multiplayer games. A proposal is to use an existing library tailored specifically at Game Development and tailor it to the engine. There are numerous good libraries available for networking.
The threading module will require extensive research to develop properly. It will be used both internally and externally for parralel execution. The interface will include easy to use function such as “merge”, “break”, “queue” and “pause/resume” of independent thread jobs. The library will make extensive use of the new Pool for creating and recycling of Thread objects.
3D scene manager will be an extention of the 2D scene manager, it will be responsible mainly for managing a 3D world.
New utility functions will be added for 3D, including 3D loaders of .OBJ and .COLLADA object formats. A utility for easy shader creation may also be explored.
The Save/Load module will provide a nice clean interface for saving and loading of game specific data in a generic manner. Options will include to append, replace exiting files aswell as direct communication with Database Systems such as SQL. Real time read/write will also be possible via the new Threading Module which will be developed as part of “new features”
ITERATIONS
- Generic Container Optimisations
All generic containers will undergo an optimisation process which will bring them up to speed with normal java containers. Generic Engine containers will also support poolable content.
- New Generic Container (HashMap)
An optimised HashMap will be added to the generic container list, which will support for collision of content aswell as fast iteration of content.
- New Generic Container (BST)
A new BST (Binary Search Tree) will also be added, which can be used with the HashMap to handle collision of data effectively.