Repository navigation
LocalLock
As it would be clumsy to use colliders to determine wether or not an element has enough free space to be included in the scene (it would need to instantiate/dispose colliders) , the LocalLock concept is used.
Upon construction, an array of array of number (Array<Array>) is added as _locallocks private property on a GameObject. The values of _locallocks are taken from the LocalLocks class which hardcodes the values for all references.
_locallocks contains the coordinates (an Array) of the voxels that the GameObject would occupy on the scene. The coordinates are relative to the GameObject origin.
Thus, it's possible to compute _worldlock by applying the GameObject transform to the _locallocks to get the world coordinates of the voxels the GameObjec would occupy on the scene.
Keeping track of a _worldlocks collection, and checking them during GameObject initialization, makes it possible to avoid GameObject intersection.
During construction, the GameObject will go through the following steps.
- Set _ref (reference) and _rot (rotation) from the constructor arguments.
- Set _localLocks from LocalLocks list.
- Compute _worldLocks.
- Check for availabilty in GameObject.WorldLocks for all _worldlocks.
- If available, keep initializing, abort otherwise.
- Once initialized, take all _worldLocks (by adding them to GameObject.WorldLocks)
During disposal, release taken _worldLocks (by splicing them from GameObject.WorldLocks)