mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:20:08 +02:00
add MyAvatar::_motionBehaviors (for obeyGravity)
Also reconcile Menu checkable set vs script-set collision groups.
This commit is contained in:
parent
0a7a5031ee
commit
0b5c1b0a9a
6 changed files with 41 additions and 8 deletions
|
@ -861,7 +861,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
|
|
||||||
case Qt::Key_G:
|
case Qt::Key_G:
|
||||||
if (isShifted) {
|
if (isShifted) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Gravity);
|
Menu::getInstance()->triggerOption(MenuOption::ObeyGravity);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -186,9 +186,9 @@ Menu::Menu() :
|
||||||
QAction::PreferencesRole);
|
QAction::PreferencesRole);
|
||||||
|
|
||||||
addDisabledActionAndSeparator(editMenu, "Physics");
|
addDisabledActionAndSeparator(editMenu, "Physics");
|
||||||
addCheckableActionToQMenuAndActionHash(editMenu, MenuOption::Gravity, Qt::SHIFT | Qt::Key_G, false);
|
QObject* avatar = appInstance->getAvatar();
|
||||||
|
addCheckableActionToQMenuAndActionHash(editMenu, MenuOption::ObeyGravity, Qt::SHIFT | Qt::Key_G, true,
|
||||||
|
avatar, SLOT(updateMotionBehaviorFlags()));
|
||||||
|
|
||||||
|
|
||||||
addAvatarCollisionSubMenu(editMenu);
|
addAvatarCollisionSubMenu(editMenu);
|
||||||
|
|
|
@ -313,7 +313,7 @@ namespace MenuOption {
|
||||||
const QString GoTo = "Go To...";
|
const QString GoTo = "Go To...";
|
||||||
const QString GoToDomain = "Go To Domain...";
|
const QString GoToDomain = "Go To Domain...";
|
||||||
const QString GoToLocation = "Go To Location...";
|
const QString GoToLocation = "Go To Location...";
|
||||||
const QString Gravity = "Use Gravity";
|
const QString ObeyGravity = "Obey Gravity";
|
||||||
const QString HandsCollideWithSelf = "Collide With Self";
|
const QString HandsCollideWithSelf = "Collide With Self";
|
||||||
const QString HeadMouse = "Head Mouse";
|
const QString HeadMouse = "Head Mouse";
|
||||||
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
||||||
|
|
|
@ -150,7 +150,7 @@ public:
|
||||||
void updateShapePositions();
|
void updateShapePositions();
|
||||||
|
|
||||||
quint32 getCollisionGroups() const { return _collisionGroups; }
|
quint32 getCollisionGroups() const { return _collisionGroups; }
|
||||||
void setCollisionGroups(quint32 collisionGroups) { _collisionGroups = (collisionGroups & VALID_COLLISION_GROUPS); }
|
virtual void setCollisionGroups(quint32 collisionGroups) { _collisionGroups = (collisionGroups & VALID_COLLISION_GROUPS); }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateCollisionGroups();
|
void updateCollisionGroups();
|
||||||
|
|
|
@ -59,6 +59,7 @@ MyAvatar::MyAvatar() :
|
||||||
_thrust(0.0f),
|
_thrust(0.0f),
|
||||||
_isThrustOn(false),
|
_isThrustOn(false),
|
||||||
_thrustMultiplier(1.0f),
|
_thrustMultiplier(1.0f),
|
||||||
|
_motionBehaviors(0),
|
||||||
_lastBodyPenetration(0.0f),
|
_lastBodyPenetration(0.0f),
|
||||||
_lookAtTargetAvatar(),
|
_lookAtTargetAvatar(),
|
||||||
_shouldRender(true),
|
_shouldRender(true),
|
||||||
|
@ -123,7 +124,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
head->setAudioLoudness(audio->getLastInputLoudness());
|
head->setAudioLoudness(audio->getLastInputLoudness());
|
||||||
head->setAudioAverageLoudness(audio->getAudioAverageInputLoudness());
|
head->setAudioAverageLoudness(audio->getAudioAverageInputLoudness());
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {
|
if (_motionBehaviors & AVATAR_MOTION_OBEY_GRAVITY) {
|
||||||
setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()));
|
setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()));
|
||||||
} else {
|
} else {
|
||||||
setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
|
setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
|
@ -1134,7 +1135,28 @@ void MyAvatar::goToLocationFromResponse(const QJsonObject& jsonObject) {
|
||||||
setPosition(newPosition);
|
setPosition(newPosition);
|
||||||
emit transformChanged();
|
emit transformChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::updateMotionBehaviors() {
|
||||||
|
_motionBehaviors = 0;
|
||||||
|
if (Menu::getInstance()->isOptionChecked(MenuOption::ObeyGravity)) {
|
||||||
|
_motionBehaviors |= AVATAR_MOTION_OBEY_GRAVITY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::setCollisionGroups(quint32 collisionGroups) {
|
||||||
|
Avatar::setCollisionGroups(collisionGroups & VALID_COLLISION_GROUPS);
|
||||||
|
Menu* menu = Menu::getInstance();
|
||||||
|
menu->setIsOptionChecked(MenuOption::CollideWithEnvironment, (bool)(_collisionGroups & COLLISION_GROUP_ENVIRONMENT));
|
||||||
|
menu->setIsOptionChecked(MenuOption::CollideWithAvatars, (bool)(_collisionGroups & COLLISION_GROUP_AVATARS));
|
||||||
|
menu->setIsOptionChecked(MenuOption::CollideWithVoxels, (bool)(_collisionGroups & COLLISION_GROUP_VOXELS));
|
||||||
|
menu->setIsOptionChecked(MenuOption::CollideWithParticles, (bool)(_collisionGroups & COLLISION_GROUP_PARTICLES));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::setMotionBehaviors(quint32 flags) {
|
||||||
|
_motionBehaviors = flags;
|
||||||
|
Menu* menu = Menu::getInstance();
|
||||||
|
menu->setIsOptionChecked(MenuOption::ObeyGravity, (bool)(_motionBehaviors & AVATAR_MOTION_OBEY_GRAVITY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) {
|
void MyAvatar::applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) {
|
||||||
|
|
|
@ -25,9 +25,12 @@ enum AvatarHandState
|
||||||
NUM_HAND_STATES
|
NUM_HAND_STATES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const quint32 AVATAR_MOTION_OBEY_GRAVITY = 1U << 0;
|
||||||
|
|
||||||
class MyAvatar : public Avatar {
|
class MyAvatar : public Avatar {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
|
Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
|
||||||
|
Q_PROPERTY(quint32 motionBehaviors READ getMotionBehaviors WRITE setMotionBehaviors)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyAvatar();
|
MyAvatar();
|
||||||
|
@ -88,6 +91,10 @@ public:
|
||||||
virtual void setFaceModelURL(const QUrl& faceModelURL);
|
virtual void setFaceModelURL(const QUrl& faceModelURL);
|
||||||
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL);
|
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL);
|
||||||
|
|
||||||
|
virtual void setCollisionGroups(quint32 collisionGroups);
|
||||||
|
void setMotionBehaviors(quint32 flags);
|
||||||
|
quint32 getMotionBehaviors() const { return _motionBehaviors; }
|
||||||
|
|
||||||
void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration);
|
void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -104,6 +111,8 @@ public slots:
|
||||||
glm::vec3 getThrust() { return _thrust; };
|
glm::vec3 getThrust() { return _thrust; };
|
||||||
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
|
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
|
||||||
|
|
||||||
|
void updateMotionBehaviors();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void transformChanged();
|
void transformChanged();
|
||||||
|
|
||||||
|
@ -123,6 +132,8 @@ private:
|
||||||
bool _isThrustOn;
|
bool _isThrustOn;
|
||||||
float _thrustMultiplier;
|
float _thrustMultiplier;
|
||||||
|
|
||||||
|
quint32 _motionBehaviors;
|
||||||
|
|
||||||
glm::vec3 _lastBodyPenetration;
|
glm::vec3 _lastBodyPenetration;
|
||||||
QWeakPointer<AvatarData> _lookAtTargetAvatar;
|
QWeakPointer<AvatarData> _lookAtTargetAvatar;
|
||||||
glm::vec3 _targetAvatarPosition;
|
glm::vec3 _targetAvatarPosition;
|
||||||
|
|
Loading…
Reference in a new issue