mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Put _isFaceshiftConnected in a bit set
This commit is contained in:
parent
c2502d03db
commit
8f27d22f7b
2 changed files with 43 additions and 37 deletions
|
@ -155,25 +155,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// Instantaneous audio loudness (used to drive facial animation)
|
||||
//destinationBuffer += packFloatToByte(destinationBuffer, std::min(MAX_AUDIO_LOUDNESS, _audioLoudness), MAX_AUDIO_LOUDNESS);
|
||||
memcpy(destinationBuffer, &_headData->_audioLoudness, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
memcpy(destinationBuffer, &_headData->_isFaceshiftConnected, sizeof(_headData->_isFaceshiftConnected));
|
||||
destinationBuffer += sizeof(_headData->_isFaceshiftConnected);
|
||||
|
||||
// If it is connected, pack up the data
|
||||
if (_headData->_isFaceshiftConnected) {
|
||||
memcpy(destinationBuffer, &_headData->_leftEyeBlink, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
memcpy(destinationBuffer, &_headData->_rightEyeBlink, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
memcpy(destinationBuffer, &_headData->_averageLoudness, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
memcpy(destinationBuffer, &_headData->_browAudioLift, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
}
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
// camera details
|
||||
memcpy(destinationBuffer, &_cameraPosition, sizeof(_cameraPosition));
|
||||
|
@ -203,6 +185,26 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// hand state
|
||||
setSemiNibbleAt(bitItems,HAND_STATE_START_BIT,_handState);
|
||||
*destinationBuffer++ = bitItems;
|
||||
|
||||
unsigned char bitItems = 0;
|
||||
if (_headData->_isFaceshiftConnected) { setAtBit(bitItems, IS_FACESHIFT_CONNECTED); }
|
||||
|
||||
*destinationBuffer++ = bitItems;
|
||||
|
||||
// If it is connected, pack up the data
|
||||
if (_headData->_isFaceshiftConnected) {
|
||||
memcpy(destinationBuffer, &_headData->_leftEyeBlink, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
memcpy(destinationBuffer, &_headData->_rightEyeBlink, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
memcpy(destinationBuffer, &_headData->_averageLoudness, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
|
||||
memcpy(destinationBuffer, &_headData->_browAudioLift, sizeof(float));
|
||||
destinationBuffer += sizeof(float);
|
||||
}
|
||||
|
||||
// leap hand data
|
||||
destinationBuffer += _handData->encodeRemoteData(destinationBuffer);
|
||||
|
@ -285,24 +287,6 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
//sourceBuffer += unpackFloatFromByte(sourceBuffer, _audioLoudness, MAX_AUDIO_LOUDNESS);
|
||||
memcpy(&_headData->_audioLoudness, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
|
||||
memcpy(&_headData->_isFaceshiftConnected, sourceBuffer, sizeof(_headData->_isFaceshiftConnected));
|
||||
sourceBuffer += sizeof(_headData->_isFaceshiftConnected);
|
||||
|
||||
// If it is connected, pack up the data
|
||||
if (_headData->_isFaceshiftConnected) {
|
||||
memcpy(&_headData->_leftEyeBlink, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
|
||||
memcpy(&_headData->_rightEyeBlink, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
|
||||
memcpy(&_headData->_averageLoudness, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
|
||||
memcpy(&_headData->_browAudioLift, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
}
|
||||
|
||||
// camera details
|
||||
memcpy(&_cameraPosition, sourceBuffer, sizeof(_cameraPosition));
|
||||
|
@ -334,6 +318,24 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
// hand state, stored as a semi-nibble in the bitItems
|
||||
_handState = getSemiNibbleAt(bitItems,HAND_STATE_START_BIT);
|
||||
|
||||
bitItems = (unsigned char)*sourceBuffer++;
|
||||
_headData->_isFaceshiftConnected = oneAtBit(bitItems, IS_FACESHIFT_CONNECTED);
|
||||
|
||||
// If it is connected, pack up the data
|
||||
if (_headData->_isFaceshiftConnected) {
|
||||
memcpy(&_headData->_leftEyeBlink, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
|
||||
memcpy(&_headData->_rightEyeBlink, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
|
||||
memcpy(&_headData->_averageLoudness, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
|
||||
memcpy(&_headData->_browAudioLift, sourceBuffer, sizeof(float));
|
||||
sourceBuffer += sizeof(float);
|
||||
}
|
||||
|
||||
// leap hand data
|
||||
if (sourceBuffer - startPosition < numBytes) {
|
||||
// check passed, bytes match
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "HeadData.h"
|
||||
#include "HandData.h"
|
||||
|
||||
// First bitset
|
||||
const int WANT_LOW_RES_MOVING_BIT = 0;
|
||||
const int WANT_COLOR_AT_BIT = 1;
|
||||
const int WANT_DELTA_AT_BIT = 2;
|
||||
|
@ -30,6 +31,9 @@ const int KEY_STATE_START_BIT = 3; // 4th and 5th bits
|
|||
const int HAND_STATE_START_BIT = 5; // 6th and 7th bits
|
||||
const int WANT_OCCLUSION_CULLING_BIT = 7; // 8th bit
|
||||
|
||||
// Second bitset
|
||||
const int IS_FACESHIFT_CONNECTED = 0;
|
||||
|
||||
const float MAX_AUDIO_LOUDNESS = 1000.0; // close enough for mouth animation
|
||||
|
||||
enum KeyState
|
||||
|
|
Loading…
Reference in a new issue