Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jeffrey Ventrella 2013-05-22 17:25:06 -07:00
commit 549d3a3671
8 changed files with 52 additions and 49 deletions

View file

@ -290,42 +290,40 @@ void Application::paintGL() {
glPushMatrix(); {
glLoadIdentity();
// camera settings
if (OculusManager::isConnected()) {
_myAvatar.setDisplayingHead(false);
_myCamera.setUpShift (0.0f);
_myCamera.setDistance (0.0f);
_myCamera.setTightness (100.0f);
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
_myCamera.setTargetRotation(_myAvatar.getBodyYaw() + _myAvatar.getHead().getYaw(),
-_myAvatar.getHead().getPitch(),
_myAvatar.getHead().getRoll());
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
_myCamera.setTightness (100.0f);
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
_myCamera.setTargetRotation(_myAvatar.getBodyYaw() - 180.0f,
0.0f,
0.0f);
} else {
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
0.0f,
//-_myAvatar.getAbsoluteHeadPitch(),
0.0f);
// Take a look at whether we are inside head, don't render it if so.
const float HEAD_RENDER_DISTANCE = 0.5;
glm::vec3 distanceToHead(_myCamera.getPosition() - _myAvatar.getSpringyHeadPosition());
if (glm::length(distanceToHead) < HEAD_RENDER_DISTANCE) { _myAvatar.setDisplayingHead(false); }
} else if (OculusManager::isConnected()) {
_myAvatar.setDisplayingHead(false);
_myCamera.setUpShift (0.0f);
_myCamera.setDistance (0.0f);
_myCamera.setTightness (100.0f);
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
-_myAvatar.getHead().getPitch(),
_myAvatar.getHead().getRoll());
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
0.0f,
//-_myAvatar.getAbsoluteHeadPitch(),
0.0f);
// Take a look at whether we are inside head, don't render it if so.
const float HEAD_RENDER_DISTANCE = 0.5;
glm::vec3 distanceToHead(_myCamera.getPosition() - _myAvatar.getSpringyHeadPosition());
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
_myCamera.setTargetRotation(_myAvatar.getBodyYaw(),
0.0f,
//-_myAvatar.getAbsoluteHeadPitch(),
0.0f);
if (glm::length(distanceToHead) < HEAD_RENDER_DISTANCE) {
_myAvatar.setDisplayingHead(false);
}
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
_myCamera.setTargetRotation(_myAvatar.getBodyYaw(),
0.0f,
//-_myAvatar.getAbsoluteHeadPitch(),
0.0f);
}
// important...
@ -1387,8 +1385,7 @@ void Application::updateAvatar(float deltaTime) {
const float HORIZONTAL_PIXELS_PER_DEGREE = 2880.f / 45.f;
const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f;
if (powf(measuredYawRate * measuredYawRate +
measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE)
{
measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE) {
_headMouseX += measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime;
_headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime;
}
@ -1400,7 +1397,7 @@ void Application::updateAvatar(float deltaTime) {
if (OculusManager::isConnected()) {
float yaw, pitch, roll;
OculusManager::getEulerAngles(yaw, pitch, roll);
_myAvatar.getHead().setYaw(-yaw);
_myAvatar.getHead().setPitch(pitch);
_myAvatar.getHead().setRoll(roll);

View file

@ -100,7 +100,6 @@ Avatar::Avatar(bool isMine) :
// give the pointer to our head to inherited _headData variable from AvatarData
_headData = &_head;
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
_driveKeys[i] = false;
}
@ -351,7 +350,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
} else {
axis = glm::normalize(glm::cross(currentUp, targetUp));
}
_righting = glm::angleAxis(min(deltaTime * ANGULAR_RIGHTING_SPEED, angle), axis) * _righting;
//_righting = glm::angleAxis(min(deltaTime * ANGULAR_RIGHTING_SPEED, angle), axis) * _righting;
}
}
@ -602,10 +601,6 @@ void Avatar::updateCollisionWithSphere(glm::vec3 position, float radius, float d
}
void Avatar::updateCollisionWithEnvironment() {
if (_position.y < _pelvisStandingHeight) {
applyCollisionWithScene(glm::vec3(0.0f, _pelvisStandingHeight - _position.y, 0.0f));
}
float radius = _height * 0.125f;
glm::vec3 penetration;
if (Application::getInstance()->getEnvironment()->findCapsulePenetration(

View file

@ -105,7 +105,7 @@ public:
float getHeight() const { return _height; }
AvatarMode getMode() const { return _mode; }
Head getHead() const { return _head; }
Head& getHead() { return _head; }
void setMousePressed(bool pressed);
void render(bool lookingInMirror, glm::vec3 cameraPosition);

View file

@ -30,14 +30,20 @@ bool operator== (const sockaddr& addr1, const sockaddr& addr2) {
return socketMatch(&addr1, &addr2);
}
static sockaddr getZeroAddress() {
sockaddr addr;
memset(&addr, 0, sizeof(sockaddr));
addr.sa_family = AF_INET;
return addr;
}
void Environment::init() {
switchToResourcesParentIfRequired();
_skyFromAtmosphereProgram = createSkyProgram("Atmosphere", _skyFromAtmosphereUniformLocations);
_skyFromSpaceProgram = createSkyProgram("Space", _skyFromSpaceUniformLocations);
// start off with a default-constructed environment data
sockaddr addr = { AF_INET };
_data[addr][0];
_data[getZeroAddress()][0];
}
void Environment::renderAtmospheres(Camera& camera) {
@ -118,8 +124,7 @@ int Environment::parseData(sockaddr *senderAddress, unsigned char* sourceBuffer,
_data[*senderAddress][newData.getID()] = newData;
// remove the default mapping, if any
sockaddr addr = { AF_INET };
_data.remove(addr);
_data.remove(getZeroAddress());
return bytesRead;
}

View file

@ -51,7 +51,10 @@ public:
float yawRate;
float noise;
private:
private:
// disallow copies of the Head, copy of owning Avatar is disallowed too
Head(const Head&);
Head& operator= (const Head&);
bool _returnHeadToCenter;
float _audioLoudness;

View file

@ -29,7 +29,6 @@ public:
void injectAudio(UDPSocket* injectorSocket, sockaddr* destinationSocket);
bool isInjectingAudio() const { return _isInjectingAudio; }
void setIsInjectingAudio(bool isInjectingAudio) { _isInjectingAudio = isInjectingAudio; }
unsigned char getVolume() const { return _volume; }
void setVolume(unsigned char volume) { _volume = volume; }

View file

@ -95,10 +95,6 @@ public:
void setHeadData(HeadData* headData) { _headData = headData; }
protected:
// privatize the copy constructor and assignment operator so they cannot be called
AvatarData(const AvatarData&);
AvatarData& operator= (const AvatarData&);
glm::vec3 _position;
glm::vec3 _handPosition;
@ -137,6 +133,10 @@ protected:
bool _wantDelta;
HeadData* _headData;
private:
// privatize the copy constructor and assignment operator so they cannot be called
AvatarData(const AvatarData&);
AvatarData& operator= (const AvatarData&);
};
#endif /* defined(__hifi__AvatarData__) */

View file

@ -55,6 +55,10 @@ protected:
glm::vec3 _lookAtPosition;
float _leanSideways;
float _leanForward;
private:
// privatize copy ctor and assignment operator so copies of this object cannot be made
HeadData(const HeadData&);
HeadData& operator= (const HeadData&);
};
#endif /* defined(__hifi__HeadData__) */