random
authorhgn <hgodden00@gmail.com>
Sat, 28 Jan 2023 10:14:57 +0000 (10:14 +0000)
committerhgn <hgodden00@gmail.com>
Sat, 28 Jan 2023 10:14:57 +0000 (10:14 +0000)
vg_build.h
vg_m.h
vg_tex.h

index fbfbf95062e56f5c744f36f58685abd4ecfb4895..53de6c3edacc3cc3ac8b3415b5223c5dfbe54540 100644 (file)
@@ -214,7 +214,7 @@ void vg_build(void)
 
    /* Warnings */
    strcat( cmd, 
-      "   -Wall\\\n"
+      "   -Wall -ferror-limit=0\\\n"
       "     -Wno-unused-function -Wno-unused-variable\\\n"
       "     -Wno-unused-command-line-argument -Wno-unused-but-set-variable\\\n"
    );
diff --git a/vg_m.h b/vg_m.h
index fbb3c45317915d592d4fbb8120390027999944d9..e70222ef1bb6b51de5948ecaa257bce90cef92a0 100644 (file)
--- a/vg_m.h
+++ b/vg_m.h
@@ -56,6 +56,8 @@ static inline float vg_fractf( float a )
    return a - floorf( a );
 }
 
+
+__attribute__ ((deprecated))
 static float stable_force( float current, float diff )
 {
    float fnew = current + diff;
@@ -66,6 +68,11 @@ static float stable_force( float current, float diff )
    return fnew;
 }
 
+static float vg_cfrictf( float current, float F )
+{
+   return -vg_signf(current) * vg_minf( F, fabsf(current) );
+}
+
 static inline int vg_min( int a, int b )
 {
    return a < b? a: b;
@@ -1014,7 +1021,7 @@ static inline void m4x3_transform_aabb( m4x3f m, boxf box )
    m4x3_expand_aabb_point( m, box, (v3f){ b[0], a[1], b[2] } );
 }
 
-int ray_aabb( boxf box, v3f co, v3f dir, float dist )
+int ray_aabb1( boxf box, v3f co, v3f dir_inv, float dist )
 {
    v3f v0, v1;
    float tmin, tmax;
@@ -1022,8 +1029,8 @@ int ray_aabb( boxf box, v3f co, v3f dir, float dist )
    v3_sub( box[0], co, v0 );
    v3_sub( box[1], co, v1 );
 
-   v3_div( v0, dir, v0 );
-   v3_div( v1, dir, 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] );
@@ -1032,7 +1039,7 @@ int ray_aabb( boxf box, v3f co, v3f dir, float dist )
    tmin = vg_maxf( tmin, vg_minf( v0[2], v1[2] ));
    tmax = vg_minf( tmax, vg_maxf( v0[2], v1[2] ));
 
-   return tmax >= tmin && tmin < dist && tmax > 0;
+   return (tmax >= tmin) && (tmin <= dist) && (tmax >= 0.0f);
 }
 
 static inline void m4x3_lookat( m4x3f m, v3f pos, v3f target, v3f up )
@@ -1352,6 +1359,26 @@ static inline void q_nlerp( v4f a, v4f b, float t, v4f d )
    q_normalize( d );
 }
 
+static void euler_m3x3( v3f angles, m3x3f d )
+{
+   float cosY = cosf( angles[0] ),
+         sinY = sinf( angles[0] ),
+         cosP = cosf( angles[1] ),
+         sinP = sinf( angles[1] ),
+         cosR = cosf( angles[2] ),
+         sinR = sinf( angles[2] );
+
+   d[2][0] = -sinY * cosP;
+   d[2][1] =  sinP;
+   d[2][2] =  cosY * cosP;
+
+   d[0][0] =  cosY * cosR;
+   d[0][1] =  sinR;
+   d[0][2] =  sinY * cosR;
+
+   v3_cross( d[0], d[2], d[1] );
+}
+
 static inline void q_m3x3( v4f q, m3x3f d )
 {
    float
@@ -1777,6 +1804,7 @@ static int ray_tri( v3f tri[3], v3f co,
    
    /* Parralel */
    a = v3_dot( v0, h );
+
    if( a > -kEpsilon && a < kEpsilon )
       return 0;
 
index dcc297ad2b13e4fbb3a9c3c41414d48db8e7d0d5..f570b11684fe367af76f8819dec2501050b5e307 100644 (file)
--- a/vg_tex.h
+++ b/vg_tex.h
@@ -134,6 +134,9 @@ VG_STATIC void vg_tex2d_qoi( void *mem, u32 size, const char *name )
    }
 }
 
+/*
+ * TODO: This blocks while we read from file 
+ */
 VG_STATIC GLuint vg_tex2d_rgba( const char *path )
 {
    GLuint texture_name = vg_tex2d_new();