yes
authorhgn <hgodden00@gmail.com>
Sun, 16 Nov 2025 22:38:14 +0000 (22:38 +0000)
committerhgn <hgodden00@gmail.com>
Sun, 16 Nov 2025 22:38:14 +0000 (22:38 +0000)
source/engine/model_entity.h
source/engine/vg_engine.c
source/engine/vg_tex.c
source/maths/perlin.c
source/maths/perlin.h [new file with mode: 0644]

index 4ba5e7e0ce9d77182338be7a8cbe4726bc6e008d..682bb6675d9551ced30974a67c05c18cca1a1e35 100644 (file)
@@ -47,6 +47,8 @@ enum entity_alias
    k_ent_waterlevel  = 204,
    k_ent_viewstone   = 205,
    k_ent_gauge       = 206,
+   k_ent_particle    = 207,
+   k_ent_deep_npc    = 208,
    k_ent_max
 };
 
index 5928c0c17e2d57322b4056892502f5ea7bb45bbb..95b75fdf480b937b2bbbc3f7d698672a25a7e171 100644 (file)
@@ -163,6 +163,7 @@ i32 main( i32 argc, const c8 *argv[] )
    SDL_RaiseWindow( _engine.window_handle );
    SDL_SetWindowMinimumSize( _engine.window_handle, 800, 600 );
    SDL_SetWindowMaximumSize( _engine.window_handle, 1920*2, 1080*2 );
+   SDL_StopTextInput( _engine.window_handle );
 
    /*
     * OpenGL loading
@@ -301,7 +302,7 @@ L_new_frame:;
             else             action = k_button_down;
          }
          else action = k_button_up;
-         _input_callback_buttonlike( k_input_device_keyboard, ev->key, action, ev->mod );
+         _input_callback_buttonlike( k_input_device_keyboard, ev->key, action, ev->mod & (SDL_KMOD_LSHIFT|SDL_KMOD_LCTRL|SDL_KMOD_LALT) );
       }
       else if( (e.type == SDL_EVENT_MOUSE_BUTTON_DOWN) || (e.type == SDL_EVENT_MOUSE_BUTTON_UP) )
       {
index 01559f79fbd0592f5902c98163e9ebbdb0b109a9..ff94a47ec5d7f9c373b911904d785697f101bec5 100644 (file)
@@ -26,7 +26,7 @@ static inline u32 big32_to_cpu( u32 x )
 b8 vg_qoi_validate( const struct qoi_desc *desc )
 {
    if( (desc->width == 0)    || (desc->height == 0) ||
-       (desc->width >= 2048) || (desc->height >= 2048) )
+       (desc->width > 2048) || (desc->height > 2048) )
    {
       $log( $error, {"QOI file is invalid; Unpermitted size: "}, $unsigned( desc->width ), {" by "}, $unsigned( desc->height ) );
       return 0;
index 6647a915bd80dca19036d9640c0a6ef9fbfc810b..050a37b38a62d05c1999b54f032836df3e367fa6 100644 (file)
@@ -1,4 +1,7 @@
-static int perlin_hash[] = {
+#include "foundation.h"
+#include "common_maths.h"
+
+static i32 perlin_hash[] = {
 0x46,0xD5,0xB8,0xD3,0xF2,0xE5,0xCC,0x07,0xD0,0xB3,0x7A,0xA2,0xC3,0xDA,0xDC,0x7F,
 0xE0,0xB7,0x42,0xA0,0xBF,0x41,0x92,0x32,0x6F,0x0D,0x45,0xC7,0x54,0xDB,0x30,0xC2,
 0xD5,0xDA,0x55,0x09,0xDE,0x74,0x48,0x20,0xE1,0x24,0x5C,0x4D,0x6F,0x36,0xD8,0xE9,
@@ -69,29 +72,28 @@ static int perlin_hash[] = {
 #define PERLIN_HASH_LENGTH 1024
 #define PERLIN_HASH_MASK (PERLIN_HASH_LENGTH-1)
 
-static int perlin_noise2( int x, int y, int seed )
+static i32 perlin_noise2( i32 x, i32 y, i32 seed )
 {
-       return perlin_hash[ (perlin_hash[(y+seed) & PERLIN_HASH_MASK] + x) 
-            & PERLIN_HASH_MASK ];
+       return perlin_hash[ (perlin_hash[(y+seed) & PERLIN_HASH_MASK] + x) & PERLIN_HASH_MASK ];
 }
 
-static int perlin_noise1( int i, int seed )
+static i32 perlin_noise1( i32 i, i32 seed )
 {
        return perlin_hash[ (seed + i) & PERLIN_HASH_MASK ];
 }
 
 static f32 perlin_smooth( f32 x, f32 y, f32 t )
 {
-       return vg_lerpf( x, y, t*t*(3.0f-2.0f*t) );
+       return f32_lerp( x, y, t*t*(3.0f-2.0f*t) );
 }
 
-f32 vg_perlin_noise_2d( f32 x, f32 y, int seed )
+f32 perlin_noise_2d( f32 x, f32 y, i32 seed )
 {
-       int ix = x, iy = y;
+       i32 ix = x, iy = y;
        f32 x_frac = x - ix,
              y_frac = y - iy;
 
-       int s = perlin_noise2( ix,   iy,   seed ),
+       i32 s = perlin_noise2( ix,   iy,   seed ),
            t = perlin_noise2( ix+1, iy,   seed ),
            u = perlin_noise2( ix,   iy+1, seed ),
            v = perlin_noise2( ix+1, iy+1, seed );
@@ -102,26 +104,27 @@ f32 vg_perlin_noise_2d( f32 x, f32 y, int seed )
        return perlin_smooth( low, high, y_frac );
 }
 
-f32 vg_perlin_noise_1d( f32 v, int seed )
+f32 perlin_noise_1d( f32 v, i32 seed )
 {
-       int iv = v;
+       i32 iv = v;
        f32 frac = v-iv;
-       int s = perlin_noise1( iv,   seed ),
+       i32 s = perlin_noise1( iv,   seed ),
            t = perlin_noise1( iv+1, seed );
 
        return perlin_smooth( s, t, frac );
 }
 
-f32 vg_perlin_fract_1d( f32 v, f32 freq, int octaves, int seed )
+f32 perlin_fract_1d( f32 v, f32 freq, i32 octaves, i32 seed )
 {
        f32 xa  = v*freq,
              amp = 1.0f,
              fin = 0.f,
              div = 0.f;
        
-       for( int i=0; i<octaves; i++ ){
+       for( i32 i=0; i<octaves; i++ )
+   {
                div += 256 * amp;
-               fin += vg_perlin_noise_1d( xa, seed ) * amp;
+               fin += perlin_noise_1d( xa, seed ) * amp;
                amp /= 2.f;
                xa *= 2.f;
        }
@@ -129,7 +132,7 @@ f32 vg_perlin_fract_1d( f32 v, f32 freq, int octaves, int seed )
        return fin/div;
 }
 
-f32 vg_perlin_fract_2d( f32 x, f32 y, f32 freq, int octaves, int seed )
+f32 perlin_fract_2d( f32 x, f32 y, f32 freq, i32 octaves, i32 seed )
 {
        f32 xa  = x*freq,
            ya  = y*freq,
@@ -137,9 +140,10 @@ f32 vg_perlin_fract_2d( f32 x, f32 y, f32 freq, int octaves, int seed )
            fin = 0.f,
            div = 0.f;
        
-       for( int i=0; i<octaves; i++ ){
+       for( i32 i=0; i<octaves; i++ )
+   {
                div += 256 * amp;
-               fin += vg_perlin_noise_2d( xa, ya, seed ) * amp;
+               fin += perlin_noise_2d( xa, ya, seed ) * amp;
                amp /= 2;
                xa *= 2;
                ya *= 2;
diff --git a/source/maths/perlin.h b/source/maths/perlin.h
new file mode 100644 (file)
index 0000000..2107cbe
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+f32 perlin_noise_2d( f32 x, f32 y, i32 seed );
+f32 perlin_noise_1d( f32 v, i32 seed );
+f32 perlin_fract_1d( f32 v, f32 freq, i32 octaves, i32 seed );
+f32 perlin_fract_2d( f32 x, f32 y, f32 freq, i32 octaves, i32 seed );