Teikitu Gaming System
Common (Shared)
Coding Standards (type and variable nomenclature)
Toggle further information
(1) Type Definitions
For the sake of brevity I created a simple naming convention (similar to Hungarian notation) to represent the most common collection of used modified types. This allows for a more succinct representation when writing code. For example [const float * __restrict const] becomes [PCU_TgFLOAT32]. The brevity makes the interface and code easier to understand once the nomenclature is understood.
C_TYPE |
const TYPE |
PC_TYPE |
TYPE * const |
PU_TYPE |
TYPE * __restrict |
CPC_TYPE |
const TYPE * const |
CPU_TYPE |
const TYPE * __restrict |
P_TYPE |
TYPE * |
PCU_TYPE |
TYPE * const __restrict |
CP_TYPE |
const TYPE * |
CPCU_TYPE |
const TYPE * const __restrict |
PP_TYPE |
TYPE ** |
|
P: Pointer, C: Const, U: Restrict, R: Reference - Prefix is in order. Thus, for instance, CR•(VECTOR) is just a const reference template vector.
(2) File Conventions:
See Information for more details on the choice of language. Since I am using straight C I wanted a method to define the same interface and in some cases implementation for different combinations of variable types. In C++ this was done using template and template specialization. The method I used was to create a file convention for header, inline and sources files that would be included multiple times in the compilation with different pre-processor macro definitions. The macros are used for name mangling so that the functions can be generated for each of the types required. It is important that code itself is never written through macros as it is too troublesome when debugging. Since the code is only name mangled and included into the regular compilation this problem does not manifest.
(3) Geometry Nomenclature:
Each primitive type is assigned a simple two letter short form. The exception are points/vectors which sometimes has more definitions based on usage (point vs directions).
tyT#: Parametric Value
tvS#: Point
tvD#: Direction
tgPC#: Particle
tgLN#: Line |
tgRY#: Ray
tgSG#: Segment
tgCI#: Circle
tgDK#: Disk
tgEL#: Ellipse |
tgPM#: Parallelogram
tgPN#: Plane
tgRT#: Rectangle
tgPT#: Point Triangle
tgET#: Edge Triangle |
tgCT#: Collision Triangle
tgST#: Space Triangle
tgBA#: Box, Axis Aligned
tgBX#: Box
tgCA#: Capsule |
tgCY#: Cylinder
tgMH#: Mesh
tgSP#: Sphere
tgTR#: Torus
tgTU#: Tube |
|
A point triangle is one described using only the three vertices and a normal to the plane. An edge triangle adds a clockwise edge definition. A collision triangle augments an edge triangle with feature reduction information (for instance if a particular edge should be considered during collision). Finally, a space triangle adds edge plane definition to a collision triangle.
(1) Type Definitions
For the sake of brevity I created a simple naming convention (similar to Hungarian notation) to represent the most common collection of used modified types. This allows for a more succinct representation when writing code. For example [const float * __restrict const] becomes [PCU_TgFLOAT32]. The brevity makes the interface and code easier to understand once the nomenclature is understood.
C_TYPE |
const TYPE |
PC_TYPE |
TYPE * const |
PU_TYPE |
TYPE * __restrict |
CPC_TYPE |
const TYPE * const |
CPU_TYPE |
const TYPE * __restrict |
P_TYPE |
TYPE * |
PCU_TYPE |
TYPE * const __restrict |
CP_TYPE |
const TYPE * |
CPCU_TYPE |
const TYPE * const __restrict |
PP_TYPE |
TYPE ** |
|
P: Pointer, C: Const, U: Restrict, R: Reference - Prefix is in order. Thus, for instance, CR•(VECTOR) is just a const reference template vector.
(2) File Conventions:
See Information for more details on the choice of language. Since I am using straight C I wanted a method to define the same interface and in some cases implementation for different combinations of variable types. In C++ this was done using template and template specialization. The method I used was to create a file convention for header, inline and sources files that would be included multiple times in the compilation with different pre-processor macro definitions. The macros are used for name mangling so that the functions can be generated for each of the types required. It is important that code itself is never written through macros as it is too troublesome when debugging. Since the code is only name mangled and included into the regular compilation this problem does not manifest.
(3) Geometry Nomenclature:
Each primitive type is assigned a simple two letter short form. The exception are points/vectors which sometimes has more definitions based on usage (point vs directions).
tyT#: Parametric Value
tvS#: Point
tvD#: Direction
tgPC#: Particle
tgLN#: Line |
tgRY#: Ray
tgSG#: Segment
tgCI#: Circle
tgDK#: Disk
tgEL#: Ellipse |
tgPM#: Parallelogram
tgPN#: Plane
tgRT#: Rectangle
tgPT#: Point Triangle
tgET#: Edge Triangle |
tgCT#: Collision Triangle
tgST#: Space Triangle
tgBA#: Box, Axis Aligned
tgBX#: Box
tgCA#: Capsule |
tgCY#: Cylinder
tgMH#: Mesh
tgSP#: Sphere
tgTR#: Torus
tgTU#: Tube |
|
A point triangle is one described using only the three vertices and a normal to the plane. An edge triangle adds a clockwise edge definition. A collision triangle augments an edge triangle with feature reduction information (for instance if a particular edge should be considered during collision). Finally, a space triangle adds edge plane definition to a collision triangle.