From: hgn Date: Sun, 26 Oct 2025 23:13:41 +0000 (+0000) Subject: experimental decoder X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=4b4f440d2843aecb1d242c787b61b2b4c992b701;p=vg.git experimental decoder --- diff --git a/source/engine/model.c b/source/engine/model.c index f0ac2bb..50e6b83 100644 --- a/source/engine/model.c +++ b/source/engine/model.c @@ -401,7 +401,7 @@ void vg_model_stream_textures_gpu( struct vg_model_stream_context *ctx ) union mdl_texture *tex = &ctx->model->textures[ i ]; struct mdl_file pack_info = tex->file; _vg_tex_load_stream( &tex->tex, vg_model_stream_pack_stream( ctx, &pack_info ), - VG_TEX_REPEAT | VG_TEX_NEAREST | VG_TEX_NOMIP ); + VG_TEX_REPEAT | VG_TEX_LINEAR | VG_TEX_NOMIP ); } } diff --git a/source/engine/model.h b/source/engine/model.h index b8dfe43..424e198 100644 --- a/source/engine/model.h +++ b/source/engine/model.h @@ -176,7 +176,8 @@ struct mdl_mesh u32 submesh_start, submesh_count, pstr_name, - entity_id, /* upper 16 bits: type, lower 16 bits: index. hgn: 11.06.2025 Is this still used??? */ + entity_id, /* upper 16 bits: type, lower 16 bits: index. hgn: 11.06.2025 Is this still used??? + hgn: 25.10.2025 Yes it is. */ armature_id; }; diff --git a/source/engine/model_entity.h b/source/engine/model_entity.h index 513d02a..5f7f3b2 100644 --- a/source/engine/model_entity.h +++ b/source/engine/model_entity.h @@ -42,6 +42,8 @@ enum entity_alias k_ent_flame = 200, k_ent_waterfall = 201, + k_ent_rb2 = 202, + k_ent_heatpipe = 203, k_ent_max }; @@ -119,16 +121,33 @@ enum light_type k_light_type_spot = 1 }; +#define ENT_LIGHT_FLAG_DAYTIME 0x1 +#define ENT_LIGHT_FLAG_OFF 0x2 + struct ent_light { struct mdl_transform transform; - u32 daytime, + u32 flags, type; f32 colour[4]; f32 angle, range; - f32 inverse_world[4][3]; - f32 angle_sin_cos[2]; + + union + { + /* These are temporary, we could remove them from the file structure. */ + struct + { + f32 inverse_world[4][3]; + f32 angle_sin_cos[2]; + }; + + struct + { + f32 lerp_start[3], lerp_end[3]; + f32 lerp_duration, timer; + }; + }; }; /* v101 */ diff --git a/source/engine/vg_tex.c b/source/engine/vg_tex.c index 01559f7..fb0b349 100644 --- a/source/engine/vg_tex.c +++ b/source/engine/vg_tex.c @@ -108,6 +108,40 @@ void vg_qoi_stream_decode( struct qoi_desc *desc, struct stream *stream, u8 *pix pixels[ ((row*desc->width) + x)*desc->channels + i ] = px.rgba[i]; } } + + if( desc->channels == 4 ) + { + for( i32 y=0; yheight; y ++ ) + { + for( i32 x=0; xwidth; x ++ ) + { + u32 ia = ((y*desc->width)+x)*4; + if( pixels[ ia+3 ] == 0 ) + { + for( i32 yy=-1; yy<=1; yy++ ) + { + for( i32 xx=-1; xx<=1; xx++ ) + { + i32 sx = x+xx, + sy = y+yy; + if( sx < 0 ) sx = desc->width-1; + if( sy < 0 ) sy = desc->height-1; + if( sx >= desc->width ) sx = 0; + if( sy >= desc->height ) sy = 0; + u32 ib = ((sy*desc->width)+sx)*4; + if( pixels[ ib + 3 ] > 1 && pixels[ib+3]!=254 ) + { + pixels[ ia+0 ] = pixels[ ib+0 ]; + pixels[ ia+1 ] = pixels[ ib+1 ]; + pixels[ ia+2 ] = pixels[ ib+2 ]; + pixels[ ia+3 ] = 1; + } + } + } + } + } + } + } } u32 vg_query_qoi_max_compressed_size( const struct qoi_desc *desc ) diff --git a/source/maths/common_maths.c b/source/maths/common_maths.c index 5546428..6d1ec4c 100644 --- a/source/maths/common_maths.c +++ b/source/maths/common_maths.c @@ -371,24 +371,20 @@ static void closest_point_elipse( v2f p, v2f e, v2f o ) * ----------------------------------------------------------------------------- */ -static int ray_aabb1( boxf box, v3f co, v3f dir_inv, f32 dist ) +static b8 ray_aabb1( f32 box[2][3], f32 co[3], f32 dir_inv[3], f32 dist ) { - v3f v0, v1; - f32 tmin, tmax; - + f32 v0[3], v1[3], + tmin, tmax; v3_sub( box[0], co, v0 ); v3_sub( box[1], co, v1 ); - v3_mul( v0, dir_inv, v0 ); v3_mul( v1, dir_inv, v1 ); - - tmin = vg_minf( v0[0], v1[0] ); - tmax = vg_maxf( v0[0], v1[0] ); - tmin = vg_maxf( tmin, vg_minf( v0[1], v1[1] )); - tmax = vg_minf( tmax, vg_maxf( v0[1], v1[1] )); - tmin = vg_maxf( tmin, vg_minf( v0[2], v1[2] )); - tmax = vg_minf( tmax, vg_maxf( v0[2], v1[2] )); - + tmin = f32_min( v0[0], v1[0] ); + tmax = f32_max( v0[0], v1[0] ); + tmin = f32_max( tmin, f32_min( v0[1], v1[1] )); + tmax = f32_min( tmax, f32_max( v0[1], v1[1] )); + tmin = f32_max( tmin, f32_min( v0[2], v1[2] )); + tmax = f32_min( tmax, f32_max( v0[2], v1[2] )); return (tmax >= tmin) && (tmin <= dist) && (tmax >= 0.0f); } diff --git a/source/maths/common_maths.h b/source/maths/common_maths.h index aeb54b1..93b7581 100644 --- a/source/maths/common_maths.h +++ b/source/maths/common_maths.h @@ -1413,8 +1413,26 @@ static inline f32 closest_point_on_segment_2d( f32 co[2], f32 a[2], f32 b[2], f3 return t; } -static void closest_point_aabb( f32 p[3], f32 box[2][3], f32 dest[3] ) +static inline void closest_point_aabb( f32 p[3], f32 box[2][3], f32 dest[3] ) { v3_max( p, box[0], dest ); v3_min( dest, box[1], dest ); } + +/* FIXME! SHOULDN't BE INLINE */ +static inline b8 ray_aabb1( f32 box[2][3], f32 co[3], f32 dir_inv[3], f32 dist ) +{ + f32 v0[3], v1[3], + tmin, tmax; + v3_sub( box[0], co, v0 ); + v3_sub( box[1], co, v1 ); + v3_mul( v0, dir_inv, v0 ); + v3_mul( v1, dir_inv, v1 ); + tmin = f32_min( v0[0], v1[0] ); + tmax = f32_max( v0[0], v1[0] ); + tmin = f32_max( tmin, f32_min( v0[1], v1[1] )); + tmax = f32_min( tmax, f32_max( v0[1], v1[1] )); + tmin = f32_max( tmin, f32_min( v0[2], v1[2] )); + tmax = f32_min( tmax, f32_max( v0[2], v1[2] )); + return (tmax >= tmin) && (tmin <= dist) && (tmax >= 0.0f); +}