Skip to content

Commit

Permalink
rename applyStandingCameraRotation to make more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
der-fruhling committed Jun 10, 2024
1 parent aa02913 commit 5fc3fd1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static float getExtraYRot(Perspective persp, float xRot, float yRot, floa
return persp.getLean(f) * (xRot / 90.0f) * -Mth.cos((persp.getYaw(f) - yRot) * Mth.DEG_TO_RAD);
}

public static Vector3d applyStandingCameraRotation(Player player, double x, double y, double z, Perspective persp, float f) {
public static Vector3d applyStandingCameraTranslation(Player player, double x, double y, double z, Perspective persp, float f) {
var lean = persp.getLean(f) * Mth.DEG_TO_RAD;
var yaw = persp.getYaw(f) * Mth.DEG_TO_RAD;
var height = player.getEyeHeight();
Expand All @@ -36,8 +36,8 @@ public static Vector3d applyStandingCameraRotation(Player player, double x, doub
return new Vector3d(newX, newY, newZ);
}

public static Vec3 applyStandingCameraRotation(Player player, Vec3 v, Perspective persp, float f) {
var vec = applyStandingCameraRotation(player, v.x, v.y, v.z, persp, f);
public static Vec3 applyStandingCameraTranslation(Player player, Vec3 v, Perspective persp, float f) {
var vec = applyStandingCameraTranslation(player, v.x, v.y, v.z, persp, f);
return new Vec3(vec.x, vec.y, vec.z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void modifyPosition(Camera instance,
&& clientPlayer.getVehicle() == null
&& !isThirdPerson) {
var persp = (Perspective) clientPlayer;
var newV = MixinUtil.applyStandingCameraRotation(clientPlayer, x, y, z, persp, f);
var newV = MixinUtil.applyStandingCameraTranslation(clientPlayer, x, y, z, persp, f);

if (ModConfig.INSTANCE.dbgShowStandingTransforms) {
clientPlayer.displayClientMessage(Component.literal("%f, %f, %f".formatted(x - newV.x, y - newV.y, z - newV.z)), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CreateRaycastHelperMixin {
@ModifyReturnValue(method = "getTraceOrigin", at = @At("RETURN"))
private static Vec3 applyLeaning(Vec3 original, Player player) {
if (Conditional.shouldApplyPerspectiveTo(player) && player instanceof Perspective persp) {
return MixinUtil.applyStandingCameraRotation(player, original, persp, 1.0f);
return MixinUtil.applyStandingCameraTranslation(player, original, persp, 1.0f);
} else {
return original;
}
Expand Down

0 comments on commit 5fc3fd1

Please sign in to comment.