projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix major overstep with last commit
[carveJwlIkooP6JGAAIwe30JlM.git]
/
model.h
diff --git
a/model.h
b/model.h
index 50913017fab68d1925f2d838668df961303cca76..d72e93cc29a4ff90e3611c308394d4921d154925 100644
(file)
--- a/
model.h
+++ b/
model.h
@@
-142,19
+142,27
@@
struct classtype_route_node
struct classtype_route
{
struct classtype_route
{
- u32 pstr_name;
u32 id_start;
v3f colour;
};
struct classtype_bone
{
u32 id_start;
v3f colour;
};
struct classtype_bone
{
- u32 deform;
+ u32 deform,
+ ik_target,
+ ik_pole,
+ collider,
+ use_limits;
+
+ v3f angle_limits[2];
+ boxf hitbox;
};
struct classtype_skeleton
{
u32 channels,
};
struct classtype_skeleton
{
u32 channels,
+ ik_count,
+ collider_count,
anim_start,
anim_count;
};
anim_start,
anim_count;
};
@@
-174,12
+182,15
@@
struct glmesh
{
GLuint vao, vbo, ebo;
u32 indice_count;
{
GLuint vao, vbo, ebo;
u32 indice_count;
+ u32 loaded;
};
static void mesh_upload( glmesh *mesh,
};
static void mesh_upload( glmesh *mesh,
- mdl_vert *verts, u32 vert_count,
- u32 *indices, u32 indice_count )
+
mdl_vert *verts, u32 vert_count,
+
u32 *indices, u32 indice_count )
{
{
+ //assert( mesh->loaded == 0 );
+
glGenVertexArrays( 1, &mesh->vao );
glGenBuffers( 1, &mesh->vbo );
glGenBuffers( 1, &mesh->ebo );
glGenVertexArrays( 1, &mesh->vao );
glGenBuffers( 1, &mesh->vbo );
glGenBuffers( 1, &mesh->ebo );
@@
-224,9
+235,10
@@
static void mesh_upload( glmesh *mesh,
stride, (void *)offsetof(mdl_vert, groups) );
glEnableVertexAttribArray( 5 );
stride, (void *)offsetof(mdl_vert, groups) );
glEnableVertexAttribArray( 5 );
-
- VG_CHECK_GL();
+ VG_CHECK_GL_ERR();
+
mesh->indice_count = indice_count;
mesh->indice_count = indice_count;
+ mesh->loaded = 1;
}
static void mesh_bind( glmesh *mesh )
}
static void mesh_bind( glmesh *mesh )
@@
-247,9
+259,12
@@
static void mesh_draw( glmesh *mesh )
static void mesh_free( glmesh *mesh )
{
static void mesh_free( glmesh *mesh )
{
- glDeleteVertexArrays( 1, &mesh->vao );
- glDeleteBuffers( 1, &mesh->ebo );
- glDeleteBuffers( 1, &mesh->vbo );
+ if( mesh->loaded )
+ {
+ glDeleteVertexArrays( 1, &mesh->vao );
+ glDeleteBuffers( 1, &mesh->ebo );
+ glDeleteBuffers( 1, &mesh->vbo );
+ }
}
}
@@
-273,7
+288,7
@@
static mdl_header *mdl_load( const char *path )
if( size < sizeof(mdl_header) )
{
if( size < sizeof(mdl_header) )
{
- free( header );
+
vg_
free( header );
vg_error( "Invalid file '%s' (too small for header)\n", path );
return NULL;
}
vg_error( "Invalid file '%s' (too small for header)\n", path );
return NULL;
}
@@
-283,7
+298,7
@@
static mdl_header *mdl_load( const char *path )
vg_error( "Invalid file '%s'"
"(wrong .file_length, %ub != real file size %ub)\n",
path, header->file_length, size );
vg_error( "Invalid file '%s'"
"(wrong .file_length, %ub != real file size %ub)\n",
path, header->file_length, size );
- free( header );
+
vg_
free( header );
return NULL;
}
return NULL;
}
@@
-334,7
+349,7
@@
static mdl_header *mdl_load( const char *path )
if( ri->count > ri->max_count )
{
if( ri->count > ri->max_count )
{
- free( header );
+
vg_
free( header );
vg_error( "'%s': '%s' buffer exceeds the maximum (%u/%u)\n",
path, ri->desc, ri->count, ri->max_count );
return NULL;
vg_error( "'%s': '%s' buffer exceeds the maximum (%u/%u)\n",
path, ri->desc, ri->count, ri->max_count );
return NULL;
@@
-342,7
+357,7
@@
static mdl_header *mdl_load( const char *path )
if( ri->offset >= header->file_length )
{
if( ri->offset >= header->file_length )
{
- free( header );
+
vg_
free( header );
vg_error( "'%s': '%s' buffer offset is out of range\n",
path, ri->desc );
return NULL;
vg_error( "'%s': '%s' buffer offset is out of range\n",
path, ri->desc );
return NULL;
@@
-350,7
+365,7
@@
static mdl_header *mdl_load( const char *path )
if( ri->offset + ri->size*ri->count > header->file_length )
{
if( ri->offset + ri->size*ri->count > header->file_length )
{
- free( header );
+
vg_
free( header );
vg_error( "'%s': '%s' buffer size is out of range\n",
path, ri->desc );
return NULL;
vg_error( "'%s': '%s' buffer size is out of range\n",
path, ri->desc );
return NULL;
@@
-365,7
+380,7
@@
static mdl_header *mdl_load( const char *path )
if( ri->offset >= rj->offset &&
(ri->offset+ri->size*ri->count < rj->offset+rj->size*rj->count))
{
if( ri->offset >= rj->offset &&
(ri->offset+ri->size*ri->count < rj->offset+rj->size*rj->count))
{
- free( header );
+
vg_
free( header );
vg_error( "'%s': '%s' buffer overlaps '%s'\n",
path, ri->desc, rj->desc );
return NULL;
vg_error( "'%s': '%s' buffer overlaps '%s'\n",
path, ri->desc, rj->desc );
return NULL;