From 3922370275a7141eebc3b3f12e24112c38fc4438 Mon Sep 17 00:00:00 2001 From: David Fioramonti Date: Sat, 23 Jun 2018 21:34:38 -0700 Subject: BLADERUNNER: Add cos/sine table This uses the one in Common. The engine now contains a 10-bit cosine and sine table. It used mostly for vector math. This also allows two vector functions to be removed from vector.h. --- engines/bladerunner/actor.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'engines/bladerunner/actor.cpp') diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 25b0a39fd0..4899ea9527 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -622,9 +622,8 @@ bool Actor::tick(bool forceDraw, Common::Rect *screenRect) { positionChange.z = positionChange.z * _actorSpeed.z; } - float angle = _facing * (M_PI / 512.0f); - float sinx = sin(angle); - float cosx = cos(angle); + float sinx = _vm->_sinTable1024->at(_facing); + float cosx = _vm->_cosTable1024->at(_facing); float originalX = _position.x; float originalY = _position.y; @@ -1183,8 +1182,8 @@ bool Actor::walkFindU1(const Vector3 &startPosition, const Vector3 &targetPositi int facing2 = facing; int facing3 = 0; while (true) { - float rotatedX = targetPosition.x + size * sin_1024(facing); - float rotatedZ = targetPosition.z - size * cos_1024(facing); + float rotatedX = targetPosition.x + size * _vm->_sinTable1024->at(facing); + float rotatedZ = targetPosition.z - size * _vm->_cosTable1024->at(facing); if (!_walkInfo->isXYZEmpty(rotatedX, targetPosition.y, rotatedZ, _id)) { if (_vm->_scene->_set->findWalkbox(rotatedX, rotatedZ) >= 0) { @@ -1201,8 +1200,8 @@ bool Actor::walkFindU1(const Vector3 &startPosition, const Vector3 &targetPositi facing3 += 20; } - rotatedX = size * sin_1024(facing2) + targetPosition.x; - rotatedZ = size * cos_1024(facing2) + targetPosition.z; + rotatedX = size * _vm->_sinTable1024->at(facing2) + targetPosition.x; + rotatedZ = size * _vm->_cosTable1024->at(facing2) + targetPosition.z; if (!_walkInfo->isXYZEmpty(rotatedX, targetPosition.y, rotatedZ, _id)) { if (_vm->_scene->_set->findWalkbox(rotatedX, rotatedZ) >= 0) { -- cgit v1.2.3