Improve target candidate resolution with player distance filtering
This commit is contained in:
@@ -339,6 +339,10 @@ const TARGETING_SCREEN_SWITCH_MAX_ABS_Y = 1.25;
|
|||||||
const TARGETING_SCREEN_PROPOSAL_MAX_ABS_X = 1;
|
const TARGETING_SCREEN_PROPOSAL_MAX_ABS_X = 1;
|
||||||
const TARGETING_SCREEN_PROPOSAL_MAX_ABS_Y = 1;
|
const TARGETING_SCREEN_PROPOSAL_MAX_ABS_Y = 1;
|
||||||
const TARGETING_MAX_ACTIVE_TARGET_DISTANCE = 15;
|
const TARGETING_MAX_ACTIVE_TARGET_DISTANCE = 15;
|
||||||
|
const TARGETING_ACTIVE_TARGET_RELEASE_DISTANCE =
|
||||||
|
TARGETING_MAX_ACTIVE_TARGET_DISTANCE + 0.75;
|
||||||
|
const TARGETING_AUTO_RETARGET_SAFE_DISTANCE =
|
||||||
|
TARGETING_MAX_ACTIVE_TARGET_DISTANCE - 0.75;
|
||||||
// Proposed-target camera nudging is intentionally disabled for now. Lux alone
|
// Proposed-target camera nudging is intentionally disabled for now. Lux alone
|
||||||
// should communicate proposal without moving the gameplay camera.
|
// should communicate proposal without moving the gameplay camera.
|
||||||
// const PROPOSED_TARGET_CAMERA_ASSIST_STRENGTH = 0.28;
|
// const PROPOSED_TARGET_CAMERA_ASSIST_STRENGTH = 0.28;
|
||||||
@@ -5788,9 +5792,17 @@ export class RuntimeHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private resolveRuntimeTargetCandidateNearestScreenCenter(
|
private resolveRuntimeTargetCandidateNearestScreenCenter(
|
||||||
options: { exclude?: RuntimeTargetReference | null } = {}
|
options: {
|
||||||
|
exclude?: RuntimeTargetReference | null;
|
||||||
|
maxDistanceFromPlayer?: number;
|
||||||
|
} = {}
|
||||||
): RuntimeTargetCandidate | null {
|
): RuntimeTargetCandidate | null {
|
||||||
const exclude = options.exclude ?? null;
|
const exclude = options.exclude ?? null;
|
||||||
|
const maxDistanceFromPlayer = options.maxDistanceFromPlayer ?? null;
|
||||||
|
const playerEyePosition =
|
||||||
|
maxDistanceFromPlayer === null
|
||||||
|
? null
|
||||||
|
: this.currentPlayerControllerTelemetry?.eyePosition ?? null;
|
||||||
let bestCandidate: RuntimeTargetCandidate | null = null;
|
let bestCandidate: RuntimeTargetCandidate | null = null;
|
||||||
let bestScreenDistanceSquared = Number.POSITIVE_INFINITY;
|
let bestScreenDistanceSquared = Number.POSITIVE_INFINITY;
|
||||||
|
|
||||||
@@ -5803,6 +5815,15 @@ export class RuntimeHost {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
maxDistanceFromPlayer !== null &&
|
||||||
|
playerEyePosition !== null &&
|
||||||
|
distanceBetweenPoints(playerEyePosition, candidate.center) >
|
||||||
|
maxDistanceFromPlayer
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const screenPoint = this.resolveRuntimeTargetScreenPoint(candidate.center);
|
const screenPoint = this.resolveRuntimeTargetScreenPoint(candidate.center);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -5850,11 +5871,12 @@ export class RuntimeHost {
|
|||||||
distanceBetweenPoints(
|
distanceBetweenPoints(
|
||||||
this.currentPlayerControllerTelemetry.eyePosition,
|
this.currentPlayerControllerTelemetry.eyePosition,
|
||||||
activeTarget.center
|
activeTarget.center
|
||||||
) > TARGETING_MAX_ACTIVE_TARGET_DISTANCE
|
) > TARGETING_ACTIVE_TARGET_RELEASE_DISTANCE
|
||||||
) {
|
) {
|
||||||
const replacementTarget =
|
const replacementTarget =
|
||||||
this.resolveRuntimeTargetCandidateNearestScreenCenter({
|
this.resolveRuntimeTargetCandidateNearestScreenCenter({
|
||||||
exclude: this.activeRuntimeTargetReference
|
exclude: this.activeRuntimeTargetReference,
|
||||||
|
maxDistanceFromPlayer: TARGETING_AUTO_RETARGET_SAFE_DISTANCE
|
||||||
});
|
});
|
||||||
|
|
||||||
if (replacementTarget !== null) {
|
if (replacementTarget !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user