Added MyAvatar.characterControllerEnabled property

This commit is contained in:
Anthony J. Thibault 2016-06-07 16:55:32 -07:00
parent 9292a9ce0b
commit 30d8ae36e8
2 changed files with 24 additions and 6 deletions

View file

@ -234,7 +234,7 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) {
void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) { void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
if (QThread::currentThread() != thread()) { if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter)); QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter), Q_ARG(bool, andReload), Q_ARG(bool, andHead));
return; return;
} }
@ -1816,6 +1816,16 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
_motionBehaviors &= ~AVATAR_MOTION_SCRIPTED_MOTOR_ENABLED; _motionBehaviors &= ~AVATAR_MOTION_SCRIPTED_MOTOR_ENABLED;
} }
setCharacterControllerEnabled(menu->isOptionChecked(MenuOption::EnableCharacterController));
}
void MyAvatar::setCharacterControllerEnabled(bool enabled) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "setCharacterControllerEnabled", Q_ARG(bool, enabled));
return;
}
bool ghostingAllowed = true; bool ghostingAllowed = true;
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities(); EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
if (entityTreeRenderer) { if (entityTreeRenderer) {
@ -1824,12 +1834,16 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
ghostingAllowed = zone->getGhostingAllowed(); ghostingAllowed = zone->getGhostingAllowed();
} }
} }
bool checked = menu->isOptionChecked(MenuOption::EnableCharacterController); _characterController.setEnabled(ghostingAllowed ? enabled : true);
if (!ghostingAllowed) { }
checked = true;
}
_characterController.setEnabled(checked); bool MyAvatar::getCharacterControllerEnabled() {
if (QThread::currentThread() != thread()) {
bool result;
QMetaObject::invokeMethod(this, "getCharacterControllerEnabled", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, result));
return result;
}
return _characterController.isEnabled();
} }
void MyAvatar::clearDriveKeys() { void MyAvatar::clearDriveKeys() {

View file

@ -84,6 +84,7 @@ class MyAvatar : public Avatar {
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy) Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
Q_PROPERTY(bool hmdLeanRecenterEnabled READ getHMDLeanRecenterEnabled WRITE setHMDLeanRecenterEnabled) Q_PROPERTY(bool hmdLeanRecenterEnabled READ getHMDLeanRecenterEnabled WRITE setHMDLeanRecenterEnabled)
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
public: public:
explicit MyAvatar(RigPointer rig); explicit MyAvatar(RigPointer rig);
@ -265,6 +266,9 @@ public:
controller::Pose getLeftHandControllerPoseInAvatarFrame() const; controller::Pose getLeftHandControllerPoseInAvatarFrame() const;
controller::Pose getRightHandControllerPoseInAvatarFrame() const; controller::Pose getRightHandControllerPoseInAvatarFrame() const;
Q_INVOKABLE void setCharacterControllerEnabled(bool enabled);
Q_INVOKABLE bool getCharacterControllerEnabled();
public slots: public slots:
void increaseSize(); void increaseSize();
void decreaseSize(); void decreaseSize();