MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / collide_player_and_player

Function collide_player_and_player

physics/collide.cpp:2038–2065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2036}
2037
2038void collide_player_and_player(object *p1, object *p2, vector *collision_point, vector *collision_normal,
2039 bool f_reverse_normal, fvi_info *hit_info) {
2040 if (f_reverse_normal)
2041 *collision_normal *= -1.0f;
2042
2043 vector rvel = p1->mtype.phys_info.velocity - p2->mtype.phys_info.velocity;
2044 float speed = vm_NormalizeVector(&rvel);
2045 float scalar;
2046
2047 if (speed <= MIN_WALL_HIT_SOUND_VEL) {
2048 scalar = 0.0f;
2049 } else if (speed >= MAX_WALL_HIT_SOUND_VEL) {
2050 scalar = 1.0f;
2051 } else {
2052 scalar = (speed - MIN_WALL_HIT_SOUND_VEL) / (MAX_WALL_HIT_SOUND_VEL - MIN_WALL_HIT_SOUND_VEL);
2053 }
2054
2055 if (scalar > .01) {
2056 pos_state cur_pos;
2057 cur_pos.position = collision_point;
2058 cur_pos.orient = &p1->orient;
2059 cur_pos.roomnum = p1->roomnum;
2060
2061 Sound_system.Play3dSound(SOUND_PLAYER_HIT_WALL, SND_PRIORITY_HIGHEST, &cur_pos, MAX_GAME_VOLUME * scalar);
2062 }
2063
2064 bump_two_objects(p1, p2, collision_point, collision_normal, 1);
2065}
2066
2067void collide_generic_and_player(object *robotobj, object *playerobj, vector *collision_point, vector *collision_normal,
2068 bool f_reverse_normal, fvi_info *hit_info) {

Callers

nothing calls this directly

Calls 3

vm_NormalizeVectorFunction · 0.85
Play3dSoundMethod · 0.80
bump_two_objectsFunction · 0.70

Tested by

no test coverage detected