2 * $Logfile: /Freespace2/code/Object/CollideDebrisWeapon.cpp $
7 * Routines to detect collisions and do physics, damage, etc for weapons and debris
10 * Revision 1.1 2002/05/03 03:28:10 root
14 * 4 7/15/99 9:20a Andsager
15 * FS2_DEMO initial checkin
17 * 3 10/16/98 1:22p Andsager
18 * clean up header files
20 * 2 10/07/98 10:53a Dave
23 * 1 10/07/98 10:50a Dave
25 * 7 4/02/98 6:29p Lawrance
26 * compile out asteroid references for demo
28 * 6 3/02/98 2:58p Mike
29 * Make "asteroids" in debug console turn asteroids on/off.
31 * 5 2/19/98 12:46a Lawrance
32 * Further work on asteroids.
34 * 4 2/05/98 12:51a Mike
35 * Early asteroid stuff.
37 * 3 1/13/98 8:09p John
38 * Removed the old collision system that checked all pairs. Added code
39 * to disable collisions and particles.
41 * 2 9/17/97 5:12p John
42 * Restructured collision routines. Probably broke a lot of stuff.
44 * 1 9/17/97 2:14p John
50 #include "objcollide.h"
55 // placeholder struct for ship_debris collisions
56 typedef struct ship_weapon_debris_struct {
58 object *debris_object;
59 vector ship_collision_cm_pos;
61 vector collision_normal;
63 vector shield_hit_tri_point;
65 } ship_weapon_debris_struct;
68 // Checks debris-weapon collisions. pair->a is debris and pair->b is weapon.
69 // Returns 1 if all future collisions between these can be ignored
70 int collide_debris_weapon( obj_pair * pair )
74 object *pdebris = pair->a;
75 object *weapon = pair->b;
77 Assert( pdebris->type == OBJ_DEBRIS );
78 Assert( weapon->type == OBJ_WEAPON );
80 // first check the bounding spheres of the two objects.
81 hit = fvi_segment_sphere(&hitpos, &weapon->last_pos, &weapon->pos, &pdebris->pos, pdebris->radius);
83 hit = debris_check_collision(pdebris, weapon, &hitpos );
87 weapon_hit( weapon, pdebris, &hitpos );
88 debris_hit( pdebris, weapon, &hitpos, Weapon_info[Weapons[weapon->instance].weapon_info_index].damage );
92 return weapon_will_never_hit( weapon, pdebris, pair );
98 // Checks debris-weapon collisions. pair->a is debris and pair->b is weapon.
99 // Returns 1 if all future collisions between these can be ignored
100 int collide_asteroid_weapon( obj_pair * pair )
104 if (!Asteroids_enabled)
109 object *pasteroid = pair->a;
110 object *weapon = pair->b;
112 Assert( pasteroid->type == OBJ_ASTEROID);
113 Assert( weapon->type == OBJ_WEAPON );
115 // first check the bounding spheres of the two objects.
116 hit = fvi_segment_sphere(&hitpos, &weapon->last_pos, &weapon->pos, &pasteroid->pos, pasteroid->radius);
118 hit = asteroid_check_collision(pasteroid, weapon, &hitpos );
122 weapon_hit( weapon, pasteroid, &hitpos );
123 asteroid_hit( pasteroid, weapon, &hitpos, Weapon_info[Weapons[weapon->instance].weapon_info_index].damage );
127 return weapon_will_never_hit( weapon, pasteroid, pair );