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

Function bump_obj_against_fixed

physics/collide.cpp:1616–1706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1614}
1615
1616void bump_obj_against_fixed(object *obj, vector *collision_point, vector *collision_normal) {
1617 ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.x));
1618 ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.y));
1619 ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.z));
1620 ASSERT(std::isfinite(obj->mtype.phys_info.velocity.x));
1621 ASSERT(std::isfinite(obj->mtype.phys_info.velocity.y));
1622 ASSERT(std::isfinite(obj->mtype.phys_info.velocity.z));
1623
1624 if (!IsOKToApplyForce(obj))
1625 return;
1626
1627 vector r1 = *collision_point - obj->pos;
1628 vector w1;
1629 vector n1;
1630 float temp1;
1631
1632 float j;
1633
1634 matrix o_t1 = obj->orient;
1635 vm_TransposeMatrix(&o_t1);
1636
1637 vector cmp1 = obj->mtype.phys_info.rotvel * o_t1;
1638
1639 ConvertEulerToAxisAmount(&cmp1, &n1, &temp1);
1640
1641 n1 *= temp1;
1642
1643 if (temp1 != 0.0f) {
1644 vm_CrossProduct(&w1, &n1, &r1);
1645 } else {
1646 w1 = Zero_vector;
1647 }
1648
1649 vector p1 = obj->mtype.phys_info.velocity + w1;
1650 float v_rel;
1651
1652 float m1 = obj->mtype.phys_info.mass;
1653
1654 ASSERT(m1 != 0.0f);
1655 if (m1 <= 0.0f)
1656 m1 = 0.00000001f;
1657
1658 v_rel = *collision_normal * (p1);
1659
1660 float e = obj->mtype.phys_info.coeff_restitution;
1661
1662 vector c1;
1663 vector cc1;
1664 float cv1;
1665
1666 // matrix i1;
1667 // matrix i2;
1668 float i1 = (2.0f / 5.0f) * m1 * obj->size * obj->size;
1669
1670 if (i1 < .0000001)
1671 i1 = .0000001f;
1672
1673 vm_CrossProduct(&c1, &r1, collision_normal);

Callers 1

do_physics_simFunction · 0.85

Calls 6

IsOKToApplyForceFunction · 0.85
ConvertEulerToAxisAmountFunction · 0.85
vm_NormalizeVectorFunction · 0.85
ConvertAxisAmountToEulerFunction · 0.85
vm_TransposeMatrixFunction · 0.50
vm_CrossProductFunction · 0.50

Tested by

no test coverage detected