angle limit constraint
[carveJwlIkooP6JGAAIwe30JlM.git] / gate.h
diff --git a/gate.h b/gate.h
index 7088c7dc5c236dc03223e5b3948904a6011278d0..c3f922967cba1a015584019bc7ce67c138669e3d 100644 (file)
--- a/gate.h
+++ b/gate.h
@@ -1,8 +1,7 @@
 #ifndef GATE_H
 #define GATE_H
 
-#define VG_3D
-#include "vg/vg.h"
+#include "common.h"
 #include "model.h"
 #include "render.h"
 #include "shaders/gate.h"
@@ -62,8 +61,8 @@ static void gate_init(void)
 {
    fb_init( &grender.fb );
 
-   model *mgate = vg_asset_read( "models/rs_gate.mdl" );
-   model_unpack( mgate, &grender.mdl );
+   mdl_header *mgate = mdl_load( "models/rs_gate.mdl" );
+   mdl_unpack_glmesh( mgate, &grender.mdl );
    free( mgate );
 }
 
@@ -72,7 +71,7 @@ static void gate_fb_resize(void)
    fb_resize( &grender.fb );
 }
 
-static void render_gate( teleport_gate *gate, m4x3f camera )
+static int render_gate( teleport_gate *gate, m4x3f camera )
 {
    v3f viewpos, viewdir, gatedir;
    v3_copy( camera[3], viewpos );
@@ -82,10 +81,10 @@ static void render_gate( teleport_gate *gate, m4x3f camera )
    v3f v0;
    v3_sub( viewpos, gate->co[0], v0 );
    if( v3_dot(v0, gatedir) >= 0.0f )
-      return;
+      return 0;
 
    if( v3_dist( viewpos, gate->co[0] ) > 100.0f )
-      return;
+      return 0;
 
    v3f a,b,c,d;
 
@@ -162,7 +161,7 @@ static void render_gate( teleport_gate *gate, m4x3f camera )
    }
 
    render_world( projection, cam_new );
-   
+
    if( grender.high_qual )
    {
       /*
@@ -202,10 +201,20 @@ static void render_gate( teleport_gate *gate, m4x3f camera )
    }
    else
    {
+      glDisable( GL_STENCIL_TEST );
+
+      render_water_texture( cam_new );
+      fb_use( NULL );
+      glEnable( GL_STENCIL_TEST );
+
+      render_water_surface( projection, cam_new );
+
       glStencilMask( 0xFF );
       glStencilFunc( GL_ALWAYS, 1, 0xFF );
       glDisable( GL_STENCIL_TEST );
    }
+
+   return 1;
 }
 
 static int gate_intersect( teleport_gate *gate, v3f pos, v3f last )
@@ -224,7 +233,7 @@ static int gate_intersect( teleport_gate *gate, v3f pos, v3f last )
 
    float d = v3_dot(surface, v0);
 
-   if( fabsf(d) > 0.00001f )
+   if( d > 0.00001f )
    {
       float t = v3_dot(delta, surface) / d;
       if( t >= 0.0f && t <= l )