added wantDelta, made want bools a bit mask

This commit is contained in:
ZappoMan 2013-05-14 11:08:59 -07:00
parent a95549da2e
commit d59a8143d7
2 changed files with 20 additions and 4 deletions

View file

@ -108,8 +108,12 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
destinationBuffer += _chatMessage.size() * sizeof(char);
// voxel sending features...
*destinationBuffer++ = _wantResIn;
*destinationBuffer++ = _wantColor;
// voxel sending features...
unsigned char wantItems = 0;
if (_wantResIn) { setAtBit(wantItems,WANT_RESIN_AT_BIT); }
if (_wantColor) { setAtBit(wantItems,WANT_COLOR_AT_BIT); }
if (_wantDelta) { setAtBit(wantItems,WANT_DELTA_AT_BIT); }
*destinationBuffer++ = wantItems;
return destinationBuffer - bufferStart;
}
@ -184,8 +188,12 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
sourceBuffer += chatMessageSize * sizeof(char);
// voxel sending features...
_wantResIn = (bool)*sourceBuffer++;
_wantColor = (bool)*sourceBuffer++;
unsigned char wantItems = 0;
wantItems = (unsigned char)*sourceBuffer++;
_wantResIn = oneAtBit(wantItems,WANT_RESIN_AT_BIT);
_wantColor = oneAtBit(wantItems,WANT_COLOR_AT_BIT);
_wantDelta = oneAtBit(wantItems,WANT_DELTA_AT_BIT);
return sourceBuffer - startPosition;
}

View file

@ -15,6 +15,10 @@
#include <AgentData.h>
const int WANT_RESIN_AT_BIT = 0;
const int WANT_COLOR_AT_BIT = 1;
const int WANT_DELTA_AT_BIT = 2;
enum KeyState
{
NO_KEY_DOWN,
@ -123,8 +127,10 @@ public:
// related to Voxel Sending strategies
bool getWantResIn() const { return _wantResIn; }
bool getWantColor() const { return _wantColor; }
bool getWantDelta() const { return _wantDelta; }
void setWantResIn(bool wantResIn) { _wantResIn = wantResIn; }
void setWantColor(bool wantColor) { _wantColor = wantColor; }
void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; }
protected:
glm::vec3 _position;
@ -167,8 +173,10 @@ protected:
// chat message
std::string _chatMessage;
// voxel server sending items
bool _wantResIn;
bool _wantColor;
bool _wantDelta;
};
#endif /* defined(__hifi__AvatarData__) */