IMPLEMENTATION
*/
-#define CXR_API
+#define CXR_API
#define CXR_EPSILON 0.001
#define CXR_PLANE_SIMILARITY_MAX 0.998
#define CXR_BIG_NUMBER 1e300
struct cxr_material
{
i32 res[2];
- const char *name;
+ char *name;
}
*materials;
}
fprintf( fp, "};\n" );
- fprintf( fp, "struct cxr_static_loop test_loops[] = {\n" );
+ fprintf( fp, "cxr_static_loop test_loops[] = {\n" );
for( int i=0; i<src->loop_count; i ++ )
{
fprintf( fp, " {%d, %d},\n",
}
fprintf( fp, "};\n" );
- fprintf( fp, "struct cxr_polygon test_polys[] = {\n" );
+ fprintf( fp, "cxr_polygon test_polys[] = {\n" );
for( int i=0; i <src->poly_count; i++ )
{
fprintf( fp, " {%d, %d, {%f, %f, %f}, {%f, %f, %f}},\n",
}
fprintf( fp, "};\n" );
- fprintf( fp, "struct cxr_edge test_edges[] = {\n" );
+ fprintf( fp, "cxr_edge test_edges[] = {\n" );
for( int i=0; i<src->edge_count; i++ )
{
fprintf( fp, " {%d, %d, %d},\n",
}
fprintf( fp, "};\n" );
- fprintf( fp, "struct cxr_static_mesh test_mesh = {\n" );
+ fprintf( fp, "cxr_static_mesh test_mesh = {\n" );
fprintf( fp, " .vertices = test_verts,\n" );
fprintf( fp, " .loops = test_loops,\n" );
fprintf( fp, " .edges = test_edges,\n" );
cxr_ab_free( &world->abverts );
cxr_ab_free( &world->absolids );
- free( world->materials );
+
+ if( world->materials )
+ {
+ for( int i=0; i<world->material_count; i++ )
+ free( world->materials[i].name );
+
+ free( world->materials );
+ }
free( world );
}
size_t dsize = sizeof(cxr_material) * src->material_count;
world->materials = malloc( dsize );
memcpy( world->materials, src->materials, dsize );
+
+ for( int i=0; i<src->material_count; i++ )
+ {
+ world->materials[i].name = malloc(strlen(src->materials[i].name) +1);
+ strcpy( world->materials[i].name, src->materials[i].name );
+ }
+ world->material_count = src->material_count;
}
else world->materials = NULL;
* TODO(harry): Error checking is needed here for bad input data
*/
- int dispedge[16];
+ int dispedge[17];
v2f corner_uvs[4];
int dispedge_count;
int disp_count = 0;
tx = (double)k/(double)(5-1);
v3_lerp( lside0, lside1, tx, lref );
v3_muls( verts[grid[index]], ctx->scale, vworld );
- v3_add( ctx->offset, vworld, ctx->offset );
+ v3_add( ctx->offset, vworld, vworld );
v3_sub( vworld, lref, vdelta );
v3_copy( vdelta, normals[index] );
world_corners[side[0]] );
cxr_vdf_kv( output, "material", matptr->name );
-
cxr_vdf_kaxis( output, "uaxis",
texinfo_shared.uaxis,
texinfo_shared.offset[0],