mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 16:43:24 +02:00
further unmangle branch split
This commit is contained in:
parent
c96f7562f2
commit
d833fb08d7
1 changed files with 53 additions and 42 deletions
|
@ -36,10 +36,12 @@ AvatarActionHold::~AvatarActionHold() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||||
|
bool gotLock = false;
|
||||||
glm::quat rotation;
|
glm::quat rotation;
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
glm::vec3 offset;
|
glm::vec3 offset;
|
||||||
bool gotLock = withTryReadLock([&]{
|
|
||||||
|
gotLock = withTryReadLock([&]{
|
||||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||||
glm::vec3 palmPosition;
|
glm::vec3 palmPosition;
|
||||||
glm::quat palmRotation;
|
glm::quat palmRotation;
|
||||||
|
@ -58,17 +60,10 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||||
|
|
||||||
if (gotLock) {
|
if (gotLock) {
|
||||||
gotLock = withTryWriteLock([&]{
|
gotLock = withTryWriteLock([&]{
|
||||||
if (_positionalTarget != position || _rotationalTarget != rotation) {
|
|
||||||
auto ownerEntity = _ownerEntity.lock();
|
|
||||||
if (ownerEntity) {
|
|
||||||
ownerEntity->setActionDataDirty(true);
|
|
||||||
}
|
|
||||||
_positionalTarget = position;
|
_positionalTarget = position;
|
||||||
_rotationalTarget = rotation;
|
_rotationalTarget = rotation;
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gotLock) {
|
if (gotLock) {
|
||||||
ObjectActionSpring::updateActionWorker(deltaTimeStep);
|
ObjectActionSpring::updateActionWorker(deltaTimeStep);
|
||||||
}
|
}
|
||||||
|
@ -76,57 +71,73 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||||
|
|
||||||
|
|
||||||
bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
||||||
if (!ObjectAction::updateArguments(arguments)) {
|
glm::vec3 relativePosition;
|
||||||
return false;
|
glm::quat relativeRotation;
|
||||||
}
|
float timeScale;
|
||||||
bool ok = true;
|
QString hand;
|
||||||
glm::vec3 relativePosition =
|
QUuid holderID;
|
||||||
EntityActionInterface::extractVec3Argument("hold", arguments, "relativePosition", ok, false);
|
bool needUpdate = false;
|
||||||
if (!ok) {
|
|
||||||
relativePosition = _relativePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok = true;
|
bool somethingChanged = ObjectAction::updateArguments(arguments);
|
||||||
glm::quat relativeRotation =
|
withReadLock([&]{
|
||||||
EntityActionInterface::extractQuatArgument("hold", arguments, "relativeRotation", ok, false);
|
bool ok = true;
|
||||||
if (!ok) {
|
relativePosition = EntityActionInterface::extractVec3Argument("hold", arguments, "relativePosition", ok, false);
|
||||||
relativeRotation = _relativeRotation;
|
if (!ok) {
|
||||||
}
|
relativePosition = _relativePosition;
|
||||||
|
}
|
||||||
ok = true;
|
|
||||||
float timeScale =
|
|
||||||
EntityActionInterface::extractFloatArgument("hold", arguments, "timeScale", ok, false);
|
|
||||||
if (!ok) {
|
|
||||||
timeScale = _linearTimeScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok = true;
|
ok = true;
|
||||||
QString hand =
|
relativeRotation = EntityActionInterface::extractQuatArgument("hold", arguments, "relativeRotation", ok, false);
|
||||||
EntityActionInterface::extractStringArgument("hold", arguments, "hand", ok, false);
|
if (!ok) {
|
||||||
if (!ok || !(hand == "left" || hand == "right")) {
|
relativeRotation = _relativeRotation;
|
||||||
hand = _hand;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (relativePosition != _relativePosition
|
ok = true;
|
||||||
|
timeScale = EntityActionInterface::extractFloatArgument("hold", arguments, "timeScale", ok, false);
|
||||||
|
if (!ok) {
|
||||||
|
timeScale = _linearTimeScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok = true;
|
||||||
|
hand = EntityActionInterface::extractStringArgument("hold", arguments, "hand", ok, false);
|
||||||
|
if (!ok || !(hand == "left" || hand == "right")) {
|
||||||
|
hand = _hand;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok = true;
|
||||||
|
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||||
|
holderID = myAvatar->getSessionUUID();
|
||||||
|
|
||||||
|
if (somethingChanged ||
|
||||||
|
relativePosition != _relativePosition
|
||||||
|| relativeRotation != _relativeRotation
|
|| relativeRotation != _relativeRotation
|
||||||
|| timeScale != _linearTimeScale
|
|| timeScale != _linearTimeScale
|
||||||
|| hand != _hand) {
|
|| hand != _hand) {
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (needUpdate) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_relativePosition = relativePosition;
|
_relativePosition = relativePosition;
|
||||||
_relativeRotation = relativeRotation;
|
_relativeRotation = relativeRotation;
|
||||||
const float MIN_TIMESCALE = 0.1f;
|
const float MIN_TIMESCALE = 0.1f;
|
||||||
_linearTimeScale = glm::min(MIN_TIMESCALE, timeScale);
|
_linearTimeScale = glm::max(MIN_TIMESCALE, timeScale);
|
||||||
_angularTimeScale = _linearTimeScale;
|
_angularTimeScale = _linearTimeScale;
|
||||||
_hand = hand;
|
_hand = hand;
|
||||||
|
|
||||||
_active = true;
|
_active = true;
|
||||||
activateBody();
|
|
||||||
|
auto ownerEntity = _ownerEntity.lock();
|
||||||
|
if (ownerEntity) {
|
||||||
|
ownerEntity->setActionDataDirty(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
activateBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantMap AvatarActionHold::getArguments() {
|
QVariantMap AvatarActionHold::getArguments() {
|
||||||
QVariantMap arguments = ObjectAction::getArguments();
|
QVariantMap arguments = ObjectAction::getArguments();
|
||||||
withReadLock([&]{
|
withReadLock([&]{
|
||||||
|
|
Loading…
Reference in a new issue