mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
Project structure update
This commit is contained in:
parent
d67c707916
commit
7730da0056
19 changed files with 58 additions and 62 deletions
43
src/maths/voxmaths.h
Normal file
43
src/maths/voxmaths.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef SRC_VOXNATHS_H_
|
||||
#define SRC_VOXNATHS_H_
|
||||
|
||||
#include "../typedefs.h"
|
||||
|
||||
inline int floordiv(int a, int b) {
|
||||
if (a < 0 && a % b) {
|
||||
return (a / b) - 1;
|
||||
}
|
||||
return a / b;
|
||||
}
|
||||
|
||||
inline int ceildiv(int a, int b) {
|
||||
if (a > 0 && a % b) {
|
||||
return a / b + 1;
|
||||
}
|
||||
return a / b;
|
||||
}
|
||||
|
||||
inline int max(int a, int b) {
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
inline int min(int a, int b) {
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
static unsigned int g_seed;
|
||||
|
||||
inline void fast_srand(int seed) {
|
||||
g_seed = seed;
|
||||
}
|
||||
|
||||
inline int fast_rand(void) {
|
||||
g_seed = (214013 * g_seed + 2531011);
|
||||
return (g_seed >> 16) & 0x7FFF;
|
||||
}
|
||||
|
||||
inline light_t light_pack(ubyte r, ubyte g, ubyte b, ubyte s) {
|
||||
return r | (g << 4) | (b << 8) | (s << 12);
|
||||
}
|
||||
|
||||
#endif // SRC_VOXNATHS_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue