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

Function ConvertAxisAmountToEuler

physics/collide.cpp:1570–1614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1568}
1569
1570void ConvertAxisAmountToEuler(vector *n, float *w, vector *e) {
1571 float s;
1572 float c;
1573 float t;
1574
1575 float scale = *w / .0001f;
1576 float w_n = .0001f;
1577 vector s_result;
1578
1579 if (*w == 0.0f) {
1580 *e = Zero_vector;
1581 return;
1582 }
1583
1584 s = sin(.0001f);
1585 c = cos(.0001f);
1586 t = 1.0f - c;
1587
1588 matrix rotmat;
1589 const float sx = s * n->x;
1590 const float sy = s * n->y;
1591 const float sz = s * n->z;
1592 const float txy = t * n->x * n->y;
1593 const float txz = t * n->x * n->z;
1594 const float tyz = t * n->y * n->z;
1595 const float txx = t * n->x * n->x;
1596 const float tyy = t * n->y * n->y;
1597 const float tzz = t * n->z * n->z;
1598
1599 rotmat.rvec.x = txx + c;
1600 rotmat.rvec.y = txy - sz;
1601 rotmat.rvec.z = txz + sy;
1602 rotmat.uvec.x = txy + sz;
1603 rotmat.uvec.y = tyy + c;
1604 rotmat.uvec.z = tyz - sx;
1605 rotmat.fvec.x = txz - sy;
1606 rotmat.fvec.y = tyz + sx;
1607 rotmat.fvec.z = tzz + c;
1608
1609 CollideExtractAnglesFromMatrix(&s_result, &rotmat);
1610
1611 e->x = (s_result.x) * scale * (65535.0f / (2.0 * PI));
1612 e->y = (s_result.y) * scale * (65535.0f / (2.0 * PI));
1613 e->z = (s_result.z) * scale * (65535.0f / (2.0 * PI));
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));

Callers 2

bump_obj_against_fixedFunction · 0.85
bump_two_objectsFunction · 0.85

Calls 1

Tested by

no test coverage detected