From 319b3ec5fd49caf7dba291c09310d3926bf7aa7a Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 23 Jun 2012 22:16:33 +0000 Subject: [PATCH] Mark more math as const correct --- common/main/fvi.h | 2 +- d1x-rebirth/main/fvi.c | 14 +++++++------- d2x-rebirth/main/fvi.c | 36 ++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/common/main/fvi.h b/common/main/fvi.h index 8ba6f0089..24d480400 100644 --- a/common/main/fvi.h +++ b/common/main/fvi.h @@ -77,7 +77,7 @@ int find_vector_intersection(fvi_query *fq,fvi_info *hit_data); //finds the uv coords of the given point on the given seg & side //fills in u & v. if l is non-NULL fills it in also -void find_hitpoint_uv(fix *u,fix *v,fix *l, vms_vector *pnt,segment *seg,int sidenum,int facenum); +void find_hitpoint_uv(fix *u,fix *v,fix *l, const vms_vector *pnt,const segment *seg,int sidenum,int facenum); //Returns true if the object is through any walls int object_intersects_wall(object *objp); diff --git a/d1x-rebirth/main/fvi.c b/d1x-rebirth/main/fvi.c index c130b78c5..b4a3c5246 100644 --- a/d1x-rebirth/main/fvi.c +++ b/d1x-rebirth/main/fvi.c @@ -1093,15 +1093,15 @@ quit_looking: //finds the uv coords of the given point on the given seg & side //fills in u & v -void find_hitpoint_uv(fix *u,fix *v,fix *l,vms_vector *pnt,segment *seg,int sidenum,int facenum) +void find_hitpoint_uv(fix *u,fix *v,fix *l,const vms_vector *pnt,const segment *seg,int sidenum,int facenum) { (void)l; - vms_vector_array *pnt_array; + const vms_vector_array *pnt_array; vms_vector_array normal_array; int segnum = seg-Segments; int num_faces; int biggest,ii,jj; - side *side = &seg->sides[sidenum]; + const side *side = &seg->sides[sidenum]; int vertex_list[6],vertnum_list[6]; vec2d p1,vec0,vec1,checkp; //@@,checkv; uvl uvls[3]; @@ -1135,21 +1135,21 @@ void find_hitpoint_uv(fix *u,fix *v,fix *l,vms_vector *pnt,segment *seg,int side //2. compute u,v of intersection point //vec from 1 -> 0 - pnt_array = (vms_vector_array *)&Vertices[vertex_list[facenum*3+1]]; + pnt_array = (const vms_vector_array *)&Vertices[vertex_list[facenum*3+1]]; p1.i = pnt_array->xyz[ii]; p1.j = pnt_array->xyz[jj]; - pnt_array = (vms_vector_array *)&Vertices[vertex_list[facenum*3+0]]; + pnt_array = (const vms_vector_array *)&Vertices[vertex_list[facenum*3+0]]; vec0.i = pnt_array->xyz[ii] - p1.i; vec0.j = pnt_array->xyz[jj] - p1.j; //vec from 1 -> 2 - pnt_array = (vms_vector_array *)&Vertices[vertex_list[facenum*3+2]]; + pnt_array = (const vms_vector_array *)&Vertices[vertex_list[facenum*3+2]]; vec1.i = pnt_array->xyz[ii] - p1.i; vec1.j = pnt_array->xyz[jj] - p1.j; //vec from 1 -> checkpoint - pnt_array = (vms_vector_array *)pnt; + pnt_array = (const vms_vector_array *)pnt; checkp.i = pnt_array->xyz[ii]; checkp.j = pnt_array->xyz[jj]; diff --git a/d2x-rebirth/main/fvi.c b/d2x-rebirth/main/fvi.c index 2b7612292..42dd26abe 100644 --- a/d2x-rebirth/main/fvi.c +++ b/d2x-rebirth/main/fvi.c @@ -42,7 +42,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //new_pnt is the found point on the plane //plane_pnt & plane_norm describe the plane //p0 & p1 are the ends of the line -int find_plane_line_intersection(vms_vector *new_pnt,vms_vector *plane_pnt,vms_vector *plane_norm,vms_vector *p0,vms_vector *p1,fix rad) +static int find_plane_line_intersection(vms_vector *new_pnt,const vms_vector *plane_pnt,const vms_vector *plane_norm,const vms_vector *p0,const vms_vector *p1,fix rad) { vms_vector d,w; fix num,den; @@ -80,7 +80,7 @@ typedef struct vec2d { //given largest componant of normal, return i & j //if largest componant is negative, swap i & j -int ij_table[3][2] = { +static const int ij_table[3][2] = { {2,1}, //pos x biggest {0,2}, //pos y biggest {1,0}, //pos z biggest @@ -93,7 +93,7 @@ int ij_table[3][2] = { #define IT_POINT 3 //touches vertex //see if a point in inside a face by projecting into 2d -uint check_point_to_face(vms_vector *checkp, side *s,int facenum,int nv,int *vertex_list) +static uint check_point_to_face(const vms_vector *checkp, const side *s,int facenum,int nv, const int *vertex_list) { vms_vector_array *checkp_array; vms_vector_array norm; @@ -159,7 +159,7 @@ uint check_point_to_face(vms_vector *checkp, side *s,int facenum,int nv,int *ver //check if a sphere intersects a face -int check_sphere_to_face(vms_vector *pnt, side *s,int facenum,int nv,fix rad,int *vertex_list) +static int check_sphere_to_face(const vms_vector *pnt, const side *s,int facenum,int nv,fix rad,const int *vertex_list) { vms_vector checkp=*pnt; uint edgemask; @@ -230,11 +230,11 @@ int check_sphere_to_face(vms_vector *pnt, side *s,int facenum,int nv,fix rad,int //point on plane, whether or not line intersects side //facenum determines which of four possible faces we have //note: the seg parm is temporary, until the face itself has a point field -int check_line_to_face(vms_vector *newp,vms_vector *p0,vms_vector *p1,segment *seg,int side,int facenum,int nv,fix rad) +static int check_line_to_face(vms_vector *newp,const vms_vector *p0,const vms_vector *p1,const segment *seg,int side,int facenum,int nv,fix rad) { vms_vector checkp; int pli; - struct side *s=&seg->sides[side]; + const struct side *s=&seg->sides[side]; int vertex_list[6]; int num_faces; int vertnum; @@ -291,7 +291,7 @@ fix calc_det_value(vms_matrix *det) //computes the parameters of closest approach of two lines //fill in two parameters, t0 & t1. returns 0 if lines are parallel, else 1 -int check_line_to_line(fix *t1,fix *t2,vms_vector *p1,vms_vector *v1,vms_vector *p2,vms_vector *v2) +static int check_line_to_line(fix *t1,fix *t2,const vms_vector *p1,const vms_vector *v1,const vms_vector *p2,const vms_vector *v2) { vms_matrix det; fix d,cross_mag2; //mag squared cross product @@ -317,7 +317,7 @@ int check_line_to_line(fix *t1,fix *t2,vms_vector *p1,vms_vector *v1,vms_vector //this version is for when the start and end positions both poke through //the plane of a side. In this case, we must do checks against the edge //of faces -int special_check_line_to_face(vms_vector *newp,vms_vector *p0,vms_vector *p1,segment *seg,int side,int facenum,int nv,fix rad) +static int special_check_line_to_face(vms_vector *newp,const vms_vector *p0,const vms_vector *p1,const segment *seg,int side,int facenum,int nv,fix rad) { vms_vector move_vec; fix edge_t=0,move_t=0,edge_t2=0,move_t2=0,closest_dist=0; @@ -326,7 +326,7 @@ int special_check_line_to_face(vms_vector *newp,vms_vector *p0,vms_vector *p1,se int num_faces,edgenum; uint edgemask; vms_vector *edge_v0,*edge_v1,edge_vec; - struct side *s=&seg->sides[side]; + const struct side *s=&seg->sides[side]; vms_vector closest_point_edge,closest_point_move; //calc some basic stuff @@ -412,7 +412,7 @@ int special_check_line_to_face(vms_vector *newp,vms_vector *p0,vms_vector *p1,se //vector defined by p0,p1 //returns dist if intersects, and fills in intp //else returns 0 -int check_vector_to_sphere_1(vms_vector *intp,vms_vector *p0,vms_vector *p1,vms_vector *sphere_pos,fix sphere_rad) +static int check_vector_to_sphere_1(vms_vector *intp,const vms_vector *p0,const vms_vector *p1,const vms_vector *sphere_pos,fix sphere_rad) { vms_vector d,dn,w,closest_point; fix mag_d,dist,w_dist,int_dist; @@ -578,7 +578,7 @@ int check_vector_to_sphere_1(vms_vector *intp,vms_vector *p0,vms_vector *p1,vms_ //determine if a vector intersects with an object //if no intersects, returns 0, else fills in intp and returns dist -fix check_vector_to_object(vms_vector *intp,vms_vector *p0,vms_vector *p1,fix rad,object *obj,object *otherobj) +static fix check_vector_to_object(vms_vector *intp,const vms_vector *p0,const vms_vector *p1,fix rad,const object *obj,const object *otherobj) { fix size = obj->size; @@ -610,7 +610,7 @@ int fvi_hit_side_seg;// what seg the hitside is in vms_vector wall_norm; //ptr to surface normal of hit wall int fvi_hit_seg2; // what segment the hit point is in -int fvi_sub(vms_vector *intp,int *ints,vms_vector *p0,int startseg,vms_vector *p1,fix rad,short thisobjnum,int *ignore_obj_list,int flags,int *seglist,int *n_segs,int entry_seg); +static int fvi_sub(vms_vector *intp,int *ints,const vms_vector *p0,int startseg,const vms_vector *p1,fix rad,short thisobjnum,const int *ignore_obj_list,int flags,int *seglist,int *n_segs,int entry_seg); //What the hell is fvi_hit_seg for??? @@ -767,7 +767,7 @@ if (hit_seg!=-1 && fq->flags&FQ_GET_SEGLIST) //--unused-- return vm_vec_dist(v0,v1); //--unused-- } -int obj_in_list(int objnum,int *obj_list) +int obj_in_list(int objnum,const int *obj_list) { int t; @@ -779,7 +779,7 @@ int obj_in_list(int objnum,int *obj_list) int check_trans_wall(vms_vector *pnt,segment *seg,int sidenum,int facenum); -int fvi_sub(vms_vector *intp,int *ints,vms_vector *p0,int startseg,vms_vector *p1,fix rad,short thisobjnum,int *ignore_obj_list,int flags,int *seglist,int *n_segs,int entry_seg) +static int fvi_sub(vms_vector *intp,int *ints,const vms_vector *p0,int startseg,const vms_vector *p1,fix rad,short thisobjnum,const int *ignore_obj_list,int flags,int *seglist,int *n_segs,int entry_seg) { segment *seg; //the segment we're looking at int startmask,endmask; //mask of faces @@ -1095,14 +1095,14 @@ quit_looking: //finds the uv coords of the given point on the given seg & side //fills in u & v. if l is non-NULL fills it in also -void find_hitpoint_uv(fix *u,fix *v,fix *l,vms_vector *pnt,segment *seg,int sidenum,int facenum) +void find_hitpoint_uv(fix *u,fix *v,fix *l,const vms_vector *pnt,const segment *seg,int sidenum,int facenum) { - vms_vector_array *pnt_array; + const vms_vector_array *pnt_array; vms_vector_array normal_array; int segnum = seg-Segments; int num_faces; int biggest,ii,jj; - side *side = &seg->sides[sidenum]; + const side *side = &seg->sides[sidenum]; int vertex_list[6],vertnum_list[6]; vec2d p1,vec0,vec1,checkp; //@@,checkv; uvl uvls[3]; @@ -1158,7 +1158,7 @@ void find_hitpoint_uv(fix *u,fix *v,fix *l,vms_vector *pnt,segment *seg,int side vec1.j = pnt_array->xyz[jj] - p1.j; //vec from 1 -> checkpoint - pnt_array = (vms_vector_array *)pnt; + pnt_array = (const vms_vector_array *)pnt; checkp.i = pnt_array->xyz[ii]; checkp.j = pnt_array->xyz[jj];