67 lines
1022 B
C
67 lines
1022 B
C
#ifndef UTILS_H
|
|
#define UTILS_H
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
#define CHUNK_MAX_X 16
|
|
#define CHUNK_MAX_Y 16
|
|
#define CHUNK_MAX_Z 128
|
|
|
|
/**
|
|
* GLSL-like three dimensional vector
|
|
*/
|
|
typedef struct vec3f
|
|
{
|
|
float x;
|
|
float y;
|
|
float z;
|
|
} vec3f;
|
|
|
|
typedef struct vec3i
|
|
{
|
|
int x;
|
|
int y;
|
|
int z;
|
|
} vec3i;
|
|
|
|
typedef struct vec4f
|
|
{
|
|
float x;
|
|
float y;
|
|
float z;
|
|
float w;
|
|
} vec4f;
|
|
|
|
/**
|
|
* Color with RGB components
|
|
*/
|
|
typedef struct Color
|
|
{
|
|
float red;
|
|
float green;
|
|
float blue;
|
|
} Color;
|
|
|
|
/**
|
|
* Calculates radian from degree.
|
|
*/
|
|
double degree_to_radian(double degree);
|
|
|
|
bool is_oob(int i, int min, int max);
|
|
|
|
void mult_matrix(const float m1[16], const float m2[16], float mo[16]);
|
|
|
|
bool matrix_inverse(const float m[16], float invOut[16]);
|
|
|
|
void vec3f_normalize(vec3f *v);
|
|
|
|
int irand_range(int min, int max);
|
|
|
|
float frand_range(float min, float max);
|
|
|
|
bool check_index(int x, int y, int z);
|
|
|
|
void print_vec3f(vec3f v, const char *str);
|
|
#endif /* UTILS_H */
|