projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
needs a lot of cleaning but lights are OK
[carveJwlIkooP6JGAAIwe30JlM.git]
/
scene.h
diff --git
a/scene.h
b/scene.h
index d0615d52688a36b18d3656a5c64a8551f58fb1b9..fa1ce4dbc8bc782a23953c22889aa20d7c27d384 100644
(file)
--- a/
scene.h
+++ b/
scene.h
@@
-10,13
+10,14
@@
typedef struct scene_vert scene_vert;
#pragma pack(push,1)
#pragma pack(push,1)
-/*
24
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 */
+ u16 lights[4]; /* 4*16 */
};
#pragma pack(pop)
};
#pragma pack(pop)
@@
-182,15
+183,14
@@
VG_STATIC scene *scene_fix( void *lin_alloc, scene *pscene )
{
/* FIXME: Why is this disabled? */
{
/* 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
= 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 */
@@
-259,6
+259,11
@@
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 );
+ /* 3: light cluster */
+ glVertexAttribIPointer( 3, 4, GL_UNSIGNED_SHORT,
+ stride, (void *)offsetof(scene_vert, lights) );
+ glEnableVertexAttribArray( 3 );
+
VG_CHECK_GL_ERR();
mesh->indice_count = pscene->indice_count;
VG_CHECK_GL_ERR();
mesh->indice_count = pscene->indice_count;
@@
-292,7
+297,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 )