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

aquadran noreply at scummvm.org
Fri Nov 27 18:29:35 UTC 2026


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

Summary:
cbabb311a5 EMI: Fix the sector test for sectors with no normal


Commit: cbabb311a5d788a8d8ae672bc15e6733f993ca35
    https://github.com/scummvm/scummvm/commit/cbabb311a5d788a8d8ae672bc15e6733f993ca35
Author: Joel Teichroeb (joel at teichroeb.net)
Date: 2026-11-27T19:29:29+01:00

Commit Message:
EMI: Fix the sector test for sectors with no normal

The first footstep_dock sector in gpt.setb repeats its first vertex, so
its normal is zero. isPointInSector then took every point of Jambalaya
as inside the dock, and the beach played wood footsteps.

The original computes the same zero normal, but its point test checks
the edges in the x-z plane and never uses the normal for that. Only
this sector and one walk sector in the lava field have a zero normal.

Fix the margins for both games, increase the height if it's equal to
0, like the original engine. This makes no difference to gameplay.

Remove the over 9000 check, the result is the same regardless, so we
don't need a special case.

Fixes #11789

Changed paths:
    engines/grim/sector.cpp


diff --git a/engines/grim/sector.cpp b/engines/grim/sector.cpp
index d22d1e59cdd..ef3ee8c34a7 100644
--- a/engines/grim/sector.cpp
+++ b/engines/grim/sector.cpp
@@ -324,12 +324,23 @@ float Sector::distanceToPoint(const Math::Vector3d &point) const {
 }
 
 bool Sector::isPointInSector(const Math::Vector3d &point) const {
+	const float defaultHeight = 0.005f;
+	const float edgeMargin = 1e-6f;
+
+	float height = _height;
+	if (height == 0.f)
+		height = defaultHeight;
+
 	// Calculate the distance of the point from the plane of the sector.
 	// Return false if it isn't within a margin.
-	if (_height < 9000.f) { // No need to check when height is 9999.
+	if (g_grim->getGameType() == GType_MONKEY4) {
+		float planeY = (_normal.dotProduct(_vertices[0]) - _normal.x() * point.x() - _normal.z() * point.z()) / _normal.y();
+		if (fabsf(point.y() - planeY) > height)
+			return false;
+	} else {
 		float dist = distanceToPoint(point);
 
-		if (fabsf(dist) > _height + 0.01) // Add an error margin
+		if (fabsf(dist) > height)
 			return false;
 	}
 
@@ -337,8 +348,15 @@ bool Sector::isPointInSector(const Math::Vector3d &point) const {
 	for (int i = 0; i < _numVertices; i++) {
 		Math::Vector3d edge = _vertices[i + 1] - _vertices[i];
 		Math::Vector3d delta = point - _vertices[i];
+		if (g_grim->getGameType() == GType_MONKEY4) {
+			edge.y() = 0;
+			delta.y() = 0;
+		}
 		Math::Vector3d cross = Math::Vector3d::crossProduct(edge, delta);
-		if (cross.dotProduct(_normal) < -0.000001f) // not "< 0.f" here, since the value could be something like -7.45058e-09 and it
+		if (g_grim->getGameType() == GType_MONKEY4) {
+			if (cross.y() / edge.getSquareMagnitude() > edgeMargin)
+				return false;
+		} else if (cross.dotProduct(_normal) < -edgeMargin) // not "< 0.f" here, since the value could be something like -7.45058e-09 and it
 			return false;                        // shuoldn't return. that was causing issue #610 (infinite loop in de.forklift_actor.dismount)
 	}
 	return true;




More information about the Scummvm-git-logs mailing list