Improved the check for being in freecam. Instead of checking the distance from the main camera to mc.player, we can check if the render entity is mc.player or not.
public static boolean isFreecamEnabled() {
return !(mc.player.isSpectator() || mc.player.equals(mc.getCameraEntity()));
}
Support distance-based volume while in freecam. The distance is calculated player-to-player. I.e. the camera's position is ignored.
Stereo effects are currently not applied while in freecam. During testing, I couldn't decide if it felt "right"" to hear players talking near mc.player in stereo when looking at them from an outside perspective.
It would be relatively simple to support stereo, by having pretty much all code use FreecamUtil.getReferencePoint() instead of the camera position, and also introducing a FreecamUtil.getRotation() to replace Camera::getYRot:
Using stereo would make freecam less of a special-case in AudioChannel::writeToSpeaker, but would mean more code would have to make use of FreecamUtil methods (e.g. PositionalAudioUtils, the ALSpeaker classes, etc)
FreecamUtil.getDistanceTo(Vec3) is used to check how/if packets should be sent/handled, rather than using the distance from the main camera:
public static double getDistanceTo(Vec3 pos) {
return getReferencePoint().distanceTo(pos);
}
I also included a commit which removes the freecamSupport config option, since IMO it is only useful for debugging edge-cases. Perhaps you'd rather merge that commit later on after a period of beta-testing? If so, I've set the config option's default value to true.
Testing has been done using hashalite's freecam (I couldn't find any others supporting 1.19.4, I found two for 1.19.3 that wouldn't run). I've tested both with a dedicated server process and with the integrated (open-to-LAN) server.
Thank you for you work, help, discussion, etc on this issue. I look forward to your thoughts and review. :smile:
Improved the check for being in freecam. Instead of checking the distance from the main camera to
mc.player
, we can check if the render entity ismc.player
or not.Support distance-based volume while in freecam. The distance is calculated player-to-player. I.e. the camera's position is ignored.
Stereo effects are currently not applied while in freecam. During testing, I couldn't decide if it felt "right"" to hear players talking near
mc.player
in stereo when looking at them from an outside perspective.It would be relatively simple to support stereo, by having pretty much all code use
FreecamUtil.getReferencePoint()
instead of the camera position, and also introducing aFreecamUtil.getRotation()
to replaceCamera::getYRot
:Using stereo would make freecam less of a special-case in
AudioChannel::writeToSpeaker
, but would mean more code would have to make use ofFreecamUtil
methods (e.g.PositionalAudioUtils
, theALSpeaker
classes, etc)FreecamUtil.getDistanceTo(Vec3)
is used to check how/if packets should be sent/handled, rather than using the distance from the main camera:I also included a commit which removes the
freecamSupport
config option, since IMO it is only useful for debugging edge-cases. Perhaps you'd rather merge that commit later on after a period of beta-testing? If so, I've set the config option's default value totrue
.Testing has been done using hashalite's freecam (I couldn't find any others supporting 1.19.4, I found two for 1.19.3 that wouldn't run). I've tested both with a dedicated server process and with the integrated (open-to-LAN) server.
Thank you for you work, help, discussion, etc on this issue. I look forward to your thoughts and review. :smile: