maintain a pointer to owning avatar from HeadData

This commit is contained in:
Stephen Birarda 2013-05-24 11:29:49 -07:00
parent 36892da488
commit 49b483ef53
6 changed files with 15 additions and 8 deletions

View file

@ -71,6 +71,7 @@ float chatMessageHeight = 0.10;
Avatar::Avatar(Agent* owningAgent, bool isMine) :
AvatarData(owningAgent),
_head(this),
_isMine(isMine),
_TEST_bigSphereRadius(0.4f),
_TEST_bigSpherePosition(5.0f, _TEST_bigSphereRadius, 5.0f),

View file

@ -30,8 +30,8 @@ unsigned int IRIS_TEXTURE_WIDTH = 768;
unsigned int IRIS_TEXTURE_HEIGHT = 498;
vector<unsigned char> irisTexture;
Head::Head() :
Head::Head(Avatar* owningAvatar) :
HeadData((AvatarData*)owningAvatar),
yawRate(0.0f),
_returnHeadToCenter(false),
_audioLoudness(0.0f),

View file

@ -24,9 +24,11 @@ enum eyeContactTargets
MOUTH
};
class Avatar;
class Head : public HeadData {
public:
Head();
Head(Avatar* owningAvatar);
void reset();
void simulate(float deltaTime, bool isMine);

View file

@ -68,7 +68,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
// lazily allocate memory for HeadData in case we're not an Avatar instance
if (!_headData) {
_headData = new HeadData();
_headData = new HeadData(this);
}
// Body world position
@ -149,7 +149,7 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
// lazily allocate memory for HeadData in case we're not an Avatar instance
if (!_headData) {
_headData = new HeadData();
_headData = new HeadData(this);
}
// increment to push past the packet header

View file

@ -8,13 +8,14 @@
#include "HeadData.h"
HeadData::HeadData() :
HeadData::HeadData(AvatarData* owningAvatar) :
_yaw(0.0f),
_pitch(0.0f),
_roll(0.0f),
_lookAtPosition(0.0f, 0.0f, 0.0f),
_leanSideways(0.0f),
_leanForward(0.0f)
_leanForward(0.0f),
_owningAvatar(owningAvatar)
{
}

View file

@ -20,9 +20,11 @@ const float MAX_HEAD_PITCH = 60;
const float MIN_HEAD_ROLL = -50;
const float MAX_HEAD_ROLL = 50;
class AvatarData;
class HeadData {
public:
HeadData();
HeadData(AvatarData* owningAvatar);
float getLeanSideways() const { return _leanSideways; }
void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; }
@ -55,6 +57,7 @@ protected:
glm::vec3 _lookAtPosition;
float _leanSideways;
float _leanForward;
AvatarData* _owningAvatar;
private:
// privatize copy ctor and assignment operator so copies of this object cannot be made
HeadData(const HeadData&);