-
Notifications
You must be signed in to change notification settings - Fork 141
bugfix(Geometry): Checks Hitboxes for buildings with BOX Geometry, preventing the building to take damage without being hit #2043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
Outdated
Show resolved
Hide resolved
| } | ||
| } | ||
| #endif | ||
|
|
There was a problem hiding this comment.
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;
}
}
#endifI did a quick test with regards to the comments made about shooting underneath buildings. I'd propose a couple of changes here:
- Change from comparing against function pointer to the
DistanceCalculationType. I haven't verified if this check is needed at all. - Use
const&forgeomInfo, that way you don't have check the pointer and don't need to dereference the pointer later. - Change the
GeometryTypetoGEOMETRY_CYLINDERfor better height checks. - 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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
There was a problem hiding this comment.
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.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
Outdated
Show resolved
Hide resolved
|
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 |
5372ef5 to
e05b7ee
Compare
e05b7ee to
cbfe201
Compare
Uh oh!
There was an error while loading. Please reload this page.