Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- #define INLINE __inline__
- #define RESTRICT __restrict__
- #define FORCEINLINE __attribute__((always_inline))
- #define ALIGN(x) __attribute__((aligned(x)))
- typedef struct {
- float x,y,z,w;
- } ALIGN(16) vector4_t;
- ...
- #define RIGIDBODY_SIZE 64
- typedef struct {
- size_t size;
- vector4_t position[RIGIDBODY_SIZE];
- vector4_t velocity[RIGIDBODY_SIZE];
- } rigidbody_t;
- ...
- void physics_integrate(rigidbody_t *RESTRICT rigidbody) {
- // Load
- size_t index = rigidbody->size;
- vector4_t *RESTRICT positions = rigidbody->position;
- vector4_t *RESTRICT velocities = rigidbody->velocity;
- // Transform
- while(index--) {
- // Load
- vector4_t position = positions[index];
- vector4_t velocity = velocities[index];
- // Transform
- vector4_t result = vector4_add(position, velocity);
- // Store
- positions[index] = result;
- }
- // Store
- }
- ...
Advertisement
Add Comment
Please, Sign In to add comment