mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 12:24:39 +02:00
Merge pull request #6073 from ZappoMan/comfortModeHack
implement comfort mode hack
This commit is contained in:
commit
a331edcee9
3 changed files with 60 additions and 22 deletions
|
@ -461,6 +461,7 @@ Menu::Menu() {
|
||||||
0, false,
|
0, false,
|
||||||
&ConnexionClient::getInstance(),
|
&ConnexionClient::getInstance(),
|
||||||
SLOT(toggleConnexion(bool)));
|
SLOT(toggleConnexion(bool)));
|
||||||
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ComfortMode, 0, true);
|
||||||
|
|
||||||
MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
|
MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
|
||||||
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false);
|
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false);
|
||||||
|
|
|
@ -159,6 +159,7 @@ namespace MenuOption {
|
||||||
const QString CenterPlayerInView = "Center Player In View";
|
const QString CenterPlayerInView = "Center Player In View";
|
||||||
const QString Chat = "Chat...";
|
const QString Chat = "Chat...";
|
||||||
const QString Collisions = "Collisions";
|
const QString Collisions = "Collisions";
|
||||||
|
const QString ComfortMode = "Comfort Mode";
|
||||||
const QString Connexion = "Activate 3D Connexion Devices";
|
const QString Connexion = "Activate 3D Connexion Devices";
|
||||||
const QString Console = "Console...";
|
const QString Console = "Console...";
|
||||||
const QString ControlWithSpeech = "Control With Speech";
|
const QString ControlWithSpeech = "Control With Speech";
|
||||||
|
|
|
@ -1514,33 +1514,69 @@ bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const {
|
||||||
|
|
||||||
void MyAvatar::updateOrientation(float deltaTime) {
|
void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
// Smoothly rotate body with arrow keys
|
// Smoothly rotate body with arrow keys
|
||||||
float targetSpeed = (_driveKeys[ROT_LEFT] - _driveKeys[ROT_RIGHT]) * YAW_SPEED;
|
float targetSpeed = 0.0f;
|
||||||
if (targetSpeed != 0.0f) {
|
|
||||||
const float ROTATION_RAMP_TIMESCALE = 0.1f;
|
// FIXME - this comfort mode code is a total hack, remove it when we have new input mapping
|
||||||
float blend = deltaTime / ROTATION_RAMP_TIMESCALE;
|
bool isComfortMode = Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode);
|
||||||
if (blend > 1.0f) {
|
bool isHMDMode = qApp->getAvatarUpdater()->isHMDMode();
|
||||||
blend = 1.0f;
|
|
||||||
}
|
if (!isHMDMode || !isComfortMode) {
|
||||||
_bodyYawDelta = (1.0f - blend) * _bodyYawDelta + blend * targetSpeed;
|
targetSpeed = (_driveKeys[ROT_LEFT] - _driveKeys[ROT_RIGHT]) * YAW_SPEED;
|
||||||
} else if (_bodyYawDelta != 0.0f) {
|
|
||||||
// attenuate body rotation speed
|
if (targetSpeed != 0.0f) {
|
||||||
const float ROTATION_DECAY_TIMESCALE = 0.05f;
|
const float ROTATION_RAMP_TIMESCALE = 0.1f;
|
||||||
float attenuation = 1.0f - deltaTime / ROTATION_DECAY_TIMESCALE;
|
float blend = deltaTime / ROTATION_RAMP_TIMESCALE;
|
||||||
if (attenuation < 0.0f) {
|
if (blend > 1.0f) {
|
||||||
attenuation = 0.0f;
|
blend = 1.0f;
|
||||||
}
|
}
|
||||||
_bodyYawDelta *= attenuation;
|
_bodyYawDelta = (1.0f - blend) * _bodyYawDelta + blend * targetSpeed;
|
||||||
|
} else if (_bodyYawDelta != 0.0f) {
|
||||||
|
// attenuate body rotation speed
|
||||||
|
const float ROTATION_DECAY_TIMESCALE = 0.05f;
|
||||||
|
float attenuation = 1.0f - deltaTime / ROTATION_DECAY_TIMESCALE;
|
||||||
|
if (attenuation < 0.0f) {
|
||||||
|
attenuation = 0.0f;
|
||||||
|
}
|
||||||
|
_bodyYawDelta *= attenuation;
|
||||||
|
|
||||||
|
float MINIMUM_ROTATION_RATE = 2.0f;
|
||||||
|
if (fabsf(_bodyYawDelta) < MINIMUM_ROTATION_RATE) {
|
||||||
|
_bodyYawDelta = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update body orientation by movement inputs
|
||||||
|
setOrientation(getOrientation() *
|
||||||
|
glm::quat(glm::radians(glm::vec3(0.0f, _bodyYawDelta * deltaTime, 0.0f))));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Comfort Mode: If you press any of the left/right rotation drive keys or input, you'll
|
||||||
|
// get an instantaneous 15 degree turn. If you keep holding the key down you'll get another
|
||||||
|
// snap turn every half second.
|
||||||
|
_bodyYawDelta = 0.0f;
|
||||||
|
|
||||||
|
static quint64 lastPulse = 0;
|
||||||
|
quint64 now = usecTimestampNow();
|
||||||
|
quint64 COMFORT_MODE_PULSE_TIMING = USECS_PER_SECOND / 2; // turn once per half second
|
||||||
|
|
||||||
|
float driveLeft = _driveKeys[ROT_LEFT];
|
||||||
|
float driveRight= _driveKeys[ROT_RIGHT];
|
||||||
|
|
||||||
|
if ((driveLeft != 0.0f || driveRight != 0.0f) && (now - lastPulse > COMFORT_MODE_PULSE_TIMING)) {
|
||||||
|
lastPulse = now;
|
||||||
|
|
||||||
|
const float SNAP_TURN_DELTA = 15.0f; // degrees
|
||||||
|
float direction = (driveLeft - driveRight) < 0.0f ? -1.0f : 1.0f;
|
||||||
|
float turnAmount = direction * SNAP_TURN_DELTA;
|
||||||
|
|
||||||
|
// update body orientation by movement inputs
|
||||||
|
setOrientation(getOrientation() *
|
||||||
|
glm::quat(glm::radians(glm::vec3(0.0f, turnAmount, 0.0f))));
|
||||||
|
|
||||||
float MINIMUM_ROTATION_RATE = 2.0f;
|
|
||||||
if (fabsf(_bodyYawDelta) < MINIMUM_ROTATION_RATE) {
|
|
||||||
_bodyYawDelta = 0.0f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
|
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
|
||||||
// update body orientation by movement inputs
|
|
||||||
setOrientation(getOrientation() *
|
|
||||||
glm::quat(glm::radians(glm::vec3(0.0f, _bodyYawDelta * deltaTime, 0.0f))));
|
|
||||||
|
|
||||||
if (qApp->getAvatarUpdater()->isHMDMode()) {
|
if (qApp->getAvatarUpdater()->isHMDMode()) {
|
||||||
glm::quat orientation = glm::quat_cast(getSensorToWorldMatrix()) * getHMDSensorOrientation();
|
glm::quat orientation = glm::quat_cast(getSensorToWorldMatrix()) * getHMDSensorOrientation();
|
||||||
|
|
Loading…
Reference in a new issue