mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
4940a6ae9a
6 changed files with 76 additions and 32 deletions
|
@ -48,14 +48,19 @@ if (APPLE)
|
|||
# set where in the bundle to put the resources file
|
||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/interface.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
|
||||
SET(INTERFACE_SRCS ${INTERFACE_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/interface.icns)
|
||||
|
||||
# grab the directories in resources and put them in the right spot in Resources
|
||||
FILE(GLOB INTERFACE_IMAGES resources/images/*)
|
||||
SET_SOURCE_FILES_PROPERTIES(${INTERFACE_IMAGES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/images)
|
||||
file(GLOB RESOURCE_SUBDIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/resources ${CMAKE_CURRENT_SOURCE_DIR}/resources/*)
|
||||
foreach(DIR ${RESOURCE_SUBDIRS})
|
||||
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources/${DIR})
|
||||
FILE(GLOB DIR_CONTENTS resources/${DIR}/*)
|
||||
SET_SOURCE_FILES_PROPERTIES(${DIR_CONTENTS} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${DIR})
|
||||
|
||||
SET(INTERFACE_SRCS ${INTERFACE_SRCS} ${DIR_CONTENTS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
FILE(GLOB INTERFACE_SHADERS resources/shaders/*)
|
||||
SET_SOURCE_FILES_PROPERTIES(${INTERFACE_SHADERS} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/shaders)
|
||||
|
||||
SET(INTERFACE_SRCS ${INTERFACE_SRCS} ${INTERFACE_IMAGES} ${INTERFACE_SHADERS} ${CMAKE_CURRENT_SOURCE_DIR}/interface.icns)
|
||||
endif (APPLE)
|
||||
|
||||
find_package(Qt4 REQUIRED QtCore QtGui QtOpenGL)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <vector>
|
||||
#include <lodepng.h>
|
||||
#include <SharedUtil.h>
|
||||
|
@ -50,6 +51,7 @@ const float HEAD_MIN_YAW = -85;
|
|||
const float PERIPERSONAL_RADIUS = 1.0f;
|
||||
const float AVATAR_BRAKING_STRENGTH = 40.0f;
|
||||
const float JOINT_TOUCH_RANGE = 0.0005f;
|
||||
const float ANGULAR_RIGHTING_SPEED = 45.0f;
|
||||
|
||||
const float LEAN_SENSITIVITY = 0.15;
|
||||
const float LEAN_MAX = 0.45;
|
||||
|
@ -336,7 +338,21 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
_bodyRoll *= tiltDecay;
|
||||
|
||||
//the following will be used to make the avatar upright no matter what gravity is
|
||||
//float f = angleBetween(_orientation.getUp(), _gravity);
|
||||
float gravityLength = glm::length(_gravity);
|
||||
if (gravityLength > 0.0f) {
|
||||
glm::vec3 targetUp = _gravity / -gravityLength;
|
||||
const glm::vec3& currentUp = _righting * glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
float angle = glm::degrees(acosf(glm::dot(currentUp, targetUp)));
|
||||
if (angle > 0.0f) {
|
||||
glm::vec3 axis;
|
||||
if (angle > 180.0f - EPSILON) { // 180 degree rotation; must use another axis
|
||||
axis = _orientation.getRight();
|
||||
} else {
|
||||
axis = glm::normalize(glm::cross(currentUp, targetUp));
|
||||
}
|
||||
_righting = glm::angleAxis(min(deltaTime * ANGULAR_RIGHTING_SPEED, angle), axis) * _righting;
|
||||
}
|
||||
}
|
||||
|
||||
// update position by velocity
|
||||
_position += _velocity * deltaTime;
|
||||
|
@ -973,6 +989,7 @@ void Avatar::updateSkeleton() {
|
|||
_orientation.yaw (_bodyYaw );
|
||||
_orientation.pitch(_bodyPitch);
|
||||
_orientation.roll (_bodyRoll );
|
||||
_orientation.rotate(_righting);
|
||||
|
||||
// calculate positions of all bones by traversing the skeleton tree:
|
||||
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
|
||||
|
|
|
@ -170,6 +170,7 @@ private:
|
|||
float _speed;
|
||||
float _maxArmLength;
|
||||
Orientation _orientation;
|
||||
glm::quat _righting;
|
||||
int _driveKeys[MAX_DRIVE_KEYS];
|
||||
float _pelvisStandingHeight;
|
||||
float _height;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMutexLocker>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <GeometryUtil.h>
|
||||
|
@ -40,6 +41,9 @@ void Environment::init() {
|
|||
}
|
||||
|
||||
void Environment::renderAtmospheres(Camera& camera) {
|
||||
// get the lock for the duration of the call
|
||||
QMutexLocker locker(&_mutex);
|
||||
|
||||
foreach (const ServerData& serverData, _data) {
|
||||
foreach (const EnvironmentData& environmentData, serverData) {
|
||||
renderAtmosphere(camera, environmentData);
|
||||
|
@ -47,7 +51,10 @@ void Environment::renderAtmospheres(Camera& camera) {
|
|||
}
|
||||
}
|
||||
|
||||
glm::vec3 Environment::getGravity (const glm::vec3& position) const {
|
||||
glm::vec3 Environment::getGravity (const glm::vec3& position) {
|
||||
// get the lock for the duration of the call
|
||||
QMutexLocker locker(&_mutex);
|
||||
|
||||
glm::vec3 gravity;
|
||||
foreach (const ServerData& serverData, _data) {
|
||||
foreach (const EnvironmentData& environmentData, serverData) {
|
||||
|
@ -60,24 +67,30 @@ glm::vec3 Environment::getGravity (const glm::vec3& position) const {
|
|||
return gravity;
|
||||
}
|
||||
|
||||
const EnvironmentData& Environment::getClosestData(const glm::vec3& position) const {
|
||||
const EnvironmentData* closest;
|
||||
const EnvironmentData Environment::getClosestData(const glm::vec3& position) {
|
||||
// get the lock for the duration of the call
|
||||
QMutexLocker locker(&_mutex);
|
||||
|
||||
EnvironmentData closest;
|
||||
float closestDistance = FLT_MAX;
|
||||
foreach (const ServerData& serverData, _data) {
|
||||
foreach (const EnvironmentData& environmentData, serverData) {
|
||||
float distance = glm::distance(position, environmentData.getAtmosphereCenter()) -
|
||||
environmentData.getAtmosphereOuterRadius();
|
||||
if (distance < closestDistance) {
|
||||
closest = &environmentData;
|
||||
closest = environmentData;
|
||||
closestDistance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return *closest;
|
||||
return closest;
|
||||
}
|
||||
|
||||
bool Environment::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end,
|
||||
float radius, glm::vec3& penetration) const {
|
||||
float radius, glm::vec3& penetration) {
|
||||
// get the lock for the duration of the call
|
||||
QMutexLocker locker(&_mutex);
|
||||
|
||||
bool found = false;
|
||||
penetration = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
foreach (const ServerData& serverData, _data) {
|
||||
|
@ -98,6 +111,9 @@ int Environment::parseData(sockaddr *senderAddress, unsigned char* sourceBuffer,
|
|||
EnvironmentData newData;
|
||||
int bytesRead = newData.parseData(sourceBuffer, numBytes);
|
||||
|
||||
// get the lock for the duration of the call
|
||||
QMutexLocker locker(&_mutex);
|
||||
|
||||
// update the mapping by address/ID
|
||||
_data[*senderAddress][newData.getID()] = newData;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define __interface__Environment__
|
||||
|
||||
#include <QHash>
|
||||
#include <QMutex>
|
||||
|
||||
#include <UDPSocket.h>
|
||||
|
||||
|
@ -25,10 +26,10 @@ public:
|
|||
void init();
|
||||
void renderAtmospheres(Camera& camera);
|
||||
|
||||
glm::vec3 getGravity (const glm::vec3& position) const;
|
||||
const EnvironmentData& getClosestData(const glm::vec3& position) const;
|
||||
glm::vec3 getGravity (const glm::vec3& position);
|
||||
const EnvironmentData getClosestData(const glm::vec3& position);
|
||||
|
||||
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration) const;
|
||||
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration);
|
||||
|
||||
int parseData(sockaddr *senderAddress, unsigned char* sourceBuffer, int numBytes);
|
||||
|
||||
|
@ -67,6 +68,8 @@ private:
|
|||
typedef QHash<int, EnvironmentData> ServerData;
|
||||
|
||||
QHash<sockaddr, ServerData> _data;
|
||||
|
||||
QMutex _mutex;
|
||||
};
|
||||
|
||||
#endif /* defined(__interface__Environment__) */
|
||||
|
|
|
@ -19,34 +19,36 @@ const glm::vec3 IDENTITY_FRONT = glm::vec3( 0.0f, 0.0f, 1.0f);
|
|||
class Orientation
|
||||
{
|
||||
public:
|
||||
Orientation();
|
||||
|
||||
void set(Orientation);
|
||||
void setToPitchYawRoll(float pitch_change, float yaw_change, float roll_change);
|
||||
void setToIdentity();
|
||||
Orientation();
|
||||
|
||||
void set(Orientation);
|
||||
void setToPitchYawRoll(float pitch_change, float yaw_change, float roll_change);
|
||||
void setToIdentity();
|
||||
|
||||
void pitch(float pitch_change);
|
||||
void yaw (float yaw_change);
|
||||
void roll (float roll_change);
|
||||
void pitch(float pitch_change);
|
||||
void yaw (float yaw_change);
|
||||
void roll (float roll_change);
|
||||
|
||||
void rotate(float pitch, float yaw, float roll);
|
||||
void rotate(glm::vec3 EulerAngles);
|
||||
void rotate(glm::quat quaternion);
|
||||
|
||||
const glm::vec3 & getRight() const {return right;}
|
||||
const glm::vec3 & getUp () const {return up; }
|
||||
const glm::vec3 & getFront() const {return front;}
|
||||
const glm::quat& getQuat() const {return quat;}
|
||||
|
||||
const glm::vec3 & getIdentityRight() const {return IDENTITY_RIGHT;}
|
||||
const glm::vec3 & getIdentityUp () const {return IDENTITY_UP;}
|
||||
const glm::vec3 & getIdentityFront() const {return IDENTITY_FRONT;}
|
||||
const glm::vec3& getRight() const {return right;}
|
||||
const glm::vec3& getUp () const {return up; }
|
||||
const glm::vec3& getFront() const {return front;}
|
||||
|
||||
const glm::vec3& getIdentityRight() const {return IDENTITY_RIGHT;}
|
||||
const glm::vec3& getIdentityUp () const {return IDENTITY_UP;}
|
||||
const glm::vec3& getIdentityFront() const {return IDENTITY_FRONT;}
|
||||
|
||||
private:
|
||||
|
||||
glm::quat quat;
|
||||
glm::vec3 right;
|
||||
glm::vec3 up;
|
||||
glm::vec3 front;
|
||||
glm::vec3 up;
|
||||
glm::vec3 front;
|
||||
|
||||
void rotateAndGenerateDirections(glm::quat rotation);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue