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

Function PhysComputeWalkerPosOrient

physics/physics.cpp:1659–1768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1657}
1658
1659bool PhysComputeWalkerPosOrient(object *obj, vector *pos, matrix *orient) {
1660 vector pnt[3];
1661 vector tpnt = obj->pos;
1662 matrix tmatrix = obj->orient;
1663 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
1664 int num_gps = (pm->n_ground == 5) ? 3 : 1;
1665 int i;
1666
1667 bool f_ok = true;
1668
1669 obj->pos = *pos;
1670 obj->orient = *orient;
1671
1672 for (i = 0; i < num_gps; i++) {
1673 PhysCalcGround(&pnt[i], NULL, obj, i);
1674 }
1675
1676 obj->pos = tpnt;
1677 obj->orient = tmatrix;
1678
1679 if (num_gps == 3) {
1680 vector pp[3];
1681 float pdist[3];
1682 int proom[3];
1683 vector hp[3];
1684
1685 for (i = 0; i < 3; i++)
1686 PhysCalPntOnCPntPlane(obj, &pnt[i], &pp[i], &pdist[i]);
1687
1688 // Moves the points to valid locations in the mine and determines the points' room numbers
1689 for (i = 0; i < 3; i++) {
1690 vector x;
1691 vector norm;
1692
1693 int fate = PhysCastWalkRay(obj, &obj->pos, &pp[i], &x, NULL, &proom[i], &norm);
1694 if (fate != HIT_NONE) {
1695 if (norm * obj->orient.uvec < 0.4717f) {
1696 return false;
1697 }
1698
1699 pp[i] = x;
1700 }
1701 }
1702
1703 int num_ave = 0;
1704 vector ave_diff = Zero_vector;
1705
1706 for (i = 0; i < 3; i++) {
1707 int fate;
1708 vector foot_pnt = pp[i] + obj->orient.uvec * -(obj->size * 1.5f);
1709 vector norm;
1710
1711 fate = PhysCastWalkRay(obj, &pp[i], &foot_pnt, &hp[i], &proom[i], NULL, &norm);
1712
1713 if (fate != HIT_NONE) {
1714 if (norm * obj->orient.uvec < 0.4717f) {
1715 return false;
1716 }

Callers 1

do_walking_simFunction · 0.85

Calls 8

PhysCalcGroundFunction · 0.85
PhysCalPntOnCPntPlaneFunction · 0.85
PhysCastWalkRayFunction · 0.85
vm_NormalizeVectorFunction · 0.85
vm_GetPerpFunction · 0.50
vm_VectorToMatrixFunction · 0.50
vm_AnglesToMatrixFunction · 0.50

Tested by

no test coverage detected