Skip to content

Conversation

@IamInnocent3X
Copy link

@IamInnocent3X IamInnocent3X commented Jan 1, 2026

@IamInnocent3X IamInnocent3X changed the title Added Boundary Box checks for Structures to Resolve Issue 2036 bugfix(Geometry): Checks Hitboxes for buildings with BOX Geometry, preventing the building to take damage without being hit Jan 1, 2026
@Skyaero42 Skyaero42 added Bug Something is not working right, typically is user facing Fix Is fixing something, but is not user facing NoRetail This fix or change is not applicable with Retail game compatibility and removed Bug Something is not working right, typically is user facing labels Jan 1, 2026
}
}
#endif

Copy link

@Caball009 Caball009 Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

				// TheSuperHackers @fix IamInnocent 31/12/2025 Added boundary box checks for structures to get an accurate hitbox instead of a hitcircle.
#if !RETAIL_COMPATIBLE_CRC && !PRESERVE_RETAIL_BEHAVIOR
				if(thisObj->isKindOf(KINDOF_STRUCTURE) && (dc == FROM_BOUNDINGSPHERE_2D || dc == FROM_BOUNDINGSPHERE_3D))
				{
					const GeometryInfo& geomInfo = thisObj->getGeometryInfo();
					if(geomInfo.getGeomType() == GEOMETRY_BOX)
					{
						const GeometryInfo geometry( GEOMETRY_CYLINDER, TRUE, maxDist, maxDist, maxDist );
						if(!geomCollidesWithGeom(objPos, geometry, 0.0f, thisObj->getPosition(), geomInfo, thisObj->getOrientation(), TRUE))
							continue;
					}
				}
#endif

I did a quick test with regards to the comments made about shooting underneath buildings. I'd propose a couple of changes here:

  1. Change from comparing against function pointer to the DistanceCalculationType. I haven't verified if this check is needed at all.
  2. Use const& for geomInfo, that way you don't have check the pointer and don't need to dereference the pointer later.
  3. Change the GeometryType to GEOMETRY_CYLINDER for better height checks.
  4. This code only applies to structures, so there's maybe no need to check the Z coordinate at all.

Combining point 3 and 4 should restore retail behavior so that shooting underneath a building does damage to it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked whether the new code can replace some of the old code. It'd be more optimal if we don't do double checks for structures.

Copy link
Author

@IamInnocent3X IamInnocent3X Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old Distance check used sqrtf(major^2+minor^2) *0.5, which will result in being unable to damage the Airfield at the edge length of the box. Setting it to solely use geomCollidesWithGeom would definitely be Gameplay Changing and not be Retail.

Copy link
Author

@IamInnocent3X IamInnocent3X Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Considering DistanceProc already considered to Z coordinates, there might no need to check Z axis.
    I'll push the Update to the Branch and await further review

Copy link
Author

@IamInnocent3X IamInnocent3X Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old Distance check used sqrtf(major^2+minor^2) *0.5, which will result in being unable to damage the Airfield at the edge length of the box. Setting it to solely use geomCollidesWithGeom would definitely be Gameplay Changing and not be Retail.

Sorry my bad, this is false memory recall, that was a different function. It does use sqr(diff.x) + sqr(diff.y) + sqr(diff.z) for its distance check. Although for there is a boost in distance based on the bounding sphere radius:

m_boundingSphereRadius = sqrt(sqr(m_majorRadius) + sqr(m_minorRadius) + sqr(m_height*0.5));

Maybe we could just add an extra Quarter of the Target's Height to both Upper and Lower Boundary of the Target's geometry during calculation? That way it could maybe solve the Double Calculation issue... Or just simply use the BoundingSphereRadius for the Upper and Lower Boundary Checking. Needs testing.

@IamInnocent3X
Copy link
Author

Adjusted the solution , also added an Accurate Sphere to Rectangle Boundary detection. Need to adjust the Game Define if anyone wants to test the Accurate Solution

@IamInnocent3X IamInnocent3X force-pushed the BoundaryBoxDamageCheck branch from 5372ef5 to e05b7ee Compare January 10, 2026 08:57
@IamInnocent3X IamInnocent3X force-pushed the BoundaryBoxDamageCheck branch from e05b7ee to cbfe201 Compare January 10, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Is fixing something, but is not user facing NoRetail This fix or change is not applicable with Retail game compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hitboxes for buildings are spheres, allowing the building to take damage without being hit

3 participants