mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:36:56 +02:00
Disable head look at when pointing
This commit is contained in:
parent
7c4fe39918
commit
0aab2ed07f
4 changed files with 40 additions and 36 deletions
|
@ -1652,7 +1652,7 @@
|
||||||
"alphaVar": "seatedPointBlendAlpha",
|
"alphaVar": "seatedPointBlendAlpha",
|
||||||
"blendType": "addAbsolute"
|
"blendType": "addAbsolute"
|
||||||
},
|
},
|
||||||
"id": "seatedReactionPoint",
|
"id": "seatedReactionPointBase",
|
||||||
"type": "blendLinear"
|
"type": "blendLinear"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1808,7 +1808,7 @@
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"alphaVar": "seatedPointAroundAlpha",
|
"alphaVar": "pointAroundAlpha",
|
||||||
"centerId": "seatedPointCenter",
|
"centerId": "seatedPointCenter",
|
||||||
"downId": "seatedPointDown",
|
"downId": "seatedPointDown",
|
||||||
"downLeftId": "seatedPointDownLeft",
|
"downLeftId": "seatedPointDownLeft",
|
||||||
|
@ -1825,7 +1825,7 @@
|
||||||
],
|
],
|
||||||
"data": {
|
"data": {
|
||||||
"alpha": 0,
|
"alpha": 0,
|
||||||
"alphaVar": "seatedPointBlendAlpha",
|
"alphaVar": "pointBlendAlpha",
|
||||||
"blendType": "addAbsolute"
|
"blendType": "addAbsolute"
|
||||||
},
|
},
|
||||||
"id": "seatedReactionPoint",
|
"id": "seatedReactionPoint",
|
||||||
|
@ -3967,7 +3967,7 @@
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"alphaVar": "idlePointAroundAlpha",
|
"alphaVar": "pointAroundAlpha",
|
||||||
"centerId": "idlePointCenter",
|
"centerId": "idlePointCenter",
|
||||||
"downId": "idlePointDown",
|
"downId": "idlePointDown",
|
||||||
"downLeftId": "idlePointDownLeft",
|
"downLeftId": "idlePointDownLeft",
|
||||||
|
@ -3984,7 +3984,7 @@
|
||||||
],
|
],
|
||||||
"data": {
|
"data": {
|
||||||
"alpha": 0,
|
"alpha": 0,
|
||||||
"alphaVar": "idlePointBlendAlpha",
|
"alphaVar": "pointBlendAlpha",
|
||||||
"blendType": "addAbsolute"
|
"blendType": "addAbsolute"
|
||||||
},
|
},
|
||||||
"id": "reactionPoint",
|
"id": "reactionPoint",
|
||||||
|
@ -6050,16 +6050,16 @@
|
||||||
"upLeftId": "lookUpLeft",
|
"upLeftId": "lookUpLeft",
|
||||||
"upRightId": "lookUpRight"
|
"upRightId": "lookUpRight"
|
||||||
},
|
},
|
||||||
"id": "lookAround",
|
"id": "lookAroundBlend",
|
||||||
"type": "blendDirectional"
|
"type": "blendDirectional"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"data": {
|
"data": {
|
||||||
"alpha": 0,
|
"alpha": 0,
|
||||||
"alphaVar": "additiveBlendAlpha",
|
"alphaVar": "lookBlendAlpha",
|
||||||
"blendType": "addAbsolute"
|
"blendType": "addAbsolute"
|
||||||
},
|
},
|
||||||
"id": "additiveBlend",
|
"id": "lookAround",
|
||||||
"type": "blendLinear"
|
"type": "blendLinear"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -99,14 +99,13 @@ static const QString USER_RECENTER_MODEL_FORCE_STAND = QStringLiteral("ForceStan
|
||||||
static const QString USER_RECENTER_MODEL_AUTO = QStringLiteral("Auto");
|
static const QString USER_RECENTER_MODEL_AUTO = QStringLiteral("Auto");
|
||||||
static const QString USER_RECENTER_MODEL_DISABLE_HMD_LEAN = QStringLiteral("DisableHMDLean");
|
static const QString USER_RECENTER_MODEL_DISABLE_HMD_LEAN = QStringLiteral("DisableHMDLean");
|
||||||
|
|
||||||
const QString HEAD_BLENDING_NAME = "lookAroundAlpha";
|
const QString HEAD_BLEND_DIRECTIONAL_ALPHA_NAME = "lookAroundAlpha";
|
||||||
const QString HEAD_ALPHA_NAME = "additiveBlendAlpha";
|
const QString HEAD_BLEND_LINEAR_ALPHA_NAME = "lookBlendAlpha";
|
||||||
const float HEAD_ALPHA_BLENDING = 1.0f;
|
const float HEAD_ALPHA_BLENDING = 1.0f;
|
||||||
|
|
||||||
const QString SEATED_POINT_BLENDING_NAME = "seatedPointAroundAlpha";
|
const QString POINT_REACTION_NAME = "point";
|
||||||
const QString SEATED_POINT_ALPHA_NAME = "seatedPointBlendAlpha";
|
const QString POINT_BLEND_DIRECTIONAL_ALPHA_NAME = "pointAroundAlpha";
|
||||||
const QString IDLE_POINT_BLENDING_NAME = "idlePointAroundAlpha";
|
const QString POINT_BLEND_LINEAR_ALPHA_NAME = "pointBlendAlpha";
|
||||||
const QString IDLE_POINT_ALPHA_NAME = "idlePointBlendAlpha";
|
|
||||||
const QString POINT_REF_JOINT_NAME = "RightShoulder";
|
const QString POINT_REF_JOINT_NAME = "RightShoulder";
|
||||||
const float POINT_ALPHA_BLENDING = 1.0f;
|
const float POINT_ALPHA_BLENDING = 1.0f;
|
||||||
|
|
||||||
|
@ -955,13 +954,16 @@ void MyAvatar::simulate(float deltaTime, bool inView) {
|
||||||
qCDebug(interfaceapp) << "MyAvatar::simulate headPosition is NaN";
|
qCDebug(interfaceapp) << "MyAvatar::simulate headPosition is NaN";
|
||||||
headPosition = glm::vec3(0.0f);
|
headPosition = glm::vec3(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
head->setPosition(headPosition);
|
head->setPosition(headPosition);
|
||||||
head->setScale(getModelScale());
|
head->setScale(getModelScale());
|
||||||
head->simulate(deltaTime);
|
head->simulate(deltaTime);
|
||||||
CameraMode mode = qApp->getCamera().getMode();
|
CameraMode mode = qApp->getCamera().getMode();
|
||||||
if (_scriptControlsHeadLookAt || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE) {
|
if (_scriptControlsHeadLookAt || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE) {
|
||||||
updateHeadLookAt(deltaTime);
|
if (!_pointAtActive) {
|
||||||
|
updateHeadLookAt(deltaTime);
|
||||||
|
} else {
|
||||||
|
resetHeadLookAt();
|
||||||
|
}
|
||||||
} else if (_headLookAtActive){
|
} else if (_headLookAtActive){
|
||||||
resetHeadLookAt();
|
resetHeadLookAt();
|
||||||
_headLookAtActive = false;
|
_headLookAtActive = false;
|
||||||
|
@ -6109,25 +6111,30 @@ bool MyAvatar::beginReaction(QString reactionName) {
|
||||||
if (reactionIndex >= 0 && reactionIndex < (int)NUM_AVATAR_BEGIN_END_REACTIONS) {
|
if (reactionIndex >= 0 && reactionIndex < (int)NUM_AVATAR_BEGIN_END_REACTIONS) {
|
||||||
std::lock_guard<std::mutex> guard(_reactionLock);
|
std::lock_guard<std::mutex> guard(_reactionLock);
|
||||||
_reactionEnabledRefCounts[reactionIndex]++;
|
_reactionEnabledRefCounts[reactionIndex]++;
|
||||||
|
if (reactionName == POINT_REACTION_NAME) {
|
||||||
|
_pointAtActive = true;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyAvatar::endReaction(QString reactionName) {
|
bool MyAvatar::endReaction(QString reactionName) {
|
||||||
if (reactionName == "point") {
|
|
||||||
resetPointAt();
|
|
||||||
}
|
|
||||||
int reactionIndex = beginEndReactionNameToIndex(reactionName);
|
int reactionIndex = beginEndReactionNameToIndex(reactionName);
|
||||||
if (reactionIndex >= 0 && reactionIndex < (int)NUM_AVATAR_BEGIN_END_REACTIONS) {
|
if (reactionIndex >= 0 && reactionIndex < (int)NUM_AVATAR_BEGIN_END_REACTIONS) {
|
||||||
std::lock_guard<std::mutex> guard(_reactionLock);
|
std::lock_guard<std::mutex> guard(_reactionLock);
|
||||||
|
bool wasReactionActive = true;
|
||||||
if (_reactionEnabledRefCounts[reactionIndex] > 0) {
|
if (_reactionEnabledRefCounts[reactionIndex] > 0) {
|
||||||
_reactionEnabledRefCounts[reactionIndex]--;
|
_reactionEnabledRefCounts[reactionIndex]--;
|
||||||
return true;
|
wasReactionActive = true;
|
||||||
} else {
|
} else {
|
||||||
_reactionEnabledRefCounts[reactionIndex] = 0;
|
_reactionEnabledRefCounts[reactionIndex] = 0;
|
||||||
return false;
|
wasReactionActive = false;
|
||||||
}
|
}
|
||||||
|
if (reactionName == POINT_REACTION_NAME) {
|
||||||
|
_pointAtActive = _reactionEnabledRefCounts[reactionIndex] > 0;
|
||||||
|
}
|
||||||
|
return wasReactionActive;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -6676,8 +6683,7 @@ glm::vec3 MyAvatar::aimToBlendValues(const glm::vec3& aimVector, const glm::quat
|
||||||
glm::vec3 aimDirection;
|
glm::vec3 aimDirection;
|
||||||
if (glm::length(aimVector) > EPSILON) {
|
if (glm::length(aimVector) > EPSILON) {
|
||||||
aimDirection = glm::normalize(aimVector);
|
aimDirection = glm::normalize(aimVector);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// aim vector is zero
|
// aim vector is zero
|
||||||
return glm::vec3();
|
return glm::vec3();
|
||||||
}
|
}
|
||||||
|
@ -6702,8 +6708,8 @@ glm::vec3 MyAvatar::aimToBlendValues(const glm::vec3& aimVector, const glm::quat
|
||||||
|
|
||||||
void MyAvatar::resetHeadLookAt() {
|
void MyAvatar::resetHeadLookAt() {
|
||||||
if (_skeletonModelLoaded) {
|
if (_skeletonModelLoaded) {
|
||||||
_skeletonModel->getRig().setDirectionalBlending(HEAD_BLENDING_NAME, glm::vec3(),
|
_skeletonModel->getRig().setDirectionalBlending(HEAD_BLEND_DIRECTIONAL_ALPHA_NAME, glm::vec3(),
|
||||||
HEAD_ALPHA_NAME, HEAD_ALPHA_BLENDING);
|
HEAD_BLEND_LINEAR_ALPHA_NAME, HEAD_ALPHA_BLENDING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6721,8 +6727,8 @@ void MyAvatar::updateHeadLookAt(float deltaTime) {
|
||||||
glm::vec3 lookAtTarget = _scriptControlsHeadLookAt ? _lookAtScriptTarget : _lookAtCameraTarget;
|
glm::vec3 lookAtTarget = _scriptControlsHeadLookAt ? _lookAtScriptTarget : _lookAtCameraTarget;
|
||||||
glm::vec3 aimVector = lookAtTarget - getDefaultEyePosition();
|
glm::vec3 aimVector = lookAtTarget - getDefaultEyePosition();
|
||||||
glm::vec3 lookAtBlend = aimToBlendValues(aimVector, getWorldOrientation());
|
glm::vec3 lookAtBlend = aimToBlendValues(aimVector, getWorldOrientation());
|
||||||
_skeletonModel->getRig().setDirectionalBlending(HEAD_BLENDING_NAME, lookAtBlend,
|
_skeletonModel->getRig().setDirectionalBlending(HEAD_BLEND_DIRECTIONAL_ALPHA_NAME, lookAtBlend,
|
||||||
HEAD_ALPHA_NAME, HEAD_ALPHA_BLENDING);
|
HEAD_BLEND_LINEAR_ALPHA_NAME, HEAD_ALPHA_BLENDING);
|
||||||
|
|
||||||
if (_scriptControlsHeadLookAt) {
|
if (_scriptControlsHeadLookAt) {
|
||||||
_scriptHeadControlTimer += deltaTime;
|
_scriptHeadControlTimer += deltaTime;
|
||||||
|
@ -6756,18 +6762,14 @@ void MyAvatar::setPointAt(const glm::vec3& pointAtTarget) {
|
||||||
if (_skeletonModelLoaded) {
|
if (_skeletonModelLoaded) {
|
||||||
glm::vec3 aimVector = pointAtTarget - getJointPosition(POINT_REF_JOINT_NAME);
|
glm::vec3 aimVector = pointAtTarget - getJointPosition(POINT_REF_JOINT_NAME);
|
||||||
glm::vec3 pointAtBlend = aimToBlendValues(aimVector, getWorldOrientation());
|
glm::vec3 pointAtBlend = aimToBlendValues(aimVector, getWorldOrientation());
|
||||||
_skeletonModel->getRig().setDirectionalBlending(IDLE_POINT_BLENDING_NAME, pointAtBlend,
|
_skeletonModel->getRig().setDirectionalBlending(POINT_BLEND_DIRECTIONAL_ALPHA_NAME, pointAtBlend,
|
||||||
IDLE_POINT_ALPHA_NAME, POINT_ALPHA_BLENDING);
|
POINT_BLEND_LINEAR_ALPHA_NAME, POINT_ALPHA_BLENDING);
|
||||||
_skeletonModel->getRig().setDirectionalBlending(SEATED_POINT_BLENDING_NAME, pointAtBlend,
|
|
||||||
SEATED_POINT_ALPHA_NAME, POINT_ALPHA_BLENDING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::resetPointAt() {
|
void MyAvatar::resetPointAt() {
|
||||||
if (_skeletonModelLoaded) {
|
if (_skeletonModelLoaded) {
|
||||||
_skeletonModel->getRig().setDirectionalBlending(IDLE_POINT_BLENDING_NAME, glm::vec3(),
|
_skeletonModel->getRig().setDirectionalBlending(POINT_BLEND_DIRECTIONAL_ALPHA_NAME, glm::vec3(),
|
||||||
IDLE_POINT_ALPHA_NAME, POINT_ALPHA_BLENDING);
|
POINT_BLEND_LINEAR_ALPHA_NAME, POINT_ALPHA_BLENDING);
|
||||||
_skeletonModel->getRig().setDirectionalBlending(SEATED_POINT_BLENDING_NAME, glm::vec3(),
|
|
||||||
SEATED_POINT_ALPHA_NAME, POINT_ALPHA_BLENDING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1769,7 +1769,7 @@ public:
|
||||||
* Aims the pointing directional blending towards the provided target point.
|
* Aims the pointing directional blending towards the provided target point.
|
||||||
* The "point" reaction should be triggered before using this method.
|
* The "point" reaction should be triggered before using this method.
|
||||||
* <code>MyAvatar.beginReaction("point")</code>
|
* <code>MyAvatar.beginReaction("point")</code>
|
||||||
* @function MyAvatar.startPointingAt
|
* @function MyAvatar.setPointingAt
|
||||||
* @param {Vec3} pointAtTarget - The target point in world coordinates.
|
* @param {Vec3} pointAtTarget - The target point in world coordinates.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void setPointAt(const glm::vec3& pointAtTarget);
|
Q_INVOKABLE void setPointAt(const glm::vec3& pointAtTarget);
|
||||||
|
@ -2662,6 +2662,7 @@ private:
|
||||||
bool _shouldTurnToFaceCamera { false };
|
bool _shouldTurnToFaceCamera { false };
|
||||||
bool _scriptControlsHeadLookAt { false };
|
bool _scriptControlsHeadLookAt { false };
|
||||||
float _scriptHeadControlTimer { 0.0f };
|
float _scriptHeadControlTimer { 0.0f };
|
||||||
|
bool _pointAtActive{ false };
|
||||||
|
|
||||||
Setting::Handle<float> _realWorldFieldOfView;
|
Setting::Handle<float> _realWorldFieldOfView;
|
||||||
Setting::Handle<bool> _useAdvancedMovementControls;
|
Setting::Handle<bool> _useAdvancedMovementControls;
|
||||||
|
|
|
@ -236,6 +236,7 @@ function beginReactionWrapper(reaction) {
|
||||||
break;
|
break;
|
||||||
case ("point"):
|
case ("point"):
|
||||||
deleteOldReticles();
|
deleteOldReticles();
|
||||||
|
pointAtTarget = MyAvatar.getHeadLookAt();
|
||||||
if (!mouseMoveEventsConnected) {
|
if (!mouseMoveEventsConnected) {
|
||||||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||||
mouseMoveEventsConnected = true;
|
mouseMoveEventsConnected = true;
|
||||||
|
|
Loading…
Reference in a new issue