projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
df shadows
[carveJwlIkooP6JGAAIwe30JlM.git]
/
world_gate.h
diff --git
a/world_gate.h
b/world_gate.h
index 3e35081e2b1c72639bfa510a9196eb4da04fc706..f83cd87a24dd0455a8fea06bf667ba571c896921 100644
(file)
--- a/
world_gate.h
+++ b/
world_gate.h
@@
-52,7
+52,11
@@
VG_STATIC int render_gate( teleport_gate *gate, camera *cam )
v3f v0;
v3_sub( cam->pos, gate->co[0], v0 );
v3f v0;
v3_sub( cam->pos, gate->co[0], v0 );
- if( v3_dot(v0, gatedir) >= 0.0f )
+
+ float dist = v3_dot(v0, gatedir);
+
+ /* Hard cutoff */
+ if( dist > 3.0f )
return 0;
if( v3_dist( cam->pos, gate->co[0] ) > 100.0f )
return 0;
if( v3_dist( cam->pos, gate->co[0] ) > 100.0f )
@@
-80,7
+84,7
@@
VG_STATIC int render_gate( teleport_gate *gate, camera *cam )
static camera gate_view;
gate_view.fov = cam->fov;
gate_view.nearz = 0.1f;
static camera gate_view;
gate_view.fov = cam->fov;
gate_view.nearz = 0.1f;
- gate_view.farz =
9
00.0f;
+ gate_view.farz =
20
00.0f;
m4x3_mul( gate->transport, cam->transform, gate_view.transform );
camera_update_view( &gate_view );
m4x3_mul( gate->transport, cam->transform, gate_view.transform );
camera_update_view( &gate_view );
@@
-93,7
+97,9
@@
VG_STATIC int render_gate( teleport_gate *gate, camera *cam )
m4x3_mulp( gate_view.transform_inverse, surface, surface );
surface[3] = -fabsf(surface[3]);
m4x3_mulp( gate_view.transform_inverse, surface, surface );
surface[3] = -fabsf(surface[3]);
- m4x4_clip_projection( gate_view.mtx.p, surface );
+
+ if( dist < -0.5f )
+ m4x4_clip_projection( gate_view.mtx.p, surface );
/* Ready to draw with new camrea */
camera_finalize( &gate_view );
/* Ready to draw with new camrea */
camera_finalize( &gate_view );
@@
-146,7
+152,8
@@
VG_STATIC int render_gate( teleport_gate *gate, camera *cam )
return 1;
}
return 1;
}
-VG_STATIC int gate_intersect( teleport_gate *gate, v3f pos, v3f last )
+VG_STATIC int gate_intersect_plane( teleport_gate *gate, v3f pos, v3f last,
+ v2f where )
{
v4f surface;
m3x3_mulv( gate->to_world, (v3f){0.0f,0.0f,-1.0f}, surface );
{
v4f surface;
m3x3_mulv( gate->to_world, (v3f){0.0f,0.0f,-1.0f}, surface );
@@
-179,12
+186,25
@@
VG_STATIC int gate_intersect( teleport_gate *gate, v3f pos, v3f last )
m3x3_mulv( gate->to_world, (v3f){0.0f,1.0f,0.0f}, vup );
m3x3_mulv( gate->to_world, (v3f){1.0f,0.0f,0.0f}, vside );
m3x3_mulv( gate->to_world, (v3f){0.0f,1.0f,0.0f}, vup );
m3x3_mulv( gate->to_world, (v3f){1.0f,0.0f,0.0f}, vside );
- v2f xy = { v3_dot( rel, vside ), v3_dot( rel, vup ) };
+ where[0] = v3_dot( rel, vside );
+ where[1] = v3_dot( rel, vup );
- if( fabsf(xy[0]) <= gate->dims[0] && fabsf(xy[1]) <= gate->dims[1] )
- {
- return 1;
- }
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+VG_STATIC int gate_intersect( teleport_gate *gate, v3f pos, v3f last )
+{
+ v2f xy;
+
+ if( gate_intersect_plane( gate, pos, last, xy ) )
+ {
+ if( fabsf(xy[0]) <= gate->dims[0] && fabsf(xy[1]) <= gate->dims[1] )
+ {
+ return 1;
}
}
}
}