mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:58:03 +02:00
send faux joints to the avatar-mixer
This commit is contained in:
parent
948b4b7a15
commit
7c5b8cb75d
6 changed files with 40 additions and 17 deletions
|
@ -415,8 +415,6 @@ private:
|
||||||
|
|
||||||
// working copies -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
|
// working copies -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
|
||||||
glm::mat4 _sensorToWorldMatrix { glm::mat4() };
|
glm::mat4 _sensorToWorldMatrix { glm::mat4() };
|
||||||
glm::mat4 _controllerRightHandMatrix { glm::mat4() };
|
|
||||||
glm::mat4 _controllerLeftHandMatrix { glm::mat4() };
|
|
||||||
|
|
||||||
// cache of the current HMD sensor position and orientation
|
// cache of the current HMD sensor position and orientation
|
||||||
// in sensor space.
|
// in sensor space.
|
||||||
|
|
|
@ -374,6 +374,16 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// faux joints
|
||||||
|
Transform controllerLeftHandTransform = Transform(getControllerLeftHandMatrix());
|
||||||
|
destinationBuffer += packOrientationQuatToSixBytes(destinationBuffer, controllerLeftHandTransform.getRotation());
|
||||||
|
destinationBuffer += packFloatVec3ToSignedTwoByteFixed(destinationBuffer, controllerLeftHandTransform.getTranslation(),
|
||||||
|
TRANSLATION_COMPRESSION_RADIX);
|
||||||
|
Transform controllerRightHandTransform = Transform(getControllerRightHandMatrix());
|
||||||
|
destinationBuffer += packOrientationQuatToSixBytes(destinationBuffer, controllerRightHandTransform.getRotation());
|
||||||
|
destinationBuffer += packFloatVec3ToSignedTwoByteFixed(destinationBuffer, controllerRightHandTransform.getTranslation(),
|
||||||
|
TRANSLATION_COMPRESSION_RADIX);
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
if (sendAll) {
|
if (sendAll) {
|
||||||
qDebug() << "AvatarData::toByteArray" << cullSmallChanges << sendAll
|
qDebug() << "AvatarData::toByteArray" << cullSmallChanges << sendAll
|
||||||
|
@ -429,6 +439,20 @@ bool AvatarData::shouldLogError(const quint64& now) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const unsigned char* unpackFauxJoint(const unsigned char* sourceBuffer, ThreadSafeValueCache<glm::mat4>& matrixCache) {
|
||||||
|
glm::quat orientation;
|
||||||
|
glm::vec3 position;
|
||||||
|
Transform transform;
|
||||||
|
sourceBuffer += unpackOrientationQuatFromSixBytes(sourceBuffer, orientation);
|
||||||
|
sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, position, TRANSLATION_COMPRESSION_RADIX);
|
||||||
|
transform.setTranslation(position);
|
||||||
|
transform.setRotation(orientation);
|
||||||
|
matrixCache.set(transform.getMatrix());
|
||||||
|
return sourceBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define PACKET_READ_CHECK(ITEM_NAME, SIZE_TO_READ) \
|
#define PACKET_READ_CHECK(ITEM_NAME, SIZE_TO_READ) \
|
||||||
if ((endPosition - sourceBuffer) < (int)SIZE_TO_READ) { \
|
if ((endPosition - sourceBuffer) < (int)SIZE_TO_READ) { \
|
||||||
if (shouldLogError(now)) { \
|
if (shouldLogError(now)) { \
|
||||||
|
@ -655,6 +679,10 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// faux joints
|
||||||
|
sourceBuffer = unpackFauxJoint(sourceBuffer, _controllerLeftHandMatrixCache);
|
||||||
|
sourceBuffer = unpackFauxJoint(sourceBuffer, _controllerRightHandMatrixCache);
|
||||||
|
|
||||||
int numBytesRead = sourceBuffer - startPosition;
|
int numBytesRead = sourceBuffer - startPosition;
|
||||||
_averageBytesReceived.updateAverage(numBytesRead);
|
_averageBytesReceived.updateAverage(numBytesRead);
|
||||||
return numBytesRead;
|
return numBytesRead;
|
||||||
|
@ -916,13 +944,13 @@ void AvatarData::clearJointsData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int AvatarData::getFauxJointIndex(const QString& name) const {
|
int AvatarData::getFauxJointIndex(const QString& name) const {
|
||||||
if (name == "sensorToWorld") {
|
if (name == "_SENSOR_TO_WORLD_MATRIX") {
|
||||||
return SENSOR_TO_WORLD_MATRIX_INDEX;
|
return SENSOR_TO_WORLD_MATRIX_INDEX;
|
||||||
}
|
}
|
||||||
if (name == "Controller.Standard.LeftHand") {
|
if (name == "_CONTROLLER_LEFTHAND") {
|
||||||
return CONTROLLER_LEFTHAND_INDEX;
|
return CONTROLLER_LEFTHAND_INDEX;
|
||||||
}
|
}
|
||||||
if (name == "Controller.Standard.RightHand") {
|
if (name == "_CONTROLLER_RIGHTHAND") {
|
||||||
return CONTROLLER_RIGHTHAND_INDEX;
|
return CONTROLLER_RIGHTHAND_INDEX;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -335,13 +335,7 @@ QVector<QString> UserInputMapper::getActionNames() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Pose UserInputMapper::getPoseState(Action action) const {
|
Pose UserInputMapper::getPoseState(Action action) const {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) { abort(); } // XXX
|
||||||
Pose result;
|
|
||||||
QMetaObject::invokeMethod(const_cast<UserInputMapper*>(this), "getPoseState", Qt::BlockingQueuedConnection,
|
|
||||||
Q_RETURN_ARG(Pose, result), Q_ARG(Action, action));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _poseStates[toInt(action)];
|
return _poseStates[toInt(action)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::AvatarData:
|
case PacketType::AvatarData:
|
||||||
case PacketType::BulkAvatarData:
|
case PacketType::BulkAvatarData:
|
||||||
case PacketType::KillAvatar:
|
case PacketType::KillAvatar:
|
||||||
return static_cast<PacketVersion>(AvatarMixerPacketVersion::SensorToWorldMat);
|
return static_cast<PacketVersion>(AvatarMixerPacketVersion::HandControllerJoints);
|
||||||
case PacketType::ICEServerHeartbeat:
|
case PacketType::ICEServerHeartbeat:
|
||||||
return 18; // ICE Server Heartbeat signing
|
return 18; // ICE Server Heartbeat signing
|
||||||
case PacketType::AssetGetInfo:
|
case PacketType::AssetGetInfo:
|
||||||
|
|
|
@ -193,7 +193,8 @@ enum class AvatarMixerPacketVersion : PacketVersion {
|
||||||
SoftAttachmentSupport,
|
SoftAttachmentSupport,
|
||||||
AvatarEntities,
|
AvatarEntities,
|
||||||
AbsoluteSixByteRotations,
|
AbsoluteSixByteRotations,
|
||||||
SensorToWorldMat
|
SensorToWorldMat,
|
||||||
|
HandControllerJoints
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DomainConnectRequestVersion : PacketVersion {
|
enum class DomainConnectRequestVersion : PacketVersion {
|
||||||
|
|
|
@ -117,7 +117,7 @@ var NEAR_GRABBING_KINEMATIC = true; // force objects to be kinematic when near-g
|
||||||
var CHECK_TOO_FAR_UNEQUIP_TIME = 0.3; // seconds, duration between checks
|
var CHECK_TOO_FAR_UNEQUIP_TIME = 0.3; // seconds, duration between checks
|
||||||
|
|
||||||
|
|
||||||
var GRAB_POINT_SPHERE_OFFSET = {x: 0, y: 0.2, z:0};
|
var GRAB_POINT_SPHERE_OFFSET = { x: 0.0, y: 0.2, z: 0.0 };
|
||||||
var GRAB_POINT_SPHERE_RADIUS = NEAR_GRAB_RADIUS;
|
var GRAB_POINT_SPHERE_RADIUS = NEAR_GRAB_RADIUS;
|
||||||
var GRAB_POINT_SPHERE_COLOR = { red: 20, green: 90, blue: 238 };
|
var GRAB_POINT_SPHERE_COLOR = { red: 20, green: 90, blue: 238 };
|
||||||
var GRAB_POINT_SPHERE_ALPHA = 0.85;
|
var GRAB_POINT_SPHERE_ALPHA = 0.85;
|
||||||
|
@ -719,6 +719,7 @@ function MyController(hand) {
|
||||||
|
|
||||||
var orientation = Quat.multiply(MyAvatar.orientation, pose.rotation)
|
var orientation = Quat.multiply(MyAvatar.orientation, pose.rotation)
|
||||||
var position = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, pose.translation), MyAvatar.position);
|
var position = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, pose.translation), MyAvatar.position);
|
||||||
|
// add to the real position so the grab-point is out in front of the hand, a bit
|
||||||
position = Vec3.sum(position, Vec3.multiplyQbyV(orientation, GRAB_POINT_SPHERE_OFFSET));
|
position = Vec3.sum(position, Vec3.multiplyQbyV(orientation, GRAB_POINT_SPHERE_OFFSET));
|
||||||
|
|
||||||
return {position: position, orientation: orientation};
|
return {position: position, orientation: orientation};
|
||||||
|
@ -847,8 +848,8 @@ function MyController(hand) {
|
||||||
drawInFront: false,
|
drawInFront: false,
|
||||||
parentID: MyAvatar.sessionUUID,
|
parentID: MyAvatar.sessionUUID,
|
||||||
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
|
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
|
||||||
"Controller.Standard.RightHand" :
|
"_CONTROLLER_RIGHTHAND" :
|
||||||
"Controller.Standard.LeftHand")
|
"_CONTROLLER_LEFTHAND")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1866,6 +1867,7 @@ function MyController(hand) {
|
||||||
if (this.ignoreIK) {
|
if (this.ignoreIK) {
|
||||||
var controllerLocation = this.getControllerLocation();
|
var controllerLocation = this.getControllerLocation();
|
||||||
handRotation = controllerLocation.orientation;
|
handRotation = controllerLocation.orientation;
|
||||||
|
// subtract off the GRAB_POINT_SPHERE_OFFSET that was added in getControllerLocation
|
||||||
handPosition = Vec3.subtract(controllerLocation.position,
|
handPosition = Vec3.subtract(controllerLocation.position,
|
||||||
Vec3.multiplyQbyV(handRotation, GRAB_POINT_SPHERE_OFFSET));
|
Vec3.multiplyQbyV(handRotation, GRAB_POINT_SPHERE_OFFSET));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue