mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 23:03:12 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
649fb72556
10 changed files with 53 additions and 37 deletions
|
@ -303,8 +303,8 @@ void Application::paintGL() {
|
||||||
_myCamera.setTightness (100.0f);
|
_myCamera.setTightness (100.0f);
|
||||||
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
|
_myCamera.setTargetPosition(_myAvatar.getHeadPosition());
|
||||||
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
|
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
|
||||||
-_myAvatar.getHead().getPitch(),
|
_myAvatar.getHead().getPitch(),
|
||||||
_myAvatar.getHead().getRoll());
|
-_myAvatar.getHead().getRoll());
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||||
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
||||||
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
|
_myCamera.setTargetRotation(_myAvatar.getAbsoluteHeadYaw(),
|
||||||
|
@ -1365,7 +1365,7 @@ void Application::updateAvatar(float deltaTime) {
|
||||||
const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f;
|
const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f;
|
||||||
if (powf(measuredYawRate * measuredYawRate +
|
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;
|
_headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime;
|
||||||
_headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime;
|
_headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime;
|
||||||
}
|
}
|
||||||
_headMouseX = max(_headMouseX, 0);
|
_headMouseX = max(_headMouseX, 0);
|
||||||
|
@ -1377,7 +1377,7 @@ void Application::updateAvatar(float deltaTime) {
|
||||||
float yaw, pitch, roll;
|
float yaw, pitch, roll;
|
||||||
OculusManager::getEulerAngles(yaw, pitch, roll);
|
OculusManager::getEulerAngles(yaw, pitch, roll);
|
||||||
|
|
||||||
_myAvatar.getHead().setYaw(-yaw);
|
_myAvatar.getHead().setYaw(yaw);
|
||||||
_myAvatar.getHead().setPitch(pitch);
|
_myAvatar.getHead().setPitch(pitch);
|
||||||
_myAvatar.getHead().setRoll(roll);
|
_myAvatar.getHead().setRoll(roll);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,8 +145,7 @@ void Avatar::updateHeadFromGyros(float deltaTime, SerialInterface* serialInterfa
|
||||||
// Update head lean distance based on accelerometer data
|
// Update head lean distance based on accelerometer data
|
||||||
glm::vec3 headRotationRates(_head.getPitch(), _head.getYaw(), _head.getRoll());
|
glm::vec3 headRotationRates(_head.getPitch(), _head.getYaw(), _head.getRoll());
|
||||||
|
|
||||||
|
glm::vec3 leaning = (serialInterface->getLastAcceleration() - serialInterface->getGravity())
|
||||||
glm::vec3 leaning = (serialInterface->getLastAcceleration() - serialInterface->getGravity())
|
|
||||||
* LEAN_SENSITIVITY
|
* LEAN_SENSITIVITY
|
||||||
* (1.f - fminf(glm::length(headRotationRates), HEAD_RATE_MAX) / HEAD_RATE_MAX);
|
* (1.f - fminf(glm::length(headRotationRates), HEAD_RATE_MAX) / HEAD_RATE_MAX);
|
||||||
leaning.y = 0.f;
|
leaning.y = 0.f;
|
||||||
|
|
|
@ -114,19 +114,29 @@ bool Environment::findCapsulePenetration(const glm::vec3& start, const glm::vec3
|
||||||
}
|
}
|
||||||
|
|
||||||
int Environment::parseData(sockaddr *senderAddress, unsigned char* sourceBuffer, int numBytes) {
|
int Environment::parseData(sockaddr *senderAddress, unsigned char* sourceBuffer, int numBytes) {
|
||||||
EnvironmentData newData;
|
// push past the packet header
|
||||||
int bytesRead = newData.parseData(sourceBuffer, numBytes);
|
unsigned char* start = sourceBuffer;
|
||||||
|
sourceBuffer++;
|
||||||
|
numBytes--;
|
||||||
|
|
||||||
// get the lock for the duration of the call
|
// get the lock for the duration of the call
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
|
|
||||||
// update the mapping by address/ID
|
EnvironmentData newData;
|
||||||
_data[*senderAddress][newData.getID()] = newData;
|
while (numBytes > 0) {
|
||||||
|
int dataLength = newData.parseData(sourceBuffer, numBytes);
|
||||||
|
|
||||||
|
// update the mapping by address/ID
|
||||||
|
_data[*senderAddress][newData.getID()] = newData;
|
||||||
|
|
||||||
|
sourceBuffer += dataLength;
|
||||||
|
numBytes -= dataLength;
|
||||||
|
}
|
||||||
|
|
||||||
// remove the default mapping, if any
|
// remove the default mapping, if any
|
||||||
_data.remove(getZeroAddress());
|
_data.remove(getZeroAddress());
|
||||||
|
|
||||||
return bytesRead;
|
return sourceBuffer - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgramObject* Environment::createSkyProgram(const char* from, int* locations) {
|
ProgramObject* Environment::createSkyProgram(const char* from, int* locations) {
|
||||||
|
|
|
@ -131,12 +131,12 @@ void Head::calculateGeometry(bool lookingInMirror) {
|
||||||
//generate orientation directions based on Euler angles...
|
//generate orientation directions based on Euler angles...
|
||||||
|
|
||||||
float pitch = _pitch;
|
float pitch = _pitch;
|
||||||
float yaw = -_yaw;
|
float yaw = _yaw;
|
||||||
float roll = -_roll;
|
float roll = _roll;
|
||||||
|
|
||||||
if (lookingInMirror) {
|
if (lookingInMirror) {
|
||||||
yaw = _yaw;
|
yaw = -_yaw;
|
||||||
roll = _roll;
|
roll = -_roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
_orientation.setToIdentity();
|
_orientation.setToIdentity();
|
||||||
|
@ -210,8 +210,6 @@ void Head::renderEars() {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Head::renderMouth() {
|
void Head::renderMouth() {
|
||||||
|
|
||||||
float s = sqrt(_averageLoudness);
|
float s = sqrt(_averageLoudness);
|
||||||
|
|
|
@ -38,7 +38,7 @@ void OculusManager::connect() {
|
||||||
|
|
||||||
void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) {
|
void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
_sensorFusion.GetOrientation().GetEulerAngles<Axis_Y, Axis_X, Axis_Z, Rotate_CW, Handed_R>(&yaw, &pitch, &roll);
|
_sensorFusion.GetOrientation().GetEulerAngles<Axis_Y, Axis_X, Axis_Z, Rotate_CCW, Handed_R>(&yaw, &pitch, &roll);
|
||||||
|
|
||||||
// convert each angle to degrees
|
// convert each angle to degrees
|
||||||
yaw = glm::degrees(yaw);
|
yaw = glm::degrees(yaw);
|
||||||
|
|
|
@ -203,8 +203,8 @@ void SerialInterface::readData() {
|
||||||
|
|
||||||
// Convert the integer rates to floats
|
// Convert the integer rates to floats
|
||||||
const float LSB_TO_DEGREES_PER_SECOND = 1.f / 16.4f; // From MPU-9150 register map, 2000 deg/sec.
|
const float LSB_TO_DEGREES_PER_SECOND = 1.f / 16.4f; // From MPU-9150 register map, 2000 deg/sec.
|
||||||
_lastRollRate = ((float) rollRate) * LSB_TO_DEGREES_PER_SECOND;
|
_lastRollRate = ((float) -rollRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||||
_lastYawRate = ((float) yawRate) * LSB_TO_DEGREES_PER_SECOND;
|
_lastYawRate = ((float) -yawRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||||
_lastPitchRate = ((float) -pitchRate) * LSB_TO_DEGREES_PER_SECOND;
|
_lastPitchRate = ((float) -pitchRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||||
|
|
||||||
// Accumulate a set of initial baseline readings for setting gravity
|
// Accumulate a set of initial baseline readings for setting gravity
|
||||||
|
|
|
@ -52,6 +52,10 @@ bool randomBoolean() {
|
||||||
return rand() % 2;
|
return rand() % 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool shouldDo(float desiredInterval, float deltaTime) {
|
||||||
|
return randFloat() < deltaTime / desiredInterval;
|
||||||
|
}
|
||||||
|
|
||||||
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) {
|
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) {
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
outputBits(buffer[i], false);
|
outputBits(buffer[i], false);
|
||||||
|
@ -417,4 +421,3 @@ int insertIntoSortedArrays(void* value, float key, int originalIndex,
|
||||||
}
|
}
|
||||||
return -1; // error case
|
return -1; // error case
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@ float randFloatInRange (float min,float max);
|
||||||
unsigned char randomColorValue(int minimum);
|
unsigned char randomColorValue(int minimum);
|
||||||
bool randomBoolean();
|
bool randomBoolean();
|
||||||
|
|
||||||
|
bool shouldDo(float desiredInterval, float deltaTime);
|
||||||
|
|
||||||
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine = true);
|
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine = true);
|
||||||
void outputBits(unsigned char byte, bool withNewLine = true);
|
void outputBits(unsigned char byte, bool withNewLine = true);
|
||||||
void printVoxelCode(unsigned char* voxelCode);
|
void printVoxelCode(unsigned char* voxelCode);
|
||||||
|
|
|
@ -28,8 +28,6 @@ EnvironmentData::EnvironmentData(int id) :
|
||||||
int EnvironmentData::getBroadcastData(unsigned char* destinationBuffer) const {
|
int EnvironmentData::getBroadcastData(unsigned char* destinationBuffer) const {
|
||||||
unsigned char* bufferStart = destinationBuffer;
|
unsigned char* bufferStart = destinationBuffer;
|
||||||
|
|
||||||
*destinationBuffer++ = PACKET_HEADER_ENVIRONMENT_DATA;
|
|
||||||
|
|
||||||
memcpy(destinationBuffer, &_id, sizeof(_id));
|
memcpy(destinationBuffer, &_id, sizeof(_id));
|
||||||
destinationBuffer += sizeof(_id);
|
destinationBuffer += sizeof(_id);
|
||||||
|
|
||||||
|
@ -64,9 +62,6 @@ int EnvironmentData::getBroadcastData(unsigned char* destinationBuffer) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int EnvironmentData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
int EnvironmentData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
// increment to push past the packet header
|
|
||||||
sourceBuffer++;
|
|
||||||
|
|
||||||
unsigned char* startPosition = sourceBuffer;
|
unsigned char* startPosition = sourceBuffer;
|
||||||
|
|
||||||
memcpy(&_id, sourceBuffer, sizeof(_id));
|
memcpy(&_id, sourceBuffer, sizeof(_id));
|
||||||
|
|
|
@ -49,6 +49,8 @@ int PACKETS_PER_CLIENT_PER_INTERVAL = 50;
|
||||||
|
|
||||||
const int MAX_VOXEL_TREE_DEPTH_LEVELS = 4;
|
const int MAX_VOXEL_TREE_DEPTH_LEVELS = 4;
|
||||||
|
|
||||||
|
const int ENVIRONMENT_SEND_INTERVAL_USECS = 1000000;
|
||||||
|
|
||||||
VoxelTree randomTree(true); // this is a reaveraging tree
|
VoxelTree randomTree(true); // this is a reaveraging tree
|
||||||
bool wantVoxelPersist = true;
|
bool wantVoxelPersist = true;
|
||||||
bool wantLocalDomain = false;
|
bool wantLocalDomain = false;
|
||||||
|
@ -161,8 +163,8 @@ void resInVoxelDistributor(AgentList* agentList,
|
||||||
int trueBytesSent = 0;
|
int trueBytesSent = 0;
|
||||||
double start = usecTimestampNow();
|
double start = usecTimestampNow();
|
||||||
|
|
||||||
int environmentPacketCount = sizeof(environmentData) / sizeof(environmentData[0]);
|
bool shouldSendEnvironments = shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS);
|
||||||
while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL - environmentPacketCount) {
|
while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL - (shouldSendEnvironments ? 1 : 0)) {
|
||||||
if (!agentData->nodeBag.isEmpty()) {
|
if (!agentData->nodeBag.isEmpty()) {
|
||||||
VoxelNode* subTree = agentData->nodeBag.extract();
|
VoxelNode* subTree = agentData->nodeBag.extract();
|
||||||
bytesWritten = randomTree.encodeTreeBitstream(agentData->getMaxSearchLevel(), subTree,
|
bytesWritten = randomTree.encodeTreeBitstream(agentData->getMaxSearchLevel(), subTree,
|
||||||
|
@ -194,13 +196,16 @@ void resInVoxelDistributor(AgentList* agentList,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// send the environment packets
|
// send the environment packets
|
||||||
for (int i = 0; i < environmentPacketCount; i++) {
|
if (shouldSendEnvironments) {
|
||||||
int envPacketLength = environmentData[i].getBroadcastData(tempOutputBuffer);
|
int envPacketLength = 1;
|
||||||
|
*tempOutputBuffer = PACKET_HEADER_ENVIRONMENT_DATA;
|
||||||
|
for (int i = 0; i < sizeof(environmentData) / sizeof(environmentData[0]); i++) {
|
||||||
|
envPacketLength += environmentData[i].getBroadcastData(tempOutputBuffer + envPacketLength);
|
||||||
|
}
|
||||||
agentList->getAgentSocket()->send(agent->getActiveSocket(), tempOutputBuffer, envPacketLength);
|
agentList->getAgentSocket()->send(agent->getActiveSocket(), tempOutputBuffer, envPacketLength);
|
||||||
trueBytesSent += envPacketLength;
|
trueBytesSent += envPacketLength;
|
||||||
truePacketsSent++;
|
truePacketsSent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
double end = usecTimestampNow();
|
double end = usecTimestampNow();
|
||||||
double elapsedmsec = (end - start)/1000.0;
|
double elapsedmsec = (end - start)/1000.0;
|
||||||
if (elapsedmsec > 100) {
|
if (elapsedmsec > 100) {
|
||||||
|
@ -301,8 +306,8 @@ void deepestLevelVoxelDistributor(AgentList* agentList,
|
||||||
int trueBytesSent = 0;
|
int trueBytesSent = 0;
|
||||||
double start = usecTimestampNow();
|
double start = usecTimestampNow();
|
||||||
|
|
||||||
int environmentPacketCount = sizeof(environmentData) / sizeof(environmentData[0]);
|
bool shouldSendEnvironments = shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS);
|
||||||
while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL - environmentPacketCount) {
|
while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL - (shouldSendEnvironments ? 1 : 0)) {
|
||||||
if (!agentData->nodeBag.isEmpty()) {
|
if (!agentData->nodeBag.isEmpty()) {
|
||||||
VoxelNode* subTree = agentData->nodeBag.extract();
|
VoxelNode* subTree = agentData->nodeBag.extract();
|
||||||
bytesWritten = randomTree.encodeTreeBitstream(INT_MAX, subTree,
|
bytesWritten = randomTree.encodeTreeBitstream(INT_MAX, subTree,
|
||||||
|
@ -334,9 +339,13 @@ void deepestLevelVoxelDistributor(AgentList* agentList,
|
||||||
packetsSentThisInterval = PACKETS_PER_CLIENT_PER_INTERVAL; // done for now, no nodes left
|
packetsSentThisInterval = PACKETS_PER_CLIENT_PER_INTERVAL; // done for now, no nodes left
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// send the environment packets
|
// send the environment packet
|
||||||
for (int i = 0; i < environmentPacketCount; i++) {
|
if (shouldSendEnvironments) {
|
||||||
int envPacketLength = environmentData[i].getBroadcastData(tempOutputBuffer);
|
int envPacketLength = 1;
|
||||||
|
*tempOutputBuffer = PACKET_HEADER_ENVIRONMENT_DATA;
|
||||||
|
for (int i = 0; i < sizeof(environmentData) / sizeof(environmentData[0]); i++) {
|
||||||
|
envPacketLength += environmentData[i].getBroadcastData(tempOutputBuffer + envPacketLength);
|
||||||
|
}
|
||||||
agentList->getAgentSocket()->send(agent->getActiveSocket(), tempOutputBuffer, envPacketLength);
|
agentList->getAgentSocket()->send(agent->getActiveSocket(), tempOutputBuffer, envPacketLength);
|
||||||
trueBytesSent += envPacketLength;
|
trueBytesSent += envPacketLength;
|
||||||
truePacketsSent++;
|
truePacketsSent++;
|
||||||
|
|
Loading…
Reference in a new issue