[brlcad-commits] CVS: brlcad/src/librt g_pipe.c,14.29,14.30
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: John A. <joh...@us...> - 2007-08-21 23:45:44
|
Update of /cvsroot/brlcad/brlcad/src/librt In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8005 Modified Files: g_pipe.c Log Message: Added a bounding box check to linear pipe segments. moved the bounding box/sphere checks into rt_pipe_shot() Index: g_pipe.c =================================================================== RCS file: /cvsroot/brlcad/brlcad/src/librt/g_pipe.c,v retrieving revision 14.29 retrieving revision 14.30 diff -w -u -r14.29 -r14.30 --- g_pipe.c 21 Aug 2007 22:12:37 -0000 14.29 +++ g_pipe.c 21 Aug 2007 23:45:44 -0000 14.30 @@ -83,6 +83,8 @@ fastf_t pipe_len; /* length of pipe segment */ mat_t pipe_SoR; /* Scale and rotate */ mat_t pipe_invRoS; /* inverse rotation and scale */ + point_t pipe_min; + point_t pipe_max; }; struct bend_pipe @@ -286,24 +288,34 @@ bn_mat_mul( pipe->pipe_SoR, S, R ); bn_mat_mul( pipe->pipe_invRoS, Rinv, S ); + VSETALL( pipe->pipe_min, MAX_FASTF ); + VSETALL( pipe->pipe_max, -MAX_FASTF ); VJOIN2( work, pt1, od1, v1, od1, v2 ); PIPE_MM( work ) + VMINMAX( pipe->pipe_min, pipe->pipe_max, work ); VJOIN2( work, pt1, -od1, v1, od1, v2 ); PIPE_MM( work ) + VMINMAX( pipe->pipe_min, pipe->pipe_max, work ); VJOIN2( work, pt1, od1, v1, -od1, v2 ); PIPE_MM( work ) + VMINMAX( pipe->pipe_min, pipe->pipe_max, work ); VJOIN2( work, pt1, -od1, v1, -od1, v2 ); PIPE_MM( work ) + VMINMAX( pipe->pipe_min, pipe->pipe_max, work ); VJOIN2( work, pt2, od2, v1, od2, v2 ); PIPE_MM( work ) + VMINMAX( pipe->pipe_min, pipe->pipe_max, work ); VJOIN2( work, pt2, -od2, v1, od2, v2 ); PIPE_MM( work ) + VMINMAX( pipe->pipe_min, pipe->pipe_max, work ); VJOIN2( work, pt2, od2, v1, -od2, v2 ); PIPE_MM( work ) + VMINMAX( pipe->pipe_min, pipe->pipe_max, work ); VJOIN2( work, pt2, -od2, v1, -od2, v2 ); PIPE_MM( work ) + VMINMAX( pipe->pipe_min, pipe->pipe_max, work ); } @@ -611,10 +623,6 @@ *hit_count = 0; - if( !rt_in_sph( rp, pipe->bend_bound_center, pipe->bend_bound_radius_sq)) { - return; /* miss */ - } - or_sq = pipe->bend_or * pipe->bend_or; ir_sq = pipe->bend_ir * pipe->bend_ir; @@ -892,6 +900,7 @@ LOCAL double t_tmp; LOCAL double a,b,c; LOCAL double descrim; + LOCAL vect_t inv_dir; if( pipe->pipe_is_bend ) { @@ -1450,13 +1459,21 @@ if( !pipe_id->pipe_is_bend ) { - linear_pipe_shot( stp, rp, ap, seghead, (struct lin_pipe *)pipe_id, + struct lin_pipe *lin = (struct lin_pipe *)pipe_id; + if( !rt_in_rpp( rp, ap->a_inv_dir, lin->pipe_min, lin->pipe_max)) { + continue; + } + linear_pipe_shot( stp, rp, ap, seghead, lin, &hit_head, &hit_count, seg_no ); total_hits += hit_count; } else { - bend_pipe_shot( stp, rp, ap, seghead, (struct bend_pipe *)pipe_id, + struct bend_pipe *bend = (struct bend_pipe *)pipe_id; + if( !rt_in_sph( rp, bend->bend_bound_center, bend->bend_bound_radius_sq)) { + continue; + } + bend_pipe_shot( stp, rp, ap, seghead, bend, &hit_head, &hit_count, seg_no ); total_hits += hit_count; } |