mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
reinstate old HandData parsing
This commit is contained in:
parent
4ed748752f
commit
4bf8f3a465
1 changed files with 12 additions and 31 deletions
|
@ -162,29 +162,21 @@ int HandData::encodeRemoteData(unsigned char* destinationBuffer) {
|
||||||
int HandData::decodeRemoteData(const QByteArray& dataByteArray) {
|
int HandData::decodeRemoteData(const QByteArray& dataByteArray) {
|
||||||
QDataStream packetStream(dataByteArray);
|
QDataStream packetStream(dataByteArray);
|
||||||
|
|
||||||
quint8 numHands;
|
const unsigned char* startPosition;
|
||||||
packetStream >> numHands;
|
const unsigned char* sourceBuffer = startPosition = reinterpret_cast<const unsigned char*>(dataByteArray.data());
|
||||||
|
unsigned int numHands = *sourceBuffer++;
|
||||||
|
|
||||||
for (unsigned int handIndex = 0; handIndex < numHands; ++handIndex) {
|
for (unsigned int handIndex = 0; handIndex < numHands; ++handIndex) {
|
||||||
if (handIndex >= getNumPalms())
|
if (handIndex >= getNumPalms())
|
||||||
addNewPalm();
|
addNewPalm();
|
||||||
PalmData& palm = getPalms()[handIndex];
|
PalmData& palm = getPalms()[handIndex];
|
||||||
|
|
||||||
glm::vec3 handPosition;
|
glm::vec3 handPosition;
|
||||||
glm::vec3 handNormal;
|
glm::vec3 handNormal;
|
||||||
qint16 twoByteHolder;
|
sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, handPosition, fingerVectorRadix);
|
||||||
|
sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, handNormal, fingerVectorRadix);
|
||||||
|
unsigned int numFingers = *sourceBuffer++;
|
||||||
|
|
||||||
packetStream >> twoByteHolder;
|
|
||||||
unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast<const unsigned char*>(&twoByteHolder),
|
|
||||||
handPosition, fingerVectorRadix);
|
|
||||||
|
|
||||||
packetStream >> twoByteHolder;
|
|
||||||
unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast<const unsigned char*>(&twoByteHolder),
|
|
||||||
handNormal, fingerVectorRadix);
|
|
||||||
|
|
||||||
quint8 numFingers;
|
|
||||||
packetStream >> numFingers;
|
|
||||||
|
|
||||||
palm.setRawPosition(handPosition);
|
palm.setRawPosition(handPosition);
|
||||||
palm.setRawNormal(handNormal);
|
palm.setRawNormal(handNormal);
|
||||||
palm.setActive(true);
|
palm.setActive(true);
|
||||||
|
@ -195,18 +187,12 @@ int HandData::decodeRemoteData(const QByteArray& dataByteArray) {
|
||||||
for (unsigned int fingerIndex = 0; fingerIndex < numFingers; ++fingerIndex) {
|
for (unsigned int fingerIndex = 0; fingerIndex < numFingers; ++fingerIndex) {
|
||||||
if (fingerIndex < palm.getNumFingers()) {
|
if (fingerIndex < palm.getNumFingers()) {
|
||||||
FingerData& finger = palm.getFingers()[fingerIndex];
|
FingerData& finger = palm.getFingers()[fingerIndex];
|
||||||
|
|
||||||
glm::vec3 tipPosition;
|
glm::vec3 tipPosition;
|
||||||
glm::vec3 rootPosition;
|
glm::vec3 rootPosition;
|
||||||
|
sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, tipPosition, fingerVectorRadix);
|
||||||
|
sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, rootPosition, fingerVectorRadix);
|
||||||
|
|
||||||
packetStream >> twoByteHolder;
|
|
||||||
unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast<const unsigned char*>(&twoByteHolder), tipPosition,
|
|
||||||
fingerVectorRadix);
|
|
||||||
|
|
||||||
packetStream >> twoByteHolder;
|
|
||||||
unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast<const unsigned char*>(&twoByteHolder), rootPosition,
|
|
||||||
fingerVectorRadix);
|
|
||||||
|
|
||||||
finger.setRawTipPosition(tipPosition);
|
finger.setRawTipPosition(tipPosition);
|
||||||
finger.setRawRootPosition(rootPosition);
|
finger.setRawRootPosition(rootPosition);
|
||||||
finger.setActive(true);
|
finger.setActive(true);
|
||||||
|
@ -225,14 +211,9 @@ int HandData::decodeRemoteData(const QByteArray& dataByteArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// One byte for error checking safety.
|
// One byte for error checking safety.
|
||||||
unsigned char requiredLength = packetStream.device()->pos();
|
unsigned char requiredLength = (unsigned char)(sourceBuffer - startPosition);
|
||||||
|
unsigned char checkLength = *sourceBuffer++;
|
||||||
unsigned char checkLength;
|
|
||||||
packetStream >> checkLength;
|
|
||||||
|
|
||||||
assert(checkLength == requiredLength);
|
assert(checkLength == requiredLength);
|
||||||
|
|
||||||
return packetStream.device()->pos();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandData::setFingerTrailLength(unsigned int length) {
|
void HandData::setFingerTrailLength(unsigned int length) {
|
||||||
|
|
Loading…
Reference in a new issue