TRECISION: Clean up maths

This commit is contained in:
SupSuper committed 2021-05-29 21:22:58 +01:00
1 parent 21cad3bd5c
commit 4e2e1d5fcf
3 files changed
+14 -16

No files matched your search

+8 -10
View File
@@ -772,8 +772,7 @@ void drawCharacter(uint8 flag) {
pa2 /= t;
tz = acos((pa0 * l0) + (pa1 * l1) + (pa2 * l2)) * 360.0 / PI2;
tz = (tz > 180) ? 180 : tz;
tz = (tz < 0) ? 0 : tz;
tz = CLIP(tz, 0.f, 180.f);
// tx falloff
// ty hospot
@@ -826,8 +825,7 @@ void drawCharacter(uint8 flag) {
pa2 = _vertex->_nz;
lint = (int)((acos(pa0 * l0 + pa1 * l1 + pa2 * l2) * 360.0) / PI);
lint = (lint > 180) ? 180 : lint;
lint = (lint < 0) ? 0 : lint;
lint = CLIP(lint, 0, 180);
_vVertex[a]._angle -= (180 - lint);
_vertex++;
@@ -875,13 +873,13 @@ void drawCharacter(uint8 flag) {
_vVertex[a]._y = (short)_y2d;
_vVertex[a]._z = (short)((dist - l2) * 128.0);
_actor._lim[0] = (_x2d < _actor._lim[0]) ? _x2d : _actor._lim[0];
_actor._lim[1] = (_x2d > _actor._lim[1]) ? _x2d : _actor._lim[1];
_actor._lim[2] = (_y2d < _actor._lim[2]) ? _y2d : _actor._lim[2];
_actor._lim[3] = (_y2d > _actor._lim[3]) ? _y2d : _actor._lim[3];
_actor._lim[0] = MIN(_x2d, _actor._lim[0]);
_actor._lim[1] = MAX(_x2d, _actor._lim[1]);
_actor._lim[2] = MIN(_y2d, _actor._lim[2]);
_actor._lim[3] = MAX(_y2d, _actor._lim[3]);
_actor._lim[4] = (_vVertex[a]._z < _actor._lim[4]) ? _vVertex[a]._z : _actor._lim[4];
_actor._lim[5] = (_vVertex[a]._z > _actor._lim[5]) ? _vVertex[a]._z : _actor._lim[5];
_actor._lim[4] = MIN(_vVertex[a]._z, _actor._lim[4]);
_actor._lim[5] = MAX(_vVertex[a]._z, _actor._lim[5]);
_vertex++;
}
+4 -4
View File
@@ -1605,10 +1605,10 @@ int intersectLinePanel(struct SPan *p, float x, float y, float z) {
_y3d = y1 + dy * t;
_z3d = z1 + dz * t;
float minx = (p->_x1 < p->_x2) ? p->_x1 - 1.5 : p->_x2 - 1.5;
float maxx = (p->_x1 > p->_x2) ? p->_x1 + 1.5 : p->_x2 + 1.5;
float minz = (p->_z1 < p->_z2) ? p->_z1 - 1.5 : p->_z2 - 1.5;
float maxz = (p->_z1 > p->_z2) ? p->_z1 + 1.5 : p->_z2 + 1.5;
float minx = MIN(p->_x1, p->_x2) - 1.5;
float maxx = MAX(p->_x1, p->_x2) + 1.5;
float minz = MIN(p->_z1, p->_z2) - 1.5;
float maxz = MAX(p->_z1, p->_z2) + 1.5;
// check if it fits inside the panel
if ((_x3d >= minx) && (_x3d <= maxx) && (_y3d >= 0.0) && (_y3d <= p->_h) && (_z3d >= minz) && (_z3d <= maxz))
+2 -2
View File
@@ -222,7 +222,7 @@ void MessageQueue::orderEvents() {
/* TESTEMPTYQUEUE */
/*-------------------------------------------------------------------------*/
bool MessageQueue::testEmptyQueue(uint8 cls) {
for (uint8 pos = _head; pos != _tail; pos = (pos == MAXMESSAGE - 1) ? 0 : pos + 1) {
for (uint8 pos = _head; pos != _tail; pos = (pos + 1) % MAXMESSAGE) {
if (_event[pos]->_class != cls)
return false;
}
@@ -234,7 +234,7 @@ bool MessageQueue::testEmptyQueue(uint8 cls) {
/* TESTEMPTYCHARACTERQUEUE4SCRIPT */
/*-------------------------------------------------------------------------*/
bool MessageQueue::testEmptyCharacterQueue4Script() {
for (uint8 pos = _head; pos != _tail; pos = (pos == MAXMESSAGE - 1) ? 0 : pos + 1) {
for (uint8 pos = _head; pos != _tail; pos = (pos + 1) % MAXMESSAGE) {
if (_event[pos]->_class != MC_CHARACTER)
continue;