projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
right hand yellow
[carveJwlIkooP6JGAAIwe30JlM.git]
/
scene.h
diff --git
a/scene.h
b/scene.h
index 7a9460b4dbfe1a7f463b401f61718dc0c3eea5b0..74c4ea61a10476c4af5de918d2a07c066621521a 100644
(file)
--- a/
scene.h
+++ b/
scene.h
@@
-10,14
+10,14
@@
typedef struct scene_vert scene_vert;
#pragma pack(push,1)
#pragma pack(push,1)
-/*
28
byte vertexs, we don't care about the normals too much,
+/*
32
byte vertexs, we don't care about the normals too much,
* maybe possible to bring down uv to i16s too */
struct scene_vert
{
v3f co; /* 3*32 */
v2f uv; /* 2*32 */
i8 norm[4]; /* 4*8 */
* maybe possible to bring down uv to i16s too */
struct scene_vert
{
v3f co; /* 3*32 */
v2f uv; /* 2*32 */
i8 norm[4]; /* 4*8 */
- u
8 lights[4]; /* 4*8 */
+ u
16 unused[4];
};
#pragma pack(pop)
};
#pragma pack(pop)
@@
-78,8
+78,7
@@
VG_STATIC void scene_vert_pack_norm( scene_vert *vert, v3f norm )
VG_STATIC void scene_add_mdl_submesh( scene *pscene, mdl_context *mdl,
mdl_submesh *sm, m4x3f transform )
{
VG_STATIC void scene_add_mdl_submesh( scene *pscene, mdl_context *mdl,
mdl_submesh *sm, m4x3f transform )
{
- if( pscene->vertex_count + sm->vertex_count > pscene->max_vertices )
- {
+ if( pscene->vertex_count + sm->vertex_count > pscene->max_vertices ){
vg_error( "%u(current) + %u > %u\n", pscene->vertex_count,
sm->vertex_count,
pscene->max_vertices );
vg_error( "%u(current) + %u > %u\n", pscene->vertex_count,
sm->vertex_count,
pscene->max_vertices );
@@
-88,8
+87,7
@@
VG_STATIC void scene_add_mdl_submesh( scene *pscene, mdl_context *mdl,
vg_fatal_exit_loop( "Scene vertex buffer overflow" );
}
vg_fatal_exit_loop( "Scene vertex buffer overflow" );
}
- if( pscene->indice_count + sm->indice_count > pscene->max_indices )
- {
+ if( pscene->indice_count + sm->indice_count > pscene->max_indices ){
vg_error( "%u(current) + %u > %u\n", pscene->indice_count,
sm->indice_count,
pscene->max_indices );
vg_error( "%u(current) + %u > %u\n", pscene->indice_count,
sm->indice_count,
pscene->max_indices );
@@
-98,10
+96,10
@@
VG_STATIC void scene_add_mdl_submesh( scene *pscene, mdl_context *mdl,
vg_fatal_exit_loop( "Scene index buffer overflow" );
}
vg_fatal_exit_loop( "Scene index buffer overflow" );
}
- mdl_vert *src_verts =
mdl_submesh_vertices( mdl, sm
);
+ mdl_vert *src_verts =
mdl_arritm( &mdl->verts, sm->vertex_start
);
scene_vert *dst_verts = &pscene->arrvertices[ pscene->vertex_count ];
scene_vert *dst_verts = &pscene->arrvertices[ pscene->vertex_count ];
- u32 *src_indices = mdl_
submesh_indices( mdl, sm
),
+ u32 *src_indices = mdl_
arritm( &mdl->indices, sm->indice_start
),
*dst_indices = &pscene->arrindices[ pscene->indice_count ];
/* Transform and place vertices */
*dst_indices = &pscene->arrindices[ pscene->indice_count ];
/* Transform and place vertices */
@@
-116,8
+114,7
@@
VG_STATIC void scene_add_mdl_submesh( scene *pscene, mdl_context *mdl,
v3_normalize( normal_matrix[1] );
v3_normalize( normal_matrix[2] );
v3_normalize( normal_matrix[1] );
v3_normalize( normal_matrix[2] );
- for( u32 i=0; i<sm->vertex_count; i++ )
- {
+ for( u32 i=0; i<sm->vertex_count; i++ ){
mdl_vert *src = &src_verts[ i ];
scene_vert *pvert = &dst_verts[ i ];
mdl_vert *src = &src_verts[ i ];
scene_vert *pvert = &dst_verts[ i ];
@@
-182,16
+179,15
@@
__attribute__((warn_unused_result))
VG_STATIC scene *scene_fix( void *lin_alloc, scene *pscene )
{
/* FIXME: Why is this disabled? */
VG_STATIC scene *scene_fix( void *lin_alloc, scene *pscene )
{
/* FIXME: Why is this disabled? */
- return pscene;
u32 vertex_count = pscene->vertex_count,
indice_count = pscene->indice_count,
vertex_length = vertex_count * sizeof(scene_vert),
index_length = indice_count * sizeof(u32),
u32 vertex_count = pscene->vertex_count,
indice_count = pscene->indice_count,
vertex_length = vertex_count * sizeof(scene_vert),
index_length = indice_count * sizeof(u32),
- tot_size =
sizeof(scene) + vertex_length + index_length
;
+ tot_size =
vg_align8(sizeof(scene) + vertex_length + index_length)
;
/* copy down index data */
/* copy down index data */
- void *dst_indices = pscene->arrvertices + vertex_
length
;
+ void *dst_indices = pscene->arrvertices + vertex_
count
;
memmove( dst_indices, pscene->arrindices, index_length );
/* realloc */
memmove( dst_indices, pscene->arrindices, index_length );
/* realloc */
@@
-251,7
+247,7
@@
VG_STATIC void scene_upload( scene *pscene, glmesh *mesh )
glEnableVertexAttribArray( 0 );
/* 1: normal */
glEnableVertexAttribArray( 0 );
/* 1: normal */
- glVertexAttribPointer( 1,
3
, GL_BYTE, GL_TRUE,
+ glVertexAttribPointer( 1,
4
, GL_BYTE, GL_TRUE,
stride, (void *)offsetof(scene_vert, norm) );
glEnableVertexAttribArray( 1 );
stride, (void *)offsetof(scene_vert, norm) );
glEnableVertexAttribArray( 1 );
@@
-260,10
+256,12
@@
VG_STATIC void scene_upload( scene *pscene, glmesh *mesh )
stride, (void *)offsetof(scene_vert, uv) );
glEnableVertexAttribArray( 2 );
stride, (void *)offsetof(scene_vert, uv) );
glEnableVertexAttribArray( 2 );
+#if 0
/* 3: light cluster */
/* 3: light cluster */
- glVertexAttribIPointer( 3, 4, GL_UNSIGNED_
BYTE
,
+ glVertexAttribIPointer( 3, 4, GL_UNSIGNED_
SHORT
,
stride, (void *)offsetof(scene_vert, lights) );
glEnableVertexAttribArray( 3 );
stride, (void *)offsetof(scene_vert, lights) );
glEnableVertexAttribArray( 3 );
+#endif
VG_CHECK_GL_ERR();
VG_CHECK_GL_ERR();
@@
-298,7
+296,20
@@
VG_STATIC float scene_bh_centroid( void *user, u32 item_index, int axis )
*pb = &s->arrvertices[ s->arrindices[item_index*3+1] ],
*pc = &s->arrvertices[ s->arrindices[item_index*3+2] ];
*pb = &s->arrvertices[ s->arrindices[item_index*3+1] ],
*pc = &s->arrvertices[ s->arrindices[item_index*3+2] ];
+ #if 0
+
+ float min, max;
+
+ min = vg_minf( pa->co[axis], pb->co[axis] );
+ max = vg_maxf( pa->co[axis], pb->co[axis] );
+ min = vg_minf( min, pc->co[axis] );
+ max = vg_maxf( max, pc->co[axis] );
+
+ return (min+max) * 0.5f;
+
+ #else
return (pa->co[axis] + pb->co[axis] + pc->co[axis]) * (1.0f/3.0f);
return (pa->co[axis] + pb->co[axis] + pc->co[axis]) * (1.0f/3.0f);
+ #endif
}
VG_STATIC void scene_bh_swap( void *user, u32 ia, u32 ib )
}
VG_STATIC void scene_bh_swap( void *user, u32 ia, u32 ib )