mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 20:13:40 +02:00
add clarifying comments about target scale changes
This commit is contained in:
parent
d5722c1654
commit
272d0c845e
2 changed files with 34 additions and 3 deletions
|
@ -1832,6 +1832,28 @@ bool findAvatarAvatarPenetration(const glm::vec3 positionA, float radiusA, float
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There can be a separation between the _targetScale and the actual scale of the rendered avatar in a domain.
|
||||||
|
// When the avatar enters a domain where their target scale is not allowed according to the min/max
|
||||||
|
// we do not change their saved target scale. Instead, we use getDomainLimitedScale() to render the avatar
|
||||||
|
// at a domain appropriate size. When the avatar leaves the limiting domain, we'll return them to their previous target scale.
|
||||||
|
// While connected to a domain that limits avatar scale if the user manually changes their avatar scale, we change
|
||||||
|
// target scale to match the new scale they have chosen. When they leave the domain they will not return to the scale they were
|
||||||
|
// before they entered the limiting domain.
|
||||||
|
|
||||||
|
void MyAvatar::clampTargetScaleToDomainLimits() {
|
||||||
|
// when we're about to change the target scale because the user has asked to increase or decrease their scale,
|
||||||
|
// we first make sure that we're starting from a target scale that is allowed by the current domain
|
||||||
|
|
||||||
|
auto clampedTargetScale = glm::clamp(_targetScale, _domainMinimumScale, _domainMaximumScale);
|
||||||
|
|
||||||
|
if (clampedTargetScale != _targetScale) {
|
||||||
|
qCDebug(interfaceapp, "Clamped scale to %f since original target scale %f was not allowed by domain",
|
||||||
|
clampedTargetScale, _targetScale);
|
||||||
|
|
||||||
|
setTargetScale(clampedTargetScale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::clampScaleChangeToDomainLimits(float desiredScale) {
|
void MyAvatar::clampScaleChangeToDomainLimits(float desiredScale) {
|
||||||
auto clampedTargetScale = glm::clamp(desiredScale, _domainMinimumScale, _domainMaximumScale);
|
auto clampedTargetScale = glm::clamp(desiredScale, _domainMinimumScale, _domainMaximumScale);
|
||||||
|
|
||||||
|
@ -1845,21 +1867,29 @@ void MyAvatar::clampScaleChangeToDomainLimits(float desiredScale) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::increaseSize() {
|
void MyAvatar::increaseSize() {
|
||||||
// clamp the target scale to the allowable scale in the domain
|
// make sure we're starting from an allowable scale
|
||||||
|
clampTargetScaleToDomainLimits();
|
||||||
|
|
||||||
|
// calculate what our new scale should be
|
||||||
float updatedTargetScale = _targetScale * (1.0f + SCALING_RATIO);
|
float updatedTargetScale = _targetScale * (1.0f + SCALING_RATIO);
|
||||||
|
|
||||||
|
// attempt to change to desired scale (clamped to the domain limits)
|
||||||
clampScaleChangeToDomainLimits(updatedTargetScale);
|
clampScaleChangeToDomainLimits(updatedTargetScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::decreaseSize() {
|
void MyAvatar::decreaseSize() {
|
||||||
// clamp the target scale to the allowable scale in the domain
|
// make sure we're starting from an allowable scale
|
||||||
|
clampTargetScaleToDomainLimits();
|
||||||
|
|
||||||
|
// calculate what our new scale should be
|
||||||
float updatedTargetScale = _targetScale * (1.0f - SCALING_RATIO);
|
float updatedTargetScale = _targetScale * (1.0f - SCALING_RATIO);
|
||||||
|
|
||||||
|
// attempt to change to desired scale (clamped to the domain limits)
|
||||||
clampScaleChangeToDomainLimits(updatedTargetScale);
|
clampScaleChangeToDomainLimits(updatedTargetScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::resetSize() {
|
void MyAvatar::resetSize() {
|
||||||
// attempt to reset avatar size to the default
|
// attempt to reset avatar size to the default (clamped to domain limits)
|
||||||
const float DEFAULT_AVATAR_SCALE = 1.0f;
|
const float DEFAULT_AVATAR_SCALE = 1.0f;
|
||||||
|
|
||||||
clampScaleChangeToDomainLimits(DEFAULT_AVATAR_SCALE);
|
clampScaleChangeToDomainLimits(DEFAULT_AVATAR_SCALE);
|
||||||
|
|
|
@ -372,6 +372,7 @@ private:
|
||||||
virtual void updatePalms() override {}
|
virtual void updatePalms() override {}
|
||||||
void lateUpdatePalms();
|
void lateUpdatePalms();
|
||||||
|
|
||||||
|
void clampTargetScaleToDomainLimits();
|
||||||
void clampScaleChangeToDomainLimits(float desiredScale);
|
void clampScaleChangeToDomainLimits(float desiredScale);
|
||||||
|
|
||||||
float _driveKeys[MAX_DRIVE_KEYS];
|
float _driveKeys[MAX_DRIVE_KEYS];
|
||||||
|
|
Loading…
Reference in a new issue