[Scummvm-git-logs] scummvm master -> bafbf669ea59ae47202f968e3a78be089c388994

neuromancer noreply at scummvm.org
Mon Nov 14 12:12:24 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bafbf669ea FREESCAPE: improved precision of drilling in driller


Commit: bafbf669ea59ae47202f968e3a78be089c388994
    https://github.com/scummvm/scummvm/commit/bafbf669ea59ae47202f968e3a78be089c388994
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-14T13:13:24+01:00

Commit Message:
FREESCAPE: improved precision of drilling in driller

Changed paths:
    engines/freescape/freescape.h
    engines/freescape/games/driller.cpp


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 616f504f0a0..b14017f0406 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -336,6 +336,7 @@ public:
 private:
 	void loadGlobalObjects(Common::SeekableReadStream *file, int offset);
 	bool drillDeployed(Area *area);
+	Math::Vector3d drillPosition();
 	void addDrill(const Math::Vector3d position);
 	bool checkDrill(const Math::Vector3d position);
 	void removeDrill(Area *area);
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index 194f806befe..91e0366c7c6 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -430,6 +430,14 @@ void DrillerEngine::drawAmigaAtariSTUI(Graphics::Surface *surface) {
 	// TODO: this needs to have fonts already parsed
 }
 
+Math::Vector3d getProjectionToPlane(const Math::Vector3d &vect, const Math::Vector3d normal) {
+	assert (normal.length() == 1);
+	// Formula: return p - n * (n . p)
+	Math::Vector3d result = vect;
+	result -= normal * normal.dotProduct(vect);
+	return result;
+}
+
 void DrillerEngine::pressedKey(const int keycode) {
 	if (keycode == Common::KEYCODE_d) {
 		Common::Point gasPocket = _currentArea->_gasPocketPosition;
@@ -452,22 +460,20 @@ void DrillerEngine::pressedKey(const int keycode) {
 			return;
 		}
 
-		Math::Vector3d drillPosition = _cameraFront;
-		drillPosition = _position + 256 * drillPosition;
+		Math::Vector3d drill = drillPosition();
 		debugC(1, kFreescapeDebugMove, "Current position at %f %f %f", _position.x(), _position.y(), _position.z());
-		drillPosition.setValue(1, _position.y() - _playerHeight * _currentArea->getScale());
-		debugC(1, kFreescapeDebugMove, "Trying to adding drill at %f %f %f", drillPosition.x(), drillPosition.y(), drillPosition.z());
+		debugC(1, kFreescapeDebugMove, "Trying to adding drill at %f %f %f", drill.x(), drill.y(), drill.z());
 		debugC(1, kFreescapeDebugMove, "with pitch: %f and yaw %f", _pitch, _yaw);
 
-		if (!checkDrill(drillPosition)) {
+		if (!checkDrill(drill)) {
 			insertTemporaryMessage(_messagesList[4], _countdown - 2);
 			return;
 		}
 
 		_gameStateVars[k8bitVariableEnergy] = _gameStateVars[k8bitVariableEnergy] - 5;
-		const Math::Vector3d gasPocket3D(gasPocket.x, drillPosition.y(), gasPocket.y);
-		addDrill(drillPosition);
-		float distanceToPocket = (gasPocket3D - drillPosition).length();
+		const Math::Vector3d gasPocket3D(gasPocket.x, drill.y(), gasPocket.y);
+		addDrill(drill);
+		float distanceToPocket = (gasPocket3D - drill).length();
 		float success = 100.0 * (1.0 - distanceToPocket / _currentArea->_gasPocketRadius);
 		insertTemporaryMessage(_messagesList[3], _countdown - 2);
 
@@ -518,6 +524,18 @@ void DrillerEngine::pressedKey(const int keycode) {
 	}
 }
 
+Math::Vector3d DrillerEngine::drillPosition() {
+	Math::Vector3d position = _position;
+	position.setValue(1, position.y() - _playerHeight);
+	position = position + 300 * getProjectionToPlane(_cameraFront, Math::Vector3d(0, 1, 0));
+
+	Object *obj = (GeometricObject *)_areaMap[255]->objectWithID(255); // Drill base
+	assert(obj);
+	position.setValue(0, position.x() - obj->getSize().x() / 2);
+	position.setValue(2, position.z() - obj->getSize().z() / 2);
+	return position;
+}
+
 bool DrillerEngine::drillDeployed(Area *area) {
 	return (area->objectWithID(252) != nullptr);
 }




More information about the Scummvm-git-logs mailing list