Common Module - ECNUPendulumRot/box3d-wiki GitHub Wiki
Common Module
The common module contains types, memory management, draw, world callback and vector math.
Types
Box3d defines various types such as int8, int16, uint8, uint16,etc. to make it easy to determine the size of structues.
Memeory Management
Using malloc or new to continuously apply for new memory, and then using free or delete to release it, will have a certain impact on performance. Therefore, Box3d uses b3BlockAllocator to apply for a large amount of memory at one time, and then form a linked list. When applying, it can be directly returned from the linked list. This reduces the steps of multiple application and release of memory. For details, please refer to the source file or the reference website
Draw
Box3d provides a top-level Draw class, which provides some basic graphics drawing and color definitions. Users can extend it to further customize the drawing graphics.
World Callback
World Callback allows users to customize events, such as when a collision occurs, ends, or when the solver is solving, when the solver is finished, etc. Users can create some special effects based on this.
Math
Rigid bodies need to have transforms in the world, so box3d defines three-dimensional vectors, three-dimensional matrices, and quaternions, etc., which are used to represent the translation, rotation, and speed of objects. In addition, some convenient functions are created based on this.