From 2bdb3d7e269bd10df6c4c1f5cb0da7701265db3c Mon Sep 17 00:00:00 2001 From: relnev Date: Mon, 17 Jun 2002 06:33:11 +0000 Subject: [PATCH] ryan's struct patch for gcc 2.95 --- Makefile | 2 +- README | 7 +- include/pstypes.h | 7 +- include/vecmat.h | 85 +-- src/cfile/cfile.cpp | 17 +- src/cmeasure/cmeasure.cpp | 9 +- src/debris/debris.cpp | 28 +- src/fireball/fireballs.cpp | 9 +- src/fireball/warpineffect.cpp | 29 +- src/freespace2/freespace.cpp | 79 +-- src/gamehelp/contexthelp.cpp | 21 +- src/graphics/2d.cpp | 37 +- src/hud/hud.cpp | 9 +- src/hud/hudartillery.cpp | 5 +- src/hud/hudlock.cpp | 9 +- src/hud/hudreticle.cpp | 7 +- src/hud/hudtarget.cpp | 21 +- src/hud/hudtargetbox.cpp | 17 +- src/inetfile/cftp.cpp | 5 + src/inetfile/chttpget.cpp | 5 + src/lighting/lighting.cpp | 5 +- src/math/fvi.cpp | 91 +-- src/math/spline.cpp | 15 +- src/math/staticrand.cpp | 9 +- src/math/vecmat.cpp | 995 ++++++++++++++-------------- src/menuui/techmenu.cpp | 5 +- src/mission/missionbriefcommon.cpp | 77 +-- src/mission/missiongrid.cpp | 59 +- src/mission/missionparse.cpp | 29 +- src/missionui/missionbrief.cpp | 23 +- src/missionui/missionshipchoice.cpp | 7 +- src/model/modelcollide.cpp | 15 +- src/model/modelinterp.cpp | 75 ++- src/model/modeloctant.cpp | 69 +- src/model/modelread.cpp | 79 +-- src/nebula/neb.cpp | 73 +- src/nebula/neblightning.cpp | 17 +- src/network/multi_obj.cpp | 6 +- src/network/multi_observer.cpp | 9 +- src/network/multi_respawn.cpp | 33 +- src/network/multimsgs.cpp | 9 +- src/network/multiteamselect.cpp | 5 +- src/network/multiutil.cpp | 245 +++---- src/object/collidedebrisship.cpp | 5 +- src/object/collideshipship.cpp | 13 +- src/object/collideshipweapon.cpp | 15 +- src/object/collideweaponweapon.cpp | 5 +- src/object/objcollide.cpp | 19 +- src/object/objectsnd.cpp | 7 +- src/object/objectsort.cpp | 5 +- src/observer/observer.cpp | 6 +- src/particle/particle.cpp | 9 +- src/physics/physics.cpp | 265 ++++---- src/playerman/playercontrol.cpp | 41 +- src/radar/radar.cpp | 13 +- src/render/3ddraw.cpp | 79 +-- src/render/3dlaser.cpp | 11 +- src/render/3dmath.cpp | 101 +-- src/render/3dsetup.cpp | 32 +- src/ship/aibig.cpp | 37 +- src/ship/aicode.cpp | 440 ++++++------ src/ship/shield.cpp | 15 +- src/ship/ship.cpp | 67 +- src/ship/shipfx.cpp | 101 +-- src/ship/shiphit.cpp | 53 +- src/sound/sound.cpp | 7 +- src/starfield/nebula.cpp | 9 +- src/starfield/starfield.cpp | 41 +- src/starfield/supernova.cpp | 13 +- src/weapon/beam.cpp | 7 +- src/weapon/corkscrew.cpp | 4 +- src/weapon/flak.cpp | 5 +- src/weapon/swarm.cpp | 15 +- src/weapon/trails.cpp | 9 +- src/weapon/weapons.cpp | 47 +- 75 files changed, 2031 insertions(+), 1823 deletions(-) diff --git a/Makefile b/Makefile index ca40993..a880b28 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Makefile for code module # for that freespace 2 thing -CC=g++-3.0 +CC=g++ AR=ar CODE_BINARY=code.a FS_BINARY=freespace2 diff --git a/README b/README index c83842a..270392d 100644 --- a/README +++ b/README @@ -9,7 +9,7 @@ Charles Mason This project is NOT supported by Volition or Interplay. -http://www.icculus.org/projects/freespace2/ +http://www.icculus.org/freespace2/ Based on the Freespace 2 source code: Copyright (C) Volition, Inc. 1999. All rights reserved. @@ -19,15 +19,12 @@ or otherwise commercially exploit the source or things you created based on the source. ---------------------------------------------- -06/16/2002 +06/17/2002 Current status: - It currently uses SDL (http://www.libsdl.org) and OpenAL (http://opensource.creative.com) -- The code requires GNU g++ 3.0 or g++ 3.1. gcc 2.95 and earlier will not -work. - - The OpenGL code is complete minus one or two things, but it is unoptimized. - Keyboard, mouse, and joystick work. diff --git a/include/pstypes.h b/include/pstypes.h index 3c242d0..4907568 100644 --- a/include/pstypes.h +++ b/include/pstypes.h @@ -15,6 +15,9 @@ * Header file containg global typedefs, constants and macros * * $Log$ + * Revision 1.5 2002/06/17 06:33:08 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:14 relnev * added copyright header * @@ -262,7 +265,7 @@ typedef struct vector { union { struct { float x,y,z; - }; + } xyz; float a1d[3]; }; } vector; @@ -289,7 +292,7 @@ typedef struct matrix { union { struct { vector rvec, uvec, fvec; - }; + } v; float a2d[3][3]; float a1d[9]; }; diff --git a/include/vecmat.h b/include/vecmat.h index 05107da..fd44a9c 100644 --- a/include/vecmat.h +++ b/include/vecmat.h @@ -15,6 +15,9 @@ * Header file for functions that manipulate vectors and matricies * * $Log$ + * Revision 1.3 2002/06/17 06:33:08 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:15 relnev * added copyright header * @@ -180,28 +183,28 @@ //#define _INLINE_VECMAT -#define vm_is_vec_nan(v) (_isnan((v)->x) || _isnan((v)->y) || _isnan((v)->z)) +#define vm_is_vec_nan(v) (_isnan((v)->xyz.x) || _isnan((v)->xyz.y) || _isnan((v)->xyz.z)) //Macros/functions to fill in fields of structures //macro to check if vector is zero -#define IS_VEC_NULL(v) (((v)->x == (float)0.0) && ((v)->y == (float)0.0) && ((v)->z == (float)0.0)) +#define IS_VEC_NULL(v) (((v)->xyz.x == (float)0.0) && ((v)->xyz.y == (float)0.0) && ((v)->xyz.z == (float)0.0)) //macro to set a vector to zero. we could do this with an in-line assembly //macro, but it's probably better to let the compiler optimize it. //Note: NO RETURN VALUE -#define vm_vec_zero(v) (v)->x=(v)->y=(v)->z=(float)0.0 +#define vm_vec_zero(v) (v)->xyz.x=(v)->xyz.y=(v)->xyz.z=(float)0.0 /* //macro set set a matrix to the identity. Note: NO RETURN VALUE #define vm_set_identity(m) do {m->rvec.x = m->uvec.y = m->fvec.z = (float)1.0; \ - m->rvec.y = m->rvec.z = \ - m->uvec.x = m->uvec.z = \ - m->fvec.x = m->fvec.y = (float)0.0;} while (0) + m->rvec.xyz.y = m->rvec.xyz.z = \ + m->uvec.xyz.x = m->uvec.xyz.z = \ + m->fvec.xyz.x = m->fvec.xyz.y = (float)0.0;} while (0) */ extern void vm_set_identity(matrix *m); -#define vm_vec_make(v,_x,_y,_z) (((v)->x=(_x), (v)->y=(_y), (v)->z=(_z)), (v)) +#define vm_vec_make(v,_x,_y,_z) (((v)->xyz.x=(_x), (v)->xyz.y=(_y), (v)->xyz.z=(_z)), (v)) //Global constants @@ -222,7 +225,7 @@ extern matrix vmd_identity_matrix; #define vm_angvec_make(v,_p,_b,_h) (((v)->p=(_p), (v)->b=(_b), (v)->h=(_h)), (v)) //negate a vector -#define vm_vec_negate(v) do {(v)->x = - (v)->x; (v)->y = - (v)->y; (v)->z = - (v)->z;} while (0); +#define vm_vec_negate(v) do {(v)->xyz.x = - (v)->xyz.x; (v)->xyz.y = - (v)->xyz.y; (v)->xyz.z = - (v)->xyz.z;} while (0); typedef struct plane { float A, B, C, D; @@ -234,9 +237,9 @@ typedef struct plane { //ok for dest to equal either source, but should use vm_vec_add2() if so #ifdef _INLINE_VECMAT #define vm_vec_add( dst, src0, src1 ) do { \ - (dst)->x = (src0)->x + (src1)->x; \ - (dst)->y = (src0)->y + (src1)->y; \ - (dst)->z = (src0)->z + (src1)->z; \ + (dst)->xyz.x = (src0)->xyz.x + (src1)->xyz.x; \ + (dst)->xyz.y = (src0)->xyz.y + (src1)->xyz.y; \ + (dst)->xyz.z = (src0)->xyz.z + (src1)->xyz.z; \ } while(0) #else void vm_vec_add(vector *dest,vector *src0,vector *src1); @@ -245,9 +248,9 @@ void vm_vec_add(vector *dest,vector *src0,vector *src1); //adds src onto dest vector, returns ptr to dest #ifdef _INLINE_VECMAT #define vm_vec_add2( dst, src ) do { \ - (dst)->x += (src)->x; \ - (dst)->y += (src)->y; \ - (dst)->z += (src)->z; \ + (dst)->xyz.x += (src)->xyz.x; \ + (dst)->xyz.y += (src)->xyz.y; \ + (dst)->xyz.z += (src)->xyz.z; \ } while(0) #else void vm_vec_add2(vector *dest,vector *src); @@ -259,9 +262,9 @@ void vm_vec_add2(vector *dest,vector *src); #ifdef _INLINE_VECMAT #define vm_vec_scale_sub2( dst, src, k ) do { \ float tmp_k = (k); \ - (dst)->x -= (src)->x*tmp_k; \ - (dst)->y -= (src)->y*tmp_k; \ - (dst)->z -= (src)->z*tmp_k; \ + (dst)->xyz.x -= (src)->xyz.x*tmp_k; \ + (dst)->xyz.y -= (src)->xyz.y*tmp_k; \ + (dst)->xyz.z -= (src)->xyz.z*tmp_k; \ } while(0) #else void vm_vec_scale_sub2(vector *dest,vector *src, float k); @@ -271,9 +274,9 @@ void vm_vec_scale_sub2(vector *dest,vector *src, float k); //ok for dest to equal either source, but should use vm_vec_sub2() if so #ifdef _INLINE_VECMAT #define vm_vec_sub( dst, src0, src1 ) do { \ - (dst)->x = (src0)->x - (src1)->x; \ - (dst)->y = (src0)->y - (src1)->y; \ - (dst)->z = (src0)->z - (src1)->z; \ + (dst)->xyz.x = (src0)->xyz.x - (src1)->xyz.x; \ + (dst)->xyz.y = (src0)->xyz.y - (src1)->xyz.y; \ + (dst)->xyz.z = (src0)->xyz.z - (src1)->xyz.z; \ } while(0) #else void vm_vec_sub(vector *dest,vector *src0,vector *src1); @@ -284,9 +287,9 @@ void vm_vec_sub(vector *dest,vector *src0,vector *src1); //dest can equal source #ifdef _INLINE_VECMAT #define vm_vec_sub2( dst, src ) do { \ - (dst)->x -= (src)->x; \ - (dst)->y -= (src)->y; \ - (dst)->z -= (src)->z; \ + (dst)->xyz.x -= (src)->xyz.x; \ + (dst)->xyz.y -= (src)->xyz.y; \ + (dst)->xyz.z -= (src)->xyz.z; \ } while(0) #else void vm_vec_sub2(vector *dest,vector *src); @@ -305,9 +308,9 @@ vector *vm_vec_avg4(vector *dest,vector *src0,vector *src1,vector *src2,vector * #ifdef _INLINE_VECMAT #define vm_vec_scale( dst, k ) do { \ float tmp_k = (k); \ - (dst)->x *= tmp_k; \ - (dst)->y *= tmp_k; \ - (dst)->z *= tmp_k; \ + (dst)->xyz.x *= tmp_k; \ + (dst)->xyz.y *= tmp_k; \ + (dst)->xyz.z *= tmp_k; \ } while(0) #else void vm_vec_scale(vector *dest,float s); @@ -317,9 +320,9 @@ void vm_vec_scale(vector *dest,float s); #ifdef _INLINE_VECMAT #define vm_vec_copy_scale( dst, src, k ) do { \ float tmp_k = (k); \ - (dst)->x = (src)->x * tmp_k; \ - (dst)->y = (src)->y * tmp_k; \ - (dst)->z = (src)->z * tmp_k; \ + (dst)->xyz.x = (src)->xyz.x * tmp_k; \ + (dst)->xyz.y = (src)->xyz.y * tmp_k; \ + (dst)->xyz.z = (src)->xyz.z * tmp_k; \ } while(0) #else void vm_vec_copy_scale(vector *dest,vector *src,float s); @@ -330,9 +333,9 @@ void vm_vec_copy_scale(vector *dest,vector *src,float s); #ifdef _INLINE_VECMAT #define vm_vec_scale_add( dst, src1, src2, k ) do { \ float tmp_k = (k); \ - (dst)->x = (src1)->x + (src2)->x * tmp_k; \ - (dst)->y = (src1)->y + (src2)->y * tmp_k; \ - (dst)->z = (src1)->z + (src2)->z * tmp_k; \ + (dst)->xyz.x = (src1)->xyz.x + (src2)->xyz.x * tmp_k; \ + (dst)->xyz.y = (src1)->xyz.y + (src2)->xyz.y * tmp_k; \ + (dst)->xyz.z = (src1)->xyz.z + (src2)->xyz.z * tmp_k; \ } while(0) #else void vm_vec_scale_add(vector *dest,vector *src1,vector *src2,float k); @@ -344,9 +347,9 @@ void vm_vec_scale_add(vector *dest,vector *src1,vector *src2,float k); #ifdef _INLINE_VECMAT #define vm_vec_scale_add2( dst, src, k ) do { \ float tmp_k = (k); \ - (dst)->x += (src)->x * tmp_k; \ - (dst)->y += (src)->y * tmp_k; \ - (dst)->z += (src)->z * tmp_k; \ + (dst)->xyz.x += (src)->xyz.x * tmp_k; \ + (dst)->xyz.y += (src)->xyz.y * tmp_k; \ + (dst)->xyz.z += (src)->xyz.z * tmp_k; \ } while(0) #else void vm_vec_scale_add2(vector *dest,vector *src,float k); @@ -357,9 +360,9 @@ void vm_vec_scale_add2(vector *dest,vector *src,float k); #ifdef _INLINE_VECMAT #define vm_vec_scale2( dst, n, d ) do { \ float tmp_k = (n)/(d); \ - (dst)->x *= tmp_k; \ - (dst)->y *= tmp_k; \ - (dst)->z *= tmp_k; \ + (dst)->xyz.x *= tmp_k; \ + (dst)->xyz.y *= tmp_k; \ + (dst)->xyz.z *= tmp_k; \ } while(0) #else void vm_vec_scale2(vector *dest,float n,float d); @@ -419,15 +422,15 @@ float vm_vec_normalized_dir_quick(vector *dest,vector *end,vector *start); ////returns dot product of two vectors #ifdef _INLINE_VECMAT -#define vm_vec_dotprod( v0, v1 ) (((v1)->x*(v0)->x)+((v1)->y*(v0)->y)+((v1)->z*(v0)->z)) -#define vm_vec_dot( v0, v1 ) (((v1)->x*(v0)->x)+((v1)->y*(v0)->y)+((v1)->z*(v0)->z)) +#define vm_vec_dotprod( v0, v1 ) (((v1)->xyz.x*(v0)->xyz.x)+((v1)->xyz.y*(v0)->xyz.y)+((v1)->xyz.z*(v0)->xyz.z)) +#define vm_vec_dot( v0, v1 ) (((v1)->xyz.x*(v0)->xyz.x)+((v1)->xyz.y*(v0)->xyz.y)+((v1)->xyz.z*(v0)->xyz.z)) #else float vm_vec_dotprod(vector *v0,vector *v1); #define vm_vec_dot vm_vec_dotprod #endif #ifdef _INLINE_VECMAT -#define vm_vec_dot3( x1, y1, z1, v ) (((x1)*(v)->x)+((y1)*(v)->y)+((z1)*(v)->z)) +#define vm_vec_dot3( x1, y1, z1, v ) (((x1)*(v)->xyz.x)+((y1)*(v)->xyz.y)+((z1)*(v)->xyz.z)) #else float vm_vec_dot3(float x,float y,float z,vector *v); #endif diff --git a/src/cfile/cfile.cpp b/src/cfile/cfile.cpp index c69848d..640a1cc 100644 --- a/src/cfile/cfile.cpp +++ b/src/cfile/cfile.cpp @@ -15,6 +15,9 @@ * Utilities for operating on files * * $Log$ + * Revision 1.6 2002/06/17 06:33:08 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.5 2002/06/09 04:41:15 relnev * added copyright header * @@ -1207,14 +1210,14 @@ void cfread_vector(vector *vec, CFILE *file, int ver, vector *deflt) if (deflt) *vec = *deflt; else - vec->x = vec->y = vec->z = 0.0f; + vec->xyz.x = vec->xyz.y = vec->xyz.z = 0.0f; return; } - vec->x = cfread_float(file, ver, deflt ? deflt->x : 0.0f); - vec->y = cfread_float(file, ver, deflt ? deflt->y : 0.0f); - vec->z = cfread_float(file, ver, deflt ? deflt->z : 0.0f); + vec->xyz.x = cfread_float(file, ver, deflt ? deflt->xyz.x : 0.0f); + vec->xyz.y = cfread_float(file, ver, deflt ? deflt->xyz.y : 0.0f); + vec->xyz.z = cfread_float(file, ver, deflt ? deflt->xyz.z : 0.0f); } void cfread_angles(angles *ang, CFILE *file, int ver, angles *deflt) @@ -1309,13 +1312,13 @@ int cfwrite_ubyte(ubyte b, CFILE *file) int cfwrite_vector(vector *vec, CFILE *file) { - if(!cfwrite_float(vec->x, file)){ + if(!cfwrite_float(vec->xyz.x, file)){ return 0; } - if(!cfwrite_float(vec->y, file)){ + if(!cfwrite_float(vec->xyz.y, file)){ return 0; } - return cfwrite_float(vec->z, file); + return cfwrite_float(vec->xyz.z, file); } int cfwrite_angles(angles *ang, CFILE *file) diff --git a/src/cmeasure/cmeasure.cpp b/src/cmeasure/cmeasure.cpp index 1454c94..628792a 100644 --- a/src/cmeasure/cmeasure.cpp +++ b/src/cmeasure/cmeasure.cpp @@ -15,6 +15,9 @@ * Counter measures. Created by Mike Kulas, May 12, 1997. * * $Log$ + * Revision 1.3 2002/06/17 06:33:08 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:15 relnev * added copyright header * @@ -447,7 +450,7 @@ int cmeasure_create( object * source_obj, vector * pos, int cm_type, int rand_va vector vel, rand_vec; - vm_vec_scale_add(&vel, &source_obj->phys_info.vel, &source_obj->orient.fvec, -25.0f); + vm_vec_scale_add(&vel, &source_obj->phys_info.vel, &source_obj->orient.v.fvec, -25.0f); static_randvec(arand+1, &rand_vec); @@ -462,8 +465,8 @@ int cmeasure_create( object * source_obj, vector * pos, int cm_type, int rand_va obj->phys_info.side_slip_time_const = 10000.0f; vm_vec_zero(&obj->phys_info.max_vel); // make so he can't turn on his own VOLITION anymore. - obj->phys_info.max_vel.z = -25.0f; - vm_vec_copy_scale(&obj->phys_info.desired_vel, &obj->orient.fvec, obj->phys_info.max_vel.z ); + obj->phys_info.max_vel.xyz.z = -25.0f; + vm_vec_copy_scale(&obj->phys_info.desired_vel, &obj->orient.v.fvec, obj->phys_info.max_vel.xyz.z ); vm_vec_zero(&obj->phys_info.max_rotvel); // make so he can't change speed on his own VOLITION anymore. diff --git a/src/debris/debris.cpp b/src/debris/debris.cpp index cae86fd..0b69c26 100644 --- a/src/debris/debris.cpp +++ b/src/debris/debris.cpp @@ -15,6 +15,9 @@ * Code for the pieces of exploding object debris. * * $Log$ + * Revision 1.4 2002/06/17 06:33:08 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:15 relnev * added copyright header * @@ -1259,25 +1262,24 @@ int debris_get_team(object *objp) void calc_debris_physics_properties( physics_info *pi, vector *mins, vector *maxs ) { float dx, dy, dz, mass; - dx = maxs->x - mins->x; - dy = maxs->y - mins->y; - dz = maxs->z - mins->z; + dx = maxs->xyz.x - mins->xyz.x; + dy = maxs->xyz.y - mins->xyz.y; + dz = maxs->xyz.z - mins->xyz.z; // John, with new bspgen, just set pi->mass = mass mass = 0.12f * dx * dy * dz; pi->mass = (float) pow(mass, 0.6666667f) * 4.65f; - pi->I_body_inv.rvec.x = 12.0f / (pi->mass * (dy*dy + dz*dz)); - pi->I_body_inv.rvec.y = 0.0f; - pi->I_body_inv.rvec.z = 0.0f; + pi->I_body_inv.v.rvec.xyz.x = 12.0f / (pi->mass * (dy*dy + dz*dz)); + pi->I_body_inv.v.rvec.xyz.y = 0.0f; + pi->I_body_inv.v.rvec.xyz.z = 0.0f; - pi->I_body_inv.uvec.x = 0.0f; - pi->I_body_inv.uvec.y = 12.0f / (pi->mass * (dx*dx + dz*dz)); - pi->I_body_inv.uvec.z = 0.0f; + pi->I_body_inv.v.uvec.xyz.x = 0.0f; + pi->I_body_inv.v.uvec.xyz.y = 12.0f / (pi->mass * (dx*dx + dz*dz)); + pi->I_body_inv.v.uvec.xyz.z = 0.0f; - pi->I_body_inv.fvec.x = 0.0f; - pi->I_body_inv.fvec.y = 0.0f; - pi->I_body_inv.fvec.z = 12.0f / (pi->mass * (dx*dx + dy*dy)); + pi->I_body_inv.v.fvec.xyz.x = 0.0f; + pi->I_body_inv.v.fvec.xyz.y = 0.0f; + pi->I_body_inv.v.fvec.xyz.z = 12.0f / (pi->mass * (dx*dx + dy*dy)); } - diff --git a/src/fireball/fireballs.cpp b/src/fireball/fireballs.cpp index 8f7aefa..08be823 100644 --- a/src/fireball/fireballs.cpp +++ b/src/fireball/fireballs.cpp @@ -15,6 +15,9 @@ * Code to move, render and otherwise deal with fireballs. * * $Log$ + * Revision 1.4 2002/06/17 06:33:08 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:16 relnev * added copyright header * @@ -926,7 +929,7 @@ int fireball_get_lod(vector *pos, fireball_info *fd, float size) vector temp; behind = 1; - vm_vec_scale_add(&temp, &Eye_position, &Eye_matrix.fvec, dist); + vm_vec_scale_add(&temp, &Eye_position, &Eye_matrix.v.fvec, dist); g3_rotate_vertex(&v, &temp); // if still behind, bail and go with default @@ -1093,8 +1096,8 @@ int fireball_create( vector * pos, int fireball_type, int parent_obj, float size if (reverse) { fb->orient = 1; // if warp out, then reverse the orientation - vm_vec_scale( &obj->orient.fvec, -1.0f ); // Reverse the forward vector - vm_vec_scale( &obj->orient.rvec, -1.0f ); // Reverse the right vector + vm_vec_scale( &obj->orient.v.fvec, -1.0f ); // Reverse the forward vector + vm_vec_scale( &obj->orient.v.rvec, -1.0f ); // Reverse the right vector } else { fb->orient = 0; } diff --git a/src/fireball/warpineffect.cpp b/src/fireball/warpineffect.cpp index 18f3e56..d9b6e9d 100644 --- a/src/fireball/warpineffect.cpp +++ b/src/fireball/warpineffect.cpp @@ -15,6 +15,9 @@ * Code for rendering the warp in effects for ships * * $Log$ + * Revision 1.3 2002/06/17 06:33:08 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:16 relnev * added copyright header * @@ -174,26 +177,26 @@ void warpin_render(matrix *orient, vector *pos, int texture_bitmap_num, float ra vector center; - vm_vec_scale_add( ¢er, pos, &orient->fvec, -(max_radius/2.5f)/3.0f ); + vm_vec_scale_add( ¢er, pos, &orient->v.fvec, -(max_radius/2.5f)/3.0f ); vector vecs[5]; vertex verts[5]; - vm_vec_scale_add( &vecs[0], ¢er, &orient->uvec, radius ); - vm_vec_scale_add2( &vecs[0], &orient->rvec, -radius ); - vm_vec_scale_add2( &vecs[0], &orient->fvec, Grid_depth ); + vm_vec_scale_add( &vecs[0], ¢er, &orient->v.uvec, radius ); + vm_vec_scale_add2( &vecs[0], &orient->v.rvec, -radius ); + vm_vec_scale_add2( &vecs[0], &orient->v.fvec, Grid_depth ); - vm_vec_scale_add( &vecs[1], ¢er, &orient->uvec, radius ); - vm_vec_scale_add2( &vecs[1], &orient->rvec, radius ); - vm_vec_scale_add2( &vecs[1], &orient->fvec, Grid_depth ); + vm_vec_scale_add( &vecs[1], ¢er, &orient->v.uvec, radius ); + vm_vec_scale_add2( &vecs[1], &orient->v.rvec, radius ); + vm_vec_scale_add2( &vecs[1], &orient->v.fvec, Grid_depth ); - vm_vec_scale_add( &vecs[2], ¢er, &orient->uvec, -radius ); - vm_vec_scale_add2( &vecs[2], &orient->rvec, radius ); - vm_vec_scale_add2( &vecs[2], &orient->fvec, Grid_depth ); + vm_vec_scale_add( &vecs[2], ¢er, &orient->v.uvec, -radius ); + vm_vec_scale_add2( &vecs[2], &orient->v.rvec, radius ); + vm_vec_scale_add2( &vecs[2], &orient->v.fvec, Grid_depth ); - vm_vec_scale_add( &vecs[3], ¢er, &orient->uvec, -radius ); - vm_vec_scale_add2( &vecs[3], &orient->rvec, -radius ); - vm_vec_scale_add2( &vecs[3], &orient->fvec, Grid_depth ); + vm_vec_scale_add( &vecs[3], ¢er, &orient->v.uvec, -radius ); + vm_vec_scale_add2( &vecs[3], &orient->v.rvec, -radius ); + vm_vec_scale_add2( &vecs[3], &orient->v.fvec, Grid_depth ); // vm_vec_scale_add( &vecs[4], ¢er, &orient->fvec, -Grid_depth ); vecs[4] = center; diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index 4169d8b..d8f2913 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -15,6 +15,9 @@ * Freespace main body * * $Log$ + * Revision 1.19 2002/06/17 06:33:08 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.18 2002/06/16 04:46:33 relnev * set up correct checksums for demo * @@ -1263,7 +1266,7 @@ void game_sunspot_process(float frametime) vector light_dir; light_get_global_dir(&light_dir, 0); float dot; - dot = vm_vec_dot( &light_dir, &Eye_matrix.fvec ); + dot = vm_vec_dot( &light_dir, &Eye_matrix.v.fvec ); if(dot >= 0.0f){ // scale it some more @@ -1322,7 +1325,7 @@ void game_sunspot_process(float frametime) vector light_dir; light_get_global_dir(&light_dir, idx); - float dot = vm_vec_dot( &light_dir, &Eye_matrix.fvec )*0.5f+0.5f; + float dot = vm_vec_dot( &light_dir, &Eye_matrix.v.fvec )*0.5f+0.5f; Sun_spot_goal += (float)pow(dot,85.0f); @@ -2677,7 +2680,7 @@ void game_show_framerate() int sx, sy; sx = 320; sy = 100; - gr_printf(sx, sy, NOX("Player Pos: (%d,%d,%d)"), fl2i(Player_obj->pos.x), fl2i(Player_obj->pos.y), fl2i(Player_obj->pos.z)); + gr_printf(sx, sy, NOX("Player Pos: (%d,%d,%d)"), fl2i(Player_obj->pos.xyz.x), fl2i(Player_obj->pos.xyz.y), fl2i(Player_obj->pos.xyz.z)); } MONITOR_INC(NumPolys, modelstats_num_polys); @@ -3325,7 +3328,7 @@ void apply_hud_shake(matrix *eye_orient) vm_vec_rand_vec_quick(&rand_vec); // play the effect - joy_ff_play_dir_effect(intensity*rand_vec.x, intensity*rand_vec.y); + joy_ff_play_dir_effect(intensity*rand_vec.xyz.x, intensity*rand_vec.xyz.y); } @@ -3350,9 +3353,9 @@ void apply_hud_shake(matrix *eye_orient) matrix tm, tm2; vm_angles_2_matrix(&tm, &tangles); - Assert(vm_vec_mag(&tm.fvec) > 0.0f); - Assert(vm_vec_mag(&tm.rvec) > 0.0f); - Assert(vm_vec_mag(&tm.uvec) > 0.0f); + Assert(vm_vec_mag(&tm.v.fvec) > 0.0f); + Assert(vm_vec_mag(&tm.v.rvec) > 0.0f); + Assert(vm_vec_mag(&tm.v.uvec) > 0.0f); vm_matrix_x_matrix(&tm2, eye_orient, &tm); *eye_orient = tm2; } @@ -3453,7 +3456,7 @@ void game_render_frame_setup(vector *eye_pos, matrix *eye_orient) Viewer_mode &= ~(VM_EXTERNAL | VM_CHASE); vm_vec_scale_add2(&Dead_camera_pos, &Original_vec_to_deader, 25.0f * flFrametime); Dead_player_last_vel = Player_obj->phys_info.vel; - //nprintf(("AI", "Player death roll vel = %7.3f %7.3f %7.3f\n", Player_obj->phys_info.vel.x, Player_obj->phys_info.vel.y, Player_obj->phys_info.vel.z)); + //nprintf(("AI", "Player death roll vel = %7.3f %7.3f %7.3f\n", Player_obj->phys_info.vel.xyz.x, Player_obj->phys_info.vel.xyz.y, Player_obj->phys_info.vel.xyz.z)); } else if (Player_ai->target_objnum != -1) { view_pos = Objects[Player_ai->target_objnum].pos; } else { @@ -3508,11 +3511,11 @@ void game_render_frame_setup(vector *eye_pos, matrix *eye_orient) vm_angles_2_matrix(&tm2, &Viewer_external_info.angles); vm_matrix_x_matrix(&tm, &Viewer_obj->orient, &tm2); - vm_vec_scale_add(eye_pos, &Viewer_obj->pos, &tm.fvec, 2.0f * Viewer_obj->radius + Viewer_external_info.distance); + vm_vec_scale_add(eye_pos, &Viewer_obj->pos, &tm.v.fvec, 2.0f * Viewer_obj->radius + Viewer_external_info.distance); vm_vec_sub(&eye_dir, &Viewer_obj->pos, eye_pos); vm_vec_normalize(&eye_dir); - vm_vector_2_matrix(eye_orient, &eye_dir, &Viewer_obj->orient.uvec, NULL); + vm_vector_2_matrix(eye_orient, &eye_dir, &Viewer_obj->orient.v.uvec, NULL); Viewer_obj = NULL; // Modify the orientation based on head orientation. @@ -3522,25 +3525,25 @@ void game_render_frame_setup(vector *eye_pos, matrix *eye_orient) vector move_dir; if ( Viewer_obj->phys_info.speed < 0.1 ) - move_dir = Viewer_obj->orient.fvec; + move_dir = Viewer_obj->orient.v.fvec; else { move_dir = Viewer_obj->phys_info.vel; vm_vec_normalize(&move_dir); } vm_vec_scale_add(eye_pos, &Viewer_obj->pos, &move_dir, -3.0f * Viewer_obj->radius - Viewer_chase_info.distance); - vm_vec_scale_add2(eye_pos, &Viewer_obj->orient.uvec, 0.75f * Viewer_obj->radius); + vm_vec_scale_add2(eye_pos, &Viewer_obj->orient.v.uvec, 0.75f * Viewer_obj->radius); vm_vec_sub(&eye_dir, &Viewer_obj->pos, eye_pos); vm_vec_normalize(&eye_dir); // JAS: I added the following code because if you slew up using - // Descent-style physics, eye_dir and Viewer_obj->orient.uvec are + // Descent-style physics, eye_dir and Viewer_obj->orient.v.uvec are // equal, which causes a zero-length vector in the vm_vector_2_matrix // call because the up and the forward vector are the same. I fixed // it by adding in a fraction of the right vector all the time to the // up vector. - vector tmp_up = Viewer_obj->orient.uvec; - vm_vec_scale_add2( &tmp_up, &Viewer_obj->orient.rvec, 0.00001f ); + vector tmp_up = Viewer_obj->orient.v.uvec; + vm_vec_scale_add2( &tmp_up, &Viewer_obj->orient.v.rvec, 0.00001f ); vm_vector_2_matrix(eye_orient, &eye_dir, &tmp_up, NULL); Viewer_obj = NULL; @@ -3554,7 +3557,7 @@ void game_render_frame_setup(vector *eye_pos, matrix *eye_orient) vm_vec_sub(&eye_dir, &shipp->warp_effect_pos, eye_pos); vm_vec_normalize(&eye_dir); - vm_vector_2_matrix(eye_orient, &eye_dir, &Player_obj->orient.uvec, NULL); + vm_vector_2_matrix(eye_orient, &eye_dir, &Player_obj->orient.v.uvec, NULL); Viewer_obj = NULL; } else { // get an eye position based upon the correct type of object @@ -3693,16 +3696,16 @@ void john_debug_stuff(vector *eye_pos, matrix *eye_orient) model_subsystem *turret = tsys->system_info; if (turret->type == SUBSYSTEM_TURRET ) { - vector fvec, uvec; + vector v.fvec, v.uvec; object * tobj = &Objects[Players[Player_num].targeted_subobject_parent]; ship_model_start(tobj); model_find_world_point(eye_pos, &turret->turret_firing_point[0], turret->model_num, turret->turret_gun_sobj, &tobj->orient, &tobj->pos ); - model_find_world_dir(&fvec, &turret->turret_matrix.fvec, turret->model_num, turret->turret_gun_sobj, &tobj->orient, NULL ); - model_find_world_dir(&uvec, &turret->turret_matrix.uvec, turret->model_num, turret->turret_gun_sobj, &tobj->orient, NULL ); + model_find_world_dir(&v.fvec, &turret->turret_matrix.v.fvec, turret->model_num, turret->turret_gun_sobj, &tobj->orient, NULL ); + model_find_world_dir(&v.uvec, &turret->turret_matrix.v.uvec, turret->model_num, turret->turret_gun_sobj, &tobj->orient, NULL ); - vm_vector_2_matrix( eye_orient, &fvec, &uvec, NULL ); + vm_vector_2_matrix( eye_orient, &v.fvec, &v.uvec, NULL ); ship_model_stop(tobj); @@ -4900,13 +4903,13 @@ void camera_set_orient( matrix *orient ) void camera_set_velocity( vector *vel, int instantaneous ) { - Camera_desired_velocity.x = 0.0f; - Camera_desired_velocity.y = 0.0f; - Camera_desired_velocity.z = 0.0f; + Camera_desired_velocity.xyz.x = 0.0f; + Camera_desired_velocity.xyz.y = 0.0f; + Camera_desired_velocity.xyz.z = 0.0f; - vm_vec_scale_add2( &Camera_desired_velocity, &Camera_orient.rvec, vel->x ); - vm_vec_scale_add2( &Camera_desired_velocity, &Camera_orient.uvec, vel->y ); - vm_vec_scale_add2( &Camera_desired_velocity, &Camera_orient.fvec, vel->z ); + vm_vec_scale_add2( &Camera_desired_velocity, &Camera_orient.v.rvec, vel->xyz.x ); + vm_vec_scale_add2( &Camera_desired_velocity, &Camera_orient.v.uvec, vel->xyz.y ); + vm_vec_scale_add2( &Camera_desired_velocity, &Camera_orient.v.fvec, vel->xyz.z ); if ( instantaneous ) { Camera_velocity = Camera_desired_velocity; @@ -4919,13 +4922,13 @@ void camera_move() { vector new_vel, delta_pos; - apply_physics( Camera_damping, Camera_desired_velocity.x, Camera_velocity.x, flFrametime, &new_vel.x, &delta_pos.x ); - apply_physics( Camera_damping, Camera_desired_velocity.y, Camera_velocity.y, flFrametime, &new_vel.y, &delta_pos.y ); - apply_physics( Camera_damping, Camera_desired_velocity.z, Camera_velocity.z, flFrametime, &new_vel.z, &delta_pos.z ); + apply_physics( Camera_damping, Camera_desired_velocity.xyz.x, Camera_velocity.xyz.x, flFrametime, &new_vel.xyz.x, &delta_pos.xyz.x ); + apply_physics( Camera_damping, Camera_desired_velocity.xyz.y, Camera_velocity.xyz.y, flFrametime, &new_vel.xyz.y, &delta_pos.xyz.y ); + apply_physics( Camera_damping, Camera_desired_velocity.xyz.z, Camera_velocity.xyz.z, flFrametime, &new_vel.xyz.z, &delta_pos.xyz.z ); Camera_velocity = new_vel; -// mprintf(( "Camera velocity = %.1f,%.1f, %.1f\n", Camera_velocity.x, Camera_velocity.y, Camera_velocity.z )); +// mprintf(( "Camera velocity = %.1f,%.1f, %.1f\n", Camera_velocity.xyz.x, Camera_velocity.xyz.y, Camera_velocity.xyz.z )); vm_vec_add2( &Camera_pos, &delta_pos ); @@ -4936,17 +4939,17 @@ void camera_move() if ( (ot < 0.667f) && ( Camera_time >= 0.667f ) ) { vector tmp; - tmp.z = 4.739f; // always go this fast forward. + tmp.xyz.z = 4.739f; // always go this fast forward. // pick x and y velocities so they are always on a // circle with a 25 m radius. float tmp_angle = frand()*PI2; - tmp.x = 22.0f * (float)sin(tmp_angle); - tmp.y = -22.0f * (float)cos(tmp_angle); + tmp.xyz.x = 22.0f * (float)sin(tmp_angle); + tmp.xyz.y = -22.0f * (float)cos(tmp_angle); - //mprintf(( "Angle = %.1f, vx=%.1f, vy=%.1f\n", tmp_angle, tmp.x, tmp.y )); + //mprintf(( "Angle = %.1f, vx=%.1f, vy=%.1f\n", tmp_angle, tmp.xyz.x, tmp.xyz.y )); //mprintf(( "Changing velocity!\n" )); camera_set_velocity( &tmp, 0 ); @@ -5317,9 +5320,9 @@ void game_process_event( int current_state, int event ) vector tmp = Player_obj->pos; matrix tmp_m; ship_get_eye( &tmp, &tmp_m, Player_obj ); - vm_vec_scale_add2( &tmp, &Player_obj->orient.rvec, 0.0f ); - vm_vec_scale_add2( &tmp, &Player_obj->orient.uvec, 0.952f ); - vm_vec_scale_add2( &tmp, &Player_obj->orient.fvec, -1.782f ); + vm_vec_scale_add2( &tmp, &Player_obj->orient.v.rvec, 0.0f ); + vm_vec_scale_add2( &tmp, &Player_obj->orient.v.uvec, 0.952f ); + vm_vec_scale_add2( &tmp, &Player_obj->orient.v.fvec, -1.782f ); Camera_time = 0.0f; camera_set_position( &tmp ); camera_set_orient( &Player_obj->orient ); @@ -7494,7 +7497,7 @@ void Time_model( int modelnum ) eye_orient = model_orient = vmd_identity_matrix; eye_pos = model_pos = vmd_zero_vector; - eye_pos.z = -pm->rad*2.0f; + eye_pos.xyz.z = -pm->rad*2.0f; vector eye_to_model; diff --git a/src/gamehelp/contexthelp.cpp b/src/gamehelp/contexthelp.cpp index d139588..4c509f6 100644 --- a/src/gamehelp/contexthelp.cpp +++ b/src/gamehelp/contexthelp.cpp @@ -15,6 +15,9 @@ * Functions to drive the context-sensitive help * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:17 relnev * added copyright header * @@ -515,18 +518,18 @@ void parse_helptbl() for (i=0; i 0){ // stuff coords - v[0].sx = (float)ceil(s1.x); - v[0].sy = (float)ceil(s1.y); + v[0].sx = (float)ceil(s1.xyz.x); + v[0].sy = (float)ceil(s1.xyz.y); v[0].sw = 0.0f; v[0].u = 0.5f; v[0].v = 0.5f; @@ -1383,8 +1386,8 @@ void gr_pline_special(vector **pts, int num_pts, int thickness) v[0].g = gr_screen.current_color.green; v[0].b = gr_screen.current_color.blue; - v[1].sx = (float)ceil(s2.x); - v[1].sy = (float)ceil(s2.y); + v[1].sx = (float)ceil(s2.xyz.x); + v[1].sy = (float)ceil(s2.xyz.y); v[1].sw = 0.0f; v[1].u = 0.5f; v[1].v = 0.5f; @@ -1395,8 +1398,8 @@ void gr_pline_special(vector **pts, int num_pts, int thickness) v[1].b = gr_screen.current_color.blue; - v[2].sx = (float)ceil(last_e2.x); - v[2].sy = (float)ceil(last_e2.y); + v[2].sx = (float)ceil(last_e2.xyz.x); + v[2].sy = (float)ceil(last_e2.xyz.y); v[2].sw = 0.0f; v[2].u = 0.5f; v[2].v = 0.5f; diff --git a/src/hud/hud.cpp b/src/hud/hud.cpp index d06fabf..a185ca7 100644 --- a/src/hud/hud.cpp +++ b/src/hud/hud.cpp @@ -15,6 +15,9 @@ * C module that contains all the HUD functions at a high level * * $Log$ + * Revision 1.3 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:21 relnev * added copyright header * @@ -1156,7 +1159,7 @@ void HUD_render_forward_icon(object *objp) vertex v0; vector p0; - vm_vec_scale_add(&p0, &objp->pos, &objp->orient.fvec, 100.0f); + vm_vec_scale_add(&p0, &objp->pos, &objp->orient.v.fvec, 100.0f); g3_rotate_vertex(&v0, &p0); gr_set_color(255, 0, 0); @@ -2282,7 +2285,7 @@ int hud_support_get_dock_time( int objnum ) // When faraway, use max speed, not current speed. Might not have sped up yet. if (d > 100.0f) { - time += (d - 100.0f)/support_objp->phys_info.max_vel.z; + time += (d - 100.0f)/support_objp->phys_info.max_vel.xyz.z; } // For mid-range, use current speed. @@ -3066,7 +3069,7 @@ void HUD_set_offsets(object *viewer_obj, int wiggedy_wack) HUD_offset_x = 0.0f; HUD_offset_y = 0.0f; - vm_vec_scale_add( &tmp, &Viewer_obj->pos, &Viewer_obj->orient.fvec, 100.0f ); + vm_vec_scale_add( &tmp, &Viewer_obj->pos, &Viewer_obj->orient.v.fvec, 100.0f ); flags = g3_rotate_vertex(&pt,&tmp); diff --git a/src/hud/hudartillery.cpp b/src/hud/hudartillery.cpp index a991b8d..453dbd6 100644 --- a/src/hud/hudartillery.cpp +++ b/src/hud/hudartillery.cpp @@ -14,6 +14,9 @@ * * * $Log$ + * Revision 1.5 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:21 relnev * added copyright header * @@ -139,7 +142,7 @@ void ssm_get_random_start_pos(vector *out, vector *start, matrix *orient, int ss vm_vec_random_in_circle(&temp, start, orient, s->radius, 1); // offset it a bit - vm_vec_scale_add(out, &temp, &orient->fvec, s->offset); + vm_vec_scale_add(out, &temp, &orient->v.fvec, s->offset); } // level init diff --git a/src/hud/hudlock.cpp b/src/hud/hudlock.cpp index 49a45c8..6396dee 100644 --- a/src/hud/hudlock.cpp +++ b/src/hud/hudlock.cpp @@ -15,6 +15,9 @@ * C module that controls missile locking * * $Log$ + * Revision 1.5 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:21 relnev * added copyright header * @@ -634,7 +637,7 @@ void hud_lock_check_if_target_in_lock_cone(vector *lock_world_pos) vector vec_to_target; dist = vm_vec_normalized_dir(&vec_to_target, lock_world_pos, &Player_obj->pos); - dot = vm_vec_dot(&Player_obj->orient.fvec, &vec_to_target); + dot = vm_vec_dot(&Player_obj->orient.v.fvec, &vec_to_target); if ( dot > 0.85) { Player->target_in_lock_cone = 1; @@ -1174,7 +1177,7 @@ void hud_lock_get_new_lock_pos(object *target_objp, vector *lock_world_pos) lock_in_range = hud_lock_world_pos_in_range(lock_world_pos, &vec_to_lock); vm_vec_normalize(&vec_to_lock); if ( lock_in_range ) { - best_lock_dot=vm_vec_dot(&Player_obj->orient.fvec, &vec_to_lock); + best_lock_dot=vm_vec_dot(&Player_obj->orient.v.fvec, &vec_to_lock); } // take center if reasonable dot if ( best_lock_dot > 0.95 ) { @@ -1190,7 +1193,7 @@ void hud_lock_get_new_lock_pos(object *target_objp, vector *lock_world_pos) if ( hud_lock_world_pos_in_range(&subsys_world_pos, &vec_to_lock) ) { vm_vec_normalize(&vec_to_lock); - lock_dot=vm_vec_dot(&Player_obj->orient.fvec, &vec_to_lock); + lock_dot=vm_vec_dot(&Player_obj->orient.v.fvec, &vec_to_lock); if ( lock_dot > best_lock_dot ) { best_lock_dot=lock_dot; Player->locking_on_center=0; diff --git a/src/hud/hudreticle.cpp b/src/hud/hudreticle.cpp index 2990309..56297de 100644 --- a/src/hud/hudreticle.cpp +++ b/src/hud/hudreticle.cpp @@ -15,6 +15,9 @@ * C module to draw and manage the recticle * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:21 relnev * added copyright header * @@ -537,7 +540,7 @@ void hud_show_throttle() max_speed = Ships[Player_obj->instance].current_max_speed; if ( max_speed <= 0 ) { - max_speed = sip->max_vel.z; + max_speed = sip->max_vel.xyz.z; } desired_speed = Player->ci.forward * max_speed; @@ -553,7 +556,7 @@ void hud_show_throttle() percent_aburn_max = 0.0f; if ( percent_max > 1 ) { percent_max = 1.0f; - percent_aburn_max = (current_speed - max_speed) / (sip->afterburner_max_vel.z - max_speed); + percent_aburn_max = (current_speed - max_speed) / (sip->afterburner_max_vel.xyz.z - max_speed); if ( percent_aburn_max > 1.0f ) { percent_aburn_max = 1.0f; } diff --git a/src/hud/hudtarget.cpp b/src/hud/hudtarget.cpp index 519b496..347d5b9 100644 --- a/src/hud/hudtarget.cpp +++ b/src/hud/hudtarget.cpp @@ -15,6 +15,9 @@ * C module to provide HUD targeting functions * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:21 relnev * added copyright header * @@ -1504,7 +1507,7 @@ void hud_target_missile(object *source_obj, int next_flag) // if no bomb is found, search for bombers ship_obj *start, *so; - extern ship_obj *Ship_objs; + //extern ship_obj *Ship_objs; if ( (aip->target_objnum != -1) && (Objects[aip->target_objnum].type == OBJ_SHIP) && (Ship_info[Ships[Objects[aip->target_objnum].instance].ship_info_index].flags & SIF_BOMBER) ) { int index = Ships[Objects[aip->target_objnum].instance].ship_list_index; start = get_ship_obj_ptr_from_index(index); @@ -1797,7 +1800,7 @@ void hud_target_live_turret(int next_flag, int auto_advance, int only_player_tar if (!auto_advance && get_closest_turret && !only_player_target) { // if within 3 degrees and not previous subsys, use subsys in front - dot = vm_vec_dotprod(&vec_to_subsys, &Player_obj->orient.fvec); + dot = vm_vec_dotprod(&vec_to_subsys, &Player_obj->orient.v.fvec); if ((dot > 0.9986) && facing) { use_straigh_ahead_turret = TRUE; break; @@ -2459,7 +2462,7 @@ void hud_target_in_reticle_new() Reticle_save_timestamp = timestamp(RESET_TARGET_IN_RETICLE); // Get 3d vector through center of reticle - vm_vec_scale_add(&terminus, &Eye_position, &Player_obj->orient.fvec, TARGET_IN_RETICLE_DISTANCE); + vm_vec_scale_add(&terminus, &Eye_position, &Player_obj->orient.v.fvec, TARGET_IN_RETICLE_DISTANCE); mc.model_num = 0; for ( A = GET_FIRST(&obj_used_list); A !=END_OF_LIST(&obj_used_list); A = GET_NEXT(A) ) { @@ -2574,7 +2577,7 @@ void hud_target_in_reticle_old() } dist = vm_vec_normalized_dir(&vec_to_target, &A->pos, &Eye_position); - dot = vm_vec_dot(&Player_obj->orient.fvec, &vec_to_target); + dot = vm_vec_dot(&Player_obj->orient.v.fvec, &vec_to_target); if ( dot > MIN_DOT_FOR_TARGET ) { hud_reticle_list_update(A, dot, 1); @@ -2638,7 +2641,7 @@ void hud_target_subsystem_in_reticle() get_subsystem_world_pos(targetp, subsys, &subobj_pos); dist = vm_vec_normalized_dir(&vec_to_target, &subobj_pos, &Eye_position); - dot = vm_vec_dot(&Player_obj->orient.fvec, &vec_to_target); + dot = vm_vec_dot(&Player_obj->orient.v.fvec, &vec_to_target); if ( dot > best_dot ) { best_dot = dot; @@ -2680,9 +2683,9 @@ void hud_render_orientation_tee(object *from_objp, object *to_objp, matrix *from // 0 - vectors are perpendicular // 1 - vectors are collinear and in the same direction (target is facing player) // -1 - vectors are collinear and in the opposite direction (target is facing away from player) - dot_product = vm_vec_dotprod(&from_orientp->fvec, &target_to_obj); + dot_product = vm_vec_dotprod(&from_orientp->v.fvec, &target_to_obj); - if (vm_vec_dotprod(&from_orientp->rvec, &target_to_obj) >= 0) { + if (vm_vec_dotprod(&from_orientp->v.rvec, &target_to_obj) >= 0) { if (dot_product >= 0){ dot_product = -PI/2*dot_product + PI; } else { @@ -4248,7 +4251,7 @@ void hud_draw_offscreen_indicator(vertex* target_point, vector *tpos, float dist // to range between 0 -> 1. vm_vec_sub(&targ_to_player, &Player_obj->pos, tpos); vm_vec_normalize(&targ_to_player); - dist_behind = vm_vec_dot(&Player_obj->orient.fvec, &targ_to_player); + dist_behind = vm_vec_dot(&Player_obj->orient.v.fvec, &targ_to_player); in_front = 0; @@ -4289,7 +4292,7 @@ void hud_draw_offscreen_indicator(vertex* target_point, vector *tpos, float dist vertex real_eye_vertex; eye_vertex = &real_eye_vertex; // this is needed since clip line takes a **vertex vector eye_pos; - vm_vec_add( &eye_pos, &Eye_position, &View_matrix.fvec); + vm_vec_add( &eye_pos, &Eye_position, &View_matrix.v.fvec); g3_rotate_vertex(eye_vertex, &eye_pos); ubyte codes_or; diff --git a/src/hud/hudtargetbox.cpp b/src/hud/hudtargetbox.cpp index 06bf2c8..7599453 100644 --- a/src/hud/hudtargetbox.cpp +++ b/src/hud/hudtargetbox.cpp @@ -15,6 +15,9 @@ * C module for drawing the target monitor box on the HUD * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:21 relnev * added copyright header * @@ -740,7 +743,7 @@ void hud_render_target_jump_node(object *target_objp) factor = target_objp->radius*4.0f; // use the player's up vector, and construct the viewers orientation matrix - up_vector = Player_obj->orient.uvec; + up_vector = Player_obj->orient.v.uvec; vm_vector_2_matrix(&camera_orient,&orient_vec,&up_vector,NULL); // normalize the vector from the player to the current target, and scale by a factor to calculate @@ -1232,10 +1235,10 @@ void hud_render_target_ship(object *target_objp) vm_vec_sub(&orient_vec, &target_objp->pos, &Player_obj->pos); vm_vec_normalize(&orient_vec); - factor = -target_sip->closeup_pos.z; + factor = -target_sip->closeup_pos.xyz.z; // use the player's up vector, and construct the viewers orientation matrix - up_vector = Player_obj->orient.uvec; + up_vector = Player_obj->orient.v.uvec; vm_vector_2_matrix(&camera_orient,&orient_vec,&up_vector,NULL); // normalize the vector from the player to the current target, and scale by a factor to calculate @@ -1322,7 +1325,7 @@ void hud_render_target_debris(object *target_objp) factor = 2*target_objp->radius; // use the player's up vector, and construct the viewers orientation matrix - up_vector = Player_obj->orient.uvec; + up_vector = Player_obj->orient.v.uvec; vm_vector_2_matrix(&camera_orient,&orient_vec,&up_vector,NULL); // normalize the vector from the player to the current target, and scale by a factor to calculate @@ -1414,7 +1417,7 @@ void hud_render_target_weapon(object *target_objp) factor = vm_vec_dist_quick(&viewer_obj->pos, &viewed_obj->pos); // use the viewer's up vector, and construct the viewers orientation matrix - up_vector = viewer_obj->orient.uvec; + up_vector = viewer_obj->orient.v.uvec; vm_vector_2_matrix(&camera_orient,&orient_vec,&up_vector,NULL); // normalize the vector from the viewer to the viwed target, and scale by a factor to calculate @@ -1705,7 +1708,7 @@ void hud_show_target_data(float frametime) dist = vm_vec_dist_quick(&Objects[Player_ai->target_objnum].pos, &Objects[aip->target_objnum].pos); vm_vec_normalized_dir(&v2t,&Objects[aip->target_objnum].pos, &Objects[Player_ai->target_objnum].pos); - dot = vm_vec_dot(&v2t, &Objects[Player_ai->target_objnum].orient.fvec); + dot = vm_vec_dot(&v2t, &Objects[Player_ai->target_objnum].orient.v.fvec); // data can be found in target montior // gr_printf(TARGET_WINDOW_X1+TARGET_WINDOW_WIDTH+3, TARGET_WINDOW_Y1+6*h, "Targ dist: %5.1f", dist); @@ -1753,7 +1756,7 @@ void hud_show_target_data(float frametime) dist = vm_vec_dist_quick(&Enemy_attacker->pos, &Player_obj->pos); vm_vec_normalized_dir(&v2t,&Objects[eaip->target_objnum].pos, &Enemy_attacker->pos); - dot = vm_vec_dot(&v2t, &Enemy_attacker->orient.fvec); + dot = vm_vec_dot(&v2t, &Enemy_attacker->orient.v.fvec); gr_printf(sx, sy, "#%i: %s", Enemy_attacker-Objects, Ships[Enemy_attacker->instance].ship_name); sy += dy; diff --git a/src/inetfile/cftp.cpp b/src/inetfile/cftp.cpp index b465af2..4716b56 100644 --- a/src/inetfile/cftp.cpp +++ b/src/inetfile/cftp.cpp @@ -15,6 +15,9 @@ * FTP Client class (get only) * * $Log$ + * Revision 1.9 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.8 2002/06/09 04:41:21 relnev * added copyright header * @@ -67,6 +70,8 @@ #include #include #include +#include +#include #include "unix.h" // unix.h #endif diff --git a/src/inetfile/chttpget.cpp b/src/inetfile/chttpget.cpp index 1db81bc..ac55eba 100644 --- a/src/inetfile/chttpget.cpp +++ b/src/inetfile/chttpget.cpp @@ -15,6 +15,9 @@ * HTTP Client class (get only) * * $Log$ +* Revision 1.7 2002/06/17 06:33:09 relnev +* ryan's struct patch for gcc 2.95 +* * Revision 1.6 2002/06/09 04:41:21 relnev * added copyright header * @@ -125,6 +128,8 @@ #include #include #include +#include +#include #include "unix.h" diff --git a/src/lighting/lighting.cpp b/src/lighting/lighting.cpp index 42d0e8c..8e01105 100644 --- a/src/lighting/lighting.cpp +++ b/src/lighting/lighting.cpp @@ -15,6 +15,9 @@ * Code to calculate dynamic lighting on a vertex. * * $Log$ + * Revision 1.3 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:22 relnev * added copyright header * @@ -598,7 +601,7 @@ int light_filter_push( int objnum, vector *pos, float rad ) int is_inside( vector *min, vector *max, vector * p0, float rad ) { - float *origin = (float *)&p0->x; + float *origin = (float *)&p0->xyz.x; float *minB = (float *)min; float *maxB = (float *)max; int i; diff --git a/src/math/fvi.cpp b/src/math/fvi.cpp index d32d219..f860809 100644 --- a/src/math/fvi.cpp +++ b/src/math/fvi.cpp @@ -15,6 +15,9 @@ * Routines to find intersections of various 3d things. * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:22 relnev * added copyright header * @@ -167,12 +170,12 @@ void accurate_square_root( float A, float B, float C, float discriminant, float float matrix_determinant_from_vectors(vector *v1,vector *v2,vector *v3) { float ans; - ans=v1->x*v2->y*v3->z; - ans+=v2->x*v3->y*v1->z; - ans+=v3->x*v1->y*v2->z; - ans-=v1->z*v2->y*v3->x; - ans-=v2->z*v3->y*v1->x; - ans-=v3->z*v1->y*v2->x; + ans=v1->xyz.x*v2->xyz.y*v3->xyz.z; + ans+=v2->xyz.x*v3->xyz.y*v1->xyz.z; + ans+=v3->xyz.x*v1->xyz.y*v2->xyz.z; + ans-=v1->xyz.z*v2->xyz.y*v3->xyz.x; + ans-=v2->xyz.z*v3->xyz.y*v1->xyz.x; + ans-=v3->xyz.z*v1->xyz.y*v2->xyz.x; return ans; } @@ -246,9 +249,9 @@ float fvi_ray_plane(vector *new_pnt, den = -vm_vec_dot(plane_norm,ray_direction); if ( den == 0.0f ) { // Ray & plane are parallel, so there is no intersection if ( new_pnt ) { - new_pnt->x = -FLT_MAX; - new_pnt->y = -FLT_MAX; - new_pnt->z = -FLT_MAX; + new_pnt->xyz.x = -FLT_MAX; + new_pnt->xyz.y = -FLT_MAX; + new_pnt->xyz.z = -FLT_MAX; } return -FLT_MAX; } @@ -319,9 +322,9 @@ int fvi_segment_sphere(vector *intp,vector *p0,vector *p1,vector *sphere_pos,flo } // normalize dn - dn.x = d.x / mag_d; - dn.y = d.y / mag_d; - dn.z = d.z / mag_d; + dn.xyz.x = d.xyz.x / mag_d; + dn.xyz.y = d.xyz.y / mag_d; + dn.xyz.z = d.xyz.z / mag_d; w_dist = vm_vec_dot(&dn,&w); @@ -391,9 +394,9 @@ int fvi_ray_sphere(vector *intp,vector *p0,vector *p1,vector *sphere_pos,float s } // normalize dn - dn.x = d.x / mag_d; - dn.y = d.y / mag_d; - dn.z = d.z / mag_d; + dn.xyz.x = d.xyz.x / mag_d; + dn.xyz.y = d.xyz.y / mag_d; + dn.xyz.z = d.xyz.z / mag_d; w_dist = vm_vec_dot(&dn,&w); @@ -449,11 +452,11 @@ int fvi_ray_sphere(vector *intp,vector *p0,vector *p1,vector *sphere_pos,float s // Fast ray-box intersection taken from Graphics Gems I, pages 395,736. int fvi_ray_boundingbox( vector *min, vector *max, vector * p0, vector *pdir, vector *hitpt ) { - float *origin = (float *)&p0->x; - float *dir = (float *)&pdir->x; + float *origin = (float *)&p0->xyz.x; + float *dir = (float *)&pdir->xyz.x; float *minB = (float *)min; float *maxB = (float *)max; - float *coord = (float *)&hitpt->x; + float *coord = (float *)&hitpt->xyz.x; int inside = 1; int middle[3]; int i; @@ -551,12 +554,12 @@ int fvi_point_face(vector *checkp, int nv, vector **verts, vector * norm1, float norm = (float *)norm1; //project polygon onto plane by finding largest component of normal - t.x = fl_abs(norm[0]); - t.y = fl_abs(norm[1]); - t.z = fl_abs(norm[2]); + t.xyz.x = fl_abs(norm[0]); + t.xyz.y = fl_abs(norm[1]); + t.xyz.z = fl_abs(norm[2]); - if (t.x > t.y) if (t.x > t.z) i0=0; else i0=2; - else if (t.y > t.z) i0=1; else i0=2; + if (t.xyz.x > t.xyz.y) if (t.xyz.x > t.xyz.z) i0=0; else i0=2; + else if (t.xyz.y > t.xyz.z) i0=1; else i0=2; if (norm[i0] > 0.0f) { i1 = ij_table[i0][0]; @@ -758,14 +761,14 @@ int fvi_sphere_perp_edge(vector *intersect_point, vector *sphere_center_start, v vm_project_point_onto_plane(&Xs_proj, sphere_center_start, &z_hat, &V0); vector plane_coord; - plane_coord.x = vm_vec_dotprod(&Xs_proj, &x_hat); - plane_coord.y = vm_vec_dotprod(&Xe_proj, &y_hat); - plane_coord.z = vm_vec_dotprod(&Xe_proj, &z_hat); + plane_coord.xyz.x = vm_vec_dotprod(&Xs_proj, &x_hat); + plane_coord.xyz.y = vm_vec_dotprod(&Xe_proj, &y_hat); + plane_coord.xyz.z = vm_vec_dotprod(&Xe_proj, &z_hat); // determime the position on the edge line - vm_vec_copy_scale( intersect_point, &x_hat, plane_coord.x ); - vm_vec_scale_add2( intersect_point, &y_hat, plane_coord.y ); - vm_vec_scale_add2( intersect_point, &z_hat, plane_coord.z ); + vm_vec_copy_scale( intersect_point, &x_hat, plane_coord.xyz.x ); + vm_vec_scale_add2( intersect_point, &y_hat, plane_coord.xyz.y ); + vm_vec_scale_add2( intersect_point, &z_hat, plane_coord.xyz.z ); // check if point is actually on edge float edge_parameter; @@ -1529,34 +1532,34 @@ int project_point_onto_bbox(vector *mins, vector *maxs, vector *start, vector *b { int inside = TRUE; - if (start->x > maxs->x) { - box_pt->x = maxs->x; + if (start->xyz.x > maxs->xyz.x) { + box_pt->xyz.x = maxs->xyz.x; inside = FALSE; - } else if (start->x < mins->x) { - box_pt->x = mins->x; + } else if (start->xyz.x < mins->xyz.x) { + box_pt->xyz.x = mins->xyz.x; inside = FALSE; } else { - box_pt->x = start->x; + box_pt->xyz.x = start->xyz.x; } - if (start->y > maxs->y) { - box_pt->y = maxs->y; + if (start->xyz.y > maxs->xyz.y) { + box_pt->xyz.y = maxs->xyz.y; inside = FALSE; - } else if (start->y < mins->y) { - box_pt->y = mins->y; + } else if (start->xyz.y < mins->xyz.y) { + box_pt->xyz.y = mins->xyz.y; inside = FALSE; } else { - box_pt->y = start->y; + box_pt->xyz.y = start->xyz.y; } - if (start->z > maxs->z) { - box_pt->z = maxs->z; + if (start->xyz.z > maxs->xyz.z) { + box_pt->xyz.z = maxs->xyz.z; inside = FALSE; - } else if (start->z < mins->z) { - box_pt->z = mins->z; + } else if (start->xyz.z < mins->xyz.z) { + box_pt->xyz.z = mins->xyz.z; inside = FALSE; } else { - box_pt->z = start->z; + box_pt->xyz.z = start->xyz.z; } return inside; diff --git a/src/math/spline.cpp b/src/math/spline.cpp index d67dee5..29b7f5d 100644 --- a/src/math/spline.cpp +++ b/src/math/spline.cpp @@ -14,6 +14,9 @@ * * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:22 relnev * added copyright header * @@ -121,21 +124,21 @@ void bez_spline::bez_get_point(vector *out, float u) } // calc - out->x = 0.0f; - out->y = 0.0f; - out->z = 0.0f; + out->xyz.x = 0.0f; + out->xyz.y = 0.0f; + out->xyz.z = 0.0f; for(idx=0; idxx += pts[idx].x * bez_val; + out->xyz.x += pts[idx].xyz.x * bez_val; // y component - out->y += pts[idx].y * bez_val; + out->xyz.y += pts[idx].xyz.y * bez_val; // z component - out->z += pts[idx].z * bez_val; + out->xyz.z += pts[idx].xyz.z * bez_val; } } diff --git a/src/math/staticrand.cpp b/src/math/staticrand.cpp index e27f83d..f7a3ab5 100644 --- a/src/math/staticrand.cpp +++ b/src/math/staticrand.cpp @@ -15,6 +15,9 @@ * static random functions. Return "random" number based on integer inut * * $Log$ + * Revision 1.3 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:22 relnev * added copyright header * @@ -95,9 +98,9 @@ float static_randf_range(int num, float min, float max) void static_randvec(int num, vector *vp) { - vp->x = static_randf(num) - 0.5f; - vp->y = static_randf(num+1) - 0.5f; - vp->z = static_randf(num+2) - 0.5f; + vp->xyz.x = static_randf(num) - 0.5f; + vp->xyz.y = static_randf(num+1) - 0.5f; + vp->xyz.z = static_randf(num+2) - 0.5f; vm_vec_normalize_quick(vp); } diff --git a/src/math/vecmat.cpp b/src/math/vecmat.cpp index b76b26f..2229fd0 100644 --- a/src/math/vecmat.cpp +++ b/src/math/vecmat.cpp @@ -15,6 +15,9 @@ * C module containg functions for manipulating vectors and matricies * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:22 relnev * added copyright header * @@ -341,9 +344,9 @@ float asqrt(float x) void vm_set_identity(matrix *m) { - m->rvec.x = 1.0f; m->rvec.y = 0.0f; m->rvec.z = 0.0f; - m->uvec.x = 0.0f; m->uvec.y = 1.0f; m->uvec.z = 0.0f; - m->fvec.x = 0.0f; m->fvec.y = 0.0f; m->fvec.z = 1.0f; + m->v.rvec.xyz.x = 1.0f; m->v.rvec.xyz.y = 0.0f; m->v.rvec.xyz.z = 0.0f; + m->v.uvec.xyz.x = 0.0f; m->v.uvec.xyz.y = 1.0f; m->v.uvec.xyz.z = 0.0f; + m->v.fvec.xyz.x = 0.0f; m->v.fvec.xyz.y = 0.0f; m->v.fvec.xyz.z = 1.0f; } //adds two vectors, fills in dest, returns ptr to dest @@ -351,9 +354,9 @@ void vm_set_identity(matrix *m) #ifndef _INLINE_VECMAT void vm_vec_add(vector *dest,vector *src0,vector *src1) { - dest->x = src0->x + src1->x; - dest->y = src0->y + src1->y; - dest->z = src0->z + src1->z; + dest->xyz.x = src0->xyz.x + src1->xyz.x; + dest->xyz.y = src0->xyz.y + src1->xyz.y; + dest->xyz.z = src0->xyz.z + src1->xyz.z; } #endif @@ -362,9 +365,9 @@ void vm_vec_add(vector *dest,vector *src0,vector *src1) #ifndef _INLINE_VECMAT void vm_vec_sub(vector *dest,vector *src0,vector *src1) { - dest->x = src0->x - src1->x; - dest->y = src0->y - src1->y; - dest->z = src0->z - src1->z; + dest->xyz.x = src0->xyz.x - src1->xyz.x; + dest->xyz.y = src0->xyz.y - src1->xyz.y; + dest->xyz.z = src0->xyz.z - src1->xyz.z; } #endif @@ -374,9 +377,9 @@ void vm_vec_sub(vector *dest,vector *src0,vector *src1) #ifndef _INLINE_VECMAT void vm_vec_add2(vector *dest,vector *src) { - dest->x += src->x; - dest->y += src->y; - dest->z += src->z; + dest->xyz.x += src->xyz.x; + dest->xyz.y += src->xyz.y; + dest->xyz.z += src->xyz.z; } #endif @@ -385,9 +388,9 @@ void vm_vec_add2(vector *dest,vector *src) #ifndef _INLINE_VECMAT void vm_vec_sub2(vector *dest,vector *src) { - dest->x -= src->x; - dest->y -= src->y; - dest->z -= src->z; + dest->xyz.x -= src->xyz.x; + dest->xyz.y -= src->xyz.y; + dest->xyz.z -= src->xyz.z; } #endif @@ -395,9 +398,9 @@ void vm_vec_sub2(vector *dest,vector *src) //dest can equal either source vector *vm_vec_avg(vector *dest,vector *src0,vector *src1) { - dest->x = (src0->x + src1->x) * 0.5f; - dest->y = (src0->y + src1->y) * 0.5f; - dest->z = (src0->z + src1->z) * 0.5f; + dest->xyz.x = (src0->xyz.x + src1->xyz.x) * 0.5f; + dest->xyz.y = (src0->xyz.y + src1->xyz.y) * 0.5f; + dest->xyz.z = (src0->xyz.z + src1->xyz.z) * 0.5f; return dest; } @@ -407,9 +410,9 @@ vector *vm_vec_avg(vector *dest,vector *src0,vector *src1) //dest can equal any source vector *vm_vec_avg4(vector *dest,vector *src0,vector *src1,vector *src2,vector *src3) { - dest->x = (src0->x + src1->x + src2->x + src3->x) * 0.25f; - dest->y = (src0->y + src1->y + src2->y + src3->y) * 0.25f; - dest->z = (src0->z + src1->z + src2->z + src3->z) * 0.25f; + dest->xyz.x = (src0->xyz.x + src1->xyz.x + src2->xyz.x + src3->xyz.x) * 0.25f; + dest->xyz.y = (src0->xyz.y + src1->xyz.y + src2->xyz.y + src3->xyz.y) * 0.25f; + dest->xyz.z = (src0->xyz.z + src1->xyz.z + src2->xyz.z + src3->xyz.z) * 0.25f; return dest; } @@ -418,9 +421,9 @@ vector *vm_vec_avg4(vector *dest,vector *src0,vector *src1,vector *src2,vector * #ifndef _INLINE_VECMAT void vm_vec_scale(vector *dest,float s) { - dest->x = dest->x * s; - dest->y = dest->y * s; - dest->z = dest->z * s; + dest->xyz.x = dest->xyz.x * s; + dest->xyz.y = dest->xyz.y * s; + dest->xyz.z = dest->xyz.z * s; } #endif @@ -429,9 +432,9 @@ void vm_vec_scale(vector *dest,float s) #ifndef _INLINE_VECMAT void vm_vec_copy_scale(vector *dest,vector *src,float s) { - dest->x = src->x*s; - dest->y = src->y*s; - dest->z = src->z*s; + dest->xyz.x = src->xyz.x*s; + dest->xyz.y = src->xyz.y*s; + dest->xyz.z = src->xyz.z*s; } #endif @@ -440,9 +443,9 @@ void vm_vec_copy_scale(vector *dest,vector *src,float s) #ifndef _INLINE_VECMAT void vm_vec_scale_add(vector *dest,vector *src1,vector *src2,float k) { - dest->x = src1->x + src2->x*k; - dest->y = src1->y + src2->y*k; - dest->z = src1->z + src2->z*k; + dest->xyz.x = src1->xyz.x + src2->xyz.x*k; + dest->xyz.y = src1->xyz.y + src2->xyz.y*k; + dest->xyz.z = src1->xyz.z + src2->xyz.z*k; } #endif @@ -451,9 +454,9 @@ void vm_vec_scale_add(vector *dest,vector *src1,vector *src2,float k) #ifndef _INLINE_VECMAT void vm_vec_scale_add2(vector *dest,vector *src,float k) { - dest->x += src->x*k; - dest->y += src->y*k; - dest->z += src->z*k; + dest->xyz.x += src->xyz.x*k; + dest->xyz.y += src->xyz.y*k; + dest->xyz.z += src->xyz.z*k; } #endif @@ -462,9 +465,9 @@ void vm_vec_scale_add2(vector *dest,vector *src,float k) #ifndef _INLINE_VECMAT void vm_vec_scale_sub2(vector *dest,vector *src,float k) { - dest->x -= src->x*k; - dest->y -= src->y*k; - dest->z -= src->z*k; + dest->xyz.x -= src->xyz.x*k; + dest->xyz.y -= src->xyz.y*k; + dest->xyz.z -= src->xyz.z*k; } #endif @@ -475,9 +478,9 @@ void vm_vec_scale2(vector *dest,float n,float d) { d = 1.0f/d; - dest->x = dest->x* n * d; - dest->y = dest->y* n * d; - dest->z = dest->z* n * d; + dest->xyz.x = dest->xyz.x* n * d; + dest->xyz.y = dest->xyz.y* n * d; + dest->xyz.z = dest->xyz.z* n * d; } #endif @@ -485,7 +488,7 @@ void vm_vec_scale2(vector *dest,float n,float d) #ifndef _INLINE_VECMAT float vm_vec_dotprod(vector *v0,vector *v1) { - return (v1->x*v0->x)+(v1->y*v0->y)+(v1->z*v0->z); + return (v1->xyz.x*v0->xyz.x)+(v1->xyz.y*v0->xyz.y)+(v1->xyz.z*v0->xyz.z); } #endif @@ -494,7 +497,7 @@ float vm_vec_dotprod(vector *v0,vector *v1) #ifndef _INLINE_VECMAT float vm_vec_dot3(float x,float y,float z,vector *v) { - return (x*v->x)+(y*v->y)+(z*v->z); + return (x*v->xyz.x)+(y*v->xyz.y)+(z*v->xyz.z); } #endif @@ -502,9 +505,9 @@ float vm_vec_dot3(float x,float y,float z,vector *v) float vm_vec_mag(vector *v) { float x,y,z,mag1, mag2; - x = v->x*v->x; - y = v->y*v->y; - z = v->z*v->z; + x = v->xyz.x*v->xyz.x; + y = v->xyz.y*v->xyz.y; + z = v->xyz.z*v->xyz.z; mag1 = x+y+z; if ( mag1 < 0.0 ) Int3(); @@ -518,9 +521,9 @@ float vm_vec_mag(vector *v) float vm_vec_mag_squared(vector *v) { float x,y,z,mag1; - x = v->x*v->x; - y = v->y*v->y; - z = v->z*v->z; + x = v->xyz.x*v->xyz.x; + y = v->xyz.y*v->xyz.y; + z = v->xyz.z*v->xyz.z; mag1 = x+y+z; return mag1; } @@ -529,9 +532,9 @@ float vm_vec_dist_squared(vector *v0, vector *v1) { float dx, dy, dz; - dx = v0->x - v1->x; - dy = v0->y - v1->y; - dz = v0->z - v1->z; + dx = v0->xyz.x - v1->xyz.x; + dy = v0->xyz.y - v1->xyz.y; + dz = v0->xyz.z - v1->xyz.z; return dx*dx + dy*dy + dz*dz; } @@ -556,20 +559,20 @@ float vm_vec_mag_quick(vector *v) { float a,b,c,bc, t; - if ( v->x < 0.0 ) - a = -v->x; + if ( v->xyz.x < 0.0 ) + a = -v->xyz.x; else - a = v->x; + a = v->xyz.x; - if ( v->y < 0.0 ) - b = -v->y; + if ( v->xyz.y < 0.0 ) + b = -v->xyz.y; else - b = v->y; + b = v->xyz.y; - if ( v->z < 0.0 ) - c = -v->z; + if ( v->xyz.z < 0.0 ) + c = -v->xyz.z; else - c = v->z; + c = v->xyz.z; if (a < b) { float t=a; a=b; b=t; @@ -612,18 +615,18 @@ float vm_vec_copy_normalize(vector *dest,vector *src) if (m <= 0.0f) { Warning(LOCATION, "Null vector in vector normalize.\n" "Trace out of vecmat.cpp and find offending code.\n"); - dest->x = 1.0f; - dest->y = 0.0f; - dest->z = 0.0f; + dest->xyz.x = 1.0f; + dest->xyz.y = 0.0f; + dest->xyz.z = 0.0f; return 1.0f; } float im = 1.0f / m; - dest->x = src->x * im; - dest->y = src->y * im; - dest->z = src->z * im; + dest->xyz.x = src->xyz.x * im; + dest->xyz.y = src->xyz.y * im; + dest->xyz.z = src->xyz.z * im; return m; } @@ -648,17 +651,17 @@ float vm_vec_normalize_safe(vector *v) // Mainly here to trap attempts to normalize a null vector. if (m <= 0.0f) { - v->x = 1.0f; - v->y = 0.0f; - v->z = 0.0f; + v->xyz.x = 1.0f; + v->xyz.y = 0.0f; + v->xyz.z = 0.0f; return 1.0f; } float im = 1.0f / m; - v->x *= im; - v->y *= im; - v->z *= im; + v->xyz.x *= im; + v->xyz.y *= im; + v->xyz.z *= im; return m; @@ -668,8 +671,8 @@ float vm_vec_normalize_safe(vector *v) //returns approximation of 1/magnitude of a vector float vm_vec_imag(vector *v) { -// return 1.0f / sqrt( (v->x*v->x)+(v->y*v->y)+(v->z*v->z) ); - return fl_isqrt( (v->x*v->x)+(v->y*v->y)+(v->z*v->z) ); +// return 1.0f / sqrt( (v->xyz.x*v->xyz.x)+(v->xyz.y*v->xyz.y)+(v->xyz.z*v->xyz.z) ); + return fl_isqrt( (v->xyz.x*v->xyz.x)+(v->xyz.y*v->xyz.y)+(v->xyz.z*v->xyz.z) ); } //normalize a vector. returns 1/mag of source vec. uses approx 1/mag @@ -682,9 +685,9 @@ float vm_vec_copy_normalize_quick(vector *dest,vector *src) Assert(im > 0.0f); - dest->x = src->x*im; - dest->y = src->y*im; - dest->z = src->z*im; + dest->xyz.x = src->xyz.x*im; + dest->xyz.y = src->xyz.y*im; + dest->xyz.z = src->xyz.z*im; return 1.0f/im; } @@ -700,9 +703,9 @@ float vm_vec_normalize_quick(vector *src) Assert(im > 0.0f); - src->x = src->x*im; - src->y = src->y*im; - src->z = src->z*im; + src->xyz.x = src->xyz.x*im; + src->xyz.y = src->xyz.y*im; + src->xyz.z = src->xyz.z*im; return 1.0f/im; @@ -721,9 +724,9 @@ float vm_vec_copy_normalize_quick_mag(vector *dest,vector *src) float im = 1.0f / m; - dest->x = src->x * im; - dest->y = src->y * im; - dest->z = src->z * im; + dest->xyz.x = src->xyz.x * im; + dest->xyz.y = src->xyz.y * im; + dest->xyz.z = src->xyz.z * im; return m; @@ -739,9 +742,9 @@ float vm_vec_normalize_quick_mag(vector *v) Assert(m > 0.0f); - v->x = v->x*m; - v->y = v->y*m; - v->z = v->z*m; + v->xyz.x = v->xyz.x*m; + v->xyz.y = v->xyz.y*m; + v->xyz.z = v->xyz.z*m; return m; @@ -803,9 +806,9 @@ vector *vm_vec_normal(vector *dest,vector *p0,vector *p1,vector *p2) //your inputs are ok. vector *vm_vec_crossprod(vector *dest,vector *src0,vector *src1) { - dest->x = (src0->y * src1->z) - (src0->z * src1->y); - dest->y = (src0->z * src1->x) - (src0->x * src1->z); - dest->z = (src0->x * src1->y) - (src0->y * src1->x); + dest->xyz.x = (src0->xyz.y * src1->xyz.z) - (src0->xyz.z * src1->xyz.y); + dest->xyz.y = (src0->xyz.z * src1->xyz.x) - (src0->xyz.x * src1->xyz.z); + dest->xyz.z = (src0->xyz.x * src1->xyz.y) - (src0->xyz.y * src1->xyz.x); return dest; } @@ -813,7 +816,7 @@ vector *vm_vec_crossprod(vector *dest,vector *src0,vector *src1) // test if 2 vectors are parallel or not. int vm_test_parallel(vector *src0, vector *src1) { - if ( (fl_abs(src0->x - src1->x) < 1e-4) && (fl_abs(src0->y - src1->y) < 1e-4) && (fl_abs(src0->z - src1->z) < 1e-4) ) { + if ( (fl_abs(src0->xyz.x - src1->xyz.x) < 1e-4) && (fl_abs(src0->xyz.y - src1->xyz.y) < 1e-4) && (fl_abs(src0->xyz.z - src1->xyz.z) < 1e-4) ) { return 1; } else { return 0; @@ -881,18 +884,18 @@ matrix *sincos_2_matrix(matrix *m,float sinp,float cosp,float sinb,float cosb,fl cbsh = cosb*sinh; sbch = sinb*cosh; - m->rvec.x = cbch + sinp*sbsh; //m1 - m->uvec.z = sbsh + sinp*cbch; //m8 + m->v.rvec.xyz.x = cbch + sinp*sbsh; //m1 + m->v.uvec.xyz.z = sbsh + sinp*cbch; //m8 - m->uvec.x = sinp*cbsh - sbch; //m2 - m->rvec.z = sinp*sbch - cbsh; //m7 + m->v.uvec.xyz.x = sinp*cbsh - sbch; //m2 + m->v.rvec.xyz.z = sinp*sbch - cbsh; //m7 - m->fvec.x = sinh*cosp; //m3 - m->rvec.y = sinb*cosp; //m4 - m->uvec.y = cosb*cosp; //m5 - m->fvec.z = cosh*cosp; //m9 + m->v.fvec.xyz.x = sinh*cosp; //m3 + m->v.rvec.xyz.y = sinb*cosp; //m4 + m->v.uvec.xyz.y = cosb*cosp; //m5 + m->v.fvec.xyz.z = cosh*cosp; //m9 - m->fvec.y = -sinp; //m6 + m->v.fvec.xyz.y = -sinp; //m6 return m; @@ -951,11 +954,11 @@ matrix *vm_vec_ang_2_matrix(matrix *m,vector *v,float a) sinb = (float)sin(a); cosb = (float)cos(a); - sinp = -v->y; + sinp = -v->xyz.y; cosp = fl_sqrt(1.0 - sinp*sinp); - sinh = v->x / cosp; - cosh = v->z / cosp; + sinh = v->xyz.x / cosp; + cosh = v->xyz.z / cosp; t = sincos_2_matrix(m,sinp,cosp,sinb,cosb,sinh,cosh); @@ -970,7 +973,7 @@ matrix *vm_vec_ang_2_matrix(matrix *m,vector *v,float a) //returns ptr to matrix matrix *vm_vector_2_matrix(matrix *m,vector *fvec,vector *uvec,vector *rvec) { - vector *xvec=&m->rvec,*yvec=&m->uvec,*zvec=&m->fvec; + vector *xvec=&m->v.rvec,*yvec=&m->v.uvec,*zvec=&m->v.fvec; Assert(fvec != NULL); @@ -988,18 +991,18 @@ matrix *vm_vector_2_matrix(matrix *m,vector *fvec,vector *uvec,vector *rvec) bad_vector2: ; - if ((zvec->x==0.0) && (zvec->z==0.0)) { //forward vec is straight up or down + if ((zvec->xyz.x==0.0) && (zvec->xyz.z==0.0)) { //forward vec is straight up or down - m->rvec.x = (float)1.0; - m->uvec.z = (zvec->y<0.0)?(float)1.0:(float)-1.0; + m->v.rvec.xyz.x = (float)1.0; + m->v.uvec.xyz.z = (zvec->xyz.y<0.0)?(float)1.0:(float)-1.0; - m->rvec.y = m->rvec.z = m->uvec.x = m->uvec.y = (float)0.0; + m->v.rvec.xyz.y = m->v.rvec.xyz.z = m->v.uvec.xyz.x = m->v.uvec.xyz.y = (float)0.0; } else { //not straight up or down - xvec->x = zvec->z; - xvec->y = (float)0.0; - xvec->z = -zvec->x; + xvec->xyz.x = zvec->xyz.z; + xvec->xyz.y = (float)0.0; + xvec->xyz.z = -zvec->xyz.x; vm_vec_normalize(xvec); @@ -1045,7 +1048,7 @@ bad_vector2: //quicker version of vm_vector_2_matrix() that takes normalized vectors matrix *vm_vector_2_matrix_norm(matrix *m,vector *fvec,vector *uvec,vector *rvec) { - vector *xvec=&m->rvec,*yvec=&m->uvec,*zvec=&m->fvec; + vector *xvec=&m->v.rvec,*yvec=&m->v.uvec,*zvec=&m->v.fvec; Assert(fvec != NULL); @@ -1059,18 +1062,18 @@ matrix *vm_vector_2_matrix_norm(matrix *m,vector *fvec,vector *uvec,vector *rvec bad_vector2: ; - if ((zvec->x==0.0) && (zvec->z==0.0)) { //forward vec is straight up or down + if ((zvec->xyz.x==0.0) && (zvec->xyz.z==0.0)) { //forward vec is straight up or down - m->rvec.x = (float)1.0; - m->uvec.z = (zvec->y<0.0)?(float)1.0:(float)-1.0; + m->v.rvec.xyz.x = (float)1.0; + m->v.uvec.xyz.z = (zvec->xyz.y<0.0)?(float)1.0:(float)-1.0; - m->rvec.y = m->rvec.z = m->uvec.x = m->uvec.y = (float)0.0; + m->v.rvec.xyz.y = m->v.rvec.xyz.z = m->v.uvec.xyz.x = m->v.uvec.xyz.y = (float)0.0; } else { //not straight up or down - xvec->x = zvec->z; - xvec->y = (float)0.0; - xvec->z = -zvec->x; + xvec->xyz.x = zvec->xyz.z; + xvec->xyz.y = (float)0.0; + xvec->xyz.z = -zvec->xyz.x; vm_vec_normalize(xvec); @@ -1114,9 +1117,9 @@ bad_vector2: //dest CANNOT equal source vector *vm_vec_rotate(vector *dest,vector *src,matrix *m) { - dest->x = (src->x*m->rvec.x)+(src->y*m->rvec.y)+(src->z*m->rvec.z); - dest->y = (src->x*m->uvec.x)+(src->y*m->uvec.y)+(src->z*m->uvec.z); - dest->z = (src->x*m->fvec.x)+(src->y*m->fvec.y)+(src->z*m->fvec.z); + dest->xyz.x = (src->xyz.x*m->v.rvec.xyz.x)+(src->xyz.y*m->v.rvec.xyz.y)+(src->xyz.z*m->v.rvec.xyz.z); + dest->xyz.y = (src->xyz.x*m->v.uvec.xyz.x)+(src->xyz.y*m->v.uvec.xyz.y)+(src->xyz.z*m->v.uvec.xyz.z); + dest->xyz.z = (src->xyz.x*m->v.fvec.xyz.x)+(src->xyz.y*m->v.fvec.xyz.y)+(src->xyz.z*m->v.fvec.xyz.z); return dest; } @@ -1136,9 +1139,9 @@ vector *vm_vec_rotate(vector *dest,vector *src,matrix *m) vector *vm_vec_unrotate(vector *dest,vector *src,matrix *m) { - dest->x = (src->x*m->rvec.x)+(src->y*m->uvec.x)+(src->z*m->fvec.x); - dest->y = (src->x*m->rvec.y)+(src->y*m->uvec.y)+(src->z*m->fvec.y); - dest->z = (src->x*m->rvec.z)+(src->y*m->uvec.z)+(src->z*m->fvec.z); + dest->xyz.x = (src->xyz.x*m->v.rvec.xyz.x)+(src->xyz.y*m->v.uvec.xyz.x)+(src->xyz.z*m->v.fvec.xyz.x); + dest->xyz.y = (src->xyz.x*m->v.rvec.xyz.y)+(src->xyz.y*m->v.uvec.xyz.y)+(src->xyz.z*m->v.fvec.xyz.y); + dest->xyz.z = (src->xyz.x*m->v.rvec.xyz.z)+(src->xyz.y*m->v.uvec.xyz.z)+(src->xyz.z*m->v.fvec.xyz.z); return dest; } @@ -1148,9 +1151,9 @@ matrix *vm_transpose_matrix(matrix *m) { float t; - t = m->uvec.x; m->uvec.x = m->rvec.y; m->rvec.y = t; - t = m->fvec.x; m->fvec.x = m->rvec.z; m->rvec.z = t; - t = m->fvec.y; m->fvec.y = m->uvec.z; m->uvec.z = t; + t = m->v.uvec.xyz.x; m->v.uvec.xyz.x = m->v.rvec.xyz.y; m->v.rvec.xyz.y = t; + t = m->v.fvec.xyz.x; m->v.fvec.xyz.x = m->v.rvec.xyz.z; m->v.rvec.xyz.z = t; + t = m->v.fvec.xyz.y; m->v.fvec.xyz.y = m->v.uvec.xyz.z; m->v.uvec.xyz.z = t; return m; } @@ -1162,17 +1165,17 @@ matrix *vm_copy_transpose_matrix(matrix *dest,matrix *src) Assert(dest != src); - dest->rvec.x = src->rvec.x; - dest->rvec.y = src->uvec.x; - dest->rvec.z = src->fvec.x; + dest->v.rvec.xyz.x = src->v.rvec.xyz.x; + dest->v.rvec.xyz.y = src->v.uvec.xyz.x; + dest->v.rvec.xyz.z = src->v.fvec.xyz.x; - dest->uvec.x = src->rvec.y; - dest->uvec.y = src->uvec.y; - dest->uvec.z = src->fvec.y; + dest->v.uvec.xyz.x = src->v.rvec.xyz.y; + dest->v.uvec.xyz.y = src->v.uvec.xyz.y; + dest->v.uvec.xyz.z = src->v.fvec.xyz.y; - dest->fvec.x = src->rvec.z; - dest->fvec.y = src->uvec.z; - dest->fvec.z = src->fvec.z; + dest->v.fvec.xyz.x = src->v.rvec.xyz.z; + dest->v.fvec.xyz.y = src->v.uvec.xyz.z; + dest->v.fvec.xyz.z = src->v.fvec.xyz.z; return dest; @@ -1185,17 +1188,17 @@ matrix *vm_matrix_x_matrix(matrix *dest,matrix *src0,matrix *src1) Assert(dest!=src0 && dest!=src1); - dest->rvec.x = vm_vec_dot3(src0->rvec.x,src0->uvec.x,src0->fvec.x, &src1->rvec); - dest->uvec.x = vm_vec_dot3(src0->rvec.x,src0->uvec.x,src0->fvec.x, &src1->uvec); - dest->fvec.x = vm_vec_dot3(src0->rvec.x,src0->uvec.x,src0->fvec.x, &src1->fvec); + dest->v.rvec.xyz.x = vm_vec_dot3(src0->v.rvec.xyz.x,src0->v.uvec.xyz.x,src0->v.fvec.xyz.x, &src1->v.rvec); + dest->v.uvec.xyz.x = vm_vec_dot3(src0->v.rvec.xyz.x,src0->v.uvec.xyz.x,src0->v.fvec.xyz.x, &src1->v.uvec); + dest->v.fvec.xyz.x = vm_vec_dot3(src0->v.rvec.xyz.x,src0->v.uvec.xyz.x,src0->v.fvec.xyz.x, &src1->v.fvec); - dest->rvec.y = vm_vec_dot3(src0->rvec.y,src0->uvec.y,src0->fvec.y, &src1->rvec); - dest->uvec.y = vm_vec_dot3(src0->rvec.y,src0->uvec.y,src0->fvec.y, &src1->uvec); - dest->fvec.y = vm_vec_dot3(src0->rvec.y,src0->uvec.y,src0->fvec.y, &src1->fvec); + dest->v.rvec.xyz.y = vm_vec_dot3(src0->v.rvec.xyz.y,src0->v.uvec.xyz.y,src0->v.fvec.xyz.y, &src1->v.rvec); + dest->v.uvec.xyz.y = vm_vec_dot3(src0->v.rvec.xyz.y,src0->v.uvec.xyz.y,src0->v.fvec.xyz.y, &src1->v.uvec); + dest->v.fvec.xyz.y = vm_vec_dot3(src0->v.rvec.xyz.y,src0->v.uvec.xyz.y,src0->v.fvec.xyz.y, &src1->v.fvec); - dest->rvec.z = vm_vec_dot3(src0->rvec.z,src0->uvec.z,src0->fvec.z, &src1->rvec); - dest->uvec.z = vm_vec_dot3(src0->rvec.z,src0->uvec.z,src0->fvec.z, &src1->uvec); - dest->fvec.z = vm_vec_dot3(src0->rvec.z,src0->uvec.z,src0->fvec.z, &src1->fvec); + dest->v.rvec.xyz.z = vm_vec_dot3(src0->v.rvec.xyz.z,src0->v.uvec.xyz.z,src0->v.fvec.xyz.z, &src1->v.rvec); + dest->v.uvec.xyz.z = vm_vec_dot3(src0->v.rvec.xyz.z,src0->v.uvec.xyz.z,src0->v.fvec.xyz.z, &src1->v.uvec); + dest->v.fvec.xyz.z = vm_vec_dot3(src0->v.rvec.xyz.z,src0->v.uvec.xyz.z,src0->v.fvec.xyz.z, &src1->v.fvec); return dest; @@ -1207,24 +1210,24 @@ angles *vm_extract_angles_matrix(angles *a,matrix *m) { float sinh,cosh,cosp; - if (m->fvec.x==0.0 && m->fvec.z==0.0) //zero head + if (m->v.fvec.xyz.x==0.0 && m->v.fvec.xyz.z==0.0) //zero head a->h = (float)0.0; else - // a->h = (float)atan2(m->fvec.z,m->fvec.x); - a->h = (float)atan2_safe(m->fvec.x,m->fvec.z); + // a->h = (float)atan2(m->v.fvec.xyz.z,m->v.fvec.xyz.x); + a->h = (float)atan2_safe(m->v.fvec.xyz.x,m->v.fvec.xyz.z); sinh = (float)sin(a->h); cosh = (float)cos(a->h); if (fl_abs(sinh) > fl_abs(cosh)) //sine is larger, so use it - cosp = m->fvec.x*sinh; + cosp = m->v.fvec.xyz.x*sinh; else //cosine is larger, so use it - cosp = m->fvec.z*cosh; + cosp = m->v.fvec.xyz.z*cosh; - if (cosp==0.0 && m->fvec.y==0.0) + if (cosp==0.0 && m->v.fvec.xyz.y==0.0) a->p = (float)0.0; else - // a->p = (float)atan2(cosp,-m->fvec.y); - a->p = (float)atan2_safe(-m->fvec.y, cosp); + // a->p = (float)atan2(cosp,-m->v.fvec.xyz.y); + a->p = (float)atan2_safe(-m->v.fvec.xyz.y, cosp); if (cosp == 0.0) //the cosine of pitch is zero. we're pitched straight up. say no bank @@ -1234,8 +1237,8 @@ angles *vm_extract_angles_matrix(angles *a,matrix *m) else { float sinb,cosb; - sinb = m->rvec.y/cosp; - cosb = m->uvec.y/cosp; + sinb = m->v.rvec.xyz.y/cosp; + cosb = m->v.uvec.xyz.y/cosp; if (sinb==0.0 && cosb==0.0) a->b = (float)0.0; @@ -1255,12 +1258,12 @@ angles *vm_extract_angles_vector_normalized(angles *a,vector *v) a->b = 0.0f; //always zero bank - a->p = (float)asin(-v->y); + a->p = (float)asin(-v->xyz.y); - if (v->x==0.0f && v->z==0.0f) + if (v->xyz.x==0.0f && v->xyz.z==0.0f) a->h = (float)0.0; else - a->h = (float)atan2_safe(v->z,v->x); + a->h = (float)atan2_safe(v->xyz.z,v->xyz.x); return a; } @@ -1326,33 +1329,33 @@ void vm_trackball( int idx, int idy, matrix * RotMat ) dxdr = dx/dr; dydr = dy/dr; - RotMat->rvec.x = cos_theta + (dydr*dydr)*cos_theta1; - RotMat->uvec.x = - ((dxdr*dydr)*cos_theta1); - RotMat->fvec.x = (dxdr*sin_theta); + RotMat->v.rvec.xyz.x = cos_theta + (dydr*dydr)*cos_theta1; + RotMat->v.uvec.xyz.x = - ((dxdr*dydr)*cos_theta1); + RotMat->v.fvec.xyz.x = (dxdr*sin_theta); - RotMat->rvec.y = RotMat->uvec.x; - RotMat->uvec.y = cos_theta + ((dxdr*dxdr)*cos_theta1); - RotMat->fvec.y = (dydr*sin_theta); + RotMat->v.rvec.xyz.y = RotMat->v.uvec.xyz.x; + RotMat->v.uvec.xyz.y = cos_theta + ((dxdr*dxdr)*cos_theta1); + RotMat->v.fvec.xyz.y = (dydr*sin_theta); - RotMat->rvec.z = -RotMat->fvec.x; - RotMat->uvec.z = -RotMat->fvec.y; - RotMat->fvec.z = cos_theta; + RotMat->v.rvec.xyz.z = -RotMat->v.fvec.xyz.x; + RotMat->v.uvec.xyz.z = -RotMat->v.fvec.xyz.y; + RotMat->v.fvec.xyz.z = cos_theta; } // Compute the outer product of A = A * transpose(A). 1x3 vector becomes 3x3 matrix. void vm_vec_outer_product(matrix *mat, vector *vec) { - mat->rvec.x = vec->x * vec->x; - mat->rvec.y = vec->x * vec->y; - mat->rvec.z = vec->x * vec->z; + mat->v.rvec.xyz.x = vec->xyz.x * vec->xyz.x; + mat->v.rvec.xyz.y = vec->xyz.x * vec->xyz.y; + mat->v.rvec.xyz.z = vec->xyz.x * vec->xyz.z; - mat->uvec.x = vec->y * vec->x; - mat->uvec.y = vec->y * vec->y; - mat->uvec.z = vec->y * vec->z; + mat->v.uvec.xyz.x = vec->xyz.y * vec->xyz.x; + mat->v.uvec.xyz.y = vec->xyz.y * vec->xyz.y; + mat->v.uvec.xyz.z = vec->xyz.y * vec->xyz.z; - mat->fvec.x = vec->z * vec->x; - mat->fvec.y = vec->z * vec->y; - mat->fvec.z = vec->z * vec->z; + mat->v.fvec.xyz.x = vec->xyz.z * vec->xyz.x; + mat->v.fvec.xyz.y = vec->xyz.z * vec->xyz.y; + mat->v.fvec.xyz.z = vec->xyz.z * vec->xyz.z; } // Find the point on the line between p0 and p1 that is nearest to int_pnt. @@ -1405,38 +1408,38 @@ void vm_orthogonalize_matrix(matrix *m_src) matrix tempm; matrix * m = &tempm; - if (vm_vec_copy_normalize(&m->fvec,&m_src->fvec) == 0.0f) { + if (vm_vec_copy_normalize(&m->v.fvec,&m_src->v.fvec) == 0.0f) { Error( LOCATION, "forward vec should not be zero-length" ); } - umag = vm_vec_mag(&m_src->uvec); - rmag = vm_vec_mag(&m_src->rvec); + umag = vm_vec_mag(&m_src->v.uvec); + rmag = vm_vec_mag(&m_src->v.rvec); if (umag <= 0.0f) { // no up vector to use.. if (rmag <= 0.0f) { // no right vector either, so make something up - if (!m->fvec.x && !m->fvec.z && m->fvec.y) // vertical vector - vm_vec_make(&m->uvec, 0.0f, 0.0f, 1.0f); + if (!m->v.fvec.xyz.x && !m->v.fvec.xyz.z && m->v.fvec.xyz.y) // vertical vector + vm_vec_make(&m->v.uvec, 0.0f, 0.0f, 1.0f); else - vm_vec_make(&m->uvec, 0.0f, 1.0f, 0.0f); + vm_vec_make(&m->v.uvec, 0.0f, 1.0f, 0.0f); } else { // use the right vector to figure up vector - vm_vec_crossprod(&m->uvec, &m->fvec, &m_src->rvec); - if (vm_vec_normalize(&m->uvec) == 0.0f) + vm_vec_crossprod(&m->v.uvec, &m->v.fvec, &m_src->v.rvec); + if (vm_vec_normalize(&m->v.uvec) == 0.0f) Error( LOCATION, "Bad vector!" ); } } else { // use source up vector - vm_vec_copy_normalize(&m->uvec, &m_src->uvec); + vm_vec_copy_normalize(&m->v.uvec, &m_src->v.uvec); } // use forward and up vectors as good vectors to calculate right vector - vm_vec_crossprod(&m->rvec, &m->uvec, &m->fvec); + vm_vec_crossprod(&m->v.rvec, &m->v.uvec, &m->v.fvec); //normalize new perpendicular vector - if (vm_vec_normalize(&m->rvec) == 0.0f) + if (vm_vec_normalize(&m->v.rvec) == 0.0f) Error( LOCATION, "Bad vector!" ); //now recompute up vector, in case it wasn't entirely perpendiclar - vm_vec_crossprod(&m->uvec, &m->fvec, &m->rvec); + vm_vec_crossprod(&m->v.uvec, &m->v.fvec, &m->v.rvec); *m_src = tempm; } @@ -1446,50 +1449,50 @@ void vm_fix_matrix(matrix *m) { float fmag, umag, rmag; - fmag = vm_vec_mag(&m->fvec); - umag = vm_vec_mag(&m->uvec); - rmag = vm_vec_mag(&m->rvec); + fmag = vm_vec_mag(&m->v.fvec); + umag = vm_vec_mag(&m->v.uvec); + rmag = vm_vec_mag(&m->v.rvec); if (fmag <= 0.0f) { - if ((umag > 0.0f) && (rmag > 0.0f) && !vm_test_parallel(&m->uvec, &m->rvec)) { - vm_vec_crossprod(&m->fvec, &m->uvec, &m->rvec); - vm_vec_normalize(&m->fvec); + if ((umag > 0.0f) && (rmag > 0.0f) && !vm_test_parallel(&m->v.uvec, &m->v.rvec)) { + vm_vec_crossprod(&m->v.fvec, &m->v.uvec, &m->v.rvec); + vm_vec_normalize(&m->v.fvec); } else if (umag > 0.0f) { - if (!m->uvec.x && !m->uvec.y && m->uvec.z) // z vector - vm_vec_make(&m->fvec, 1.0f, 0.0f, 0.0f); + if (!m->v.uvec.xyz.x && !m->v.uvec.xyz.y && m->v.uvec.xyz.z) // z vector + vm_vec_make(&m->v.fvec, 1.0f, 0.0f, 0.0f); else - vm_vec_make(&m->fvec, 0.0f, 0.0f, 1.0f); + vm_vec_make(&m->v.fvec, 0.0f, 0.0f, 1.0f); } } else - vm_vec_normalize(&m->fvec); + vm_vec_normalize(&m->v.fvec); // we now have a valid and normalized forward vector - if ((umag <= 0.0f) || vm_test_parallel(&m->fvec, &m->uvec)) { // no up vector to use.. - if ((rmag <= 0.0f) || vm_test_parallel(&m->fvec, &m->rvec)) { // no right vector either, so make something up - if (!m->fvec.x && m->fvec.y && !m->fvec.z) // vertical vector - vm_vec_make(&m->uvec, 0.0f, 0.0f, -1.0f); + if ((umag <= 0.0f) || vm_test_parallel(&m->v.fvec, &m->v.uvec)) { // no up vector to use.. + if ((rmag <= 0.0f) || vm_test_parallel(&m->v.fvec, &m->v.rvec)) { // no right vector either, so make something up + if (!m->v.fvec.xyz.x && m->v.fvec.xyz.y && !m->v.fvec.xyz.z) // vertical vector + vm_vec_make(&m->v.uvec, 0.0f, 0.0f, -1.0f); else - vm_vec_make(&m->uvec, 0.0f, 1.0f, 0.0f); + vm_vec_make(&m->v.uvec, 0.0f, 1.0f, 0.0f); } else { // use the right vector to figure up vector - vm_vec_crossprod(&m->uvec, &m->fvec, &m->rvec); - vm_vec_normalize(&m->uvec); + vm_vec_crossprod(&m->v.uvec, &m->v.fvec, &m->v.rvec); + vm_vec_normalize(&m->v.uvec); } } else - vm_vec_normalize(&m->uvec); + vm_vec_normalize(&m->v.uvec); // we now have both valid and normalized forward and up vectors - vm_vec_crossprod(&m->rvec, &m->uvec, &m->fvec); + vm_vec_crossprod(&m->v.rvec, &m->v.uvec, &m->v.fvec); //normalize new perpendicular vector - vm_vec_normalize(&m->rvec); + vm_vec_normalize(&m->v.rvec); //now recompute up vector, in case it wasn't entirely perpendiclar - vm_vec_crossprod(&m->uvec, &m->fvec, &m->rvec); + vm_vec_crossprod(&m->v.uvec, &m->v.fvec, &m->v.rvec); } //Rotates the orient matrix by the angles in tangles and then @@ -1523,27 +1526,27 @@ void compute_point_on_plane(vector *q, plane *planep, vector *p) float k, tv; vector normal; - normal.x = planep->A; - normal.y = planep->B; - normal.z = planep->C; + normal.xyz.x = planep->A; + normal.xyz.y = planep->B; + normal.xyz.z = planep->C; k = (planep->D + vm_vec_dot(&normal, p)) / vm_vec_dot(&normal, &normal); vm_vec_scale_add(q, p, &normal, -k); - tv = planep->A * q->x + planep->B * q->y + planep->C * q->z + planep->D; + tv = planep->A * q->xyz.x + planep->B * q->xyz.y + planep->C * q->xyz.z + planep->D; } // Generate a fairly random vector that's fairly near normalized. void vm_vec_rand_vec_quick(vector *rvec) { - rvec->x = (frand() - 0.5f) * 2; - rvec->y = (frand() - 0.5f) * 2; - rvec->z = (frand() - 0.5f) * 2; + rvec->xyz.x = (frand() - 0.5f) * 2; + rvec->xyz.y = (frand() - 0.5f) * 2; + rvec->xyz.z = (frand() - 0.5f) * 2; if (IS_VEC_NULL(rvec)) - rvec->x = 1.0f; + rvec->xyz.x = 1.0f; vm_vec_normalize_quick(rvec); } @@ -1587,9 +1590,9 @@ int vm_vec_cmp( vector * a, vector * b ) int vm_matrix_cmp( matrix * a, matrix * b ) { float tmp1,tmp2,tmp3; - tmp1 = (float)fl_abs(vm_vec_dot( &a->uvec, &b->uvec ) - 1.0f); - tmp2 = (float)fl_abs(vm_vec_dot( &a->fvec, &b->fvec ) - 1.0f); - tmp3 = (float)fl_abs(vm_vec_dot( &a->rvec, &b->rvec ) - 1.0f); + tmp1 = (float)fl_abs(vm_vec_dot( &a->v.uvec, &b->v.uvec ) - 1.0f); + tmp2 = (float)fl_abs(vm_vec_dot( &a->v.fvec, &b->v.fvec ) - 1.0f); + tmp3 = (float)fl_abs(vm_vec_dot( &a->v.rvec, &b->v.rvec ) - 1.0f); // mprintf(( "Mat=%.16f, %.16f, %.16f\n", tmp1, tmp2, tmp3 )); if ( tmp1 > 0.0000005f ) return 1; @@ -1636,18 +1639,18 @@ void vm_interp_angle( float *h, float desired_angle, float step_size ) // check a matrix for zero rows and columns int vm_check_matrix_for_zeros(matrix *m) { - if (!m->fvec.x && !m->fvec.y && !m->fvec.z) + if (!m->v.fvec.xyz.x && !m->v.fvec.xyz.y && !m->v.fvec.xyz.z) return 1; - if (!m->rvec.x && !m->rvec.y && !m->rvec.z) + if (!m->v.rvec.xyz.x && !m->v.rvec.xyz.y && !m->v.rvec.xyz.z) return 1; - if (!m->uvec.x && !m->uvec.y && !m->uvec.z) + if (!m->v.uvec.xyz.x && !m->v.uvec.xyz.y && !m->v.uvec.xyz.z) return 1; - if (!m->fvec.x && !m->rvec.x && !m->uvec.x) + if (!m->v.fvec.xyz.x && !m->v.rvec.xyz.x && !m->v.uvec.xyz.x) return 1; - if (!m->fvec.y && !m->rvec.y && !m->uvec.y) + if (!m->v.fvec.xyz.y && !m->v.rvec.xyz.y && !m->v.uvec.xyz.y) return 1; - if (!m->fvec.z && !m->rvec.z && !m->uvec.z) + if (!m->v.fvec.xyz.z && !m->v.rvec.xyz.z && !m->v.uvec.xyz.z) return 1; return 0; @@ -1656,7 +1659,7 @@ int vm_check_matrix_for_zeros(matrix *m) // see if two vectors are the same int vm_vec_same(vector *v1, vector *v2) { - if ( v1->x == v2->x && v1->y == v2->y && v1->z == v2->z ) + if ( v1->xyz.x == v2->xyz.x && v1->xyz.y == v2->xyz.y && v1->xyz.z == v2->xyz.z ) return 1; return 0; @@ -1677,23 +1680,23 @@ void vm_quaternion_rotate(matrix *M, float theta, vector *u) float a,b,c, s; - a = (float) (u->x * sin(theta * 0.5f)); - b = (float) (u->y * sin(theta * 0.5f)); - c = (float) (u->z * sin(theta * 0.5f)); + a = (float) (u->xyz.x * sin(theta * 0.5f)); + b = (float) (u->xyz.y * sin(theta * 0.5f)); + c = (float) (u->xyz.z * sin(theta * 0.5f)); s = (float) cos(theta/2.0); // 1st ROW vector - M->rvec.x = 1.0f - 2.0f*b*b - 2.0f*c*c; - M->rvec.y = 2.0f*a*b + 2.0f*s*c; - M->rvec.z = 2.0f*a*c - 2.0f*s*b; + M->v.rvec.xyz.x = 1.0f - 2.0f*b*b - 2.0f*c*c; + M->v.rvec.xyz.y = 2.0f*a*b + 2.0f*s*c; + M->v.rvec.xyz.z = 2.0f*a*c - 2.0f*s*b; // 2nd ROW vector - M->uvec.x = 2.0f*a*b - 2.0f*s*c; - M->uvec.y = 1.0f - 2.0f*a*a - 2.0f*c*c; - M->uvec.z = 2.0f*b*c + 2.0f*s*a; + M->v.uvec.xyz.x = 2.0f*a*b - 2.0f*s*c; + M->v.uvec.xyz.y = 1.0f - 2.0f*a*a - 2.0f*c*c; + M->v.uvec.xyz.z = 2.0f*b*c + 2.0f*s*a; // 3rd ROW vector - M->fvec.x = 2.0f*a*c + 2.0f*s*b; - M->fvec.y = 2.0f*b*c - 2.0f*s*a; - M->fvec.z = 1.0f - 2.0f*a*a - 2.0f*b*b; + M->v.fvec.xyz.x = 2.0f*a*c + 2.0f*s*b; + M->v.fvec.xyz.y = 2.0f*b*c - 2.0f*s*a; + M->v.fvec.xyz.z = 1.0f - 2.0f*a*a - 2.0f*b*b; } // -------------------------------------------------------------------------------------- @@ -1705,17 +1708,17 @@ void vm_quaternion_rotate(matrix *M, float theta, vector *u) // void rotate_z ( matrix *m, float theta ) { - m->rvec.x = (float) cos (theta); - m->rvec.y = (float) sin (theta); - m->rvec.z = 0.0f; + m->v.rvec.xyz.x = (float) cos (theta); + m->v.rvec.xyz.y = (float) sin (theta); + m->v.rvec.xyz.z = 0.0f; - m->uvec.x = -m->rvec.y; - m->uvec.y = m->rvec.x; - m->uvec.z = 0.0f; + m->v.uvec.xyz.x = -m->v.rvec.xyz.y; + m->v.uvec.xyz.y = m->v.rvec.xyz.x; + m->v.uvec.xyz.z = 0.0f; - m->fvec.x = 0.0f; - m->fvec.y = 0.0f; - m->fvec.z = 1.0f; + m->v.fvec.xyz.x = 0.0f; + m->v.fvec.xyz.y = 0.0f; + m->v.fvec.xyz.z = 1.0f; } @@ -1742,9 +1745,9 @@ void vm_matrix_to_rot_axis_and_angle(matrix *m, float *theta, vector *rot_axis) *theta = float(acos(cos_theta)); Assert(!_isnan(*theta)); - rot_axis->x = (m->uvec.z - m->fvec.y); - rot_axis->y = (m->fvec.x - m->rvec.z); - rot_axis->z = (m->rvec.y - m->uvec.x); + rot_axis->xyz.x = (m->v.uvec.xyz.z - m->v.fvec.xyz.y); + rot_axis->xyz.y = (m->v.fvec.xyz.x - m->v.rvec.xyz.z); + rot_axis->xyz.z = (m->v.rvec.xyz.y - m->v.uvec.xyz.x); vm_vec_normalize(rot_axis); } else { // angle is PI within limits *theta = PI; @@ -1762,31 +1765,31 @@ void vm_matrix_to_rot_axis_and_angle(matrix *m, float *theta, vector *rot_axis) switch (largest_diagonal_index) { case 0: float ix; - ix = 1.0f / rot_axis->x; + ix = 1.0f / rot_axis->xyz.x; - rot_axis->x = fl_sqrt(m->a2d[0][0] + 1.0f); - rot_axis->y = m->a2d[0][1] * ix; - rot_axis->z = m->a2d[0][2] * ix; + rot_axis->xyz.x = fl_sqrt(m->a2d[0][0] + 1.0f); + rot_axis->xyz.y = m->a2d[0][1] * ix; + rot_axis->xyz.z = m->a2d[0][2] * ix; vm_vec_normalize(rot_axis); break; case 1: float iy; - iy = 1.0f / rot_axis->y; + iy = 1.0f / rot_axis->xyz.y; - rot_axis->y = fl_sqrt(m->a2d[1][1] + 1.0f); - rot_axis->x = m->a2d[1][0] * iy; - rot_axis->z = m->a2d[1][2] * iy; + rot_axis->xyz.y = fl_sqrt(m->a2d[1][1] + 1.0f); + rot_axis->xyz.x = m->a2d[1][0] * iy; + rot_axis->xyz.z = m->a2d[1][2] * iy; vm_vec_normalize(rot_axis); break; case 2: float iz; - iz = 1.0f / rot_axis->z; + iz = 1.0f / rot_axis->xyz.z; - rot_axis->z = fl_sqrt(m->a2d[2][2] + 1.0f); - rot_axis->x = m->a2d[2][0] * iz; - rot_axis->y = m->a2d[2][1] * iz; + rot_axis->xyz.z = fl_sqrt(m->a2d[2][2] + 1.0f); + rot_axis->xyz.x = m->a2d[2][0] * iz; + rot_axis->xyz.y = m->a2d[2][1] * iz; break; default: @@ -2004,93 +2007,93 @@ void vm_matrix_interpolate(matrix *goal_orient, matrix *curr_orient, vector *w_i float delta_theta; // find rotation about x - if (theta_goal.x > 0) { - if (w_in->x >= 0) { - delta_theta = approach(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; - } else { // w_in->x < 0 - delta_theta = away(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; + if (theta_goal.xyz.x > 0) { + if (w_in->xyz.x >= 0) { + delta_theta = approach(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; + } else { // w_in->xyz.x < 0 + delta_theta = away(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; } - } else if (theta_goal.x < 0) { - if (w_in->x <= 0) { - delta_theta = approach(-w_in->x, vel_limit->x, -theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; - } else { // w_in->x > 0 - delta_theta = away(-w_in->x, vel_limit->x, -theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; + } else if (theta_goal.xyz.x < 0) { + if (w_in->xyz.x <= 0) { + delta_theta = approach(-w_in->xyz.x, vel_limit->xyz.x, -theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; + } else { // w_in->xyz.x > 0 + delta_theta = away(-w_in->xyz.x, vel_limit->xyz.x, -theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; } } else { // theta_goal == 0 - if (w_in->x < 0) { - delta_theta = away(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; + if (w_in->xyz.x < 0) { + delta_theta = away(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; } else { - delta_theta = away(-w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; + delta_theta = away(-w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; } } // find rotation about y - if (theta_goal.y > 0) { - if (w_in->y >= 0) { - delta_theta = approach(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; - } else { // w_in->y < 0 - delta_theta = away(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; + if (theta_goal.xyz.y > 0) { + if (w_in->xyz.y >= 0) { + delta_theta = approach(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; + } else { // w_in->xyz.y < 0 + delta_theta = away(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; } - } else if (theta_goal.y < 0) { - if (w_in->y <= 0) { - delta_theta = approach(-w_in->y, vel_limit->y, -theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; - } else { // w_in->y > 0 - delta_theta = away(-w_in->y, vel_limit->y, -theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; + } else if (theta_goal.xyz.y < 0) { + if (w_in->xyz.y <= 0) { + delta_theta = approach(-w_in->xyz.y, vel_limit->xyz.y, -theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; + } else { // w_in->xyz.y > 0 + delta_theta = away(-w_in->xyz.y, vel_limit->xyz.y, -theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; } } else { // theta_goal == 0 - if (w_in->y < 0) { - delta_theta = away(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; + if (w_in->xyz.y < 0) { + delta_theta = away(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; } else { - delta_theta = away(-w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; + delta_theta = away(-w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; } } // find rotation about z - if (theta_goal.z > 0) { - if (w_in->z >= 0) { - delta_theta = approach(w_in->z, vel_limit->z, theta_goal.z, acc_limit->z, delta_t, &w_out->z, no_overshoot); - theta_end.z = delta_theta; - } else { // w_in->z < 0 - delta_theta = away(w_in->z, vel_limit->z, theta_goal.z, acc_limit->z, delta_t, &w_out->z, no_overshoot); - theta_end.z = delta_theta; + if (theta_goal.xyz.z > 0) { + if (w_in->xyz.z >= 0) { + delta_theta = approach(w_in->xyz.z, vel_limit->xyz.z, theta_goal.xyz.z, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); + theta_end.xyz.z = delta_theta; + } else { // w_in->xyz.z < 0 + delta_theta = away(w_in->xyz.z, vel_limit->xyz.z, theta_goal.xyz.z, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); + theta_end.xyz.z = delta_theta; } - } else if (theta_goal.z < 0) { - if (w_in->z <= 0) { - delta_theta = approach(-w_in->z, vel_limit->z, -theta_goal.z, acc_limit->z, delta_t, &w_out->z, no_overshoot); - theta_end.z = -delta_theta; - w_out->z = -w_out->z; - } else { // w_in->z > 0 - delta_theta = away(-w_in->z, vel_limit->z, -theta_goal.z, acc_limit->z, delta_t, &w_out->z, no_overshoot); - theta_end.z = -delta_theta; - w_out->z = -w_out->z; + } else if (theta_goal.xyz.z < 0) { + if (w_in->xyz.z <= 0) { + delta_theta = approach(-w_in->xyz.z, vel_limit->xyz.z, -theta_goal.xyz.z, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); + theta_end.xyz.z = -delta_theta; + w_out->xyz.z = -w_out->xyz.z; + } else { // w_in->xyz.z > 0 + delta_theta = away(-w_in->xyz.z, vel_limit->xyz.z, -theta_goal.xyz.z, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); + theta_end.xyz.z = -delta_theta; + w_out->xyz.z = -w_out->xyz.z; } } else { // theta_goal == 0 - if (w_in->z < 0) { - delta_theta = away(w_in->z, vel_limit->z, theta_goal.z, acc_limit->z, delta_t, &w_out->z, no_overshoot); - theta_end.z = delta_theta; + if (w_in->xyz.z < 0) { + delta_theta = away(w_in->xyz.z, vel_limit->xyz.z, theta_goal.xyz.z, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); + theta_end.xyz.z = delta_theta; } else { - delta_theta = away(-w_in->z, vel_limit->z, theta_goal.z, acc_limit->z, delta_t, &w_out->z, no_overshoot); - theta_end.z = -delta_theta; - w_out->z = -w_out->z; + delta_theta = away(-w_in->xyz.z, vel_limit->xyz.z, theta_goal.xyz.z, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); + theta_end.xyz.z = -delta_theta; + w_out->xyz.z = -w_out->xyz.z; } } @@ -2105,7 +2108,7 @@ void vm_matrix_interpolate(matrix *goal_orient, matrix *curr_orient, vector *w_i theta = vm_vec_normalize(&rot_axis); // arrived at goal? - if (theta_end.x == theta_goal.x && theta_end.y == theta_goal.y && theta_end.z == theta_goal.z) { + if (theta_end.xyz.x == theta_goal.xyz.x && theta_end.xyz.y == theta_goal.xyz.y && theta_end.xyz.z == theta_goal.xyz.z) { *next_orient = *goal_orient; } else { // otherwise rotate to better position @@ -2136,9 +2139,9 @@ void get_camera_limits(matrix *start_camera, matrix *end_camera, float time, vec vm_matrix_to_rot_axis_and_angle(&rot_matrix, &theta, &rot_axis); // find the rotation about each axis - angle.x = theta * rot_axis.x; - angle.y = theta * rot_axis.y; - angle.z = theta * rot_axis.z; + angle.xyz.x = theta * rot_axis.xyz.x; + angle.xyz.y = theta * rot_axis.xyz.y; + angle.xyz.z = theta * rot_axis.xyz.z; // allow for 0 time input if (time <= 1e-5f) { @@ -2148,15 +2151,15 @@ void get_camera_limits(matrix *start_camera, matrix *end_camera, float time, vec // find acceleration limit using (theta/2) takes (time/2) // and using const accel theta = 1/2 acc * time^2 - acc_max->x = 4.0f * (float)fl_abs(angle.x) / (time * time); - acc_max->y = 4.0f * (float)fl_abs(angle.y) / (time * time); - acc_max->z = 4.0f * (float)fl_abs(angle.z) / (time * time); + acc_max->xyz.x = 4.0f * (float)fl_abs(angle.xyz.x) / (time * time); + acc_max->xyz.y = 4.0f * (float)fl_abs(angle.xyz.y) / (time * time); + acc_max->xyz.z = 4.0f * (float)fl_abs(angle.xyz.z) / (time * time); // find angular velocity limits // w_max = acc_max * time / 2 - w_max->x = acc_max->x * time / 2.0f; - w_max->y = acc_max->y * time / 2.0f; - w_max->z = acc_max->z * time / 2.0f; + w_max->xyz.x = acc_max->xyz.x * time / 2.0f; + w_max->xyz.y = acc_max->xyz.y * time / 2.0f; + w_max->xyz.z = acc_max->xyz.z * time / 2.0f; } } @@ -2188,20 +2191,20 @@ void vm_fvec_matrix_interpolate(matrix *goal_orient, matrix *orient, vector *w_i float bank; // magnitude of rotation about the forward axis int no_bank; // flag set if there is no bank for the object vector vtemp; // temp angular velocity before rotation about z - float z_dotprod; // dotprod of orient->fvec and goal_orient->fvec - float r_dotprod; // dotprod of orient->rvec and goal_orient->rvec + float z_dotprod; // dotprod of orient->v.fvec and goal_orient->v.fvec + float r_dotprod; // dotprod of orient->v.rvec and goal_orient->v.rvec float delta_bank; // FIND XY ROTATION NEEDED FOR GOAL - // rotation vector is (current fvec) orient->fvec x goal_f + // rotation vector is (current fvec) orient->v.fvec x goal_f // magnitude = asin ( magnitude of crossprod ) - vm_vec_crossprod ( &rot_axis, &orient->fvec, &goal_orient->fvec ); + vm_vec_crossprod ( &rot_axis, &orient->v.fvec, &goal_orient->v.fvec ); float t = vm_vec_mag(&rot_axis); if (t > 1.0f) t = 1.0f; - z_dotprod = vm_vec_dotprod ( &orient->fvec, &goal_orient->fvec ); + z_dotprod = vm_vec_dotprod ( &orient->v.fvec, &goal_orient->v.fvec ); if ( t < SMALLER_NUM ) { if ( z_dotprod > 0.0f ) @@ -2209,7 +2212,7 @@ void vm_fvec_matrix_interpolate(matrix *goal_orient, matrix *orient, vector *w_i else { // the forward vector is pointing exactly opposite of goal // arbitrarily choose the x axis to rotate around until t becomes large enough theta = PI; - rot_axis = orient->rvec; + rot_axis = orient->v.rvec; } } else { theta = (float) asin ( t ); @@ -2223,73 +2226,73 @@ void vm_fvec_matrix_interpolate(matrix *goal_orient, matrix *orient, vector *w_i // find theta to goal vm_vec_copy_scale(&theta_goal, &local_rot_axis, theta); - Assert ( fl_abs (theta_goal.z) < 0.001f ); // check for proper rotation + Assert ( fl_abs (theta_goal.xyz.z) < 0.001f ); // check for proper rotation theta_end = vmd_zero_vector; float delta_theta; // find rotation about x - if (theta_goal.x > 0) { - if (w_in->x >= 0) { - delta_theta = approach(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; - } else { // w_in->x < 0 - delta_theta = away(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; + if (theta_goal.xyz.x > 0) { + if (w_in->xyz.x >= 0) { + delta_theta = approach(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; + } else { // w_in->xyz.x < 0 + delta_theta = away(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; } - } else if (theta_goal.x < 0) { - if (w_in->x <= 0) { - delta_theta = approach(-w_in->x, vel_limit->x, -theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; - } else { // w_in->x > 0 - delta_theta = away(-w_in->x, vel_limit->x, -theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; + } else if (theta_goal.xyz.x < 0) { + if (w_in->xyz.x <= 0) { + delta_theta = approach(-w_in->xyz.x, vel_limit->xyz.x, -theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; + } else { // w_in->xyz.x > 0 + delta_theta = away(-w_in->xyz.x, vel_limit->xyz.x, -theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; } } else { // theta_goal == 0 - if (w_in->x < 0) { - delta_theta = away(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; + if (w_in->xyz.x < 0) { + delta_theta = away(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; } else { - delta_theta = away(-w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; + delta_theta = away(-w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; } } // find rotation about y - if (theta_goal.y > 0) { - if (w_in->y >= 0) { - delta_theta = approach(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; - } else { // w_in->y < 0 - delta_theta = away(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; + if (theta_goal.xyz.y > 0) { + if (w_in->xyz.y >= 0) { + delta_theta = approach(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; + } else { // w_in->xyz.y < 0 + delta_theta = away(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; } - } else if (theta_goal.y < 0) { - if (w_in->y <= 0) { - delta_theta = approach(-w_in->y, vel_limit->y, -theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; - } else { // w_in->y > 0 - delta_theta = away(-w_in->y, vel_limit->y, -theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; + } else if (theta_goal.xyz.y < 0) { + if (w_in->xyz.y <= 0) { + delta_theta = approach(-w_in->xyz.y, vel_limit->xyz.y, -theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; + } else { // w_in->xyz.y > 0 + delta_theta = away(-w_in->xyz.y, vel_limit->xyz.y, -theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; } } else { // theta_goal == 0 - if (w_in->y < 0) { - delta_theta = away(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; + if (w_in->xyz.y < 0) { + delta_theta = away(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; } else { - delta_theta = away(-w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; + delta_theta = away(-w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; } } // FIND Z ROTATON MATRIX - theta_end.z = 0.0f; + theta_end.xyz.z = 0.0f; rot_axis = theta_end; Assert(is_valid_vec(&rot_axis)); @@ -2309,29 +2312,29 @@ void vm_fvec_matrix_interpolate(matrix *goal_orient, matrix *orient, vector *w_i // FIND ROTATION ABOUT Z (IF ANY) // no rotation if delta_bank and w_in both 0 or rotational acc in forward is 0 - no_bank = ( acc_limit->z == 0.0f && vel_limit->z == 0.0f ); + no_bank = ( acc_limit->xyz.z == 0.0f && vel_limit->xyz.z == 0.0f ); if ( no_bank ) { // no rotation on z, so we're done (no rotation of w) *next_orient = M_intermed; vm_orthogonalize_matrix ( next_orient ); return; } else { - // calculate delta_bank using orient->rvec, goal_orient->rvec + // calculate delta_bank using orient->v.rvec, goal_orient->v.rvec // - vm_vec_crossprod ( &rot_axis, &orient->rvec, &goal_orient->rvec ); + vm_vec_crossprod ( &rot_axis, &orient->v.rvec, &goal_orient->v.rvec ); t = vm_vec_mag(&rot_axis); if (t > 1.0f) t = 1.0f; - r_dotprod = vm_vec_dotprod ( &orient->rvec, &goal_orient->rvec ); + r_dotprod = vm_vec_dotprod ( &orient->v.rvec, &goal_orient->v.rvec ); if ( t < SMALLER_NUM ) { if ( r_dotprod > 0.0f ) theta = 0.0f; else { // the right vector is pointing exactly opposite of goal, so rotate 180 on z theta = PI; - rot_axis = orient->fvec; + rot_axis = orient->v.fvec; } } else { theta = (float) asin ( t ); @@ -2343,39 +2346,39 @@ void vm_fvec_matrix_interpolate(matrix *goal_orient, matrix *orient, vector *w_i // rotate rot_axis into ship reference frame vm_vec_rotate ( &local_rot_axis, &rot_axis, orient ); - // find theta.z to goal - delta_bank = local_rot_axis.z * theta; - Assert( fl_abs (local_rot_axis.x) < 0.001f ); // check for proper rotation + // find theta.xyz.z to goal + delta_bank = local_rot_axis.xyz.z * theta; + Assert( fl_abs (local_rot_axis.xyz.x) < 0.001f ); // check for proper rotation bank = 0.0f; // end calculate delta_bank // find rotation about z if (delta_bank > 0) { - if (w_in->z >= 0) { - delta_theta = approach(w_in->z, vel_limit->z, delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + if (w_in->xyz.z >= 0) { + delta_theta = approach(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = delta_theta; - } else { // w_in->z < 0 - delta_theta = away(w_in->z, vel_limit->z, delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + } else { // w_in->xyz.z < 0 + delta_theta = away(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = delta_theta; } } else if (delta_bank < 0) { - if (w_in->z <= 0) { - delta_theta = approach(-w_in->z, vel_limit->z, -delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + if (w_in->xyz.z <= 0) { + delta_theta = approach(-w_in->xyz.z, vel_limit->xyz.z, -delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = -delta_theta; - w_out->z = -w_out->z; - } else { // w_in->z > 0 - delta_theta = away(-w_in->z, vel_limit->z, -delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + w_out->xyz.z = -w_out->xyz.z; + } else { // w_in->xyz.z > 0 + delta_theta = away(-w_in->xyz.z, vel_limit->xyz.z, -delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = -delta_theta; - w_out->z = -w_out->z; + w_out->xyz.z = -w_out->xyz.z; } } else { // theta_goal == 0 - if (w_in->z < 0) { - delta_theta = away(w_in->z, vel_limit->z, delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + if (w_in->xyz.z < 0) { + delta_theta = away(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = delta_theta; } else { - delta_theta = away(-w_in->z, vel_limit->z, delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + delta_theta = away(-w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = -delta_theta; - w_out->z = -w_out->z; + w_out->xyz.z = -w_out->xyz.z; } } @@ -2427,15 +2430,15 @@ void vm_forward_interpolate(vector *goal_f, matrix *orient, vector *w_in, float float z_dotprod; // FIND ROTATION NEEDED FOR GOAL - // rotation vector is (current fvec) orient->fvec x goal_f + // rotation vector is (current fvec) orient->v.fvec x goal_f // magnitude = asin ( magnitude of crossprod ) - vm_vec_crossprod( &rot_axis, &orient->fvec, goal_f ); + vm_vec_crossprod( &rot_axis, &orient->v.fvec, goal_f ); float t = vm_vec_mag(&rot_axis); if (t > 1.0f) t = 1.0f; - z_dotprod = vm_vec_dotprod( &orient->fvec, goal_f ); + z_dotprod = vm_vec_dotprod( &orient->v.fvec, goal_f ); if ( t < SMALLER_NUM ) { if ( z_dotprod > 0.0f ) @@ -2443,7 +2446,7 @@ void vm_forward_interpolate(vector *goal_f, matrix *orient, vector *w_in, float else { // the forward vector is pointing exactly opposite of goal // arbitrarily choose the x axis to rotate around until t becomes large enough theta = PI; - rot_axis = orient->rvec; + rot_axis = orient->v.rvec; } } else { theta = (float) asin( t ); @@ -2457,73 +2460,73 @@ void vm_forward_interpolate(vector *goal_f, matrix *orient, vector *w_in, float // find theta to goal vm_vec_copy_scale(&theta_goal, &local_rot_axis, theta); - Assert(fl_abs(theta_goal.z) < 0.001f); // check for proper rotation + Assert(fl_abs(theta_goal.xyz.z) < 0.001f); // check for proper rotation theta_end = vmd_zero_vector; float delta_theta; // find rotation about x - if (theta_goal.x > 0) { - if (w_in->x >= 0) { - delta_theta = approach(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; - } else { // w_in->x < 0 - delta_theta = away(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; + if (theta_goal.xyz.x > 0) { + if (w_in->xyz.x >= 0) { + delta_theta = approach(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; + } else { // w_in->xyz.x < 0 + delta_theta = away(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; } - } else if (theta_goal.x < 0) { - if (w_in->x <= 0) { - delta_theta = approach(-w_in->x, vel_limit->x, -theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; - } else { // w_in->x > 0 - delta_theta = away(-w_in->x, vel_limit->x, -theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; + } else if (theta_goal.xyz.x < 0) { + if (w_in->xyz.x <= 0) { + delta_theta = approach(-w_in->xyz.x, vel_limit->xyz.x, -theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; + } else { // w_in->xyz.x > 0 + delta_theta = away(-w_in->xyz.x, vel_limit->xyz.x, -theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; } } else { // theta_goal == 0 - if (w_in->x < 0) { - delta_theta = away(w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = delta_theta; + if (w_in->xyz.x < 0) { + delta_theta = away(w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = delta_theta; } else { - delta_theta = away(-w_in->x, vel_limit->x, theta_goal.x, acc_limit->x, delta_t, &w_out->x, no_overshoot); - theta_end.x = -delta_theta; - w_out->x = -w_out->x; + delta_theta = away(-w_in->xyz.x, vel_limit->xyz.x, theta_goal.xyz.x, acc_limit->xyz.x, delta_t, &w_out->xyz.x, no_overshoot); + theta_end.xyz.x = -delta_theta; + w_out->xyz.x = -w_out->xyz.x; } } // find rotation about y - if (theta_goal.y > 0) { - if (w_in->y >= 0) { - delta_theta = approach(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; - } else { // w_in->y < 0 - delta_theta = away(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; + if (theta_goal.xyz.y > 0) { + if (w_in->xyz.y >= 0) { + delta_theta = approach(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; + } else { // w_in->xyz.y < 0 + delta_theta = away(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; } - } else if (theta_goal.y < 0) { - if (w_in->y <= 0) { - delta_theta = approach(-w_in->y, vel_limit->y, -theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; - } else { // w_in->y > 0 - delta_theta = away(-w_in->y, vel_limit->y, -theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; + } else if (theta_goal.xyz.y < 0) { + if (w_in->xyz.y <= 0) { + delta_theta = approach(-w_in->xyz.y, vel_limit->xyz.y, -theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; + } else { // w_in->xyz.y > 0 + delta_theta = away(-w_in->xyz.y, vel_limit->xyz.y, -theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; } } else { // theta_goal == 0 - if (w_in->y < 0) { - delta_theta = away(w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = delta_theta; + if (w_in->xyz.y < 0) { + delta_theta = away(w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = delta_theta; } else { - delta_theta = away(-w_in->y, vel_limit->y, theta_goal.y, acc_limit->y, delta_t, &w_out->y, no_overshoot); - theta_end.y = -delta_theta; - w_out->y = -w_out->y; + delta_theta = away(-w_in->xyz.y, vel_limit->xyz.y, theta_goal.xyz.y, acc_limit->xyz.y, delta_t, &w_out->xyz.y, no_overshoot); + theta_end.xyz.y = -delta_theta; + w_out->xyz.y = -w_out->xyz.y; } } // no rotation if delta_bank and w_in both 0 or rotational acc in forward is 0 - no_bank = ( delta_bank == 0.0f && vel_limit->z == 0.0f && acc_limit->z == 0.0f ); + no_bank = ( delta_bank == 0.0f && vel_limit->xyz.z == 0.0f && acc_limit->xyz.z == 0.0f ); // do rotation about z bank = 0.0f; @@ -2533,31 +2536,31 @@ void vm_forward_interpolate(vector *goal_f, matrix *orient, vector *w_in, float // find rotation about z if (delta_bank > 0) { - if (w_in->z >= 0) { - delta_theta = approach(w_in->z, vel_limit->z, delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + if (w_in->xyz.z >= 0) { + delta_theta = approach(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = delta_theta; - } else { // w_in->z < 0 - delta_theta = away(w_in->z, vel_limit->z, delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + } else { // w_in->xyz.z < 0 + delta_theta = away(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = delta_theta; } } else if (delta_bank < 0) { - if (w_in->z <= 0) { - delta_theta = approach(-w_in->z, vel_limit->z, -delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + if (w_in->xyz.z <= 0) { + delta_theta = approach(-w_in->xyz.z, vel_limit->xyz.z, -delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = -delta_theta; - w_out->z = -w_out->z; - } else { // w_in->z > 0 - delta_theta = away(-w_in->z, vel_limit->z, -delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + w_out->xyz.z = -w_out->xyz.z; + } else { // w_in->xyz.z > 0 + delta_theta = away(-w_in->xyz.z, vel_limit->xyz.z, -delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = -delta_theta; - w_out->z = -w_out->z; + w_out->xyz.z = -w_out->xyz.z; } } else { // theta_goal == 0 - if (w_in->z < 0) { - delta_theta = away(w_in->z, vel_limit->z, delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + if (w_in->xyz.z < 0) { + delta_theta = away(w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = delta_theta; } else { - delta_theta = away(-w_in->z, vel_limit->z, delta_bank, acc_limit->z, delta_t, &w_out->z, no_overshoot); + delta_theta = away(-w_in->xyz.z, vel_limit->xyz.z, delta_bank, acc_limit->xyz.z, delta_t, &w_out->xyz.z, no_overshoot); bank = -delta_theta; - w_out->z = -w_out->z; + w_out->xyz.z = -w_out->xyz.z; } } } @@ -2565,7 +2568,7 @@ void vm_forward_interpolate(vector *goal_f, matrix *orient, vector *w_in, float // the amount of rotation about each axis is determined in // functions approach and away. first find the magnitude // of the rotation and then normalize the axis (ship coords) - theta_end.z = bank; + theta_end.xyz.z = bank; rot_axis = theta_end; // normalize rotation axis and determine total rotation angle @@ -2609,22 +2612,22 @@ void vm_find_bounding_sphere(vector *pnts, int num_pnts, vector *center, float * xmax = vmd_zero_vector; ymax = vmd_zero_vector; zmax = vmd_zero_vector; - xmin.x = ymin.y = zmin.z = BIGNUMBER; - xmax.x = ymax.y = zmax.z = -BIGNUMBER; + xmin.xyz.x = ymin.xyz.y = zmin.xyz.z = BIGNUMBER; + xmax.xyz.x = ymax.xyz.y = zmax.xyz.z = -BIGNUMBER; for ( i = 0; i < num_pnts; i++ ) { p = &pnts[i]; - if ( p->x < xmin.x ) + if ( p->xyz.x < xmin.xyz.x ) xmin = *p; - if ( p->x > xmax.x ) + if ( p->xyz.x > xmax.xyz.x ) xmax = *p; - if ( p->y < ymin.y ) + if ( p->xyz.y < ymin.xyz.y ) ymin = *p; - if ( p->y > ymax.y ) + if ( p->xyz.y > ymax.xyz.y ) ymax = *p; - if ( p->z < zmin.z ) + if ( p->xyz.z < zmin.xyz.z ) zmin = *p; - if ( p->z > zmax.z ) + if ( p->xyz.z > zmax.xyz.z ) zmax = *p; } @@ -2673,10 +2676,10 @@ void vm_find_bounding_sphere(vector *pnts, int num_pnts, vector *center, float * rad_sq = rad * rad; old_to_new = old_to_p - rad; // calc new center of sphere - center->x = (rad*center->x + old_to_new*p->x) / old_to_p; - center->y = (rad*center->y + old_to_new*p->y) / old_to_p; - center->z = (rad*center->z + old_to_new*p->z) / old_to_p; - nprintf(("Alan", "New sphere: cen,rad = %f %f %f %f\n", center->x, center->y, center->z, rad)); + center->xyz.x = (rad*center->xyz.x + old_to_new*p->xyz.x) / old_to_p; + center->xyz.y = (rad*center->xyz.y + old_to_new*p->xyz.y) / old_to_p; + center->xyz.z = (rad*center->xyz.z + old_to_new*p->xyz.z) / old_to_p; + nprintf(("Alan", "New sphere: cen,rad = %f %f %f %f\n", center->xyz.x, center->xyz.y, center->xyz.z, rad)); } } @@ -2737,13 +2740,13 @@ void vm_estimate_next_orientation(matrix *last_orient, matrix *current_orient, m // Return true if all elements of *vec are legal, that is, not a NAN. int is_valid_vec(vector *vec) { - return !_isnan(vec->x) && !_isnan(vec->y) && !_isnan(vec->z); + return !_isnan(vec->xyz.x) && !_isnan(vec->xyz.y) && !_isnan(vec->xyz.z); } // Return true if all elements of *m are legal, that is, not a NAN. int is_valid_matrix(matrix *m) { - return is_valid_vec(&m->fvec) && is_valid_vec(&m->uvec) && is_valid_vec(&m->rvec); + return is_valid_vec(&m->v.fvec) && is_valid_vec(&m->v.uvec) && is_valid_vec(&m->v.rvec); } // interpolate between 2 vectors. t goes from 0.0 to 1.0. at @@ -2779,13 +2782,13 @@ void vm_vec_random_cone(vector *out, vector *in, float max_angle, matrix *orient } // axis 1 - vm_rot_point_around_line(&t1, in, fl_radian(frand_range(-max_angle, max_angle)), &vmd_zero_vector, &rot->fvec); + vm_rot_point_around_line(&t1, in, fl_radian(frand_range(-max_angle, max_angle)), &vmd_zero_vector, &rot->v.fvec); // axis 2 - vm_rot_point_around_line(&t2, &t1, fl_radian(frand_range(-max_angle, max_angle)), &vmd_zero_vector, &rot->rvec); + vm_rot_point_around_line(&t2, &t1, fl_radian(frand_range(-max_angle, max_angle)), &vmd_zero_vector, &rot->v.rvec); // axis 3 - vm_rot_point_around_line(out, &t2, fl_radian(frand_range(-max_angle, max_angle)), &vmd_zero_vector, &rot->uvec); + vm_rot_point_around_line(out, &t2, fl_radian(frand_range(-max_angle, max_angle)), &vmd_zero_vector, &rot->v.uvec); } // given a start vector, an orientation and a radius, give a point on the plane of the circle @@ -2795,10 +2798,10 @@ void vm_vec_random_in_circle(vector *out, vector *in, matrix *orient, float radi vector temp; // point somewhere in the plane - vm_vec_scale_add(&temp, in, &orient->rvec, on_edge ? radius : frand_range(0.0f, radius)); + vm_vec_scale_add(&temp, in, &orient->v.rvec, on_edge ? radius : frand_range(0.0f, radius)); // rotate to a random point on the circle - vm_rot_point_around_line(out, &temp, fl_radian(frand_range(0.0f, 359.0f)), in, &orient->fvec); + vm_rot_point_around_line(out, &temp, fl_radian(frand_range(0.0f, 359.0f)), in, &orient->v.fvec); } // find the nearest point on the line to p. if dist is non-NULL, it is filled in diff --git a/src/menuui/techmenu.cpp b/src/menuui/techmenu.cpp index ce6ff88..92d3495 100644 --- a/src/menuui/techmenu.cpp +++ b/src/menuui/techmenu.cpp @@ -15,6 +15,9 @@ * C module that contains functions to drive the Tech Menu user interface * * $Log$ + * Revision 1.5 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:22 relnev * added copyright header * @@ -771,7 +774,7 @@ void techroom_ships_render(float frametime) // lighting for techroom light_reset(); vector light_dir = vmd_zero_vector; - light_dir.y = 1.0f; + light_dir.xyz.y = 1.0f; light_add_directional(&light_dir, 0.85f, 1.0f, 1.0f, 1.0f); // light_filter_reset(); light_rotate_all(); diff --git a/src/mission/missionbriefcommon.cpp b/src/mission/missionbriefcommon.cpp index 05caead..896df62 100644 --- a/src/mission/missionbriefcommon.cpp +++ b/src/mission/missionbriefcommon.cpp @@ -15,6 +15,9 @@ * C module for briefing code common to FreeSpace and FRED * * $Log$ + * Revision 1.6 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.5 2002/06/09 04:41:22 relnev * added copyright header * @@ -1555,20 +1558,20 @@ void brief_render_elements(vector *pos, grid* gridp) plane tplane; vector *gv; - if ( pos->y < 1 && pos->y > -1 ) + if ( pos->xyz.y < 1 && pos->xyz.y > -1 ) return; - tplane.A = gridp->gmatrix.uvec.x; - tplane.B = gridp->gmatrix.uvec.y; - tplane.C = gridp->gmatrix.uvec.z; + tplane.A = gridp->gmatrix.v.uvec.xyz.x; + tplane.B = gridp->gmatrix.v.uvec.xyz.y; + tplane.C = gridp->gmatrix.v.uvec.xyz.z; tplane.D = gridp->planeD; compute_point_on_plane(&gpos, &tplane, pos); dxz = vm_vec_dist(pos, &gpos)/8.0f; - gv = &gridp->gmatrix.uvec; - if (gv->x * pos->x + gv->y * pos->y + gv->z * pos->z < -gridp->planeD) + gv = &gridp->gmatrix.v.uvec; + if (gv->xyz.x * pos->xyz.x + gv->xyz.y * pos->xyz.y + gv->xyz.z * pos->xyz.z < -gridp->planeD) gr_set_color(127, 127, 127); else gr_set_color(255, 255, 255); // white @@ -1579,16 +1582,16 @@ void brief_render_elements(vector *pos, grid* gridp) tpos = gpos; - vm_vec_scale_add2(&gpos, &gridp->gmatrix.rvec, -dxz/2); - vm_vec_scale_add2(&gpos, &gridp->gmatrix.fvec, -dxz/2); + vm_vec_scale_add2(&gpos, &gridp->gmatrix.v.rvec, -dxz/2); + vm_vec_scale_add2(&gpos, &gridp->gmatrix.v.fvec, -dxz/2); - vm_vec_scale_add2(&tpos, &gridp->gmatrix.rvec, dxz/2); - vm_vec_scale_add2(&tpos, &gridp->gmatrix.fvec, dxz/2); + vm_vec_scale_add2(&tpos, &gridp->gmatrix.v.rvec, dxz/2); + vm_vec_scale_add2(&tpos, &gridp->gmatrix.v.fvec, dxz/2); brief_rpd_line(&gpos, &tpos); - vm_vec_scale_add2(&gpos, &gridp->gmatrix.rvec, dxz); - vm_vec_scale_add2(&tpos, &gridp->gmatrix.rvec, -dxz); + vm_vec_scale_add2(&gpos, &gridp->gmatrix.v.rvec, dxz); + vm_vec_scale_add2(&tpos, &gridp->gmatrix.v.rvec, -dxz); brief_rpd_line(&gpos, &tpos); */ @@ -1639,8 +1642,8 @@ void brief_set_camera_target(vector *pos, matrix *orient, int time) Total_move_time = time_in_seconds; Elapsed_time = 0.0f; - vm_vec_scale_add(&Start_lookat_pos, &Start_cam_pos, &Start_cam_orient.fvec, LOOKAT_DIST); - vm_vec_scale_add(&Target_lookat_pos, &Target_cam_pos, &Target_cam_orient.fvec, LOOKAT_DIST); + vm_vec_scale_add(&Start_lookat_pos, &Start_cam_pos, &Start_cam_orient.v.fvec, LOOKAT_DIST); + vm_vec_scale_add(&Target_lookat_pos, &Target_cam_pos, &Target_cam_orient.v.fvec, LOOKAT_DIST); Play_highlight_flag = 1; // once target reached, play highlight anims Cam_target_reached = 0; @@ -1958,7 +1961,7 @@ void brief_set_new_stage(vector *pos, matrix *orient, int time, int stage_num) if ( (Last_new_stage != -1) && (num_movers == 0) && not_objv ) { if ( !vm_vec_cmp( &Briefing->stages[stage_num].camera_pos, &Briefing->stages[Last_new_stage].camera_pos) ) { - if ( !vm_vec_cmp( &Briefing->stages[stage_num].camera_orient.fvec, &Briefing->stages[Last_new_stage].camera_orient.fvec) ){ + if ( !vm_vec_cmp( &Briefing->stages[stage_num].camera_orient.v.fvec, &Briefing->stages[Last_new_stage].camera_orient.v.fvec) ){ new_time = 0; } } @@ -2036,11 +2039,11 @@ void interpolate_matrix(matrix *result, matrix *goal, matrix *start, float elaps time0 = elapsed_time / total_time; time1 = (total_time - elapsed_time) / total_time; - vm_vec_copy_scale(&fvec, &start->fvec, time1); - vm_vec_scale_add2(&fvec, &goal->fvec, time0); + vm_vec_copy_scale(&fvec, &start->v.fvec, time1); + vm_vec_scale_add2(&fvec, &goal->v.fvec, time0); - vm_vec_copy_scale(&rvec, &start->rvec, time1); - vm_vec_scale_add2(&rvec, &goal->rvec, time0); + vm_vec_copy_scale(&rvec, &start->v.rvec, time1); + vm_vec_scale_add2(&rvec, &goal->v.rvec, time0); vm_vector_2_matrix(result, &fvec, NULL, &rvec); } @@ -2101,7 +2104,7 @@ void brief_camera_move(float frametime, int stage_num) } cur_dist = Start_dist + Dist_change_rate * Elapsed_time; - vm_vec_copy_scale(&dist_moved, &Current_cam_orient.fvec, -cur_dist); + vm_vec_copy_scale(&dist_moved, &Current_cam_orient.v.fvec, -cur_dist); vm_vec_add(&Current_cam_pos, &Current_lookat_pos, &dist_moved); */ @@ -2141,13 +2144,13 @@ void brief_maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int f float dist_to_plane; float square_size, ux, uy, uz; - ux = tplane.A = gridp->gmatrix.uvec.x; - uy = tplane.B = gridp->gmatrix.uvec.y; - uz = tplane.C = gridp->gmatrix.uvec.z; + ux = tplane.A = gridp->gmatrix.v.uvec.xyz.x; + uy = tplane.B = gridp->gmatrix.v.uvec.xyz.y; + uz = tplane.C = gridp->gmatrix.v.uvec.xyz.z; tplane.D = gridp->planeD; compute_point_on_plane(&c, &tplane, pos); - dist_to_plane = fl_abs(vm_dist_to_plane(pos, &gridp->gmatrix.uvec, &c)); + dist_to_plane = fl_abs(vm_dist_to_plane(pos, &gridp->gmatrix.v.uvec, &c)); square_size = 1.0f; while (dist_to_plane >= 25.0f) @@ -2156,9 +2159,9 @@ void brief_maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int f dist_to_plane /= 10.0f; } - if (fvi_ray_plane(&gpos, &gridp->center, &gridp->gmatrix.uvec, pos, &orient->fvec, 0.0f)<0.0f) { + if (fvi_ray_plane(&gpos, &gridp->center, &gridp->gmatrix.v.uvec, pos, &orient->v.fvec, 0.0f)<0.0f) { vector p; - vm_vec_scale_add(&p,pos,&orient->fvec, 100.0f ); + vm_vec_scale_add(&p,pos,&orient->v.fvec, 100.0f ); compute_point_on_plane(&gpos, &tplane, &p ); } @@ -2171,16 +2174,16 @@ void brief_maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int f roundoff = (int) square_size * 10; if (!ux) - gpos.x = fl_roundoff(gpos.x, roundoff); + gpos.xyz.x = fl_roundoff(gpos.xyz.x, roundoff); if (!uy) - gpos.y = fl_roundoff(gpos.y, roundoff); + gpos.xyz.y = fl_roundoff(gpos.xyz.y, roundoff); if (!uz) - gpos.z = fl_roundoff(gpos.z, roundoff); + gpos.xyz.z = fl_roundoff(gpos.xyz.z, roundoff); if ((square_size != gridp->square_size) || - (gpos.x != gridp->center.x) || - (gpos.y != gridp->center.y) || - (gpos.z != gridp->center.z) || force) + (gpos.xyz.x != gridp->center.xyz.x) || + (gpos.xyz.y != gridp->center.xyz.y) || + (gpos.xyz.z != gridp->center.xyz.z) || force) { gridp->square_size = square_size; gridp->center = gpos; @@ -2237,13 +2240,13 @@ grid *brief_create_grid(grid *gridp, vector *forward, vector *right, vector *cen Assert(!IS_VEC_NULL(&uvec)); - gridp->gmatrix.uvec = uvec; + gridp->gmatrix.v.uvec = uvec; - gridp->planeD = -(center->x * uvec.x + center->y * uvec.y + center->z * uvec.z); + gridp->planeD = -(center->xyz.x * uvec.xyz.x + center->xyz.y * uvec.xyz.y + center->xyz.z * uvec.xyz.z); Assert(!_isnan(gridp->planeD)); - gridp->gmatrix.fvec = dfvec; - gridp->gmatrix.rvec = drvec; + gridp->gmatrix.v.fvec = dfvec; + gridp->gmatrix.v.rvec = drvec; vm_vec_scale(&dfvec, square_size); vm_vec_scale(&drvec, square_size); @@ -2370,7 +2373,7 @@ void brief_render_grid(grid *gridp) void brief_modify_grid(grid *gridp) { - brief_create_grid(gridp, &gridp->gmatrix.fvec, &gridp->gmatrix.rvec, &gridp->center, + brief_create_grid(gridp, &gridp->gmatrix.v.fvec, &gridp->gmatrix.v.rvec, &gridp->center, gridp->nrows, gridp->ncols, gridp->square_size); } diff --git a/src/mission/missiongrid.cpp b/src/mission/missiongrid.cpp index 37bc382..b64274c 100644 --- a/src/mission/missiongrid.cpp +++ b/src/mission/missiongrid.cpp @@ -15,6 +15,9 @@ * C module for grid specific functions * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:22 relnev * added copyright header * @@ -118,13 +121,13 @@ void maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int force) float dist_to_plane; float square_size, ux, uy, uz; - ux = tplane.A = gridp->gmatrix.uvec.x; - uy = tplane.B = gridp->gmatrix.uvec.y; - uz = tplane.C = gridp->gmatrix.uvec.z; + ux = tplane.A = gridp->gmatrix.v.uvec.xyz.x; + uy = tplane.B = gridp->gmatrix.v.uvec.xyz.y; + uz = tplane.C = gridp->gmatrix.v.uvec.xyz.z; tplane.D = gridp->planeD; compute_point_on_plane(&c, &tplane, pos); - dist_to_plane = fl_abs(vm_dist_to_plane(pos, &gridp->gmatrix.uvec, &c)); + dist_to_plane = fl_abs(vm_dist_to_plane(pos, &gridp->gmatrix.v.uvec, &c)); square_size = 1.0f; while (dist_to_plane >= 25.0f) { @@ -132,9 +135,9 @@ void maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int force) dist_to_plane /= 10.0f; } - if (fvi_ray_plane(&gpos, &gridp->center, &gridp->gmatrix.uvec, pos, &orient->fvec, 0.0f)<0.0f) { + if (fvi_ray_plane(&gpos, &gridp->center, &gridp->gmatrix.v.uvec, pos, &orient->v.fvec, 0.0f)<0.0f) { vector p; - vm_vec_scale_add(&p,pos,&orient->fvec, 100.0f ); + vm_vec_scale_add(&p,pos,&orient->v.fvec, 100.0f ); compute_point_on_plane(&gpos, &tplane, &p ); } @@ -147,16 +150,16 @@ void maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int force) roundoff = (int) square_size * 10; if (!ux) - gpos.x = fl_roundoff(gpos.x, roundoff); + gpos.xyz.x = fl_roundoff(gpos.xyz.x, roundoff); if (!uy) - gpos.y = fl_roundoff(gpos.y, roundoff); + gpos.xyz.y = fl_roundoff(gpos.xyz.y, roundoff); if (!uz) - gpos.z = fl_roundoff(gpos.z, roundoff); + gpos.xyz.z = fl_roundoff(gpos.xyz.z, roundoff); if ((square_size != gridp->square_size) || - (gpos.x != gridp->center.x) || - (gpos.y != gridp->center.y) || - (gpos.z != gridp->center.z) || force) + (gpos.xyz.x != gridp->center.xyz.x) || + (gpos.xyz.y != gridp->center.xyz.y) || + (gpos.xyz.z != gridp->center.xyz.z) || force) { gridp->square_size = square_size; gridp->center = gpos; @@ -213,13 +216,13 @@ grid *create_grid(grid *gridp, vector *forward, vector *right, vector *center, i Assert(!IS_VEC_NULL(&uvec)); - gridp->gmatrix.uvec = uvec; + gridp->gmatrix.v.uvec = uvec; - gridp->planeD = -(center->x * uvec.x + center->y * uvec.y + center->z * uvec.z); + gridp->planeD = -(center->xyz.x * uvec.xyz.x + center->xyz.y * uvec.xyz.y + center->xyz.z * uvec.xyz.z); Assert(!_isnan(gridp->planeD)); - gridp->gmatrix.fvec = dfvec; - gridp->gmatrix.rvec = drvec; + gridp->gmatrix.v.fvec = dfvec; + gridp->gmatrix.v.rvec = drvec; vm_vec_scale(&dfvec, square_size); vm_vec_scale(&drvec, square_size); @@ -299,7 +302,7 @@ void rpd_line(vector *v0, vector *v1) void modify_grid(grid *gridp) { - create_grid(gridp, &gridp->gmatrix.fvec, &gridp->gmatrix.rvec, &gridp->center, + create_grid(gridp, &gridp->gmatrix.v.fvec, &gridp->gmatrix.v.rvec, &gridp->center, gridp->nrows, gridp->ncols, gridp->square_size); } @@ -311,17 +314,17 @@ void grid_render_elevation_line(vector *pos, grid* gridp) plane tplane; vector *gv; - tplane.A = gridp->gmatrix.uvec.x; - tplane.B = gridp->gmatrix.uvec.y; - tplane.C = gridp->gmatrix.uvec.z; + tplane.A = gridp->gmatrix.v.uvec.xyz.x; + tplane.B = gridp->gmatrix.v.uvec.xyz.y; + tplane.C = gridp->gmatrix.v.uvec.xyz.z; tplane.D = gridp->planeD; compute_point_on_plane(&gpos, &tplane, pos); dxz = vm_vec_dist(pos, &gpos)/8.0f; - gv = &gridp->gmatrix.uvec; - if (gv->x * pos->x + gv->y * pos->y + gv->z * pos->z < -gridp->planeD) + gv = &gridp->gmatrix.v.uvec; + if (gv->xyz.x * pos->xyz.x + gv->xyz.y * pos->xyz.y + gv->xyz.z * pos->xyz.z < -gridp->planeD) gr_set_color(127, 127, 127); else gr_set_color(255, 255, 255); // white @@ -330,16 +333,16 @@ void grid_render_elevation_line(vector *pos, grid* gridp) tpos = gpos; - vm_vec_scale_add2(&gpos, &gridp->gmatrix.rvec, -dxz/2); - vm_vec_scale_add2(&gpos, &gridp->gmatrix.fvec, -dxz/2); + vm_vec_scale_add2(&gpos, &gridp->gmatrix.v.rvec, -dxz/2); + vm_vec_scale_add2(&gpos, &gridp->gmatrix.v.fvec, -dxz/2); - vm_vec_scale_add2(&tpos, &gridp->gmatrix.rvec, dxz/2); - vm_vec_scale_add2(&tpos, &gridp->gmatrix.fvec, dxz/2); + vm_vec_scale_add2(&tpos, &gridp->gmatrix.v.rvec, dxz/2); + vm_vec_scale_add2(&tpos, &gridp->gmatrix.v.fvec, dxz/2); rpd_line(&gpos, &tpos); - vm_vec_scale_add2(&gpos, &gridp->gmatrix.rvec, dxz); - vm_vec_scale_add2(&tpos, &gridp->gmatrix.rvec, -dxz); + vm_vec_scale_add2(&gpos, &gridp->gmatrix.v.rvec, dxz); + vm_vec_scale_add2(&tpos, &gridp->gmatrix.v.rvec, -dxz); rpd_line(&gpos, &tpos); } diff --git a/src/mission/missionparse.cpp b/src/mission/missionparse.cpp index af4ef52..270aea4 100644 --- a/src/mission/missionparse.cpp +++ b/src/mission/missionparse.cpp @@ -15,6 +15,9 @@ * main upper level code for pasring stuff * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:22 relnev * added copyright header * @@ -1357,10 +1360,10 @@ void position_ship_for_knossos_warpin(p_object *objp, int shipnum, int objnum) // position self for warp on plane of device vector new_point; - float dist = fvi_ray_plane(&new_point, &Objects[knossos_num].pos, &Objects[knossos_num].orient.fvec, &objp->pos, &objp->orient.fvec, 0.0f); + float dist = fvi_ray_plane(&new_point, &Objects[knossos_num].pos, &Objects[knossos_num].orient.v.fvec, &objp->pos, &objp->orient.v.fvec, 0.0f); polymodel *pm = model_get(Ship_info[Ships[shipnum].ship_info_index].modelnum); - float desired_dist = -pm->mins.z; - vm_vec_scale_add2(&Objects[objnum].pos, &Objects[objnum].orient.fvec, (dist - desired_dist)); + float desired_dist = -pm->mins.xyz.z; + vm_vec_scale_add2(&Objects[objnum].pos, &Objects[objnum].orient.v.fvec, (dist - desired_dist)); // if ship is BIG or HUGE, make it go through the center of the knossos if (Ship_info[Ships[shipnum].ship_info_index].flags & SIF_HUGE_SHIP) { vector offset; @@ -1698,7 +1701,7 @@ int parse_create_object(p_object *objp) // initial velocities now do not apply to ships which warp in after mission starts if ( !(Game_mode & GM_IN_MISSION) ) { Objects[objnum].phys_info.speed = (float)objp->initial_velocity * sip->max_speed / 100.0f; - Objects[objnum].phys_info.vel.z = Objects[objnum].phys_info.speed; + Objects[objnum].phys_info.vel.xyz.z = Objects[objnum].phys_info.speed; Objects[objnum].phys_info.prev_ramp_vel = Objects[objnum].phys_info.vel; Objects[objnum].phys_info.desired_vel = Objects[objnum].phys_info.vel; } @@ -3494,8 +3497,8 @@ void post_process_mission() Player_ai->targeted_subsys_parent = -1; // determine if player start has initial velocity and set forward cruise percent to relect this - if ( Player_obj->phys_info.vel.z > 0.0f ) - Player->ci.forward_cruise_percent = Player_obj->phys_info.vel.z / Player_ship->current_max_speed * 100.0f; + if ( Player_obj->phys_info.vel.xyz.z > 0.0f ) + Player->ci.forward_cruise_percent = Player_obj->phys_info.vel.xyz.z / Player_ship->current_max_speed * 100.0f; // put in hard coded starting wing names. if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){ @@ -4130,7 +4133,7 @@ int mission_set_arrival_location(int anchor, int location, int dist, int objnum, return 0; } Objects[objnum].pos = pos; - Objects[objnum].orient.fvec = fvec; + Objects[objnum].orient.v.fvec = fvec; } else { // AL: ensure dist > 0 (otherwise get errors in vecmat) @@ -4170,9 +4173,9 @@ int mission_set_arrival_location(int anchor, int location, int dist, int objnum, r2 = static_rand(Objects[objnum].net_signature+1) < RAND_MAX/2 ? -1 : 1; } - vm_vec_copy_scale(&t1, &(Objects[anchor_objnum].orient.fvec), x); - vm_vec_copy_scale(&t2, &(Objects[anchor_objnum].orient.rvec), (1.0f - x) * r1); - vm_vec_copy_scale(&t3, &(Objects[anchor_objnum].orient.uvec), (1.0f - x) * r2); + vm_vec_copy_scale(&t1, &(Objects[anchor_objnum].orient.v.fvec), x); + vm_vec_copy_scale(&t2, &(Objects[anchor_objnum].orient.v.rvec), (1.0f - x) * r1); + vm_vec_copy_scale(&t3, &(Objects[anchor_objnum].orient.v.uvec), (1.0f - x) * r2); vm_vec_add(&rand_vec, &t1, &t2); vm_vec_add2(&rand_vec, &t3); @@ -4841,9 +4844,9 @@ int get_warp_in_pos(vector *pos, object *objp, float x, float y, float z) *pos = objp->pos; - vm_vec_scale_add2( pos, &objp->orient.rvec, x*rand_val*800.0f); - vm_vec_scale_add2( pos, &objp->orient.uvec, y*rand_val*800.0f); - vm_vec_scale_add2( pos, &objp->orient.fvec, z*rand_val*800.0f); + vm_vec_scale_add2( pos, &objp->orient.v.rvec, x*rand_val*800.0f); + vm_vec_scale_add2( pos, &objp->orient.v.uvec, y*rand_val*800.0f); + vm_vec_scale_add2( pos, &objp->orient.v.fvec, z*rand_val*800.0f); return pp_collide_any(&objp->pos, pos, objp->radius, objp, NULL, 1); } diff --git a/src/missionui/missionbrief.cpp b/src/missionui/missionbrief.cpp index 9a6c9e4..c194168 100644 --- a/src/missionui/missionbrief.cpp +++ b/src/missionui/missionbrief.cpp @@ -15,6 +15,9 @@ * C module that contains code to display the mission briefing to the player * * $Log$ + * Revision 1.5 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:22 relnev * added copyright header * @@ -1567,7 +1570,7 @@ int brief_setup_closeup(brief_icon *bi) vm_set_identity(&Closeup_orient); vm_vec_make(&tvec, 0.0f, 0.0f, -1.0f); - Closeup_orient.fvec = tvec; + Closeup_orient.v.fvec = tvec; vm_vec_zero(&Closeup_pos); Closeup_angles.p = 0.0f; Closeup_angles.b = 0.0f; @@ -1794,42 +1797,42 @@ void brief_do_frame(float frametime) } case KEY_A: - Closeup_cam_pos.z += 1; + Closeup_cam_pos.xyz.z += 1; cam_change = 1; break; case KEY_A + KEY_SHIFTED: - Closeup_cam_pos.z += 10; + Closeup_cam_pos.xyz.z += 10; cam_change = 1; break; case KEY_Z: - Closeup_cam_pos.z -= 1; + Closeup_cam_pos.xyz.z -= 1; cam_change = 1; break; case KEY_Z + KEY_SHIFTED: - Closeup_cam_pos.z -= 10; + Closeup_cam_pos.xyz.z -= 10; cam_change = 1; break; case KEY_Y: - Closeup_cam_pos.y += 1; + Closeup_cam_pos.xyz.y += 1; cam_change = 1; break; case KEY_Y + KEY_SHIFTED: - Closeup_cam_pos.y += 10; + Closeup_cam_pos.xyz.y += 10; cam_change = 1; break; case KEY_H: - Closeup_cam_pos.y -= 1; + Closeup_cam_pos.xyz.y -= 1; cam_change = 1; break; case KEY_H + KEY_SHIFTED: - Closeup_cam_pos.y -= 10; + Closeup_cam_pos.xyz.y -= 10; cam_change = 1; break; @@ -1867,7 +1870,7 @@ void brief_do_frame(float frametime) #ifndef NDEBUG if ( cam_change ) { - nprintf(("General","Camera pos: %.2f, %.2f %.2f // ", Closeup_cam_pos.x, Closeup_cam_pos.y, Closeup_cam_pos.z)); + nprintf(("General","Camera pos: %.2f, %.2f %.2f // ", Closeup_cam_pos.xyz.x, Closeup_cam_pos.xyz.y, Closeup_cam_pos.xyz.z)); nprintf(("General","Camera zoom: %.2f\n", Closeup_zoom)); } #endif diff --git a/src/missionui/missionshipchoice.cpp b/src/missionui/missionshipchoice.cpp index 3e50609..efa69ed 100644 --- a/src/missionui/missionshipchoice.cpp +++ b/src/missionui/missionshipchoice.cpp @@ -15,6 +15,9 @@ * C module to allow player ship selection for the mission * * $Log$ + * Revision 1.3 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:23 relnev * added copyright header * @@ -1358,9 +1361,9 @@ void ship_select_blit_ship_info() gr_set_color_fast(header); gr_string(Ship_info_coords[gr_screen.res][SHIP_SELECT_X_COORD], y_start,XSTR("Max Velocity",742)); y_start += 10; - sprintf(str,XSTR("%d m/s",743),(int)sip->max_vel.z); + sprintf(str,XSTR("%d m/s",743),(int)sip->max_vel.xyz.z); gr_set_color_fast(text); - gr_string(Ship_info_coords[gr_screen.res][SHIP_SELECT_X_COORD]+4, y_start,str); + gr_string(Ship_info_coords[gr_screen.res][SHIP_SELECT_X_COORD]+4, y_start,str); y_start += 10; // blit the maneuverability diff --git a/src/model/modelcollide.cpp b/src/model/modelcollide.cpp index 28b839c..ff16bfb 100644 --- a/src/model/modelcollide.cpp +++ b/src/model/modelcollide.cpp @@ -15,6 +15,9 @@ * Routines for detecting collisions of models. * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:23 relnev * added copyright header * @@ -333,12 +336,12 @@ int mc_ray_boundingbox( vector *min, vector *max, vector * p0, vector *pdir, vec vector sphere_mod_min, sphere_mod_max; - sphere_mod_min.x = min->x - Mc->radius; - sphere_mod_max.x = max->x + Mc->radius; - sphere_mod_min.y = min->y - Mc->radius; - sphere_mod_max.y = max->y + Mc->radius; - sphere_mod_min.z = min->z - Mc->radius; - sphere_mod_max.z = max->z + Mc->radius; + sphere_mod_min.xyz.x = min->xyz.x - Mc->radius; + sphere_mod_max.xyz.x = max->xyz.x + Mc->radius; + sphere_mod_min.xyz.y = min->xyz.y - Mc->radius; + sphere_mod_max.xyz.y = max->xyz.y + Mc->radius; + sphere_mod_min.xyz.z = min->xyz.z - Mc->radius; + sphere_mod_max.xyz.z = max->xyz.z + Mc->radius; return fvi_ray_boundingbox( &sphere_mod_min, &sphere_mod_max, p0, pdir, hitpos ); } else { diff --git a/src/model/modelinterp.cpp b/src/model/modelinterp.cpp index 1ce5587..8580b40 100644 --- a/src/model/modelinterp.cpp +++ b/src/model/modelinterp.cpp @@ -15,6 +15,9 @@ * Rendering models, I think. * * $Log$ + * Revision 1.5 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:23 relnev * added copyright header * @@ -548,10 +551,10 @@ void model_interp_defpoints(ubyte * p, polymodel *pm, bsp_info *sm) // Only scale vertices that aren't on the "base" of // the effect. Base is something Adam decided to be // anything under 1.5 meters, hence the 1.5f. - if ( src->z < min_thruster_dist ) { - tmp.x = src->x * 1.0f; - tmp.y = src->y * 1.0f; - tmp.z = src->z * Interp_thrust_scale; + if ( src->xyz.z < min_thruster_dist ) { + tmp.xyz.x = src->xyz.x * 1.0f; + tmp.xyz.y = src->xyz.y * 1.0f; + tmp.xyz.z = src->xyz.z * Interp_thrust_scale; } else { tmp = *src; } @@ -587,11 +590,11 @@ void model_interp_defpoints(ubyte * p, polymodel *pm, bsp_info *sm) ct = cos(theta); // twist - tmp.z = (src->z * ct) - (src->y * st); - tmp.y = (src->z * st) + (src->y * ct); + tmp.xyz.z = (src->xyz.z * ct) - (src->xyz.y * st); + tmp.xyz.y = (src->xyz.z * st) + (src->xyz.y * ct); // scale the z a bit - tmp.z += Interp_thrust_twist; + tmp.xyz.z += Interp_thrust_twist; } g3_rotate_vertex(dest, &tmp); @@ -629,15 +632,15 @@ void interp_compute_environment_mapping( vector *nrm, vertex * pnt, vector *vert vm_vec_rotate( &R, nrm, &View_matrix ); vm_vec_normalize(&R); - a = 2.0f * R.z; - R.x = a * R.x; // reflected R = 2N(N.E) -E; E = eye - R.y = a * R.y; - R.z = a * R.z; + a = 2.0f * R.xyz.z; + R.xyz.x = a * R.xyz.x; // reflected R = 2N(N.E) -E; E = eye + R.xyz.y = a * R.xyz.y; + R.xyz.z = a * R.xyz.z; vm_vec_normalize(&R); - a = (float)fl_sqrt( 1.0f - R.y * R.y); - pnt->u = (float)atan2( R.x, -R.z) / (2.0f * 3.14159f); + a = (float)fl_sqrt( 1.0f - R.xyz.y * R.xyz.y); + pnt->u = (float)atan2( R.xyz.x, -R.xyz.z) / (2.0f * 3.14159f); if (pnt->u < 0.0) pnt->u += 1.0f; - pnt->v = 1.0f - (float)atan2( a, R.y) / 3.14159f; + pnt->v = 1.0f - (float)atan2( a, R.xyz.y) / 3.14159f; } */ @@ -1322,9 +1325,9 @@ void interp_render_arc_segment( vector *v1, vector *v2, int depth ) vm_vec_avg( &tmp, v1, v2 ); float scaler = 0.30f; - tmp.x += (frand()-0.5f)*d*scaler; - tmp.y += (frand()-0.5f)*d*scaler; - tmp.z += (frand()-0.5f)*d*scaler; + tmp.xyz.x += (frand()-0.5f)*d*scaler; + tmp.xyz.y += (frand()-0.5f)*d*scaler; + tmp.xyz.z += (frand()-0.5f)*d*scaler; interp_render_arc_segment( v1, &tmp, depth+1 ); interp_render_arc_segment( &tmp, v2, depth+1 ); @@ -1459,15 +1462,15 @@ int interp_box_offscreen( vector *min, vector *max ) } vector v[8]; - v[0].x = min->x; v[0].y = min->y; v[0].z = min->z; - v[1].x = max->x; v[1].y = min->y; v[1].z = min->z; - v[2].x = max->x; v[2].y = max->y; v[2].z = min->z; - v[3].x = min->x; v[3].y = max->y; v[3].z = min->z; + v[0].xyz.x = min->xyz.x; v[0].xyz.y = min->xyz.y; v[0].xyz.z = min->xyz.z; + v[1].xyz.x = max->xyz.x; v[1].xyz.y = min->xyz.y; v[1].xyz.z = min->xyz.z; + v[2].xyz.x = max->xyz.x; v[2].xyz.y = max->xyz.y; v[2].xyz.z = min->xyz.z; + v[3].xyz.x = min->xyz.x; v[3].xyz.y = max->xyz.y; v[3].xyz.z = min->xyz.z; - v[4].x = min->x; v[4].y = min->y; v[4].z = max->z; - v[5].x = max->x; v[5].y = min->y; v[5].z = max->z; - v[6].x = max->x; v[6].y = max->y; v[6].z = max->z; - v[7].x = min->x; v[7].y = max->y; v[7].z = max->z; + v[4].xyz.x = min->xyz.x; v[4].xyz.y = min->xyz.y; v[4].xyz.z = max->xyz.z; + v[5].xyz.x = max->xyz.x; v[5].xyz.y = min->xyz.y; v[5].xyz.z = max->xyz.z; + v[6].xyz.x = max->xyz.x; v[6].xyz.y = max->xyz.y; v[6].xyz.z = max->xyz.z; + v[7].xyz.x = min->xyz.x; v[7].xyz.y = max->xyz.y; v[7].xyz.z = max->xyz.z; ubyte and_codes = 0xff; ubyte or_codes = 0xff; @@ -1740,7 +1743,7 @@ int model_cache_calc_coords(vector *pnt,float rad, float *cx, float *cy, float * *cx = pt.sx; *cy = pt.sy; - *cr = rad*Matrix_scale.x*Canv_w2/pt.z; + *cr = rad*Matrix_scale.xyz.x*Canv_w2/pt.z; if ( *cr < 1.0f ) { *cr = 1.0f; @@ -1786,29 +1789,29 @@ int model_get_rotated_bitmap_points(vertex *pnt,float angle, float rad, vertex * width = height = rad; - v[0].x = (-width*ca - height*sa)*Matrix_scale.x + pnt->x; - v[0].y = (-width*sa + height*ca)*Matrix_scale.y + pnt->y; + v[0].x = (-width*ca - height*sa)*Matrix_scale.xyz.x + pnt->x; + v[0].y = (-width*sa + height*ca)*Matrix_scale.xyz.y + pnt->y; v[0].z = pnt->z; v[0].sw = 0.0f; v[0].u = 0.0f; v[0].v = 0.0f; - v[1].x = (width*ca - height*sa)*Matrix_scale.x + pnt->x; - v[1].y = (width*sa + height*ca)*Matrix_scale.y + pnt->y; + v[1].x = (width*ca - height*sa)*Matrix_scale.xyz.x + pnt->x; + v[1].y = (width*sa + height*ca)*Matrix_scale.xyz.y + pnt->y; v[1].z = pnt->z; v[1].sw = 0.0f; v[1].u = 1.0f; v[1].v = 0.0f; - v[2].x = (width*ca + height*sa)*Matrix_scale.x + pnt->x; - v[2].y = (width*sa - height*ca)*Matrix_scale.y + pnt->y; + v[2].x = (width*ca + height*sa)*Matrix_scale.xyz.x + pnt->x; + v[2].y = (width*sa - height*ca)*Matrix_scale.xyz.y + pnt->y; v[2].z = pnt->z; v[2].sw = 0.0f; v[2].u = 1.0f; v[2].v = 1.0f; - v[3].x = (-width*ca + height*sa)*Matrix_scale.x + pnt->x; - v[3].y = (-width*sa - height*ca)*Matrix_scale.y + pnt->y; + v[3].x = (-width*ca + height*sa)*Matrix_scale.xyz.x + pnt->x; + v[3].y = (-width*sa - height*ca)*Matrix_scale.xyz.y + pnt->y; v[3].z = pnt->z; v[3].sw = 0.0f; v[3].u = 0.0f; @@ -2454,10 +2457,10 @@ JustDrawIt: // The box's dimensions from 'min' to 'max'. float interp_closest_dist_to_box( vector *hitpt, vector *p0, vector *min, vector *max ) { - float *origin = (float *)&p0->x; + float *origin = (float *)&p0->xyz.x; float *minB = (float *)min; float *maxB = (float *)max; - float *coord = (float *)&hitpt->x; + float *coord = (float *)&hitpt->xyz.x; int inside = 1; int i; diff --git a/src/model/modeloctant.cpp b/src/model/modeloctant.cpp index 7b8eff0..5d59f93 100644 --- a/src/model/modeloctant.cpp +++ b/src/model/modeloctant.cpp @@ -15,6 +15,9 @@ * Routines for model octants * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:23 relnev * added copyright header * @@ -110,14 +113,14 @@ // returns 1 if a point is in an octant. int point_in_octant( polymodel * pm, model_octant * oct, vector *vert ) { - if ( vert->x < oct->min.x ) return 0; - if ( vert->x > oct->max.x ) return 0; + if ( vert->xyz.x < oct->min.xyz.x ) return 0; + if ( vert->xyz.x > oct->max.xyz.x ) return 0; - if ( vert->y < oct->min.y ) return 0; - if ( vert->y > oct->max.y ) return 0; + if ( vert->xyz.y < oct->min.xyz.y ) return 0; + if ( vert->xyz.y > oct->max.xyz.y ) return 0; - if ( vert->z< oct->min.z) return 0; - if ( vert->z> oct->max.z) return 0; + if ( vert->xyz.z< oct->min.xyz.z) return 0; + if ( vert->xyz.z> oct->max.xyz.z) return 0; return 1; } @@ -219,9 +222,9 @@ void moff_tmappoly(ubyte * p, polymodel * pm, model_octant * oct, int just_count vm_vec_add2( ¢er_point, Interp_verts[verts[i].vertnum] ); } - center_point.x /= nv; - center_point.y /= nv; - center_point.z /= nv; + center_point.xyz.x /= nv; + center_point.xyz.y /= nv; + center_point.xyz.z /= nv; *vp(p+20) = center_point; @@ -278,9 +281,9 @@ void moff_flatpoly(ubyte * p, polymodel * pm, model_octant * oct, int just_count vm_vec_add2( ¢er_point, Interp_verts[verts[i*2]] ); } - center_point.x /= nv; - center_point.y /= nv; - center_point.z /= nv; + center_point.xyz.x /= nv; + center_point.xyz.y /= nv; + center_point.xyz.z /= nv; *vp(p+20) = center_point; @@ -394,27 +397,27 @@ void model_octant_create( polymodel * pm ) z = i & 1; if ( x ) { - pm->octants[i].max.x = max.x; - pm->octants[i].min.x = center.x; + pm->octants[i].max.xyz.x = max.xyz.x; + pm->octants[i].min.xyz.x = center.xyz.x; } else { - pm->octants[i].max.x = center.x; - pm->octants[i].min.x = min.x; + pm->octants[i].max.xyz.x = center.xyz.x; + pm->octants[i].min.xyz.x = min.xyz.x; } if ( y ) { - pm->octants[i].max.y = max.y; - pm->octants[i].min.y = center.y; + pm->octants[i].max.xyz.y = max.xyz.y; + pm->octants[i].min.xyz.y = center.xyz.y; } else { - pm->octants[i].max.y = center.y; - pm->octants[i].min.y = min.y; + pm->octants[i].max.xyz.y = center.xyz.y; + pm->octants[i].min.xyz.y = min.xyz.y; } if ( z ) { - pm->octants[i].max.z = max.z; - pm->octants[i].min.z = center.z; + pm->octants[i].max.xyz.z = max.xyz.z; + pm->octants[i].min.xyz.z = center.xyz.z; } else { - pm->octants[i].max.z = center.z; - pm->octants[i].min.z = min.z; + pm->octants[i].max.xyz.z = center.xyz.z; + pm->octants[i].min.xyz.z = min.xyz.z; } model_octant_find_shields( pm, &pm->octants[i] ); @@ -471,9 +474,9 @@ int model_which_octant_distant_many( vector *pnt, int model_num,matrix *model_or vm_vec_avg( ¢er, &((*pm)->mins), &((*pm)->maxs )); int i, x, y, z; - if ( rotpnt.x > center.x ) x = 1; else x = 0; - if ( rotpnt.y > center.y ) y = 1; else y = 0; - if ( rotpnt.z > center.z ) z = 1; else z = 0; + if ( rotpnt.xyz.x > center.xyz.x ) x = 1; else x = 0; + if ( rotpnt.xyz.y > center.xyz.y ) y = 1; else y = 0; + if ( rotpnt.xyz.z > center.xyz.z ) z = 1; else z = 0; i = ( (x<<2) | (y<<1) | z ); @@ -511,9 +514,9 @@ int model_which_octant_distant( vector *pnt, int model_num,matrix *model_orient, vm_vec_avg( ¢er, &pm->mins, &pm->maxs ); int i, x, y, z; - if ( rotpnt.x > center.x ) x = 1; else x = 0; - if ( rotpnt.y > center.y ) y = 1; else y = 0; - if ( rotpnt.z > center.z ) z = 1; else z = 0; + if ( rotpnt.xyz.x > center.xyz.x ) x = 1; else x = 0; + if ( rotpnt.xyz.y > center.xyz.y ) y = 1; else y = 0; + if ( rotpnt.xyz.z > center.xyz.z ) z = 1; else z = 0; i = ( (x<<2) | (y<<1) | z ); @@ -550,9 +553,9 @@ int model_which_octant( vector *pnt, int model_num,matrix *model_orient, vector vm_vec_avg( ¢er, &pm->mins, &pm->maxs ); int i, x, y, z; - if ( rotpnt.x > center.x ) x = 1; else x = 0; - if ( rotpnt.y > center.y ) y = 1; else y = 0; - if ( rotpnt.z > center.z ) z = 1; else z = 0; + if ( rotpnt.xyz.x > center.xyz.x ) x = 1; else x = 0; + if ( rotpnt.xyz.y > center.xyz.y ) y = 1; else y = 0; + if ( rotpnt.xyz.z > center.xyz.z ) z = 1; else z = 0; i = (x<<2) | (y<<1) | z; diff --git a/src/model/modelread.cpp b/src/model/modelread.cpp index 776f05f..43ea276 100644 --- a/src/model/modelread.cpp +++ b/src/model/modelread.cpp @@ -15,6 +15,9 @@ * file which reads and deciphers POF information * * $Log$ + * Revision 1.6 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.5 2002/06/09 04:41:23 relnev * added copyright header * @@ -1193,16 +1196,16 @@ void create_family_tree(polymodel *obj) void model_calc_bound_box( vector *box, vector *big_mn, vector *big_mx) { - box[0].x = big_mn->x; box[0].y = big_mn->y; box[0].z = big_mn->z; - box[1].x = big_mx->x; box[1].y = big_mn->y; box[1].z = big_mn->z; - box[2].x = big_mx->x; box[2].y = big_mx->y; box[2].z = big_mn->z; - box[3].x = big_mn->x; box[3].y = big_mx->y; box[3].z = big_mn->z; + box[0].xyz.x = big_mn->xyz.x; box[0].xyz.y = big_mn->xyz.y; box[0].xyz.z = big_mn->xyz.z; + box[1].xyz.x = big_mx->xyz.x; box[1].xyz.y = big_mn->xyz.y; box[1].xyz.z = big_mn->xyz.z; + box[2].xyz.x = big_mx->xyz.x; box[2].xyz.y = big_mx->xyz.y; box[2].xyz.z = big_mn->xyz.z; + box[3].xyz.x = big_mn->xyz.x; box[3].xyz.y = big_mx->xyz.y; box[3].xyz.z = big_mn->xyz.z; - box[4].x = big_mn->x; box[4].y = big_mn->y; box[4].z = big_mx->z; - box[5].x = big_mx->x; box[5].y = big_mn->y; box[5].z = big_mx->z; - box[6].x = big_mx->x; box[6].y = big_mx->y; box[6].z = big_mx->z; - box[7].x = big_mn->x; box[7].y = big_mx->y; box[7].z = big_mx->z; + box[4].xyz.x = big_mn->xyz.x; box[4].xyz.y = big_mn->xyz.y; box[4].xyz.z = big_mx->xyz.z; + box[5].xyz.x = big_mx->xyz.x; box[5].xyz.y = big_mn->xyz.y; box[5].xyz.z = big_mx->xyz.z; + box[6].xyz.x = big_mx->xyz.x; box[6].xyz.y = big_mx->xyz.y; box[6].xyz.z = big_mx->xyz.z; + box[7].xyz.x = big_mn->xyz.x; box[7].xyz.y = big_mx->xyz.y; box[7].xyz.z = big_mx->xyz.z; } @@ -1334,9 +1337,9 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs pm->mass = cfread_float(fp); cfread_vector( &pm->center_of_mass, fp ); - cfread_vector( &pm->moment_of_inertia.rvec, fp ); - cfread_vector( &pm->moment_of_inertia.uvec, fp ); - cfread_vector( &pm->moment_of_inertia.fvec, fp ); + cfread_vector( &pm->moment_of_inertia.v.rvec, fp ); + cfread_vector( &pm->moment_of_inertia.v.uvec, fp ); + cfread_vector( &pm->moment_of_inertia.v.fvec, fp ); } else { // old code where mass wasn't based on area, so do the calculation manually @@ -1349,14 +1352,14 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs float mass_ratio = vol_mass / area_mass; cfread_vector( &pm->center_of_mass, fp ); - cfread_vector( &pm->moment_of_inertia.rvec, fp ); - cfread_vector( &pm->moment_of_inertia.uvec, fp ); - cfread_vector( &pm->moment_of_inertia.fvec, fp ); + cfread_vector( &pm->moment_of_inertia.v.rvec, fp ); + cfread_vector( &pm->moment_of_inertia.v.uvec, fp ); + cfread_vector( &pm->moment_of_inertia.v.fvec, fp ); // John remove this with change to bspgen - vm_vec_scale( &pm->moment_of_inertia.rvec, mass_ratio ); - vm_vec_scale( &pm->moment_of_inertia.uvec, mass_ratio ); - vm_vec_scale( &pm->moment_of_inertia.fvec, mass_ratio ); + vm_vec_scale( &pm->moment_of_inertia.v.rvec, mass_ratio ); + vm_vec_scale( &pm->moment_of_inertia.v.uvec, mass_ratio ); + vm_vec_scale( &pm->moment_of_inertia.v.fvec, mass_ratio ); } } else { #ifndef NDEBUG @@ -1370,9 +1373,9 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs pm->mass = 50.0f; vm_vec_zero( &pm->center_of_mass ); vm_set_identity( &pm->moment_of_inertia ); - vm_vec_scale(&pm->moment_of_inertia.rvec, 0.001f); - vm_vec_scale(&pm->moment_of_inertia.uvec, 0.001f); - vm_vec_scale(&pm->moment_of_inertia.fvec, 0.001f); + vm_vec_scale(&pm->moment_of_inertia.v.rvec, 0.001f); + vm_vec_scale(&pm->moment_of_inertia.v.uvec, 0.001f); + vm_vec_scale(&pm->moment_of_inertia.v.fvec, 0.001f); } // read in cross section info @@ -1430,7 +1433,7 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs // cfread_vector(&pm->submodel[n].pnt,fp); cfread_vector(&pm->submodel[n].offset,fp); -// mprintf(( "Subobj %d, offs = %.1f, %.1f, %.1f\n", n, pm->submodel[n].offset.x, pm->submodel[n].offset.y, pm->submodel[n].offset.z )); +// mprintf(( "Subobj %d, offs = %.1f, %.1f, %.1f\n", n, pm->submodel[n].offset.xyz.x, pm->submodel[n].offset.xyz.y, pm->submodel[n].offset.xyz.z )); #if defined ( FREESPACE1_FORMAT ) pm->submodel[n].rad = cfread_float(fp); //radius @@ -1790,7 +1793,7 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs // check if $Split p = strstr(name, "$split"); if (p != NULL) { - pm->split_plane[pm->num_split_plane] = pnt.z; + pm->split_plane[pm->num_split_plane] = pnt.xyz.z; pm->num_split_plane++; Assert(pm->num_split_plane <= MAX_SPLIT_PLANE); } else if ( ( p = strstr(props, "$special"))!= NULL ) { @@ -2205,9 +2208,9 @@ int model_load(char *filename, int n_subsystems, model_subsystem *subsystems) // Find the core_radius... the minimum of float rx, ry, rz; - rx = fl_abs( pm->submodel[pm->detail[0]].max.x - pm->submodel[pm->detail[0]].min.x ); - ry = fl_abs( pm->submodel[pm->detail[0]].max.y - pm->submodel[pm->detail[0]].min.y ); - rz = fl_abs( pm->submodel[pm->detail[0]].max.z - pm->submodel[pm->detail[0]].min.z ); + rx = fl_abs( pm->submodel[pm->detail[0]].max.xyz.x - pm->submodel[pm->detail[0]].min.xyz.x ); + ry = fl_abs( pm->submodel[pm->detail[0]].max.xyz.y - pm->submodel[pm->detail[0]].min.xyz.y ); + rz = fl_abs( pm->submodel[pm->detail[0]].max.xyz.z - pm->submodel[pm->detail[0]].min.xyz.z ); pm->core_radius = min( rx, min(ry, rz) ) / 2.0f; @@ -2508,10 +2511,10 @@ int model_find_2d_bound(int model_num,matrix *orient, vector * pos,int *x1, int return 2; t = (width * Canv_w2)/pnt.z; - w = t*Matrix_scale.x; + w = t*Matrix_scale.xyz.x; t = (height*Canv_h2)/pnt.z; - h = t*Matrix_scale.y; + h = t*Matrix_scale.xyz.y; if (x1) *x1 = fl2i(pnt.sx - w); if (y1) *y1 = fl2i(pnt.sy - h); @@ -2546,10 +2549,10 @@ int subobj_find_2d_bound(float radius ,matrix *orient, vector * pos,int *x1, int return 2; t = (width * Canv_w2)/pnt.z; - w = t*Matrix_scale.x; + w = t*Matrix_scale.xyz.x; t = (height*Canv_h2)/pnt.z; - h = t*Matrix_scale.y; + h = t*Matrix_scale.xyz.y; if (x1) *x1 = fl2i(pnt.sx - w); if (y1) *y1 = fl2i(pnt.sy - h); @@ -2839,9 +2842,9 @@ void model_make_turrent_matrix(int model_num, model_subsystem * turret ) vm_vec_normalize(&rvec); vm_vec_normalize(&uvec); - turret->turret_matrix.fvec = fvec; - turret->turret_matrix.rvec = rvec; - turret->turret_matrix.uvec = uvec; + turret->turret_matrix.v.fvec = fvec; + turret->turret_matrix.v.rvec = rvec; + turret->turret_matrix.v.uvec = uvec; // vm_vector_2_matrix(&turret->turret_matrix,&turret->turret_norm,NULL,NULL); @@ -2904,7 +2907,7 @@ int model_rotate_gun(int model_num, model_subsystem *turret, matrix *orient, ang gr_set_color(255,0,0); g3_draw_sphere(&dpnt1,1.0f); - vm_vec_copy_scale( &tmp1, &turret->turret_matrix.fvec, 10.0f ); + vm_vec_copy_scale( &tmp1, &turret->turret_matrix.v.fvec, 10.0f ); model_find_world_point(&tmp, &tmp1, model_num, turret->turret_gun_sobj, orient, pos ); g3_rotate_vertex( &dpnt2, &tmp ); @@ -2913,14 +2916,14 @@ int model_rotate_gun(int model_num, model_subsystem *turret, matrix *orient, ang gr_set_color(0,128,0); g3_draw_sphere(&dpnt2,0.2f); - vm_vec_copy_scale( &tmp1, &turret->turret_matrix.rvec, 10.0f ); + vm_vec_copy_scale( &tmp1, &turret->turret_matrix.v.rvec, 10.0f ); model_find_world_point(&tmp, &tmp1, model_num, turret->turret_gun_sobj, orient, pos ); g3_rotate_vertex( &dpnt2, &tmp ); gr_set_color(0,0,255); g3_draw_line(&dpnt1,&dpnt2); - vm_vec_copy_scale( &tmp1, &turret->turret_matrix.uvec, 10.0f ); + vm_vec_copy_scale( &tmp1, &turret->turret_matrix.v.uvec, 10.0f ); model_find_world_point(&tmp, &tmp1, model_num, turret->turret_gun_sobj, orient, pos ); g3_rotate_vertex( &dpnt2, &tmp ); @@ -2954,11 +2957,11 @@ int model_rotate_gun(int model_num, model_subsystem *turret, matrix *orient, ang // Call this the desired_angles angles desired_angles; - desired_angles.p = (float)acos(of_dst.z); - desired_angles.h = PI - atan2_safe(of_dst.x, of_dst.y); + desired_angles.p = (float)acos(of_dst.xyz.z); + desired_angles.h = PI - atan2_safe(of_dst.xyz.x, of_dst.xyz.y); desired_angles.b = 0.0f; - // mprintf(( "Z = %.1f, atan= %.1f\n", of_dst.z, desired_angles.p )); + // mprintf(( "Z = %.1f, atan= %.1f\n", of_dst.xyz.z, desired_angles.p )); //------------ // Gradually turn the turret towards the desired angles diff --git a/src/nebula/neb.cpp b/src/nebula/neb.cpp index 6974f82..cb6fcb1 100644 --- a/src/nebula/neb.cpp +++ b/src/nebula/neb.cpp @@ -15,6 +15,9 @@ * Nebula effect * * $Log$ + * Revision 1.7 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.6 2002/06/09 04:41:23 relnev * added copyright header * @@ -748,28 +751,28 @@ int crossed_border() neb2_get_eye_pos(&eye_pos); // check left, right (0, and 1, x and -x) - if(cube_cen.x - eye_pos.x > ws){ + if(cube_cen.xyz.x - eye_pos.xyz.x > ws){ // -x return 0; - } else if(eye_pos.x - cube_cen.x > ws){ + } else if(eye_pos.xyz.x - cube_cen.xyz.x > ws){ // +x return 1; } // check up, down (2, and 3, y and -y) - if(cube_cen.y - eye_pos.y > hs){ + if(cube_cen.xyz.y - eye_pos.xyz.y > hs){ // -y return 2; - } else if(eye_pos.y - cube_cen.y > hs){ + } else if(eye_pos.xyz.y - cube_cen.xyz.y > hs){ // +y return 3; } // check front, back (4, and 5, z and -z) - if(cube_cen.z - eye_pos.z > ds){ + if(cube_cen.xyz.z - eye_pos.xyz.z > ds){ // -z return 4; - } else if(eye_pos.z - cube_cen.z > ds){ + } else if(eye_pos.xyz.z - cube_cen.xyz.z > ds){ // +z return 5; } @@ -825,18 +828,18 @@ void neb2_gen_slice(int xyz, int src, vector *cube_center) ds = Nd->cube_dim / (float)Neb2_slices; h_incd = ds / 2.0f; cube_corner = *cube_center; - cube_corner.x -= (Nd->cube_dim / 2.0f); - cube_corner.y -= (Nd->cube_dim / 2.0f); - cube_corner.z -= (Nd->cube_dim / 2.0f); + cube_corner.xyz.x -= (Nd->cube_dim / 2.0f); + cube_corner.xyz.y -= (Nd->cube_dim / 2.0f); + cube_corner.xyz.z -= (Nd->cube_dim / 2.0f); switch(xyz){ case 0: for(idx1=0; idx1x = h_incw + (ws * (float)src) + frand_range(-Nd->wj, Nd->wj); - v->y = h_inch + (hs * (float)idx1) + frand_range(-Nd->hj, Nd->hj); - v->z = h_incd + (ds * (float)idx2) + frand_range(-Nd->dj, Nd->dj); + v->xyz.x = h_incw + (ws * (float)src) + frand_range(-Nd->wj, Nd->wj); + v->xyz.y = h_inch + (hs * (float)idx1) + frand_range(-Nd->hj, Nd->hj); + v->xyz.z = h_incd + (ds * (float)idx2) + frand_range(-Nd->dj, Nd->dj); vm_vec_add2(v, &cube_corner); // set the bitmap @@ -854,9 +857,9 @@ void neb2_gen_slice(int xyz, int src, vector *cube_center) for(idx2=0; idx2x = h_incw + (ws * (float)idx1) + frand_range(-Nd->wj, Nd->wj); - v->y = h_inch + (hs * (float)src) + frand_range(-Nd->hj, Nd->hj); - v->z = h_incd + (ds * (float)idx2) + frand_range(-Nd->dj, Nd->dj); + v->xyz.x = h_incw + (ws * (float)idx1) + frand_range(-Nd->wj, Nd->wj); + v->xyz.y = h_inch + (hs * (float)src) + frand_range(-Nd->hj, Nd->hj); + v->xyz.z = h_incd + (ds * (float)idx2) + frand_range(-Nd->dj, Nd->dj); vm_vec_add2(v, &cube_corner); // set the bitmap @@ -874,9 +877,9 @@ void neb2_gen_slice(int xyz, int src, vector *cube_center) for(idx2=0; idx2x = h_incw + (ws * (float)idx1) + frand_range(-Nd->wj, Nd->wj); - v->y = h_inch + (hs * (float)idx2) + frand_range(-Nd->hj, Nd->hj); - v->z = h_incd + (ds * (float)src) + frand_range(-Nd->dj, Nd->dj); + v->xyz.x = h_incw + (ws * (float)idx1) + frand_range(-Nd->wj, Nd->wj); + v->xyz.y = h_inch + (hs * (float)idx2) + frand_range(-Nd->hj, Nd->hj); + v->xyz.z = h_incd + (ds * (float)src) + frand_range(-Nd->dj, Nd->dj); vm_vec_add2(v, &cube_corner); // set the bitmap @@ -975,7 +978,7 @@ void neb2_render_player() break; // -x case 0 : - cube_cen.x -= Nd->cube_dim / (float)Neb2_slices; + cube_cen.xyz.x -= Nd->cube_dim / (float)Neb2_slices; for(idx1=Neb2_slices-1; idx1>0; idx1--){ neb2_copy(0, idx1-1, idx1); } @@ -983,7 +986,7 @@ void neb2_render_player() break; // x case 1 : - cube_cen.x += Nd->cube_dim / (float)Neb2_slices; + cube_cen.xyz.x += Nd->cube_dim / (float)Neb2_slices; for(idx1=0; idx1cube_dim / (float)Neb2_slices; + cube_cen.xyz.y -= Nd->cube_dim / (float)Neb2_slices; for(idx1=Neb2_slices-1; idx1>0; idx1--){ neb2_copy(1, idx1-1, idx1); } @@ -999,7 +1002,7 @@ void neb2_render_player() break; // y case 3 : - cube_cen.y += Nd->cube_dim / (float)Neb2_slices; + cube_cen.xyz.y += Nd->cube_dim / (float)Neb2_slices; for(idx1=0; idx1cube_dim / (float)Neb2_slices; + cube_cen.xyz.z -= Nd->cube_dim / (float)Neb2_slices; for(idx1=Neb2_slices-1; idx1>0; idx1--){ neb2_copy(2, idx1-1, idx1); } @@ -1015,7 +1018,7 @@ void neb2_render_player() break; // z case 5 : - cube_cen.z += Nd->cube_dim / (float)Neb2_slices; + cube_cen.xyz.z += Nd->cube_dim / (float)Neb2_slices; for(idx1=0; idx1num_poofs; idxfvec, frand_range(neb->magic_num, neb->inner_radius)); + vm_vec_copy_scale(&pt, &orient->v.fvec, frand_range(neb->magic_num, neb->inner_radius)); // rotate the point by -ang <-> ang around the up vector vm_rot_point_around_line(&pt2, &pt, fl_radian(frand_range(-ang, ang)), &vmd_zero_vector, &orient->uvec); @@ -1793,9 +1796,9 @@ void neb2_add_inner(neb2 *neb, int num_poofs, matrix *orient, float ang) // now add in the center of the nebula so its placed properly (ie, not around the origin) vm_vec_add(&neb->pts[idx], &pt3, &Objects[neb->objnum].pos); } else { - neb->pts[idx].x = frand_range(-1.0f * neb->inner_radius, neb->inner_radius) + Objects[neb->objnum].pos.x; - neb->pts[idx].y = frand_range(-1.0f * neb->inner_radius, neb->inner_radius) + Objects[neb->objnum].pos.y; - neb->pts[idx].z = frand_range(-1.0f * neb->inner_radius, neb->inner_radius) + Objects[neb->objnum].pos.z; + neb->pts[idx].xyz.x = frand_range(-1.0f * neb->inner_radius, neb->inner_radius) + Objects[neb->objnum].pos.xyz.x; + neb->pts[idx].xyz.y = frand_range(-1.0f * neb->inner_radius, neb->inner_radius) + Objects[neb->objnum].pos.xyz.y; + neb->pts[idx].xyz.z = frand_range(-1.0f * neb->inner_radius, neb->inner_radius) + Objects[neb->objnum].pos.xyz.z; } neb->bmaps[idx] = (int)frand_range(0.0f, (float)2); @@ -1805,7 +1808,7 @@ void neb2_add_inner(neb2 *neb, int num_poofs, matrix *orient, float ang) // add N poofs to the outer shell of the nebula // if orient and ang are specified, generate the poofs so that they are "visible" around -// the orient fvec in a cone of ang degrees +// the orient v.fvec in a cone of ang degrees void neb2_add_outer(neb2 *neb, int num_poofs, matrix *orient, float ang) { int idx; @@ -1817,7 +1820,7 @@ void neb2_add_outer(neb2 *neb, int num_poofs, matrix *orient, float ang) for(idx=neb->num_poofs; idxfvec, neb->outer_radius); + vm_vec_copy_scale(&pt, &orient->v.fvec, neb->outer_radius); // rotate the point by -ang <-> ang around the up vector vm_rot_point_around_line(&pt2, &pt, fl_radian(frand_range(-ang, ang)), &vmd_zero_vector, &orient->uvec); @@ -1832,9 +1835,9 @@ void neb2_add_outer(neb2 *neb, int num_poofs, matrix *orient, float ang) phi = fl_radian(frand_range(0.0f, 360.0f)); theta = fl_radian(frand_range(0.0f, 360.f)); - neb->pts[idx].x = neb->outer_radius * (float)sin(phi) * (float)cos(theta); - neb->pts[idx].y = neb->outer_radius * (float)sin(phi) * (float)sin(theta); - neb->pts[idx].z = neb->outer_radius * (float)cos(phi); + neb->pts[idx].xyz.x = neb->outer_radius * (float)sin(phi) * (float)cos(theta); + neb->pts[idx].xyz.y = neb->outer_radius * (float)sin(phi) * (float)sin(theta); + neb->pts[idx].xyz.z = neb->outer_radius * (float)cos(phi); } // pick a random bitmap and increment the # of poofs diff --git a/src/nebula/neblightning.cpp b/src/nebula/neblightning.cpp index 9116649..7181b86 100644 --- a/src/nebula/neblightning.cpp +++ b/src/nebula/neblightning.cpp @@ -15,6 +15,9 @@ * Nebula effect * * $Log$ + * Revision 1.4 2002/06/17 06:33:09 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:23 relnev * added copyright header * @@ -461,9 +464,9 @@ void nebl_init() // flavor required_string("+flavor:"); - stuff_float(&s->flavor.x); - stuff_float(&s->flavor.y); - stuff_float(&s->flavor.z); + stuff_float(&s->flavor.xyz.x); + stuff_float(&s->flavor.xyz.y); + stuff_float(&s->flavor.xyz.z); // frequencies required_string("+random_freq:"); @@ -804,7 +807,7 @@ void nebl_bolt(int type, vector *start, vector *strike) // setup the rest of the important bolt data if(vm_vec_same(&Nebl_bolt_start, &Nebl_bolt_strike)){ - Nebl_bolt_strike.z += 150.0f; + Nebl_bolt_strike.xyz.z += 150.0f; } Nebl_bolt_len = vm_vec_dist(&Nebl_bolt_start, &Nebl_bolt_strike); vm_vec_sub(&dir, &Nebl_bolt_strike, &Nebl_bolt_start); @@ -995,9 +998,9 @@ int nebl_gen(vector *left, vector *right, float depth, float max_depth, int chil } float scaler = 0.30f; - tmp.x += (frand()-0.5f)*d*scaler; - tmp.y += (frand()-0.5f)*d*scaler; - tmp.z += (frand()-0.5f)*d*scaler; + tmp.xyz.x += (frand()-0.5f)*d*scaler; + tmp.xyz.y += (frand()-0.5f)*d*scaler; + tmp.xyz.z += (frand()-0.5f)*d*scaler; // generate left half l_node *ll = NULL; diff --git a/src/network/multi_obj.cpp b/src/network/multi_obj.cpp index 3d8344b..863b1d3 100644 --- a/src/network/multi_obj.cpp +++ b/src/network/multi_obj.cpp @@ -174,8 +174,8 @@ int multi_oo_sort_func(const void *ship1, const void *ship2) dist1 = vm_vec_copy_normalize(&vn1, &v1); vm_vec_sub(&v2, &OO_player_obj->pos, &obj2->pos); dist2 = vm_vec_copy_normalize(&vn2, &v2); - dot1 = vm_vec_dotprod(&OO_player_obj->orient.fvec, &vn1); - dot2 = vm_vec_dotprod(&OO_player_obj->orient.fvec, &vn2); + dot1 = vm_vec_dotprod(&OO_player_obj->orient.v.fvec, &vn1); + dot2 = vm_vec_dotprod(&OO_player_obj->orient.v.fvec, &vn2); // objects in front take precedence if((dot1 < 0.0f) && (dot2 >= 0.0f)){ @@ -1117,7 +1117,7 @@ int multi_oo_maybe_update(net_player *pl, object *obj, ubyte *data) } // check dot products - player_eye = pl->s_info.eye_orient.fvec; + player_eye = pl->s_info.eye_orient.v.fvec; vm_vec_sub(&obj_dot, &obj->pos, &pl->s_info.eye_pos); vm_vec_normalize(&obj_dot); eye_dot = vm_vec_dot(&obj_dot, &player_eye); diff --git a/src/network/multi_observer.cpp b/src/network/multi_observer.cpp index da4b973..6ddbe08 100644 --- a/src/network/multi_observer.cpp +++ b/src/network/multi_observer.cpp @@ -13,6 +13,9 @@ * $Author$ * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:23 relnev * added copyright header * @@ -193,9 +196,9 @@ void multi_obs_create_observer(net_player *pl) Objects[objnum].net_signature = 0; // put it a 1,1,1 - Objects[objnum].pos.x = 1.0f; - Objects[objnum].pos.y = 1.0f; - Objects[objnum].pos.z = 1.0f; + Objects[objnum].pos.xyz.x = 1.0f; + Objects[objnum].pos.xyz.y = 1.0f; + Objects[objnum].pos.xyz.z = 1.0f; // assign this object to the player pl->player->objnum = objnum; diff --git a/src/network/multi_respawn.cpp b/src/network/multi_respawn.cpp index dd0bc8a..d7bc16e 100644 --- a/src/network/multi_respawn.cpp +++ b/src/network/multi_respawn.cpp @@ -13,6 +13,9 @@ * $Author$ * * $Log$ + * Revision 1.4 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:23 relnev * added copyright header * @@ -874,7 +877,7 @@ void multi_respawn_check_ai() vector gpos; \ vm_vec_sub2(&temp, &hit_check->pos); \ vm_vec_rotate(&gpos, &temp, &hit_check->orient); \ - if((gpos.x >= pm->mins.x * scale) && (gpos.y >= pm->mins.y * scale) && (gpos.z >= pm->mins.z * scale) && (gpos.x <= pm->maxs.x * scale) && (gpos.y <= pm->maxs.y * scale) && (gpos.z <= pm->maxs.z * scale)) { \ + if((gpos.xyz.x >= pm->mins.xyz.x * scale) && (gpos.xyz.y >= pm->mins.xyz.y * scale) && (gpos.xyz.z >= pm->mins.xyz.z * scale) && (gpos.xyz.x <= pm->maxs.xyz.x * scale) && (gpos.xyz.y <= pm->maxs.xyz.y * scale) && (gpos.xyz.z <= pm->maxs.xyz.z * scale)) { \ collided = 1; \ } \ } \ @@ -885,19 +888,19 @@ void multi_respawn_check_ai() if(pm != NULL){ \ switch((int)frand_range(0.0f, 3.9f)){ \ case 0: \ - new_obj->pos.x += 200.0f; \ + new_obj->pos.xyz.x += 200.0f; \ break; \ case 1: \ - new_obj->pos.x -= 200.0f; \ + new_obj->pos.xyz.x -= 200.0f; \ break; \ case 2: \ - new_obj->pos.y += 200.0f; \ + new_obj->pos.xyz.y += 200.0f; \ break; \ case 3: \ - new_obj->pos.y -= 200.0f; \ + new_obj->pos.xyz.y -= 200.0f; \ break; \ default : \ - new_obj->pos.z -= 200.0f; \ + new_obj->pos.xyz.z -= 200.0f; \ break; \ } \ } \ @@ -934,37 +937,37 @@ void multi_respawn_place(object *new_obj, int team) // hmm, ugly. Pick a point 2000 meters to the y direction if(pm == NULL){ - vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.rvec, 2000.0f); + vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.v.rvec, 2000.0f); } else { // pick a random direction int d = (int)frand_range(0.0f, 5.9f); switch(d){ case 0: - vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.rvec, (pm->maxs.x - pm->mins.x)); + vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.v.rvec, (pm->maxs.xyz.x - pm->mins.xyz.x)); break; case 1: - vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.rvec, -(pm->maxs.x - pm->mins.x)); + vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.v.rvec, -(pm->maxs.xyz.x - pm->mins.xyz.x)); break; case 2: - vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.uvec, (pm->maxs.y - pm->mins.y)); + vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.v.uvec, (pm->maxs.xyz.y - pm->mins.xyz.y)); break; case 3: - vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.uvec, -(pm->maxs.y - pm->mins.y)); + vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.v.uvec, -(pm->maxs.xyz.y - pm->mins.xyz.y)); break; case 4: - vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.fvec, (pm->maxs.z - pm->mins.z)); + vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.v.fvec, (pm->maxs.xyz.z - pm->mins.xyz.z)); break; case 5: - vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.fvec, -(pm->maxs.z - pm->mins.z)); + vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.v.fvec, -(pm->maxs.xyz.z - pm->mins.xyz.z)); break; default: - vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.uvec, -(pm->maxs.y - pm->mins.y)); + vm_vec_scale_add(&new_obj->pos, &pri_obj->pos, &pri_obj->orient.v.uvec, -(pm->maxs.xyz.y - pm->mins.xyz.y)); break; } } @@ -1014,7 +1017,7 @@ void multi_respawn_place(object *new_obj, int team) // just to make sure we don't get any strange magnitude errors if(vm_vec_same(&hit_check->pos, &new_obj->pos)){ - new_obj->pos.x += 1.0f; + new_obj->pos.xyz.x += 1.0f; } WITHIN_BBOX(); diff --git a/src/network/multimsgs.cpp b/src/network/multimsgs.cpp index 44c58fc..e8d4f10 100644 --- a/src/network/multimsgs.cpp +++ b/src/network/multimsgs.cpp @@ -15,6 +15,9 @@ * C file that holds functions for the building and processing of multiplayer packets * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:24 relnev * added copyright header * @@ -3184,7 +3187,7 @@ void send_turret_fired_packet( int ship_objnum, int subsys_index, int weapon_obj // build the fire turret packet. BUILD_HEADER(FIRE_TURRET_WEAPON); - packet_size += multi_pack_unpack_position(1, data + packet_size, &objp->orient.fvec); + packet_size += multi_pack_unpack_position(1, data + packet_size, &objp->orient.v.fvec); ADD_DATA( has_sig ); ADD_DATA( pnet_signature ); if(has_sig){ @@ -6119,7 +6122,7 @@ void send_shield_explosion_packet( int objnum, int tri_num, vector hit_pos ) } vm_vec_normalized_dir(&eye_to_obj_vec, &Objects[objnum].pos, &eye_pos); - dot = vm_vec_dot(&eye_orient.fvec, &eye_to_obj_vec); + dot = vm_vec_dot(&eye_orient.v.fvec, &eye_to_obj_vec); if ( dot < OBJ_VISIBILITY_DOT ){ continue; @@ -7687,7 +7690,7 @@ void send_flak_fired_packet(int ship_objnum, int subsys_index, int weapon_objnum // build the fire turret packet. BUILD_HEADER(FLAK_FIRED); - packet_size += multi_pack_unpack_position(1, data + packet_size, &objp->orient.fvec); + packet_size += multi_pack_unpack_position(1, data + packet_size, &objp->orient.v.fvec); ADD_DATA( pnet_signature ); ADD_DATA( cindex ); val = (short)ssp->submodel_info_1.angs.h; diff --git a/src/network/multiteamselect.cpp b/src/network/multiteamselect.cpp index 4d4fb43..b14a8af 100644 --- a/src/network/multiteamselect.cpp +++ b/src/network/multiteamselect.cpp @@ -15,6 +15,9 @@ * Multiplayer Team Selection Code * * $Log$ + * Revision 1.4 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:24 relnev * added copyright header * @@ -1697,7 +1700,7 @@ void multi_ts_blit_ship_info() // blit the max velocity gr_set_color_fast(&Color_normal); gr_string(Multi_ts_ship_info_coords[gr_screen.res][MULTI_TS_X_COORD], y_start,XSTR("Max Velocity",742)); - sprintf(str,XSTR("%d m/s",743),(int)sip->max_vel.z); + sprintf(str,XSTR("%d m/s",743),(int)sip->max_vel.xyz.z); gr_set_color_fast(&Color_bright); gr_string(Multi_ts_ship_info_coords[gr_screen.res][MULTI_TS_X_COORD] + 150, y_start,str); y_start += 10; diff --git a/src/network/multiutil.cpp b/src/network/multiutil.cpp index 1da119b..b7a6576 100644 --- a/src/network/multiutil.cpp +++ b/src/network/multiutil.cpp @@ -15,6 +15,9 @@ * C file that contains misc. functions to support multiplayer * * $Log$ + * Revision 1.8 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.7 2002/06/09 04:41:24 relnev * added copyright header * @@ -1277,37 +1280,37 @@ void multi_pack_orient_matrix(ubyte *data,matrix *m) { data[16]=0; - if(m->rvec.z < 0) data[16] |= (1<<0); // X - if(m->uvec.z < 0) data[16] |= (1<<1); // Y - if(m->fvec.z < 0) data[16] |= (1<<2); // V - if(m->fvec.x < 0) data[16] |= (1<<3); // Z - if(m->fvec.y < 0) data[16] |= (1<<4); // W - memcpy(&data[0],&m->rvec.x,4); // a - memcpy(&data[4],&m->rvec.y,4); // b - memcpy(&data[8],&m->uvec.x,4); // c - memcpy(&data[12],&m->uvec.y,4); // d + if(m->v.rvec.xyz.z < 0) data[16] |= (1<<0); // X + if(m->v.uvec.xyz.z < 0) data[16] |= (1<<1); // Y + if(m->v.fvec.xyz.z < 0) data[16] |= (1<<2); // V + if(m->v.fvec.xyz.x < 0) data[16] |= (1<<3); // Z + if(m->v.fvec.xyz.y < 0) data[16] |= (1<<4); // W + memcpy(&data[0],&m->v.rvec.xyz.x,4); // a + memcpy(&data[4],&m->v.rvec.xyz.y,4); // b + memcpy(&data[8],&m->v.uvec.xyz.x,4); // c + memcpy(&data[12],&m->v.uvec.xyz.y,4); // d } // return bytes processed // non-16 byte version of unpack matrix code void multi_unpack_orient_matrix(ubyte *data,matrix *m) { - memcpy(&m->rvec.x,&data[0],4); - memcpy(&m->rvec.y,&data[4],4); - memcpy(&m->uvec.x,&data[8],4); - memcpy(&m->uvec.y,&data[12],4); + memcpy(&m->v.rvec.xyz.x,&data[0],4); + memcpy(&m->v.rvec.xyz.y,&data[4],4); + memcpy(&m->v.uvec.xyz.x,&data[8],4); + memcpy(&m->v.uvec.xyz.y,&data[12],4); - m->rvec.z = fl_sqrt(fl_abs(1 - (m->rvec.x * m->rvec.x) - (m->rvec.y * m->rvec.y))); // X - m->uvec.z = fl_sqrt(fl_abs(1 - (m->uvec.x * m->uvec.x) - (m->uvec.y * m->uvec.y))); // Y - m->fvec.z = fl_sqrt(fl_abs(1 - (m->rvec.z * m->rvec.z) - (m->uvec.z * m->uvec.z))); // V - m->fvec.x = fl_sqrt(fl_abs(1 - (m->rvec.x * m->rvec.x) - (m->uvec.x * m->uvec.x))); // Z - m->fvec.y = fl_sqrt(fl_abs(1 - (m->rvec.y * m->rvec.y) - (m->uvec.y * m->uvec.y))); // W - - m->rvec.z *= (data[16] & (1<<0)) ? -1.0f : 1.0f; - m->uvec.z *= (data[16] & (1<<1)) ? -1.0f : 1.0f; - m->fvec.z *= (data[16] & (1<<2)) ? -1.0f : 1.0f; - m->fvec.x *= (data[16] & (1<<3)) ? -1.0f : 1.0f; - m->fvec.y *= (data[16] & (1<<4)) ? -1.0f : 1.0f; + m->v.rvec.xyz.z = fl_sqrt(fl_abs(1 - (m->v.rvec.xyz.x * m->v.rvec.xyz.x) - (m->v.rvec.xyz.y * m->v.rvec.xyz.y))); // X + m->v.uvec.xyz.z = fl_sqrt(fl_abs(1 - (m->v.uvec.xyz.x * m->v.uvec.xyz.x) - (m->v.uvec.xyz.y * m->v.uvec.xyz.y))); // Y + m->v.fvec.xyz.z = fl_sqrt(fl_abs(1 - (m->v.rvec.xyz.z * m->v.rvec.xyz.z) - (m->v.uvec.xyz.z * m->v.uvec.xyz.z))); // V + m->v.fvec.xyz.x = fl_sqrt(fl_abs(1 - (m->v.rvec.xyz.x * m->v.rvec.xyz.x) - (m->v.uvec.xyz.x * m->v.uvec.xyz.x))); // Z + m->v.fvec.xyz.y = fl_sqrt(fl_abs(1 - (m->v.rvec.xyz.y * m->v.rvec.xyz.y) - (m->v.uvec.xyz.y * m->v.uvec.xyz.y))); // W + + m->v.rvec.xyz.z *= (data[16] & (1<<0)) ? -1.0f : 1.0f; + m->v.uvec.xyz.z *= (data[16] & (1<<1)) ? -1.0f : 1.0f; + m->v.fvec.xyz.z *= (data[16] & (1<<2)) ? -1.0f : 1.0f; + m->v.fvec.xyz.x *= (data[16] & (1<<3)) ? -1.0f : 1.0f; + m->v.fvec.xyz.y *= (data[16] & (1<<4)) ? -1.0f : 1.0f; } void multi_do_client_warp(float flFrametime) @@ -3517,9 +3520,9 @@ int multi_pack_unpack_position( int write, ubyte *data, vector *pos) if ( write ) { // Output pos - a = fl2i(pos->x*105.0f+0.5f); - b = fl2i(pos->y*105.0f+0.5f); - c = fl2i(pos->z*105.0f+0.5f); + a = fl2i(pos->xyz.x*105.0f+0.5f); + b = fl2i(pos->xyz.y*105.0f+0.5f); + c = fl2i(pos->xyz.z*105.0f+0.5f); CAP(a,-8388608,8388607); CAP(b,-8388608,8388607); CAP(c,-8388608,8388607); @@ -3538,9 +3541,9 @@ int multi_pack_unpack_position( int write, ubyte *data, vector *pos) b = bitbuffer_get_signed(&buf,24); c = bitbuffer_get_signed(&buf,24); - pos->x = i2fl(a)/105.0f; - pos->y = i2fl(b)/105.0f; - pos->z = i2fl(c)/105.0f; + pos->xyz.x = i2fl(a)/105.0f; + pos->xyz.y = i2fl(b)/105.0f; + pos->xyz.z = i2fl(c)/105.0f; return bitbuffer_read_flush(&buf); } @@ -3550,49 +3553,49 @@ int degenerate_count = 0; int non_degenerate_count = 0; /* -hack = ((ushort)orient->fvec.x * 32767); - memcpy(&hack, &orient->fvec.x, 4); +hack = ((ushort)orient->v.fvec.xyz.x * 32767); + memcpy(&hack, &orient->v.fvec.xyz.x, 4); bitbuffer_put( &buf, hack, 32 ); - memcpy(&hack, &orient->fvec.y, 4); + memcpy(&hack, &orient->v.fvec.xyz.y, 4); bitbuffer_put( &buf, hack, 32 ); - memcpy(&hack, &orient->fvec.z, 4); + memcpy(&hack, &orient->v.fvec.xyz.z, 4); bitbuffer_put( &buf, hack, 32 ); - memcpy(&hack, &orient->uvec.x, 4); + memcpy(&hack, &orient->v.uvec.xyz.x, 4); bitbuffer_put( &buf, hack, 32 ); - memcpy(&hack, &orient->uvec.y, 4); + memcpy(&hack, &orient->v.uvec.xyz.y, 4); bitbuffer_put( &buf, hack, 32 ); - memcpy(&hack, &orient->uvec.z, 4); + memcpy(&hack, &orient->v.uvec.xyz.z, 4); bitbuffer_put( &buf, hack, 32 ); - memcpy(&hack, &orient->rvec.x, 4); + memcpy(&hack, &orient->v.rvec.xyz.x, 4); bitbuffer_put( &buf, hack, 32 ); - memcpy(&hack, &orient->rvec.y, 4); + memcpy(&hack, &orient->v.rvec.xyz.y, 4); bitbuffer_put( &buf, hack, 32 ); - memcpy(&hack, &orient->rvec.z, 4); + memcpy(&hack, &orient->v.rvec.xyz.z, 4); bitbuffer_put( &buf, hack, 32 );*/ /* hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->fvec.x, &hack, 4); + memcpy(&orient->v.fvec.xyz.x, &hack, 4); hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->fvec.y, &hack, 4); + memcpy(&orient->v.fvec.xyz.y, &hack, 4); hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->fvec.z, &hack, 4); + memcpy(&orient->v.fvec.xyz.z, &hack, 4); hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->uvec.x, &hack, 4); + memcpy(&orient->v.uvec.xyz.x, &hack, 4); hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->uvec.y, &hack, 4); + memcpy(&orient->v.uvec.xyz.y, &hack, 4); hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->uvec.z, &hack, 4); + memcpy(&orient->v.uvec.xyz.z, &hack, 4); hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->rvec.x, &hack, 4); + memcpy(&orient->v.rvec.xyz.x, &hack, 4); hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->rvec.y, &hack, 4); + memcpy(&orient->v.rvec.xyz.y, &hack, 4); hack = bitbuffer_get_unsigned(&buf, 32); - memcpy(&orient->rvec.z, &hack, 4);*/ + memcpy(&orient->v.rvec.xyz.z, &hack, 4);*/ // Packs/unpacks an orientation matrix. // Returns number of bytes read or written. @@ -3626,33 +3629,33 @@ int multi_pack_unpack_orient( int write, ubyte *data, matrix *orient) flag = 0xff; // stuff it - a = fl2i(orient->fvec.x * D_SCALE); + a = fl2i(orient->v.fvec.xyz.x * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); - a = fl2i(orient->fvec.y * D_SCALE); + a = fl2i(orient->v.fvec.xyz.y * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); - a = fl2i(orient->fvec.z * D_SCALE); + a = fl2i(orient->v.fvec.xyz.z * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); - a = fl2i(orient->uvec.x * D_SCALE); + a = fl2i(orient->v.uvec.xyz.x * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); - a = fl2i(orient->uvec.y * D_SCALE); + a = fl2i(orient->v.uvec.xyz.y * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); - a = fl2i(orient->uvec.z * D_SCALE); + a = fl2i(orient->v.uvec.xyz.z * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); - a = fl2i(orient->rvec.x * D_SCALE); + a = fl2i(orient->v.rvec.xyz.x * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); - a = fl2i(orient->rvec.y * D_SCALE); + a = fl2i(orient->v.rvec.xyz.y * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); - a = fl2i(orient->rvec.z * D_SCALE); + a = fl2i(orient->v.rvec.xyz.z * D_SCALE); CAP(a, D_MIN_RANGE, D_MAX_RANGE); bitbuffer_put( &buf, a, 16 ); } else { @@ -3664,9 +3667,9 @@ int multi_pack_unpack_orient( int write, ubyte *data, matrix *orient) theta = theta*2.0f/PI-1.0f; // -1 to 1 - a = fl2i(rot_axis.x*N_SCALE); - b = fl2i(rot_axis.y*N_SCALE); - c = fl2i(rot_axis.z*N_SCALE); + a = fl2i(rot_axis.xyz.x*N_SCALE); + b = fl2i(rot_axis.xyz.y*N_SCALE); + c = fl2i(rot_axis.xyz.z*N_SCALE); d = fl2i(theta*N_SCALE); CAP(a, N_MIN_RANGE, N_MAX_RANGE); @@ -3690,25 +3693,25 @@ int multi_pack_unpack_orient( int write, ubyte *data, matrix *orient) // degenerate if(flag){ a = bitbuffer_get_signed(&buf, 16); - orient->fvec.x = i2fl(a) / D_SCALE; + orient->v.fvec.xyz.x = i2fl(a) / D_SCALE; a = bitbuffer_get_signed(&buf, 16); - orient->fvec.y = i2fl(a) / D_SCALE; + orient->v.fvec.xyz.y = i2fl(a) / D_SCALE; a = bitbuffer_get_signed(&buf, 16); - orient->fvec.z = i2fl(a) / D_SCALE; + orient->v.fvec.xyz.z = i2fl(a) / D_SCALE; a = bitbuffer_get_signed(&buf, 16); - orient->uvec.x = i2fl(a) / D_SCALE; + orient->v.uvec.xyz.x = i2fl(a) / D_SCALE; a = bitbuffer_get_signed(&buf, 16); - orient->uvec.y = i2fl(a) / D_SCALE; + orient->v.uvec.xyz.y = i2fl(a) / D_SCALE; a = bitbuffer_get_signed(&buf, 16); - orient->uvec.z = i2fl(a) / D_SCALE; + orient->v.uvec.xyz.z = i2fl(a) / D_SCALE; a = bitbuffer_get_signed(&buf, 16); - orient->rvec.x = i2fl(a) / D_SCALE; + orient->v.rvec.xyz.x = i2fl(a) / D_SCALE; a = bitbuffer_get_signed(&buf, 16); - orient->rvec.y = i2fl(a) / D_SCALE; + orient->v.rvec.xyz.y = i2fl(a) / D_SCALE; a = bitbuffer_get_signed(&buf, 16); - orient->rvec.z = i2fl(a) / D_SCALE; + orient->v.rvec.xyz.z = i2fl(a) / D_SCALE; } else { a = bitbuffer_get_signed(&buf,12); b = bitbuffer_get_signed(&buf,12); @@ -3716,9 +3719,9 @@ int multi_pack_unpack_orient( int write, ubyte *data, matrix *orient) d = bitbuffer_get_signed(&buf,12); // special case - rot_axis.x = i2fl(a)/N_SCALE; - rot_axis.y = i2fl(b)/N_SCALE; - rot_axis.z = i2fl(c)/N_SCALE; + rot_axis.xyz.x = i2fl(a)/N_SCALE; + rot_axis.xyz.y = i2fl(b)/N_SCALE; + rot_axis.xyz.z = i2fl(c)/N_SCALE; theta = i2fl(d)/N_SCALE; // Convert theta back to range 0-PI @@ -3767,9 +3770,9 @@ int multi_pack_unpack_orient( int write, ubyte *data, matrix *orient) #define MIN_RANGE -2048 // -1 to 1 - a = fl2i(rot_axis.x*SCALE); - b = fl2i(rot_axis.y*SCALE); - c = fl2i(rot_axis.z*SCALE); + a = fl2i(rot_axis.xyz.x*SCALE); + b = fl2i(rot_axis.xyz.y*SCALE); + c = fl2i(rot_axis.xyz.z*SCALE); d = fl2i(theta*SCALE); CAP(a,MIN_RANGE,MAX_RANGE); @@ -3793,9 +3796,9 @@ int multi_pack_unpack_orient( int write, ubyte *data, matrix *orient) d = bitbuffer_get_signed(&buf,12); // special case - rot_axis.x = i2fl(a)/SCALE; - rot_axis.y = i2fl(b)/SCALE; - rot_axis.z = i2fl(c)/SCALE; + rot_axis.xyz.x = i2fl(a)/SCALE; + rot_axis.xyz.y = i2fl(b)/SCALE; + rot_axis.xyz.z = i2fl(c)/SCALE; theta = i2fl(d)/SCALE; // Convert theta back to range 0-PI @@ -3824,9 +3827,9 @@ int multi_pack_unpack_vel( int write, ubyte *data, matrix *orient, vector *pos, if ( write ) { // output velocity - r = vm_vec_dot( &orient->rvec, &pi->vel ); - u = vm_vec_dot( &orient->uvec, &pi->vel ); - f = vm_vec_dot( &orient->fvec, &pi->vel ); + r = vm_vec_dot( &orient->v.rvec, &pi->vel ); + u = vm_vec_dot( &orient->v.uvec, &pi->vel ); + f = vm_vec_dot( &orient->v.fvec, &pi->vel ); a = fl2i(r * 0.5f); b = fl2i(u * 0.5f); @@ -3851,9 +3854,9 @@ int multi_pack_unpack_vel( int write, ubyte *data, matrix *orient, vector *pos, // Convert into world coordinates vm_vec_zero(&pi->vel); - vm_vec_scale_add2( &pi->vel, &orient->rvec, r ); - vm_vec_scale_add2( &pi->vel, &orient->uvec, u ); - vm_vec_scale_add2( &pi->vel, &orient->fvec, f ); + vm_vec_scale_add2( &pi->vel, &orient->v.rvec, r ); + vm_vec_scale_add2( &pi->vel, &orient->v.uvec, u ); + vm_vec_scale_add2( &pi->vel, &orient->v.fvec, f ); return bitbuffer_read_flush(&buf); } @@ -3873,47 +3876,47 @@ int multi_pack_unpack_desired_vel( int write, ubyte *data, matrix *orient, vecto float r,u,f; int fields = 0; - max_vel.x = max( sip->max_vel.x, sip->afterburner_max_vel.x ); - max_vel.y = max( sip->max_vel.y, sip->afterburner_max_vel.y ); - max_vel.z = max( sip->max_vel.z, sip->afterburner_max_vel.z ); + max_vel.xyz.x = max( sip->max_vel.xyz.x, sip->afterburner_max_vel.xyz.x ); + max_vel.xyz.y = max( sip->max_vel.xyz.y, sip->afterburner_max_vel.xyz.y ); + max_vel.xyz.z = max( sip->max_vel.xyz.z, sip->afterburner_max_vel.xyz.z ); if ( write ) { // Find desired vel in local coordinates // Velocity can be from -1024 to 1024 // bitfields for each value - if(max_vel.x > 0.0f){ + if(max_vel.xyz.x > 0.0f){ fields |= (1<<0); } - if(max_vel.y > 0.0f){ + if(max_vel.xyz.y > 0.0f){ fields |= (1<<1); } - if(max_vel.z > 0.0f){ + if(max_vel.xyz.z > 0.0f){ fields |= (1<<2); } // fields = sip - Ship_info; bitbuffer_put(&buf, (uint)fields, 8); - r = vm_vec_dot( &orient->rvec, &pi->desired_vel ); - u = vm_vec_dot( &orient->uvec, &pi->desired_vel ); - f = vm_vec_dot( &orient->fvec, &pi->desired_vel ); + r = vm_vec_dot( &orient->v.rvec, &pi->desired_vel ); + u = vm_vec_dot( &orient->v.uvec, &pi->desired_vel ); + f = vm_vec_dot( &orient->v.fvec, &pi->desired_vel ); - if ( max_vel.x > 0.0f ) { - r = r / max_vel.x; + if ( max_vel.xyz.x > 0.0f ) { + r = r / max_vel.xyz.x; a = fl2i( r * 128.0f ); CAP(a,-128, 127 ); bitbuffer_put( &buf, (uint)a, 8 ); } - if ( max_vel.y > 0.0f ) { - u = u / max_vel.y; + if ( max_vel.xyz.y > 0.0f ) { + u = u / max_vel.xyz.y; a = fl2i( u * 128.0f ); CAP(a,-128, 127 ); bitbuffer_put( &buf, (uint)a, 8 ); } - if ( max_vel.z > 0.0f ) { - f = f / max_vel.z; + if ( max_vel.xyz.z > 0.0f ) { + f = f / max_vel.xyz.z; a = fl2i( f * 128.0f ); CAP(a,-128, 127 ); bitbuffer_put( &buf, (uint)a, 8 ); @@ -3951,9 +3954,9 @@ int multi_pack_unpack_desired_vel( int write, ubyte *data, matrix *orient, vecto // Convert into world coordinates vm_vec_zero(&pi->vel); - vm_vec_scale_add2( &pi->desired_vel, &orient->rvec, r*max_vel.x ); - vm_vec_scale_add2( &pi->desired_vel, &orient->uvec, u*max_vel.y ); - vm_vec_scale_add2( &pi->desired_vel, &orient->fvec, f*max_vel.z ); + vm_vec_scale_add2( &pi->desired_vel, &orient->v.rvec, r*max_vel.xyz.x ); + vm_vec_scale_add2( &pi->desired_vel, &orient->v.uvec, u*max_vel.xyz.y ); + vm_vec_scale_add2( &pi->desired_vel, &orient->v.fvec, f*max_vel.xyz.z ); return bitbuffer_read_flush(&buf); } @@ -3972,9 +3975,9 @@ int multi_pack_unpack_rotvel( int write, ubyte *data, matrix *orient, vector *po if ( write ) { // output rotational velocity - a = fl2i(pi->rotvel.x*32.0f); - b = fl2i(pi->rotvel.y*32.0f); - c = fl2i(pi->rotvel.z*32.0f); + a = fl2i(pi->rotvel.xyz.x*32.0f); + b = fl2i(pi->rotvel.xyz.y*32.0f); + c = fl2i(pi->rotvel.xyz.z*32.0f); CAP(a,-512,511); CAP(b,-512,511); CAP(c,-512,511); @@ -3991,9 +3994,9 @@ int multi_pack_unpack_rotvel( int write, ubyte *data, matrix *orient, vector *po a = bitbuffer_get_signed(&buf,10); b = bitbuffer_get_signed(&buf,10); c = bitbuffer_get_signed(&buf,10); - pi->rotvel.x = i2fl(a)/32.0f; - pi->rotvel.y = i2fl(b)/32.0f; - pi->rotvel.z = i2fl(c)/32.0f; + pi->rotvel.xyz.x = i2fl(a)/32.0f; + pi->rotvel.xyz.y = i2fl(b)/32.0f; + pi->rotvel.xyz.z = i2fl(c)/32.0f; return bitbuffer_read_flush(&buf); } @@ -4016,33 +4019,33 @@ int multi_pack_unpack_desired_rotvel( int write, ubyte *data, matrix *orient, ve // use ship_info values for max_rotvel instead of taking it from physics info // bitfields for each value - if(sip->max_rotvel.x > 0.0f){ + if(sip->max_rotvel.xyz.x > 0.0f){ fields |= (1<<0); } - if(sip->max_rotvel.y > 0.0f){ + if(sip->max_rotvel.xyz.y > 0.0f){ fields |= (1<<1); } - if(sip->max_rotvel.z > 0.0f){ + if(sip->max_rotvel.xyz.z > 0.0f){ fields |= (1<<2); } bitbuffer_put(&buf, (uint)fields, 8); // output desired rotational velocity as a percent of max - if ( sip->max_rotvel.x > 0.0f ) { - a = fl2i( pi->desired_rotvel.x*128.0f / sip->max_rotvel.x ); + if ( sip->max_rotvel.xyz.x > 0.0f ) { + a = fl2i( pi->desired_rotvel.xyz.x*128.0f / sip->max_rotvel.xyz.x ); CAP(a,-128, 127 ); bitbuffer_put( &buf, (uint)a, 8 ); } - if ( sip->max_rotvel.y > 0.0f ) { - a = fl2i( pi->desired_rotvel.y*128.0f / sip->max_rotvel.y ); + if ( sip->max_rotvel.xyz.y > 0.0f ) { + a = fl2i( pi->desired_rotvel.xyz.y*128.0f / sip->max_rotvel.xyz.y ); CAP(a,-128, 127 ); bitbuffer_put( &buf, (uint)a, 8 ); } - if ( sip->max_rotvel.z > 0.0f ) { - a = fl2i( pi->desired_rotvel.z*128.0f / sip->max_rotvel.z ); + if ( sip->max_rotvel.xyz.z > 0.0f ) { + a = fl2i( pi->desired_rotvel.xyz.z*128.0f / sip->max_rotvel.xyz.z ); CAP(a,-128, 127 ); bitbuffer_put( &buf, (uint)a, 8 ); } @@ -4070,9 +4073,9 @@ int multi_pack_unpack_desired_rotvel( int write, ubyte *data, matrix *orient, ve } else { f = 0.0f; } - pi->desired_rotvel.x = r*sip->max_rotvel.x; - pi->desired_rotvel.y = u*sip->max_rotvel.y; - pi->desired_rotvel.z = f*sip->max_rotvel.z; + pi->desired_rotvel.xyz.x = r*sip->max_rotvel.xyz.x; + pi->desired_rotvel.xyz.y = u*sip->max_rotvel.xyz.y; + pi->desired_rotvel.xyz.z = f*sip->max_rotvel.xyz.z; return bitbuffer_read_flush(&buf); } diff --git a/src/object/collidedebrisship.cpp b/src/object/collidedebrisship.cpp index 3f01ff1..e3fd60c 100644 --- a/src/object/collidedebrisship.cpp +++ b/src/object/collidedebrisship.cpp @@ -15,6 +15,9 @@ * Routines to detect collisions and do physics, damage, etc for ships and debris * * $Log$ + * Revision 1.4 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:24 relnev * added copyright header * @@ -287,7 +290,7 @@ int collide_debris_ship( obj_pair * pair ) ship_max_speed = ship_get_max_speed(shipp); } ship_max_speed = max(ship_max_speed, 10.0f); - ship_max_speed = max(ship_max_speed, pship->phys_info.vel.z); + ship_max_speed = max(ship_max_speed, pship->phys_info.vel.xyz.z); debris_speed = pdebris->phys_info.speed; diff --git a/src/object/collideshipship.cpp b/src/object/collideshipship.cpp index 58e4b4e..6964131 100644 --- a/src/object/collideshipship.cpp +++ b/src/object/collideshipship.cpp @@ -15,6 +15,9 @@ * Routines to detect collisions and do physics, damage, etc for ships and ships * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:24 relnev * added copyright header * @@ -1538,12 +1541,12 @@ void maybe_push_little_ship_from_fast_big_ship(object *big, object *small, float if (Ship_info[Ships[big->instance].ship_info_index].flags & (SIF_CAPITAL|SIF_SUPERCAP)) { if (Ship_info[Ships[small->instance].ship_info_index].flags & (SIF_SMALL_SHIP)) { float big_speed = vm_vec_mag_quick(&big->phys_info.vel); - if (big_speed > 3*big->phys_info.max_vel.z) { + if (big_speed > 3*big->phys_info.max_vel.xyz.z) { // push player away in direction perp to forward of big ship // get perp vec vector temp, perp; vm_vec_sub(&temp, &small->pos, &big->pos); - vm_vec_scale_add(&perp, &temp, &big->orient.fvec, -vm_vec_dotprod(&temp, &big->orient.fvec)); + vm_vec_scale_add(&perp, &temp, &big->orient.v.fvec, -vm_vec_dotprod(&temp, &big->orient.v.fvec)); vm_vec_normalize_quick(&perp); // don't drive into sfc we just collided with @@ -1730,10 +1733,10 @@ int collide_ship_ship( obj_pair * pair ) if ( Ships[A->instance].team == Ships[B->instance].team ) { vector collision_vec, right_angle_vec; vm_vec_normalized_dir(&collision_vec, &ship_ship_hit_info.hit_pos, &A->pos); - if (vm_vec_dot(&collision_vec, &A->orient.fvec) > 0.999f){ - right_angle_vec = A->orient.rvec; + if (vm_vec_dot(&collision_vec, &A->orient.v.fvec) > 0.999f){ + right_angle_vec = A->orient.v.rvec; } else { - vm_vec_cross(&right_angle_vec, &A->orient.uvec, &collision_vec); + vm_vec_cross(&right_angle_vec, &A->orient.v.uvec, &collision_vec); } vm_vec_scale_add2( &A->phys_info.vel, &right_angle_vec, +2.0f); diff --git a/src/object/collideshipweapon.cpp b/src/object/collideshipweapon.cpp index 48a2f0d..e2058e5 100644 --- a/src/object/collideshipweapon.cpp +++ b/src/object/collideshipweapon.cpp @@ -15,6 +15,9 @@ * Routines to detect collisions and do physics, damage, etc for weapons and ships * * $Log$ + * Revision 1.4 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:24 relnev * added copyright header * @@ -364,7 +367,7 @@ int ship_weapon_check_collision(object * ship_obj, object * weapon_obj, float ti vm_vec_normalized_dir(&vec_to_ship, &ship_obj->pos, &weapon_obj->pos); - if (vm_vec_dot(&vec_to_ship, &weapon_obj->orient.fvec) < 0.0f) { + if (vm_vec_dot(&vec_to_ship, &weapon_obj->orient.v.fvec) < 0.0f) { // check if we're colliding against "invisible" ship if (!(Ship_info[shipp->ship_info_index].flags & SIF_DONT_COLLIDE_INVIS)) { wp->lifeleft = 0.001f; @@ -434,7 +437,7 @@ float estimate_ship_speed_upper_limit( object *ship, float time ) float delta_v; float factor; - delta_v = Ship_info[Ships[ship->instance].ship_info_index].max_vel.z - ship->phys_info.speed; + delta_v = Ship_info[Ships[ship->instance].ship_info_index].max_vel.xyz.z - ship->phys_info.speed; if (ship->phys_info.forward_accel_time_const == 0) { return ship->phys_info.speed; } @@ -467,13 +470,13 @@ int check_inside_radius_for_big_ships( object *ship, object *weapon, obj_pair *p if (max_error < 2) max_error = 2.0f; - time_to_exit_sphere = (ship->radius + vm_vec_dist(&ship->pos, &weapon->pos)) / (weapon->phys_info.max_vel.z - ship->phys_info.max_vel.z); + time_to_exit_sphere = (ship->radius + vm_vec_dist(&ship->pos, &weapon->pos)) / (weapon->phys_info.max_vel.xyz.z - ship->phys_info.max_vel.xyz.z); ship_speed_at_exit_sphere = estimate_ship_speed_upper_limit( ship, time_to_exit_sphere ); // update estimated time to exit sphere - time_to_exit_sphere = (ship->radius + vm_vec_dist(&ship->pos, &weapon->pos)) / (weapon->phys_info.max_vel.z - ship_speed_at_exit_sphere); - vm_vec_scale_add( &error_vel, &ship->phys_info.vel, &weapon->orient.fvec, -vm_vec_dotprod(&ship->phys_info.vel, &weapon->orient.fvec) ); + time_to_exit_sphere = (ship->radius + vm_vec_dist(&ship->pos, &weapon->pos)) / (weapon->phys_info.max_vel.xyz.z - ship_speed_at_exit_sphere); + vm_vec_scale_add( &error_vel, &ship->phys_info.vel, &weapon->orient.v.fvec, -vm_vec_dotprod(&ship->phys_info.vel, &weapon->orient.v.fvec) ); error_vel_mag = vm_vec_mag_quick( &error_vel ); - error_vel_mag += 0.5f * (ship->phys_info.max_vel.z - error_vel_mag)*(time_to_exit_sphere/ship->phys_info.forward_accel_time_const); + error_vel_mag += 0.5f * (ship->phys_info.max_vel.xyz.z - error_vel_mag)*(time_to_exit_sphere/ship->phys_info.forward_accel_time_const); // error_vel_mag is now average velocity over period error_at_exit_sphere = error_vel_mag * time_to_exit_sphere; time_to_max_error = max_error / error_at_exit_sphere * time_to_exit_sphere; diff --git a/src/object/collideweaponweapon.cpp b/src/object/collideweaponweapon.cpp index 0ce1606..d4e52d8 100644 --- a/src/object/collideweaponweapon.cpp +++ b/src/object/collideweaponweapon.cpp @@ -15,6 +15,9 @@ * Routines to detect collisions and do physics, damage, etc for weapons and weapons * * $Log$ + * Revision 1.3 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:24 relnev * added copyright header * @@ -97,7 +100,7 @@ int collide_weapon_weapon( obj_pair * pair ) // Only shoot down teammate's missile if not traveling in nearly same direction. if (Weapons[A->instance].team == Weapons[B->instance].team) - if (vm_vec_dot(&A->orient.fvec, &B->orient.fvec) > 0.7f) + if (vm_vec_dot(&A->orient.v.fvec, &B->orient.v.fvec) > 0.7f) return 1; // Ignore collisions involving a bomb if the bomb is not yet armed. diff --git a/src/object/objcollide.cpp b/src/object/objcollide.cpp index e06f95d..b0f7e16 100644 --- a/src/object/objcollide.cpp +++ b/src/object/objcollide.cpp @@ -16,6 +16,9 @@ * Also keeps track of all the object pairs. * * $Log$ + * Revision 1.4 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:24 relnev * added copyright header * @@ -490,7 +493,7 @@ void obj_add_pair( object *A, object *B, int check_time, int add_to_end ) if (Weapon_info[Weapons[B->instance].weapon_info_index].subtype == WP_LASER) { vector velocity_rel_weapon; vm_vec_sub(&velocity_rel_weapon, &B->phys_info.vel, &A->phys_info.vel); - vdot = -vm_vec_dot(&velocity_rel_weapon, &B->orient.fvec); + vdot = -vm_vec_dot(&velocity_rel_weapon, &B->orient.v.fvec); } else { vdot = vm_vec_dot( &A->phys_info.vel, &B->phys_info.vel); } @@ -499,7 +502,7 @@ void obj_add_pair( object *A, object *B, int check_time, int add_to_end ) // check their positions vector weapon2other; vm_vec_sub( &weapon2other, &A->pos, &B->pos ); - float pdot = vm_vec_dot( &B->orient.fvec, &weapon2other ); + float pdot = vm_vec_dot( &B->orient.v.fvec, &weapon2other ); if ( pdot <= -A->radius ) { // The other object is behind the weapon by more than // its radius, so it will never hit... @@ -795,7 +798,7 @@ int weapon_will_never_hit( object *weapon, object *other, obj_pair * current_pai if (Weapon_info[Weapons[weapon->instance].weapon_info_index].subtype == WP_LASER) { vector velocity_rel_weapon; vm_vec_sub(&velocity_rel_weapon, &weapon->phys_info.vel, &other->phys_info.vel); - vdot = -vm_vec_dot(&velocity_rel_weapon, &weapon->orient.fvec); + vdot = -vm_vec_dot(&velocity_rel_weapon, &weapon->orient.v.fvec); } else { vdot = vm_vec_dot( &other->phys_info.vel, &weapon->phys_info.vel); } @@ -804,7 +807,7 @@ int weapon_will_never_hit( object *weapon, object *other, obj_pair * current_pai // check their positions vector weapon2other; vm_vec_sub( &weapon2other, &other->pos, &weapon->pos ); - float pdot = vm_vec_dot( &weapon->orient.fvec, &weapon2other ); + float pdot = vm_vec_dot( &weapon->orient.v.fvec, &weapon2other ); if ( pdot <= -other->radius ) { // The other object is behind the weapon by more than // its radius, so it will never hit... @@ -833,8 +836,8 @@ int weapon_will_never_hit( object *weapon, object *other, obj_pair * current_pai //vector max_vel; //maximum foward velocity in x,y,z float max_vel_weapon, max_vel_other; - max_vel_weapon = weapon->phys_info.max_vel.z; - max_vel_other = other->phys_info.max_vel.z; + max_vel_weapon = weapon->phys_info.max_vel.xyz.z; + max_vel_other = other->phys_info.max_vel.xyz.z; if (max_vel_other < 10.0f) { if ( vm_vec_mag_squared( &other->phys_info.vel ) > 100 ) { // bump up velocity from collision @@ -854,7 +857,7 @@ int weapon_will_never_hit( object *weapon, object *other, obj_pair * current_pai float root1, root2, root, earliest_time; vm_vec_sub( &delta_x, &weapon->pos, &other->pos ); - vm_vec_copy_scale( &laser_vel, &weapon->orient.fvec, max_vel_weapon ); + vm_vec_copy_scale( &laser_vel, &weapon->orient.v.fvec, max_vel_weapon ); delta_t = (other->radius + 10.0f) / max_vel_other; // time to get from center to radius of other obj delta_x_dot_vl = vm_vec_dotprod( &delta_x, &laser_vel ); @@ -1003,7 +1006,7 @@ int collide_predict_large_ship(object *objp, float distance) cur_pos = objp->pos; - vm_vec_scale_add(&goal_pos, &cur_pos, &objp->orient.fvec, distance); + vm_vec_scale_add(&goal_pos, &cur_pos, &objp->orient.v.fvec, distance); for ( objp2 = GET_FIRST(&obj_used_list); objp2 != END_OF_LIST(&obj_used_list); objp2 = GET_NEXT(objp2) ) { if ((objp != objp2) && (objp2->type == OBJ_SHIP)) { diff --git a/src/object/objectsnd.cpp b/src/object/objectsnd.cpp index 46c393f..0c5428a 100644 --- a/src/object/objectsnd.cpp +++ b/src/object/objectsnd.cpp @@ -15,6 +15,9 @@ * C module for managing object-linked persistant sounds * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:24 relnev * added copyright header * @@ -739,11 +742,11 @@ void obj_snd_do_frame() speed_vol_multiplier = 1.0f; if ( objp->type == OBJ_SHIP ) { if ( !(Ship_info[Ships[objp->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) { - if ( objp->phys_info.max_vel.z <= 0 ) { + if ( objp->phys_info.max_vel.xyz.z <= 0 ) { percent_max = 0.0f; } else - percent_max = objp->phys_info.fspeed / objp->phys_info.max_vel.z; + percent_max = objp->phys_info.fspeed / objp->phys_info.max_vel.xyz.z; if ( percent_max >= 0.5 ) speed_vol_multiplier = 1.0f; diff --git a/src/object/objectsort.cpp b/src/object/objectsort.cpp index b8d5137..50f091a 100644 --- a/src/object/objectsort.cpp +++ b/src/object/objectsort.cpp @@ -15,6 +15,9 @@ * Sorting code for objects. * * $Log$ + * Revision 1.3 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:25 relnev * added copyright header * @@ -262,7 +265,7 @@ void obj_render_all(void (*render_function)(object *objp) ) osp->obj = objp; vector to_obj; vm_vec_sub( &to_obj, &objp->pos, &Eye_position ); - osp->z = vm_vec_dot( &Eye_matrix.fvec, &to_obj ); + osp->z = vm_vec_dot( &Eye_matrix.v.fvec, &to_obj ); /* if ( objp->type == OBJ_SHOCKWAVE ) osp->z -= 2*objp->radius; diff --git a/src/observer/observer.cpp b/src/observer/observer.cpp index ed673b9..61939ec 100644 --- a/src/observer/observer.cpp +++ b/src/observer/observer.cpp @@ -64,9 +64,9 @@ int observer_create(matrix *orient, vector *pos) // setup some physics parameters - pi->max_vel.x = OBS_MAX_VEL_X; - pi->max_vel.y = OBS_MAX_VEL_Y; - pi->max_vel.z = OBS_MAX_VEL_Z; + pi->max_vel.xyz.x = OBS_MAX_VEL_X; + pi->max_vel.xyz.y = OBS_MAX_VEL_Y; + pi->max_vel.xyz.z = OBS_MAX_VEL_Z; vm_vec_zero(&pi->prev_ramp_vel); vm_vec_zero(&pi->desired_vel); vm_vec_zero(&pi->desired_rotvel); diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index f4c2a84..a62764f 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -15,6 +15,9 @@ * Code for particle system * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:25 relnev * added copyright header * @@ -781,9 +784,9 @@ void particle_emit( particle_emitter *pe, int type, uint optional_data, float ra float life = (( pe->max_life - pe->min_life ) * frand()) + pe->min_life; - normal.x = pe->normal.x + (frand()*2.0f - 1.0f)*pe->normal_variance; - normal.y = pe->normal.y + (frand()*2.0f - 1.0f)*pe->normal_variance; - normal.z = pe->normal.z + (frand()*2.0f - 1.0f)*pe->normal_variance; + normal.xyz.x = pe->normal.xyz.x + (frand()*2.0f - 1.0f)*pe->normal_variance; + normal.xyz.y = pe->normal.xyz.y + (frand()*2.0f - 1.0f)*pe->normal_variance; + normal.xyz.z = pe->normal.xyz.z + (frand()*2.0f - 1.0f)*pe->normal_variance; vm_vec_normalize_safe( &normal ); vm_vec_scale_add( &tmp_vel, &pe->vel, &normal, speed ); diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index bf26a8d..a595046 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -15,6 +15,9 @@ * Physics stuff * * $Log$ + * Revision 1.4 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:25 relnev * added copyright header * @@ -403,25 +406,25 @@ void physics_init( physics_info * pi ) pi->side_slip_time_const = 0.05f; pi->rotdamp = 0.1f; - pi->max_vel.x = 100.0f; //sideways - pi->max_vel.y = 100.0f; //up/down - pi->max_vel.z = 100.0f; //forward + pi->max_vel.xyz.x = 100.0f; //sideways + pi->max_vel.xyz.y = 100.0f; //up/down + pi->max_vel.xyz.z = 100.0f; //forward pi->max_rear_vel = 100.0f; //backward -- controlled seperately - pi->max_rotvel.x = 2.0f; //pitch - pi->max_rotvel.y = 1.0f; //heading - pi->max_rotvel.z = 2.0f; //bank + pi->max_rotvel.xyz.x = 2.0f; //pitch + pi->max_rotvel.xyz.y = 1.0f; //heading + pi->max_rotvel.xyz.z = 2.0f; //bank - pi->prev_ramp_vel.x = 0.0f; - pi->prev_ramp_vel.y = 0.0f; - pi->prev_ramp_vel.z = 0.0f; + pi->prev_ramp_vel.xyz.x = 0.0f; + pi->prev_ramp_vel.xyz.y = 0.0f; + pi->prev_ramp_vel.xyz.z = 0.0f; - pi->desired_vel.x = 0.0f; - pi->desired_vel.y = 0.0f; - pi->desired_vel.z = 0.0f; + pi->desired_vel.xyz.x = 0.0f; + pi->desired_vel.xyz.y = 0.0f; + pi->desired_vel.xyz.z = 0.0f; - pi->slide_accel_time_const=pi->side_slip_time_const; // slide using max_vel.x & .y - pi->slide_decel_time_const=pi->side_slip_time_const; // slide using max_vel.x & .y + pi->slide_accel_time_const=pi->side_slip_time_const; // slide using max_vel.xyz.x & .xyz.y + pi->slide_decel_time_const=pi->side_slip_time_const; // slide using max_vel.xyz.x & .xyz.y pi->afterburner_decay = 1; pi->forward_thrust = 0.0f; @@ -429,9 +432,9 @@ void physics_init( physics_info * pi ) pi->flags = 0; // default values for moment of inetaia - vm_vec_make( &pi->I_body_inv.rvec, 1e-5f, 0.0f, 0.0f ); - vm_vec_make( &pi->I_body_inv.uvec, 0.0f, 1e-5f, 0.0f ); - vm_vec_make( &pi->I_body_inv.fvec, 0.0f, 0.0f, 1e-5f ); + vm_vec_make( &pi->I_body_inv.v.rvec, 1e-5f, 0.0f, 0.0f ); + vm_vec_make( &pi->I_body_inv.v.uvec, 0.0f, 1e-5f, 0.0f ); + vm_vec_make( &pi->I_body_inv.v.fvec, 0.0f, 0.0f, 1e-5f ); } @@ -524,9 +527,9 @@ void physics_sim_rot(matrix * orient, physics_info * pi, float sim_time ) } // Do rotational physics with given damping - apply_physics( rotdamp, pi->desired_rotvel.x, pi->rotvel.x, sim_time, &new_vel.x, NULL ); - apply_physics( rotdamp, pi->desired_rotvel.y, pi->rotvel.y, sim_time, &new_vel.y, NULL ); - apply_physics( rotdamp, pi->desired_rotvel.z, pi->rotvel.z, sim_time, &new_vel.z, NULL ); + apply_physics( rotdamp, pi->desired_rotvel.xyz.x, pi->rotvel.xyz.x, sim_time, &new_vel.xyz.x, NULL ); + apply_physics( rotdamp, pi->desired_rotvel.xyz.y, pi->rotvel.xyz.y, sim_time, &new_vel.xyz.y, NULL ); + apply_physics( rotdamp, pi->desired_rotvel.xyz.z, pi->rotvel.xyz.z, sim_time, &new_vel.xyz.z, NULL ); /* #ifdef ROT_DEBUG @@ -539,9 +542,9 @@ void physics_sim_rot(matrix * orient, physics_info * pi, float sim_time ) pi->rotvel = new_vel; - tangles.p = pi->rotvel.x*sim_time; - tangles.h = pi->rotvel.y*sim_time; - tangles.b = pi->rotvel.z*sim_time; + tangles.p = pi->rotvel.xyz.x*sim_time; + tangles.h = pi->rotvel.xyz.y*sim_time; + tangles.b = pi->rotvel.xyz.z*sim_time; // If this is the viewer_object, keep track of the // changes in banking so that rotated bitmaps look correct. @@ -620,20 +623,20 @@ void physics_sim_rot_editor(matrix * orient, physics_info * pi, float sim_time) matrix tmp; angles t1, t2; - apply_physics( pi->rotdamp, pi->desired_rotvel.x, pi->rotvel.x, sim_time, - &new_vel.x, NULL ); + apply_physics( pi->rotdamp, pi->desired_rotvel.xyz.x, pi->rotvel.xyz.x, sim_time, + &new_vel.xyz.x, NULL ); - apply_physics( pi->rotdamp, pi->desired_rotvel.y, pi->rotvel.y, sim_time, - &new_vel.y, NULL ); + apply_physics( pi->rotdamp, pi->desired_rotvel.xyz.y, pi->rotvel.xyz.y, sim_time, + &new_vel.xyz.y, NULL ); - apply_physics( pi->rotdamp, pi->desired_rotvel.z, pi->rotvel.z, sim_time, - &new_vel.z, NULL ); + apply_physics( pi->rotdamp, pi->desired_rotvel.xyz.z, pi->rotvel.xyz.z, sim_time, + &new_vel.xyz.z, NULL ); pi->rotvel = new_vel; - tangles.p = pi->rotvel.x*sim_time; - tangles.h = pi->rotvel.y*sim_time; - tangles.b = pi->rotvel.z*sim_time; + tangles.p = pi->rotvel.xyz.x*sim_time; + tangles.h = pi->rotvel.xyz.y*sim_time; + tangles.b = pi->rotvel.xyz.z*sim_time; t1 = t2 = tangles; t1.h = 0.0f; t1.b = 0.0f; @@ -681,9 +684,9 @@ void physics_sim_vel(vector * position, physics_info * pi, float sim_time, matri } else { // damp is multiplied by fraction and not fraction^2, gives better collision separation float reduced_damp_fraction_time_left = timestamp_until( pi->reduced_damp_decay ) / (float) REDUCED_DAMP_TIME; - damp.x = pi->side_slip_time_const * ( 1 + (REDUCED_DAMP_FACTOR-1) * reduced_damp_fraction_time_left ); - damp.y = pi->side_slip_time_const * ( 1 + (REDUCED_DAMP_FACTOR-1) * reduced_damp_fraction_time_left ); - damp.z = pi->side_slip_time_const * reduced_damp_fraction_time_left * REDUCED_DAMP_FACTOR; + damp.xyz.x = pi->side_slip_time_const * ( 1 + (REDUCED_DAMP_FACTOR-1) * reduced_damp_fraction_time_left ); + damp.xyz.y = pi->side_slip_time_const * ( 1 + (REDUCED_DAMP_FACTOR-1) * reduced_damp_fraction_time_left ); + damp.xyz.z = pi->side_slip_time_const * reduced_damp_fraction_time_left * REDUCED_DAMP_FACTOR; } } else { // regular damping @@ -701,10 +704,10 @@ void physics_sim_vel(vector * position, physics_info * pi, float sim_time, matri vm_vec_rotate (&local_desired_vel, &pi->desired_vel, orient); // find updated LOCAL velocity and position in the local x direction - apply_physics (damp.x, local_desired_vel.x, local_v_in.x, sim_time, &local_v_out.x, &local_disp.x); + apply_physics (damp.xyz.x, local_desired_vel.xyz.x, local_v_in.xyz.x, sim_time, &local_v_out.xyz.x, &local_disp.xyz.x); // find updated LOCAL velocity and position in the local y direction - apply_physics (damp.y, local_desired_vel.y, local_v_in.y, sim_time, &local_v_out.y, &local_disp.y); + apply_physics (damp.xyz.y, local_desired_vel.xyz.y, local_v_in.xyz.y, sim_time, &local_v_out.xyz.y, &local_disp.xyz.y); // find updated LOCAL velocity and position in the local z direction // for player ship, damp should normally be zero, but may be altered in a shockwave @@ -713,21 +716,21 @@ void physics_sim_vel(vector * position, physics_info * pi, float sim_time, matri // become (0.01x in 3 sec) int special_warp_in = FALSE; - float excess = local_v_in.z - pi->max_vel.z; + float excess = local_v_in.xyz.z - pi->max_vel.xyz.z; if (excess > 5 && (pi->flags & PF_SPECIAL_WARP_IN)) { special_warp_in = TRUE; float exp_factor = float(exp(-sim_time / SPECIAL_WARP_T_CONST)); - local_v_out.z = pi->max_vel.z + excess * exp_factor; - local_disp.z = (pi->max_vel.z * sim_time) + excess * (float(SPECIAL_WARP_T_CONST) * (1.0f - exp_factor)); + local_v_out.xyz.z = pi->max_vel.xyz.z + excess * exp_factor; + local_disp.xyz.z = (pi->max_vel.xyz.z * sim_time) + excess * (float(SPECIAL_WARP_T_CONST) * (1.0f - exp_factor)); } else if (pi->flags & PF_SPECIAL_WARP_OUT) { float exp_factor = float(exp(-sim_time / SPECIAL_WARP_T_CONST)); vector temp; vm_vec_rotate(&temp, &pi->prev_ramp_vel, orient); - float deficeit = temp.z - local_v_in.z; - local_v_out.z = local_v_in.z + deficeit * (1.0f - exp_factor); - local_disp.z = (local_v_in.z * sim_time) + deficeit * (sim_time - (float(SPECIAL_WARP_T_CONST) * (1.0f - exp_factor))); + float deficeit = temp.xyz.z - local_v_in.xyz.z; + local_v_out.xyz.z = local_v_in.xyz.z + deficeit * (1.0f - exp_factor); + local_disp.xyz.z = (local_v_in.xyz.z * sim_time) + deficeit * (sim_time - (float(SPECIAL_WARP_T_CONST) * (1.0f - exp_factor))); } else { - apply_physics (damp.z, local_desired_vel.z, local_v_in.z, sim_time, &local_v_out.z, &local_disp.z); + apply_physics (damp.xyz.z, local_desired_vel.xyz.z, local_v_in.xyz.z, sim_time, &local_v_out.xyz.z, &local_disp.xyz.z); } // maybe turn off special warp in flag @@ -769,7 +772,7 @@ void physics_sim(vector* position, matrix* orient, physics_info* pi, float sim_t physics_sim_rot(orient, pi, sim_time); pi->speed = vm_vec_mag(&pi->vel); // Note, cannot use quick version, causes cumulative error, increasing speed. - pi->fspeed = vm_vec_dot(&orient->fvec, &pi->vel); // instead of vector magnitude -- use only forward vector since we are only interested in forward velocity + pi->fspeed = vm_vec_dot(&orient->v.fvec, &pi->vel); // instead of vector magnitude -- use only forward vector since we are only interested in forward velocity } } @@ -783,20 +786,20 @@ void physics_sim_editor(vector *position, matrix * orient, physics_info * pi, fl physics_sim_vel(position, pi, sim_time, orient); physics_sim_rot_editor(orient, pi, sim_time); pi->speed = vm_vec_mag_quick(&pi->vel); - pi->fspeed = vm_vec_dot(&orient->fvec, &pi->vel); // instead of vector magnitude -- use only forward vector since we are only interested in forward velocity + pi->fspeed = vm_vec_dot(&orient->v.fvec, &pi->vel); // instead of vector magnitude -- use only forward vector since we are only interested in forward velocity } // function to predict an object's position given the delta time and an objects physics info void physics_predict_pos(physics_info *pi, float delta_time, vector *predicted_pos) { - apply_physics( pi->side_slip_time_const, pi->desired_vel.x, pi->vel.x, delta_time, - NULL, &predicted_pos->x ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.x, pi->vel.xyz.x, delta_time, + NULL, &predicted_pos->xyz.x ); - apply_physics( pi->side_slip_time_const, pi->desired_vel.y, pi->vel.y, delta_time, - NULL, &predicted_pos->y ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.y, pi->vel.xyz.y, delta_time, + NULL, &predicted_pos->xyz.y ); - apply_physics( pi->side_slip_time_const, pi->desired_vel.z, pi->vel.z, delta_time, - NULL, &predicted_pos->z ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.z, pi->vel.xyz.z, delta_time, + NULL, &predicted_pos->xyz.z ); } // function to predict an object's velocity given the parameters @@ -805,14 +808,14 @@ void physics_predict_vel(physics_info *pi, float delta_time, vector *predicted_v if (pi->flags & PF_CONST_VEL) { predicted_vel = &pi->vel; } else { - apply_physics( pi->side_slip_time_const, pi->desired_vel.x, pi->vel.x, delta_time, - &predicted_vel->x, NULL ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.x, pi->vel.xyz.x, delta_time, + &predicted_vel->xyz.x, NULL ); - apply_physics( pi->side_slip_time_const, pi->desired_vel.y, pi->vel.y, delta_time, - &predicted_vel->y, NULL ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.y, pi->vel.xyz.y, delta_time, + &predicted_vel->xyz.y, NULL ); - apply_physics( pi->side_slip_time_const, pi->desired_vel.z, pi->vel.z, delta_time, - &predicted_vel->z, NULL ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.z, pi->vel.xyz.z, delta_time, + &predicted_vel->xyz.z, NULL ); } } @@ -820,14 +823,14 @@ void physics_predict_vel(physics_info *pi, float delta_time, vector *predicted_v void physics_predict_pos_and_vel(physics_info *pi, float delta_time, vector *predicted_vel, vector *predicted_pos) { - apply_physics( pi->side_slip_time_const, pi->desired_vel.x, pi->vel.x, delta_time, - &predicted_vel->x, &predicted_pos->x ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.x, pi->vel.xyz.x, delta_time, + &predicted_vel->xyz.x, &predicted_pos->xyz.x ); - apply_physics( pi->side_slip_time_const, pi->desired_vel.y, pi->vel.y, delta_time, - &predicted_vel->y, &predicted_pos->y ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.y, pi->vel.xyz.y, delta_time, + &predicted_vel->xyz.y, &predicted_pos->xyz.y ); - apply_physics( pi->side_slip_time_const, pi->desired_vel.z, pi->vel.z, delta_time, - &predicted_vel->z, &predicted_pos->z ); + apply_physics( pi->side_slip_time_const, pi->desired_vel.xyz.z, pi->vel.xyz.z, delta_time, + &predicted_vel->xyz.z, &predicted_pos->xyz.z ); } // physics_read_flying_controls() @@ -861,9 +864,9 @@ void physics_read_flying_controls( matrix * orient, physics_info * pi, control_i // give control imput to cause rotation in engine wash extern int Wash_on; if ( wash_rot && Wash_on ) { - ci->pitch += wash_rot->x; - ci->bank += wash_rot->z; - ci->heading += wash_rot->y; + ci->pitch += wash_rot->xyz.x; + ci->bank += wash_rot->xyz.z; + ci->heading += wash_rot->xyz.y; } if (ci->pitch > 1.0f ) ci->pitch = 1.0f; @@ -887,8 +890,8 @@ void physics_read_flying_controls( matrix * orient, physics_info * pi, control_i if (ci->forward > 1.0f ) ci->forward = 1.0f; else if (ci->forward < -1.0f ) ci->forward = -1.0f; - pi->desired_rotvel.x = ci->pitch * pi->max_rotvel.x; - pi->desired_rotvel.y = ci->heading * pi->max_rotvel.y; + pi->desired_rotvel.xyz.x = ci->pitch * pi->max_rotvel.xyz.x; + pi->desired_rotvel.xyz.y = ci->heading * pi->max_rotvel.xyz.y; float delta_bank; @@ -896,27 +899,27 @@ void physics_read_flying_controls( matrix * orient, physics_info * pi, control_i // To change direction of bank, negate the whole expression. // To increase magnitude of banking, decrease denominator. // Adam: The following statement is all the math for banking while turning. - delta_bank = - (ci->heading * pi->max_rotvel.y)/2.0f; + delta_bank = - (ci->heading * pi->max_rotvel.xyz.y)/2.0f; #else delta_bank = 0.0f; #endif - pi->desired_rotvel.z = ci->bank * pi->max_rotvel.z + delta_bank; + pi->desired_rotvel.xyz.z = ci->bank * pi->max_rotvel.xyz.z + delta_bank; pi->forward_thrust = ci->forward; if ( pi->flags & PF_AFTERBURNER_ON ) { - goal_vel.x = ci->sideways*pi->afterburner_max_vel.x; - goal_vel.y = ci->vertical*pi->afterburner_max_vel.y; - goal_vel.z = ci->forward* pi->afterburner_max_vel.z; + goal_vel.xyz.x = ci->sideways*pi->afterburner_max_vel.xyz.x; + goal_vel.xyz.y = ci->vertical*pi->afterburner_max_vel.xyz.y; + goal_vel.xyz.z = ci->forward* pi->afterburner_max_vel.xyz.z; } else { - goal_vel.x = ci->sideways*pi->max_vel.x; - goal_vel.y = ci->vertical*pi->max_vel.y; - goal_vel.z = ci->forward* pi->max_vel.z; + goal_vel.xyz.x = ci->sideways*pi->max_vel.xyz.x; + goal_vel.xyz.y = ci->vertical*pi->max_vel.xyz.y; + goal_vel.xyz.z = ci->forward* pi->max_vel.xyz.z; } - if ( goal_vel.z < -pi->max_rear_vel ) - goal_vel.z = -pi->max_rear_vel; + if ( goal_vel.xyz.z < -pi->max_rear_vel ) + goal_vel.xyz.z = -pi->max_rear_vel; if ( pi->flags & PF_ACCELERATES ) { @@ -943,13 +946,13 @@ void physics_read_flying_controls( matrix * orient, physics_info * pi, control_i if (pi->flags & PF_SLIDE_ENABLED) { // determine the local velocity // deterimine whether accelerating or decleration toward goal for x - if ( goal_vel.x > 0.0f ) { - if ( goal_vel.x >= pi->prev_ramp_vel.x ) + if ( goal_vel.xyz.x > 0.0f ) { + if ( goal_vel.xyz.x >= pi->prev_ramp_vel.xyz.x ) ramp_time_const = pi->slide_accel_time_const; else ramp_time_const = pi->slide_decel_time_const; - } else { // goal_vel.x <= 0.0 - if ( goal_vel.x <= pi->prev_ramp_vel.x ) + } else { // goal_vel.xyz.x <= 0.0 + if ( goal_vel.xyz.x <= pi->prev_ramp_vel.xyz.x ) ramp_time_const = pi->slide_accel_time_const; else ramp_time_const = pi->slide_decel_time_const; @@ -958,16 +961,16 @@ void physics_read_flying_controls( matrix * orient, physics_info * pi, control_i if ( pi->flags & PF_REDUCED_DAMP ) { ramp_time_const *= reduced_damp_ramp_time_expansion; } - pi->prev_ramp_vel.x = velocity_ramp(pi->prev_ramp_vel.x, goal_vel.x, ramp_time_const, sim_time); + pi->prev_ramp_vel.xyz.x = velocity_ramp(pi->prev_ramp_vel.xyz.x, goal_vel.xyz.x, ramp_time_const, sim_time); // deterimine whether accelerating or decleration toward goal for y - if ( goal_vel.y > 0.0f ) { - if ( goal_vel.y >= pi->prev_ramp_vel.y ) + if ( goal_vel.xyz.y > 0.0f ) { + if ( goal_vel.xyz.y >= pi->prev_ramp_vel.xyz.y ) ramp_time_const = pi->slide_accel_time_const; else ramp_time_const = pi->slide_decel_time_const; - } else { // goal_vel.y <= 0.0 - if ( goal_vel.y <= pi->prev_ramp_vel.y ) + } else { // goal_vel.xyz.y <= 0.0 + if ( goal_vel.xyz.y <= pi->prev_ramp_vel.xyz.y ) ramp_time_const = pi->slide_accel_time_const; else ramp_time_const = pi->slide_decel_time_const; @@ -976,15 +979,15 @@ void physics_read_flying_controls( matrix * orient, physics_info * pi, control_i if ( pi->flags & PF_REDUCED_DAMP ) { ramp_time_const *= reduced_damp_ramp_time_expansion; } - pi->prev_ramp_vel.y = velocity_ramp( pi->prev_ramp_vel.y, goal_vel.y, ramp_time_const, sim_time); + pi->prev_ramp_vel.xyz.y = velocity_ramp( pi->prev_ramp_vel.xyz.y, goal_vel.xyz.y, ramp_time_const, sim_time); } else { // slide not enabled - pi->prev_ramp_vel.x = 0.0f; - pi->prev_ramp_vel.y = 0.0f; + pi->prev_ramp_vel.xyz.x = 0.0f; + pi->prev_ramp_vel.xyz.y = 0.0f; } // find ramp velocity in the forward direction - if ( goal_vel.z >= pi->prev_ramp_vel.z ) { + if ( goal_vel.xyz.z >= pi->prev_ramp_vel.xyz.z ) { if ( pi->flags & PF_AFTERBURNER_ON ) ramp_time_const = pi->afterburner_forward_accel_time_const; else @@ -996,15 +999,15 @@ void physics_read_flying_controls( matrix * orient, physics_info * pi, control_i if ( pi->flags & PF_REDUCED_DAMP ) { ramp_time_const *= reduced_damp_ramp_time_expansion; } - pi->prev_ramp_vel.z = velocity_ramp( pi->prev_ramp_vel.z, goal_vel.z, ramp_time_const, sim_time); + pi->prev_ramp_vel.xyz.z = velocity_ramp( pi->prev_ramp_vel.xyz.z, goal_vel.xyz.z, ramp_time_const, sim_time); // this translates local desired velocities to world velocities vm_vec_zero(&pi->desired_vel); - vm_vec_scale_add2( &pi->desired_vel, &orient->rvec, pi->prev_ramp_vel.x ); - vm_vec_scale_add2( &pi->desired_vel, &orient->uvec, pi->prev_ramp_vel.y ); - vm_vec_scale_add2( &pi->desired_vel, &orient->fvec, pi->prev_ramp_vel.z ); + vm_vec_scale_add2( &pi->desired_vel, &orient->v.rvec, pi->prev_ramp_vel.xyz.x ); + vm_vec_scale_add2( &pi->desired_vel, &orient->v.uvec, pi->prev_ramp_vel.xyz.y ); + vm_vec_scale_add2( &pi->desired_vel, &orient->v.fvec, pi->prev_ramp_vel.xyz.z ); } else // object does not accelerate (PF_ACCELERATES not set) pi->desired_vel = pi->vel; } @@ -1053,7 +1056,7 @@ void physics_apply_whack(vector *impulse, vector *pos, physics_info *pi, matrix // vector npos; // Detect null vector. - if ((fl_abs(impulse->x) <= WHACK_LIMIT) && (fl_abs(impulse->y) <= WHACK_LIMIT) && (fl_abs(impulse->z) <= WHACK_LIMIT)) + if ((fl_abs(impulse->xyz.x) <= WHACK_LIMIT) && (fl_abs(impulse->xyz.y) <= WHACK_LIMIT) && (fl_abs(impulse->xyz.z) <= WHACK_LIMIT)) return; // first do the rotational velocity @@ -1074,7 +1077,7 @@ void physics_apply_whack(vector *impulse, vector *pos, physics_info *pi, matrix } #endif - //mprintf(("Whack: %7.3f %7.3f %7.3f\n", pi->rotvel.x, pi->rotvel.y, pi->rotvel.z)); + //mprintf(("Whack: %7.3f %7.3f %7.3f\n", pi->rotvel.xyz.x, pi->rotvel.xyz.y, pi->rotvel.xyz.z)); // instant whack on the velocity // reduce damping on all axes @@ -1167,17 +1170,17 @@ void physics_apply_shock(vector *direction_vec, float pressure, physics_info *pi vm_vec_normalize_safe ( direction_vec ); - area.x = (max->y - min->z) * (max->z - min->z); - area.y = (max->x - min->x) * (max->z - min->z); - area.z = (max->x - min->x) * (max->y - min->y); + area.xyz.x = (max->xyz.y - min->xyz.z) * (max->xyz.z - min->xyz.z); + area.xyz.y = (max->xyz.x - min->xyz.x) * (max->xyz.z - min->xyz.z); + area.xyz.z = (max->xyz.x - min->xyz.x) * (max->xyz.y - min->xyz.y); - normal.x = vm_vec_dotprod( direction_vec, &orient->rvec ); - normal.y = vm_vec_dotprod( direction_vec, &orient->uvec ); - normal.z = vm_vec_dotprod( direction_vec, &orient->fvec ); + normal.xyz.x = vm_vec_dotprod( direction_vec, &orient->v.rvec ); + normal.xyz.y = vm_vec_dotprod( direction_vec, &orient->v.uvec ); + normal.xyz.z = vm_vec_dotprod( direction_vec, &orient->v.fvec ); - sin.x = fl_sqrt( fl_abs(1.0f - normal.x*normal.x) ); - sin.y = fl_sqrt( fl_abs(1.0f - normal.y*normal.y) ); - sin.z = fl_sqrt( fl_abs(1.0f - normal.z*normal.z) ); + sin.xyz.x = fl_sqrt( fl_abs(1.0f - normal.xyz.x*normal.xyz.x) ); + sin.xyz.y = fl_sqrt( fl_abs(1.0f - normal.xyz.y*normal.xyz.y) ); + sin.xyz.z = fl_sqrt( fl_abs(1.0f - normal.xyz.z*normal.xyz.z) ); vm_vec_make( &torque, 0.0f, 0.0f, 0.0f ); @@ -1191,28 +1194,28 @@ void physics_apply_shock(vector *direction_vec, float pressure, physics_info *pi // more massive objects get less rotation // find torque due to forces on the right/left face - if ( normal.x < 0.0f ) // normal < 0, hits the right face - vm_vec_copy_scale( &impact_vec, &orient->rvec, max->x * pressure * area.x * normal.x * sin.x / pi->mass ); + if ( normal.xyz.x < 0.0f ) // normal < 0, hits the right face + vm_vec_copy_scale( &impact_vec, &orient->v.rvec, max->xyz.x * pressure * area.xyz.x * normal.xyz.x * sin.xyz.x / pi->mass ); else // normal > 0, hits the left face - vm_vec_copy_scale( &impact_vec, &orient->rvec, min->x * pressure * area.x * -normal.x * sin.x / pi->mass ); + vm_vec_copy_scale( &impact_vec, &orient->v.rvec, min->xyz.x * pressure * area.xyz.x * -normal.xyz.x * sin.xyz.x / pi->mass ); vm_vec_crossprod( &temp_torque, &impact_vec, direction_vec ); vm_vec_add2( &torque, &temp_torque ); // find torque due to forces on the up/down face - if ( normal.y < 0.0f ) - vm_vec_copy_scale( &impact_vec, &orient->uvec, max->y * pressure * area.y * normal.y * sin.y / pi->mass ); + if ( normal.xyz.y < 0.0f ) + vm_vec_copy_scale( &impact_vec, &orient->v.uvec, max->xyz.y * pressure * area.xyz.y * normal.xyz.y * sin.xyz.y / pi->mass ); else - vm_vec_copy_scale( &impact_vec, &orient->uvec, min->y * pressure * area.y * -normal.y * sin.y / pi->mass ); + vm_vec_copy_scale( &impact_vec, &orient->v.uvec, min->xyz.y * pressure * area.xyz.y * -normal.xyz.y * sin.xyz.y / pi->mass ); vm_vec_crossprod( &temp_torque, &impact_vec, direction_vec ); vm_vec_add2( &torque, &temp_torque ); // find torque due to forces on the forward/backward face - if ( normal.z < 0.0f ) - vm_vec_copy_scale( &impact_vec, &orient->fvec, max->z * pressure * area.z * normal.z * sin.z / pi->mass ); + if ( normal.xyz.z < 0.0f ) + vm_vec_copy_scale( &impact_vec, &orient->v.fvec, max->xyz.z * pressure * area.xyz.z * normal.xyz.z * sin.xyz.z / pi->mass ); else - vm_vec_copy_scale( &impact_vec, &orient->fvec, min->z * pressure * area.z * -normal.z * sin.z / pi->mass ); + vm_vec_copy_scale( &impact_vec, &orient->v.fvec, min->xyz.z * pressure * area.xyz.z * -normal.xyz.z * sin.xyz.z / pi->mass ); vm_vec_crossprod( &temp_torque, &impact_vec, direction_vec ); vm_vec_add2( &torque, &temp_torque ); @@ -1280,7 +1283,7 @@ void physics_collide_whack( vector *impulse, vector *world_delta_rotvel, physics vector body_delta_rotvel; // Detect null vector. - if ((fl_abs(impulse->x) <= WHACK_LIMIT) && (fl_abs(impulse->y) <= WHACK_LIMIT) && (fl_abs(impulse->z) <= WHACK_LIMIT)) + if ((fl_abs(impulse->xyz.x) <= WHACK_LIMIT) && (fl_abs(impulse->xyz.y) <= WHACK_LIMIT) && (fl_abs(impulse->xyz.z) <= WHACK_LIMIT)) return; vm_vec_rotate( &body_delta_rotvel, world_delta_rotvel, orient ); @@ -1330,32 +1333,32 @@ int check_rotvel_limit( physics_info *pi ) if ( !(pi->flags & PF_DEAD_DAMP) ) { // case of normal, live ship // -- Commented out by MK: Assert( vm_vec_mag_squared(&pi->max_rotvel) > ROTVEL_TOL ); - // Assert( (pi->max_rotvel.x <= ROTVEL_CAP) && (pi->max_rotvel.y <= ROTVEL_CAP) && (pi->max_rotvel.z <= ROTVEL_CAP) ); - // Warning(LOCATION,"Excessive rotvel (wx: %f, wy: %f, wz:%f)\n", pi->rotvel.x, pi->rotvel.y, pi->rotvel.z); - if ( fl_abs(pi->rotvel.x) > pi->max_rotvel.x ) { - pi->rotvel.x = (pi->rotvel.x / fl_abs(pi->rotvel.x)) * (pi->max_rotvel.x - (float) ROTVEL_TOL); + // Assert( (pi->max_rotvel.xyz.x <= ROTVEL_CAP) && (pi->max_rotvel.xyz.y <= ROTVEL_CAP) && (pi->max_rotvel.xyz.z <= ROTVEL_CAP) ); + // Warning(LOCATION,"Excessive rotvel (wx: %f, wy: %f, wz:%f)\n", pi->rotvel.xyz.x, pi->rotvel.xyz.y, pi->rotvel.xyz.z); + if ( fl_abs(pi->rotvel.xyz.x) > pi->max_rotvel.xyz.x ) { + pi->rotvel.xyz.x = (pi->rotvel.xyz.x / fl_abs(pi->rotvel.xyz.x)) * (pi->max_rotvel.xyz.x - (float) ROTVEL_TOL); change_made = 1; } - if ( fl_abs(pi->rotvel.y) > pi->max_rotvel.y ) { - pi->rotvel.y = (pi->rotvel.y / fl_abs(pi->rotvel.y)) * (pi->max_rotvel.y - (float) ROTVEL_TOL); + if ( fl_abs(pi->rotvel.xyz.y) > pi->max_rotvel.xyz.y ) { + pi->rotvel.xyz.y = (pi->rotvel.xyz.y / fl_abs(pi->rotvel.xyz.y)) * (pi->max_rotvel.xyz.y - (float) ROTVEL_TOL); change_made = 1; } - if ( fl_abs(pi->rotvel.z) > pi->max_rotvel.z ) { - pi->rotvel.z = (pi->rotvel.z / fl_abs(pi->rotvel.z)) * (pi->max_rotvel.z - (float) ROTVEL_TOL); + if ( fl_abs(pi->rotvel.xyz.z) > pi->max_rotvel.xyz.z ) { + pi->rotvel.xyz.z = (pi->rotvel.xyz.z / fl_abs(pi->rotvel.xyz.z)) * (pi->max_rotvel.xyz.z - (float) ROTVEL_TOL); change_made = 1; } } else { // case of dead ship - if ( fl_abs(pi->rotvel.x) > DEAD_ROTVEL_CAP ) { - pi->rotvel.x = (pi->rotvel.x / fl_abs(pi->rotvel.x)) * (float) (DEAD_ROTVEL_CAP - ROTVEL_TOL); + if ( fl_abs(pi->rotvel.xyz.x) > DEAD_ROTVEL_CAP ) { + pi->rotvel.xyz.x = (pi->rotvel.xyz.x / fl_abs(pi->rotvel.xyz.x)) * (float) (DEAD_ROTVEL_CAP - ROTVEL_TOL); change_made = 1; } - if ( fl_abs(pi->rotvel.y) > DEAD_ROTVEL_CAP ) { - pi->rotvel.y = (pi->rotvel.y / fl_abs(pi->rotvel.y)) * (float) (DEAD_ROTVEL_CAP - ROTVEL_TOL); + if ( fl_abs(pi->rotvel.xyz.y) > DEAD_ROTVEL_CAP ) { + pi->rotvel.xyz.y = (pi->rotvel.xyz.y / fl_abs(pi->rotvel.xyz.y)) * (float) (DEAD_ROTVEL_CAP - ROTVEL_TOL); change_made = 1; } - if ( fl_abs(pi->rotvel.z) > DEAD_ROTVEL_CAP ) { - pi->rotvel.z = (pi->rotvel.z / fl_abs(pi->rotvel.z)) * (float) (DEAD_ROTVEL_CAP - ROTVEL_TOL); + if ( fl_abs(pi->rotvel.xyz.z) > DEAD_ROTVEL_CAP ) { + pi->rotvel.xyz.z = (pi->rotvel.xyz.z / fl_abs(pi->rotvel.xyz.z)) * (float) (DEAD_ROTVEL_CAP - ROTVEL_TOL); change_made = 1; } } diff --git a/src/playerman/playercontrol.cpp b/src/playerman/playercontrol.cpp index d72803a..5523878 100644 --- a/src/playerman/playercontrol.cpp +++ b/src/playerman/playercontrol.cpp @@ -15,6 +15,9 @@ * Routines to deal with player ship movement * * $Log$ + * Revision 1.4 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:25 relnev * added copyright header * @@ -1184,7 +1187,7 @@ void read_player_controls(object *objp, float frametime) // the ships maximum velocity now depends on the energy flowing to engines if(objp->type != OBJ_OBSERVER){ - objp->phys_info.max_vel.z = Ships[objp->instance].current_max_speed; + objp->phys_info.max_vel.xyz.z = Ships[objp->instance].current_max_speed; } if(Player_obj->type == OBJ_SHIP){ // only read player control info if player ship is not dead @@ -1676,7 +1679,7 @@ int player_inspect_cargo(float frametime, char *outstr) // check if player is facing cargo, do not proceed with inspection if not vm_vec_normalized_dir(&vec_to_cargo, &cargo_objp->pos, &Player_obj->pos); - dot = vm_vec_dot(&vec_to_cargo, &Player_obj->orient.fvec); + dot = vm_vec_dot(&vec_to_cargo, &Player_obj->orient.v.fvec); if ( dot < CARGO_MIN_DOT_TO_REVEAL ) { if ( !(cargo_sp->flags & SF_SCANNABLE) ) sprintf(outstr,XSTR( "cargo: ", 86)); @@ -1777,7 +1780,7 @@ int player_inspect_cap_subsys_cargo(float frametime, char *outstr) // check if player is facing cargo, do not proceed with inspection if not vm_vec_normalized_dir(&vec_to_cargo, &subsys_pos, &Player_obj->pos); - dot = vm_vec_dot(&vec_to_cargo, &Player_obj->orient.fvec); + dot = vm_vec_dot(&vec_to_cargo, &Player_obj->orient.v.fvec); int hud_targetbox_subsystem_in_view(object *target_objp, int *sx, int *sy); subsys_in_view = hud_targetbox_subsystem_in_view(cargo_objp, &x, &y); @@ -2084,17 +2087,17 @@ void player_get_padlock_orient(matrix *eye_orient) old_eye_orient = *eye_orient; if ( Viewer_mode & VM_PADLOCK_UP ) { - eye_orient->fvec = old_eye_orient.uvec; - vm_vec_copy_scale( &eye_orient->uvec, &old_eye_orient.fvec, -1.0f ); + eye_orient->v.fvec = old_eye_orient.v.uvec; + vm_vec_copy_scale( &eye_orient->v.uvec, &old_eye_orient.v.fvec, -1.0f ); } else if ( Viewer_mode & VM_PADLOCK_REAR ) { - vm_vec_negate(&eye_orient->fvec); - vm_vec_negate(&eye_orient->rvec); + vm_vec_negate(&eye_orient->v.fvec); + vm_vec_negate(&eye_orient->v.rvec); } else if ( Viewer_mode & VM_PADLOCK_LEFT ) { - vm_vec_copy_scale( &eye_orient->fvec, &old_eye_orient.rvec, -1.0f ); - eye_orient->rvec = old_eye_orient.fvec; + vm_vec_copy_scale( &eye_orient->v.fvec, &old_eye_orient.v.rvec, -1.0f ); + eye_orient->v.rvec = old_eye_orient.v.fvec; } else if ( Viewer_mode & VM_PADLOCK_RIGHT ) { - eye_orient->fvec = old_eye_orient.rvec; - vm_vec_copy_scale( &eye_orient->rvec, &old_eye_orient.fvec, -1.0f ); + eye_orient->v.fvec = old_eye_orient.v.rvec; + vm_vec_copy_scale( &eye_orient->v.rvec, &old_eye_orient.v.fvec, -1.0f ); } else { Int3(); } @@ -2232,11 +2235,11 @@ void player_get_eye(vector *eye_pos, matrix *eye_orient) vm_angles_2_matrix(&tm2, &Viewer_external_info.angles); vm_matrix_x_matrix(&tm, &viewer_obj->orient, &tm2); - vm_vec_scale_add(eye_pos, &viewer_obj->pos, &tm.fvec, 2.0f * viewer_obj->radius + Viewer_external_info.distance); + vm_vec_scale_add(eye_pos, &viewer_obj->pos, &tm.v.fvec, 2.0f * viewer_obj->radius + Viewer_external_info.distance); vm_vec_sub(&eye_dir, &viewer_obj->pos, eye_pos); vm_vec_normalize(&eye_dir); - vm_vector_2_matrix(eye_orient, &eye_dir, &viewer_obj->orient.uvec, NULL); + vm_vector_2_matrix(eye_orient, &eye_dir, &viewer_obj->orient.v.uvec, NULL); viewer_obj = NULL; // Modify the orientation based on head orientation. @@ -2245,25 +2248,25 @@ void player_get_eye(vector *eye_pos, matrix *eye_orient) vector move_dir; if ( viewer_obj->phys_info.speed < 0.1 ){ - move_dir = viewer_obj->orient.fvec; + move_dir = viewer_obj->orient.v.fvec; } else { move_dir = viewer_obj->phys_info.vel; vm_vec_normalize_safe(&move_dir); } vm_vec_scale_add(eye_pos, &viewer_obj->pos, &move_dir, -3.0f * viewer_obj->radius - Viewer_chase_info.distance); - vm_vec_scale_add2(eye_pos, &viewer_obj->orient.uvec, 0.75f * viewer_obj->radius); + vm_vec_scale_add2(eye_pos, &viewer_obj->orient.v.uvec, 0.75f * viewer_obj->radius); vm_vec_sub(&eye_dir, &viewer_obj->pos, eye_pos); vm_vec_normalize(&eye_dir); // JAS: I added the following code because if you slew up using - // Descent-style physics, eye_dir and Viewer_obj->orient.uvec are + // Descent-style physics, eye_dir and Viewer_obj->orient.v.uvec are // equal, which causes a zero-length vector in the vm_vector_2_matrix // call because the up and the forward vector are the same. I fixed // it by adding in a fraction of the right vector all the time to the // up vector. - vector tmp_up = viewer_obj->orient.uvec; - vm_vec_scale_add2( &tmp_up, &viewer_obj->orient.rvec, 0.00001f ); + vector tmp_up = viewer_obj->orient.v.uvec; + vm_vec_scale_add2( &tmp_up, &viewer_obj->orient.v.rvec, 0.00001f ); vm_vector_2_matrix(eye_orient, &eye_dir, &tmp_up, NULL); viewer_obj = NULL; @@ -2277,7 +2280,7 @@ void player_get_eye(vector *eye_pos, matrix *eye_orient) vm_vec_sub(&eye_dir, &shipp->warp_effect_pos, eye_pos); vm_vec_normalize(&eye_dir); - vm_vector_2_matrix(eye_orient, &eye_dir, &Player_obj->orient.uvec, NULL); + vm_vector_2_matrix(eye_orient, &eye_dir, &Player_obj->orient.v.uvec, NULL); viewer_obj = NULL; } else { // get an eye position based upon the correct type of object diff --git a/src/radar/radar.cpp b/src/radar/radar.cpp index 0b6afe9..6eaf27a 100644 --- a/src/radar/radar.cpp +++ b/src/radar/radar.cpp @@ -15,6 +15,9 @@ * C module containg functions to display and manage the radar * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:25 relnev * added copyright header * @@ -476,13 +479,13 @@ void radar_plot_object( object *objp ) return; } - if ( dist < pos.z ) { + if ( dist < pos.xyz.z ) { rscale = 0.0f; } else { - rscale = (float) acos( pos.z/dist ) / 3.14159f; //2.0f; + rscale = (float) acos( pos.xyz.z/dist ) / 3.14159f; //2.0f; } - zdist = fl_sqrt( (pos.x*pos.x)+(pos.y*pos.y) ); + zdist = fl_sqrt( (pos.xyz.x*pos.xyz.x)+(pos.xyz.y*pos.xyz.y) ); float new_x_dist, clipped_x_dist; float new_y_dist, clipped_y_dist; @@ -492,8 +495,8 @@ void radar_plot_object( object *objp ) new_y_dist = 0.0f; } else { - new_x_dist = (pos.x/zdist) * rscale * radx; - new_y_dist = (pos.y/zdist) * rscale * rady; + new_x_dist = (pos.xyz.x/zdist) * rscale * radx; + new_y_dist = (pos.xyz.y/zdist) * rscale * rady; // force new_x_dist and new_y_dist to be inside the radar diff --git a/src/render/3ddraw.cpp b/src/render/3ddraw.cpp index 7ee8a92..68495ff 100644 --- a/src/render/3ddraw.cpp +++ b/src/render/3ddraw.cpp @@ -15,6 +15,9 @@ * 3D rendering primitives * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:25 relnev * added copyright header * @@ -282,7 +285,7 @@ int do_facing_check(vector *norm,vertex **vertlist,vector *p) if (norm) { //have normal - Assert(norm->x || norm->y || norm->z); + Assert(norm->xyz.x || norm->xyz.y || norm->xyz.z); return g3_check_normal_facing(p,norm); } @@ -511,7 +514,7 @@ int g3_draw_sphere(vertex *pnt,float rad) if (! (pnt->codes & PF_OVERFLOW)) { float r2,t; - r2 = rad*Matrix_scale.x; + r2 = rad*Matrix_scale.xyz.x; t=r2*Canv_w2/pnt->z; @@ -584,10 +587,10 @@ int g3_draw_bitmap(vertex *pnt,int orient, float rad,uint tmap_flags) return 1; t = (width*Canv_w2)/pnt->z; - w = t*Matrix_scale.x; + w = t*Matrix_scale.xyz.x; t = (height*Canv_h2)/pnt->z; - h = t*Matrix_scale.y; + h = t*Matrix_scale.xyz.y; float z,sw; z = pnt->z - rad/2.0f; @@ -664,10 +667,10 @@ int g3_get_bitmap_dims(int bitmap, vertex *pnt, float rad, int *x, int *y, int * } t = (width*Canv_w2)/pnt->z; - *w = (int)(t*Matrix_scale.x); + *w = (int)(t*Matrix_scale.xyz.x); t = (height*Canv_h2)/pnt->z; - *h = (int)(t*Matrix_scale.y); + *h = (int)(t*Matrix_scale.xyz.y); *x = (int)(pnt->sx - *w/2.0f); *y = (int)(pnt->sy - *h/2.0f); @@ -735,29 +738,29 @@ int g3_draw_rotated_bitmap(vertex *pnt,float angle, float rad,uint tmap_flags) } - v[0].x = (-width*ca + height*sa)*Matrix_scale.x + pnt->x; - v[0].y = (-width*sa - height*ca)*Matrix_scale.y + pnt->y; + v[0].x = (-width*ca + height*sa)*Matrix_scale.xyz.x + pnt->x; + v[0].y = (-width*sa - height*ca)*Matrix_scale.xyz.y + pnt->y; v[0].z = pnt->z; v[0].sw = 0.0f; v[0].u = 0.0f; v[0].v = 1.0f; - v[1].x = (width*ca + height*sa)*Matrix_scale.x + pnt->x; - v[1].y = (width*sa - height*ca)*Matrix_scale.y + pnt->y; + v[1].x = (width*ca + height*sa)*Matrix_scale.xyz.x + pnt->x; + v[1].y = (width*sa - height*ca)*Matrix_scale.xyz.y + pnt->y; v[1].z = pnt->z; v[1].sw = 0.0f; v[1].u = 1.0f; v[1].v = 1.0f; - v[2].x = (width*ca - height*sa)*Matrix_scale.x + pnt->x; - v[2].y = (width*sa + height*ca)*Matrix_scale.y + pnt->y; + v[2].x = (width*ca - height*sa)*Matrix_scale.xyz.x + pnt->x; + v[2].y = (width*sa + height*ca)*Matrix_scale.xyz.y + pnt->y; v[2].z = pnt->z; v[2].sw = 0.0f; v[2].u = 1.0f; v[2].v = 0.0f; - v[3].x = (-width*ca - height*sa)*Matrix_scale.x + pnt->x; - v[3].y = (-width*sa + height*ca)*Matrix_scale.y + pnt->y; + v[3].x = (-width*ca - height*sa)*Matrix_scale.xyz.x + pnt->x; + v[3].y = (-width*sa + height*ca)*Matrix_scale.xyz.y + pnt->y; v[3].z = pnt->z; v[3].sw = 0.0f; v[3].u = 0.0f; @@ -786,7 +789,7 @@ int g3_draw_rotated_bitmap(vertex *pnt,float angle, float rad,uint tmap_flags) return 0; } -#define TRIANGLE_AREA(_p, _q, _r) do { vector a, b, cross; a.x = _q->x - _p->x; a.y = _q->y - _p->y; a.z = 0.0f; b.x = _r->x - _p->x; b.y = _r->y - _p->y; b.z = 0.0f; vm_vec_crossprod(&cross, &a, &b); total_area += vm_vec_mag(&cross) * 0.5f; } while(0); +#define TRIANGLE_AREA(_p, _q, _r) do { vector a, b, cross; a.xyz.x = _q->x - _p->x; a.xyz.y = _q->y - _p->y; a.xyz.z = 0.0f; b.xyz.x = _r->x - _p->x; b.xyz.y = _r->y - _p->y; b.xyz.z = 0.0f; vm_vec_crossprod(&cross, &a, &b); total_area += vm_vec_mag(&cross) * 0.5f; } while(0); float g3_get_poly_area(int nv, vertex **pointlist) { int idx; @@ -942,29 +945,29 @@ float g3_draw_rotated_bitmap_area(vertex *pnt,float angle, float rad,uint tmap_f } - v[0].x = (-width*ca + height*sa)*Matrix_scale.x + pnt->x; - v[0].y = (-width*sa - height*ca)*Matrix_scale.y + pnt->y; + v[0].x = (-width*ca + height*sa)*Matrix_scale.xyz.x + pnt->x; + v[0].y = (-width*sa - height*ca)*Matrix_scale.xyz.y + pnt->y; v[0].z = pnt->z; v[0].sw = 0.0f; v[0].u = 0.0f; v[0].v = 1.0f; - v[1].x = (width*ca + height*sa)*Matrix_scale.x + pnt->x; - v[1].y = (width*sa - height*ca)*Matrix_scale.y + pnt->y; + v[1].x = (width*ca + height*sa)*Matrix_scale.xyz.x + pnt->x; + v[1].y = (width*sa - height*ca)*Matrix_scale.xyz.y + pnt->y; v[1].z = pnt->z; v[1].sw = 0.0f; v[1].u = 1.0f; v[1].v = 1.0f; - v[2].x = (width*ca - height*sa)*Matrix_scale.x + pnt->x; - v[2].y = (width*sa + height*ca)*Matrix_scale.y + pnt->y; + v[2].x = (width*ca - height*sa)*Matrix_scale.xyz.x + pnt->x; + v[2].y = (width*sa + height*ca)*Matrix_scale.xyz.y + pnt->y; v[2].z = pnt->z; v[2].sw = 0.0f; v[2].u = 1.0f; v[2].v = 0.0f; - v[3].x = (-width*ca - height*sa)*Matrix_scale.x + pnt->x; - v[3].y = (-width*sa + height*ca)*Matrix_scale.y + pnt->y; + v[3].x = (-width*ca - height*sa)*Matrix_scale.xyz.x + pnt->x; + v[3].y = (-width*sa + height*ca)*Matrix_scale.xyz.y + pnt->y; v[3].z = pnt->z; v[3].sw = 0.0f; v[3].u = 0.0f; @@ -1021,7 +1024,7 @@ void g3_draw_horizon_line() // if ( View_matrix.uvec.y < 0.0f ) // color_swap = 1; // else if ( View_matrix.uvec.y == 0.0f ) { -// if ( View_matrix.uvec.x > 0.0f ) +// if ( View_matrix.uvec.xyz.x > 0.0f ) // color_swap = 1; // } @@ -1038,15 +1041,15 @@ void g3_draw_horizon_line() //compute horizon_vector - horizon_vec.x = Unscaled_matrix.rvec.y*Matrix_scale.y*Matrix_scale.z; - horizon_vec.y = Unscaled_matrix.uvec.y*Matrix_scale.x*Matrix_scale.z; - horizon_vec.z = Unscaled_matrix.fvec.y*Matrix_scale.x*Matrix_scale.y; + horizon_vec.xyz.x = Unscaled_matrix.v.rvec.xyz.y*Matrix_scale.xyz.y*Matrix_scale.xyz.z; + horizon_vec.xyz.y = Unscaled_matrix.v.uvec.xyz.y*Matrix_scale.xyz.x*Matrix_scale.xyz.z; + horizon_vec.xyz.z = Unscaled_matrix.v.fvec.xyz.y*Matrix_scale.xyz.x*Matrix_scale.xyz.y; // now compute values & flag for 4 corners. - up_right = horizon_vec.x + horizon_vec.y + horizon_vec.z; - down_right = horizon_vec.x - horizon_vec.y + horizon_vec.z; - down_left = -horizon_vec.x - horizon_vec.y + horizon_vec.z; - up_left = -horizon_vec.x + horizon_vec.y + horizon_vec.z; + up_right = horizon_vec.xyz.x + horizon_vec.xyz.y + horizon_vec.xyz.z; + down_right = horizon_vec.xyz.x - horizon_vec.xyz.y + horizon_vec.xyz.z; + down_left = -horizon_vec.xyz.x - horizon_vec.xyz.y + horizon_vec.xyz.z; + up_left = -horizon_vec.xyz.x + horizon_vec.xyz.y + horizon_vec.xyz.z; //check flags for all sky or all ground. if ( (up_right<0.0f)&&(down_right<0.0f)&&(down_left<0.0f)&&(up_left<0.0f) ) { @@ -1072,7 +1075,7 @@ void g3_draw_horizon_line() s2 = down_left > 0.0f; if ( s1 != s2 ) { horz_pts[cpnt].x = 0.0f; - horz_pts[cpnt].y = fl_abs(up_left * Canv_h2 / horizon_vec.y); + horz_pts[cpnt].y = fl_abs(up_left * Canv_h2 / horizon_vec.xyz.y); horz_pts[cpnt].edge = 0; cpnt++; } @@ -1081,7 +1084,7 @@ void g3_draw_horizon_line() s1 = up_left > 0.0f; s2 = up_right > 0.0f; if ( s1 != s2 ) { - horz_pts[cpnt].x = fl_abs(up_left * Canv_w2 / horizon_vec.x); + horz_pts[cpnt].x = fl_abs(up_left * Canv_w2 / horizon_vec.xyz.x); horz_pts[cpnt].y = 0.0f; horz_pts[cpnt].edge = 1; cpnt++; @@ -1093,7 +1096,7 @@ void g3_draw_horizon_line() s2 = down_right > 0.0f; if ( s1 != s2 ) { horz_pts[cpnt].x = i2fl(Canvas_width)-1; - horz_pts[cpnt].y = fl_abs(up_right * Canv_h2 / horizon_vec.y); + horz_pts[cpnt].y = fl_abs(up_right * Canv_h2 / horizon_vec.xyz.y); horz_pts[cpnt].edge = 2; cpnt++; } @@ -1102,7 +1105,7 @@ void g3_draw_horizon_line() s1 = down_right > 0.0f; s2 = down_left > 0.0f; if ( s1 != s2 ) { - horz_pts[cpnt].x = fl_abs(down_left * Canv_w2 / horizon_vec.x); + horz_pts[cpnt].x = fl_abs(down_left * Canv_w2 / horizon_vec.xyz.x); horz_pts[cpnt].y = i2fl(Canvas_height)-1; horz_pts[cpnt].edge = 3; cpnt++; @@ -1625,9 +1628,9 @@ void stars_project_2d_onto_sphere( vector *pnt, float rho, float phi, float thet float sin_a = (float)sin(a); // coords - pnt->z = rho * sin_a * (float)cos(b); - pnt->y = rho * sin_a * (float)sin(b); - pnt->x = rho * (float)cos(a); + pnt->xyz.z = rho * sin_a * (float)cos(b); + pnt->xyz.y = rho * sin_a * (float)sin(b); + pnt->xyz.x = rho * (float)cos(a); } // draw a perspective bitmap based on angles and radius diff --git a/src/render/3dlaser.cpp b/src/render/3dlaser.cpp index a6d0f41..8cfeb22 100644 --- a/src/render/3dlaser.cpp +++ b/src/render/3dlaser.cpp @@ -15,6 +15,9 @@ * Code to draw 3d looking lasers * * $Log$ + * Revision 1.4 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:25 relnev * added copyright header * @@ -176,11 +179,11 @@ float g3_draw_laser(vector *headp, float head_width, vector *tailp, float tail_w headx = pt1.sx; heady = pt1.sy; - headr = (head_width*Matrix_scale.x*Canv_w2*pt1.sw); + headr = (head_width*Matrix_scale.xyz.x*Canv_w2*pt1.sw); tailx = pt2.sx; taily = pt2.sy; - tailr = (tail_width*Matrix_scale.x*Canv_w2*pt2.sw); + tailr = (tail_width*Matrix_scale.xyz.x*Canv_w2*pt2.sw); float len_2d = fl_sqrt( (tailx-headx)*(tailx-headx) + (taily-heady)*(taily-heady) ); @@ -336,11 +339,11 @@ float g3_draw_laser_rgb(vector *headp, float head_width, vector *tailp, float ta headx = pt1.sx; heady = pt1.sy; - headr = (head_width*Matrix_scale.x*Canv_w2*pt1.sw); + headr = (head_width*Matrix_scale.xyz.x*Canv_w2*pt1.sw); tailx = pt2.sx; taily = pt2.sy; - tailr = (tail_width*Matrix_scale.x*Canv_w2*pt2.sw); + tailr = (tail_width*Matrix_scale.xyz.x*Canv_w2*pt2.sw); float len_2d = fl_sqrt( (tailx-headx)*(tailx-headx) + (taily-heady)*(taily-heady) ); diff --git a/src/render/3dmath.cpp b/src/render/3dmath.cpp index 1f2afa4..1f710d3 100644 --- a/src/render/3dmath.cpp +++ b/src/render/3dmath.cpp @@ -15,6 +15,9 @@ * 3d Math routines used by the Renderer lib * * $Log$ + * Revision 1.3 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:25 relnev * added copyright header * @@ -100,19 +103,19 @@ ubyte g3_code_vector(vector * p) { ubyte cc=0; - if (p->x > p->z) + if (p->xyz.x > p->xyz.z) cc |= CC_OFF_RIGHT; - if (p->y > p->z) + if (p->xyz.y > p->xyz.z) cc |= CC_OFF_TOP; - if (p->x < -p->z) + if (p->xyz.x < -p->xyz.z) cc |= CC_OFF_LEFT; - if (p->y < -p->z) + if (p->xyz.y < -p->xyz.z) cc |= CC_OFF_BOT; - if (p->z < MIN_Z ) + if (p->xyz.z < MIN_Z ) cc |= CC_BEHIND; if ( G3_user_clip ) { @@ -174,21 +177,21 @@ ubyte g3_rotate_vertex(vertex *dest,vector *src) MONITOR_INC( NumRotations, 1 ); - tx = src->x - View_position.x; - ty = src->y - View_position.y; - tz = src->z - View_position.z; + tx = src->xyz.x - View_position.xyz.x; + ty = src->xyz.y - View_position.xyz.y; + tz = src->xyz.z - View_position.xyz.z; - x = tx * View_matrix.rvec.x; - x += ty * View_matrix.rvec.y; - x += tz * View_matrix.rvec.z; + x = tx * View_matrix.v.rvec.xyz.x; + x += ty * View_matrix.v.rvec.xyz.y; + x += tz * View_matrix.v.rvec.xyz.z; - y = tx * View_matrix.uvec.x; - y += ty * View_matrix.uvec.y; - y += tz * View_matrix.uvec.z; + y = tx * View_matrix.v.uvec.xyz.x; + y += ty * View_matrix.v.uvec.xyz.y; + y += tz * View_matrix.v.uvec.xyz.z; - z = tx * View_matrix.fvec.x; - z += ty * View_matrix.fvec.y; - z += tz * View_matrix.fvec.z; + z = tx * View_matrix.v.fvec.xyz.x; + z += ty * View_matrix.v.fvec.xyz.y; + z += tz * View_matrix.v.fvec.xyz.z; codes = 0; @@ -250,12 +253,12 @@ ubyte g3_project_vector(vector *p, float *sx, float *sy ) Assert( G3_count == 1 ); - if ( p->z <= MIN_Z ) return PF_OVERFLOW; + if ( p->xyz.z <= MIN_Z ) return PF_OVERFLOW; - w=1.0f / p->z; + w=1.0f / p->xyz.z; - *sx = (Canvas_width + (p->x*Canvas_width*w))*0.5f; - *sy = (Canvas_height - (p->y*Canvas_height*w))*0.5f; + *sx = (Canvas_width + (p->xyz.x*Canvas_width*w))*0.5f; + *sy = (Canvas_height - (p->xyz.y*Canvas_height*w))*0.5f; return PF_PROJECTED; } @@ -299,12 +302,12 @@ void g3_point_to_vec(vector *v,int sx,int sy) Assert( G3_count == 1 ); - tempv.x = ((float)sx - Canv_w2) / Canv_w2; - tempv.y = -((float)sy - Canv_h2) / Canv_h2; - tempv.z = 1.0f; + tempv.xyz.x = ((float)sx - Canv_w2) / Canv_w2; + tempv.xyz.y = -((float)sy - Canv_h2) / Canv_h2; + tempv.xyz.z = 1.0f; - tempv.x = tempv.x * Matrix_scale.z / Matrix_scale.x; - tempv.y = tempv.y * Matrix_scale.z / Matrix_scale.y; + tempv.xyz.x = tempv.xyz.x * Matrix_scale.xyz.z / Matrix_scale.xyz.x; + tempv.xyz.y = tempv.xyz.y * Matrix_scale.xyz.z / Matrix_scale.xyz.y; vm_vec_normalize(&tempv); vm_vec_unrotate(v, &tempv, &Unscaled_matrix); @@ -317,12 +320,12 @@ void g3_point_to_vec_delayed(vector *v,int sx,int sy) { vector tempv; - tempv.x = ((float)sx - Canv_w2) / Canv_w2; - tempv.y = -((float)sy - Canv_h2) / Canv_h2; - tempv.z = 1.0f; + tempv.xyz.x = ((float)sx - Canv_w2) / Canv_w2; + tempv.xyz.y = -((float)sy - Canv_h2) / Canv_h2; + tempv.xyz.z = 1.0f; - tempv.x = tempv.x * Matrix_scale.z / Matrix_scale.x; - tempv.y = tempv.y * Matrix_scale.z / Matrix_scale.y; + tempv.xyz.x = tempv.xyz.x * Matrix_scale.xyz.z / Matrix_scale.xyz.x; + tempv.xyz.y = tempv.xyz.y * Matrix_scale.xyz.z / Matrix_scale.xyz.y; vm_vec_normalize(&tempv); vm_vec_unrotate(v, &tempv, &Unscaled_matrix); @@ -337,9 +340,9 @@ vector *g3_rotate_delta_vec(vector *dest,vector *src) // vms_vector tempv; // vms_matrix tempm; // -// tempv.x = fixmuldiv(fixdiv((sx<<16) - Canv_w2,Canv_w2),Matrix_scale.z,Matrix_scale.x); -// tempv.y = -fixmuldiv(fixdiv((sy<<16) - Canv_h2,Canv_h2),Matrix_scale.z,Matrix_scale.y); -// tempv.z = f1_0; +// tempv.xyz.x = fixmuldiv(fixdiv((sx<<16) - Canv_w2,Canv_w2),Matrix_scale.xyz.z,Matrix_scale.xyz.x); +// tempv.xyz.y = -fixmuldiv(fixdiv((sy<<16) - Canv_h2,Canv_h2),Matrix_scale.xyz.z,Matrix_scale.xyz.y); +// tempv.xyz.z = f1_0; // // vm_vec_normalize(&tempv); // @@ -355,9 +358,9 @@ void g3_point_2_vec(vector *v,int sx,int sy) vector tempv; matrix tempm; - tempv.x = fixmuldiv(fixdiv((sx<<16) - Canv_w2,Canv_w2),Matrix_scale.z,Matrix_scale.x); - tempv.y = -fixmuldiv(fixdiv((sy<<16) - Canv_h2,Canv_h2),Matrix_scale.z,Matrix_scale.y); - tempv.z = f1_0; + tempv.xyz.x = fixmuldiv(fixdiv((sx<<16) - Canv_w2,Canv_w2),Matrix_scale.xyz.z,Matrix_scale.xyz.x); + tempv.xyz.y = -fixmuldiv(fixdiv((sy<<16) - Canv_h2,Canv_h2),Matrix_scale.xyz.z,Matrix_scale.xyz.y); + tempv.xyz.z = f1_0; vm_vec_normalize(&tempv); @@ -370,27 +373,27 @@ void g3_point_2_vec(vector *v,int sx,int sy) //delta rotation functions vms_vector *g3_rotate_delta_x(vms_vector *dest,fix dx) { - dest->x = fixmul(View_matrix.rvec.x,dx); - dest->y = fixmul(View_matrix.uvec.x,dx); - dest->z = fixmul(View_matrix.fvec.x,dx); + dest->x = fixmul(View_matrix.v.rvec.xyz.x,dx); + dest->y = fixmul(View_matrix.v.uvec.xyz.x,dx); + dest->z = fixmul(View_matrix.v.fvec.xyz.x,dx); return dest; } vms_vector *g3_rotate_delta_y(vms_vector *dest,fix dy) { - dest->x = fixmul(View_matrix.rvec.y,dy); - dest->y = fixmul(View_matrix.uvec.y,dy); - dest->z = fixmul(View_matrix.fvec.y,dy); + dest->x = fixmul(View_matrix.v.rvec.xyz.y,dy); + dest->y = fixmul(View_matrix.v.uvec.xyz.y,dy); + dest->z = fixmul(View_matrix.v.fvec.xyz.y,dy); return dest; } vms_vector *g3_rotate_delta_z(vms_vector *dest,fix dz) { - dest->x = fixmul(View_matrix.rvec.z,dz); - dest->y = fixmul(View_matrix.uvec.z,dz); - dest->z = fixmul(View_matrix.fvec.z,dz); + dest->x = fixmul(View_matrix.v.rvec.xyz.z,dz); + dest->y = fixmul(View_matrix.v.uvec.xyz.z,dz); + dest->z = fixmul(View_matrix.v.fvec.xyz.z,dz); return dest; } @@ -412,9 +415,9 @@ float g3_calc_point_depth(vector *pnt) { float q; - q = (pnt->x - View_position.x) * View_matrix.fvec.x; - q += (pnt->y - View_position.y) * View_matrix.fvec.y; - q += (pnt->z - View_position.z) * View_matrix.fvec.z; + q = (pnt->xyz.x - View_position.xyz.x) * View_matrix.v.fvec.xyz.x; + q += (pnt->xyz.y - View_position.xyz.y) * View_matrix.v.fvec.xyz.y; + q += (pnt->xyz.z - View_position.xyz.z) * View_matrix.v.fvec.xyz.z; return q; } diff --git a/src/render/3dsetup.cpp b/src/render/3dsetup.cpp index a4972d5..fb09a4e 100644 --- a/src/render/3dsetup.cpp +++ b/src/render/3dsetup.cpp @@ -15,6 +15,9 @@ * Code to setup matrix instancing and viewers * * $Log$ + * Revision 1.3 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.2 2002/06/09 04:41:25 relnev * added copyright header * @@ -169,15 +172,15 @@ void g3_start_frame_func(int zbuffer_flag, char * filename, int lineno) s = aspect*(float)Canvas_height/(float)Canvas_width; if (s <= 0) { //scale x - Window_scale.x = s; - Window_scale.y = 1.0f; + Window_scale.xyz.x = s; + Window_scale.xyz.y = 1.0f; } else { - Window_scale.y = 1.0f / s; - Window_scale.x = 1.0f; + Window_scale.xyz.y = 1.0f / s; + Window_scale.xyz.x = 1.0f; } - Window_scale.z = 1.0f; //always 1 + Window_scale.xyz.z = 1.0f; //always 1 init_free_points(); @@ -222,9 +225,9 @@ void g3_set_view_matrix(vector *view_pos,matrix *view_matrix,float zoom) scale_matrix(); Light_matrix = vmd_identity_matrix; - Light_base.x = 0.0f; - Light_base.y = 0.0f; - Light_base.z = 0.0f; + Light_base.xyz.x = 0.0f; + Light_base.xyz.y = 0.0f; + Light_base.xyz.z = 0.0f; } @@ -250,22 +253,21 @@ void scale_matrix(void) if (View_zoom <= 1.0) //zoom in by scaling z - Matrix_scale.z = Matrix_scale.z*View_zoom; + Matrix_scale.xyz.z = Matrix_scale.xyz.z*View_zoom; else { //zoom out by scaling x&y float s = (float)1.0 / View_zoom; - Matrix_scale.x = Matrix_scale.x*s; - Matrix_scale.y = Matrix_scale.y*s; + Matrix_scale.xyz.x = Matrix_scale.xyz.x*s; + Matrix_scale.xyz.y = Matrix_scale.xyz.y*s; } //now scale matrix elements - vm_vec_scale(&View_matrix.rvec,Matrix_scale.x); - vm_vec_scale(&View_matrix.uvec,Matrix_scale.y); - vm_vec_scale(&View_matrix.fvec,Matrix_scale.z); - + vm_vec_scale(&View_matrix.v.rvec,Matrix_scale.xyz.x); + vm_vec_scale(&View_matrix.v.uvec,Matrix_scale.xyz.y); + vm_vec_scale(&View_matrix.v.fvec,Matrix_scale.xyz.z); } ubyte g3_rotate_vertex_popped(vertex *dest,vector *src) diff --git a/src/ship/aibig.cpp b/src/ship/aibig.cpp index c883d7d..14becc7 100644 --- a/src/ship/aibig.cpp +++ b/src/ship/aibig.cpp @@ -15,6 +15,9 @@ * C module for AI code related to large ships * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:26 relnev * added copyright header * @@ -601,7 +604,7 @@ void ai_big_pick_attack_point(object *objp, object *attacker_objp, vector *attac // checks valid line to target vector surface_normal; - ai_bpap(objp, &attacker_objp->pos, &attacker_objp->orient.fvec, attack_point, &local_attack_point, fov, 99999.9f, &surface_normal); + ai_bpap(objp, &attacker_objp->pos, &attacker_objp->orient.v.fvec, attack_point, &local_attack_point, fov, 99999.9f, &surface_normal); switch (attacker_objp->type) { case OBJ_SHIP: { @@ -887,9 +890,9 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vector *enemy_pos, float float dist; vm_vec_sub(&in_vec, &objp->pos, &Pl_objp->pos); - if (vm_vec_dot(&in_vec, &objp->orient.fvec) > 0.0f) { + if (vm_vec_dot(&in_vec, &objp->orient.v.fvec) > 0.0f) { dist = vm_vec_normalize(&in_vec); - if ((dist < 200.0f) && (vm_vec_dot(&in_vec, &objp->orient.fvec) > 0.95f)) { + if ((dist < 200.0f) && (vm_vec_dot(&in_vec, &objp->orient.v.fvec) > 0.95f)) { if ((Objects[objp->parent].signature == objp->parent_sig) && (vm_vec_dist_quick(&objp->pos, &Objects[objp->parent].pos) < 300.0f)) { set_target_objnum(aip, objp->parent); aip->submode = SM_ATTACK; @@ -933,7 +936,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vector *enemy_pos, float rel_pos = NULL; dist_to_enemy = vm_vec_normalized_dir(&vec_to_enemy, enemy_pos, &Pl_objp->pos); - dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.fvec); + dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.v.fvec); vector rvec_vec, *rvec = &rvec_vec; @@ -1135,7 +1138,7 @@ void ai_big_chase() } dist_to_enemy = vm_vec_normalized_dir(&vec_to_enemy, &enemy_pos, &player_pos); // - En_objp->radius; - dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.fvec); + dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.v.fvec); if (aip->ai_flags & AIF_TARGET_COLLISION) { if ( ai_big_strafe_maybe_retreat(dist_to_enemy, &enemy_pos) ) { @@ -1164,7 +1167,7 @@ void ai_big_chase() vm_vec_add2(&enemy_pos, &predicted_enemy_pos); vm_vec_sub2(&enemy_pos, &En_objp->pos); dist_to_enemy = vm_vec_normalized_dir(&vec_to_enemy, &enemy_pos, &player_pos); // - En_objp->radius; - dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.fvec); + dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.v.fvec); update_aspect_lock_information(aip, &vec_to_enemy, dist_to_enemy, En_objp->radius); } else if (En_objp->flags & OF_PROTECTED) { // If protected and we're not attacking a subsystem, stop attacking! update_aspect_lock_information(aip, &vec_to_enemy, dist_to_enemy - En_objp->radius, En_objp->radius); @@ -1428,12 +1431,12 @@ void ai_big_attack_get_data(vector *enemy_pos, float *dist_to_enemy, float *dot_ } // Take player pos to be center of ship + ship_radius - vm_vec_scale_add2(&player_pos, &Pl_objp->orient.fvec, Pl_objp->radius); + vm_vec_scale_add2(&player_pos, &Pl_objp->orient.v.fvec, Pl_objp->radius); // If seeking lock, try to point directly at ship, else predict position so lasers can hit it. // If just acquired target, or target is not in reasonable cone, don't refine believed enemy position. vm_vec_normalized_dir(&vec_to_enemy, enemy_pos, &player_pos); - *dot_to_enemy=vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.fvec); + *dot_to_enemy=vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.v.fvec); if ((*dot_to_enemy < 0.25f) || (aip->target_time < 1.0f) || (aip->ai_flags & AIF_SEEK_LOCK)) { predicted_enemy_pos=*enemy_pos; } else { @@ -1451,7 +1454,7 @@ void ai_big_attack_get_data(vector *enemy_pos, float *dist_to_enemy, float *dot_ } *dist_to_enemy = vm_vec_normalized_dir(&vec_to_enemy, &predicted_enemy_pos, &player_pos); - *dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.fvec); + *dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.v.fvec); update_aspect_lock_information(aip, &vec_to_enemy, *dist_to_enemy, En_objp->radius); *enemy_pos = predicted_enemy_pos; @@ -1556,16 +1559,16 @@ void ai_big_strafe_attack() aip->goal_point = Pl_objp->pos; switch(rand()%4) { case 0: - vm_vec_scale_add(&rand_vec, &Pl_objp->orient.fvec, &Pl_objp->orient.uvec, 2.0f); + vm_vec_scale_add(&rand_vec, &Pl_objp->orient.v.fvec, &Pl_objp->orient.v.uvec, 2.0f); break; case 1: - vm_vec_scale_add(&rand_vec, &Pl_objp->orient.fvec, &Pl_objp->orient.uvec, -2.0f); + vm_vec_scale_add(&rand_vec, &Pl_objp->orient.v.fvec, &Pl_objp->orient.v.uvec, -2.0f); break; case 2: - vm_vec_scale_add(&rand_vec, &Pl_objp->orient.fvec, &Pl_objp->orient.rvec, 2.0f); + vm_vec_scale_add(&rand_vec, &Pl_objp->orient.v.fvec, &Pl_objp->orient.v.rvec, 2.0f); break; case 3: - vm_vec_scale_add(&rand_vec, &Pl_objp->orient.fvec, &Pl_objp->orient.rvec, -2.0f); + vm_vec_scale_add(&rand_vec, &Pl_objp->orient.v.fvec, &Pl_objp->orient.v.rvec, -2.0f); break; } // end switch @@ -1666,16 +1669,16 @@ void ai_big_strafe_retreat1() aip->prev_goal_point = Pl_objp->pos; switch(rand()%4) { case 0: - vm_vec_add(&rand_vec, &Pl_objp->orient.fvec, &Pl_objp->orient.uvec); + vm_vec_add(&rand_vec, &Pl_objp->orient.v.fvec, &Pl_objp->orient.v.uvec); break; case 1: - vm_vec_scale_add(&rand_vec, &Pl_objp->orient.fvec, &Pl_objp->orient.uvec, -1.0f); + vm_vec_scale_add(&rand_vec, &Pl_objp->orient.v.fvec, &Pl_objp->orient.v.uvec, -1.0f); break; case 2: - vm_vec_add(&rand_vec, &Pl_objp->orient.fvec, &Pl_objp->orient.rvec); + vm_vec_add(&rand_vec, &Pl_objp->orient.v.fvec, &Pl_objp->orient.v.rvec); break; case 3: - vm_vec_scale_add(&rand_vec, &Pl_objp->orient.fvec, &Pl_objp->orient.rvec, -1.0f); + vm_vec_scale_add(&rand_vec, &Pl_objp->orient.v.fvec, &Pl_objp->orient.v.rvec, -1.0f); break; } // end switch diff --git a/src/ship/aicode.cpp b/src/ship/aicode.cpp index 109fbd6..b3dca38 100644 --- a/src/ship/aicode.cpp +++ b/src/ship/aicode.cpp @@ -15,6 +15,9 @@ * AI code that does interesting stuff * * $Log$ + * Revision 1.5 2002/06/17 06:33:10 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:26 relnev * added copyright header * @@ -1221,7 +1224,7 @@ int ai_is_stealth_visible(object *viewer_objp, object *stealth_objp) if ( !ship_is_visible_by_team(stealth_objp->instance, Ships[viewer_objp->instance].team) ) { vm_vec_sub(&vec_to_stealth, &stealth_objp->pos, &viewer_objp->pos); dist_to_stealth = vm_vec_mag_quick(&vec_to_stealth); - dot_to_stealth = vm_vec_dotprod(&viewer_objp->orient.fvec, &vec_to_stealth) / dist_to_stealth; + dot_to_stealth = vm_vec_dotprod(&viewer_objp->orient.v.fvec, &vec_to_stealth) / dist_to_stealth; // get max dist at which stealth is visible max_stealth_dist = get_skill_stealth_dist_scaler() * STEALTH_MAX_VIEW_DIST; @@ -1260,10 +1263,10 @@ float compute_dots(object *objp, object *other_objp, float *to_dot, float *from_ dist = vm_vec_normalized_dir(&v2o, &other_objp->pos, &objp->pos); - *to_dot = vm_vec_dot(&objp->orient.fvec, &v2o); + *to_dot = vm_vec_dot(&objp->orient.v.fvec, &v2o); if (from_dot != NULL) - *from_dot = - vm_vec_dot(&other_objp->orient.fvec, &v2o); + *from_dot = - vm_vec_dot(&other_objp->orient.v.fvec, &v2o); return dist; } @@ -1313,7 +1316,7 @@ void update_ai_stealth_info_with_error(ai_info *aip/*, int no_error*/) // find vec_to_stealth and dist vm_vec_sub(&vec_to_stealth, &stealth_objp->pos, &ship->pos); dist_to_stealth = vm_vec_normalize_quick(&vec_to_stealth); - dot_to_stealth = vm_vec_dotprod(&vec_to_stealth, &ship->orient.fvec); + dot_to_stealth = vm_vec_dotprod(&vec_to_stealth, &ship->orient.v.fvec); // put cap on time delta_capped = delta_time; @@ -1471,9 +1474,9 @@ void ai_turn_towards_vector(vector *dest, object *objp, } // Set max turn rate. - vel_limit.x = 2*PI/turn_time; - vel_limit.y = 2*PI/turn_time; - vel_limit.z = 2*PI/turn_time; + vel_limit.xyz.x = 2*PI/turn_time; + vel_limit.xyz.y = 2*PI/turn_time; + vel_limit.xyz.z = 2*PI/turn_time; // Set rate at which ship can accelerate to its rotational velocity. // For now, weapons just go much faster. @@ -1506,9 +1509,9 @@ void ai_turn_towards_vector(vector *dest, object *objp, delta_bank = bank_override; //nprintf(("AI", "%i: %7.3f\n", Framecount, bank_override)); } else { - delta_bank = vm_vec_dot(&curr_orient.rvec, &objp->last_orient.rvec); + delta_bank = vm_vec_dot(&curr_orient.v.rvec, &objp->last_orient.v.rvec); delta_bank = 100.0f * (1.0f - delta_bank); - if (vm_vec_dot(&objp->last_orient.fvec, &objp->orient.rvec) < 0.0f) + if (vm_vec_dot(&objp->last_orient.v.fvec, &objp->orient.v.rvec) < 0.0f) delta_bank = -delta_bank; //nprintf(("AI", "%s: Frame %i: delta bank = %7.3f\n", Ships[objp->instance].ship_name, Framecount, delta_bank)); @@ -1520,7 +1523,7 @@ void ai_turn_towards_vector(vector *dest, object *objp, // This will allow you to rerun vm_forward_interpolate() with the values that caused the error. // Note, you'll need to enable the Int3() about ten lines below. #ifndef NDEBUG -vector tvec = objp->orient.fvec; +vector tvec = objp->orient.v.fvec; vector vel_in_copy; matrix objp_orient_copy; @@ -1541,7 +1544,7 @@ objp->orient = objp_orient_copy; } #ifndef NDEBUG if (!((objp->type == OBJ_WEAPON) && (Weapon_info[Weapons[objp->instance].weapon_info_index].subtype == WP_MISSILE))) { - if (delta_time < 0.25f && vm_vec_dot(&objp->orient.fvec, &tvec) < 0.1f) + if (delta_time < 0.25f && vm_vec_dot(&objp->orient.v.fvec, &tvec) < 0.1f) Int3(); // Get Andsager. A ship has turned too far in one frame. } #endif @@ -1558,7 +1561,7 @@ void init_ship_info() for (i=0; iinstance].ai_index]; - // check if in formation and if not leader, don't change rotvel.z (bank to match leader elsewhere) + // check if in formation and if not leader, don't change rotvel.xyz.z (bank to match leader elsewhere) if (aip->ai_flags & AIF_FORMATION) { if (&Objects[aip->goal_objnum] != objp) { - float rotvel_z = objp->phys_info.rotvel.z; + float rotvel_z = objp->phys_info.rotvel.xyz.z; ai_turn_towards_vector(point, objp, flFrametime, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, slide_vec, NULL, bank_override, 0); - objp->phys_info.rotvel.z = rotvel_z; + objp->phys_info.rotvel.xyz.z = rotvel_z; } } else { // normal turn @@ -1871,11 +1874,11 @@ float turn_towards_tangent(object *objp, vector *point, float radius) vector up_vec, perp_vec; vm_vec_normalized_dir(&vec_to_point, point, &objp->pos); - vm_vec_crossprod(&up_vec, &vec_to_point, &objp->orient.fvec); + vm_vec_crossprod(&up_vec, &vec_to_point, &objp->orient.v.fvec); vm_vec_crossprod(&perp_vec, &vec_to_point, &up_vec); vm_vec_scale_add(&perp_point, point, &vec_to_point, -radius); - if (vm_vec_dot(&objp->orient.fvec, &perp_vec) > 0.0f) { + if (vm_vec_dot(&objp->orient.v.fvec, &perp_vec) > 0.0f) { vm_vec_scale_add(&goal_point, &perp_point, &perp_vec, radius); } else { vm_vec_scale_add(&goal_point, &perp_point, &perp_vec, -radius); @@ -1887,7 +1890,7 @@ float turn_towards_tangent(object *objp, vector *point, float radius) vector v2g; vm_vec_normalized_dir(&v2g, &goal_point, &objp->pos); - return vm_vec_dot(&objp->orient.fvec, &v2g); + return vm_vec_dot(&objp->orient.v.fvec, &v2g); } float turn_toward_tangent_with_axis(object *objp, object *center_objp, float radius) @@ -1898,19 +1901,19 @@ float turn_toward_tangent_with_axis(object *objp, object *center_objp, float rad // find closest z of center objp vm_vec_sub(&sph_r_vec, &objp->pos, ¢er_objp->pos); - center_obj_z = vm_vec_dotprod(&sph_r_vec, ¢er_objp->orient.fvec); + center_obj_z = vm_vec_dotprod(&sph_r_vec, ¢er_objp->orient.v.fvec); // find pt on axis with closest z - vm_vec_scale_add(¢er_vec, ¢er_objp->pos, ¢er_objp->orient.fvec, center_obj_z); + vm_vec_scale_add(¢er_vec, ¢er_objp->pos, ¢er_objp->orient.v.fvec, center_obj_z); // get r_vec vm_vec_sub(&r_vec, &objp->pos, ¢er_vec); // float r_mag = vm_vec_normalize_quick(&r_vec); // mprintf(("cur_r: %.1f, desired_r: %.1f\n", r_mag, radius)); - Assert( (vm_vec_dotprod(&r_vec, ¢er_objp->orient.fvec) < 0.0001)); + Assert( (vm_vec_dotprod(&r_vec, ¢er_objp->orient.v.fvec) < 0.0001)); // get theta vec - perp to r_vec and z_vec - vm_vec_crossprod(&theta_vec, ¢er_objp->orient.fvec, &r_vec); + vm_vec_crossprod(&theta_vec, ¢er_objp->orient.v.fvec, &r_vec); #ifndef NDEBUG float mag = vm_vec_normalize(&theta_vec); @@ -1921,7 +1924,7 @@ float turn_toward_tangent_with_axis(object *objp, object *center_objp, float rad vm_vec_crossprod(&temp, &r_vec, &theta_vec); #ifndef NDEBUG - float dot = vm_vec_dotprod(&temp, ¢er_objp->orient.fvec); + float dot = vm_vec_dotprod(&temp, ¢er_objp->orient.v.fvec); Assert( dot >0.9999 && dot < 1.0001); #endif @@ -1935,7 +1938,7 @@ float turn_toward_tangent_with_axis(object *objp, object *center_objp, float rad turn_towards_point(objp, &goal_pt, NULL, 0.0f); vm_vec_normalized_dir(&v2g, &goal_pt, &objp->pos); - return vm_vec_dot(&objp->orient.fvec, &v2g); + return vm_vec_dot(&objp->orient.v.fvec, &v2g); } // Returns a point radius units away from *point that *objp should turn towards to orbit *point @@ -1946,13 +1949,13 @@ void get_tangent_point(vector *goal_point, object *objp, vector *point, float ra vector up_vec, perp_vec; vm_vec_normalized_dir(&vec_to_point, point, &objp->pos); - vm_vec_crossprod(&up_vec, &vec_to_point, &objp->orient.fvec); + vm_vec_crossprod(&up_vec, &vec_to_point, &objp->orient.v.fvec); vm_vec_crossprod(&perp_vec, &vec_to_point, &up_vec); vm_vec_normalize(&perp_vec); vm_vec_scale_add(&perp_point, point, &vec_to_point, -radius); - if (vm_vec_dot(&objp->orient.fvec, &perp_vec) > 0.0f) { + if (vm_vec_dot(&objp->orient.v.fvec, &perp_vec) > 0.0f) { vm_vec_scale_add(goal_point, &perp_point, &perp_vec, radius); } else { vm_vec_scale_add(goal_point, &perp_point, &perp_vec, -radius); @@ -2546,7 +2549,7 @@ int bomb_headed_towards_ship(object *bomb_objp, object *ship_objp) vector bomb_to_ship_vector; vm_vec_normalized_dir(&bomb_to_ship_vector, &ship_objp->pos, &bomb_objp->pos); - dot = vm_vec_dot(&bomb_objp->orient.fvec, &bomb_to_ship_vector); + dot = vm_vec_dot(&bomb_objp->orient.v.fvec, &bomb_to_ship_vector); if ( dot > 0 ) { return 1; @@ -3253,10 +3256,10 @@ void bisect_chord(vector *p0, vector *p1, vector *centerp, float radius) vm_vec_sub2(&tvec, centerp); if (vm_vec_mag_quick(&tvec) < 0.1f) { vm_vec_sub(&tvec, p0, p1); - if (fl_abs(tvec.x) <= fl_abs(tvec.z)){ - tvec.x = -tvec.z; + if (fl_abs(tvec.xyz.x) <= fl_abs(tvec.xyz.z)){ + tvec.xyz.x = -tvec.xyz.z; } else { - tvec.y = -tvec.x; + tvec.xyz.y = -tvec.xyz.x; } } @@ -3602,8 +3605,8 @@ int maybe_avoid_player(object *objp, vector *goal_pos) vm_vec_sub(&avoid_vec, &n_vec_to_goal, &n_vec_to_player); if (vm_vec_mag_quick(&avoid_vec) < 0.01f) { - vm_vec_copy_scale(&avoid_vec, &objp->orient.rvec, frand()-0.5f); - vm_vec_scale_add2(&avoid_vec, &objp->orient.uvec, frand()-0.5f); + vm_vec_copy_scale(&avoid_vec, &objp->orient.v.rvec, frand()-0.5f); + vm_vec_scale_add2(&avoid_vec, &objp->orient.v.uvec, frand()-0.5f); vm_vec_normalize(&avoid_vec); } else { vector tvec1; @@ -3648,7 +3651,7 @@ void ai_stay_still(object *still_objp, vector *view_pos) if (view_pos != NULL) aip->goal_point = *view_pos; else - vm_vec_scale_add(&aip->goal_point, &still_objp->pos, &still_objp->orient.fvec, 100.0f); + vm_vec_scale_add(&aip->goal_point, &still_objp->pos, &still_objp->orient.v.fvec, 100.0f); } // code which is called from ai_dock_with_object and ai_dock to set flags and apprioriate variable @@ -4005,7 +4008,7 @@ void fds_aux(float *dot, float *tts, vector *pos, float dtime, object *objp) vector v2s; vm_vec_sub(&v2s, pos, &objp->pos); - *dot = vm_vec_dot(&v2s, &objp->orient.fvec); + *dot = vm_vec_dot(&v2s, &objp->orient.v.fvec); if (*dot > 0.0f) { float dist; @@ -4046,7 +4049,7 @@ int find_danger_weapon(object *sobjp, float dtime, float *atime, float dot_thres vector v2e; vm_vec_normalized_dir(&v2e, &objp->pos, &sobjp->pos); -// dot_from_sobjp = vm_vec_dot(&sobjp->orient.fvec, &v2e); +// dot_from_sobjp = vm_vec_dot(&sobjp->orient.v.fvec, &v2e); // if (dot_from_sobjp >= dot_threshhold) if (tts < dtime) { if (tts < best_tts) { @@ -4104,7 +4107,7 @@ int find_nearest_waypoint(object *objp) for (i=0; icount; i++) { dist = vm_vec_dist_quick(&objp->pos, &wpl->waypoints[i]); - dot = vm_vec_dot_to_point(&objp->orient.fvec, &objp->pos, &wpl->waypoints[i]); + dot = vm_vec_dot_to_point(&objp->orient.v.fvec, &objp->pos, &wpl->waypoints[i]); dist = (float) (dist * (1.25 - dot)); if (dist < min_dist) { min_dist = dist; @@ -4188,9 +4191,9 @@ float ai_matrix_dist(matrix *mat1, matrix *mat2) { float t; - t = 1.0f - vm_vec_dot(&mat1->fvec, &mat2->fvec); - t += 1.0f - vm_vec_dot(&mat1->uvec, &mat2->uvec); - t += 1.0f - vm_vec_dot(&mat1->rvec, &mat2->rvec); + t = 1.0f - vm_vec_dot(&mat1->v.fvec, &mat2->v.fvec); + t += 1.0f - vm_vec_dot(&mat1->v.uvec, &mat2->v.uvec); + t += 1.0f - vm_vec_dot(&mat1->v.rvec, &mat2->v.rvec); return t; } @@ -4443,13 +4446,13 @@ float ai_path() // point at goal. slop_vec = NULL; if (mag < 1.0f) - nvel_vec = Pl_objp->orient.fvec; + nvel_vec = Pl_objp->orient.v.fvec; else if (mag > 5.0f) { float nv_dot; - nv_dot = vm_vec_dot(&Pl_objp->orient.fvec, &nvel_vec); + nv_dot = vm_vec_dot(&Pl_objp->orient.v.fvec, &nvel_vec); if ((nv_dot > 0.5f) && (nv_dot < 0.97f)) { slop_vec = &temp_vec; - vm_vec_sub(slop_vec, &nvel_vec, &Pl_objp->orient.fvec); + vm_vec_sub(slop_vec, &nvel_vec, &Pl_objp->orient.v.fvec); } } @@ -4524,9 +4527,9 @@ int get_enemy_team_range(object *my_objp, float range, int enemy_team_mask, vect *max_vec = objp->pos; count++; } else { - update_min_max(objp->pos.x, &min_vec->x, &max_vec->x); - update_min_max(objp->pos.y, &min_vec->y, &max_vec->y); - update_min_max(objp->pos.z, &min_vec->z, &max_vec->z); + update_min_max(objp->pos.xyz.x, &min_vec->xyz.x, &max_vec->xyz.x); + update_min_max(objp->pos.xyz.y, &min_vec->xyz.y, &max_vec->xyz.y); + update_min_max(objp->pos.xyz.z, &min_vec->xyz.z, &max_vec->xyz.z); } } @@ -4558,7 +4561,7 @@ void ai_safety_pick_spot(object *objp) vm_vec_scale_add(&goal_pos, ¢er, &vec_to_center, 2000.0f); } else - vm_vec_scale_add(&goal_pos, &objp->pos, &objp->orient.fvec, 100.0f); + vm_vec_scale_add(&goal_pos, &objp->pos, &objp->orient.v.fvec, 100.0f); Ai_info[Ships[objp->instance].ai_index].goal_point = goal_pos; } @@ -4577,7 +4580,7 @@ float ai_safety_goto_spot(object *objp) aip = &Ai_info[Ships[objp->instance].ai_index]; dist = vm_vec_normalized_dir(&vec_to_goal, &aip->goal_point, &objp->pos); - dot = vm_vec_dot(&vec_to_goal, &objp->orient.fvec); + dot = vm_vec_dot(&vec_to_goal, &objp->orient.v.fvec); dot_val = (1.1f + dot) / 2.0f; if (dist > 200.0f) { @@ -4602,7 +4605,7 @@ void ai_safety_circle_spot(object *objp) set_accel_for_target_speed(objp, 0.5f * (1.0f + dot) * sip->max_speed/4.0f); // float dist = vm_vec_dist_quick(&goal_point, &Pl_objp->pos); -// nprintf(("AI", "Ship %s circling %7.3f %7.3f %7.3f. Distance = %7.3f\n", Ships[Pl_objp->instance].ship_name, goal_point.x, goal_point.y, goal_point.z, dist)); +// nprintf(("AI", "Ship %s circling %7.3f %7.3f %7.3f. Distance = %7.3f\n", Ships[Pl_objp->instance].ship_name, goal_point.xyz.x, goal_point.xyz.y, goal_point.xyz.z, dist)); } @@ -4691,13 +4694,13 @@ void ai_waypoints() // point at goal. slop_vec = NULL; if (mag < 1.0f) { - nvel_vec = Pl_objp->orient.fvec; + nvel_vec = Pl_objp->orient.v.fvec; } else if (mag > 5.0f) { float nv_dot; - nv_dot = vm_vec_dot(&Pl_objp->orient.fvec, &nvel_vec); + nv_dot = vm_vec_dot(&Pl_objp->orient.v.fvec, &nvel_vec); if ((nv_dot > 0.5f) && (nv_dot < 0.97f)) { slop_vec = &temp_vec; - vm_vec_sub(slop_vec, &nvel_vec, &Pl_objp->orient.fvec); + vm_vec_sub(slop_vec, &nvel_vec, &Pl_objp->orient.v.fvec); } } @@ -4733,7 +4736,7 @@ void ai_waypoints() // We are further from pointing at our goal this frame than last frame, so slow down. set_accel_for_target_speed(Pl_objp, Pl_objp->phys_info.speed * 0.95f); } else if (dist_to_goal < 100.0f) { - float slew_dot = vm_vec_dot(&Pl_objp->orient.fvec, &nvel_vec); + float slew_dot = vm_vec_dot(&Pl_objp->orient.v.fvec, &nvel_vec); if (fl_abs(slew_dot) < 0.9f) { accelerate_ship(aip, 0.0f); } else if (dot < 0.88f + 0.1f*(100.0f - dist_to_goal)/100.0f) { @@ -4855,7 +4858,7 @@ void avoid_ship() // If inside sphere, zero speed and turn towards outside. // If outside sphere, inside 2x sphere, set speed percent of max to: // max(away_dot, (dist-rad)/rad) - // where away_dot is dot(Pl_objp->fvec, vec_En_objp_to_Pl_objp) + // where away_dot is dot(Pl_objp->v.fvec, vec_En_objp_to_Pl_objp) vector vec_to_enemy; float away_dot; @@ -4874,15 +4877,15 @@ void avoid_ship() vm_vec_sub(&vec_to_enemy, &enemy_pos, &Pl_objp->pos); dist = vm_vec_normalize(&vec_to_enemy); - away_dot = -vm_vec_dot(&Pl_objp->orient.fvec, &vec_to_enemy); + away_dot = -vm_vec_dot(&Pl_objp->orient.v.fvec, &vec_to_enemy); - if ((sip->max_vel.x > 0.0f) || (sip->max_vel.y > 0.0f)) { - if (vm_vec_dot(&Pl_objp->orient.rvec, &vec_to_enemy) > 0.0f) { + if ((sip->max_vel.xyz.x > 0.0f) || (sip->max_vel.xyz.y > 0.0f)) { + if (vm_vec_dot(&Pl_objp->orient.v.rvec, &vec_to_enemy) > 0.0f) { AI_ci.sideways = -1.0f; } else { AI_ci.sideways = 1.0f; } - if (vm_vec_dot(&Pl_objp->orient.uvec, &vec_to_enemy) > 0.0f) { + if (vm_vec_dot(&Pl_objp->orient.v.uvec, &vec_to_enemy) > 0.0f) { AI_ci.vertical = -1.0f; } else { AI_ci.vertical = 1.0f; @@ -4899,7 +4902,7 @@ void avoid_ship() } else { vector goal_pos; - vm_vec_scale_add(&goal_pos, &En_objp->pos, &En_objp->orient.fvec, -100.0f); + vm_vec_scale_add(&goal_pos, &En_objp->pos, &En_objp->orient.v.fvec, -100.0f); turn_towards_point(Pl_objp, &goal_pos, NULL, Pl_objp->phys_info.speed); } @@ -5000,7 +5003,7 @@ int ai_maybe_fire_afterburner(object *objp, ai_info *aip) float dot; vm_vec_normalized_dir(&v2p, &Player_obj->pos, &objp->pos); - dot = vm_vec_dot(&v2p, &objp->orient.fvec); + dot = vm_vec_dot(&v2p, &objp->orient.v.fvec); if (dot > 0.0f) { if (dot * dist > 50.0f) @@ -5026,7 +5029,7 @@ void maybe_afterburner_after_ship_hit(object *objp, ai_info *aip, object *en_obj vector v2e; vm_vec_normalized_dir(&v2e, &en_objp->pos, &objp->pos); - if (vm_vec_dot(&v2e, &objp->orient.fvec) > -0.5f) + if (vm_vec_dot(&v2e, &objp->orient.v.fvec) > -0.5f) return; } @@ -5108,8 +5111,8 @@ void evade_weapon() dist = vm_vec_normalized_dir(&vec_from_enemy, &player_pos, &weapon_pos); - dot_to_enemy = -vm_vec_dot(&Pl_objp->orient.fvec, &vec_from_enemy); - dot_from_enemy = vm_vec_dot(&weapon_objp->orient.fvec, &vec_from_enemy); + dot_to_enemy = -vm_vec_dot(&Pl_objp->orient.v.fvec, &vec_from_enemy); + dot_from_enemy = vm_vec_dot(&weapon_objp->orient.v.fvec, &vec_from_enemy); //nprintf(("AI", "dot from enemy = %7.3f\n", dot_from_enemy)); // If shot is incoming... @@ -5133,12 +5136,12 @@ void evade_weapon() float rdot; // Turn hard left or right, depending on which gets out of way quicker. - rdot = vm_vec_dot(&Pl_objp->orient.rvec, &vec_from_enemy); + rdot = vm_vec_dot(&Pl_objp->orient.v.rvec, &vec_from_enemy); if ((rdot < -0.5f) || (rdot > 0.5f)) - vm_vec_scale_add(&goal_point, &Pl_objp->pos, &Pl_objp->orient.rvec, -200.0f); + vm_vec_scale_add(&goal_point, &Pl_objp->pos, &Pl_objp->orient.v.rvec, -200.0f); else - vm_vec_scale_add(&goal_point, &Pl_objp->pos, &Pl_objp->orient.rvec, 200.0f); + vm_vec_scale_add(&goal_point, &Pl_objp->pos, &Pl_objp->orient.v.rvec, 200.0f); turn_towards_point(Pl_objp, &goal_point, NULL, 0.0f); } @@ -5159,7 +5162,7 @@ void slide_face_ship() sip = &Ship_info[Ships[Pl_objp->instance].ship_info_index]; // If can't slide, return. - if ((sip->max_vel.x == 0.0f) && (sip->max_vel.y == 0.0f)) + if ((sip->max_vel.xyz.x == 0.0f) && (sip->max_vel.xyz.y == 0.0f)) return; vector goal_pos; @@ -5175,30 +5178,30 @@ void slide_face_ship() ai_turn_towards_vector(&En_objp->pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0); - dot_from_enemy = vm_vec_dot(&vec_from_enemy, &En_objp->orient.fvec); - dot_to_enemy = -vm_vec_dot(&vec_from_enemy, &Pl_objp->orient.fvec); + dot_from_enemy = vm_vec_dot(&vec_from_enemy, &En_objp->orient.v.fvec); + dot_to_enemy = -vm_vec_dot(&vec_from_enemy, &Pl_objp->orient.v.fvec); - if (vm_vec_dot(&vec_from_enemy, &En_objp->orient.rvec) > 0.0f) + if (vm_vec_dot(&vec_from_enemy, &En_objp->orient.v.rvec) > 0.0f) right = 1.0f; else right = -1.0f; - if (vm_vec_dot(&vec_from_enemy, &En_objp->orient.uvec) > 0.0f) + if (vm_vec_dot(&vec_from_enemy, &En_objp->orient.v.uvec) > 0.0f) up = 1.0f; else up = -1.0f; - vm_vec_scale_add(&goal_pos, &En_objp->pos, &En_objp->orient.rvec, right * 200.0f); - vm_vec_scale_add(&goal_pos, &En_objp->pos, &En_objp->orient.uvec, up * 200.0f); + vm_vec_scale_add(&goal_pos, &En_objp->pos, &En_objp->orient.v.rvec, right * 200.0f); + vm_vec_scale_add(&goal_pos, &En_objp->pos, &En_objp->orient.v.uvec, up * 200.0f); vm_vec_normalized_dir(&vec_to_goal, &goal_pos, &Pl_objp->pos); - if (vm_vec_dot(&vec_to_goal, &Pl_objp->orient.rvec) > 0.0f) + if (vm_vec_dot(&vec_to_goal, &Pl_objp->orient.v.rvec) > 0.0f) AI_ci.sideways = 1.0f; else AI_ci.sideways = -1.0f; - if (vm_vec_dot(&vec_to_goal, &Pl_objp->orient.uvec) > 0.0f) + if (vm_vec_dot(&vec_to_goal, &Pl_objp->orient.v.uvec) > 0.0f) AI_ci.vertical = 1.0f; else AI_ci.vertical = -1.0f; @@ -5257,20 +5260,20 @@ void evade_ship() vm_vec_sub(&vec_from_enemy, &player_pos, &enemy_pos); dist = vm_vec_normalize(&vec_from_enemy); - dot_from_enemy = vm_vec_dot(&En_objp->orient.fvec, &vec_from_enemy); + dot_from_enemy = vm_vec_dot(&En_objp->orient.v.fvec, &vec_from_enemy); if (dist > 250.0f) { vector gp1, gp2; // If far away from enemy, circle, going to nearer of point far off left or right wing - vm_vec_scale_add(&gp1, &enemy_pos, &En_objp->orient.rvec, 250.0f); - vm_vec_scale_add(&gp2, &enemy_pos, &En_objp->orient.rvec, -250.0f); + vm_vec_scale_add(&gp1, &enemy_pos, &En_objp->orient.v.rvec, 250.0f); + vm_vec_scale_add(&gp2, &enemy_pos, &En_objp->orient.v.rvec, -250.0f); if (vm_vec_dist_quick(&gp1, &Pl_objp->pos) < vm_vec_dist_quick(&gp2, &Pl_objp->pos)) goal_point = gp1; else goal_point = gp2; } else if (dot_from_enemy < 0.1f) { // If already close to behind, goal is to get completely behind. - vm_vec_scale_add(&goal_point, &enemy_pos, &En_objp->orient.fvec, -1000.0f); + vm_vec_scale_add(&goal_point, &enemy_pos, &En_objp->orient.v.fvec, -1000.0f); } else if (dot_from_enemy > 0.9f) { // If enemy pointing almost right at self, and self pointing close to enemy, turn away from vector vec_to_enemy; @@ -5279,11 +5282,11 @@ void evade_ship() vm_vec_sub(&vec_to_enemy, &enemy_pos, &player_pos); vm_vec_normalize(&vec_to_enemy); - dot_to_enemy = vm_vec_dot(&Pl_objp->orient.fvec, &vec_to_enemy); + dot_to_enemy = vm_vec_dot(&Pl_objp->orient.v.fvec, &vec_to_enemy); if (dot_to_enemy > 0.75f) { // Used to go to En_objp's right vector, but due to banking while turning, that // caused flying in an odd spiral. - vm_vec_scale_add(&goal_point, &enemy_pos, &Pl_objp->orient.rvec, 1000.0f); + vm_vec_scale_add(&goal_point, &enemy_pos, &Pl_objp->orient.v.rvec, 1000.0f); if (dist < 100.0f) bank_override = Pl_objp->phys_info.speed; } else { @@ -5302,13 +5305,13 @@ evade_ship_l1: ; psrandval = psrandval/16.0f; // Value between -1/2 and 1/2 (approx) // If not close to behind, turn towards his right or left vector, whichever won't cross his path. - if (vm_vec_dot(&vec_from_enemy, &En_objp->orient.rvec) > psrandval) { + if (vm_vec_dot(&vec_from_enemy, &En_objp->orient.v.rvec) > psrandval) { scale = 1000.0f; } else { scale = -1000.0f; } - vm_vec_scale_add(&goal_point, &enemy_pos, &En_objp->orient.rvec, scale); + vm_vec_scale_add(&goal_point, &enemy_pos, &En_objp->orient.v.rvec, scale); temp = ((Missiontime >> 16) & 0x07); temp = ((temp * (temp+1)) % 16)/2 - 4; @@ -5317,19 +5320,19 @@ evade_ship_l1: ; scale = 200.0f * temp; - vm_vec_scale_add2(&goal_point, &En_objp->orient.uvec, scale); + vm_vec_scale_add2(&goal_point, &En_objp->orient.v.uvec, scale); } else { // No evasion this frame, but continue with previous turn. // Reason: If you don't, you lose rotational momentum. Turning every other frame, // and not in between results in a very slow turn because of loss of momentum. - if ((aip->prev_goal_point.x != 0.0f) || (aip->prev_goal_point.y != 0.0f) || (aip->prev_goal_point.z != 0.0f)) + if ((aip->prev_goal_point.xyz.x != 0.0f) || (aip->prev_goal_point.xyz.y != 0.0f) || (aip->prev_goal_point.xyz.z != 0.0f)) goal_point = aip->prev_goal_point; else - vm_vec_scale_add(&goal_point, &enemy_pos, &En_objp->orient.rvec, 100.0f); + vm_vec_scale_add(&goal_point, &enemy_pos, &En_objp->orient.v.rvec, 100.0f); } } - // nprintf(("Mike", "Goal point = %7.1f %7.1f %7.1f\n", goal_point.x, goal_point.y, goal_point.z)); + // nprintf(("Mike", "Goal point = %7.1f %7.1f %7.1f\n", goal_point.xyz.x, goal_point.xyz.y, goal_point.xyz.z)); turn_towards_point(Pl_objp, &goal_point, NULL, bank_override); aip->prev_goal_point = goal_point; @@ -5402,16 +5405,16 @@ void show_firing_diag() return; mprintf(("Fired from %5.1f, %5.1f %5.1f at time = %5.1f, predict collision in %5.2f seconds at %5.1f %5.1f %5.1f\n", - Pl_objp->pos.x, Pl_objp->pos.y, Pl_objp->pos.z, (float) Missiontime/1000.0f, G_collision_time, G_predicted_pos.x, G_predicted_pos.y, G_predicted_pos.z)); + Pl_objp->pos.xyz.x, Pl_objp->pos.xyz.y, Pl_objp->pos.xyz.z, (float) Missiontime/1000.0f, G_collision_time, G_predicted_pos.xyz.x, G_predicted_pos.xyz.y, G_predicted_pos.xyz.z)); vm_vec_normalized_dir(&v2t, &G_predicted_pos, &G_fire_pos); - dot = vm_vec_dot(&v2t, &Pl_objp->orient.fvec); - mprintf(("Dot of fvec and vector to predicted position = %10.7f (%7.3f degrees)\n", dot, acos(dot)*180.0f/3.141592654f)); + dot = vm_vec_dot(&v2t, &Pl_objp->orient.v.fvec); + mprintf(("Dot of v.fvec and vector to predicted position = %10.7f (%7.3f degrees)\n", dot, acos(dot)*180.0f/3.141592654f)); vm_vec_scale_add(&pos1, &En_objp->pos, &En_objp->phys_info.vel, G_collision_time); - vm_vec_scale_add(&pos2, &G_fire_pos, &Pl_objp->orient.fvec, G_collision_time*300.0f); + vm_vec_scale_add(&pos2, &G_fire_pos, &Pl_objp->orient.v.fvec, G_collision_time*300.0f); dist = vm_vec_dist(&pos1, &pos2); - mprintf(("Enemy, laser pos, distance: [%5.1f %5.1f %5.1f] [%5.1f %5.1f %5.1f] %6.2f\n", pos1.x, pos1.y, pos1.z, pos2.x, pos2.y, pos2.z, dist)); + mprintf(("Enemy, laser pos, distance: [%5.1f %5.1f %5.1f] [%5.1f %5.1f %5.1f] %6.2f\n", pos1.xyz.x, pos1.xyz.y, pos1.xyz.z, pos2.xyz.x, pos2.xyz.y, pos2.xyz.z, dist)); } */ @@ -5609,9 +5612,9 @@ void ai_fire_primary_weapon(object *objp) nprintf(("Warning", "Avoid NULL vector assert.. why are G_predicted_pos and G_fire_pos the same?\n")); } else { vm_vec_normalized_dir(&v2t, &G_predicted_pos, &G_fire_pos); - dot = vm_vec_dot(&v2t, &objp->orient.fvec); + dot = vm_vec_dot(&v2t, &objp->orient.v.fvec); if (dot > .998629534f){ // if within 3.0 degrees of desired heading, bash - vm_vector_2_matrix(&objp->orient, &v2t, &objp->orient.uvec, NULL); + vm_vector_2_matrix(&objp->orient, &v2t, &objp->orient.v.uvec, NULL); } } } @@ -6021,7 +6024,7 @@ int might_hit_teammate(object *firing_objp) vm_vec_sub(&vec_to_objp, &firing_objp->pos, &objp->pos); dist = vm_vec_mag_quick(&vec_to_objp); - dot = vm_vec_dot(&firing_objp->orient.fvec, &vec_to_objp)/dist; + dot = vm_vec_dot(&firing_objp->orient.v.fvec, &vec_to_objp)/dist; if (might_collide_with_ship(firing_objp, objp, dot, dist, 2.0f)) return 1; } @@ -6368,7 +6371,7 @@ void set_predicted_enemy_pos(vector *predicted_enemy_pos, object *pobjp, object vector temp; vm_vec_sub(&temp, &eobjp->pos, &pobjp->pos); vm_vec_normalize_quick(&temp); - float dot = vm_vec_dotprod(&temp, &pobjp->orient.fvec); + float dot = vm_vec_dotprod(&temp, &pobjp->orient.v.fvec); float st_err = 3.0f * (1.4f - dot) * (1.0f + dist / (get_skill_stealth_dist_scaler() * STEALTH_MAX_VIEW_DIST)) * (1 - aip->ai_accuracy); scale += st_err; // mprintf(("error term: %.1f, total %.1f, dot %.3f\n", st_err, scale, dot)); @@ -6400,20 +6403,20 @@ void ai_chase_ct() tvec = Pl_objp->pos; if (aip->submode_parm0 & 0x01) - vm_vec_add2(&tvec, &Pl_objp->orient.rvec); + vm_vec_add2(&tvec, &Pl_objp->orient.v.rvec); if (aip->submode_parm0 & 0x02) - vm_vec_sub2(&tvec, &Pl_objp->orient.rvec); + vm_vec_sub2(&tvec, &Pl_objp->orient.v.rvec); if (aip->submode_parm0 & 0x04) - vm_vec_add2(&tvec, &Pl_objp->orient.uvec); + vm_vec_add2(&tvec, &Pl_objp->orient.v.uvec); if (aip->submode_parm0 & 0x08) - vm_vec_sub2(&tvec, &Pl_objp->orient.uvec); + vm_vec_sub2(&tvec, &Pl_objp->orient.v.uvec); // Detect degenerate cases that cause tvec to be same as player pos. if (vm_vec_dist_quick(&tvec, &Pl_objp->pos) < 0.1f) { aip->submode_parm0 &= 0x05; if (aip->submode_parm0 == 0) aip->submode_parm0 = 1; - vm_vec_add2(&tvec, &Pl_objp->orient.rvec); + vm_vec_add2(&tvec, &Pl_objp->orient.v.rvec); } ai_turn_towards_vector(&tvec, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0); @@ -6431,7 +6434,7 @@ void ai_chase_eb(ai_info *aip, ship_info *sip, vector *predicted_enemy_pos, floa // If we're trying to slow down to get behind, then point to turn towards is different. _pep = *predicted_enemy_pos; if ((dot_to_enemy > dot_from_enemy + 0.1f) || (dot_to_enemy > 0.9f)) - vm_vec_scale_add(&_pep, &Pl_objp->pos, &En_objp->orient.fvec, 100.0f); + vm_vec_scale_add(&_pep, &Pl_objp->pos, &En_objp->orient.v.fvec, 100.0f); ai_turn_towards_vector(&_pep, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0); @@ -6562,10 +6565,10 @@ void get_behind_ship(ai_info *aip, ship_info *sip, float dist_to_enemy) dist = vm_vec_normalized_dir(&vec_from_enemy, &Pl_objp->pos, &En_objp->pos); - vm_vec_scale_add(&new_pos, &En_objp->pos, &En_objp->orient.fvec, -100.0f); // Pick point 100 units behind. + vm_vec_scale_add(&new_pos, &En_objp->pos, &En_objp->orient.v.fvec, -100.0f); // Pick point 100 units behind. ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0); - dot = vm_vec_dot(&vec_from_enemy, &En_objp->orient.fvec); + dot = vm_vec_dot(&vec_from_enemy, &En_objp->orient.v.fvec); if (dot > 0.25f) { accelerate_ship(aip, 1.0f); @@ -6718,8 +6721,8 @@ void mabs_pick_goal_point(object *objp, object *big_objp, vector *collision_poin ku = -ku; if (i&2) kr = -kr; - vm_vec_scale_add2(&p, &mat1.uvec, ku); - vm_vec_scale_add2(&p, &mat1.rvec, kr); + vm_vec_scale_add2(&p, &mat1.v.uvec, ku); + vm_vec_scale_add2(&p, &mat1.v.rvec, kr); goals[i].pos = p; goals[i].dist = vm_vec_dist_quick(&objp->pos, &p); goals[i].collide = will_collide_pp(&objp->pos, &p, objp->radius, big_objp, collision_point); @@ -6783,7 +6786,7 @@ int maybe_avoid_big_ship(object *objp, object *ignore_objp, ai_info *aip, vector ai_turn_towards_vector(&aip->avoid_goal_point, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0); vm_vec_normalized_dir(&v2g, &aip->avoid_goal_point, &Pl_objp->pos); - float dot = vm_vec_dot(&objp->orient.fvec, &v2g); + float dot = vm_vec_dot(&objp->orient.v.fvec, &v2g); float d2 = (1.0f + dot) * (1.0f + dot); accelerate_ship(aip, d2/4.0f); return 1; @@ -6799,11 +6802,11 @@ void compute_desired_rvec(vector *rvec, vector *goal_pos, vector *cur_pos) vector v2e; vm_vec_normalized_dir(&v2e, goal_pos, cur_pos); - rvec->x = v2e.z; - rvec->y = 0.0f; - rvec->z = -v2e.x; + rvec->xyz.x = v2e.xyz.z; + rvec->xyz.y = 0.0f; + rvec->xyz.z = -v2e.xyz.x; if (vm_vec_mag_squared(rvec) < 0.001f) - rvec->y = 1.0f; + rvec->xyz.y = 1.0f; } // Handler for stealth find submode of Chase. @@ -6845,16 +6848,16 @@ void ai_stealth_find() // if dist is near max and dot is close to 1, accel, afterburn vm_vec_sub(&vec_to_enemy, &new_pos, &Pl_objp->pos); dist_to_enemy = vm_vec_normalize_quick(&vec_to_enemy); - dot_to_enemy = vm_vec_dotprod(&vec_to_enemy, &Pl_objp->orient.fvec); + dot_to_enemy = vm_vec_dotprod(&vec_to_enemy, &Pl_objp->orient.v.fvec); // if i think i should see him ahead and i don't, set goal pos and turn around, but only if I haven't seen him for a while if ( (delta_time > 800) && (aip->submode_parm0 == SM_SF_AHEAD) && (dot_to_enemy > .94) && (dist_to_enemy < get_skill_stealth_dist_scaler()*STEALTH_MAX_VIEW_DIST + 50) ) { // do turn around) - vm_vec_scale_add(&aip->goal_point, &Pl_objp->pos, &Pl_objp->orient.fvec, -300.0f); + vm_vec_scale_add(&aip->goal_point, &Pl_objp->pos, &Pl_objp->orient.v.fvec, -300.0f); aip->submode_parm0 = SM_SF_BEHIND; vm_vec_sub(&vec_to_enemy, &new_pos, &Pl_objp->pos); dist_to_enemy = vm_vec_normalize_quick(&vec_to_enemy); - dot_to_enemy = vm_vec_dotprod(&vec_to_enemy, &Pl_objp->orient.fvec); + dot_to_enemy = vm_vec_dotprod(&vec_to_enemy, &Pl_objp->orient.v.fvec); } if ( (dist_to_enemy > get_skill_stealth_dist_scaler()*STEALTH_MAX_VIEW_DIST) && (dot_to_enemy > 0.94f) ) { // 20 degree half angle @@ -6884,7 +6887,7 @@ void ai_stealth_find() ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0); } - dot_from_enemy = -vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.fvec); + dot_from_enemy = -vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.v.fvec); attack_set_accel(aip, dist_to_enemy, dot_to_enemy, dot_from_enemy); } @@ -7014,7 +7017,7 @@ void ai_stealth_sweep() if (dist_to_goal < 100) { vector vec_to_goal; vm_vec_normalized_dir(&vec_to_goal, &goal_pt, &Pl_objp->pos); - dot = vm_vec_dotprod(&vec_to_goal, &Pl_objp->orient.fvec); + dot = vm_vec_dotprod(&vec_to_goal, &Pl_objp->orient.v.fvec); } accelerate_ship(aip, 0.8f*dot); @@ -7093,17 +7096,17 @@ void ai_chase_es(ai_info *aip, ship_info *sip) scale = ((Missiontime >> 16) & 0x0f) << 14; if (timeslice & 0x01) - vm_vec_scale_add2(&tvec, &Pl_objp->orient.rvec, f2fl(scale ^ 0x10000)); + vm_vec_scale_add2(&tvec, &Pl_objp->orient.v.rvec, f2fl(scale ^ 0x10000)); if (timeslice & 0x02) - vm_vec_scale_sub2(&tvec, &Pl_objp->orient.rvec, f2fl(scale)); + vm_vec_scale_sub2(&tvec, &Pl_objp->orient.v.rvec, f2fl(scale)); if (timeslice & 0x04) - vm_vec_scale_add2(&tvec, &Pl_objp->orient.uvec, f2fl(scale ^ 0x10000)); + vm_vec_scale_add2(&tvec, &Pl_objp->orient.v.uvec, f2fl(scale ^ 0x10000)); if (timeslice & 0x08) - vm_vec_scale_sub2(&tvec, &Pl_objp->orient.uvec, f2fl(scale)); + vm_vec_scale_sub2(&tvec, &Pl_objp->orient.v.uvec, f2fl(scale)); while (vm_vec_dist_quick(&tvec, &Pl_objp->pos) < 0.1f) { - tvec.x += frand(); - tvec.y += frand(); + tvec.xyz.x += frand(); + tvec.xyz.y += frand(); } bank_override = Pl_objp->phys_info.speed; @@ -7123,7 +7126,7 @@ void ai_chase_ga(ai_info *aip, ship_info *sip) if (En_objp != NULL) { vm_vec_normalized_dir(&vec_from_enemy, &Pl_objp->pos, &En_objp->pos); } else - vec_from_enemy = Pl_objp->orient.fvec; + vec_from_enemy = Pl_objp->orient.v.fvec; static_randvec(Missiontime >> 15, &tvec); vm_vec_scale(&tvec, 100.0f); @@ -7387,7 +7390,7 @@ void update_aspect_lock_information(ai_info *aip, vector *vec_to_enemy, float di // Update locking information for aspect seeking missiles. aip->current_target_is_locked = 0; - dot_to_enemy = vm_vec_dot(vec_to_enemy, &Pl_objp->orient.fvec); + dot_to_enemy = vm_vec_dot(vec_to_enemy, &Pl_objp->orient.v.fvec); float needed_dot = 0.9f - 0.5f * enemy_radius/(dist_to_enemy + enemy_radius); // Replaced MIN_TRACKABLE_DOT with 0.9f if (dot_to_enemy > needed_dot) { @@ -7439,7 +7442,7 @@ void ai_chase_fly_away(object *objp, ai_info *aip) vm_vec_normalized_dir(&v2e, &Objects[aip->target_objnum].pos, &objp->pos); - dot = vm_vec_dot(&objp->orient.fvec, &v2e); + dot = vm_vec_dot(&objp->orient.v.fvec, &v2e); if (dot < 0.0f) accelerate_ship(aip, 1.0f); else @@ -7595,26 +7598,26 @@ void ai_chase_big_get_separations(object *attack_objp, object *target_objp, vect // get parameters of ships (as cylinders - radius and height) // get radius of attacker (for rotations about forward) pm = model_get(Ships[attack_objp->instance].modelnum); - temp = max(pm->maxs.x, pm->maxs.y); - r_attacker = max(-pm->mins.x, -pm->mins.y); + temp = max(pm->maxs.xyz.x, pm->maxs.xyz.y); + r_attacker = max(-pm->mins.xyz.x, -pm->mins.xyz.y); r_attacker = max(temp, r_attacker); - h_attacker = max(-pm->mins.z, pm->maxs.z); + h_attacker = max(-pm->mins.xyz.z, pm->maxs.xyz.z); // get radius of target (for rotations about forward) pm = model_get(Ships[attack_objp->instance].modelnum); - temp = max(pm->maxs.x, pm->maxs.y); - r_target = max(-pm->mins.x, -pm->mins.y); + temp = max(pm->maxs.xyz.x, pm->maxs.xyz.y); + r_target = max(-pm->mins.xyz.x, -pm->mins.xyz.y); r_target = max(temp, r_target); - h_target = max(-pm->mins.z, pm->maxs.z); + h_target = max(-pm->mins.xyz.z, pm->maxs.xyz.z); // find separation between cylinders [if parallel] vm_vec_sub(&vec_to_target, &attack_objp->pos, &target_objp->pos); // find the distance between centers along forward direction of ships - perp_dist = vm_vec_dotprod(&vec_to_target, &target_objp->orient.fvec); + perp_dist = vm_vec_dotprod(&vec_to_target, &target_objp->orient.v.fvec); // subtract off perp component to get "horizontal" separation vector between cylinders [ASSUMING parallel] - vm_vec_scale_add(horz_vec_to_target, &vec_to_target, &target_objp->orient.fvec, -perp_dist); + vm_vec_scale_add(horz_vec_to_target, &vec_to_target, &target_objp->orient.v.fvec, -perp_dist); *cur_separation = vm_vec_mag_quick(horz_vec_to_target); // choose "optimal" separation of 1000 + r_target + r_attacker @@ -7632,20 +7635,20 @@ void ai_chase_big_parallel_set_goal(vector *goal_pos, object *attack_objp, objec // get parameters of ships (as cylinders - radius and height) // get radius of attacker (for rotations about forward) pm = model_get(Ships[attack_objp->instance].modelnum); - temp = max(pm->maxs.x, pm->maxs.y); - r_attacker = max(-pm->mins.x, -pm->mins.y); + temp = max(pm->maxs.xyz.x, pm->maxs.xyz.y); + r_attacker = max(-pm->mins.xyz.x, -pm->mins.xyz.y); r_attacker = max(temp, r_attacker); - h_attacker = max(-pm->mins.z, pm->maxs.z); + h_attacker = max(-pm->mins.xyz.z, pm->maxs.xyz.z); // get radius of target (for rotations about forward) pm = model_get(Ships[attack_objp->instance].modelnum); - temp = max(pm->maxs.x, pm->maxs.y); - r_target = max(-pm->mins.x, -pm->mins.y); + temp = max(pm->maxs.xyz.x, pm->maxs.xyz.y); + r_target = max(-pm->mins.xyz.x, -pm->mins.xyz.y); r_target = max(temp, r_target); - h_target = max(-pm->mins.z, pm->maxs.z); + h_target = max(-pm->mins.xyz.z, pm->maxs.xyz.z); // are we opposing (only when other ship is not moving) - opposing = ( vm_vec_dotprod(&attack_objp->orient.fvec, &target_objp->orient.fvec) < 0 ); + opposing = ( vm_vec_dotprod(&attack_objp->orient.v.fvec, &target_objp->orient.v.fvec) < 0 ); ai_chase_big_get_separations(attack_objp, target_objp, &horz_vec_to_target, &optimal_separation, &separation); @@ -7656,16 +7659,16 @@ void ai_chase_big_parallel_set_goal(vector *goal_pos, object *attack_objp, objec } // set the goal pos as dist forward from target along target forward - vm_vec_scale_add(goal_pos, &target_objp->pos, &target_objp->orient.fvec, dist); + vm_vec_scale_add(goal_pos, &target_objp->pos, &target_objp->orient.v.fvec, dist); // then add horizontal separation vm_vec_scale_add2(goal_pos, &horz_vec_to_target, optimal_separation/separation); // find the distance between centers along forward direction of ships vector vec_to_target; vm_vec_sub(&vec_to_target, &target_objp->pos, &attack_objp->pos); - float perp_dist = vm_vec_dotprod(&vec_to_target, &target_objp->orient.fvec); + float perp_dist = vm_vec_dotprod(&vec_to_target, &target_objp->orient.v.fvec); - float match_accel = target_objp->phys_info.vel.z / Ship_info[Ships[attack_objp->instance].ship_info_index].max_vel.z; + float match_accel = target_objp->phys_info.vel.xyz.z / Ship_info[Ships[attack_objp->instance].ship_info_index].max_vel.xyz.z; float length_scale = attack_objp->radius; // if we're heading toward enemy ship, we want to keep going if we're ahead @@ -7823,7 +7826,7 @@ void ai_cruiser_chase() // maybe switch to new mode vector vec_to_enemy; float dist_to_enemy; - int moving = (En_objp->phys_info.vel.z > 0.5f); + int moving = (En_objp->phys_info.vel.xyz.z > 0.5f); vm_vec_sub(&vec_to_enemy, &En_objp->pos, &Pl_objp->pos); dist_to_enemy = vm_vec_mag_quick(&vec_to_enemy); @@ -7833,7 +7836,7 @@ void ai_cruiser_chase() // moving if (moving) { // if within 90 degrees of en forward, go into parallel, otherwise circle - if ( vm_vec_dotprod(&En_objp->orient.fvec, &Pl_objp->orient.fvec) > 0 ) { + if ( vm_vec_dotprod(&En_objp->orient.v.fvec, &Pl_objp->orient.v.fvec) > 0 ) { aip->submode = SM_BIG_PARALLEL; } } @@ -7851,9 +7854,9 @@ void ai_cruiser_chase() vector temp; float desired_sep, cur_sep; // we're behind the enemy ship - if (vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.fvec) > 0) { + if (vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.v.fvec) > 0) { // and we're turning toward the enemy - if (vm_vec_dotprod(&En_objp->orient.fvec, &Pl_objp->orient.fvec) > 0) { + if (vm_vec_dotprod(&En_objp->orient.v.fvec, &Pl_objp->orient.v.fvec) > 0) { // get separation ai_chase_big_get_separations(Pl_objp, En_objp, &temp, &desired_sep, &cur_sep); // and the separation is > 0.9 desired @@ -7867,9 +7870,9 @@ void ai_cruiser_chase() vector temp; float desired_sep, cur_sep; // we're behind the enemy ship - if (vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.fvec) > 0) { + if (vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.v.fvec) > 0) { // and we're turning toward the enemy - if (vm_vec_dotprod(&En_objp->orient.fvec, &Pl_objp->orient.fvec) > 0) { + if (vm_vec_dotprod(&En_objp->orient.v.fvec, &Pl_objp->orient.v.fvec) > 0) { // get separation ai_chase_big_get_separations(Pl_objp, En_objp, &temp, &desired_sep, &cur_sep); //and the separation is [0.9 to 1.1] desired @@ -7881,7 +7884,7 @@ void ai_cruiser_chase() // in front of ship else { // and we're turning toward the enemy - if (vm_vec_dotprod(&En_objp->orient.fvec, &Pl_objp->orient.fvec) < 0) { + if (vm_vec_dotprod(&En_objp->orient.v.fvec, &Pl_objp->orient.v.fvec) < 0) { // get separation ai_chase_big_get_separations(Pl_objp, En_objp, &temp, &desired_sep, &cur_sep); //and the separation is [0.9 to 1.1] desired @@ -7895,7 +7898,7 @@ void ai_cruiser_chase() case SM_BIG_PARALLEL: // we're opposing - if ( vm_vec_dotprod(&Pl_objp->orient.fvec, &En_objp->orient.fvec) < 0 ) { + if ( vm_vec_dotprod(&Pl_objp->orient.v.fvec, &En_objp->orient.v.fvec) < 0 ) { // and the other ship is moving if (moving) { // and we no longer overlap @@ -7967,7 +7970,7 @@ void ai_chase() vm_vec_normalize(&real_vec_to_enemy); - real_dot_to_enemy = vm_vec_dot(&real_vec_to_enemy, &Pl_objp->orient.fvec); + real_dot_to_enemy = vm_vec_dot(&real_vec_to_enemy, &Pl_objp->orient.v.fvec); int is_stealthy_ship = 0; if ( (enemy_sip_flags > 0) && (enemy_sip_flags & SIF_STEALTH) ) { @@ -8005,11 +8008,11 @@ void ai_chase() set_predicted_enemy_pos(&predicted_enemy_pos, Pl_objp, En_objp, aip); set_target_objnum(aip, -1); } - // nprintf(("AI", "Attacking subsystem: rval = %i, pos = %7.3f %7.3f %7.3f\n", rval, predicted_enemy_pos.x, predicted_enemy_pos.y, predicted_enemy_pos.z)); + // nprintf(("AI", "Attacking subsystem: rval = %i, pos = %7.3f %7.3f %7.3f\n", rval, predicted_enemy_pos.xyz.x, predicted_enemy_pos.xyz.y, predicted_enemy_pos.xyz.z)); } else { set_predicted_enemy_pos(&predicted_enemy_pos, Pl_objp, En_objp, aip); - // nprintf(("AI", "Attacking subsystem: pos = %7.3f %7.3f %7.3f\n", predicted_enemy_pos.x, predicted_enemy_pos.y, predicted_enemy_pos.z)); + // nprintf(("AI", "Attacking subsystem: pos = %7.3f %7.3f %7.3f\n", predicted_enemy_pos.xyz.x, predicted_enemy_pos.xyz.y, predicted_enemy_pos.xyz.z)); } } else { set_predicted_enemy_pos(&predicted_enemy_pos, Pl_objp, En_objp, aip); @@ -8020,8 +8023,8 @@ void ai_chase() vm_vec_normalize(&predicted_vec_to_enemy); - dot_to_enemy = vm_vec_dot(&Pl_objp->orient.fvec, &predicted_vec_to_enemy); - dot_from_enemy= - vm_vec_dot(&En_objp->orient.fvec, &real_vec_to_enemy); + dot_to_enemy = vm_vec_dot(&Pl_objp->orient.v.fvec, &predicted_vec_to_enemy); + dot_from_enemy= - vm_vec_dot(&En_objp->orient.v.fvec, &real_vec_to_enemy); // // Set turn and acceleration based on submode. @@ -8761,7 +8764,7 @@ float dock_orient_and_approach(object *objp, object *dobjp, int dock_mode) float turn_time = Ship_info[Ships[objp->instance].ship_info_index].srotation_time; ai_turn_towards_vector(&goal_point, objp, flFrametime, turn_time, NULL, NULL, 0.0f, 0); - dot = vm_vec_dot(&objp->orient.fvec, &away_vec); + dot = vm_vec_dot(&objp->orient.v.fvec, &away_vec); accel = 0.1f; if (dot > accel) accel = dot; @@ -8786,7 +8789,7 @@ float dock_orient_and_approach(object *objp, object *dobjp, int dock_mode) //nprintf(("AI", "or/app: dist = %7.3f/%7.3f, dot = %7.3f, global dot = %7.3f\n", // vm_vec_dist_quick(&goal_point, &objp->pos), fdist, - // vm_vec_dot(&objp->orient.fvec, &dom.fvec), + // vm_vec_dot(&objp->orient.v.fvec, &dom.v.fvec), // vm_vec_dot(&d0, &d1))); #endif @@ -9169,7 +9172,7 @@ void ai_guard_find_nearby_asteroid(object *guarding_objp, object *guarded_objp) } if ( dist_to_self < closest_asteroid_dist ) { // only attack if moving slower than own max speed - if ( vm_vec_mag_quick(&asteroid_objp->phys_info.vel) < guarding_objp->phys_info.max_vel.z ) { + if ( vm_vec_mag_quick(&asteroid_objp->phys_info.vel) < guarding_objp->phys_info.max_vel.xyz.z ) { closest_asteroid_dist = dist_to_self; closest_asteroid_objp = asteroid_objp; } @@ -9219,8 +9222,8 @@ float get_cylinder_points(object *other_objp, object *cyl_objp, vector *axis_pt, // get radius of cylinder polymodel *pm = model_get(Ships[cyl_objp->instance].modelnum); float tempx, tempy; - tempx = max(-pm->mins.x, pm->maxs.x); - tempy = max(-pm->mins.y, pm->maxs.y); + tempx = max(-pm->mins.xyz.x, pm->maxs.xyz.x); + tempy = max(-pm->mins.xyz.y, pm->maxs.xyz.y); *radius = max(tempx, tempy); // get vec from cylinder to other_obj @@ -9230,10 +9233,10 @@ float get_cylinder_points(object *other_objp, object *cyl_objp, vector *axis_pt, // get point on axis and on cylinder // extended_cylinder_z is along extended cylinder // cylinder_z is capped within cylinder - float extended_cylinder_z = vm_vec_dotprod(&r_sph, &cyl_objp->orient.fvec); + float extended_cylinder_z = vm_vec_dotprod(&r_sph, &cyl_objp->orient.v.fvec); // get pt on axis of extended cylinder - vm_vec_scale_add(axis_pt, &cyl_objp->pos, &cyl_objp->orient.fvec, extended_cylinder_z); + vm_vec_scale_add(axis_pt, &cyl_objp->pos, &cyl_objp->orient.v.fvec, extended_cylinder_z); // get r_vec (pos - axis_pt) normalized vm_vec_normalized_dir(r_vec, &other_objp->pos, axis_pt); @@ -9266,7 +9269,7 @@ void ai_big_guard() // get position relative to cylinder of guard_objp extended_z = get_cylinder_points(Pl_objp, guard_objp, &axis_pt, &r_vec, &radius); - vm_vec_crossprod(&theta_vec, &guard_objp->orient.fvec, &r_vec); + vm_vec_crossprod(&theta_vec, &guard_objp->orient.v.fvec, &r_vec); // half ships circle each way if (objval > 0.5f) { @@ -9280,8 +9283,8 @@ void ai_big_guard() // get z extents float min_z, max_z, length; polymodel *pm = model_get(Ships[guard_objp->instance].modelnum); - min_z = pm->mins.z; - max_z = pm->maxs.z; + min_z = pm->mins.xyz.z; + max_z = pm->maxs.xyz.z; length = max_z - min_z; // get desired z @@ -9307,9 +9310,9 @@ void ai_big_guard() } else { // move to where I can orbit if (extended_z < min_z) { - vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.fvec, min_z); + vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.v.fvec, min_z); } else { - vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.fvec, max_z); + vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.v.fvec, max_z); } vm_vec_scale_add2(&goal_pt, &r_vec, desired_guard_dist); vm_vec_scale_add2(&goal_pt, &theta_vec, desired_guard_dist); @@ -9322,9 +9325,9 @@ void ai_big_guard() } else { // outside (fly to edge and circle) if (extended_z < min_z) { - vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.fvec, min_z); + vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.v.fvec, min_z); } else { - vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.fvec, max_z); + vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.v.fvec, max_z); } vm_vec_scale_add2(&goal_pt, &r_vec, max_guard_dist); vm_vec_scale_add2(&goal_pt, &theta_vec, desired_guard_dist); @@ -9346,13 +9349,13 @@ void ai_big_guard() v_z = 20.0f; } - vm_vec_scale_add2(&goal_pt, &guard_objp->orient.fvec, v_z*time); + vm_vec_scale_add2(&goal_pt, &guard_objp->orient.v.fvec, v_z*time); } } else { // cast vector to center of guard_ship adjusted by desired_z float delta_z = desired_z - extended_z; - vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.fvec, delta_z); + vm_vec_scale_add(&goal_pt, &guard_objp->pos, &guard_objp->orient.v.fvec, delta_z); } // try not to bump into things along the way @@ -9465,14 +9468,14 @@ void ai_guard() case AIS_GUARD_PATROL: // Stay near ship dist_to_guardobj = vm_vec_normalized_dir(&vec_to_guardobj, &guard_objp->pos, &Pl_objp->pos); - dot_to_guardobj = vm_vec_dot(&Pl_objp->orient.fvec, &vec_to_guardobj); + dot_to_guardobj = vm_vec_dot(&Pl_objp->orient.v.fvec, &vec_to_guardobj); rel_vec = aip->guard_vec; vm_vec_add(&goal_point, &guard_objp->pos, &rel_vec); vm_vec_normalized_dir(&v2g, &goal_point, &Pl_objp->pos); dist_to_goal_point = vm_vec_dist_quick(&goal_point, &Pl_objp->pos); - dot_to_goal_point = vm_vec_dot(&v2g, &Pl_objp->orient.fvec); + dot_to_goal_point = vm_vec_dot(&v2g, &Pl_objp->orient.v.fvec); accel_scale = (1.0f + dot_to_goal_point)/2.0f; // If far away, get closer @@ -9518,7 +9521,7 @@ void ai_guard() if (speed > 10.0f) { // If goal ship is moving more than a tiny bit, don't orbit it, get near it. if (vm_vec_dist_quick(&goal_point, &Pl_objp->pos) > 40.0f) { - if (vm_vec_dot(&Pl_objp->orient.fvec, &v2g) < 0.0f) { + if (vm_vec_dot(&Pl_objp->orient.v.fvec, &v2g) < 0.0f) { // Just slow down, don't turn. set_accel_for_target_speed(Pl_objp, guard_objp->phys_info.speed - dist_to_goal_point/10.0f); } else { @@ -11318,10 +11321,9 @@ void get_wing_delta(vector *_delta_vec, int wing_index) row--; column = wi0 - k + row + 1; - _delta_vec->x = ((float) column - (float) row/2.0f) * DEFAULT_WING_X_DELTA/DEFAULT_WING_MAG; - _delta_vec->y = ((float)row + (float)bank*2.25f) * DEFAULT_WING_Y_DELTA/DEFAULT_WING_MAG; - _delta_vec->z = - ((float)row + 0.5f * (float) bank) * DEFAULT_WING_Z_DELTA/DEFAULT_WING_MAG; - + _delta_vec->xyz.x = ((float) column - (float) row/2.0f) * DEFAULT_WING_X_DELTA/DEFAULT_WING_MAG; + _delta_vec->xyz.y = ((float)row + (float)bank*2.25f) * DEFAULT_WING_Y_DELTA/DEFAULT_WING_MAG; + _delta_vec->xyz.z = - ((float)row + 0.5f * (float) bank) * DEFAULT_WING_Z_DELTA/DEFAULT_WING_MAG; } // Compute the largest radius of a ship in a *objp's wing. @@ -11412,7 +11414,7 @@ void get_absolute_wing_pos(vector *result_pos, object *leader_objp, int wing_ind // for player obj (1) move ships up 20% (2) scale formation up 20% if (leader_objp->flags & OF_PLAYER_SHIP) { - wing_delta.y *= Wing_y_scale; + wing_delta.xyz.y *= Wing_y_scale; wing_spread_size *= Wing_scale; } @@ -11572,8 +11574,8 @@ int formation_is_leader_chaotic(object *objp) speed_scale = 3.0f + objp->phys_info.speed * 0.1f; - fdot = 5.0f * (1.0f - vm_vec_dot(&objp->orient.fvec, &objp->last_orient.fvec)) * flFrametime; - udot = 8.0f * (1.0f - vm_vec_dot(&objp->orient.uvec, &objp->last_orient.uvec)) * flFrametime; + fdot = 5.0f * (1.0f - vm_vec_dot(&objp->orient.v.fvec, &objp->last_orient.v.fvec)) * flFrametime; + udot = 8.0f * (1.0f - vm_vec_dot(&objp->orient.v.uvec, &objp->last_orient.v.uvec)) * flFrametime; Leader_chaos += fdot * speed_scale + udot * speed_scale; @@ -11700,18 +11702,18 @@ int ai_formation() get_absolute_wing_pos(&goal_point, leader_objp, wing_index, aip->ai_flags & AIF_FORMATION_OBJECT); vm_vec_scale_add(&future_goal_point_5, &goal_point, &leader_vec, 10.0f); vm_vec_scale_add(&future_goal_point_2, &goal_point, &leader_vec, 5.0f); - vm_vec_scale_add(&future_goal_point_x, &goal_point, &leader_objp->orient.fvec, 10.0f); // used when very close to destination - vm_vec_scale_add(&future_goal_point_1000x, &goal_point, &leader_objp->orient.fvec, 1000.0f); // used when very close to destination + vm_vec_scale_add(&future_goal_point_x, &goal_point, &leader_objp->orient.v.fvec, 10.0f); // used when very close to destination + vm_vec_scale_add(&future_goal_point_1000x, &goal_point, &leader_objp->orient.v.fvec, 1000.0f); // used when very close to destination // Now, get information telling this object how to turn and accelerate to get to its // desired location. vm_vec_sub(&vec_to_goal, &goal_point, &Pl_objp->pos); if ( vm_vec_mag_quick(&vec_to_goal) < AICODE_SMALL_MAGNITUDE ) - vec_to_goal.x += 0.1f; + vec_to_goal.xyz.x += 0.1f; vm_vec_copy_normalize(&dir_to_goal, &vec_to_goal); - //dot_to_goal = vm_vec_dot(&dir_to_goal, &leader_objp->orient.fvec); - dot_to_goal = vm_vec_dot(&dir_to_goal, &Pl_objp->orient.fvec); + //dot_to_goal = vm_vec_dot(&dir_to_goal, &leader_objp->orient.v.fvec); + dot_to_goal = vm_vec_dot(&dir_to_goal, &Pl_objp->orient.v.fvec); dist_to_goal = vm_vec_dist_quick(&Pl_objp->pos, &goal_point); float dist_to_goal_2 = vm_vec_dist_quick(&Pl_objp->pos, &future_goal_point_2); @@ -11745,7 +11747,7 @@ int ai_formation() float dist_to_f2; dist_to_f2 = vm_vec_normalized_dir(&v2f2, &future_goal_point_2, &Pl_objp->pos); - dot_to_f2 = vm_vec_dot(&v2f2, &Pl_objp->orient.fvec); + dot_to_f2 = vm_vec_dot(&v2f2, &Pl_objp->orient.v.fvec); // Leader flying like a maniac. Don't try hard to form on wing. if (chaotic_leader) { @@ -11826,7 +11828,7 @@ int ai_formation() } // See how different this ship's bank is relative to wing leader - float up_dot = vm_vec_dot(&leader_objp->orient.uvec, &Pl_objp->orient.uvec); + float up_dot = vm_vec_dot(&leader_objp->orient.v.uvec, &Pl_objp->orient.v.uvec); if (up_dot < 0.996f) { vector w_out; matrix new_orient; @@ -11835,12 +11837,12 @@ int ai_formation() vm_vec_copy_scale(&angular_accel, &Pl_objp->phys_info.max_rotvel, 0.2f); vm_matrix_interpolate(&leader_objp->orient, &Pl_objp->orient, &Pl_objp->phys_info.rotvel, flFrametime, &new_orient, &w_out, &Pl_objp->phys_info.max_rotvel, &angular_accel, 1); - // nprintf(("AI", "Frame %d Bashing formation orient. Dot was %6.3f, becomes %6.3f\n", Framecount, up_dot, vm_vec_dot(&leader_objp->orient.uvec, &new_orient.uvec))); + // nprintf(("AI", "Frame %d Bashing formation orient. Dot was %6.3f, becomes %6.3f\n", Framecount, up_dot, vm_vec_dot(&leader_objp->orient.v.uvec, &new_orient.v.uvec))); Pl_objp->orient = new_orient; Pl_objp->phys_info.rotvel = w_out; // Pl_objp->phys_info.desired_rotvel = w_out; } else { - Pl_objp->phys_info.rotvel.z = 0.0f; + Pl_objp->phys_info.rotvel.xyz.z = 0.0f; } return 0; @@ -12087,7 +12089,7 @@ void ai_safety_circle_spot() set_accel_for_target_speed(Pl_objp, sip->max_speed/4.0f); // float dist = vm_vec_dist_quick(&goal_point, &Pl_objp->pos); -// nprintf(("AI", "Ship %s circling %7.3f %7.3f %7.3f. Distance = %7.3f\n", Ships[Pl_objp->instance].ship_name, goal_point.x, goal_point.y, goal_point.z, dist)); +// nprintf(("AI", "Ship %s circling %7.3f %7.3f %7.3f. Distance = %7.3f\n", Ships[Pl_objp->instance].ship_name, goal_point.xyz.x, goal_point.xyz.y, goal_point.xyz.z, dist)); } */ @@ -12459,7 +12461,7 @@ void maybe_evade_dumbfire_weapon(ai_info *aip) // determine what path to use when emerging from a fighter bay // input: pl_objp => pointer to object for ship that is arriving // pos => output parameter, it is the starting world pos for path choosen -// fvec => output parameter, this is the forward vector that ship has when arriving +// v.fvec => output parameter, this is the forward vector that ship has when arriving // // exit: -1 => path could not be located // 0 => success @@ -12536,9 +12538,9 @@ int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, vector *pos, vect vm_vec_scale( &vel, speed ); pl_objp->phys_info.vel = vel; pl_objp->phys_info.desired_vel = vel; - pl_objp->phys_info.prev_ramp_vel.x = 0.0f; - pl_objp->phys_info.prev_ramp_vel.y = 0.0f; - pl_objp->phys_info.prev_ramp_vel.z = speed; + pl_objp->phys_info.prev_ramp_vel.xyz.x = 0.0f; + pl_objp->phys_info.prev_ramp_vel.xyz.y = 0.0f; + pl_objp->phys_info.prev_ramp_vel.xyz.z = speed; pl_objp->phys_info.forward_thrust = 0.0f; // How much the forward thruster is applied. 0-1. return 0; @@ -12832,7 +12834,7 @@ void ai_execute_behavior(ai_info *aip) ai_evade(); } else { vector tvec; - vm_vec_scale_add(&tvec, &Pl_objp->pos, &Pl_objp->orient.rvec, 100.0f); + vm_vec_scale_add(&tvec, &Pl_objp->pos, &Pl_objp->orient.v.rvec, 100.0f); turn_towards_point(Pl_objp, &tvec, NULL, 0.0f); accelerate_ship(aip, 0.5f); } @@ -13118,7 +13120,7 @@ void ai_warp_out(object *objp) aip->force_warp_time = timestamp(4*1000); // Try to attain target speed for up to 4 seconds. } else { vector goal_point; - vm_vec_scale_add(&goal_point, &objp->pos, &objp->orient.uvec, 100.0f); + vm_vec_scale_add(&goal_point, &objp->pos, &objp->orient.v.uvec, 100.0f); turn_towards_point(objp, &goal_point, NULL, 0.0f); accelerate_ship(aip, 0.0f); } @@ -13140,7 +13142,7 @@ void ai_warp_out(object *objp) //set_accel_for_target_speed(objp, 40.0f); // DKA 8/11/99 objp->phys_info.flags |= PF_USE_VEL; This flag is set in object code if warping out and AIS_WARP >= 3, properly accounting for blown engines speed = goal_speed * flFrametime + objp->phys_info.speed * (1.0f - flFrametime); - vm_vec_copy_scale(&objp->phys_info.vel, &objp->orient.fvec, speed); + vm_vec_copy_scale(&objp->phys_info.vel, &objp->orient.v.fvec, speed); objp->phys_info.desired_vel = objp->phys_info.vel; // nprintf(("AI", "Frame %i, speed = %7.3f, goal = %7.3f\n", Framecount, vm_vec_mag_quick(&objp->phys_info.vel), goal_speed)); if (timestamp_elapsed(aip->force_warp_time) || (fl_abs(objp->phys_info.speed - goal_speed) < 2.0f)) @@ -13330,7 +13332,7 @@ int aas_1(object *objp, ai_info *aip, vector *safe_pos) time_scale = weaponp->lifeleft/2.0f; } - vm_vec_scale_add(&expected_pos, &weapon_objp->pos, &weapon_objp->orient.fvec, time_scale); + vm_vec_scale_add(&expected_pos, &weapon_objp->pos, &weapon_objp->orient.v.fvec, time_scale); } // See if too far away to care about shockwave. @@ -13342,14 +13344,14 @@ int aas_1(object *objp, ai_info *aip, vector *safe_pos) vector vec_from_exp; float dir = 1.0f; vm_vec_sub(&vec_from_exp, &objp->pos, &expected_pos); - float dot = vm_vec_dotprod(&vec_from_exp, &weapon_objp->orient.fvec); + float dot = vm_vec_dotprod(&vec_from_exp, &weapon_objp->orient.v.fvec); if (dot > -30) { // if we're already on the other side of the explosion, don't try to fly behind it dir = -1.0f; } // Fly towards a point behind the weapon. - vm_vec_scale_add(safe_pos, &weapon_objp->pos, &weapon_objp->orient.fvec, -50000.0f*dir); + vm_vec_scale_add(safe_pos, &weapon_objp->pos, &weapon_objp->orient.v.fvec, -50000.0f*dir); // verify safe_pos will not make us collide with our target objnum, else try 2 other vecs // don't bang your head, else go @@ -13362,7 +13364,7 @@ int aas_1(object *objp, ai_info *aip, vector *safe_pos) int idx; for (idx=0; idx<2; idx++) { vm_vec_rand_vec_quick(&rand_vec); - vm_vec_scale_add(&dir_vec, &weapon_objp->orient.fvec, &rand_vec, 0.5f); + vm_vec_scale_add(&dir_vec, &weapon_objp->orient.v.fvec, &rand_vec, 0.5f); vm_vec_scale_add(safe_pos, &weapon_objp->pos, &dir_vec, -50000.0f*dir); if ( !pp_collide(&objp->pos, safe_pos, target_ship_obj, objp->radius) ) { go_safe = TRUE; @@ -13494,7 +13496,7 @@ int ai_avoid_shockwave(object *objp, ai_info *aip) vm_vec_normalized_dir(&vec_to_safe_pos, &safe_pos, &objp->pos); - dot_to_goal = vm_vec_dot(&objp->orient.fvec, &vec_to_safe_pos); + dot_to_goal = vm_vec_dot(&objp->orient.v.fvec, &vec_to_safe_pos); if (dot_to_goal < -0.5f) accelerate_ship(aip, 0.3f); else { @@ -13542,11 +13544,11 @@ int ai_await_repair_frame(object *objp, ai_info *aip) return 0; } - vm_vec_scale_add(&goal_point, &repair_objp->pos, &repair_objp->orient.uvec, -50.0f); // Fly towards point below repair ship. + vm_vec_scale_add(&goal_point, &repair_objp->pos, &repair_objp->orient.v.uvec, -50.0f); // Fly towards point below repair ship. vector vtr; float dist = vm_vec_normalized_dir(&vtr, &goal_point, &objp->pos); - float dot = vm_vec_dot(&vtr, &objp->orient.fvec); + float dot = vm_vec_dot(&vtr, &objp->orient.v.fvec); if (dist > 200.0f) { //nprintf(("AI", "%s flying towards %s for repair, dist = %7.3f\n", Ships[objp->instance].ship_name, &Ships[repair_objp->instance].ship_name, dist)); @@ -13628,7 +13630,7 @@ int maybe_big_ship_collide_recover_frame(object *objp, ai_info *aip) if (aip->ai_flags & AIF_BIG_SHIP_COLLIDE_RECOVER_1) { ai_turn_towards_vector(&aip->big_recover_pos_1, objp, flFrametime, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, NULL, NULL, 0.0f, 0, NULL); dist = vm_vec_normalized_dir(&v2g, &aip->big_recover_pos_1, &objp->pos); - dot = vm_vec_dot(&objp->orient.fvec, &v2g); + dot = vm_vec_dot(&objp->orient.v.fvec, &v2g); accelerate_ship(aip, dot); // If close to desired point, or 15+ seconds since entered this mode, continue to next mode. @@ -13642,7 +13644,7 @@ int maybe_big_ship_collide_recover_frame(object *objp, ai_info *aip) } else if (aip->ai_flags & AIF_BIG_SHIP_COLLIDE_RECOVER_2) { ai_turn_towards_vector(&aip->big_recover_pos_2, objp, flFrametime, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, NULL, NULL, 0.0f, 0, NULL); dist = vm_vec_normalized_dir(&v2g, &aip->big_recover_pos_2, &objp->pos); - dot = vm_vec_dot(&objp->orient.fvec, &v2g); + dot = vm_vec_dot(&objp->orient.v.fvec, &v2g); accelerate_ship(aip, dot); // If close to desired point, or 30+ seconds since started avoiding collision, done avoiding. @@ -13767,7 +13769,7 @@ void ai_frame(int objnum) ai_preprocess_ignore_objnum(Pl_objp, aip); target_objnum = set_target_objnum(aip, aip->target_objnum); - // nprintf(("AI", "Frame %i: Coords = %7.3f %7.3f %7.3f\n", AI_FrameCount, Pl_objp->pos.x, Pl_objp->pos.y, Pl_objp->pos.z)); + // nprintf(("AI", "Frame %i: Coords = %7.3f %7.3f %7.3f\n", AI_FrameCount, Pl_objp->pos.xyz.x, Pl_objp->pos.xyz.y, Pl_objp->pos.xyz.z)); Assert(objnum != target_objnum); @@ -13855,7 +13857,7 @@ void ai_frame(int objnum) aip->target_objnum = -1; } - if ((En_objp != NULL) && (En_objp->pos.x == Pl_objp->pos.x) && (En_objp->pos.y == Pl_objp->pos.y) && (En_objp->pos.z == Pl_objp->pos.z)) { + if ((En_objp != NULL) && (En_objp->pos.xyz.x == Pl_objp->pos.xyz.x) && (En_objp->pos.xyz.y == Pl_objp->pos.xyz.y) && (En_objp->pos.xyz.z == Pl_objp->pos.xyz.z)) { mprintf(("Warning: Object and its enemy have same position. Object #%i\n", Pl_objp-Objects)); En_objp = NULL; } @@ -14007,7 +14009,7 @@ void ai_process( object * obj, int ai_index, float frametime ) AI_ci.heading = 0.0f; // the ships maximum velocity now depends on the energy flowing to engines - obj->phys_info.max_vel.z = Ships[obj->instance].current_max_speed; + obj->phys_info.max_vel.xyz.z = Ships[obj->instance].current_max_speed; ai_info *aip = &Ai_info[Ships[obj->instance].ai_index]; // In certain circumstances, the AI says don't fly in the normal way. @@ -14063,8 +14065,8 @@ void init_ai_object(int objnum) ship_type = Ships[ship_index].ship_info_index; - vm_vec_scale_add(&near_vec, &objp->pos, &objp->orient.fvec, 100.0f); - vm_vec_scale_add2(&near_vec, &objp->orient.rvec, 10.0f); + vm_vec_scale_add(&near_vec, &objp->pos, &objp->orient.v.fvec, 100.0f); + vm_vec_scale_add2(&near_vec, &objp->orient.v.rvec, 10.0f); // Things that shouldn't have to get initialized, but initialize them just in case! aip->ai_flags = 0; @@ -14128,9 +14130,9 @@ void init_ai_object(int objnum) aip->attacker_objnum = -1; aip->goal_signature = -1; - Objects[objnum].phys_info.prev_fvec = Objects[objnum].orient.fvec; + Objects[objnum].phys_info.prev_fvec = Objects[objnum].orient.v.fvec; - aip->last_predicted_enemy_pos.x = 0.0f; // Says this value needs to be recomputed! + aip->last_predicted_enemy_pos.xyz.x = 0.0f; // Says this value needs to be recomputed! aip->time_enemy_in_range = 0.0f; aip->resume_goal_time = -1; // Say there is no goal to resume. @@ -14535,7 +14537,7 @@ void big_ship_collide_recover_start(object *objp, object *big_objp, vector *coll if (collision_normal) { direction = *collision_normal; } else { - vm_vec_copy_scale(&direction, &objp->orient.fvec, -1.0f); + vm_vec_copy_scale(&direction, &objp->orient.v.fvec, -1.0f); } vm_vec_scale_add(&aip->big_recover_pos_1, &objp->pos, &direction, 100.0f); @@ -14544,14 +14546,14 @@ void big_ship_collide_recover_start(object *objp, object *big_objp, vector *coll accelerate_ship(aip, 0.0f); /* - if (vm_vec_dot(collision_normal, &objp->orient.fvec) > 0.5f) { + if (vm_vec_dot(collision_normal, &objp->orient.v.fvec) > 0.5f) { // vm_vec_scale_add(&aip->big_recover_pos_1, &objp->pos, &out_vec, big_objp->radius/2.0f); -// vm_vec_scale_add(&aip->big_recover_pos_2, &aip->big_recover_pos_1, &objp->orient.uvec, big_objp->radius/2.0f); +// vm_vec_scale_add(&aip->big_recover_pos_2, &aip->big_recover_pos_1, &objp->orient.v.uvec, big_objp->radius/2.0f); // vm_vec_scale_add(&aip->big_recover_pos_2, &objp->pos, &out_vec, big_objp->radius*2.0f); accelerate_ship(aip, 2.0f); } else { // vm_vec_scale_add(&aip->big_recover_pos_1, &objp->pos, &out_vec, big_objp->radius/2.0f); -// vm_vec_scale_add(&aip->big_recover_pos_2, &aip->big_recover_pos_1, &objp->orient.uvec, big_objp->radius/2.0f); +// vm_vec_scale_add(&aip->big_recover_pos_2, &aip->big_recover_pos_1, &objp->orient.v.uvec, big_objp->radius/2.0f); accelerate_ship(aip, 0.0f); } */ } @@ -14995,7 +14997,7 @@ void ai_warp_out(object *objp, vector *vp) shipfx_warpout_start(objp); } else { - dot = vm_vec_dot(&objp->orient.fvec, &v2v); + dot = vm_vec_dot(&objp->orient.v.fvec, &v2v); aip = &Ai_info[Ships[objp->instance].ai_index]; diff --git a/src/ship/shield.cpp b/src/ship/shield.cpp index b39cff8..2db4281 100644 --- a/src/ship/shield.cpp +++ b/src/ship/shield.cpp @@ -15,6 +15,9 @@ * Stuff pertaining to shield graphical effects, etc. * * $Log$ + * Revision 1.4 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:26 relnev * added copyright header * @@ -688,7 +691,7 @@ void create_tris_containing(vector *vp, matrix *orient, shield_info *shieldp, ve vector v; v = verts[shieldp->tris[i].verts[j]].pos; - if ((vp->x == v.x) && (vp->y == v.y) && (vp->z == v.z)) + if ((vp->xyz.x == v.xyz.x) && (vp->xyz.y == v.xyz.y) && (vp->xyz.z == v.xyz.z)) create_shield_from_triangle(i, orient, shieldp, tcp, centerp, radius, rvec, uvec); } } @@ -883,7 +886,7 @@ void create_shield_low_detail(int objnum, int model_num, matrix *orient, vector vm_vector_2_matrix(&tom, &shieldp->tris[tr0].norm, NULL, NULL); //rs_compute_uvs( &shieldp->tris[tr0], shieldp->verts, tcp, Objects[objnum].radius, &tom.rvec, &tom.uvec); - create_low_detail_poly(gi, tcp, &tom.rvec, &tom.uvec); + create_low_detail_poly(gi, tcp, &tom.v.rvec, &tom.v.uvec); } @@ -947,10 +950,10 @@ void create_shield_explosion(int objnum, int model_num, matrix *orient, vector * //vm_vec_sub(&v2c, tcp, &Objects[objnum].pos); // Create the shield from the current triangle, as well as its neighbors. - create_shield_from_triangle(tr0, orient, shieldp, tcp, centerp, Objects[objnum].radius, &tom.rvec, &tom.uvec); + create_shield_from_triangle(tr0, orient, shieldp, tcp, centerp, Objects[objnum].radius, &tom.v.rvec, &tom.v.uvec); //nprintf(("AI", "\n")); for (i=0; i<3; i++) - create_shield_from_triangle(shieldp->tris[tr0].neighbors[i], orient, shieldp, tcp, centerp, Objects[objnum].radius, &tom.rvec, &tom.uvec); + create_shield_from_triangle(shieldp->tris[tr0].neighbors[i], orient, shieldp, tcp, centerp, Objects[objnum].radius, &tom.v.rvec, &tom.v.uvec); copy_shield_to_globals(objnum, shieldp); // render_shield(orient, centerp); @@ -1246,10 +1249,10 @@ int get_quadrant(vector *hit_pnt) { int result = 0; - if (hit_pnt->x < hit_pnt->z) + if (hit_pnt->xyz.x < hit_pnt->xyz.z) result |= 1; - if (hit_pnt->x < -hit_pnt->z) + if (hit_pnt->xyz.x < -hit_pnt->xyz.z) result |= 2; return result; diff --git a/src/ship/ship.cpp b/src/ship/ship.cpp index 05e721e..c742d13 100644 --- a/src/ship/ship.cpp +++ b/src/ship/ship.cpp @@ -15,6 +15,9 @@ * Ship (and other object) handling functions * * $Log$ + * Revision 1.5 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:26 relnev * added copyright header * @@ -1192,11 +1195,11 @@ int parse_ship() required_string("$Rotation Time:"); stuff_vector(&sip->rotation_time); - sip->srotation_time = (sip->rotation_time.x + sip->rotation_time.y)/2.0f; + sip->srotation_time = (sip->rotation_time.xyz.x + sip->rotation_time.xyz.y)/2.0f; - sip->max_rotvel.x = (2 * PI) / sip->rotation_time.x; - sip->max_rotvel.y = (2 * PI) / sip->rotation_time.y; - sip->max_rotvel.z = (2 * PI) / sip->rotation_time.z; + sip->max_rotvel.xyz.x = (2 * PI) / sip->rotation_time.xyz.x; + sip->max_rotvel.xyz.y = (2 * PI) / sip->rotation_time.xyz.y; + sip->max_rotvel.xyz.z = (2 * PI) / sip->rotation_time.xyz.z; // get the backwards velocity; required_string("$Rear Velocity:"); @@ -1438,9 +1441,9 @@ int parse_ship() required_string("+Aburn Rec Rate:"); stuff_float(&sip->afterburner_recover_rate); } else { - sip->afterburner_max_vel.x = 0.0f; - sip->afterburner_max_vel.y = 0.0f; - sip->afterburner_max_vel.z = 0.0f; + sip->afterburner_max_vel.xyz.x = 0.0f; + sip->afterburner_max_vel.xyz.y = 0.0f; + sip->afterburner_max_vel.xyz.z = 0.0f; } required_string("$Countermeasures:"); @@ -1879,9 +1882,9 @@ void physics_ship_init(object *objp) pi->mass = pm->mass * sinfo->density; pi->I_body_inv = pm->moment_of_inertia; // scale pm->I_body_inv value by density - vm_vec_scale( &pi->I_body_inv.rvec, sinfo->density ); - vm_vec_scale( &pi->I_body_inv.uvec, sinfo->density ); - vm_vec_scale( &pi->I_body_inv.fvec, sinfo->density ); + vm_vec_scale( &pi->I_body_inv.v.rvec, sinfo->density ); + vm_vec_scale( &pi->I_body_inv.v.uvec, sinfo->density ); + vm_vec_scale( &pi->I_body_inv.v.fvec, sinfo->density ); pi->side_slip_time_const = sinfo->damp; pi->rotdamp = sinfo->rotdamp; @@ -1900,7 +1903,7 @@ void physics_ship_init(object *objp) pi->slide_accel_time_const=sinfo->slide_accel; pi->slide_decel_time_const=sinfo->slide_decel; - if ( (pi->max_vel.x > 0.000001f) || (pi->max_vel.y > 0.000001f) ) + if ( (pi->max_vel.xyz.x > 0.000001f) || (pi->max_vel.xyz.y > 0.000001f) ) pi->flags |= PF_SLIDE_ENABLED; vm_vec_zero(&pi->vel); @@ -2447,7 +2450,7 @@ void ship_render(object * obj) vector p0,v; vertex v0; - vm_vec_scale_add( &v, &obj->phys_info.vel, &obj->orient.fvec, 3.0f ); + vm_vec_scale_add( &v, &obj->phys_info.vel, &obj->orient.v.fvec, 3.0f ); vm_vec_normalize( &v ); @@ -3220,8 +3223,8 @@ void ship_dying_frame(object *objp, int ship_num) if ( timestamp_elapsed(Ships[ship_num].next_fireball)) { vector rand_vec, outpnt; // [0-.7 rad] in plane vm_vec_rand_vec_quick(&rand_vec); - float scale = -vm_vec_dotprod(&objp->orient.fvec, &rand_vec) * (0.9f + 0.2f * frand()); - vm_vec_scale_add2(&rand_vec, &objp->orient.fvec, scale); + float scale = -vm_vec_dotprod(&objp->orient.v.fvec, &rand_vec) * (0.9f + 0.2f * frand()); + vm_vec_scale_add2(&rand_vec, &objp->orient.v.fvec, scale); vm_vec_normalize_quick(&rand_vec); scale = objp->radius * frand() * 0.717f; vm_vec_scale(&rand_vec, scale); @@ -3242,7 +3245,7 @@ void ship_dying_frame(object *objp, int ship_num) pe.vel = objp->phys_info.vel; // Initial velocity of all the particles pe.min_life = 2.0f; // How long the particles live pe.max_life = 12.0f; // How long the particles live - pe.normal = objp->orient.uvec; // What normal the particle emit around + pe.normal = objp->orient.v.uvec; // What normal the particle emit around pe.normal_variance = 2.0f; // How close they stick to that normal 0=on normal, 1=180, 2=360 degree pe.min_vel = 50.0f; pe.max_vel = 350.0f; @@ -3346,7 +3349,7 @@ void ship_dying_frame(object *objp, int ship_num) pe.vel = objp->phys_info.vel; // Initial velocity of all the particles pe.min_life = 0.5f; // How long the particles live pe.max_life = 4.0f; // How long the particles live - pe.normal = objp->orient.uvec; // What normal the particle emit around + pe.normal = objp->orient.v.uvec; // What normal the particle emit around pe.normal_variance = 2.0f; // How close they stick to that normal 0=on normal, 1=180, 2=360 degree pe.min_vel = 0.0f; // How fast the slowest particle can move pe.max_vel = 20.0f; // How fast the fastest particle can move @@ -4812,7 +4815,7 @@ int ship_fire_primary_debug(object *objp) if (!stricmp(Weapon_info[i].name, NOX("Debug Laser"))) break; - vm_vec_add(&wpos, &objp->pos, &(objp->orient.fvec) ); + vm_vec_add(&wpos, &objp->pos, &(objp->orient.v.fvec) ); if (i != MAX_WEAPONS) { int weapon_objnum; weapon_objnum = weapon_create( &wpos, &objp->orient, i, OBJ_INDEX(objp), 0 ); @@ -4876,7 +4879,7 @@ int ship_launch_countermeasure(object *objp, int rand_val) cmeasure_count = shipp->cmeasure_count; shipp->cmeasure_count--; - vm_vec_scale_add(&pos, &objp->pos, &objp->orient.fvec, -objp->radius/2.0f); + vm_vec_scale_add(&pos, &objp->pos, &objp->orient.v.fvec, -objp->radius/2.0f); // cmeasure_create fires 1 countermeasure. returns -1 if not fired, otherwise a non-negative // value @@ -5237,7 +5240,7 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) weapon_set_tracking_info(weapon_objnum, OBJ_INDEX(obj), aip->target_objnum, aip->current_target_is_locked, aip->targeted_subsys); // create the muzzle flash effect - shipfx_flash_create( obj, shipp, &pnt, &obj->orient.fvec, 1, weapon ); + shipfx_flash_create( obj, shipp, &pnt, &obj->orient.v.fvec, 1, weapon ); // maybe shudder the ship - if its me if((winfo_p->wi_flags & WIF_SHUDDER) && (obj == Player_obj) && !(Game_mode & GM_STANDALONE_SERVER)){ @@ -5787,7 +5790,7 @@ int ship_fire_secondary( object *obj, int allow_swarm ) weapon_set_tracking_info(weapon_num, OBJ_INDEX(obj), aip->target_objnum, aip->current_target_is_locked, aip->targeted_subsys); // create the muzzle flash effect - shipfx_flash_create( obj, shipp, &pnt, &obj->orient.fvec, 0, weapon ); + shipfx_flash_create( obj, shipp, &pnt, &obj->orient.v.fvec, 0, weapon ); /* if ( weapon_num != -1 ) @@ -6431,7 +6434,7 @@ void ship_get_eye( vector *eye_pos, matrix *eye_orient, object *obj ) //} else { // model_find_world_dir( &vec, &ep->norm, shipp->modelnum, ep->parent, &obj->orient, &obj->pos ); // kind of bogus, but use the objects uvec to avoid totally stupid looking behavior. - // vm_vector_2_matrix(eye_orient,&vec,&obj->orient.uvec,NULL); + // vm_vector_2_matrix(eye_orient,&vec,&obj->orient.v.uvec,NULL); //} // Modify the orientation based on head orientation. @@ -7024,7 +7027,7 @@ void ship_assign_sound(ship *sp) sip = &Ship_info[sp->ship_info_index]; if ( sip->engine_snd != -1 ) { - vm_vec_copy_scale(&engine_pos, &objp->orient.fvec, -objp->radius/2.0f); + vm_vec_copy_scale(&engine_pos, &objp->orient.v.fvec, -objp->radius/2.0f); obj_snd_assign(sp->objnum, sip->engine_snd, &engine_pos, 1); } @@ -8262,12 +8265,12 @@ void ship_maybe_warn_player(ship *enemy_sp, float dist) vm_vec_normalized_dir(&vec_to_target, &Objects[enemy_sp->objnum].pos, &Eye_position); // ensure that enemy fighter is oriented towards player - fdot = vm_vec_dot(&Objects[enemy_sp->objnum].orient.fvec, &vec_to_target); + fdot = vm_vec_dot(&Objects[enemy_sp->objnum].orient.v.fvec, &vec_to_target); if ( fdot > -0.7 ) { return; } - fdot = vm_vec_dot(&Player_obj->orient.fvec, &vec_to_target); + fdot = vm_vec_dot(&Player_obj->orient.v.fvec, &vec_to_target); msg_type = -1; @@ -8286,7 +8289,7 @@ void ship_maybe_warn_player(ship *enemy_sp, float dist) } // ok, ship is on 3 or 9. Find out which - rdot = vm_vec_dot(&Player_obj->orient.rvec, &vec_to_target); + rdot = vm_vec_dot(&Player_obj->orient.v.rvec, &vec_to_target); if ( rdot > 0 ) { on_right = 1; } else { @@ -8294,7 +8297,7 @@ void ship_maybe_warn_player(ship *enemy_sp, float dist) } // now determine if ship is high or low - udot = vm_vec_dot(&Player_obj->orient.uvec, &vec_to_target); + udot = vm_vec_dot(&Player_obj->orient.v.uvec, &vec_to_target); if ( udot < -0.8 ) { return; // if ship is attacking from directly below, no warning given } @@ -9387,9 +9390,9 @@ int check_world_pt_in_expanded_ship_bbox(vector *world_pt, object *objp, float d pm = model_get(Ships[objp->instance].modelnum); return ( - (ship_pt.x > pm->mins.x - delta_box) && (ship_pt.x < pm->maxs.x + delta_box) - && (ship_pt.y > pm->mins.y - delta_box) && (ship_pt.y < pm->maxs.y + delta_box) - && (ship_pt.z > pm->mins.z - delta_box) && (ship_pt.z < pm->maxs.z + delta_box) + (ship_pt.xyz.x > pm->mins.xyz.x - delta_box) && (ship_pt.xyz.x < pm->maxs.xyz.x + delta_box) + && (ship_pt.xyz.y > pm->mins.xyz.y - delta_box) && (ship_pt.xyz.y < pm->maxs.xyz.y + delta_box) + && (ship_pt.xyz.z > pm->mins.xyz.z - delta_box) && (ship_pt.xyz.z < pm->maxs.xyz.z + delta_box) ); } @@ -9419,10 +9422,10 @@ float ship_get_max_speed(ship *shipp) max_speed = Ship_info[ship_info_index].max_overclocked_speed; // normal max speed - max_speed = max(max_speed, Ship_info[ship_info_index].max_vel.z); + max_speed = max(max_speed, Ship_info[ship_info_index].max_vel.xyz.z); // afterburn - max_speed = max(max_speed, Ship_info[ship_info_index].afterburner_max_vel.z); + max_speed = max(max_speed, Ship_info[ship_info_index].afterburner_max_vel.xyz.z); return max_speed; } @@ -9469,6 +9472,6 @@ int ship_get_species_by_type(int ship_info_index) float ship_get_length(ship* shipp) { polymodel *pm = model_get(shipp->modelnum); - return (pm->maxs.z - pm->mins.z); + return (pm->maxs.xyz.z - pm->mins.xyz.z); } diff --git a/src/ship/shipfx.cpp b/src/ship/shipfx.cpp index b8a384d..82ed39d 100644 --- a/src/ship/shipfx.cpp +++ b/src/ship/shipfx.cpp @@ -15,6 +15,9 @@ * Routines for ship effects (as in special) * * $Log$ + * Revision 1.4 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:26 relnev * added copyright header * @@ -578,8 +581,8 @@ static float shipfx_calculate_effect_radius( object *objp ) polymodel *pm = model_get( shipp->modelnum ); - w = pm->maxs.x - pm->mins.x; - h = pm->maxs.y - pm->mins.y; + w = pm->maxs.xyz.x - pm->mins.xyz.x; + h = pm->maxs.xyz.y - pm->mins.xyz.y; if ( w > h ) { rad = w / 2.0f; @@ -595,8 +598,8 @@ static float shipfx_calculate_effect_radius( object *objp ) pm = model_get( docked_shipp->modelnum ); - w = pm->maxs.x - pm->mins.x; - h = pm->maxs.y - pm->mins.y; + w = pm->maxs.xyz.x - pm->mins.xyz.x; + h = pm->maxs.xyz.y - pm->mins.xyz.y; if ( w > h ) { rad += w / 2.0f; @@ -724,9 +727,9 @@ void shipfx_warpin_start( object *objp ) Assert(!(Game_mode & GM_MULTIPLAYER)); polymodel *pm; pm = model_get(shipp->modelnum); - vm_vec_scale_add(&shipp->warp_effect_pos, &objp->pos, &objp->orient.fvec, -pm->mins.z); + vm_vec_scale_add(&shipp->warp_effect_pos, &objp->pos, &objp->orient.v.fvec, -pm->mins.xyz.z); } else { - vm_vec_scale_add( &shipp->warp_effect_pos, &objp->pos, &objp->orient.fvec, objp->radius ); + vm_vec_scale_add( &shipp->warp_effect_pos, &objp->pos, &objp->orient.v.fvec, objp->radius ); } // The ending zero mean this is a warp-in effect @@ -751,10 +754,10 @@ void shipfx_warpin_start( object *objp ) return; } - shipp->warp_effect_fvec = Objects[warp_objnum].orient.fvec; + shipp->warp_effect_fvec = Objects[warp_objnum].orient.v.fvec; // maybe negate if special warp effect if (shipp->special_warp_objnum >= 0) { - if (vm_vec_dotprod(&shipp->warp_effect_fvec, &objp->orient.fvec) < 0) { + if (vm_vec_dotprod(&shipp->warp_effect_fvec, &objp->orient.v.fvec) < 0) { vm_vec_negate(&shipp->warp_effect_fvec); } } @@ -796,13 +799,13 @@ void shipfx_warpin_frame( object *objp, float frametime ) // Make ship move at velocity so that it moves two radius's in warp_time seconds. vector vel; - vel = objp->orient.fvec; + vel = objp->orient.v.fvec; vm_vec_scale( &vel, speed ); objp->phys_info.vel = vel; objp->phys_info.desired_vel = vel; - objp->phys_info.prev_ramp_vel.x = 0.0f; - objp->phys_info.prev_ramp_vel.y = 0.0f; - objp->phys_info.prev_ramp_vel.z = speed; + objp->phys_info.prev_ramp_vel.xyz.x = 0.0f; + objp->phys_info.prev_ramp_vel.xyz.y = 0.0f; + objp->phys_info.prev_ramp_vel.xyz.z = speed; objp->phys_info.forward_thrust = 0.0f; // How much the forward thruster is applied. 0-1. shipp->final_warp_time = timestamp(fl2i(warp_time*1000.0f)); @@ -904,17 +907,17 @@ int compute_special_warpout_stuff(object *objp, float *speed, float *warp_time, // get facing normal from knossos vm_vec_sub(&vec_to_knossos, &sp_objp->pos, &objp->pos); - facing_normal = sp_objp->orient.fvec; - if (vm_vec_dotprod(&vec_to_knossos, &sp_objp->orient.fvec) > 0) { + facing_normal = sp_objp->orient.v.fvec; + if (vm_vec_dotprod(&vec_to_knossos, &sp_objp->orient.v.fvec) > 0) { vm_vec_negate(&facing_normal); } // find position to play the warp ani.. - dist_to_plane = fvi_ray_plane(warp_pos, &sp_objp->pos, &facing_normal, &objp->pos, &objp->orient.fvec, 0.0f); + dist_to_plane = fvi_ray_plane(warp_pos, &sp_objp->pos, &facing_normal, &objp->pos, &objp->orient.v.fvec, 0.0f); // calculate distance to warpout point. polymodel *pm = model_get(Ships[objp->instance].modelnum); - dist_to_plane += pm->mins.z; + dist_to_plane += pm->mins.xyz.z; if (dist_to_plane < 0) { mprintf(("warpout started too late\n")); @@ -927,7 +930,7 @@ int compute_special_warpout_stuff(object *objp, float *speed, float *warp_time, max_warpout_angle = 0.866f; // 30 degree half-angle cone for BIG or HUGE } - if (-vm_vec_dotprod(&objp->orient.fvec, &facing_normal) < max_warpout_angle) { // within allowed angle + if (-vm_vec_dotprod(&objp->orient.v.fvec, &facing_normal) < max_warpout_angle) { // within allowed angle Int3(); mprintf(("special warpout angle exceeded\n")); return -1; @@ -976,7 +979,7 @@ void compute_warpout_stuff(object *objp, float *speed, float *warp_time, vector *speed = shipfx_calculate_warp_speed(objp); if ( objp == Player_obj ) { - *speed = 0.8f*objp->phys_info.max_vel.z; + *speed = 0.8f*objp->phys_info.max_vel.xyz.z; } // Now we know our speed. Figure out how far the warp effect will be from here. @@ -997,10 +1000,10 @@ void compute_warpout_stuff(object *objp, float *speed, float *warp_time, vector // allow for off center if (Ship_info[Ships[objp->instance].ship_info_index].flags & SIF_HUGE_SHIP) { polymodel *pm = model_get(Ships[objp->instance].modelnum); - warp_dist -= pm->mins.z; + warp_dist -= pm->mins.xyz.z; } - vm_vec_scale_add( warp_pos, ¢er_pos, &objp->orient.fvec, warp_dist ); + vm_vec_scale_add( warp_pos, ¢er_pos, &objp->orient.v.fvec, warp_dist ); } // JAS - code to start the ship doing the warp out effect @@ -1080,10 +1083,10 @@ void shipfx_warpout_start( object *objp ) return; } - shipp->warp_effect_fvec = Objects[warp_objnum].orient.fvec; + shipp->warp_effect_fvec = Objects[warp_objnum].orient.v.fvec; // maybe negate if special warp effect if (shipp->special_warp_objnum >= 0) { - if (vm_vec_dotprod(&shipp->warp_effect_fvec, &objp->orient.fvec) > 0) { + if (vm_vec_dotprod(&shipp->warp_effect_fvec, &objp->orient.v.fvec) > 0) { vm_vec_negate(&shipp->warp_effect_fvec); } } @@ -1107,13 +1110,13 @@ void shipfx_warpout_start( object *objp ) // and keeps going if ( objp != Player_obj ) { vector vel; - vel = objp->orient.fvec; + vel = objp->orient.v.fvec; vm_vec_scale( &vel, speed ); objp->phys_info.vel = vel; objp->phys_info.desired_vel = vel; - objp->phys_info.prev_ramp_vel.x = 0.0f; - objp->phys_info.prev_ramp_vel.y = 0.0f; - objp->phys_info.prev_ramp_vel.z = speed; + objp->phys_info.prev_ramp_vel.xyz.x = 0.0f; + objp->phys_info.prev_ramp_vel.xyz.y = 0.0f; + objp->phys_info.prev_ramp_vel.xyz.z = speed; objp->phys_info.forward_thrust = 1.0f; // How much the forward thruster is applied. 0-1. // special case for HUGE ships @@ -1845,11 +1848,11 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) split_ship->front_ship.cur_clip_plane_pt = init_clip_plane_dist; float dist; - dist = (split_ship->front_ship.cur_clip_plane_pt+pm->maxs.z)/2.0f; - vm_vec_copy_scale(&split_ship->front_ship.local_pivot, &orient->fvec, dist); + dist = (split_ship->front_ship.cur_clip_plane_pt+pm->maxs.xyz.z)/2.0f; + vm_vec_copy_scale(&split_ship->front_ship.local_pivot, &orient->v.fvec, dist); vm_vec_make(&split_ship->front_ship.model_center_disp_to_orig_center, 0.0f, 0.0f, -dist); - dist = (split_ship->back_ship.cur_clip_plane_pt +pm->mins.z)/2.0f; - vm_vec_copy_scale(&split_ship->back_ship.local_pivot, &orient->fvec, dist); + dist = (split_ship->back_ship.cur_clip_plane_pt +pm->mins.xyz.z)/2.0f; + vm_vec_copy_scale(&split_ship->back_ship.local_pivot, &orient->v.fvec, dist); vm_vec_make(&split_ship->back_ship.model_center_disp_to_orig_center, 0.0f, 0.0f, -dist); vm_vec_add2(&split_ship->front_ship.local_pivot, &parent_ship_obj->pos ); vm_vec_add2(&split_ship->back_ship.local_pivot, &parent_ship_obj->pos ); @@ -1861,7 +1864,7 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) vector tmp1 = pm->submodel[pm->debris_objects[i]].offset; // tmp is world position, temp_pos is world_pivot, tmp1 is offset from world_pivot (in ship local coord) model_find_world_point(&tmp, &tmp1, shipp->modelnum, -1, &vmd_identity_matrix, &temp_pos ); - if (tmp.z > init_clip_plane_dist) { + if (tmp.xyz.z > init_clip_plane_dist) { split_ship->front_ship.draw_debris[i] = DEBRIS_DRAW; split_ship->back_ship.draw_debris[i] = DEBRIS_NONE; } else { @@ -1888,8 +1891,8 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) split_ship->back_ship.phys_info.rotdamp = 10000.0f; // set up explosion vel and relative velocities (assuming mass depends on length) - float front_length = pm->maxs.z - split_ship->front_ship.cur_clip_plane_pt; - float back_length = split_ship->back_ship.cur_clip_plane_pt - pm->mins.z; + float front_length = pm->maxs.xyz.z - split_ship->front_ship.cur_clip_plane_pt; + float back_length = split_ship->back_ship.cur_clip_plane_pt - pm->mins.xyz.z; float ship_length = front_length + back_length; split_ship->front_ship.length_left = front_length; split_ship->back_ship.length_left = back_length; @@ -1911,18 +1914,18 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) // set up rotational vel vector rotvel; vm_vec_rand_vec_quick(&rotvel); - rotvel.z = 0.0f; + rotvel.xyz.z = 0.0f; vm_vec_normalize(&rotvel); vm_vec_scale(&rotvel, 0.15f / speed_reduction_factor); split_ship->front_ship.phys_info.rotvel = rotvel; vm_vec_copy_scale(&split_ship->back_ship.phys_info.rotvel, &rotvel, -(front_length*front_length)/(back_length*back_length)); - split_ship->front_ship.phys_info.rotvel.z = parent_ship_obj->phys_info.rotvel.z; - split_ship->back_ship.phys_info.rotvel.z = parent_ship_obj->phys_info.rotvel.z; + split_ship->front_ship.phys_info.rotvel.xyz.z = parent_ship_obj->phys_info.rotvel.xyz.z; + split_ship->back_ship.phys_info.rotvel.xyz.z = parent_ship_obj->phys_info.rotvel.xyz.z; // modify vel of each split ship based on rotvel of parent ship obj vector temp_rotvel = parent_ship_obj->phys_info.rotvel; - temp_rotvel.z = 0.0f; + temp_rotvel.xyz.z = 0.0f; vector vel_from_rotvel; vm_vec_crossprod(&vel_from_rotvel, &temp_rotvel, &split_ship->front_ship.local_pivot); // vm_vec_scale_add2(&split_ship->front_ship.phys_info.vel, &vel_from_rotvel, 0.5f); @@ -1934,8 +1937,8 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) split_ship->back_ship.phys_info.vel = parent_ship_obj->phys_info.vel; maybe_fireball_wipe(&split_ship->front_ship, (int*)&split_ship->sound_handle); maybe_fireball_wipe(&split_ship->back_ship, (int*)&split_ship->sound_handle); - vm_vec_scale_add2(&split_ship->front_ship.phys_info.vel, &orient->fvec, front_vel); - vm_vec_scale_add2(&split_ship->back_ship.phys_info.vel, &orient->fvec, back_vel); + vm_vec_scale_add2(&split_ship->front_ship.phys_info.vel, &orient->v.fvec, front_vel); + vm_vec_scale_add2(&split_ship->back_ship.phys_info.vel, &orient->v.fvec, back_vel); // HANDLE LIVE DEBRIS - blow off if not already gone shipfx_maybe_create_live_debris_at_ship_death( parent_ship_obj ); @@ -1977,20 +1980,20 @@ static void half_ship_render_ship_and_debris(clip_ship* half_ship,ship *shipp) int create_debris = 0; // front ship if (half_ship->explosion_vel > 0) { - if (half_ship->cur_clip_plane_pt > tmp1.z + pm->submodel[pm->debris_objects[i]].max.z - 0.1f*half_ship->explosion_vel) { + if (half_ship->cur_clip_plane_pt > tmp1.xyz.z + pm->submodel[pm->debris_objects[i]].max.xyz.z - 0.1f*half_ship->explosion_vel) { create_debris = 1; } // is the debris visible -// if (half_ship->cur_clip_plane_pt > tmp1.z + pm->submodel[pm->debris_objects[i]].min.z - 0.5f*half_ship->explosion_vel) { +// if (half_ship->cur_clip_plane_pt > tmp1.xyz.z + pm->submodel[pm->debris_objects[i]].min.xyz.z - 0.5f*half_ship->explosion_vel) { // render_debris = 1; // } // back ship } else { - if (half_ship->cur_clip_plane_pt < tmp1.z + pm->submodel[pm->debris_objects[i]].min.z - 0.1f*half_ship->explosion_vel) { + if (half_ship->cur_clip_plane_pt < tmp1.xyz.z + pm->submodel[pm->debris_objects[i]].min.xyz.z - 0.1f*half_ship->explosion_vel) { create_debris = 1; } // is the debris visible -// if (half_ship->cur_clip_plane_pt < tmp1.z + pm->submodel[pm->debris_objects[i]].max.z - 0.5f*half_ship->explosion_vel) { +// if (half_ship->cur_clip_plane_pt < tmp1.xyz.z + pm->submodel[pm->debris_objects[i]].max.xyz.z - 0.5f*half_ship->explosion_vel) { // render_debris = 1; // } } @@ -2725,13 +2728,13 @@ void shipfx_do_shockwave_stuff(ship *shipp, shockwave_create_info *sci) if(pm == NULL){ return; } - head.x = pm->submodel[0].offset.x; - head.y = pm->submodel[0].offset.y; - head.z = pm->maxs.z; + head.xyz.x = pm->submodel[0].offset.xyz.x; + head.xyz.y = pm->submodel[0].offset.xyz.y; + head.xyz.z = pm->maxs.xyz.z; - tail.x = pm->submodel[0].offset.x; - tail.y = pm->submodel[0].offset.y; - tail.z = pm->mins.z; + tail.xyz.x = pm->submodel[0].offset.xyz.x; + tail.xyz.y = pm->submodel[0].offset.xyz.y; + tail.xyz.z = pm->mins.xyz.z; // transform the vectors into world coords vm_vec_unrotate(&temp, &head, &objp->orient); diff --git a/src/ship/shiphit.cpp b/src/ship/shiphit.cpp index b37a91f..529ab02 100644 --- a/src/ship/shiphit.cpp +++ b/src/ship/shiphit.cpp @@ -15,6 +15,9 @@ * Code to deal with a ship getting hit by something, be it a missile, dog, or ship. * * $Log$ + * Revision 1.5 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:26 relnev * added copyright header * @@ -1445,9 +1448,9 @@ void ship_hit_create_sparks(object *ship_obj, vector *hitpos, int submodel_num) vm_vec_sub(&diff, hitpos, &temp_zero); // find displacement from submodel origin in submodel RF - ship_p->sparks[n].pos.x = vm_vec_dotprod(&diff, &temp_x); - ship_p->sparks[n].pos.y = vm_vec_dotprod(&diff, &temp_y); - ship_p->sparks[n].pos.z = vm_vec_dotprod(&diff, &temp_z); + ship_p->sparks[n].pos.xyz.x = vm_vec_dotprod(&diff, &temp_x); + ship_p->sparks[n].pos.xyz.y = vm_vec_dotprod(&diff, &temp_y); + ship_p->sparks[n].pos.xyz.z = vm_vec_dotprod(&diff, &temp_z); ship_p->sparks[n].submodel_num = submodel_num; ship_p->sparks[n].end_time = timestamp(-1); } else { @@ -1472,9 +1475,9 @@ void player_died_start(object *killer_objp) nprintf(("Network", "starting my player death\n")); gameseq_post_event(GS_EVENT_DEATH_DIED); -/* vm_vec_scale_add(&Dead_camera_pos, &Player_obj->pos, &Player_obj->orient.fvec, -10.0f); - vm_vec_scale_add2(&Dead_camera_pos, &Player_obj->orient.uvec, 3.0f); - vm_vec_scale_add2(&Dead_camera_pos, &Player_obj->orient.rvec, 5.0f); +/* vm_vec_scale_add(&Dead_camera_pos, &Player_obj->pos, &Player_obj->orient.v.fvec, -10.0f); + vm_vec_scale_add2(&Dead_camera_pos, &Player_obj->orient.v.uvec, 3.0f); + vm_vec_scale_add2(&Dead_camera_pos, &Player_obj->orient.v.rvec, 5.0f); */ // Create a good vector for the camera to move along during death sequence. @@ -1514,9 +1517,9 @@ void player_died_start(object *killer_objp) other_objp = Player_obj; } - vm_vec_add(&Original_vec_to_deader, &Player_obj->orient.fvec, &Player_obj->orient.rvec); + vm_vec_add(&Original_vec_to_deader, &Player_obj->orient.v.fvec, &Player_obj->orient.v.rvec); vm_vec_scale(&Original_vec_to_deader, 2.0f); - vm_vec_add2(&Original_vec_to_deader, &Player_obj->orient.uvec); + vm_vec_add2(&Original_vec_to_deader, &Player_obj->orient.v.uvec); vm_vec_normalize(&Original_vec_to_deader); vector vec_from_killer; @@ -1527,7 +1530,7 @@ void player_died_start(object *killer_objp) if (Player_obj == other_objp) { dist = 50.0f; - vec_from_killer = Player_obj->orient.fvec; + vec_from_killer = Player_obj->orient.v.fvec; } else { dist = vm_vec_normalized_dir(&vec_from_killer, &Player_obj->pos, &other_objp->pos); } @@ -1536,11 +1539,11 @@ void player_died_start(object *killer_objp) dist = 100.0f; vm_vec_scale_add(&Dead_camera_pos, &Player_obj->pos, &vec_from_killer, dist); - float dot = vm_vec_dot(&Player_obj->orient.rvec, &vec_from_killer); + float dot = vm_vec_dot(&Player_obj->orient.v.rvec, &vec_from_killer); if (fl_abs(dot) > 0.8f) - side_vec = &Player_obj->orient.fvec; + side_vec = &Player_obj->orient.v.fvec; else - side_vec = &Player_obj->orient.rvec; + side_vec = &Player_obj->orient.v.rvec; vm_vec_scale_add2(&Dead_camera_pos, side_vec, 10.0f); @@ -1683,18 +1686,18 @@ void ship_generic_kill_stuff( object *objp, float percent_killed ) } else { // if added rotvel is too random, we should decrease the random component, putting a const in front of the rotvel. sp->deathroll_rotvel = objp->phys_info.rotvel; - sp->deathroll_rotvel.x += (frand() - 0.5f) * 2.0f * rotvel_mag; - saturate_fabs(&sp->deathroll_rotvel.x, 0.75f*DEATHROLL_ROTVEL_CAP); - sp->deathroll_rotvel.y += (frand() - 0.5f) * 3.0f * rotvel_mag; - saturate_fabs(&sp->deathroll_rotvel.y, 0.75f*DEATHROLL_ROTVEL_CAP); - sp->deathroll_rotvel.z += (frand() - 0.5f) * 6.0f * rotvel_mag; + sp->deathroll_rotvel.xyz.x += (frand() - 0.5f) * 2.0f * rotvel_mag; + saturate_fabs(&sp->deathroll_rotvel.xyz.x, 0.75f*DEATHROLL_ROTVEL_CAP); + sp->deathroll_rotvel.xyz.y += (frand() - 0.5f) * 3.0f * rotvel_mag; + saturate_fabs(&sp->deathroll_rotvel.xyz.y, 0.75f*DEATHROLL_ROTVEL_CAP); + sp->deathroll_rotvel.xyz.z += (frand() - 0.5f) * 6.0f * rotvel_mag; // make z component 2x larger than larger of x,y - float largest_mag = max(fl_abs(sp->deathroll_rotvel.x), fl_abs(sp->deathroll_rotvel.y)); - if (fl_abs(sp->deathroll_rotvel.z) < 2.0f*largest_mag) { - sp->deathroll_rotvel.z *= (2.0f * largest_mag / fl_abs(sp->deathroll_rotvel.z)); + float largest_mag = max(fl_abs(sp->deathroll_rotvel.xyz.x), fl_abs(sp->deathroll_rotvel.xyz.y)); + if (fl_abs(sp->deathroll_rotvel.xyz.z) < 2.0f*largest_mag) { + sp->deathroll_rotvel.xyz.z *= (2.0f * largest_mag / fl_abs(sp->deathroll_rotvel.xyz.z)); } - saturate_fabs(&sp->deathroll_rotvel.z, 0.75f*DEATHROLL_ROTVEL_CAP); - // nprintf(("Physics", "Frame: %i rotvel_mag: %5.2f, rotvel: (%4.2f, %4.2f, %4.2f)\n", Framecount, rotvel_mag, sp->deathroll_rotvel.x, sp->deathroll_rotvel.y, sp->deathroll_rotvel.z)); + saturate_fabs(&sp->deathroll_rotvel.xyz.z, 0.75f*DEATHROLL_ROTVEL_CAP); + // nprintf(("Physics", "Frame: %i rotvel_mag: %5.2f, rotvel: (%4.2f, %4.2f, %4.2f)\n", Framecount, rotvel_mag, sp->deathroll_rotvel.xyz.x, sp->deathroll_rotvel.xyz.y, sp->deathroll_rotvel.xyz.z)); } @@ -1924,7 +1927,7 @@ void ship_apply_whack(vector *force, vector *new_pos, object *objp) vector test; vm_vec_unrotate(&test, force, &objp->orient); - game_whack_apply( -test.x, -test.y ); + game_whack_apply( -test.xyz.x, -test.xyz.y ); } physics_apply_whack(force, new_pos, &objp->phys_info, &objp->orient, objp->phys_info.mass); @@ -2440,7 +2443,7 @@ void ship_apply_global_damage(object *ship_obj, object *other_obj, vector *force // Since an force_center wasn't specified, this is probably just a debug key // to kill an object. So pick a shield quadrant and a point on the // radius of the object. - vm_vec_scale_add( &world_hitpos, &ship_obj->pos, &ship_obj->orient.fvec, ship_obj->radius ); + vm_vec_scale_add( &world_hitpos, &ship_obj->pos, &ship_obj->orient.v.fvec, ship_obj->radius ); for (int i=0; iorient.fvec, &rand_vec, 0.5f); + vm_vec_scale_add(&direction_vec, &ship_obj->orient.v.fvec, &rand_vec, 0.5f); vm_vec_normalize_quick(&direction_vec); vm_vec_scale_add( &world_hitpos, &ship_obj->pos, &direction_vec, ship_obj->radius ); diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp index 748a74e..1908152 100644 --- a/src/sound/sound.cpp +++ b/src/sound/sound.cpp @@ -15,6 +15,9 @@ * Low-level sound code * * $Log$ + * Revision 1.8 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.7 2002/06/09 04:41:27 relnev * added copyright header * @@ -923,7 +926,7 @@ int snd_play_3d(game_snd *gs, vector *source_pos, vector *listen_pos, float radi pan = 0.0f; } else { - pan = vm_vec_dot(&View_matrix.rvec,&vector_to_sound); + pan = vm_vec_dot(&View_matrix.v.rvec,&vector_to_sound); } if(looping){ handle = snd_play_looping( gs, pan, -1, -1, volume/gs->default_volume, priority, force ); @@ -1009,7 +1012,7 @@ int snd_get_3d_vol_and_pan(game_snd *gs, vector *pos, float* vol, float *pan, fl if ( distance <= 0 ) *pan = 0.0f; else - *pan = vm_vec_dot(&View_matrix.rvec,&vector_to_sound); + *pan = vm_vec_dot(&View_matrix.v.rvec,&vector_to_sound); } return 0; diff --git a/src/starfield/nebula.cpp b/src/starfield/nebula.cpp index 11c3b0f..78e1456 100644 --- a/src/starfield/nebula.cpp +++ b/src/starfield/nebula.cpp @@ -15,6 +15,9 @@ * Code to load & display nebulas * * $Log$ + * Revision 1.6 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.5 2002/06/09 04:41:27 relnev * added copyright header * @@ -194,9 +197,9 @@ void project_2d_onto_sphere( vector *pnt, float u, float v ) s = scale_factor * fl_sqrt( 1.0f - z*z ); x = s * (float)cos(a); y = s * (float)sin(a); - pnt->x = x; - pnt->y = y; - pnt->z = z; + pnt->xyz.x = x; + pnt->xyz.y = y; + pnt->xyz.z = z; } // Version 199 mean major version=1, minor=99. diff --git a/src/starfield/starfield.cpp b/src/starfield/starfield.cpp index 21c6040..2b367f2 100644 --- a/src/starfield/starfield.cpp +++ b/src/starfield/starfield.cpp @@ -16,6 +16,9 @@ * debris, etc. * * $Log$ + * Revision 1.5 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:27 relnev * added copyright header * @@ -509,11 +512,11 @@ void stars_level_init() for (i=0; i= dist_max) { - v.x = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX); - v.y = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX); - v.z = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX); + v.xyz.x = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX); + v.xyz.y = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX); + v.xyz.z = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX); - dist = v.x * v.x + v.y * v.y + v.z * v.z; + dist = v.xyz.x * v.xyz.x + v.xyz.y * v.xyz.y + v.xyz.z * v.xyz.z; } vm_vec_copy_normalize(&Stars[i].pos, &v); } @@ -703,7 +706,7 @@ void stars_get_sun_pos(int sun_n, vector *pos) // rotate the sun properly temp = vmd_zero_vector; - temp.z = 1.0f; + temp.xyz.z = 1.0f; // rotation matrix vm_angles_2_matrix(&rot, &Suns[sun_n].ang); @@ -733,7 +736,7 @@ void stars_draw_sun( int show_sun ) // get sun pos sun_pos = vmd_zero_vector; - sun_pos.y = 1.0f; + sun_pos.xyz.y = 1.0f; stars_get_sun_pos(idx, &sun_pos); // get the direction @@ -779,7 +782,7 @@ void stars_draw_sun_glow(int sun_n) // get sun pos sun_pos = vmd_zero_vector; - sun_pos.y = 1.0f; + sun_pos.xyz.y = 1.0f; stars_get_sun_pos(sun_n, &sun_pos); // get the direction @@ -1087,9 +1090,9 @@ void stars_draw( int show_stars, int show_suns, int show_nebulas, int show_subsp for (sp=Stars,i=0; ipos); - sp->last_star_pos.x = p2.x; - sp->last_star_pos.y = p2.y; - sp->last_star_pos.z = p2.z; + sp->last_star_pos.xyz.x = p2.x; + sp->last_star_pos.xyz.y = p2.y; + sp->last_star_pos.xyz.z = p2.z; } } @@ -1137,9 +1140,9 @@ void stars_draw( int show_stars, int show_suns, int show_nebulas, int show_subsp } ratio *= Star_amount; - p1.x = p2.x + (sp->last_star_pos.x-p2.x)*ratio; - p1.y = p2.y + (sp->last_star_pos.y-p2.y)*ratio; - p1.z = p2.z + (sp->last_star_pos.z-p2.z)*ratio; + p1.x = p2.x + (sp->last_star_pos.xyz.x-p2.x)*ratio; + p1.y = p2.y + (sp->last_star_pos.xyz.y-p2.y)*ratio; + p1.z = p2.z + (sp->last_star_pos.xyz.z-p2.z)*ratio; p1.flags = 0; // not projected g3_code_vertex( &p1 ); @@ -1154,9 +1157,9 @@ void stars_draw( int show_stars, int show_suns, int show_nebulas, int show_subsp } } - sp->last_star_pos.x = p2.x; - sp->last_star_pos.y = p2.y; - sp->last_star_pos.z = p2.z; + sp->last_star_pos.xyz.x = p2.x; + sp->last_star_pos.xyz.y = p2.y; + sp->last_star_pos.xyz.z = p2.z; if ( !can_draw ) continue; @@ -1217,9 +1220,9 @@ void stars_draw( int show_stars, int show_suns, int show_nebulas, int show_subsp vertex p; if (!d->active) { - d->pos.x = f2fl(myrand() - RAND_MAX/2); - d->pos.y = f2fl(myrand() - RAND_MAX/2); - d->pos.z = f2fl(myrand() - RAND_MAX/2); + d->pos.xyz.x = f2fl(myrand() - RAND_MAX/2); + d->pos.xyz.y = f2fl(myrand() - RAND_MAX/2); + d->pos.xyz.z = f2fl(myrand() - RAND_MAX/2); vm_vec_normalize(&d->pos); diff --git a/src/starfield/supernova.cpp b/src/starfield/supernova.cpp index 84e9ffa..79c025f 100644 --- a/src/starfield/supernova.cpp +++ b/src/starfield/supernova.cpp @@ -15,6 +15,9 @@ * Include file for nebula stuff * * $Log$ + * Revision 1.4 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:27 relnev * added copyright header * @@ -341,9 +344,9 @@ void supernova_apply_shake(matrix *eye_orient, float intensity) matrix tm, tm2; vm_angles_2_matrix(&tm, &tangles); - Assert(vm_vec_mag(&tm.fvec) > 0.0f); - Assert(vm_vec_mag(&tm.rvec) > 0.0f); - Assert(vm_vec_mag(&tm.uvec) > 0.0f); + Assert(vm_vec_mag(&tm.v.fvec) > 0.0f); + Assert(vm_vec_mag(&tm.v.rvec) > 0.0f); + Assert(vm_vec_mag(&tm.v.uvec) > 0.0f); vm_matrix_x_matrix(&tm2, eye_orient, &tm); *eye_orient = tm2; } @@ -378,8 +381,8 @@ void supernova_set_view(vector *eye_pos, matrix *eye_orient) // always set the camera pos matrix whee; vm_vector_2_matrix(&whee, &move, NULL, NULL); - vm_vec_scale_add(&Supernova_camera_pos, &Player_obj->pos, &whee.rvec, sn_cam_distance); - vm_vec_scale_add2(&Supernova_camera_pos, &whee.uvec, 30.0f); + vm_vec_scale_add(&Supernova_camera_pos, &Player_obj->pos, &whee.v.rvec, sn_cam_distance); + vm_vec_scale_add2(&Supernova_camera_pos, &whee.v.uvec, 30.0f); *eye_pos = Supernova_camera_pos; // if we're no longer moving the camera diff --git a/src/weapon/beam.cpp b/src/weapon/beam.cpp index 92b3969..df28735 100644 --- a/src/weapon/beam.cpp +++ b/src/weapon/beam.cpp @@ -15,6 +15,9 @@ * all sorts of cool stuff about ships * * $Log$ + * Revision 1.5 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.4 2002/06/09 04:41:29 relnev * added copyright header * @@ -1049,7 +1052,7 @@ void beam_type_c_move(beam *b) temp = b->targeting_laser_offset; vm_vec_unrotate(&b->last_start, &temp, &b->objp->orient); vm_vec_add2(&b->last_start, &b->objp->pos); - vm_vec_scale_add(&b->last_shot, &b->last_start, &b->objp->orient.fvec, BEAM_FAR_LENGTH); + vm_vec_scale_add(&b->last_shot, &b->last_start, &b->objp->orient.v.fvec, BEAM_FAR_LENGTH); } // type D functions @@ -2155,7 +2158,7 @@ void beam_aim(beam *b) temp = b->targeting_laser_offset; vm_vec_unrotate(&b->last_start, &temp, &b->objp->orient); vm_vec_add2(&b->last_start, &b->objp->pos); - vm_vec_scale_add(&b->last_shot, &b->last_start, &b->objp->orient.fvec, BEAM_FAR_LENGTH); + vm_vec_scale_add(&b->last_shot, &b->last_start, &b->objp->orient.v.fvec, BEAM_FAR_LENGTH); break; case BEAM_TYPE_D: diff --git a/src/weapon/corkscrew.cpp b/src/weapon/corkscrew.cpp index b88dd03..e03c4ca 100644 --- a/src/weapon/corkscrew.cpp +++ b/src/weapon/corkscrew.cpp @@ -144,7 +144,7 @@ int cscrew_create(object *obj) // get the "center" pointing vector vector neg; - neg = obj->orient.uvec; + neg = obj->orient.v.uvec; if(Corkscrew_down_first){ vm_vec_negate(&neg); } @@ -225,7 +225,7 @@ void cscrew_process_post(object *objp) twist_val *= flFrametime; // rotate the missile position - vm_rot_point_around_line(&new_pt, &objp->pos, twist_val, &cen, &objp->orient.fvec); + vm_rot_point_around_line(&new_pt, &objp->pos, twist_val, &cen, &objp->orient.v.fvec); objp->pos = new_pt; // rotate the missile itself diff --git a/src/weapon/flak.cpp b/src/weapon/flak.cpp index 2711827..3f17891 100644 --- a/src/weapon/flak.cpp +++ b/src/weapon/flak.cpp @@ -15,6 +15,9 @@ * flak functions * * $Log$ + * Revision 1.4 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:29 relnev * added copyright header * @@ -202,7 +205,7 @@ void flak_jitter_aim(vector *dir, float dist_to_target, float weapon_subsys_stre if(rand_dist <= 0.0f){ return; } - vm_vec_copy_scale(&rand_twist_pre, &temp.rvec, rand_dist); + vm_vec_copy_scale(&rand_twist_pre, &temp.v.rvec, rand_dist); // now rotate the twist vector around the x axis (the base aim axis) at a random angle vm_rot_point_around_line(&rand_twist_post, &rand_twist_pre, fl_radian(359.0f * frand_range(0.0f, 1.0f)), &vmd_zero_vector, dir); diff --git a/src/weapon/swarm.cpp b/src/weapon/swarm.cpp index 52f3e89..2af9be2 100644 --- a/src/weapon/swarm.cpp +++ b/src/weapon/swarm.cpp @@ -15,6 +15,9 @@ * C module for managing swarm missiles * * $Log$ + * Revision 1.4 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:29 relnev * added copyright header * @@ -338,9 +341,9 @@ void swarm_update_direction(object *objp, float frametime) } } - vm_vec_scale_add(&swarmp->original_target, &objp->pos, &objp->orient.fvec, SWARM_CONE_LENGTH); - swarmp->circle_rvec = objp->orient.rvec; - swarmp->circle_uvec = objp->orient.uvec; + vm_vec_scale_add(&swarmp->original_target, &objp->pos, &objp->orient.v.fvec, SWARM_CONE_LENGTH); + swarmp->circle_rvec = objp->orient.v.rvec; + swarmp->circle_uvec = objp->orient.v.uvec; swarmp->change_count = 1; swarmp->change_time = fl2i(SWARM_CHANGE_DIR_TIME + SWARM_TIME_VARIANCE*(frand() - 0.5f) * 2); @@ -365,8 +368,8 @@ void swarm_update_direction(object *objp, float frametime) // Calculate a rvec and uvec that will determine the displacement from the // intended target. Use crossprod to generate a right vector, from the missile // up vector and the vector connecting missile to the homing object. - swarmp->circle_uvec = objp->orient.uvec; - swarmp->circle_rvec = objp->orient.rvec; + swarmp->circle_uvec = objp->orient.v.uvec; + swarmp->circle_rvec = objp->orient.v.rvec; missile_speed = pi->speed; missile_dist = missile_speed * swarmp->change_time/1000.0f; @@ -467,7 +470,7 @@ void swarm_update_direction(object *objp, float frametime) ai_turn_towards_vector(&swarmp->new_target, objp, frametime, wip->turn_time, NULL, NULL, 0.0f, 0); vel = vm_vec_mag(&objp->phys_info.desired_vel); - vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.fvec, vel); + vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.v.fvec, vel); } // ------------------------------------------------------------------ diff --git a/src/weapon/trails.cpp b/src/weapon/trails.cpp index d90b82e..9dc995b 100644 --- a/src/weapon/trails.cpp +++ b/src/weapon/trails.cpp @@ -15,6 +15,9 @@ * Code for missile trails * * $Log$ + * Revision 1.4 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.3 2002/06/09 04:41:29 relnev * added copyright header * @@ -283,9 +286,9 @@ void trail_render( trail * trailp ) } else { fvec = &tmp_fvec; - fvec->x = 0.0f; - fvec->y = 0.0f; - fvec->z = 1.0f; + fvec->xyz.x = 0.0f; + fvec->xyz.y = 0.0f; + fvec->xyz.z = 1.0f; } } else { vm_vec_sub(&tmp_fvec, &last_pos, &pos ); diff --git a/src/weapon/weapons.cpp b/src/weapon/weapons.cpp index 8e66ade..3a18dae 100644 --- a/src/weapon/weapons.cpp +++ b/src/weapon/weapons.cpp @@ -15,6 +15,9 @@ * Code to handle the weapon systems * * $Log$ + * Revision 1.7 2002/06/17 06:33:11 relnev + * ryan's struct patch for gcc 2.95 + * * Revision 1.6 2002/06/09 04:41:30 relnev * added copyright header * @@ -1535,7 +1538,7 @@ void weapon_render(object *obj) gr_set_bitmap(wip->laser_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.99999f); vector headp; - vm_vec_scale_add(&headp, &obj->pos, &obj->orient.fvec, wip->laser_length); + vm_vec_scale_add(&headp, &obj->pos, &obj->orient.v.fvec, wip->laser_length); wp->weapon_flags &= ~WF_CONSIDER_FOR_FLYBY_SOUND; if ( g3_draw_laser(&headp, wip->laser_head_radius, &obj->pos, wip->laser_tail_radius) ) { wp->weapon_flags |= WF_CONSIDER_FOR_FLYBY_SOUND; @@ -1548,7 +1551,7 @@ void weapon_render(object *obj) weapon_get_laser_color(&c, obj); vector headp2; - vm_vec_scale_add(&headp2, &obj->pos, &obj->orient.fvec, wip->laser_length * weapon_glow_scale_l); + vm_vec_scale_add(&headp2, &obj->pos, &obj->orient.v.fvec, wip->laser_length * weapon_glow_scale_l); gr_set_bitmap(wip->laser_glow_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, (gr_screen.mode == GR_DIRECT3D || gr_screen.mode == GR_OPENGL) ? weapon_glow_alpha_d3d : weapon_glow_alpha_glide); g3_draw_laser_rgb(&headp2, wip->laser_head_radius * weapon_glow_scale_f, &obj->pos, wip->laser_tail_radius * weapon_glow_scale_r, c.red, c.green, c.blue); } @@ -1747,7 +1750,7 @@ void find_homing_object(object *weapon_objp, int num) if (objp->type == OBJ_CMEASURE) dist *= 0.5f; - dot = vm_vec_dot(&vec_to_object, &weapon_objp->orient.fvec); + dot = vm_vec_dot(&vec_to_object, &weapon_objp->orient.v.fvec); if (dot > wip->fov) { if (dist < best_dist) { @@ -1811,7 +1814,7 @@ void find_homing_object_cmeasures_1(object *weapon_objp) if (objp->signature != wp->cmeasure_ignore_objnum) { - dot = vm_vec_dot(&vec_to_object, &weapon_objp->orient.fvec); + dot = vm_vec_dot(&vec_to_object, &weapon_objp->orient.v.fvec); if (dot > best_dot) { //nprintf(("Jim", "Frame %i: Weapon #%i homing on cmeasure #%i\n", Framecount, weapon_objp-Objects, objp->signature)); @@ -1909,10 +1912,10 @@ void weapon_home(object *obj, int num, float frame_time) if (obj->phys_info.speed > wip->max_speed) { obj->phys_info.speed -= frame_time * 4; - vm_vec_copy_scale( &obj->phys_info.desired_vel, &obj->orient.fvec, obj->phys_info.speed); + vm_vec_copy_scale( &obj->phys_info.desired_vel, &obj->orient.v.fvec, obj->phys_info.speed); } else if ((obj->phys_info.speed < wip->max_speed/4) && (wip->wi_flags & WIF_HOMING_HEAT)) { obj->phys_info.speed = wip->max_speed/4; - vm_vec_copy_scale( &obj->phys_info.desired_vel, &obj->orient.fvec, obj->phys_info.speed); + vm_vec_copy_scale( &obj->phys_info.desired_vel, &obj->orient.v.fvec, obj->phys_info.speed); } /* Removed code that makes bombs drop for a bit. They looked odd and it was confusing. People wondered where their weapons went. @@ -2101,7 +2104,7 @@ void weapon_home(object *obj, int num, float frame_time) wp->homing_pos = target_pos; Assert( !vm_is_vec_nan(&wp->homing_pos) ); - // nprintf(("AI", "Attack point = %7.3f %7.3f %7.3f\n", target_pos.x, target_pos.y, target_pos.z)); + // nprintf(("AI", "Attack point = %7.3f %7.3f %7.3f\n", target_pos.xyz.x, target_pos.xyz.y, target_pos.xyz.z)); } else target_pos = wp->homing_pos; } @@ -2190,17 +2193,17 @@ void weapon_home(object *obj, int num, float frame_time) Assert( obj->phys_info.speed > 0.0f ); - vm_vec_copy_scale( &obj->phys_info.desired_vel, &obj->orient.fvec, obj->phys_info.speed); + vm_vec_copy_scale( &obj->phys_info.desired_vel, &obj->orient.v.fvec, obj->phys_info.speed); // turn the missile towards the target only if non-swarm. Homing swarm missiles choose // a different vector to turn towards, this is done in swarm_update_direction(). // if ( !(wip->wi_flags & WIF_SWARM) ) { if ( wp->swarm_index < 0 ) { - // nprintf(("AI", "Dot, dist = %7.3f, %7.3f, target pos = %7.3f %7.3f %7.3f\n", old_dot, vm_vec_dist_quick(&obj->pos, &target_pos), target_pos.x, target_pos.y, target_pos.z)); + // nprintf(("AI", "Dot, dist = %7.3f, %7.3f, target pos = %7.3f %7.3f %7.3f\n", old_dot, vm_vec_dist_quick(&obj->pos, &target_pos), target_pos.xyz.x, target_pos.xyz.y, target_pos.xyz.z)); ai_turn_towards_vector(&target_pos, obj, frame_time, wip->turn_time, NULL, NULL, 0.0f, 0, NULL); vel = vm_vec_mag(&obj->phys_info.desired_vel); - vm_vec_copy_scale(&obj->phys_info.desired_vel, &obj->orient.fvec, vel); + vm_vec_copy_scale(&obj->phys_info.desired_vel, &obj->orient.v.fvec, vel); } @@ -2264,13 +2267,13 @@ void weapon_maybe_play_flyby_sound(object *weapon_objp, weapon *wp) vm_vec_normalize(&vec_to_weapon); // ensure laser is in front of eye - dot = vm_vec_dot(&vec_to_weapon, &Eye_matrix.fvec); + dot = vm_vec_dot(&vec_to_weapon, &Eye_matrix.v.fvec); if ( dot < 0.1 ) { return; } // ensure that laser is moving in similar direction to fvec - dot = vm_vec_dot(&vec_to_weapon, &weapon_objp->orient.fvec); + dot = vm_vec_dot(&vec_to_weapon, &weapon_objp->orient.v.fvec); // nprintf(("Alan", "Weapon dot: %.2f\n", dot)); if ( (dot < -0.80) && (dot > -0.98) ) { @@ -2395,7 +2398,7 @@ void weapon_process_post(object * obj, float frame_time) } vm_vec_normalized_dir(&tvec, &v0, &Objects[wp->target_num].pos); - dot = vm_vec_dot(&tvec, &Objects[wp->target_num].orient.fvec); + dot = vm_vec_dot(&tvec, &Objects[wp->target_num].orient.v.fvec); // nprintf(("AI", "Miss dot = %7.3f, dist = %7.3f, lead_scale = %7.3f\n", dot, cur_dist, lead_scale)); wp->target_num = -1; @@ -2673,7 +2676,7 @@ int weapon_create( vector * pos, matrix * orient, int weapon_id, int parent_objn objp->phys_info.side_slip_time_const = 0.0f; objp->phys_info.rotdamp = 0.0f; vm_vec_zero(&objp->phys_info.max_vel); - objp->phys_info.max_vel.z = wip->max_speed; + objp->phys_info.max_vel.xyz.z = wip->max_speed; vm_vec_zero(&objp->phys_info.max_rotvel); objp->shields[0] = wip->damage; if (wip->wi_flags & WIF_BOMB){ @@ -2695,7 +2698,7 @@ int weapon_create( vector * pos, matrix * orient, int weapon_id, int parent_objn // Note: If you change how speed works here, such as adding in speed of parent ship, you'll need to change the AI code // that predicts collision points. See Mike Kulas or Dave Andsager. (Or see ai_get_weapon_speed().) if (!(wip->wi_flags & WIF_HOMING)) { - vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.fvec, objp->phys_info.max_vel.z ); + vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.v.fvec, objp->phys_info.max_vel.xyz.z ); objp->phys_info.vel = objp->phys_info.desired_vel; objp->phys_info.speed = vm_vec_mag(&objp->phys_info.desired_vel); } else { @@ -2703,9 +2706,9 @@ int weapon_create( vector * pos, matrix * orient, int weapon_id, int parent_objn // Note that it is important to extract the forward component of the parent's velocity to factor out sliding, else // the missile will not be moving forward. if(parent_objp != NULL){ - vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.fvec, vm_vec_dot(&parent_objp->phys_info.vel, &parent_objp->orient.fvec) + objp->phys_info.max_vel.z/4 ); + vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.v.fvec, vm_vec_dot(&parent_objp->phys_info.vel, &parent_objp->orient.v.fvec) + objp->phys_info.max_vel.xyz.z/4 ); } else { - vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.fvec, objp->phys_info.max_vel.z/4 ); + vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.v.fvec, objp->phys_info.max_vel.xyz.z/4 ); } objp->phys_info.vel = objp->phys_info.desired_vel; objp->phys_info.speed = vm_vec_mag(&objp->phys_info.vel); @@ -3476,26 +3479,26 @@ void weapon_maybe_spew_particle(object *obj) // spew some particles for(idx=0; idxorient.fvec; + direct = obj->orient.v.fvec; vm_vec_negate(&direct); // randomly perturb x, y and z // uvec ang = fl_radian(frand_range(-90.0f, 90.0f)); - vm_rot_point_around_line(&direct_temp, &direct, ang, &null_vec, &obj->orient.fvec); + vm_rot_point_around_line(&direct_temp, &direct, ang, &null_vec, &obj->orient.v.fvec); direct = direct_temp; vm_vec_scale(&direct, Weapon_particle_spew_scale); // rvec ang = fl_radian(frand_range(-90.0f, 90.0f)); - vm_rot_point_around_line(&direct_temp, &direct, ang, &null_vec, &obj->orient.rvec); + vm_rot_point_around_line(&direct_temp, &direct, ang, &null_vec, &obj->orient.v.rvec); direct = direct_temp; vm_vec_scale(&direct, Weapon_particle_spew_scale); // fvec ang = fl_radian(frand_range(-90.0f, 90.0f)); - vm_rot_point_around_line(&direct_temp, &direct, ang, &null_vec, &obj->orient.uvec); + vm_rot_point_around_line(&direct_temp, &direct, ang, &null_vec, &obj->orient.v.uvec); direct = direct_temp; vm_vec_scale(&direct, Weapon_particle_spew_scale); @@ -3705,7 +3708,7 @@ int weapon_get_expl_handle(int weapon_expl_index, vector *pos, float size) vector temp; behind = 1; - vm_vec_scale_add(&temp, &Eye_position, &Eye_matrix.fvec, dist); + vm_vec_scale_add(&temp, &Eye_position, &Eye_matrix.v.fvec, dist); g3_rotate_vertex(&v, &temp); // if still behind, bail and go with default -- 2.39.2