Skip to content
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

fixed RayTest calls to use the fps ray distances #415

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/game/CGrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ void CGrenade::FrameAction() {
// | /
// |G <- approaching wall at 45° needs sqrt(2)*radius to intersect wall... lower angles might pass collision instead
static Fixed addRad = sqrt(2)*partList[0]->enclosureRadius;
Fixed classicRayLength = NormalizeVector(3, rayHit.direction) + addRad;
rayHit.distance = classicRayLength;
// use the smaller FPS-scaled rayLength to search a much smaller volume
Fixed rayLength = FpsCoefficient2(NormalizeVector(3, rayHit.direction)) + addRad;
rayHit.distance = rayLength;
RayTestWithGround(&rayHit, kSolidBit);

// if the grenade path (ray test) intersects with an object during this frame
Fixed classicRayDistance = ClassicCoefficient2(rayHit.distance);
if (classicRayLength > classicRayDistance) {
if (rayLength > rayHit.distance) {
// scale distance up to Classic so it's backed out properly when adding to location
Fixed classicRayDistance = ClassicCoefficient2(rayHit.distance);
speed[0] = FMul(rayHit.direction[0], classicRayDistance);
speed[1] = FMul(rayHit.direction[1], classicRayDistance);
speed[2] = FMul(rayHit.direction[2], classicRayDistance);
Expand Down
4 changes: 2 additions & 2 deletions src/game/CSmart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ if (IsClassicInterval()) { // indented like this because hope to remove it in th
rayHit.closestHit = NULL;

rayHit.distance = NormalizeVector(3, rayHit.direction);

realSpeed = rayHit.distance;
rayHit.distance = FpsCoefficient2(rayHit.distance);

RayTestWithGround(&rayHit, kSolidBit);

Expand All @@ -336,7 +336,7 @@ if (IsClassicInterval()) { // indented like this because hope to remove it in th
}

if (rayHit.closestHit) {
realSpeed = rayHit.distance;
realSpeed = ClassicCoefficient2(rayHit.distance);
speed[0] = FMul(rayHit.direction[0], realSpeed);
speed[1] = FMul(rayHit.direction[1], realSpeed);
speed[2] = FMul(rayHit.direction[2], realSpeed);
Expand Down
Loading