return a - floorf( a );
 }
 
+
+__attribute__ ((deprecated))
 static float stable_force( float current, float diff )
 {
    float fnew = current + 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;
    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;
    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] );
    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 )
    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
    
    /* Parralel */
    a = v3_dot( v0, h );
+
    if( a > -kEpsilon && a < kEpsilon )
       return 0;