mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 11:35:20 +02:00
Show hand controllers when out-of-body for more then 3/4 of a second
Without the timer, the hands can flicker in and out of visibility when lightly brushing against collision.
This commit is contained in:
parent
c78f2b5409
commit
69bd4ccea2
3 changed files with 35 additions and 3 deletions
|
@ -88,6 +88,8 @@ const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
|||
extern glm::vec3 TRUNCATE_IK_CAPSULE_POSITION;
|
||||
extern float TRUNCATE_IK_CAPSULE_LENGTH;
|
||||
extern float TRUNCATE_IK_CAPSULE_RADIUS;
|
||||
extern float MIN_OUT_OF_BODY_DISTANCE;
|
||||
extern float MAX_OUT_OF_BODY_DISTANCE;
|
||||
|
||||
MyAvatar::MyAvatar(RigPointer rig) :
|
||||
Avatar(rig),
|
||||
|
@ -365,6 +367,27 @@ void MyAvatar::update(float deltaTime) {
|
|||
|
||||
simulate(deltaTime);
|
||||
|
||||
// Request to show the hand controllers if we're out-of-body for more then HAND_CONTROLLER_SHOW_TIME.
|
||||
// Similarlly request to hide the controllers when we return to our bodies.
|
||||
const float HAND_CONTROLLER_SHOW_TIME = 0.75f;
|
||||
auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();
|
||||
if (isOutOfBody() != _handControllerShow) {
|
||||
_handControllerShowTimer += deltaTime;
|
||||
if (_handControllerShowTimer > HAND_CONTROLLER_SHOW_TIME) {
|
||||
if (isOutOfBody()) {
|
||||
hmdInterface->requestShowHandControllers();
|
||||
_handControllerShow = true;
|
||||
_handControllerShowTimer = 0.0f;
|
||||
} else {
|
||||
hmdInterface->requestHideHandControllers();
|
||||
_handControllerShow = false;
|
||||
_handControllerShowTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_handControllerShowTimer = 0.0f;
|
||||
}
|
||||
|
||||
currentEnergy += energyChargeRate;
|
||||
currentEnergy -= getAccelerationEnergy();
|
||||
currentEnergy -= getAudioEnergy();
|
||||
|
@ -2210,6 +2233,10 @@ glm::quat MyAvatar::getOrientationForAudio() {
|
|||
return quat();
|
||||
}
|
||||
|
||||
bool MyAvatar::isOutOfBody() const {
|
||||
return _follow._isOutOfBody;
|
||||
}
|
||||
|
||||
void MyAvatar::setAudioListenerMode(AudioListenerMode audioListenerMode) {
|
||||
if (_audioListenerMode != audioListenerMode) {
|
||||
_audioListenerMode = audioListenerMode;
|
||||
|
@ -2361,6 +2388,7 @@ void MyAvatar::FollowHelper::postPhysicsUpdate(MyAvatar& myAvatar) {
|
|||
glm::vec3 capsuleStart = myAvatar.getPosition() + Vectors::UNIT_Y * (TRUNCATE_IK_CAPSULE_LENGTH / 2.0f);
|
||||
glm::vec3 capsuleEnd = myAvatar.getPosition() - Vectors::UNIT_Y * (TRUNCATE_IK_CAPSULE_LENGTH / 2.0f);
|
||||
_isOutOfBody = !pointIsInsideCapsule(worldHMDPosition, capsuleStart, capsuleEnd, TRUNCATE_IK_CAPSULE_RADIUS);
|
||||
_outOfBodyDistance = distanceFromCapsule(worldHMDPosition, capsuleStart, capsuleEnd, TRUNCATE_IK_CAPSULE_RADIUS);
|
||||
}
|
||||
|
||||
float MyAvatar::getAccelerationEnergy() {
|
||||
|
|
|
@ -333,7 +333,7 @@ public slots:
|
|||
glm::vec3 getPositionForAudio();
|
||||
glm::quat getOrientationForAudio();
|
||||
|
||||
bool isOutOfBody() const { return _follow._isOutOfBody; }
|
||||
bool isOutOfBody() const;
|
||||
|
||||
signals:
|
||||
void audioListenerModeChanged();
|
||||
|
@ -467,6 +467,7 @@ private:
|
|||
};
|
||||
uint8_t _activeBits { 0 };
|
||||
bool _isOutOfBody { false };
|
||||
float _outOfBodyDistance { 0.0f };
|
||||
|
||||
void deactivate();
|
||||
void deactivate(FollowType type);
|
||||
|
@ -541,6 +542,9 @@ private:
|
|||
};
|
||||
DebugDrawVertex _debugLineLoop[DEBUG_LINE_LOOP_SIZE];
|
||||
size_t _debugLineLoopIndex { 0 };
|
||||
|
||||
bool _handControllerShow { false };
|
||||
float _handControllerShowTimer { 0.0f };
|
||||
};
|
||||
|
||||
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
glm::vec3 TRUNCATE_IK_CAPSULE_POSITION(0.0f, 0.0f, 0.0f);
|
||||
float TRUNCATE_IK_CAPSULE_LENGTH = 1000.0f;
|
||||
float TRUNCATE_IK_CAPSULE_RADIUS = 0.25f;
|
||||
float MIN_OUT_OF_BODY_DISTANCE = TRUNCATE_IK_CAPSULE_RADIUS - 0.1f;
|
||||
float MAX_OUT_OF_BODY_DISTANCE = TRUNCATE_IK_CAPSULE_RADIUS + 0.1f;
|
||||
|
||||
SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer rig) :
|
||||
Model(rig, parent),
|
||||
|
@ -165,8 +167,6 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
Rig::HandParameters handParams;
|
||||
|
||||
// compute interp factor between in body and out of body hand positions.
|
||||
const float MIN_OUT_OF_BODY_DISTANCE = TRUNCATE_IK_CAPSULE_RADIUS - 0.1f;
|
||||
const float MAX_OUT_OF_BODY_DISTANCE = TRUNCATE_IK_CAPSULE_RADIUS + 0.1f;
|
||||
glm::vec3 capsuleStart = Vectors::UNIT_Y * (TRUNCATE_IK_CAPSULE_LENGTH / 2.0f);
|
||||
glm::vec3 capsuleEnd = -Vectors::UNIT_Y * (TRUNCATE_IK_CAPSULE_LENGTH / 2.0f);
|
||||
float outOfBodyAlpha = distanceFromCapsule(hmdPositionInRigSpace, capsuleStart, capsuleEnd, TRUNCATE_IK_CAPSULE_RADIUS);
|
||||
|
|
Loading…
Reference in a new issue