experimental decoder
authorhgn <hgodden00@gmail.com>
Sun, 26 Oct 2025 23:13:41 +0000 (23:13 +0000)
committerhgn <hgodden00@gmail.com>
Sun, 26 Oct 2025 23:13:41 +0000 (23:13 +0000)
source/engine/model.c
source/engine/model.h
source/engine/model_entity.h
source/engine/vg_tex.c
source/maths/common_maths.c
source/maths/common_maths.h

index f0ac2bb00a16bf3e76ea87908f2f6ce745a5cf6a..50e6b83a06233cb3dc3684c2919b6dc20bd566a6 100644 (file)
@@ -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 );
    }
 }
 
index b8dfe436eb5cf1e294f2375e5c2ded2ae76a359d..424e198ad15798cdbd7080d56fec2af089cee8e0 100644 (file)
@@ -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;
 };
 
index 513d02a10f105837f5288057238aff68f8f800e0..5f7f3b27397b0fa7ef056e01d8ab409778a7ec0e 100644 (file)
@@ -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 */
index 01559f79fbd0592f5902c98163e9ebbdb0b109a9..fb0b349916e42e36a24e827776c9e84cbd7ebe2a 100644 (file)
@@ -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; y<desc->height; y ++ )
+      {
+         for( i32 x=0; x<desc->width; 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 )
index 5546428dc8a89d659af5b7fce9331315ae51aa47..6d1ec4c76c6f4819ff16603a6f1ff6c62fcf05d7 100644 (file)
@@ -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);
 }
 
index aeb54b19e61c62a7ec356e06f8dd77f6ec1e4833..93b75818c5bb0de154e381ef21922884a4c80496 100644 (file)
@@ -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);
+}