IMPLEMENTATION
*/
-#define CXR_API
#define CXR_EPSILON 0.001
#define CXR_PLANE_SIMILARITY_MAX 0.998
#define CXR_BIG_NUMBER 1e300
#include <stdio.h>
#include <math.h>
-#include <stdint.h>
-#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
-typedef int8_t i8;
-typedef int16_t i16;
-typedef int32_t i32;
-typedef int64_t i64;
-
-typedef unsigned int uint;
-
-typedef double v2f[2];
-typedef double v3f[3];
-typedef double v4f[4];
-typedef v3f m3x3f[3];
-typedef v3f m4x3f[4];
-typedef v3f boxf[2];
-
+#include "cxr_types.h"
#include "cxr_math.h"
#include "cxr_mem.h"
+#include "cxr_log.h"
+
+#ifdef CXR_VALVE_BIN
+ #include "cxr_valve_bin.h"
+#endif
typedef struct cxr_world cxr_world;
typedef struct cxr_solid cxr_solid;
/* Simple mesh type mainly for debugging */
struct cxr_tri_mesh
{
- v3f *vertices;
+ v3f *vertices,
+ *normals;
+ v2f *uvs;
v4f *colours;
+
i32 *indices,
indices_count,
vertex_count;
#endif
#endif
-static void (*cxr_log_func)(const char *str);
-static void (*cxr_line_func)( v3f p0, v3f p1, v4f colour );
-
static int cxr_range(int x, int bound)
{
if( x < 0 )
#ifdef CXR_DEBUG
-static void cxr_log( const char *fmt, ... )
-{
- char buf[512];
-
- va_list args;
- va_start( args, fmt );
- vsnprintf( buf, sizeof(buf)-1, fmt, args );
- va_end(args);
-
- if( cxr_log_func )
- cxr_log_func( buf );
-
- fputs(buf,stdout);
-}
-
static void cxr_debug_line( v3f p0, v3f p1, v4f colour )
{
if( cxr_line_func )
out->colours = malloc( sizeof(v4f)*out->vertex_count );
out->vertices = malloc( sizeof(v3f)*out->vertex_count );
out->indices = malloc( sizeof(i32)*out->indices_count );
+ out->uvs = NULL;
+ out->normals = NULL;
v3f *overts = out->vertices;
v4f *colours = out->colours;
free( mesh->colours );
free( mesh->indices );
free( mesh->vertices );
+ free( mesh->normals );
+ free( mesh->uvs );
free( mesh );
}
return 1;
}
+
#endif /* CXR_VALVE_MAP_FILE */
#endif /* CXR_IMPLEMENTATION */