Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(wwmath): a ray that starts inside a box has a contact point

Olcay Seygand2609b71f919
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWMath/colmathline.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWMath/colmathline.cpp
index 469455dbc..dadb741cb 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWMath/colmathline.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWMath/colmathline.cpp
@@ -292,8 +292,13 @@ bool CollisionMath::Collide(const LineSegClass & line,const AABoxClass & box,Cas
// if ray starts inside the box, note that fact and bail.
if (test.Inside) {
- res->StartBad = true;
- return true;
+ res->StartBad = true;
+ // The contact is where the line began. It used to be left at whatever the caller had in
+ // there, so a caller that reads ContactPoint on a StartBad hit read a stale point.
+ if (res->ComputeContactPoint) {
+ res->ContactPoint = line.Get_P0();
+ }
+ return true;
}
// Now, if this intersection is before any current intersection
@@ -327,7 +332,11 @@ bool CollisionMath::Collide(const LineSegClass & line,const OBBoxClass & box,Cas
// if ray starts inside the box, don't collide
if (test.Inside) {
- result->StartBad = true;
+ result->StartBad = true;
+ // Same as the aligned box above: the contact is where the line began.
+ if (result->ComputeContactPoint) {
+ result->ContactPoint = line.Get_P0();
+ }
return true;
}