Index: Myth2Code/connectors.c
===================================================================
--- Myth2Code/connectors.c	(revision 4486)
+++ Myth2Code/connectors.c	(working copy)
@@ -585,7 +585,7 @@
 	struct sequence_frame_data *frame= get_sequence_frame(sequence, collection_index, sequence_index, 0);
 	struct bitmap_instance_data *bitmap_instance= get_bitmap_instance(collection_index, get_sequence_frame_bitmap_instance_indexes(frame)[0]);
 	world_point3d tl, tr, bl, br;
-	short_world_point3d transformed_tl, transformed_tr, transformed_bl, transformed_br;
+	world_point3d transformed_tl, transformed_tr, transformed_bl, transformed_br;
 
 	set_world_point3d(&tl, p0->x, p0->y, p0->z - bitmap_instance->world_top);
 	set_world_point3d(&bl, p0->x, p0->y, p0->z + bitmap_instance->world_bottom);
Index: Myth2Code/geometry_definitions.c
===================================================================
--- Myth2Code/geometry_definitions.c	(revision 4486)
+++ Myth2Code/geometry_definitions.c	(working copy)
@@ -203,9 +203,10 @@
 	dispose_definitions_from_old_map(&geometries);
 }
 
-static short_world_point3d *transform_model_point3d(short_world_point3d *result,
+static world_point3d *transform_model_point3d(world_point3d *result,
 	matrix3x3 *rotation, world_point3d *viewer, world_point3d *point);
-
+static short_world_point3d *transform_model_point3d_short_GAMEPLAY(short_world_point3d *result,
+	matrix3x3 *rotation, world_point3d *viewer, world_point3d *point);
 static void scale_matrix(matrix3x3 *m, world_vector3d *scale_vector);
 short world_matrix_cofactor(matrix3x3 *m, int i, int j);
 short world_matrix_determinant(matrix3x3 *m);
@@ -243,7 +244,7 @@
 	world_point3d *result)
 {
 	world_point3d geometry_center, geometry_space_pt;
-	short_world_point3d pt;
+	world_point3d pt;
 
 	// do ridiculous transformations from short_world_point3d to world_point3d
 	geometry_center.x= center->x;
@@ -276,12 +277,54 @@
 	return;
 }
 
+// models may be rotated...
+void transform_geometry_point_to_world_short_GAMEPLAY(
+	world_point3d *origin,
+	short_world_point3d *center,
+	short_world_point3d *p,
+	matrix3x3 *geometry_to_world_matrix,
+	world_point3d *result)
+{
+	world_point3d geometry_center, geometry_space_pt;
+	short_world_point3d pt;
+
+	// do ridiculous transformations from short_world_point3d to world_point3d
+	geometry_center.x= center->x;
+	geometry_center.y= center->y;
+	geometry_center.z= center->z;
+
+	geometry_space_pt.x= p->x;
+	geometry_space_pt.y= p->y;
+	geometry_space_pt.z= p->z;
+
+	// don't rotate on identity matrix
+	if(geometry_to_world_matrix->n[0][0]==WORLD_ONE &&
+		geometry_to_world_matrix->n[1][1]==WORLD_ONE &&
+		geometry_to_world_matrix->n[2][2]==WORLD_ONE)
+	{
+		pt.x= geometry_space_pt.x - geometry_center.x;
+		pt.y= geometry_space_pt.y - geometry_center.y;
+		pt.z= geometry_space_pt.z - geometry_center.z;
+	} else {
+		transform_model_point3d_short_GAMEPLAY(&pt, geometry_to_world_matrix, &geometry_center, &geometry_space_pt);
+	}
+
+//	*** MATH ERROR! Fix is below... but it could fuck everything up.
+/*	result->x= pt.x + origin->x + center->x;
+	result->y= pt.y + origin->y + center->y;
+	result->z= pt.z + origin->z + center->z;*/
+	result->x= pt.x + origin->x;
+	result->y= pt.y + origin->y;
+	result->z= pt.z + origin->z;
+	return;
+}
+
 void transform_world_point_to_geometry(
-	world_point3d *origin, 
+	world_point3d *origin,
 	short_world_point3d *center,
-	world_point3d *p, 
-	matrix3x3 *world_to_geometry_matrix, 
-	short_world_point3d *result)
+	world_point3d *p,
+	matrix3x3 *world_to_geometry_matrix,
+	world_point3d *result)
 {
 	world_point3d modified_geometry_origin= *origin;
 
@@ -307,6 +350,37 @@
 	return;
 }
 
+void transform_world_point_to_geometry_short_GAMEPLAY(
+	world_point3d *origin,
+	short_world_point3d *center,
+	world_point3d *p,
+	matrix3x3 *world_to_geometry_matrix,
+	short_world_point3d *result)
+{
+	world_point3d modified_geometry_origin= *origin;
+
+//	*** MATH ERROR! Fix is to remove the following line... but it could fuck everything up.
+//	modified_geometry_origin.x+= center->x; modified_geometry_origin.y+= center->y; modified_geometry_origin.z+= center->z;
+
+	// donÕt rotate on identity matrix
+	if(world_to_geometry_matrix->n[0][0]==WORLD_ONE &&
+		world_to_geometry_matrix->n[1][1]==WORLD_ONE &&
+		world_to_geometry_matrix->n[2][2]==WORLD_ONE)
+	{
+		result->x= p->x - modified_geometry_origin.x;
+		result->y= p->y - modified_geometry_origin.y;
+		result->z= p->z - modified_geometry_origin.z;
+	} else {
+		transform_model_point3d_short_GAMEPLAY(result, world_to_geometry_matrix, &modified_geometry_origin, p);
+	}
+
+	result->x+= center->x;
+	result->y+= center->y;
+	result->z+= center->z;
+
+	return;
+}
+
 world_vector3d *rotate_model_vector(
 	world_vector3d *result,
 	matrix3x3 *rotation,
@@ -319,12 +393,6 @@
 	temp.j= (dx*rotation->n[0][1] + dy*rotation->n[1][1] + dz*rotation->n[2][1])>>WORLD_FRACTIONAL_BITS;
 	temp.k= (dx*rotation->n[0][2] + dy*rotation->n[1][2] + dz*rotation->n[2][2])>>WORLD_FRACTIONAL_BITS;
 
-//	vwarn(x>SHORT_MIN && x<SHORT_MAX && y>SHORT_MIN && y<SHORT_MAX && z>SHORT_MIN && z<SHORT_MAX,
-//		csprintf(temporary, "v(#%d,#%d,#%d) r(#%d,#%d,#%d)", 
-//		source->i, source->j, source->k, x, y, z));
-
-//	dprintf("p(#%d,#%d,#%d) o(#%d,#%d,#%d) r(#%d,#%d,#%d)", point->x, point->y, point->z,
-//		viewer->x, viewer->y, viewer->z, x, y, z);
 	*result= temp;
 
 	return result;
@@ -481,33 +549,33 @@
 	return geometries.count;
 }
 
-static short_world_point3d *transform_model_point3d(
+static world_point3d *transform_model_point3d(
+	world_point3d *result,
+	matrix3x3 *rotation,
+	world_point3d *viewer,
+	world_point3d *point)
+{
+	int dx= point->x - viewer->x, dy= point->y - viewer->y, dz= point->z - viewer->z;
+
+	result->x= (dx*rotation->n[0][0] + dy*rotation->n[1][0] + dz*rotation->n[2][0])>>WORLD_FRACTIONAL_BITS;
+	result->y= (dx*rotation->n[0][1] + dy*rotation->n[1][1] + dz*rotation->n[2][1])>>WORLD_FRACTIONAL_BITS;
+	result->z= (dx*rotation->n[0][2] + dy*rotation->n[1][2] + dz*rotation->n[2][2])>>WORLD_FRACTIONAL_BITS;
+
+	return result;
+}
+
+static short_world_point3d *transform_model_point3d_short_GAMEPLAY(
 	short_world_point3d *result,
 	matrix3x3 *rotation,
 	world_point3d *viewer,
 	world_point3d *point)
 {
 	int dx= point->x - viewer->x, dy= point->y - viewer->y, dz= point->z - viewer->z;
-	
-//	vwarn(dx>SHORT_MIN && dx<SHORT_MAX && dy>SHORT_MIN && dy<SHORT_MAX && dz>SHORT_MIN && dz<SHORT_MAX,
-//		csprintf(temporary, "p(#%d,#%d,#%d) o(#%d,#%d,#%d) ¶(#%d,#%d,#%d)", point->x, point->y, point->z,
-//		viewer->x, viewer->y, viewer->z, dx, dy, dz));
 
 	result->x= (dx*rotation->n[0][0] + dy*rotation->n[1][0] + dz*rotation->n[2][0])>>WORLD_FRACTIONAL_BITS;
 	result->y= (dx*rotation->n[0][1] + dy*rotation->n[1][1] + dz*rotation->n[2][1])>>WORLD_FRACTIONAL_BITS;
 	result->z= (dx*rotation->n[0][2] + dy*rotation->n[1][2] + dz*rotation->n[2][2])>>WORLD_FRACTIONAL_BITS;
 
-#ifdef DEBUG
-//	if(x<SHORT_MIN || x>SHORT_MAX || y<SHORT_MIN || y>SHORT_MAX || z<SHORT_MIN || z>SHORT_MAX)
-//	{
-//		dprintf("p(#%d,#%d,#%d) o(#%d,#%d,#%d) r(#%d,#%d,#%d);g", point->x, point->y, point->z,
-//			viewer->x, viewer->y, viewer->z, x, y, z);
-//		dprintf_matrix("Matrix:", rotation);
-//	}
-#endif
-//	dprintf("p(#%d,#%d,#%d) o(#%d,#%d,#%d) r(#%d,#%d,#%d)", point->x, point->y, point->z,
-//		viewer->x, viewer->y, viewer->z, x, y, z);
-
 	return result;
 }
 
Index: Myth2Code/geometry_definitions.h
===================================================================
--- Myth2Code/geometry_definitions.h	(revision 4486)
+++ Myth2Code/geometry_definitions.h	(working copy)
@@ -193,7 +193,11 @@
 // because collision detection (models.c) and drawing need this (render_models.c)
 void transform_geometry_point_to_world(world_point3d *origin, short_world_point3d *center,
 	short_world_point3d *p, matrix3x3 *geometry_to_world_matrix, world_point3d *result);
+void transform_geometry_point_to_world_short_GAMEPLAY(world_point3d *origin, short_world_point3d *center,
+	short_world_point3d *p, matrix3x3 *geometry_to_world_matrix, world_point3d *result);
 void transform_world_point_to_geometry(world_point3d *origin, short_world_point3d *center,
+	world_point3d *p, matrix3x3 *world_to_geometry_matrix, world_point3d *result);
+void transform_world_point_to_geometry_short_GAMEPLAY(world_point3d *origin, short_world_point3d *center,
 	world_point3d *p, matrix3x3 *world_to_geometry_matrix, short_world_point3d *result);
 void get_geometry_matrices(world_vector3d *rotation_vector,
 	world_vector3d *up_vector,
Index: Myth2Code/hardware/OpenGL/render_opengl.c
===================================================================
--- Myth2Code/hardware/OpenGL/render_opengl.c	(revision 4486)
+++ Myth2Code/hardware/OpenGL/render_opengl.c	(working copy)
@@ -58,8 +58,8 @@
 // disable Myth-Z for models. (Reduces model/sprite clipping issues.)
 #define VERTICAL_SPRITE_DEPTHS 1
 
-#define GL_POSITION_TYPE GL_SHORT
-typedef GLshort GLposition;
+#define GL_POSITION_TYPE GL_INT
+typedef GLint GLposition;
 #define POSITION_ONE WORLD_ONE
 #define ConvertPosition(x) ((GLposition)(x))
 
@@ -2221,7 +2221,7 @@
 	}
 }
 
-/*
+
 static void frustum_debug(struct view_data *view)
 {
 	int i, r;
@@ -2331,7 +2331,7 @@
 			submit_line_opengl();
 		}
 	}
-}*/
+}
 
 void rasterize_scene_opengl(
 	struct view_data *view,
Index: Myth2Code/hardware/OpenGL/utilities_opengl.c
===================================================================
--- Myth2Code/hardware/OpenGL/utilities_opengl.c	(revision 4486)
+++ Myth2Code/hardware/OpenGL/utilities_opengl.c	(working copy)
@@ -514,7 +514,7 @@
 	if(!(texture->flags & _texture_anisotropic_flag) &&
 		texture->mipmap_count > 1)
 	{
-		const int log_min_pixels = 5; // 32 pixels
+		const int log_min_pixels = 0; // 32 pixels
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, texture->mipmap_count - log_min_pixels);
 	}
 
Index: Myth2Code/interface.c
===================================================================
--- Myth2Code/interface.c	(revision 4486)
+++ Myth2Code/interface.c	(working copy)
@@ -511,7 +511,7 @@
 	world_point3d *p,
 	point2d *screen_point)
 {
-	short_world_point3d vertex;
+	world_point3d vertex;
 
 	transform_point3d(&vertex, &(view->world_to_viewer_rotation), &(view->location.position), p);
 	transform_view_point_to_screen_space(view, &vertex, screen_point);
Index: Myth2Code/lightning.c
===================================================================
--- Myth2Code/lightning.c	(revision 4486)
+++ Myth2Code/lightning.c	(working copy)
@@ -753,7 +753,7 @@
 	short type)
 {
 	boolean is_reflection= (reflective_cell != NULL);
-	short_world_point3d transformed_position, next_transformed_position;
+	world_point3d transformed_position, next_transformed_position;
 
 	// Offset particle to the viewer's box and transform particle origin into viewer space
 	transform_world_point_to_viewer_space(view, last_point, &transformed_position, is_reflection);
@@ -841,8 +841,8 @@
 	struct sequence_frame_data *frame = get_sequence_frame(sequence, local_lightning->collection_index, sequence_index, 0);
 	if(frame->shadow_map_index != NONE)
 	{
-		short_world_distance height = current_point->z - get_true_height((world_point2d *)current_point);
-		short_world_distance apparent_height = height/4; // this division appears to be a hack to make lightning brighter.
+		world_distance height = current_point->z - get_true_height((world_point2d *)current_point);
+		world_distance apparent_height = height/4; // this division appears to be a hack to make lightning brighter.
 		build_render_map_overlay(view, region, local_lightning->collection_index, frame->shadow_map_index,
 			_transfer_mode_none, 0, current_point, apparent_height, FIXED_ONE-1);
 	}
Index: Myth2Code/local_projectiles.c
===================================================================
--- Myth2Code/local_projectiles.c	(revision 4486)
+++ Myth2Code/local_projectiles.c	(working copy)
@@ -852,9 +852,9 @@
 		}
 	}
 
-	if (distance2d((world_point2d *)&location, (world_point2d *)(&view->location.position))<MAXIMUM_VIEWER_TO_OBJECT_DISTANCE)
+	//if (distance2d((world_point2d *)&location, (world_point2d *)(&view->location.position))<MAXIMUM_VIEWER_TO_OBJECT_DISTANCE)
 	{
-		short_world_point3d transformed_position;
+		world_point3d transformed_position;
 		struct object_render_data render_data;
 		
 		{
@@ -1009,7 +1009,7 @@
 				
 				if (x0<x1 && y0<y1 && x1>0 && x0<view->screen_width && y1>0 && y0<view->screen_height)
 				{	
-					struct render_rectangle *rectangle= (struct render_rectangle*)new_render_rectangle();
+					struct render_rectangle *rectangle= new_render_rectangle();
 
 					// initialize rectangle
 					rectangle->viewer_rect.left = viewer_left;
Index: Myth2Code/mesh.h
===================================================================
--- Myth2Code/mesh.h	(revision 4486)
+++ Myth2Code/mesh.h	(working copy)
@@ -78,7 +78,7 @@
 	VOLATILE_TEXTURE_WIDTH_CHUNKS = 1<<VOLATILE_TEXTURE_WIDTH_CHUNKS_BITS,
 	VOLATILE_TEXTURE_CHUNK_ADDRESS_DOWNSHIFT = VOLATILE_TEXTURE_CHUNK_WIDTH_BITS-SUBMESH_CELL_TEXTURE_WIDTH_BITS,
 
-	TILE_CACHE_TEXTURE_WIDTH = 1024,
+	TILE_CACHE_TEXTURE_WIDTH = 4096,
 
 	// each tile is 14x14 cells (figured so that CACHE_TILE_TEXTURE_WIDTH is a power of 2)
 	CACHE_TILE_CELLS = 14,
Index: Myth2Code/mesh_effects.c
===================================================================
--- Myth2Code/mesh_effects.c	(revision 4486)
+++ Myth2Code/mesh_effects.c	(working copy)
@@ -390,8 +390,8 @@
 	struct mesh_effect_data *mesh_effect)
 {
 	struct mesh_effect_definition *definition= get_mesh_effect_definition(mesh_effect->type);
-	short_world_point3d view_inner_points[MAXIMUM_RADIAL_POINTS];
-	short_world_point3d view_outer_points[MAXIMUM_RADIAL_POINTS];
+	world_point3d view_inner_points[MAXIMUM_RADIAL_POINTS];
+	world_point3d view_outer_points[MAXIMUM_RADIAL_POINTS];
 	point2d screen_inner_points[MAXIMUM_RADIAL_POINTS];
 	point2d screen_outer_points[MAXIMUM_RADIAL_POINTS];
 	
Index: Myth2Code/model_animations.c
===================================================================
--- Myth2Code/model_animations.c	(revision 4486)
+++ Myth2Code/model_animations.c	(working copy)
@@ -478,7 +478,7 @@
 				int frame_offset= animation->current_frame_index * definition->shadow_map_height * definition->shadow_bytes_per_row;
 				byte *frame= definition->shadow_maps + frame_offset;
 
-				struct render_map_overlay *overlay= (struct render_map_overlay*)new_render_map_overlay();
+				struct render_map_overlay *overlay= new_render_map_overlay();
 
 				overlay->pixels= frame;
 				overlay->width= definition->shadow_map_width;
Index: Myth2Code/models.c
===================================================================
--- Myth2Code/models.c	(revision 4486)
+++ Myth2Code/models.c	(working copy)
@@ -486,10 +486,10 @@
 		matrix3x3 *g_to_w= &model->geometry_to_world_matrix;
 
 		// transform points into geometry space...
-		transform_world_point_to_geometry(&model->location, &geometry->center, new_position, 
-			w_to_g, &new_point_in_geometry_space);
-		transform_world_point_to_geometry(&model->location, &geometry->center, old_position, 
-			w_to_g, &old_point_in_geometry_space);
+		transform_world_point_to_geometry_short_GAMEPLAY(&model->location, &geometry->center,
+			new_position, w_to_g, &new_point_in_geometry_space);
+		transform_world_point_to_geometry_short_GAMEPLAY(&model->location, &geometry->center,
+			old_position, w_to_g, &old_point_in_geometry_space);
 
 		// find the surface impacted...
 		surface_collided_index= find_surface_collided(geometry, &new_point_in_geometry_space, &old_point_in_geometry_space, &collision_point_in_geometry_space);
@@ -522,7 +522,7 @@
 			}
 
 			// set the new_position to the collision point...
-			transform_geometry_point_to_world(&model->location, &geometry->center, 
+			transform_geometry_point_to_world_short_GAMEPLAY(&model->location, &geometry->center, 
 				&collision_point_in_geometry_space, g_to_w, new_position);
 
 			// we hit him...
@@ -587,8 +587,8 @@
 		{
 			// check the surface equation of this surface...
 			// first check- if the two points are on opposite sides of the surface...
-			int old_cell_side= point_in_plane_test(&surface->normal, surface->d, old_point);
-			int new_cell_side= point_in_plane_test(&surface->normal, surface->d, new_point);
+			int old_cell_side= point_in_plane_test_short_GAMEPLAY(&surface->normal, surface->d, old_point);
+			int new_cell_side= point_in_plane_test_short_GAMEPLAY(&surface->normal, surface->d, new_point);
 
 			// if we changed sides of this plane...
 			if (SGN(old_cell_side) != SGN(new_cell_side))
@@ -951,7 +951,7 @@
 		p.y= INTEGER_TO_WORLD(model_cell->y) + WORLD_ONE_HALF;
 		p.z= 0;
 
-		transform_geometry_point_to_world(&model->location, &geometry->center, &p,
+		transform_geometry_point_to_world_short_GAMEPLAY(&model->location, &geometry->center, &p,
 			&model->geometry_to_world_matrix, &result);
 		
 		x= WORLD_TO_INTEGER(result.x);
@@ -1099,7 +1099,7 @@
 			world_point3d result;
 
 			// transform the geometry_point to world space.		
-			transform_geometry_point_to_world(&model->location, &geometry->center, &vertex->p,
+			transform_geometry_point_to_world_short_GAMEPLAY(&model->location, &geometry->center, &vertex->p,
 				&model->geometry_to_world_matrix, &result);
 
 //dprintf("p: %d %d %d became %d %d %d", vertex->p.x, vertex->p.y, vertex->p.z, result.x, result.y, result.z);
@@ -1237,9 +1237,9 @@
 	struct geometry_definition *geometry= get_geometry_definition(definition->geometry_index);
 
 	// transform bounds into world space...
-	transform_geometry_point_to_world(&model->location, &geometry->center, &geometry->bounds.minimum_corner, 
+	transform_geometry_point_to_world_short_GAMEPLAY(&model->location, &geometry->center, &geometry->bounds.minimum_corner, 
 		&model->geometry_to_world_matrix, &model->bounds.minimum_corner);
-	transform_geometry_point_to_world(&model->location, &geometry->center, &geometry->bounds.maximum_corner, 
+	transform_geometry_point_to_world_short_GAMEPLAY(&model->location, &geometry->center, &geometry->bounds.maximum_corner, 
 		&model->geometry_to_world_matrix, &model->bounds.maximum_corner);
 		
 	return;
Index: Myth2Code/observer.c
===================================================================
--- Myth2Code/observer.c	(revision 4486)
+++ Myth2Code/observer.c	(working copy)
@@ -38,7 +38,7 @@
 
 #include <string.h>
 
-//#define FREE_CAMERA_HACK
+#define FREE_CAMERA_HACK
 
 /* ---------- constants */
 
@@ -935,7 +935,7 @@
 				variables->location.yaw = real_angle_normalize(variables->location.yaw + k*delta_x);
 				variables->location.pitch = real_angle_normalize(variables->location.pitch + k*delta_y);
 			}
-
+/*
 #ifdef windows
 			{
 				char text[256];
@@ -950,7 +950,7 @@
 					SetWindowText(screen_window, text);
 				}
 			}
-#endif // windows
+#endif // windows*/
 
 			return;
 		}
Index: Myth2Code/particle_systems.c
===================================================================
--- Myth2Code/particle_systems.c	(revision 4486)
+++ Myth2Code/particle_systems.c	(working copy)
@@ -355,7 +355,7 @@
 					particle_index>=0;
 					particle_index= particle->next_in_cell)
 				{
-					short_world_point3d transformed_position;
+					world_point3d transformed_position;
 					int dx, dy, dz;
 
 					particle= get_particle_data(particle_index);
Index: Myth2Code/render/render.c
===================================================================
--- Myth2Code/render/render.c	(revision 4486)
+++ Myth2Code/render/render.c	(working copy)
@@ -295,7 +295,7 @@
 void transform_world_point_to_viewer_space(
 	struct view_data *view,
 	const world_point3d *pt,
-	short_world_point3d *transformed_pt,
+	world_point3d *transformed_pt,
 	boolean is_reflection)
 {
 	int dx= pt->x - view->location.position.x;
Index: Myth2Code/render/render.h
===================================================================
--- Myth2Code/render/render.h	(revision 4486)
+++ Myth2Code/render/render.h	(working copy)
@@ -91,7 +91,7 @@
 {
 	word flags;
 	point2d mesh_vertex;
-	short_world_point3d p; // viewer-space
+	world_point3d p; // viewer-space
 	point2d screen;
 };
 
@@ -188,7 +188,7 @@
 	world_distance precise_z; \
 	/* HACK: obj_view_y is the view space y position of the object, used for rectangles only. \
 		It's here because there were some bytes available */ \
-	short_world_distance obj_view_y,z; \
+	world_distance obj_view_y,z; \
 	fixed_fraction transparency; \
 	word flags:NUMBER_OF_SURFACE_FLAGS; \
 	word type:CEIL_LOG2_NUM_SURFACE_TYPES; \
@@ -467,7 +467,7 @@
 boolean cell_region_visibility_test(struct mesh_region *region, int cell_x, int cell_y, boolean *tile_only);
 
 void transform_world_point_to_viewer_space(struct view_data *view,
-	const world_point3d *pt, short_world_point3d *transformed_pt, boolean is_reflection);	
+	const world_point3d *pt, world_point3d *transformed_pt, boolean is_reflection);	
 
 // transform_world_point_to_viewer_space(struct view_data *view, short_world_point3d *view_pt, point2d screen_pt);	
 #define transform_view_point_to_screen_space(view, view_pt, screen_pt) \
Index: Myth2Code/render/render_clip.c
===================================================================
--- Myth2Code/render/render_clip.c	(revision 4486)
+++ Myth2Code/render/render_clip.c	(working copy)
@@ -34,59 +34,49 @@
 		int y= view->yk + (vertex->p.y * world_to_screen);
 		
 		assert(VERTEX_IS_EXTANT(vertex));
-	
-//		dprintf("(#%d,#%d,#%d) ==> (#%d,#%d)", vertex->p.x, vertex->p.y, vertex->p.z, x, y);
-	
-//		if (x>SHORT_MIN && x<SHORT_MAX && y>SHORT_MIN && y<SHORT_MAX)
-		if (x == (short) x && y == (short) y)
+
+		// top
+		if (flags&_vertex_on_top_flag)
 		{
-			// top
-			if (flags&_vertex_on_top_flag)
-			{
-				y= 0;
-			}
-			else
-			{
-				if (y<=0) flags|= _vertex_out_top_flag;
-			}
-			
-			// bottom
-			if (flags&_vertex_on_bottom_flag)
-			{
-				y= view->screen_height;
-			}
-			else
-			{
-				if (y>=view->screen_height) flags|= _vertex_out_bottom_flag;
-			}
-			
-			// left
-			if (flags&_vertex_on_left_flag)
-			{
-				x= 0;
-			}
-			else
-			{
-				if (x<=0) flags|= _vertex_out_left_flag;
-			}
-			
-			// right
-			if (flags&_vertex_on_right_flag)
-			{
-				x= view->screen_width;
-			}
-			else
-			{
-				if (x>=view->screen_width) flags|= _vertex_out_right_flag;
-			}
-		
-			vertex->screen.x= x;
-			vertex->screen.y= y;
+			y= 0;
 		}
 		else
 		{
-			flags|= _vertex_discarded_flag;
+			if (y<=0) flags|= _vertex_out_top_flag;
 		}
+
+		// bottom
+		if (flags&_vertex_on_bottom_flag)
+		{
+			y= view->screen_height;
+		}
+		else
+		{
+			if (y>=view->screen_height) flags|= _vertex_out_bottom_flag;
+		}
+
+		// left
+		if (flags&_vertex_on_left_flag)
+		{
+			x= 0;
+		}
+		else
+		{
+			if (x<=0) flags|= _vertex_out_left_flag;
+		}
+
+		// right
+		if (flags&_vertex_on_right_flag)
+		{
+			x= view->screen_width;
+		}
+		else
+		{
+			if (x>=view->screen_width) flags|= _vertex_out_right_flag;
+		}
+
+		vertex->screen.x= x;
+		vertex->screen.y= y;
 	}
 	else
 	{
@@ -135,27 +125,7 @@
 				}
 			}
 		}
-		else
-		{
-			/*
-			if (SURFACE_IS_POLYGON(surface))
-			{
-			int and_flags= _vertex_out_flags, or_flags= 0;
-			int vertex_index;
 
-			for (vertex_index= 0; vertex_index<((struct render_polygon *)surface)->vertex_count; ++vertex_index)
-			{
-			struct render_vertex *vertex= get_render_polygon_vertices(surface)[vertex_index];
-
-			if (!VERTEX_IS_CLIPPED(vertex)) clip_affine_vertex_to_all_planes(view, vertex);
-			and_flags&= vertex->flags, or_flags|= vertex->flags;
-			}
-
-			if (and_flags || (or_flags&_vertex_discarded_flag)) discarded= TRUE;
-			}
-			*/
-		}
-
 		if (discarded) surface->flags|= _surface_discarded_flag;
 	}
 }
Index: Myth2Code/render/render_geometry.c
===================================================================
--- Myth2Code/render/render_geometry.c	(revision 4486)
+++ Myth2Code/render/render_geometry.c	(working copy)
@@ -24,7 +24,7 @@
 
 struct cached_vertex {
 	short in_visible_region;
-	short_world_point3d view;
+	world_point3d view;
 };
 
 static struct cached_vertex transformed_vertices[MAXIMUM_VERTICES_PER_GEOMETRY];
@@ -37,10 +37,10 @@
 
 static struct render_surface *submit_render_surface(struct view_data *view, int surface_index,
 	struct geometry_surface *surface, struct geometry_material *material,
-	short_world_point3d *view_vertex[VERTICES_PER_TRIANGLE], int model_index, boolean reflection,
+	world_point3d *view_vertex[VERTICES_PER_TRIANGLE], int model_index, boolean reflection,
 	fixed_fraction geometry_transparency);
 
-static void	sort_geometry_surface_list(struct geometry_definition *geometry);
+static void sort_geometry_surface_list(struct geometry_definition *geometry);
 
 /* ------------- code */
 
@@ -64,7 +64,7 @@
 	int index;
 	matrix3x3 geometry_to_world_matrix, world_to_geometry_matrix;
 
-	short_world_point3d	viewer_in_geometry_space;
+	world_point3d viewer_in_geometry_space;
 	world_point3d adjusted_viewer;
 
 	assert(view);
@@ -120,7 +120,7 @@
 		if(side>0 || (surface->flags & _geometry_surface_no_backface_cull_flag))
 		{
 			// Check the corners of the surface and see if we should render it.
-			short_world_point3d *view_vertex[VERTICES_PER_TRIANGLE];
+			world_point3d *view_vertex[VERTICES_PER_TRIANGLE];
 			struct cached_vertex *c0= &transformed_vertices[surface->corners[0].vertex_index];
 			struct cached_vertex *c1= &transformed_vertices[surface->corners[1].vertex_index];
 			struct cached_vertex *c2= &transformed_vertices[surface->corners[2].vertex_index];
@@ -146,7 +146,7 @@
 
 				{
 					struct render_surface * rsurf = submit_render_surface(view, index, surface,
-						material, view_vertex, model_index,	reflection, geometry_transparency);
+						material, view_vertex, model_index, reflection, geometry_transparency);
 					if(whole_model_transparent_hack_required && rsurf)
 					{
 						whole_model_transparent_hack|= rsurf->flags & _surface_transparent_flag;
@@ -256,54 +256,21 @@
 			}
 		}
 
-		transformed_vertex->in_visible_region= FALSE;			
+		transformed_vertex->in_visible_region= FALSE;
 
-/*		// Transform vertex into view space
-		{
-			int dx= geometry_world_point.x - view->location.position.x;
-			int dy= geometry_world_point.y - view->location.position.y;
-			int dz= geometry_world_point.z - view->location.position.z;
-			
-			if (dx>SHORT_MIN && dx<SHORT_MAX && dy>SHORT_MIN && dy<SHORT_MAX && dz>SHORT_MIN && dz<SHORT_MAX)
-			{
-				int x, y, z;
-				matrix3x3 *rotation= &view->world_to_viewer_rotation;
-
-				transformed_vertex->view.x= x= (dx*rotation->n[0][0] + dy*rotation->n[1][0] + dz*rotation->n[2][0])>>TRIG_BITS;
-				transformed_vertex->view.y= y= (dx*rotation->n[0][1] + dy*rotation->n[1][1] + dz*rotation->n[2][1])>>TRIG_BITS;
-				transformed_vertex->view.z= z= (dx*rotation->n[0][2] + dy*rotation->n[1][2] + dz*rotation->n[2][2])>>TRIG_BITS;
-			} else{
-				goto _vertex_is_invisible;
-			}
-		}
-*/
 		// Transform vertex into view space
 		{
 			int dx= geometry_world_point.x - view->location.position.x;
 			int dy= geometry_world_point.y - view->location.position.y;
 			int dz= geometry_world_point.z - view->location.position.z;
 
-			if (dx == (short) dx && dy == (short) dy && dz == (short) dz)
-			{
-				matrix3x3 *rotation= &view->world_to_viewer_rotation;
+			matrix3x3 *rotation= &view->world_to_viewer_rotation;
 
-				transformed_vertex->view.x= (dx*rotation->n[0][0] + dy*rotation->n[1][0] + dz*rotation->n[2][0])>>TRIG_BITS;
-				transformed_vertex->view.y= (dx*rotation->n[0][1] + dy*rotation->n[1][1] + dz*rotation->n[2][1])>>TRIG_BITS;
-				transformed_vertex->view.z= (dx*rotation->n[0][2] + dy*rotation->n[1][2] + dz*rotation->n[2][2])>>TRIG_BITS;
-			}
-			else
-			{
-				// Vertex is outside short space
-				goto _vertex_is_invisible;
-			}
+			transformed_vertex->view.x= (dx*rotation->n[0][0] + dy*rotation->n[1][0] + dz*rotation->n[2][0])>>TRIG_BITS;
+			transformed_vertex->view.y= (dx*rotation->n[0][1] + dy*rotation->n[1][1] + dz*rotation->n[2][1])>>TRIG_BITS;
+			transformed_vertex->view.z= (dx*rotation->n[0][2] + dy*rotation->n[1][2] + dz*rotation->n[2][2])>>TRIG_BITS;
 		}
 
-/*		if (transform_point3d(&transformed_vertex->view, &view->world_to_viewer_rotation,
-			&view->location.position, &geometry_world_point))
-		{
-			goto _vertex_is_invisible;
-		}*/
-
 		// Don't bother submitting surfaces which are behind the front viewing plane!
 		if (transformed_vertex->view.z < -MINIMUM_VIEW_DISTANCE) // -z away from viewer
 		{
@@ -335,7 +302,7 @@
 					
 					span++;
 				}
-			}				
+			}
 		}
 
 		_vertex_is_invisible: ;
@@ -354,7 +321,7 @@
 	int surface_index,
 	struct geometry_surface *surface,
 	struct geometry_material *material,
-	short_world_point3d *view_vertex[VERTICES_PER_TRIANGLE],
+	world_point3d *view_vertex[VERTICES_PER_TRIANGLE],
 	int model_index,
 	boolean reflection,
 	fixed_fraction geometry_transparency)
@@ -407,7 +374,7 @@
 	}
 
 	// copy corners and, when necessary, vertices
-	render_surface->z= ((surface->flags & _geometry_surface_uses_closest_z_flag) ? SHORT_MIN : SHORT_MAX);
+	render_surface->z= ((surface->flags & _geometry_surface_uses_closest_z_flag) ? INT_MIN : INT_MAX);
 
 	for (vertex_index= 0; vertex_index < VERTICES_PER_TRIANGLE; ++vertex_index, ++geometry_corner)
 	{
Index: Myth2Code/render/render_mesh.c
===================================================================
--- Myth2Code/render/render_mesh.c	(revision 4486)
+++ Myth2Code/render/render_mesh.c	(working copy)
@@ -31,7 +31,7 @@
 
 /* ---------- code */
 
-static const byte small_edge_vertex_indexes[4][4]=
+static const word small_edge_vertex_indexes[4][4]=
 {
 	{MAXIMUM_MESH_REGION_WIDTH+1, 2, 1, 0},
 	{MAXIMUM_MESH_REGION_WIDTH+1, 2*MAXIMUM_MESH_REGION_WIDTH+2, MAXIMUM_MESH_REGION_WIDTH+2, 2},
@@ -50,12 +50,12 @@
 };
 
 // every pair {[i],[(i+1) mod 4] gives an edge whose centre must be interpolated
-static const byte small_edge_windings[4]=
+static const word small_edge_windings[4]=
 {
 	0,2,2+2*MAXIMUM_MESH_REGION_WIDTH,2*MAXIMUM_MESH_REGION_WIDTH
 };
 
-static const byte large_edge_vertex_indexes[2][4]=
+static const word large_edge_vertex_indexes[2][4]=
 {
 	{2*MAXIMUM_MESH_REGION_WIDTH+2, 2, 0, 2*MAXIMUM_MESH_REGION_WIDTH},
 	{2, 0, 2*MAXIMUM_MESH_REGION_WIDTH, 2*MAXIMUM_MESH_REGION_WIDTH+2},
@@ -68,7 +68,7 @@
 };
 
 // every pair {[direction][i],[direction][i+1]} gives an edge whose centre must be interpolated
-static const byte large_edge_windings[2][6]=
+static const word large_edge_windings[2][6]=
 {
 	{2+2*MAXIMUM_MESH_REGION_WIDTH,2,0,2*MAXIMUM_MESH_REGION_WIDTH,2+2*MAXIMUM_MESH_REGION_WIDTH,0},
 	{2,0,2*MAXIMUM_MESH_REGION_WIDTH,2+2*MAXIMUM_MESH_REGION_WIDTH,2,2*MAXIMUM_MESH_REGION_WIDTH}
@@ -109,7 +109,7 @@
 		int flags = v0->flags | v1->flags | v2->flags;
 		if(!(flags & _vertex_discarded_flag))
 		{
-			struct render_triangle * triangle= (struct render_triangle*)new_render_triangle();
+			struct render_triangle *triangle= new_render_triangle();
 
 			triangle->corners[0].vertex = v0;
 			triangle->corners[1].vertex = v1;
@@ -255,7 +255,7 @@
 
 				for (edge_index= 0; edge_index<4; ++edge_index)
 				{
-					const byte *vertex_indexes= small_edge_vertex_indexes[edge_index];
+					const word *vertex_indexes= small_edge_vertex_indexes[edge_index];
 					const bpoint2d *texture_indexes= small_edge_texture_indexes[edge_index];
 
 					//triangle 1
@@ -326,7 +326,7 @@
 					if(vertices[a] && vertices[b]) \
 					{ unsigned mid = (a+b)/2; \
 					  if(vertices[mid]) \
-					  { short_world_point3d *mp = &vertices[mid]->p, *ap = &vertices[a]->p, *bp = &vertices[b]->p; \
+					  { world_point3d *mp = &vertices[mid]->p, *ap = &vertices[a]->p, *bp = &vertices[b]->p; \
 					    mp->x = (ap->x+bp->x)/2; \
 					    mp->y = (ap->y+bp->y)/2; \
 					    mp->z = (ap->z+bp->z)/2; \
@@ -404,7 +404,7 @@
 
 					for (edge_index= 0; edge_index<4; ++edge_index)
 					{
-						const byte *vertex_indexes= small_edge_vertex_indexes[edge_index];
+						const word *vertex_indexes= small_edge_vertex_indexes[edge_index];
 						const bpoint2d *texture_indexes= small_edge_texture_indexes[edge_index];
 
 						if (cell_flags&FLAG(_cell_edge_detail_first_bit+edge_index))
@@ -485,7 +485,7 @@
 				{
 					// two big triangles 
 					unsigned index= (((x^y)&2)>>1);
-					const byte *vertex_indexes= large_edge_vertex_indexes[index];
+					const word *vertex_indexes= large_edge_vertex_indexes[index];
 					const bpoint2d *texture_indexes= large_edge_texture_indexes[index];
 					struct render_triangle *surface1, *surface2;
 					int flags = surface_flags | ((cell_flags&FLAG(_cell_triangle_media_first_bit)) ? _surface_media_flag : 0);
Index: Myth2Code/render/render_objects.c
===================================================================
--- Myth2Code/render/render_objects.c	(revision 4486)
+++ Myth2Code/render/render_objects.c	(working copy)
@@ -83,13 +83,13 @@
 static void build_render_object(struct view_data *view, struct mesh_region *region, boolean reflection,
 	boolean fully_visible, boolean under_media, boolean shadow_only, struct object_data *object, short object_index);
 
-static void add_selection_surfaces_to_buckets(struct view_data *view, short object_index, short_world_point3d *transformed_position, world_distance precise_z,
+static void add_selection_surfaces_to_buckets(struct view_data *view, short object_index, world_point3d *transformed_position, world_distance precise_z,
 	short x0, short y0, short x1, short y1, short clip_top, short clip_bottom, fixed transparency, boolean show_selection);
-static void add_selection_box_surfaces_to_buckets(struct view_data *view, short object_index, short_world_point3d *transformed_position, world_distance precise_z,
+static void add_selection_box_surfaces_to_buckets(struct view_data *view, short object_index, world_point3d *transformed_position, world_distance precise_z,
 	short x0, short y0, short x1, short y1, short clip_top, short clip_bottom, fixed transparency);
-static void add_vitality_box_surfaces_to_buckets(struct view_data *view, short object_index, short_world_point3d *transformed_position, world_distance precise_z,
+static void add_vitality_box_surfaces_to_buckets(struct view_data *view, short object_index, world_point3d *transformed_position, world_distance precise_z,
 	short x0, short y0, short x1, short y1, short clip_top, short clip_bottom, fixed transparency);
-static void add_mana_box_surfaces_to_buckets(struct view_data *view, short object_index, short_world_point3d *transformed_position, world_distance precise_z,
+static void add_mana_box_surfaces_to_buckets(struct view_data *view, short object_index, world_point3d *transformed_position, world_distance precise_z,
 	short x0, short y0, short x1, short y1, short clip_top, short clip_bottom, fixed transparency);
 
 /* ---------- code */
@@ -386,7 +386,7 @@
 			for(x = left; x <= right; ++x)
 			{
 				struct mesh_tile *tile = get_mesh_tile(y*mesh_tile_width+x);
-				struct render_map_overlay *overlay_copy = (struct render_map_overlay*)new_render_map_overlay();
+				struct render_map_overlay *overlay_copy = new_render_map_overlay();
 				struct render_map_overlay **list= is_light ? &tile->light_map_overlays : &tile->shadow_map_overlays;
 				memcpy(overlay_copy, overlay, sizeof(struct render_map_overlay));
 				overlay_copy->next_map_overlay= *list;
@@ -451,7 +451,7 @@
 
 			if (density>0)
 			{
-				struct render_map_overlay *overlay= (struct render_map_overlay*)new_render_map_overlay();
+				struct render_map_overlay *overlay= new_render_map_overlay();
 				world_point2d apparent_position;
 
 				apparent_position.x= position->x + shift_amount;
@@ -489,10 +489,10 @@
 	short object_index)
 {
 	struct mesh_cell *cell= get_mesh_cell(WORLD_TO_INTEGER(object->location.position.x), WORLD_TO_INTEGER(object->location.position.y));
-	short_world_point3d transformed_position;
+	world_point3d transformed_position;
 	struct object_render_data render_data;
-	short_world_distance dx, dy, dz, reflection_dz;
-	short_world_distance z= object->location.position.z;
+	world_distance dx, dy, dz, reflection_dz;
+	world_distance z= object->location.position.z;
 	world_distance precise_z; // Build 400 - DRB
 	
 	unsigned char shape_sequence_index; // Build 367 - ALS - made unsigned
@@ -776,15 +776,15 @@
 					// Figure out the clip bounds so submerged objects are clipped against the media
 					if (under_media && !(object->flags&_object_is_media_surface_effect_flag) && !submerged_friendly)
 					{
-						short_world_distance dx= object->location.position.x - view->location.position.x;
-						short_world_distance dy= object->location.position.y - view->location.position.y;
-						short_world_distance dz= cell->media_height - view->location.position.z;
+						world_distance dx= object->location.position.x - view->location.position.x;
+						world_distance dy= object->location.position.y - view->location.position.y;
+						world_distance dz= cell->media_height - view->location.position.z;
 						
-						short_world_distance y= (dx*view->world_to_viewer_rotation.n[0][1] + dy*view->world_to_viewer_rotation.n[1][1] + dz*view->world_to_viewer_rotation.n[2][1])>>TRIG_BITS;
-						short_world_distance z= (dx*view->world_to_viewer_rotation.n[0][2] + dy*view->world_to_viewer_rotation.n[1][2] + dz*view->world_to_viewer_rotation.n[2][2])>>TRIG_BITS;
-						
-						short_world_distance screen_y= view->yk + (y*view->iworld_to_screen)/z;
+						world_distance y= (dx*view->world_to_viewer_rotation.n[0][1] + dy*view->world_to_viewer_rotation.n[1][1] + dz*view->world_to_viewer_rotation.n[2][1])>>TRIG_BITS;
+						world_distance z= (dx*view->world_to_viewer_rotation.n[0][2] + dy*view->world_to_viewer_rotation.n[1][2] + dz*view->world_to_viewer_rotation.n[2][2])>>TRIG_BITS;
 
+						world_distance screen_y= view->yk + (y*view->iworld_to_screen)/z;
+
 						if (reflection)
 						{
 							viewer_clip_top = y;
@@ -948,7 +948,7 @@
 						
 						if (OBJECT_IS_VERTICALLY_MIRRORED(object))
 						{
-							short_world_distance swap= -top;
+							world_distance swap= -top;
 							top= -bottom, bottom= swap;
 						}
 
@@ -983,7 +983,7 @@
 						
 						if (OBJECT_IS_VERTICALLY_MIRRORED(object))
 						{
-							short_world_distance swap= -top;
+							world_distance swap= -top;
 							top= -bottom, bottom= swap;
 						}
 
@@ -1084,7 +1084,7 @@
 			!(object->flags&_object_has_no_shadow_flag) &&
 			(!under_media || object->location.position.z+object->height1 > cell->media_height))
 		{
-			short_world_distance height= z - get_true_height((world_point2d *)&object->location.position);
+			world_distance height= z - get_true_height((world_point2d *)&object->location.position);
 			build_render_map_overlay(view, region, object->shape_collection_index, render_data.shadow_map_index,
 				render_data.transfer_mode, render_data.transfer_phase, &object->location.position, height, FIXED_ONE-1);
 		}
@@ -1178,7 +1178,7 @@
 static void add_selection_surfaces_to_buckets(
 	struct view_data *view,
 	short object_index,
-	short_world_point3d *transformed_position,
+	world_point3d *transformed_position,
 	world_distance precise_z,
 	short x0,
 	short y0,
@@ -1202,7 +1202,7 @@
 static void add_selection_box_surfaces_to_buckets(
 	struct view_data *view,
 	short object_index,
-	short_world_point3d *transformed_position,
+	world_point3d *transformed_position,
 	world_distance precise_z,
 	short x0,
 	short y0,
@@ -1405,7 +1405,7 @@
 static void add_vitality_box_surfaces_to_buckets(
 	struct view_data *view,
 	short object_index,
-	short_world_point3d *transformed_position,
+	world_point3d *transformed_position,
 	world_distance precise_z,
 	short x0,
 	short y0,
@@ -1519,7 +1519,7 @@
 static void add_mana_box_surfaces_to_buckets(
 	struct view_data *view,
 	short object_index,
-	short_world_point3d *transformed_position,
+	world_point3d *transformed_position,
 	world_distance precise_z,
 	short x0,
 	short y0,
Index: Myth2Code/render/render_private.h
===================================================================
--- Myth2Code/render/render_private.h	(revision 4486)
+++ Myth2Code/render/render_private.h	(working copy)
@@ -29,26 +29,18 @@
 	//                   be powers of 2, and setting them to 128 makes the volatile colormap
 	//                   texture increase from 512x512 to 1024x1024... a change that is bound
 	//                   to cause significant performance penalties on low-end systems.
-	MAXIMUM_MESH_REGION_WIDTH= 64,
+	MAXIMUM_MESH_REGION_WIDTH= 256,
 
 	// Build 241 ACS - was 40.  Increasing it fixed odd clipping bugs on some maps with steep terrain.
 	// Build 279 - ALS - increased from 50 to 60, to fix some more clipping bugs
 	// Build 292 - ALS - increased the below to 90 (for renwood build)
 	// Build 361 - DRB - set to MAXIMUM_MESH_REGION_WIDTH, which is the maximum effective value.
-	MAXIMUM_VIEW_CELLS= MAXIMUM_MESH_REGION_WIDTH,
+	MAXIMUM_VIEW_CELLS= 360,
 
 	// Build 400 - DRB
 	MAXIMUM_PROJECTED_VIEW_PYRAMID_VERTICES= 20, //20 = 4*(5 corners of pyramid)
 };
 
-enum // modes for building the scene
-{
-	_build_landscape,
-	_build_media,
-	_build_reflections,
-	_build_raw_mesh
-};
-
 /* ---------- mesh region */
 
 struct mesh_span
@@ -99,20 +91,17 @@
 
 enum
 {
-	RENDER_MEMORY_POOL_SIZE= 2048*KILO//512*KILO	// Build 255 - ALS - upped even more from 1024: memory corruption is bad (checks added elsewhere)
+	RENDER_MEMORY_POOL_SIZE= 8192*KILO//512*KILO	// Build 255 - ALS - upped even more from 1024: memory corruption is bad (checks added elsewhere)
 };
 
-#define new_render_vertex() render_malloc(sizeof(struct render_vertex))
-#define new_render_line() render_malloc(sizeof(struct render_line))
-#define new_render_corner() render_malloc(sizeof(struct render_corner))
-#define new_render_triangle() render_malloc(sizeof(struct render_triangle))
-#define new_render_model_triangle() render_malloc(sizeof(struct render_model_triangle))
-#define new_render_rectangle() render_malloc(sizeof(struct render_rectangle))
-#define new_render_filled_rectangle() render_malloc(sizeof(struct render_filled_rectangle))
-#define new_render_map_overlay() render_malloc(sizeof(struct render_map_overlay))
-#define new_render_polygon(n) render_malloc(sizeof(struct render_polygon) + (n)*sizeof(struct render_vertex *))
-#define new_render_bitmap_rectangle() render_malloc(sizeof(struct render_bitmap_rectangle))
-#define new_render_text_rectangle(s) render_malloc(sizeof(struct render_text_rectangle)+strlen(s)+1)
+#define new_render_vertex() (struct render_vertex*)render_malloc(sizeof(struct render_vertex))
+#define new_render_corner() (struct render_corner*)render_malloc(sizeof(struct render_corner))
+#define new_render_triangle() (struct render_triangle*)render_malloc(sizeof(struct render_triangle))
+#define new_render_model_triangle() (struct render_model_triangle*)render_malloc(sizeof(struct render_model_triangle))
+#define new_render_rectangle() (struct render_rectangle*)render_malloc(sizeof(struct render_rectangle))
+#define new_render_filled_rectangle() (struct render_filled_rectangle*)render_malloc(sizeof(struct render_filled_rectangle))
+#define new_render_map_overlay() (struct render_map_overlay*)render_malloc(sizeof(struct render_map_overlay))
+#define new_render_text_rectangle(s) (struct render_text_rectangle*)render_malloc(sizeof(struct render_text_rectangle)+strlen(s)+1)
 
 void *render_malloc(long size); // Build 255 - ALS
 void *render_temporary(long size); // Build 361 - DRB
Index: Myth2Code/render/render_scene.c
===================================================================
--- Myth2Code/render/render_scene.c	(revision 4486)
+++ Myth2Code/render/render_scene.c	(working copy)
@@ -265,15 +265,16 @@
 	return p;
 }
 
-static int vector_2d_square_magnitude(point p)
+static int64 vector_2d_square_magnitude(point p)
 {
-	return p.x*p.x + p.y*p.y;
+	return (int64)p.x*p.x + (int64)p.y*p.y;
 }
 
-static int vector_2d_cross_magnitude(point p, point q)
+static int64 vector_2d_cross_magnitude(point p, point q)
 {
 	// ((p:0)x(q:0)).z or the signed area of the parallelogram on p,q
-	return p.x*q.y - q.x*p.y;
+	int64 v = ((int64)p.x)*((int64)q.y) - ((int64)q.x)*((int64)p.y);
+	return v;
 }
 
 // true iff the angle of (0,q) is less than the angle of (0,p)
@@ -308,7 +309,7 @@
 		{
 			point p = points[j];
 			point q = points[best_i];
-			int mag = vector_2d_cross_magnitude(p,q);
+			int64 mag = vector_2d_cross_magnitude(p,q);
 			if(mag < 0 || mag == 0 && vector_2d_square_magnitude(p) > vector_2d_square_magnitude(q))
 			{
 				best_i = j;
@@ -397,11 +398,11 @@
 static point polygon_center(point points[], int count)
 {
 	int i;
-	int Cx = 0, Cy = 0, A = 0;
+	int64 Cx = 0, Cy = 0, A = 0;
 	for(i = 0; i < count; ++i)
 	{
 		int j = (i+1)%count;
-		int cm = vector_2d_cross_magnitude(points[i], points[j]);
+		int64 cm = vector_2d_cross_magnitude(points[i], points[j]);
 		A += cm;
 		Cx += (points[i].x+points[j].x)*cm;
 		Cy += (points[i].y+points[j].y)*cm;
@@ -474,6 +475,7 @@
 
 	region->frustum_corner_count = convex_hull(region->frustum_corners, point_count);
 
+	if(region->frustum_corner_count<point_count)
 	for(i = 0; i < region->frustum_corner_count; ++i)
 	{
 		region->frustum_corners[i].x = WORLD_TO_INTEGER(region->frustum_corners[i].x);
@@ -485,7 +487,7 @@
 {
 	const int max_d = (MAXIMUM_MESH_REGION_WIDTH/2)-2;
 	int i, temp;
-	int x, y, x0, y0;
+	int x, y, x0, y0, max_x0, max_y0;
 	world_rectangle2d frustum_bbox;
 	point center, eye, eye_to_center;
 	real len;
@@ -560,12 +562,15 @@
 	x0 = x - (MAXIMUM_MESH_REGION_WIDTH/2);
 	y0 = y - (MAXIMUM_MESH_REGION_WIDTH/2);
 
+	max_x0 = MAX(0, mesh_width-MAXIMUM_MESH_REGION_WIDTH);
+	max_y0 = MAX(0, mesh_height-MAXIMUM_MESH_REGION_WIDTH);
+
 	x0= MAX(x0, 0);
 	x0= x0&~1;
-	x0= MIN(x0, mesh_width-MAXIMUM_MESH_REGION_WIDTH);
+	x0= MIN(x0, max_x0);
 	y0= MAX(y0, 0);
 	y0= y0&~1;
-	y0= MIN(y0, mesh_height-MAXIMUM_MESH_REGION_WIDTH);
+	y0= MIN(y0, max_y0);
 
 	region->original_x0= x0;
 	region->original_y0= y0;
@@ -613,18 +618,23 @@
 
 static void extend_spans(struct mesh_region *region, int x, int y)
 {
-	int yy = y - region->original_y0;
-	if(yy >= 0 && yy < MAXIMUM_MESH_REGION_WIDTH)
+	if(y < mesh_height-1)
 	{
-		struct mesh_span *span = region->spans + yy;
-		x = MAX(x, region->original_x0);
-		x = MIN(x, region->original_x0+MAXIMUM_MESH_REGION_WIDTH-1);
-		span->x0 = MIN(span->x0, x);
-		span->x1 = MAX(span->x1, x);
-		region->x0 = MIN(region->x0, x);
-		region->x1 = MAX(region->x1, x);
-		region->y0 = MIN(region->y0, y);
-		region->y1 = MAX(region->y1, y);
+		int yy = y - region->original_y0;
+		if(yy >= 0 && yy < MAXIMUM_MESH_REGION_WIDTH)
+		{
+			struct mesh_span *span = region->spans + yy;
+			x = MAX(x, region->original_x0);
+			x = MIN(x, region->original_x0+MAXIMUM_MESH_REGION_WIDTH-1);
+			x = MIN(x, mesh_width-1);
+			y = MIN(y, mesh_height-1);
+			span->x0 = MIN(span->x0, x);
+			span->x1 = MAX(span->x1, x);
+			region->x0 = MIN(region->x0, x);
+			region->x1 = MAX(region->x1, x);
+			region->y0 = MIN(region->y0, y);
+			region->y1 = MAX(region->y1, y);
+		}
 	}
 }
 
@@ -735,6 +745,8 @@
 				unsigned x_tile_end = CELL_TO_TILE(span->x1);
 				unsigned y_tile = CELL_TO_TILE(y);
 
+				assert(x_tile_end+ mesh_tile_width*y_tile < mesh_tile_width*mesh_tile_height);
+
 				for(x_tile = x_tile_start; x_tile <= x_tile_end; ++x_tile)
 				{
 					unsigned local_tile_index = (y_tile-y0_tile)*width + (x_tile-x0_tile);
@@ -866,81 +878,60 @@
 
 			// create a render_vertex in world space
 			{
-				struct world_point3d transformed;
-				struct short_world_point3d short_transformed;
-				boolean overflow = FALSE;
+				struct render_vertex *vertex= new_render_vertex();
 
-				transform_point3d(&transformed, &view->world_to_viewer_rotation, &view->location.position, &p);
+				transform_point3d(&vertex->p, &view->world_to_viewer_rotation, &view->location.position, &p);
 
-				if(((short_transformed.x= transformed.x) - transformed.x) |
-					((short_transformed.y= transformed.y) - transformed.y) |
-					((short_transformed.z= transformed.z) - transformed.z))
-				{
-					overflow = TRUE;
-				}
+				vertex->flags= 0;
+				vertex->mesh_vertex.x= mesh_x;
+				vertex->mesh_vertex.y= mesh_y;
 
-				if(!overflow)
+				//clip_affine_vertex_to_all_planes(view, vertex);
+
+				// faster inlined version of clip_affine_vertex_to_all_planes
 				{
-					struct render_vertex *vertex= (struct render_vertex*)new_render_vertex();
-					vertex->p = short_transformed;
-					vertex->flags= 0;
-					vertex->mesh_vertex.x= mesh_x;
-					vertex->mesh_vertex.y= mesh_y;
+					int flags = _vertex_clipped_flag|_vertex_screen_transformed_flag;
 
-					//clip_affine_vertex_to_all_planes(view, vertex);
-
-					// faster inlined version of clip_affine_vertex_to_all_planes
+					if (vertex->p.z<0)
 					{
-						int flags = _vertex_clipped_flag|_vertex_screen_transformed_flag;
+						float world_to_screen= view->fworld_to_screen/vertex->p.z;
+						int x= view->xk - (vertex->p.x * world_to_screen);
+						int y= view->yk + (vertex->p.y * world_to_screen);
 
-						if (vertex->p.z<0)
-						{
-							float world_to_screen= view->fworld_to_screen/vertex->p.z;
-							int x= view->xk - (vertex->p.x * world_to_screen);
-							int y= view->yk + (vertex->p.y * world_to_screen);
-
-							if(x == (short)x && y == (short)y)
-							{
-								if (y<=0) flags|= _vertex_out_top_flag;
-								if (y>=view->screen_height) flags|= _vertex_out_bottom_flag;
-								if (x<=0) flags|= _vertex_out_left_flag;
-								if (x>=view->screen_width) flags|= _vertex_out_right_flag;
-								vertex->screen.x= x;
-								vertex->screen.y= y;
-							}
-							else
-							{
-								flags |= _vertex_discarded_flag;
-							}
-						}
-						else
-						{
-							flags |= _vertex_discarded_flag;
-						}
-
-						vertex->flags = flags;
+						if (y<=0) flags|= _vertex_out_top_flag;
+						if (y>=view->screen_height) flags|= _vertex_out_bottom_flag;
+						if (x<=0) flags|= _vertex_out_left_flag;
+						if (x>=view->screen_width) flags|= _vertex_out_right_flag;
+						vertex->screen.x= x;
+						vertex->screen.y= y;
 					}
-
+					else
 					{
-						int y = mesh_y - y0;
-						int x = mesh_x - x0;
-						assert(y >= 0 && y < MAXIMUM_MESH_REGION_WIDTH);
-						assert(x >= 0 && y < MAXIMUM_MESH_REGION_WIDTH);
-						region_vertices[y*MAXIMUM_MESH_REGION_WIDTH+x]= vertex;
+						flags |= _vertex_discarded_flag;
 					}
 
-					// cells containing models can't mark frustum edges unless models can limit rendering
-					if ((cell->model_index == NONE || models_cells_can_limit_rendering) &&
-						vertex->flags&(_vertex_out_left_flag|_vertex_out_top_flag|_vertex_out_right_flag|_vertex_discarded_flag))
-					{
+					vertex->flags = flags;
+				}
 
-					}
-					else
-					{
-						span->x0 = MIN(span->x0, mesh_x);
-						span->x1 = MAX(span->x1, mesh_x);
-					}
+				{
+					int y = mesh_y - y0;
+					int x = mesh_x - x0;
+					assert(y >= 0 && y < MAXIMUM_MESH_REGION_WIDTH);
+					assert(x >= 0 && y < MAXIMUM_MESH_REGION_WIDTH);
+					region_vertices[y*MAXIMUM_MESH_REGION_WIDTH+x]= vertex;
 				}
+
+				// cells containing models can't mark frustum edges unless models can limit rendering
+				if ((cell->model_index == NONE || models_cells_can_limit_rendering) &&
+					vertex->flags&(_vertex_out_left_flag|_vertex_out_top_flag|_vertex_out_right_flag|_vertex_discarded_flag))
+				{
+
+				}
+				else
+				{
+					span->x0 = MIN(span->x0, mesh_x);
+					span->x1 = MAX(span->x1, mesh_x);
+				}
 			}
 		}
 	}
@@ -1116,48 +1107,29 @@
 		// create a render_vertex in world space
 		{
 			word flags= 0;
+			struct render_vertex *vertex= new_render_vertex();
 
-			struct world_point3d transformed;
-			struct short_world_point3d short_transformed;
-			boolean overflow = FALSE;
+			transform_point3d(&vertex->p, &view->world_to_viewer_rotation, &view->location.position, &p);
 
-			transform_point3d(&transformed, &view->world_to_viewer_rotation, &view->location.position, &p);
+			vertex->flags= 0;
+			vertex->mesh_vertex.x= mesh_x;
+			vertex->mesh_vertex.y= mesh_y;
 
-			if(((short_transformed.x= transformed.x) - transformed.x) |
-			((short_transformed.y= transformed.y) - transformed.y) |
-			((short_transformed.z= transformed.z) - transformed.z))
-			{
-				overflow = TRUE;
-			}
+			clip_affine_vertex_to_all_planes(view, vertex);
+			region_vertices[node->y*MAXIMUM_MESH_REGION_WIDTH + node->x]= vertex;
 
-			if(!overflow)
+			// cells containing models can't mark frustum edges unless models can limit rendering
+			if ((cell->model_index == NONE || models_cells_can_limit_rendering) &&
+				vertex->flags&(_vertex_out_left_flag|_vertex_out_top_flag|_vertex_out_right_flag|_vertex_discarded_flag))
 			{
-				struct render_vertex *vertex= new_render_vertex();
-				vertex->p = short_transformed;
-				vertex->flags= 0;
-				vertex->mesh_vertex.x= mesh_x;
-				vertex->mesh_vertex.y= mesh_y;
-
-				clip_affine_vertex_to_all_planes(view, vertex);
-				region_vertices[node->y*MAXIMUM_MESH_REGION_WIDTH + node->x]= vertex;
-
-				// cells containing models can't mark frustum edges unless models can limit rendering
-				if ((cell->model_index == NONE || models_cells_can_limit_rendering) &&
-					vertex->flags&(_vertex_out_left_flag|_vertex_out_top_flag|_vertex_out_right_flag|_vertex_discarded_flag))
+				if (inside)
 				{
-					if (inside)
-					{
-						flags= _node_is_edge_flag;
-					}
+					flags= _node_is_edge_flag;
 				}
-				else
-				{
-					inside= TRUE;
-				}
 			}
-			else if (inside)
+			else
 			{
-				flags= _node_is_edge_flag;
+				inside= TRUE;
 			}
 
 			// if this vertex is in the view region, add all its unvisited children to the node list
@@ -1236,12 +1208,12 @@
 {
 	struct mesh_region *region;
 
-	/*if(key_down(_key_space))
+	if(key_down(_key_space))
 	{
 		region = build_mesh_region_old(view);
 		compute_frustum_polygon(view, region);
 	}
-	else*/
+	else
 	{
 		region = build_mesh_region_new(view);
 	}
Index: Myth2Code/render/render_surfaces.c
===================================================================
--- Myth2Code/render/render_surfaces.c	(revision 4486)
+++ Myth2Code/render/render_surfaces.c	(working copy)
@@ -18,14 +18,14 @@
 	short collection_index,
 	short color_table_index,
 	fixed_fraction transparency,
-	short_world_point3d *transformed_position,
+	world_point3d *transformed_position,
 	rectangle2d *viewer_rect,
 	int x0,
 	int x1,
 	int y0,
 	int y1)
 {
-	struct render_rectangle *rectangle= (struct render_rectangle *)new_render_rectangle();
+	struct render_rectangle *rectangle= new_render_rectangle();
 	unsigned long flags= 0;
 
 	// handle x, y mirroring
@@ -69,7 +69,7 @@
 
 void build_extended_bitmap_surface_triangles(
 	struct bitmap_instance_data *bitmap_instance,
-	short_world_point3d *transformed_position,
+	world_point3d *transformed_position,
 	world_vector3d *direction,
 	struct view_data *view,
 	struct render_surface_list *surfaces,
Index: Myth2Code/render/render_surfaces.h
===================================================================
--- Myth2Code/render/render_surfaces.h	(revision 4486)
+++ Myth2Code/render/render_surfaces.h	(working copy)
@@ -46,11 +46,11 @@
 
 void build_bitmap_surface_rectangle(struct bitmap_instance_data *bitmap_instance,
 	struct view_data *view, short collection_index, short color_table_index,
-	fixed_fraction transparency, short_world_point3d *transformed_position, rectangle2d *viewer_rect,
+	fixed_fraction transparency, world_point3d *transformed_position, rectangle2d *viewer_rect,
 	int x0, int x1, int y0, int y1);
 
 void build_extended_bitmap_surface_triangles(struct bitmap_instance_data *bitmap_instance,
-	short_world_point3d *transformed_position, world_vector3d *direction, struct view_data *view,
+	world_point3d *transformed_position, world_vector3d *direction, struct view_data *view,
 	struct render_surface_list *surfaces, struct build_bitmap_triangles_data *data);
 
 void quad_into_triangles(struct view_data *view, struct quad_triangle_data *data,
Index: Myth2Code/render/render_wireframe.c
===================================================================
--- Myth2Code/render/render_wireframe.c	(revision 4486)
+++ Myth2Code/render/render_wireframe.c	(working copy)
@@ -364,8 +364,8 @@
 	world_point3d *p1,
 	struct rgb_color *color)
 {
-	if (distance3d(p0, &view->location.position) < MAXIMUM_VIEWER_TO_OBJECT_DISTANCE &&
-		distance3d(p1, &view->location.position) < MAXIMUM_VIEWER_TO_OBJECT_DISTANCE)
+	/*if (distance3d(p0, &view->location.position) < MAXIMUM_VIEWER_TO_OBJECT_DISTANCE &&
+		distance3d(p1, &view->location.position) < MAXIMUM_VIEWER_TO_OBJECT_DISTANCE)*/
 	{
 		world_point3d transformed_p0;
 		world_point3d transformed_p1;
Index: Myth2Code/selection.c
===================================================================
--- Myth2Code/selection.c	(revision 4486)
+++ Myth2Code/selection.c	(working copy)
@@ -1848,7 +1848,7 @@
 		struct monster_data *monster= get_monster_data(selection_globals->current_selection.monster_indexes[i]);
 		struct object_data *object= get_object_data(monster->object_index);
 		
-		if (distance2d((world_point2d *)&object->location.position, (world_point2d *)(&view->location.position)) < MAXIMUM_VIEWER_TO_OBJECT_DISTANCE)
+		//if (distance2d((world_point2d *)&object->location.position, (world_point2d *)(&view->location.position)) < MAXIMUM_VIEWER_TO_OBJECT_DISTANCE)
 		{
 			draw_facing_arrow(view, &object->location.position, theta);
 		}
Index: Myth2Code/world.c
===================================================================
--- Myth2Code/world.c	(revision 4486)
+++ Myth2Code/world.c	(working copy)
@@ -1264,6 +1264,14 @@
 world_distance point_in_plane_test(
 	world_vector3d *normal, 
 	world_distance d, 
+	world_point3d *p)
+{
+	return (normal->i*p->x + normal->j*p->y + normal->k*p->z) + d;
+}
+
+world_distance point_in_plane_test_short_GAMEPLAY(
+	world_vector3d *normal, 
+	world_distance d, 
 	short_world_point3d *p)
 {
 	return (normal->i*p->x + normal->j*p->y + normal->k*p->z) + d;
Index: Myth2Code/world.h
===================================================================
--- Myth2Code/world.h	(revision 4486)
+++ Myth2Code/world.h	(working copy)
@@ -372,7 +372,8 @@
 world_distance trig_dot_product3d(world_vector3d *a, world_vector3d *b);
 world_vector3d *trig_cross_product3d(world_vector3d *a, world_vector3d *b, world_vector3d *r);
 
-world_distance point_in_plane_test(world_vector3d *normal, world_distance d, short_world_point3d *p);
+world_distance point_in_plane_test(world_vector3d *normal, world_distance d, world_point3d *p);
+world_distance point_in_plane_test_short_GAMEPLAY(world_vector3d *normal, world_distance d, short_world_point3d *p);
 boolean point_in_polygon_test(world_point2d *p, world_point2d *points, short point_count, 
 	boolean closed_geometry);
 
