altEngine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Macros | Functions | Variables
common.cpp File Reference
#include "include.h"
#include "common.h"
#include "junzip.h"
#include "md5sum.h"
#include "stb_image.h"
#include <stdarg.h>
#include <math.h>
Include dependency graph for common.cpp:

Macros

#define STB_IMAGE_IMPLEMENTATION
 
#define DMESG_SIZE   2048
 

Functions

float newtonSqrt (float x)
 
void md5sum (char *data, int size, char *hash)
 
bool aabb_visible (vec3 &min, vec3 &max, matrix4 &mvp)
 
bool RayTriangleMT (vec3 &origin, vec3 &dir, vec3 &a, vec3 &b, vec3 &c, float &t, float &u, float &v)
 
bool RaySphere (vec3 &origin, vec3 &dir, vec3 &sphere, float radius, float &t)
 
bool RayPlane (vec3 &origin, vec3 &dir, vec3 &normal, float d, vec3 &point)
 
bool RayBoxSlab (vec3 &origin, vec3 &dir, vec3 &min, vec3 &max, float &distance)
 
void quadratic_bezier_curve (vec3 &a, vec3 &b, vec3 &c, float time, vec3 &out)
 
void cubic_bezier_curve (vec3 &a, vec3 &b, vec3 &c, vec3 &d, float time, vec3 &out)
 
void bicubic_bezier_surface (vec3 *control, float time_x, float time_y, vec3 &out)
 
void quadratic_bezier_surface (vec3 *control, float time_x, float time_y, vec3 &out)
 
void tessellate_quadratic_bezier_surface (vec3 *control, vertex_t *&vertex, int *&index, int &num_vertex, int &num_index, float level)
 
int debugf (const char *format,...)
 
char * get_file (char *filename, int *size)
 
int write_file (char *filename, const char *bytes, int size)
 
int processFile (JZFile *zip, userdata_t *user)
 
int recordCallback (JZFile *zip, int idx, JZFileHeader *header, char *filename, void *user_data)
 
int listCallback (JZFile *zip, int idx, JZFileHeader *header, char *filename, void *filelist)
 
int get_zipfile (char *zipfile, char *file, unsigned char **data, int *size)
 
int list_zipfile (char *zipfile, char *filelist)
 
void newlinelist (char *filename, char **list, unsigned int &num, char **file)
 
int load_texture_pk3 (Graphics &gfx, char *file_name, char **pk3_list, int num_pk3, bool clamp, bool bgr, int anisotropic)
 
int load_texture (Graphics &gfx, char *file_name, bool clamp, bool bgr, int anisotropic)
 
void calc_hash (char *filename, char *hash)
 
bytetga_24to32 (int width, int height, byte *pBits, bool bgr)
 
void navdata_to_graph (ref_t *&ref, graph_node_t *&node, vector< Entity * > &entity_list, int start)
 
void print_graph (graph_node_t *node, int num_node)
 
void print_path (int *path, int path_length, graph_node_t *node)
 
float rand_float (float fMin, float fAdd)
 
unsigned int crc32_byte (unsigned int r)
 
void crc32 (const void *data, unsigned int n_bytes, unsigned int *crc)
 
int spiral (float distance, vec3 &scale, float step, vec3 *point)
 
int gen_spiral (Graphics &gfx, unsigned int &ibo, unsigned int &vbo)
 
int lightning (float distance, vec3 &scale, float step, vec3 *point)
 
int gen_lightning (Graphics &gfx, unsigned int &ibo, unsigned int &vbo)
 
int trim (char *data, int length)
 
void delta_compress (char *output, char *input, char *delta, int size)
 
void delta_uncompress (char *output, char *input, char *delta, int size)
 
void runlength_encode (uint8_t *output, rletable_t *table, int *table_size, uint8_t *input, unsigned int *size)
 
void runlength_decode (uint8_t *output, rletable_t *table, uint8_t *input, unsigned int *size)
 
float GetLuminance (vec3 &v)
 
vec3 ColorToVector (const pixel_t &color)
 
pixel_t VectorToColor (vec3 &v)
 
void gen_normalmap (float scale, const pixel_t *pixel, pixel_t *pixelout, int width, int height)
 
void write_bitmap (char *filename, int width, int height, int *data)
 
void ping_time_start (int sequence)
 
double ping_time_end (int sequence)
 
float clamp (float value, float min, float max)
 
int clamp (int value, int min, int max)
 
void get_cpu_info (struct cpuinfo *info)
 
void show_hw_info ()
 
void pid_controller (const vec3 &target, const float timestep, const vec3 &pos, vec3 &thrust, const float kd)
 
void init_pid (pid_state_t *pid)
 
void update_pid (pid_state_t *pid, const vec3 &target, const vec3 &position, vec3 &output)
 
void bezier_curve (float t, vec3 &p, const vec3 &p0, const vec3 &p1, const vec3 &p2, const vec3 &p3)
 
void polyline (vec3 *point, int num_point, float t, vec3 &p)
 
float random_float ()
 
int auto_complete (const char *a, const char *b)
 
int getFarthestInDir (const vec3 *shape, const vec3 &v, const int num_vert)
 
void support (const vec3 *shape1, const vec3 *shape2, const vec3 &v, vec3 &point, const int num_vert_one, const int num_vert_two)
 
void pick_line (const vec3 &v, const vec3 *shape1, const vec3 *shape2, vec3 &a, vec3 &b, const int num_vert_one, const int num_vert_two)
 
void pick_triangle (vec3 &a, vec3 &b, vec3 &c, int &flag, const vec3 *shape1, const vec3 *shape2, const int iteration_allowed, const int num_vert_one, const int num_vert_two)
 
void pick_tetrahedron (vec3 &a, vec3 &b, vec3 &c, int &flag, const vec3 *shape1, const vec3 *shape2, const int iteration_allowed, const int num_vert_one, const int num_vert_two)
 
int gjk (const vec3 *shape1, const vec3 *shape2, const int iterations, const int num_vert_one, const int num_vert_two)
 
void GetInterval (const vec3 *object, const vec3 &axis, float &minv, float &maxv)
 
bool TestIntersection (const vec3 *object_a, const vec3 *object_b, const vec3 *normal_a, const vec3 *normal_b, const vec3 *edge_a, const vec3 *edge_b)
 
int separating_axis_theorem (const vec3 *box_a, const vec3 *box_b)
 
void CreateSphere (int sides, float radius, vertex_t *&vertex, unsigned int *&index, unsigned int &num_vertex, unsigned int &num_index, bool invert, vec3 &offset)
 
void ClipVelocity (vec3 &in, vec3 &normal)
 
void make_skybox (Graphics &gfx, unsigned int num_vertex, unsigned int &num_index, int &skybox_vertex, int &skybox_index, bool sphere)
 
void WriteObj (char *filename, vertex_t *vertex_array, unsigned int num_vertex, unsigned int *index_array, unsigned int num_index)
 

Variables

char dmesg [DMESG_SIZE][1024]
 
int dmesg_index
 
ping_t hist [64]
 
int hist_index = 0
 
static unsigned int seed = 0x13371337
 

Macro Definition Documentation

#define DMESG_SIZE   2048
#define STB_IMAGE_IMPLEMENTATION

Function Documentation

bool aabb_visible ( vec3 min,
vec3 max,
matrix4 mvp 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int auto_complete ( const char *  a,
const char *  b 
)

Here is the caller graph for this function:

void bezier_curve ( float  t,
vec3 p,
const vec3 p0,
const vec3 p1,
const vec3 p2,
const vec3 p3 
)

Here is the caller graph for this function:

void bicubic_bezier_surface ( vec3 control,
float  time_x,
float  time_y,
vec3 out 
)

Here is the call graph for this function:

void calc_hash ( char *  filename,
char *  hash 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float clamp ( float  value,
float  min,
float  max 
)
int clamp ( int  value,
int  min,
int  max 
)

Here is the caller graph for this function:

void ClipVelocity ( vec3 in,
vec3 normal 
)

Here is the caller graph for this function:

vec3 ColorToVector ( const pixel_t color)

Here is the caller graph for this function:

void crc32 ( const void *  data,
unsigned int  n_bytes,
unsigned int *  crc 
)

Here is the call graph for this function:

unsigned int crc32_byte ( unsigned int  r)

Here is the caller graph for this function:

void CreateSphere ( int  sides,
float  radius,
vertex_t *&  vertex,
unsigned int *&  index,
unsigned int &  num_vertex,
unsigned int &  num_index,
bool  invert,
vec3 offset 
)

Here is the call graph for this function:

void cubic_bezier_curve ( vec3 a,
vec3 b,
vec3 c,
vec3 d,
float  time,
vec3 out 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int debugf ( const char *  format,
  ... 
)
void delta_compress ( char *  output,
char *  input,
char *  delta,
int  size 
)
void delta_uncompress ( char *  output,
char *  input,
char *  delta,
int  size 
)
int gen_lightning ( Graphics gfx,
unsigned int &  ibo,
unsigned int &  vbo 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void gen_normalmap ( float  scale,
const pixel_t pixel,
pixel_t pixelout,
int  width,
int  height 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int gen_spiral ( Graphics gfx,
unsigned int &  ibo,
unsigned int &  vbo 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void get_cpu_info ( struct cpuinfo info)

Here is the caller graph for this function:

char* get_file ( char *  filename,
int *  size 
)

Here is the caller graph for this function:

int get_zipfile ( char *  zipfile,
char *  file,
unsigned char **  data,
int *  size 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int getFarthestInDir ( const vec3 shape,
const vec3 v,
const int  num_vert 
)

Here is the caller graph for this function:

void GetInterval ( const vec3 object,
const vec3 axis,
float &  minv,
float &  maxv 
)

Here is the caller graph for this function:

float GetLuminance ( vec3 v)

Here is the caller graph for this function:

int gjk ( const vec3 shape1,
const vec3 shape2,
const int  iterations,
const int  num_vert_one,
const int  num_vert_two 
)

Here is the call graph for this function:

void init_pid ( pid_state_t pid)

Here is the caller graph for this function:

int lightning ( float  distance,
vec3 scale,
float  step,
vec3 point 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int list_zipfile ( char *  zipfile,
char *  filelist 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int listCallback ( JZFile zip,
int  idx,
JZFileHeader header,
char *  filename,
void *  filelist 
)

Here is the caller graph for this function:

int load_texture ( Graphics gfx,
char *  file_name,
bool  clamp,
bool  bgr,
int  anisotropic 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int load_texture_pk3 ( Graphics gfx,
char *  file_name,
char **  pk3_list,
int  num_pk3,
bool  clamp,
bool  bgr,
int  anisotropic 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void make_skybox ( Graphics gfx,
unsigned int  num_vertex,
unsigned int &  num_index,
int &  skybox_vertex,
int &  skybox_index,
bool  sphere 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void md5sum ( char *  data,
int  size,
char *  hash 
)

Here is the caller graph for this function:

void navdata_to_graph ( ref_t *&  ref,
graph_node_t *&  node,
vector< Entity * > &  entity_list,
int  start 
)

Here is the caller graph for this function:

void newlinelist ( char *  filename,
char **  list,
unsigned int &  num,
char **  file 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float newtonSqrt ( float  x)
void pick_line ( const vec3 v,
const vec3 shape1,
const vec3 shape2,
vec3 a,
vec3 b,
const int  num_vert_one,
const int  num_vert_two 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pick_tetrahedron ( vec3 a,
vec3 b,
vec3 c,
int &  flag,
const vec3 shape1,
const vec3 shape2,
const int  iteration_allowed,
const int  num_vert_one,
const int  num_vert_two 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pick_triangle ( vec3 a,
vec3 b,
vec3 c,
int &  flag,
const vec3 shape1,
const vec3 shape2,
const int  iteration_allowed,
const int  num_vert_one,
const int  num_vert_two 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pid_controller ( const vec3 target,
const float  timestep,
const vec3 pos,
vec3 thrust,
const float  kd 
)

Here is the caller graph for this function:

double ping_time_end ( int  sequence)

Here is the call graph for this function:

Here is the caller graph for this function:

void ping_time_start ( int  sequence)

Here is the call graph for this function:

Here is the caller graph for this function:

void polyline ( vec3 point,
int  num_point,
float  t,
vec3 p 
)

Here is the call graph for this function:

void print_graph ( graph_node_t node,
int  num_node 
)

Here is the caller graph for this function:

void print_path ( int *  path,
int  path_length,
graph_node_t node 
)
int processFile ( JZFile zip,
userdata_t user 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void quadratic_bezier_curve ( vec3 a,
vec3 b,
vec3 c,
float  time,
vec3 out 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void quadratic_bezier_surface ( vec3 control,
float  time_x,
float  time_y,
vec3 out 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float rand_float ( float  fMin,
float  fAdd 
)

Here is the caller graph for this function:

float random_float ( )
bool RayBoxSlab ( vec3 origin,
vec3 dir,
vec3 min,
vec3 max,
float &  distance 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool RayPlane ( vec3 origin,
vec3 dir,
vec3 normal,
float  d,
vec3 point 
)

Here is the call graph for this function:

bool RaySphere ( vec3 origin,
vec3 dir,
vec3 sphere,
float  radius,
float &  t 
)

Here is the call graph for this function:

bool RayTriangleMT ( vec3 origin,
vec3 dir,
vec3 a,
vec3 b,
vec3 c,
float &  t,
float &  u,
float &  v 
)

Here is the call graph for this function:

int recordCallback ( JZFile zip,
int  idx,
JZFileHeader header,
char *  filename,
void *  user_data 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void runlength_decode ( uint8_t *  output,
rletable_t table,
uint8_t *  input,
unsigned int *  size 
)
void runlength_encode ( uint8_t *  output,
rletable_t table,
int *  table_size,
uint8_t *  input,
unsigned int *  size 
)
int separating_axis_theorem ( const vec3 box_a,
const vec3 box_b 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void show_hw_info ( )

Here is the call graph for this function:

int spiral ( float  distance,
vec3 scale,
float  step,
vec3 point 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void support ( const vec3 shape1,
const vec3 shape2,
const vec3 v,
vec3 point,
const int  num_vert_one,
const int  num_vert_two 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void tessellate_quadratic_bezier_surface ( vec3 control,
vertex_t *&  vertex,
int *&  index,
int &  num_vertex,
int &  num_index,
float  level 
)

Here is the call graph for this function:

bool TestIntersection ( const vec3 object_a,
const vec3 object_b,
const vec3 normal_a,
const vec3 normal_b,
const vec3 edge_a,
const vec3 edge_b 
)

Here is the call graph for this function:

Here is the caller graph for this function:

byte* tga_24to32 ( int  width,
int  height,
byte pBits,
bool  bgr 
)

Here is the caller graph for this function:

int trim ( char *  data,
int  length 
)
void update_pid ( pid_state_t pid,
const vec3 target,
const vec3 position,
vec3 output 
)

Here is the call graph for this function:

Here is the caller graph for this function:

pixel_t VectorToColor ( vec3 v)

Here is the caller graph for this function:

void write_bitmap ( char *  filename,
int  width,
int  height,
int *  data 
)

Here is the caller graph for this function:

int write_file ( char *  filename,
const char *  bytes,
int  size 
)

Here is the caller graph for this function:

void WriteObj ( char *  filename,
vertex_t vertex_array,
unsigned int  num_vertex,
unsigned int *  index_array,
unsigned int  num_index 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

char dmesg[DMESG_SIZE][1024]
int dmesg_index
ping_t hist[64]
int hist_index = 0
unsigned int seed = 0x13371337
static