2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Object/CollideDebrisWeapon.cpp $
15 * Routines to detect collisions and do physics, damage, etc for weapons and debris
18 * Revision 1.3 2003/05/25 02:30:43 taylor
21 * Revision 1.2 2002/06/09 04:41:24 relnev
22 * added copyright header
24 * Revision 1.1.1.1 2002/05/03 03:28:10 root
28 * 4 7/15/99 9:20a Andsager
29 * FS2_DEMO initial checkin
31 * 3 10/16/98 1:22p Andsager
32 * clean up header files
34 * 2 10/07/98 10:53a Dave
37 * 1 10/07/98 10:50a Dave
39 * 7 4/02/98 6:29p Lawrance
40 * compile out asteroid references for demo
42 * 6 3/02/98 2:58p Mike
43 * Make "asteroids" in debug console turn asteroids on/off.
45 * 5 2/19/98 12:46a Lawrance
46 * Further work on asteroids.
48 * 4 2/05/98 12:51a Mike
49 * Early asteroid stuff.
51 * 3 1/13/98 8:09p John
52 * Removed the old collision system that checked all pairs. Added code
53 * to disable collisions and particles.
55 * 2 9/17/97 5:12p John
56 * Restructured collision routines. Probably broke a lot of stuff.
58 * 1 9/17/97 2:14p John
64 #include "objcollide.h"
69 // placeholder struct for ship_debris collisions
70 typedef struct ship_weapon_debris_struct {
72 object *debris_object;
73 vector ship_collision_cm_pos;
75 vector collision_normal;
77 vector shield_hit_tri_point;
79 } ship_weapon_debris_struct;
82 // Checks debris-weapon collisions. pair->a is debris and pair->b is weapon.
83 // Returns 1 if all future collisions between these can be ignored
84 int collide_debris_weapon( obj_pair * pair )
88 object *pdebris = pair->a;
89 object *weapon = pair->b;
91 SDL_assert( pdebris->type == OBJ_DEBRIS );
92 SDL_assert( weapon->type == OBJ_WEAPON );
94 // first check the bounding spheres of the two objects.
95 hit = fvi_segment_sphere(&hitpos, &weapon->last_pos, &weapon->pos, &pdebris->pos, pdebris->radius);
97 hit = debris_check_collision(pdebris, weapon, &hitpos );
101 weapon_hit( weapon, pdebris, &hitpos );
102 debris_hit( pdebris, weapon, &hitpos, Weapon_info[Weapons[weapon->instance].weapon_info_index].damage );
106 return weapon_will_never_hit( weapon, pdebris, pair );
112 // Checks debris-weapon collisions. pair->a is debris and pair->b is weapon.
113 // Returns 1 if all future collisions between these can be ignored
114 int collide_asteroid_weapon( obj_pair * pair )
116 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
118 if (!Asteroids_enabled)
123 object *pasteroid = pair->a;
124 object *weapon = pair->b;
126 SDL_assert( pasteroid->type == OBJ_ASTEROID);
127 SDL_assert( weapon->type == OBJ_WEAPON );
129 // first check the bounding spheres of the two objects.
130 hit = fvi_segment_sphere(&hitpos, &weapon->last_pos, &weapon->pos, &pasteroid->pos, pasteroid->radius);
132 hit = asteroid_check_collision(pasteroid, weapon, &hitpos );
136 weapon_hit( weapon, pasteroid, &hitpos );
137 asteroid_hit( pasteroid, weapon, &hitpos, Weapon_info[Weapons[weapon->instance].weapon_info_index].damage );
141 return weapon_will_never_hit( weapon, pasteroid, pair );