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) {
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;
}
@ -1816,6 +1816,16 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
_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;
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
if (entityTreeRenderer) {
@ -1824,12 +1834,16 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
ghostingAllowed = zone->getGhostingAllowed();
}
}
bool checked = menu->isOptionChecked(MenuOption::EnableCharacterController);
if (!ghostingAllowed) {
checked = true;
}
_characterController.setEnabled(ghostingAllowed ? enabled : 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() {

View file

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