mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:47:41 +02:00
Merge branch 'master' into 21235
# Conflicts: # interface/src/Menu.cpp # interface/src/ui/DialogsManager.h
This commit is contained in:
commit
e3b9d588ec
11 changed files with 181 additions and 240 deletions
|
@ -4383,16 +4383,16 @@ void Application::update(float deltaTime) {
|
||||||
myAvatar->clearDriveKeys();
|
myAvatar->clearDriveKeys();
|
||||||
if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) {
|
if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) {
|
||||||
if (!_controllerScriptingInterface->areActionsCaptured()) {
|
if (!_controllerScriptingInterface->areActionsCaptured()) {
|
||||||
myAvatar->setDriveKeys(TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));
|
myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));
|
||||||
myAvatar->setDriveKeys(TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
|
myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
|
||||||
myAvatar->setDriveKeys(TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X));
|
myAvatar->setDriveKey(MyAvatar::TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X));
|
||||||
if (deltaTime > FLT_EPSILON) {
|
if (deltaTime > FLT_EPSILON) {
|
||||||
myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
|
myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
|
||||||
myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
|
myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
|
||||||
myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
|
myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myAvatar->setDriveKeys(ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
|
myAvatar->setDriveKey(MyAvatar::ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
|
||||||
}
|
}
|
||||||
|
|
||||||
controller::Pose leftHandPose = userInputMapper->getPoseState(controller::Action::LEFT_HAND);
|
controller::Pose leftHandPose = userInputMapper->getPoseState(controller::Action::LEFT_HAND);
|
||||||
|
@ -5503,8 +5503,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
|
scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
|
||||||
|
|
||||||
// hook our avatar and avatar hash map object into this script engine
|
// hook our avatar and avatar hash map object into this script engine
|
||||||
scriptEngine->registerGlobalObject("MyAvatar", getMyAvatar().get());
|
getMyAvatar()->registerMetaTypes(scriptEngine);
|
||||||
qScriptRegisterMetaType(scriptEngine, audioListenModeToScriptValue, audioListenModeFromScriptValue);
|
|
||||||
|
|
||||||
scriptEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarManager>().data());
|
scriptEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarManager>().data());
|
||||||
|
|
||||||
|
|
|
@ -562,8 +562,6 @@ Menu::Menu() {
|
||||||
false,
|
false,
|
||||||
&UserActivityLogger::getInstance(),
|
&UserActivityLogger::getInstance(),
|
||||||
SLOT(disable(bool)));
|
SLOT(disable(bool)));
|
||||||
addActionToQMenuAndActionHash(networkMenu, MenuOption::CachesSize, 0,
|
|
||||||
dialogsManager.data(), SLOT(cachesSizeDialog()));
|
|
||||||
addActionToQMenuAndActionHash(networkMenu, MenuOption::ShowDSConnectTable, 0,
|
addActionToQMenuAndActionHash(networkMenu, MenuOption::ShowDSConnectTable, 0,
|
||||||
dialogsManager.data(), SLOT(showDomainConnectionDialog()));
|
dialogsManager.data(), SLOT(showDomainConnectionDialog()));
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ namespace MenuOption {
|
||||||
const QString BinaryEyelidControl = "Binary Eyelid Control";
|
const QString BinaryEyelidControl = "Binary Eyelid Control";
|
||||||
const QString BookmarkLocation = "Bookmark Location";
|
const QString BookmarkLocation = "Bookmark Location";
|
||||||
const QString Bookmarks = "Bookmarks";
|
const QString Bookmarks = "Bookmarks";
|
||||||
const QString CachesSize = "RAM Caches Size";
|
|
||||||
const QString CalibrateCamera = "Calibrate Camera";
|
const QString CalibrateCamera = "Calibrate Camera";
|
||||||
const QString CameraEntityMode = "Entity Mode";
|
const QString CameraEntityMode = "Entity Mode";
|
||||||
const QString CenterPlayerInView = "Center Player In View";
|
const QString CenterPlayerInView = "Center Player In View";
|
||||||
|
|
|
@ -119,9 +119,7 @@ MyAvatar::MyAvatar(RigPointer rig) :
|
||||||
using namespace recording;
|
using namespace recording;
|
||||||
_skeletonModel->flagAsCauterized();
|
_skeletonModel->flagAsCauterized();
|
||||||
|
|
||||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
|
clearDriveKeys();
|
||||||
_driveKeys[i] = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Necessary to select the correct slot
|
// Necessary to select the correct slot
|
||||||
using SlotType = void(MyAvatar::*)(const glm::vec3&, bool, const glm::quat&, bool);
|
using SlotType = void(MyAvatar::*)(const glm::vec3&, bool, const glm::quat&, bool);
|
||||||
|
@ -230,6 +228,21 @@ MyAvatar::~MyAvatar() {
|
||||||
_lookAtTargetAvatar.reset();
|
_lookAtTargetAvatar.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyAvatar::registerMetaTypes(QScriptEngine* engine) {
|
||||||
|
QScriptValue value = engine->newQObject(this, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater | QScriptEngine::ExcludeChildObjects);
|
||||||
|
engine->globalObject().setProperty("MyAvatar", value);
|
||||||
|
|
||||||
|
QScriptValue driveKeys = engine->newObject();
|
||||||
|
auto metaEnum = QMetaEnum::fromType<DriveKeys>();
|
||||||
|
for (int i = 0; i < MAX_DRIVE_KEYS; ++i) {
|
||||||
|
driveKeys.setProperty(metaEnum.key(i), metaEnum.value(i));
|
||||||
|
}
|
||||||
|
engine->globalObject().setProperty("DriveKeys", driveKeys);
|
||||||
|
|
||||||
|
qScriptRegisterMetaType(engine, audioListenModeToScriptValue, audioListenModeFromScriptValue);
|
||||||
|
qScriptRegisterMetaType(engine, driveKeysToScriptValue, driveKeysFromScriptValue);
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::setOrientationVar(const QVariant& newOrientationVar) {
|
void MyAvatar::setOrientationVar(const QVariant& newOrientationVar) {
|
||||||
Avatar::setOrientation(quatFromVariant(newOrientationVar));
|
Avatar::setOrientation(quatFromVariant(newOrientationVar));
|
||||||
}
|
}
|
||||||
|
@ -462,7 +475,7 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
// When there are no step values, we zero out the last step pulse.
|
// When there are no step values, we zero out the last step pulse.
|
||||||
// This allows a user to do faster snapping by tapping a control
|
// This allows a user to do faster snapping by tapping a control
|
||||||
for (int i = STEP_TRANSLATE_X; !stepAction && i <= STEP_YAW; ++i) {
|
for (int i = STEP_TRANSLATE_X; !stepAction && i <= STEP_YAW; ++i) {
|
||||||
if (_driveKeys[i] != 0.0f) {
|
if (getDriveKey((DriveKeys)i) != 0.0f) {
|
||||||
stepAction = true;
|
stepAction = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1655,7 +1668,7 @@ 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[YAW] * _yawSpeed;
|
float targetSpeed = getDriveKey(YAW) * _yawSpeed;
|
||||||
if (targetSpeed != 0.0f) {
|
if (targetSpeed != 0.0f) {
|
||||||
const float ROTATION_RAMP_TIMESCALE = 0.1f;
|
const float ROTATION_RAMP_TIMESCALE = 0.1f;
|
||||||
float blend = deltaTime / ROTATION_RAMP_TIMESCALE;
|
float blend = deltaTime / ROTATION_RAMP_TIMESCALE;
|
||||||
|
@ -1684,8 +1697,8 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
// Comfort Mode: If you press any of the left/right rotation drive keys or input, you'll
|
// 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
|
// get an instantaneous 15 degree turn. If you keep holding the key down you'll get another
|
||||||
// snap turn every half second.
|
// snap turn every half second.
|
||||||
if (_driveKeys[STEP_YAW] != 0.0f) {
|
if (getDriveKey(STEP_YAW) != 0.0f) {
|
||||||
totalBodyYaw += _driveKeys[STEP_YAW];
|
totalBodyYaw += getDriveKey(STEP_YAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use head/HMD orientation to turn while flying
|
// use head/HMD orientation to turn while flying
|
||||||
|
@ -1722,7 +1735,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
// update body orientation by movement inputs
|
// update body orientation by movement inputs
|
||||||
setOrientation(getOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
setOrientation(getOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
||||||
|
|
||||||
getHead()->setBasePitch(getHead()->getBasePitch() + _driveKeys[PITCH] * _pitchSpeed * deltaTime);
|
getHead()->setBasePitch(getHead()->getBasePitch() + getDriveKey(PITCH) * _pitchSpeed * deltaTime);
|
||||||
|
|
||||||
if (qApp->isHMDMode()) {
|
if (qApp->isHMDMode()) {
|
||||||
glm::quat orientation = glm::quat_cast(getSensorToWorldMatrix()) * getHMDSensorOrientation();
|
glm::quat orientation = glm::quat_cast(getSensorToWorldMatrix()) * getHMDSensorOrientation();
|
||||||
|
@ -1756,14 +1769,14 @@ void MyAvatar::updateActionMotor(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute action input
|
// compute action input
|
||||||
glm::vec3 front = (_driveKeys[TRANSLATE_Z]) * IDENTITY_FRONT;
|
glm::vec3 front = (getDriveKey(TRANSLATE_Z)) * IDENTITY_FRONT;
|
||||||
glm::vec3 right = (_driveKeys[TRANSLATE_X]) * IDENTITY_RIGHT;
|
glm::vec3 right = (getDriveKey(TRANSLATE_X)) * IDENTITY_RIGHT;
|
||||||
|
|
||||||
glm::vec3 direction = front + right;
|
glm::vec3 direction = front + right;
|
||||||
CharacterController::State state = _characterController.getState();
|
CharacterController::State state = _characterController.getState();
|
||||||
if (state == CharacterController::State::Hover) {
|
if (state == CharacterController::State::Hover) {
|
||||||
// we're flying --> support vertical motion
|
// we're flying --> support vertical motion
|
||||||
glm::vec3 up = (_driveKeys[TRANSLATE_Y]) * IDENTITY_UP;
|
glm::vec3 up = (getDriveKey(TRANSLATE_Y)) * IDENTITY_UP;
|
||||||
direction += up;
|
direction += up;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1802,7 +1815,7 @@ void MyAvatar::updateActionMotor(float deltaTime) {
|
||||||
_actionMotorVelocity = MAX_WALKING_SPEED * direction;
|
_actionMotorVelocity = MAX_WALKING_SPEED * direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
float boomChange = _driveKeys[ZOOM];
|
float boomChange = getDriveKey(ZOOM);
|
||||||
_boomLength += 2.0f * _boomLength * boomChange + boomChange * boomChange;
|
_boomLength += 2.0f * _boomLength * boomChange + boomChange * boomChange;
|
||||||
_boomLength = glm::clamp<float>(_boomLength, ZOOM_MIN, ZOOM_MAX);
|
_boomLength = glm::clamp<float>(_boomLength, ZOOM_MIN, ZOOM_MAX);
|
||||||
}
|
}
|
||||||
|
@ -1833,11 +1846,11 @@ void MyAvatar::updatePosition(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// capture the head rotation, in sensor space, when the user first indicates they would like to move/fly.
|
// capture the head rotation, in sensor space, when the user first indicates they would like to move/fly.
|
||||||
if (!_hoverReferenceCameraFacingIsCaptured && (fabs(_driveKeys[TRANSLATE_Z]) > 0.1f || fabs(_driveKeys[TRANSLATE_X]) > 0.1f)) {
|
if (!_hoverReferenceCameraFacingIsCaptured && (fabs(getDriveKey(TRANSLATE_Z)) > 0.1f || fabs(getDriveKey(TRANSLATE_X)) > 0.1f)) {
|
||||||
_hoverReferenceCameraFacingIsCaptured = true;
|
_hoverReferenceCameraFacingIsCaptured = true;
|
||||||
// transform the camera facing vector into sensor space.
|
// transform the camera facing vector into sensor space.
|
||||||
_hoverReferenceCameraFacing = transformVectorFast(glm::inverse(_sensorToWorldMatrix), getHead()->getCameraOrientation() * Vectors::UNIT_Z);
|
_hoverReferenceCameraFacing = transformVectorFast(glm::inverse(_sensorToWorldMatrix), getHead()->getCameraOrientation() * Vectors::UNIT_Z);
|
||||||
} else if (_hoverReferenceCameraFacingIsCaptured && (fabs(_driveKeys[TRANSLATE_Z]) <= 0.1f && fabs(_driveKeys[TRANSLATE_X]) <= 0.1f)) {
|
} else if (_hoverReferenceCameraFacingIsCaptured && (fabs(getDriveKey(TRANSLATE_Z)) <= 0.1f && fabs(getDriveKey(TRANSLATE_X)) <= 0.1f)) {
|
||||||
_hoverReferenceCameraFacingIsCaptured = false;
|
_hoverReferenceCameraFacingIsCaptured = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2093,17 +2106,61 @@ bool MyAvatar::getCharacterControllerEnabled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::clearDriveKeys() {
|
void MyAvatar::clearDriveKeys() {
|
||||||
for (int i = 0; i < MAX_DRIVE_KEYS; ++i) {
|
_driveKeys.fill(0.0f);
|
||||||
_driveKeys[i] = 0.0f;
|
}
|
||||||
|
|
||||||
|
void MyAvatar::setDriveKey(DriveKeys key, float val) {
|
||||||
|
try {
|
||||||
|
_driveKeys.at(key) = val;
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float MyAvatar::getDriveKey(DriveKeys key) const {
|
||||||
|
return isDriveKeyDisabled(key) ? 0.0f : getRawDriveKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
float MyAvatar::getRawDriveKey(DriveKeys key) const {
|
||||||
|
try {
|
||||||
|
return _driveKeys.at(key);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||||
|
return 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::relayDriveKeysToCharacterController() {
|
void MyAvatar::relayDriveKeysToCharacterController() {
|
||||||
if (_driveKeys[TRANSLATE_Y] > 0.0f) {
|
if (getDriveKey(TRANSLATE_Y) > 0.0f) {
|
||||||
_characterController.jump();
|
_characterController.jump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyAvatar::disableDriveKey(DriveKeys key) {
|
||||||
|
try {
|
||||||
|
_disabledDriveKeys.set(key);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::enableDriveKey(DriveKeys key) {
|
||||||
|
try {
|
||||||
|
_disabledDriveKeys.reset(key);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MyAvatar::isDriveKeyDisabled(DriveKeys key) const {
|
||||||
|
try {
|
||||||
|
return _disabledDriveKeys.test(key);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::getWorldBodyPosition() const {
|
glm::vec3 MyAvatar::getWorldBodyPosition() const {
|
||||||
return transformPoint(_sensorToWorldMatrix, extractTranslation(_bodySensorMatrix));
|
return transformPoint(_sensorToWorldMatrix, extractTranslation(_bodySensorMatrix));
|
||||||
}
|
}
|
||||||
|
@ -2189,7 +2246,15 @@ QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioList
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioListenModeFromScriptValue(const QScriptValue& object, AudioListenerMode& audioListenerMode) {
|
void audioListenModeFromScriptValue(const QScriptValue& object, AudioListenerMode& audioListenerMode) {
|
||||||
audioListenerMode = (AudioListenerMode)object.toUInt16();
|
audioListenerMode = static_cast<AudioListenerMode>(object.toUInt16());
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue driveKeysToScriptValue(QScriptEngine* engine, const MyAvatar::DriveKeys& driveKeys) {
|
||||||
|
return driveKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
void driveKeysFromScriptValue(const QScriptValue& object, MyAvatar::DriveKeys& driveKeys) {
|
||||||
|
driveKeys = static_cast<MyAvatar::DriveKeys>(object.toUInt16());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2382,7 +2447,7 @@ bool MyAvatar::didTeleport() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyAvatar::hasDriveInput() const {
|
bool MyAvatar::hasDriveInput() const {
|
||||||
return fabsf(_driveKeys[TRANSLATE_X]) > 0.0f || fabsf(_driveKeys[TRANSLATE_Y]) > 0.0f || fabsf(_driveKeys[TRANSLATE_Z]) > 0.0f;
|
return fabsf(getDriveKey(TRANSLATE_X)) > 0.0f || fabsf(getDriveKey(TRANSLATE_Y)) > 0.0f || fabsf(getDriveKey(TRANSLATE_Z)) > 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setAway(bool value) {
|
void MyAvatar::setAway(bool value) {
|
||||||
|
@ -2498,7 +2563,7 @@ bool MyAvatar::pinJoint(int index, const glm::vec3& position, const glm::quat& o
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(position);
|
slamPosition(position);
|
||||||
setOrientation(orientation);
|
setOrientation(orientation);
|
||||||
|
|
||||||
_rig->setMaxHipsOffsetLength(0.05f);
|
_rig->setMaxHipsOffsetLength(0.05f);
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef hifi_MyAvatar_h
|
#ifndef hifi_MyAvatar_h
|
||||||
#define hifi_MyAvatar_h
|
#define hifi_MyAvatar_h
|
||||||
|
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include <SettingHandle.h>
|
#include <SettingHandle.h>
|
||||||
|
@ -29,20 +31,6 @@
|
||||||
class AvatarActionHold;
|
class AvatarActionHold;
|
||||||
class ModelItemID;
|
class ModelItemID;
|
||||||
|
|
||||||
enum DriveKeys {
|
|
||||||
TRANSLATE_X = 0,
|
|
||||||
TRANSLATE_Y,
|
|
||||||
TRANSLATE_Z,
|
|
||||||
YAW,
|
|
||||||
STEP_TRANSLATE_X,
|
|
||||||
STEP_TRANSLATE_Y,
|
|
||||||
STEP_TRANSLATE_Z,
|
|
||||||
STEP_YAW,
|
|
||||||
PITCH,
|
|
||||||
ZOOM,
|
|
||||||
MAX_DRIVE_KEYS
|
|
||||||
};
|
|
||||||
|
|
||||||
enum eyeContactTarget {
|
enum eyeContactTarget {
|
||||||
LEFT_EYE,
|
LEFT_EYE,
|
||||||
RIGHT_EYE,
|
RIGHT_EYE,
|
||||||
|
@ -88,9 +76,26 @@ class MyAvatar : public Avatar {
|
||||||
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
|
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum DriveKeys {
|
||||||
|
TRANSLATE_X = 0,
|
||||||
|
TRANSLATE_Y,
|
||||||
|
TRANSLATE_Z,
|
||||||
|
YAW,
|
||||||
|
STEP_TRANSLATE_X,
|
||||||
|
STEP_TRANSLATE_Y,
|
||||||
|
STEP_TRANSLATE_Z,
|
||||||
|
STEP_YAW,
|
||||||
|
PITCH,
|
||||||
|
ZOOM,
|
||||||
|
MAX_DRIVE_KEYS
|
||||||
|
};
|
||||||
|
Q_ENUM(DriveKeys)
|
||||||
|
|
||||||
explicit MyAvatar(RigPointer rig);
|
explicit MyAvatar(RigPointer rig);
|
||||||
~MyAvatar();
|
~MyAvatar();
|
||||||
|
|
||||||
|
void registerMetaTypes(QScriptEngine* engine);
|
||||||
|
|
||||||
virtual void simulateAttachments(float deltaTime) override;
|
virtual void simulateAttachments(float deltaTime) override;
|
||||||
|
|
||||||
AudioListenerMode getAudioListenerModeHead() const { return FROM_HEAD; }
|
AudioListenerMode getAudioListenerModeHead() const { return FROM_HEAD; }
|
||||||
|
@ -180,9 +185,15 @@ public:
|
||||||
|
|
||||||
// Set what driving keys are being pressed to control thrust levels
|
// Set what driving keys are being pressed to control thrust levels
|
||||||
void clearDriveKeys();
|
void clearDriveKeys();
|
||||||
void setDriveKeys(int key, float val) { _driveKeys[key] = val; };
|
void setDriveKey(DriveKeys key, float val);
|
||||||
|
float getDriveKey(DriveKeys key) const;
|
||||||
|
Q_INVOKABLE float getRawDriveKey(DriveKeys key) const;
|
||||||
void relayDriveKeysToCharacterController();
|
void relayDriveKeysToCharacterController();
|
||||||
|
|
||||||
|
Q_INVOKABLE void disableDriveKey(DriveKeys key);
|
||||||
|
Q_INVOKABLE void enableDriveKey(DriveKeys key);
|
||||||
|
Q_INVOKABLE bool isDriveKeyDisabled(DriveKeys key) const;
|
||||||
|
|
||||||
eyeContactTarget getEyeContactTarget();
|
eyeContactTarget getEyeContactTarget();
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec3 getTrackedHeadPosition() const { return _trackedHeadPosition; }
|
Q_INVOKABLE glm::vec3 getTrackedHeadPosition() const { return _trackedHeadPosition; }
|
||||||
|
@ -352,7 +363,6 @@ private:
|
||||||
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;
|
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;
|
||||||
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }
|
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }
|
||||||
bool getShouldRenderLocally() const { return _shouldRender; }
|
bool getShouldRenderLocally() const { return _shouldRender; }
|
||||||
bool getDriveKeys(int key) { return _driveKeys[key] != 0.0f; };
|
|
||||||
bool isMyAvatar() const override { return true; }
|
bool isMyAvatar() const override { return true; }
|
||||||
virtual int parseDataFromBuffer(const QByteArray& buffer) override;
|
virtual int parseDataFromBuffer(const QByteArray& buffer) override;
|
||||||
virtual glm::vec3 getSkeletonPosition() const override;
|
virtual glm::vec3 getSkeletonPosition() const override;
|
||||||
|
@ -388,7 +398,9 @@ private:
|
||||||
void clampScaleChangeToDomainLimits(float desiredScale);
|
void clampScaleChangeToDomainLimits(float desiredScale);
|
||||||
glm::mat4 computeCameraRelativeHandControllerMatrix(const glm::mat4& controllerSensorMatrix) const;
|
glm::mat4 computeCameraRelativeHandControllerMatrix(const glm::mat4& controllerSensorMatrix) const;
|
||||||
|
|
||||||
float _driveKeys[MAX_DRIVE_KEYS];
|
std::array<float, MAX_DRIVE_KEYS> _driveKeys;
|
||||||
|
std::bitset<MAX_DRIVE_KEYS> _disabledDriveKeys;
|
||||||
|
|
||||||
bool _wasPushing;
|
bool _wasPushing;
|
||||||
bool _isPushing;
|
bool _isPushing;
|
||||||
bool _isBeingPushed;
|
bool _isBeingPushed;
|
||||||
|
@ -541,4 +553,7 @@ private:
|
||||||
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);
|
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);
|
||||||
void audioListenModeFromScriptValue(const QScriptValue& object, AudioListenerMode& audioListenerMode);
|
void audioListenModeFromScriptValue(const QScriptValue& object, AudioListenerMode& audioListenerMode);
|
||||||
|
|
||||||
|
QScriptValue driveKeysToScriptValue(QScriptEngine* engine, const MyAvatar::DriveKeys& driveKeys);
|
||||||
|
void driveKeysFromScriptValue(const QScriptValue& object, MyAvatar::DriveKeys& driveKeys);
|
||||||
|
|
||||||
#endif // hifi_MyAvatar_h
|
#endif // hifi_MyAvatar_h
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
//
|
|
||||||
// CachesSizeDialog.cpp
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by Clement on 1/12/15.
|
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <QDoubleSpinBox>
|
|
||||||
#include <QFormLayout>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
#include <AnimationCache.h>
|
|
||||||
#include <DependencyManager.h>
|
|
||||||
#include <GeometryCache.h>
|
|
||||||
#include <SoundCache.h>
|
|
||||||
#include <TextureCache.h>
|
|
||||||
|
|
||||||
#include "CachesSizeDialog.h"
|
|
||||||
|
|
||||||
|
|
||||||
QDoubleSpinBox* createDoubleSpinBox(QWidget* parent) {
|
|
||||||
QDoubleSpinBox* box = new QDoubleSpinBox(parent);
|
|
||||||
box->setDecimals(0);
|
|
||||||
box->setRange(MIN_UNUSED_MAX_SIZE / BYTES_PER_MEGABYTES, MAX_UNUSED_MAX_SIZE / BYTES_PER_MEGABYTES);
|
|
||||||
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
CachesSizeDialog::CachesSizeDialog(QWidget* parent) :
|
|
||||||
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint)
|
|
||||||
{
|
|
||||||
setWindowTitle("Caches Size");
|
|
||||||
|
|
||||||
// Create layouter
|
|
||||||
QFormLayout* form = new QFormLayout(this);
|
|
||||||
setLayout(form);
|
|
||||||
|
|
||||||
form->addRow("Animations cache size (MB):", _animations = createDoubleSpinBox(this));
|
|
||||||
form->addRow("Geometries cache size (MB):", _geometries = createDoubleSpinBox(this));
|
|
||||||
form->addRow("Sounds cache size (MB):", _sounds = createDoubleSpinBox(this));
|
|
||||||
form->addRow("Textures cache size (MB):", _textures = createDoubleSpinBox(this));
|
|
||||||
|
|
||||||
resetClicked(true);
|
|
||||||
|
|
||||||
// Add a button to reset
|
|
||||||
QPushButton* confirmButton = new QPushButton("Confirm", this);
|
|
||||||
QPushButton* resetButton = new QPushButton("Reset", this);
|
|
||||||
form->addRow(confirmButton, resetButton);
|
|
||||||
connect(confirmButton, SIGNAL(clicked(bool)), this, SLOT(confirmClicked(bool)));
|
|
||||||
connect(resetButton, SIGNAL(clicked(bool)), this, SLOT(resetClicked(bool)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CachesSizeDialog::confirmClicked(bool checked) {
|
|
||||||
DependencyManager::get<AnimationCache>()->setUnusedResourceCacheSize(_animations->value() * BYTES_PER_MEGABYTES);
|
|
||||||
DependencyManager::get<ModelCache>()->setUnusedResourceCacheSize(_geometries->value() * BYTES_PER_MEGABYTES);
|
|
||||||
DependencyManager::get<SoundCache>()->setUnusedResourceCacheSize(_sounds->value() * BYTES_PER_MEGABYTES);
|
|
||||||
// Disabling the texture cache because it's a liability in cases where we're overcommiting GPU memory
|
|
||||||
#if 0
|
|
||||||
DependencyManager::get<TextureCache>()->setUnusedResourceCacheSize(_textures->value() * BYTES_PER_MEGABYTES);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QDialog::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CachesSizeDialog::resetClicked(bool checked) {
|
|
||||||
_animations->setValue(DependencyManager::get<AnimationCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
|
||||||
_geometries->setValue(DependencyManager::get<ModelCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
|
||||||
_sounds->setValue(DependencyManager::get<SoundCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
|
||||||
_textures->setValue(DependencyManager::get<TextureCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CachesSizeDialog::reject() {
|
|
||||||
// Just regularly close upon ESC
|
|
||||||
QDialog::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CachesSizeDialog::closeEvent(QCloseEvent* event) {
|
|
||||||
QDialog::closeEvent(event);
|
|
||||||
emit closed();
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
//
|
|
||||||
// CachesSizeDialog.h
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by Clement on 1/12/15.
|
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef hifi_CachesSizeDialog_h
|
|
||||||
#define hifi_CachesSizeDialog_h
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class QDoubleSpinBox;
|
|
||||||
|
|
||||||
class CachesSizeDialog : public QDialog {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
// Sets up the UI
|
|
||||||
CachesSizeDialog(QWidget* parent);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void closed();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void reject() override;
|
|
||||||
void confirmClicked(bool checked);
|
|
||||||
void resetClicked(bool checked);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Emits a 'closed' signal when this dialog is closed.
|
|
||||||
void closeEvent(QCloseEvent* event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QDoubleSpinBox* _animations = nullptr;
|
|
||||||
QDoubleSpinBox* _geometries = nullptr;
|
|
||||||
QDoubleSpinBox* _scripts = nullptr;
|
|
||||||
QDoubleSpinBox* _sounds = nullptr;
|
|
||||||
QDoubleSpinBox* _textures = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // hifi_CachesSizeDialog_h
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
|
||||||
#include "AddressBarDialog.h"
|
#include "AddressBarDialog.h"
|
||||||
#include "CachesSizeDialog.h"
|
|
||||||
#include "ConnectionFailureDialog.h"
|
#include "ConnectionFailureDialog.h"
|
||||||
#include "DomainConnectionDialog.h"
|
#include "DomainConnectionDialog.h"
|
||||||
#include "HMDToolsDialog.h"
|
#include "HMDToolsDialog.h"
|
||||||
|
@ -91,16 +90,6 @@ void DialogsManager::octreeStatsDetails() {
|
||||||
_octreeStatsDialog->raise();
|
_octreeStatsDialog->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsManager::cachesSizeDialog() {
|
|
||||||
if (!_cachesSizeDialog) {
|
|
||||||
maybeCreateDialog(_cachesSizeDialog);
|
|
||||||
|
|
||||||
connect(_cachesSizeDialog, SIGNAL(closed()), _cachesSizeDialog, SLOT(deleteLater()));
|
|
||||||
_cachesSizeDialog->show();
|
|
||||||
}
|
|
||||||
_cachesSizeDialog->raise();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DialogsManager::lodTools() {
|
void DialogsManager::lodTools() {
|
||||||
if (!_lodToolsDialog) {
|
if (!_lodToolsDialog) {
|
||||||
maybeCreateDialog(_lodToolsDialog);
|
maybeCreateDialog(_lodToolsDialog);
|
||||||
|
|
|
@ -48,7 +48,6 @@ public slots:
|
||||||
void toggleLoginDialog();
|
void toggleLoginDialog();
|
||||||
void showLoginDialog();
|
void showLoginDialog();
|
||||||
void octreeStatsDetails();
|
void octreeStatsDetails();
|
||||||
void cachesSizeDialog();
|
|
||||||
void lodTools();
|
void lodTools();
|
||||||
void hmdTools(bool showTools);
|
void hmdTools(bool showTools);
|
||||||
void showScriptEditor();
|
void showScriptEditor();
|
||||||
|
|
|
@ -160,7 +160,7 @@ AudioClient::AudioClient() :
|
||||||
_loopbackAudioOutput(NULL),
|
_loopbackAudioOutput(NULL),
|
||||||
_loopbackOutputDevice(NULL),
|
_loopbackOutputDevice(NULL),
|
||||||
_inputRingBuffer(0),
|
_inputRingBuffer(0),
|
||||||
_localInjectorsStream(0),
|
_localInjectorsStream(0, 1),
|
||||||
_receivedAudioStream(RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES),
|
_receivedAudioStream(RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES),
|
||||||
_isStereoInput(false),
|
_isStereoInput(false),
|
||||||
_outputStarveDetectionStartTimeMsec(0),
|
_outputStarveDetectionStartTimeMsec(0),
|
||||||
|
|
|
@ -6,26 +6,35 @@
|
||||||
var ANIMATION_FPS = 30;
|
var ANIMATION_FPS = 30;
|
||||||
var ANIMATION_FIRST_FRAME = 1;
|
var ANIMATION_FIRST_FRAME = 1;
|
||||||
var ANIMATION_LAST_FRAME = 10;
|
var ANIMATION_LAST_FRAME = 10;
|
||||||
var RELEASE_KEYS = ['w', 'a', 's', 'd', 'UP', 'LEFT', 'DOWN', 'RIGHT'];
|
|
||||||
var RELEASE_TIME = 500; // ms
|
var RELEASE_TIME = 500; // ms
|
||||||
var RELEASE_DISTANCE = 0.2; // meters
|
var RELEASE_DISTANCE = 0.2; // meters
|
||||||
var MAX_IK_ERROR = 30;
|
var MAX_IK_ERROR = 30;
|
||||||
|
var IK_SETTLE_TIME = 250; // ms
|
||||||
var DESKTOP_UI_CHECK_INTERVAL = 100;
|
var DESKTOP_UI_CHECK_INTERVAL = 100;
|
||||||
var DESKTOP_MAX_DISTANCE = 5;
|
var DESKTOP_MAX_DISTANCE = 5;
|
||||||
var SIT_DELAY = 25
|
var SIT_DELAY = 25;
|
||||||
var MAX_RESET_DISTANCE = 0.5
|
var MAX_RESET_DISTANCE = 0.5; // meters
|
||||||
|
var OVERRIDEN_DRIVE_KEYS = [
|
||||||
|
DriveKeys.TRANSLATE_X,
|
||||||
|
DriveKeys.TRANSLATE_Y,
|
||||||
|
DriveKeys.TRANSLATE_Z,
|
||||||
|
DriveKeys.STEP_TRANSLATE_X,
|
||||||
|
DriveKeys.STEP_TRANSLATE_Y,
|
||||||
|
DriveKeys.STEP_TRANSLATE_Z,
|
||||||
|
];
|
||||||
|
|
||||||
this.entityID = null;
|
this.entityID = null;
|
||||||
this.timers = {};
|
|
||||||
this.animStateHandlerID = null;
|
this.animStateHandlerID = null;
|
||||||
this.interval = null;
|
this.interval = null;
|
||||||
|
this.sitDownSettlePeriod = null;
|
||||||
|
this.lastTimeNoDriveKeys = null;
|
||||||
|
|
||||||
this.preload = function(entityID) {
|
this.preload = function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
}
|
}
|
||||||
this.unload = function() {
|
this.unload = function() {
|
||||||
if (Settings.getValue(SETTING_KEY) === this.entityID) {
|
if (Settings.getValue(SETTING_KEY) === this.entityID) {
|
||||||
this.sitUp();
|
this.standUp();
|
||||||
}
|
}
|
||||||
if (this.interval !== null) {
|
if (this.interval !== null) {
|
||||||
Script.clearInterval(this.interval);
|
Script.clearInterval(this.interval);
|
||||||
|
@ -96,6 +105,11 @@
|
||||||
print("Someone is already sitting in that chair.");
|
print("Someone is already sitting in that chair.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
print("Sitting down (" + this.entityID + ")");
|
||||||
|
|
||||||
|
var now = Date.now();
|
||||||
|
this.sitDownSettlePeriod = now + IK_SETTLE_TIME;
|
||||||
|
this.lastTimeNoDriveKeys = now;
|
||||||
|
|
||||||
var previousValue = Settings.getValue(SETTING_KEY);
|
var previousValue = Settings.getValue(SETTING_KEY);
|
||||||
Settings.setValue(SETTING_KEY, this.entityID);
|
Settings.setValue(SETTING_KEY, this.entityID);
|
||||||
|
@ -118,20 +132,17 @@
|
||||||
return { headType: 0 };
|
return { headType: 0 };
|
||||||
}, ["headType"]);
|
}, ["headType"]);
|
||||||
Script.update.connect(this, this.update);
|
Script.update.connect(this, this.update);
|
||||||
Controller.keyPressEvent.connect(this, this.keyPressed);
|
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
||||||
Controller.keyReleaseEvent.connect(this, this.keyReleased);
|
MyAvatar.disableDriveKey(OVERRIDEN_DRIVE_KEYS[i]);
|
||||||
for (var i in RELEASE_KEYS) {
|
|
||||||
Controller.captureKeyEvents({ text: RELEASE_KEYS[i] });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sitUp = function() {
|
this.standUp = function() {
|
||||||
|
print("Standing up (" + this.entityID + ")");
|
||||||
MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);
|
MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);
|
||||||
Script.update.disconnect(this, this.update);
|
Script.update.disconnect(this, this.update);
|
||||||
Controller.keyPressEvent.disconnect(this, this.keyPressed);
|
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
||||||
Controller.keyReleaseEvent.disconnect(this, this.keyReleased);
|
MyAvatar.enableDriveKey(OVERRIDEN_DRIVE_KEYS[i]);
|
||||||
for (var i in RELEASE_KEYS) {
|
|
||||||
Controller.releaseKeyEvents({ text: RELEASE_KEYS[i] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setSeatUser(null);
|
this.setSeatUser(null);
|
||||||
|
@ -156,6 +167,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function called by teleport.js if it detects the appropriate userData
|
||||||
this.sit = function () {
|
this.sit = function () {
|
||||||
this.sitDown();
|
this.sitDown();
|
||||||
}
|
}
|
||||||
|
@ -207,7 +219,33 @@
|
||||||
var properties = Entities.getEntityProperties(this.entityID);
|
var properties = Entities.getEntityProperties(this.entityID);
|
||||||
var avatarDistance = Vec3.distance(MyAvatar.position, properties.position);
|
var avatarDistance = Vec3.distance(MyAvatar.position, properties.position);
|
||||||
var ikError = MyAvatar.getIKErrorOnLastSolve();
|
var ikError = MyAvatar.getIKErrorOnLastSolve();
|
||||||
if (avatarDistance > RELEASE_DISTANCE || ikError > MAX_IK_ERROR) {
|
var now = Date.now();
|
||||||
|
var shouldStandUp = false;
|
||||||
|
|
||||||
|
// Check if a drive key is pressed
|
||||||
|
var hasActiveDriveKey = false;
|
||||||
|
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
||||||
|
if (MyAvatar.getRawDriveKey(OVERRIDEN_DRIVE_KEYS[i]) != 0.0) {
|
||||||
|
hasActiveDriveKey = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only standup if user has been pushing a drive key for RELEASE_TIME
|
||||||
|
if (hasActiveDriveKey) {
|
||||||
|
var elapsed = now - this.lastTimeNoDriveKeys;
|
||||||
|
shouldStandUp = elapsed > RELEASE_TIME;
|
||||||
|
} else {
|
||||||
|
this.lastTimeNoDriveKeys = Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow some time for the IK to settle
|
||||||
|
if (ikError > MAX_IK_ERROR && now > this.sitDownSettlePeriod) {
|
||||||
|
shouldStandUp = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (shouldStandUp || avatarDistance > RELEASE_DISTANCE) {
|
||||||
print("IK error: " + ikError + ", distance from chair: " + avatarDistance);
|
print("IK error: " + ikError + ", distance from chair: " + avatarDistance);
|
||||||
|
|
||||||
// Move avatar in front of the chair to avoid getting stuck in collision hulls
|
// Move avatar in front of the chair to avoid getting stuck in collision hulls
|
||||||
|
@ -215,45 +253,13 @@
|
||||||
var offset = { x: 0, y: 1.0, z: -0.5 - properties.dimensions.z * properties.registrationPoint.z };
|
var offset = { x: 0, y: 1.0, z: -0.5 - properties.dimensions.z * properties.registrationPoint.z };
|
||||||
var position = Vec3.sum(properties.position, Vec3.multiplyQbyV(properties.rotation, offset));
|
var position = Vec3.sum(properties.position, Vec3.multiplyQbyV(properties.rotation, offset));
|
||||||
MyAvatar.position = position;
|
MyAvatar.position = position;
|
||||||
|
print("Moving Avatar in front of the chair.")
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sitUp();
|
this.standUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.keyPressed = function(event) {
|
|
||||||
if (isInEditMode()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RELEASE_KEYS.indexOf(event.text) !== -1) {
|
|
||||||
var that = this;
|
|
||||||
this.timers[event.text] = Script.setTimeout(function() {
|
|
||||||
delete that.timers[event.text];
|
|
||||||
|
|
||||||
var properties = Entities.getEntityProperties(that.entityID);
|
|
||||||
var avatarDistance = Vec3.distance(MyAvatar.position, properties.position);
|
|
||||||
|
|
||||||
// Move avatar in front of the chair to avoid getting stuck in collision hulls
|
|
||||||
if (avatarDistance < MAX_RESET_DISTANCE) {
|
|
||||||
var offset = { x: 0, y: 1.0, z: -0.5 - properties.dimensions.z * properties.registrationPoint.z };
|
|
||||||
var position = Vec3.sum(properties.position, Vec3.multiplyQbyV(properties.rotation, offset));
|
|
||||||
MyAvatar.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
that.sitUp();
|
|
||||||
}, RELEASE_TIME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.keyReleased = function(event) {
|
|
||||||
if (RELEASE_KEYS.indexOf(event.text) !== -1) {
|
|
||||||
if (this.timers[event.text]) {
|
|
||||||
Script.clearTimeout(this.timers[event.text]);
|
|
||||||
delete this.timers[event.text];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.canSitDesktop = function() {
|
this.canSitDesktop = function() {
|
||||||
var properties = Entities.getEntityProperties(this.entityID, ["position"]);
|
var properties = Entities.getEntityProperties(this.entityID, ["position"]);
|
||||||
var distanceFromSeat = Vec3.distance(MyAvatar.position, properties.position);
|
var distanceFromSeat = Vec3.distance(MyAvatar.position, properties.position);
|
||||||
|
|
Loading…
Reference in a new issue