mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 11:26:27 +02:00
Remove left/right relative pos/rot from c++
This commit is contained in:
parent
b64dfc7e99
commit
70dd8ec19a
4 changed files with 26 additions and 62 deletions
|
@ -65,15 +65,13 @@ std::shared_ptr<Avatar> AvatarActionHold::getTarget(glm::quat& rotation, glm::ve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRightHand) {
|
if (!isRightHand) {
|
||||||
rotation = palmRotation * _rightRelativeRotation;
|
|
||||||
position = palmPosition + rotation * _rightRelativePosition;
|
|
||||||
} else {
|
|
||||||
static const glm::quat yFlip = glm::angleAxis(PI, Vectors::UNIT_Y);
|
static const glm::quat yFlip = glm::angleAxis(PI, Vectors::UNIT_Y);
|
||||||
palmRotation *= yFlip; // Match right hand frame of reference
|
palmRotation *= yFlip; // Match right hand frame of reference
|
||||||
rotation = palmRotation * _leftRelativeRotation;
|
|
||||||
position = palmPosition + rotation * _leftRelativePosition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rotation = palmRotation * _relativeRotation;
|
||||||
|
position = palmPosition + rotation * _relativePosition;
|
||||||
});
|
});
|
||||||
|
|
||||||
return holdingAvatar;
|
return holdingAvatar;
|
||||||
|
@ -175,10 +173,8 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
||||||
glm::vec3 leftRelativePosition;
|
glm::vec3 relativePosition;
|
||||||
glm::quat leftRelativeRotation;
|
glm::quat relativeRotation;
|
||||||
glm::vec3 rightRelativePosition;
|
|
||||||
glm::quat rightRelativeRotation;
|
|
||||||
float timeScale;
|
float timeScale;
|
||||||
QString hand;
|
QString hand;
|
||||||
QUuid holderID;
|
QUuid holderID;
|
||||||
|
@ -190,27 +186,15 @@ bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
||||||
bool somethingChanged = ObjectAction::updateArguments(arguments);
|
bool somethingChanged = ObjectAction::updateArguments(arguments);
|
||||||
withReadLock([&]{
|
withReadLock([&]{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
leftRelativePosition = EntityActionInterface::extractVec3Argument("hold", arguments, "leftRelativePosition", ok, false);
|
relativePosition = EntityActionInterface::extractVec3Argument("hold", arguments, "relativePosition", ok, false);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
leftRelativePosition = _leftRelativePosition;
|
relativePosition = _relativePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = true;
|
ok = true;
|
||||||
leftRelativeRotation = EntityActionInterface::extractQuatArgument("hold", arguments, "leftRelativeRotation", ok, false);
|
relativeRotation = EntityActionInterface::extractQuatArgument("hold", arguments, "relativeRotation", ok, false);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
leftRelativeRotation = _leftRelativeRotation;
|
relativeRotation = _relativeRotation;
|
||||||
}
|
|
||||||
|
|
||||||
ok = true;
|
|
||||||
rightRelativePosition = EntityActionInterface::extractVec3Argument("hold", arguments, "rightRelativePosition", ok, false);
|
|
||||||
if (!ok) {
|
|
||||||
rightRelativePosition = _rightRelativePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok = true;
|
|
||||||
rightRelativeRotation = EntityActionInterface::extractQuatArgument("hold", arguments, "rightRelativeRotation", ok, false);
|
|
||||||
if (!ok) {
|
|
||||||
rightRelativeRotation = _rightRelativeRotation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = true;
|
ok = true;
|
||||||
|
@ -234,25 +218,17 @@ bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
_kinematic = false;
|
_kinematic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = true;
|
ok = true;
|
||||||
kinematicSetVelocity = EntityActionInterface::extractBooleanArgument("hold", arguments,
|
kinematicSetVelocity = EntityActionInterface::extractBooleanArgument("hold", arguments,
|
||||||
"kinematicSetVelocity", ok, false);
|
"kinematicSetVelocity", ok, false);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
_kinematicSetVelocity = false;
|
_kinematicSetVelocity = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = true;
|
|
||||||
ignoreIK = EntityActionInterface::extractBooleanArgument("hold", arguments, "ignoreIK", ok, false);
|
|
||||||
if (!ok) {
|
|
||||||
_ignoreIK = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (somethingChanged ||
|
if (somethingChanged ||
|
||||||
leftRelativePosition != _leftRelativePosition ||
|
relativePosition != _relativePosition ||
|
||||||
leftRelativeRotation != _leftRelativeRotation ||
|
relativeRotation != _relativeRotation ||
|
||||||
rightRelativePosition != _rightRelativePosition ||
|
|
||||||
rightRelativeRotation != _rightRelativeRotation ||
|
|
||||||
timeScale != _linearTimeScale ||
|
timeScale != _linearTimeScale ||
|
||||||
hand != _hand ||
|
hand != _hand ||
|
||||||
holderID != _holderID ||
|
holderID != _holderID ||
|
||||||
|
@ -265,10 +241,8 @@ bool AvatarActionHold::updateArguments(QVariantMap arguments) {
|
||||||
|
|
||||||
if (needUpdate) {
|
if (needUpdate) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_leftRelativePosition = leftRelativePosition;
|
_relativePosition = relativePosition;
|
||||||
_leftRelativeRotation = leftRelativeRotation;
|
_relativeRotation = relativeRotation;
|
||||||
_rightRelativePosition = rightRelativePosition;
|
|
||||||
_rightRelativeRotation = rightRelativeRotation;
|
|
||||||
const float MIN_TIMESCALE = 0.1f;
|
const float MIN_TIMESCALE = 0.1f;
|
||||||
_linearTimeScale = glm::max(MIN_TIMESCALE, timeScale);
|
_linearTimeScale = glm::max(MIN_TIMESCALE, timeScale);
|
||||||
_angularTimeScale = _linearTimeScale;
|
_angularTimeScale = _linearTimeScale;
|
||||||
|
@ -295,10 +269,8 @@ QVariantMap AvatarActionHold::getArguments() {
|
||||||
QVariantMap arguments = ObjectAction::getArguments();
|
QVariantMap arguments = ObjectAction::getArguments();
|
||||||
withReadLock([&]{
|
withReadLock([&]{
|
||||||
arguments["holderID"] = _holderID;
|
arguments["holderID"] = _holderID;
|
||||||
arguments["leftRelativePosition"] = glmToQMap(_leftRelativePosition);
|
arguments["relativePosition"] = glmToQMap(_relativePosition);
|
||||||
arguments["leftRelativeRotation"] = glmToQMap(_leftRelativeRotation);
|
arguments["relativeRotation"] = glmToQMap(_relativeRotation);
|
||||||
arguments["rightRelativePosition"] = glmToQMap(_rightRelativePosition);
|
|
||||||
arguments["rightRelativeRotation"] = glmToQMap(_rightRelativeRotation);
|
|
||||||
arguments["timeScale"] = _linearTimeScale;
|
arguments["timeScale"] = _linearTimeScale;
|
||||||
arguments["hand"] = _hand;
|
arguments["hand"] = _hand;
|
||||||
arguments["kinematic"] = _kinematic;
|
arguments["kinematic"] = _kinematic;
|
||||||
|
@ -318,10 +290,8 @@ QByteArray AvatarActionHold::serialize() const {
|
||||||
dataStream << AvatarActionHold::holdVersion;
|
dataStream << AvatarActionHold::holdVersion;
|
||||||
|
|
||||||
dataStream << _holderID;
|
dataStream << _holderID;
|
||||||
dataStream << _leftRelativePosition;
|
dataStream << _relativePosition;
|
||||||
dataStream << _leftRelativeRotation;
|
dataStream << _relativeRotation;
|
||||||
dataStream << _rightRelativePosition;
|
|
||||||
dataStream << _rightRelativeRotation;
|
|
||||||
dataStream << _linearTimeScale;
|
dataStream << _linearTimeScale;
|
||||||
dataStream << _hand;
|
dataStream << _hand;
|
||||||
|
|
||||||
|
@ -353,10 +323,8 @@ void AvatarActionHold::deserialize(QByteArray serializedArguments) {
|
||||||
|
|
||||||
withWriteLock([&]{
|
withWriteLock([&]{
|
||||||
dataStream >> _holderID;
|
dataStream >> _holderID;
|
||||||
dataStream >> _leftRelativePosition;
|
dataStream >> _relativePosition;
|
||||||
dataStream >> _leftRelativeRotation;
|
dataStream >> _relativeRotation;
|
||||||
dataStream >> _rightRelativePosition;
|
|
||||||
dataStream >> _rightRelativeRotation;
|
|
||||||
dataStream >> _linearTimeScale;
|
dataStream >> _linearTimeScale;
|
||||||
_angularTimeScale = _linearTimeScale;
|
_angularTimeScale = _linearTimeScale;
|
||||||
dataStream >> _hand;
|
dataStream >> _hand;
|
||||||
|
|
|
@ -38,15 +38,12 @@ public:
|
||||||
std::shared_ptr<Avatar> getTarget(glm::quat& rotation, glm::vec3& position);
|
std::shared_ptr<Avatar> getTarget(glm::quat& rotation, glm::vec3& position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint16_t holdVersion;
|
|
||||||
|
|
||||||
void doKinematicUpdate(float deltaTimeStep);
|
void doKinematicUpdate(float deltaTimeStep);
|
||||||
|
|
||||||
glm::vec3 _leftRelativePosition{ Vectors::ZERO };
|
static const uint16_t holdVersion;
|
||||||
glm::quat _leftRelativeRotation{ Quaternions::IDENTITY };
|
|
||||||
glm::vec3 _rightRelativePosition{ Vectors::ZERO };
|
|
||||||
glm::quat _rightRelativeRotation{ Quaternions::IDENTITY };
|
|
||||||
|
|
||||||
|
glm::vec3 _relativePosition { Vectors::ZERO };
|
||||||
|
glm::quat _relativeRotation { Quaternions::IDENTITY };
|
||||||
QString _hand { "right" };
|
QString _hand { "right" };
|
||||||
QUuid _holderID;
|
QUuid _holderID;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::EntityAdd:
|
case PacketType::EntityAdd:
|
||||||
case PacketType::EntityEdit:
|
case PacketType::EntityEdit:
|
||||||
case PacketType::EntityData:
|
case PacketType::EntityData:
|
||||||
return VERSION_ENTITIES_ACTIONS_PER_HAND_OFFSET;
|
return VERSION_ENTITIES_POLYLINE_TEXTURE;
|
||||||
case PacketType::AvatarData:
|
case PacketType::AvatarData:
|
||||||
case PacketType::BulkAvatarData:
|
case PacketType::BulkAvatarData:
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -160,6 +160,5 @@ const PacketVersion VERSION_ENTITIES_KEYLIGHT_PROPERTIES_GROUP = 47;
|
||||||
const PacketVersion VERSION_ENTITIES_KEYLIGHT_PROPERTIES_GROUP_BIS = 48;
|
const PacketVersion VERSION_ENTITIES_KEYLIGHT_PROPERTIES_GROUP_BIS = 48;
|
||||||
const PacketVersion VERSION_ENTITIES_PARTICLES_ADDITIVE_BLENDING = 49;
|
const PacketVersion VERSION_ENTITIES_PARTICLES_ADDITIVE_BLENDING = 49;
|
||||||
const PacketVersion VERSION_ENTITIES_POLYLINE_TEXTURE = 50;
|
const PacketVersion VERSION_ENTITIES_POLYLINE_TEXTURE = 50;
|
||||||
const PacketVersion VERSION_ENTITIES_ACTIONS_PER_HAND_OFFSET = 51;
|
|
||||||
|
|
||||||
#endif // hifi_PacketHeaders_h
|
#endif // hifi_PacketHeaders_h
|
||||||
|
|
Loading…
Reference in a new issue