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

Function check_vector_to_object

physics/findintersection.cpp:1747–1808  ·  view source on GitHub ↗

determine if a vector intersects with an object if no intersects, returns 0, else fills in intp and returns dist

Source from the content-addressed store, hash-verified

1745// determine if a vector intersects with an object
1746// if no intersects, returns 0, else fills in intp and returns dist
1747int check_vector_to_object(vector *intp, float *col_dist, vector *p0, vector *p1, float rad, object *still_obj,
1748 object *fvi_obj) {
1749 float still_size;
1750 vector still_pos = still_obj->pos;
1751 float total_size;
1752
1753 int fvi_objnum = fvi_query_ptr->thisobjnum;
1754
1755 if ((still_obj->flags & OF_POLYGON_OBJECT) && still_obj->type != OBJ_POWERUP && still_obj->type != OBJ_WEAPON &&
1756 still_obj->type != OBJ_DEBRIS && still_obj->type != OBJ_ROOM && still_obj->type != OBJ_PLAYER) {
1757 still_size = Poly_models[still_obj->rtype.pobj_info.model_num].anim_size;
1758 still_pos += still_obj->anim_sphere_offset;
1759 } else {
1760 still_size = still_obj->size;
1761 }
1762
1763 // chrishack -- why?
1764 // if (obj->type == OBJ_ROBOT && Robot_info[obj->id].attack_type)
1765 // size = (size*3)/4;
1766 // if obj is player, and bumping into other player or a weapon of another coop player, reduce radius
1767 // if (obj->type == OBJ_PLAYER &&
1768 // ((otherobj->type == OBJ_PLAYER) ||
1769 // ((Game_mode&GM_MULTI_COOP) && otherobj->type == OBJ_WEAPON &&
1770 // otherobj->ctype.laser_info.parent_type
1771 //== OBJ_PLAYER))) size = size/2;
1772
1773 // This accounts for relative position vs. relative velocity
1774 if (fvi_objnum != -1 && still_obj->movement_type == MT_PHYSICS && Objects[fvi_objnum].movement_type == MT_PHYSICS) {
1775 if (still_obj->type != OBJ_POWERUP && Objects[fvi_objnum].type != OBJ_POWERUP) {
1776 if ((still_pos - Objects[fvi_objnum].pos) *
1777 (still_obj->mtype.phys_info.velocity - Objects[fvi_objnum].mtype.phys_info.velocity) >=
1778 0) {
1779#ifndef NED_PHYSICS
1780#ifdef _DEBUG
1781 if (Physics_player_verbose) {
1782 if (Player_object == &Objects[fvi_objnum]) {
1783 mprintf(0, "FVI: Earily exit on %d\n", OBJNUM(still_obj));
1784 }
1785 }
1786#endif
1787#endif
1788
1789 return 0;
1790 }
1791 }
1792 }
1793
1794 total_size = still_size + rad;
1795
1796 if (total_size <= 0.0f) {
1797#ifdef _DEBUG
1798 if (fvi_objnum >= 0)
1799 mprintf(0, "Get Chris: type %d and type %d are zero radius\n", still_obj->type, Objects[fvi_objnum].type);
1800 else
1801 mprintf(0, "Get Chris: A non-object tried to hit a zero radii object of type %d\n", still_obj->type);
1802#endif
1803 return 0;
1804 }

Callers 1

check_hit_objFunction · 0.85

Calls 1

check_vector_to_sphere_1Function · 0.85

Tested by

no test coverage detected