mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
3ebb4e3ba9
9 changed files with 86 additions and 62 deletions
|
@ -159,26 +159,25 @@ void Agent::run() {
|
|||
// find the audio-mixer in the NodeList so we can inject audio at it
|
||||
Node* audioMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
||||
|
||||
|
||||
if (audioMixer && audioMixer->getActiveSocket()) {
|
||||
emit willSendAudioDataCallback();
|
||||
}
|
||||
|
||||
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * INJECT_INTERVAL_USECS) - usecTimestampNow();
|
||||
if (usecToSleep > 0) {
|
||||
usleep(usecToSleep);
|
||||
}
|
||||
|
||||
if (audioMixer && audioMixer->getActiveSocket() && scriptedAudioInjector.hasSamplesToInject()) {
|
||||
// we have an audio mixer and samples to inject, send those off
|
||||
scriptedAudioInjector.injectAudio(NodeList::getInstance()->getNodeSocket(), audioMixer->getActiveSocket());
|
||||
|
||||
if (scriptedAudioInjector.hasSamplesToInject()) {
|
||||
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * INJECT_INTERVAL_USECS) - usecTimestampNow();
|
||||
if (usecToSleep > 0) {
|
||||
usleep(usecToSleep);
|
||||
}
|
||||
|
||||
scriptedAudioInjector.injectAudio(NodeList::getInstance()->getNodeSocket(), audioMixer->getActiveSocket());
|
||||
|
||||
// clear out the audio injector so that it doesn't re-send what we just sent
|
||||
scriptedAudioInjector.clear();
|
||||
}
|
||||
} else if (audioMixer) {
|
||||
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * INJECT_INTERVAL_USECS) - usecTimestampNow();
|
||||
if (usecToSleep > 0) {
|
||||
usleep(usecToSleep);
|
||||
}
|
||||
|
||||
// clear out the audio injector so that it doesn't re-send what we just sent
|
||||
scriptedAudioInjector.clear();
|
||||
}
|
||||
|
||||
if (audioMixer && !audioMixer->getActiveSocket()) {
|
||||
// don't have an active socket for the audio-mixer, ping it now
|
||||
NodeList::getInstance()->pingPublicAndLocalSocketsForInactiveNode(audioMixer);
|
||||
}
|
||||
|
|
|
@ -724,7 +724,7 @@ int DomainServer::run() {
|
|||
Assignment* assignmentToDeploy = deployableAssignmentForRequest(requestAssignment);
|
||||
|
||||
if (assignmentToDeploy) {
|
||||
|
||||
|
||||
// give this assignment out, either the type matches or the requestor said they will take any
|
||||
int numHeaderBytes = populateTypeAndVersion(broadcastPacket, PACKET_TYPE_CREATE_ASSIGNMENT);
|
||||
int numAssignmentBytes = assignmentToDeploy->packToBuffer(broadcastPacket + numHeaderBytes);
|
||||
|
|
|
@ -194,7 +194,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
|
||||
// call Menu getInstance static method to set up the menu
|
||||
_window->setMenuBar(Menu::getInstance());
|
||||
|
||||
|
||||
// Check to see if the user passed in a command line option for loading a local
|
||||
// Voxel File.
|
||||
_voxelsFilename = getCmdOption(argc, constArgv, "-i");
|
||||
|
@ -533,6 +533,7 @@ void Application::resetProfile(const QString& username) {
|
|||
// call the destructor on the old profile and construct a new one
|
||||
(&_profile)->~Profile();
|
||||
new (&_profile) Profile(username);
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
|
@ -3790,13 +3791,25 @@ void Application::attachNewHeadToNode(Node* newNode) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::updateWindowTitle(){
|
||||
QString title = "";
|
||||
QString username = _profile.getUsername();
|
||||
if(!username.isEmpty()){
|
||||
title += _profile.getUsername();
|
||||
title += " @ ";
|
||||
}
|
||||
title += _profile.getLastDomain();
|
||||
|
||||
qDebug("Application title set to: %s.\n", title.toStdString().c_str());
|
||||
_window->setWindowTitle(title);
|
||||
}
|
||||
|
||||
void Application::domainChanged(QString domain) {
|
||||
qDebug("Application title set to: %s.\n", domain.toStdString().c_str());
|
||||
_window->setWindowTitle(domain);
|
||||
|
||||
// update the user's last domain in their Profile (which will propagate to data-server)
|
||||
_profile.updateDomain(domain);
|
||||
|
||||
updateWindowTitle();
|
||||
|
||||
// reset the environment so that we don't erroneously end up with multiple
|
||||
_environment.resetToDefault();
|
||||
}
|
||||
|
|
|
@ -109,6 +109,8 @@ public:
|
|||
void touchEndEvent(QTouchEvent* event);
|
||||
void touchUpdateEvent(QTouchEvent* event);
|
||||
|
||||
void updateWindowTitle();
|
||||
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
|
||||
const glm::vec3 getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel);
|
||||
|
|
|
@ -532,6 +532,7 @@ void Menu::loadSettings(QSettings* settings) {
|
|||
Application::getInstance()->getAvatar()->loadData(settings);
|
||||
Application::getInstance()->getSwatch()->loadData(settings);
|
||||
Application::getInstance()->getProfile()->loadData(settings);
|
||||
Application::getInstance()->updateWindowTitle();
|
||||
NodeList::getInstance()->loadData(settings);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
|
|||
if (dataBuffer[numBytesRead] != '\0') {
|
||||
// read the pool from the data buffer
|
||||
setPool((const char*) dataBuffer + numBytesRead);
|
||||
numBytesRead += strlen(_pool) + sizeof('\0');
|
||||
} else {
|
||||
// skip past the null pool and null out our pool
|
||||
setPool(NULL);
|
||||
|
@ -192,7 +193,7 @@ int Assignment::packToBuffer(unsigned char* buffer) {
|
|||
numPackedBytes += NUM_BYTES_RFC4122_UUID;
|
||||
}
|
||||
|
||||
if (_pool) {
|
||||
if (hasPool()) {
|
||||
// pack the pool for this assignment, it exists
|
||||
int numBytesNullTerminatedPool = strlen(_pool) + sizeof('\0');
|
||||
memcpy(buffer + numPackedBytes, _pool, numBytesNullTerminatedPool);
|
||||
|
|
|
@ -492,10 +492,10 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
|
||||
// check in packet has header, optional UUID, node type, port, IP, node types of interest, null termination
|
||||
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) +
|
||||
NUM_BYTES_RFC4122_UUID + (2 * (sizeof(uint16_t) + IP_ADDRESS_BYTES)) +
|
||||
numBytesNodesOfInterest + sizeof(unsigned char);
|
||||
NUM_BYTES_RFC4122_UUID + (2 * (sizeof(uint16_t) + IP_ADDRESS_BYTES)) +
|
||||
numBytesNodesOfInterest + sizeof(unsigned char);
|
||||
|
||||
unsigned char* checkInPacket = new unsigned char[numPacketBytes];
|
||||
unsigned char checkInPacket[numPacketBytes];
|
||||
unsigned char* packetPosition = checkInPacket;
|
||||
|
||||
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
||||
|
@ -533,8 +533,6 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
|
||||
_nodeSocket.send(_domainIP.toString().toLocal8Bit().constData(), _domainPort, checkInPacket,
|
||||
packetPosition - checkInPacket);
|
||||
|
||||
delete[] checkInPacket; // clean up
|
||||
|
||||
const int NUM_DOMAIN_SERVER_CHECKINS_PER_STUN_REQUEST = 5;
|
||||
static unsigned int numDomainCheckins = 0;
|
||||
|
|
|
@ -74,6 +74,8 @@ bool PacketSender::process() {
|
|||
// we can determine how many packets we need to send per call to achieve our desired
|
||||
// packets per second send rate.
|
||||
int callsPerSecond = USECS_PER_SECOND / averageCallTime;
|
||||
// make sure our number of calls per second doesn't cause a divide by zero
|
||||
glm::clamp(callsPerSecond, 1, _packetsPerSecond);
|
||||
packetsPerCall = ceil(_packetsPerSecond / callsPerSecond);
|
||||
|
||||
// send at least one packet per call, if we have it
|
||||
|
|
|
@ -351,6 +351,7 @@ VoxelNode* VoxelNode::getChildAtIndex(int childIndex) const {
|
|||
int indexTwo = getNthBit(_childBitmask, 2);
|
||||
|
||||
if (_childrenExternal) {
|
||||
//assert(_children.external);
|
||||
if (indexOne == childIndex) {
|
||||
result = _children.external[0];
|
||||
} else if (indexTwo == childIndex) {
|
||||
|
@ -375,6 +376,7 @@ VoxelNode* VoxelNode::getChildAtIndex(int childIndex) const {
|
|||
int indexThree = getNthBit(_childBitmask, 3);
|
||||
|
||||
if (_childrenExternal) {
|
||||
//assert(_children.external);
|
||||
if (indexOne == childIndex) {
|
||||
result = _children.external[0];
|
||||
} else if (indexTwo == childIndex) {
|
||||
|
@ -407,7 +409,12 @@ VoxelNode* VoxelNode::getChildAtIndex(int childIndex) const {
|
|||
for (int ordinal = 1; ordinal <= childCount; ordinal++) {
|
||||
int index = getNthBit(_childBitmask, ordinal);
|
||||
if (index == childIndex) {
|
||||
result = _children.external[ordinal-1];
|
||||
int externalIndex = ordinal-1;
|
||||
if (externalIndex < childCount && externalIndex >= 0) {
|
||||
result = _children.external[externalIndex];
|
||||
} else {
|
||||
qDebug("getChildAtIndex() attempt to access external client out of bounds externalIndex=%d <<<<<<<<<< WARNING!!! \n",externalIndex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -430,9 +437,11 @@ void VoxelNode::storeTwoChildren(VoxelNode* childOne, VoxelNode* childTwo) {
|
|||
const int64_t minOffset = std::numeric_limits<int32_t>::min();
|
||||
const int64_t maxOffset = std::numeric_limits<int32_t>::max();
|
||||
|
||||
if (isBetween(offsetOne, maxOffset, minOffset) && isBetween(offsetTwo, maxOffset, minOffset)) {
|
||||
bool forceExternal = true;
|
||||
if (!forceExternal && isBetween(offsetOne, maxOffset, minOffset) && isBetween(offsetTwo, maxOffset, minOffset)) {
|
||||
// if previously external, then clean it up...
|
||||
if (_childrenExternal) {
|
||||
//assert(_children.external);
|
||||
const int previousChildCount = 2;
|
||||
_externalChildrenMemoryUsage -= previousChildCount * sizeof(VoxelNode*);
|
||||
delete[] _children.external;
|
||||
|
@ -539,7 +548,9 @@ void VoxelNode::storeThreeChildren(VoxelNode* childOne, VoxelNode* childTwo, Vox
|
|||
const int64_t minOffset = -1048576; // what can fit in 20 bits // std::numeric_limits<int16_t>::min();
|
||||
const int64_t maxOffset = 1048576; // what can fit in 20 bits // std::numeric_limits<int16_t>::max();
|
||||
|
||||
if (isBetween(offsetOne, maxOffset, minOffset) &&
|
||||
bool forceExternal = true;
|
||||
if (!forceExternal &&
|
||||
isBetween(offsetOne, maxOffset, minOffset) &&
|
||||
isBetween(offsetTwo, maxOffset, minOffset) &&
|
||||
isBetween(offsetThree, maxOffset, minOffset)) {
|
||||
// if previously external, then clean it up...
|
||||
|
@ -601,7 +612,9 @@ void VoxelNode::checkStoreFourChildren(VoxelNode* childOne, VoxelNode* childTwo,
|
|||
const int64_t minOffset = std::numeric_limits<int16_t>::min();
|
||||
const int64_t maxOffset = std::numeric_limits<int16_t>::max();
|
||||
|
||||
if (isBetween(offsetOne, maxOffset, minOffset) &&
|
||||
bool forceExternal = true;
|
||||
if (!forceExternal &&
|
||||
isBetween(offsetOne, maxOffset, minOffset) &&
|
||||
isBetween(offsetTwo, maxOffset, minOffset) &&
|
||||
isBetween(offsetThree, maxOffset, minOffset) &&
|
||||
isBetween(offsetFour, maxOffset, minOffset)
|
||||
|
@ -720,7 +733,7 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
|
|||
storeTwoChildren(childOne, childTwo);
|
||||
} else if (previousChildCount == 2 && newChildCount == 1) {
|
||||
// If we had 2 children, and we're removing one, then we know we can go down to single mode
|
||||
assert(child == NULL); // this is the only logical case
|
||||
//assert(child == NULL); // this is the only logical case
|
||||
|
||||
int indexTwo = getNthBit(previousChildMask, 2);
|
||||
bool keepChildOne = indexTwo == childIndex;
|
||||
|
@ -743,31 +756,19 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
|
|||
int indexOne = getNthBit(previousChildMask, 1);
|
||||
bool replaceChildOne = indexOne == childIndex;
|
||||
|
||||
// If we previously had an external array, then just replace the right one... that's easy.
|
||||
if (_childrenExternal) {
|
||||
// technically, we could look to see if these are now in the offsets to handle be encoded, but
|
||||
// we're going to go ahead and keep this as an array.
|
||||
if (replaceChildOne) {
|
||||
_children.external[0] = child;
|
||||
} else {
|
||||
_children.external[1] = child;
|
||||
}
|
||||
} else {
|
||||
// If we were previously encoded as offsets, then we need to see if we can still encode as offsets
|
||||
VoxelNode* childOne;
|
||||
VoxelNode* childTwo;
|
||||
|
||||
if (replaceChildOne) {
|
||||
childOne = child;
|
||||
childTwo = (VoxelNode*)((uint8_t*)this + _children.offsetsTwoChildren[1]);
|
||||
} else {
|
||||
childOne = (VoxelNode*)((uint8_t*)this + _children.offsetsTwoChildren[0]);
|
||||
childTwo = child;
|
||||
}
|
||||
// Get the existing two children out of their encoding...
|
||||
VoxelNode* childOne;
|
||||
VoxelNode* childTwo;
|
||||
retrieveTwoChildren(childOne, childTwo);
|
||||
|
||||
_twoChildrenOffsetCount--; // will end up one or the other
|
||||
storeTwoChildren(childOne, childTwo);
|
||||
if (replaceChildOne) {
|
||||
childOne = child;
|
||||
} else {
|
||||
childTwo = child;
|
||||
}
|
||||
|
||||
storeTwoChildren(childOne, childTwo);
|
||||
|
||||
} else if (previousChildCount == 2 && newChildCount == 3) {
|
||||
// If we had 2 children, and now have 3, then we know we are going to an external case...
|
||||
|
||||
|
@ -893,7 +894,7 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
|
|||
_externalChildrenCount++;
|
||||
} else if (previousChildCount == 4 && newChildCount == 3) {
|
||||
// If we had 4 children, and now have 3, then we know we are going from an external case to a potential internal case
|
||||
assert(_childrenExternal);
|
||||
//assert(_children.external && _childrenExternal && previousChildCount == 4);
|
||||
|
||||
// We need to determine which children we had, and which one we got rid of...
|
||||
int indexOne = getNthBit(previousChildMask, 1);
|
||||
|
@ -928,10 +929,11 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
|
|||
_children.external = NULL;
|
||||
_externalChildrenCount--;
|
||||
_externalChildrenMemoryUsage -= previousChildCount * sizeof(VoxelNode*);
|
||||
|
||||
|
||||
storeThreeChildren(childOne, childTwo, childThree);
|
||||
} else if (previousChildCount == newChildCount) {
|
||||
//assert(_children.external && _childrenExternal && previousChildCount >= 4);
|
||||
//assert(previousChildCount == newChildCount);
|
||||
|
||||
// 4 or more children, one item being replaced, we know we're stored externally, we just need to find the one
|
||||
// that needs to be replaced and replace it.
|
||||
for (int ordinal = 1; ordinal <= 8; ordinal++) {
|
||||
|
@ -944,6 +946,10 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
|
|||
}
|
||||
}
|
||||
} else if (previousChildCount < newChildCount) {
|
||||
// Growing case... previous must be 4 or greater
|
||||
//assert(_children.external && _childrenExternal && previousChildCount >= 4);
|
||||
//assert(previousChildCount == newChildCount-1);
|
||||
|
||||
// 4 or more children, one item being added, we know we're stored externally, we just figure out where to insert
|
||||
// this child pointer into our external list
|
||||
VoxelNode** newExternalList = new VoxelNode*[newChildCount];
|
||||
|
@ -975,13 +981,16 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
|
|||
_externalChildrenMemoryUsage += newChildCount * sizeof(VoxelNode*);
|
||||
|
||||
} else if (previousChildCount > newChildCount) {
|
||||
//assert(_children.external && _childrenExternal && previousChildCount >= 4);
|
||||
//assert(previousChildCount == newChildCount+1);
|
||||
|
||||
// 4 or more children, one item being removed, we know we're stored externally, we just figure out which
|
||||
// item to remove from our external list
|
||||
VoxelNode** newExternalList = new VoxelNode*[newChildCount];
|
||||
|
||||
for (int ordinal = 1; ordinal <= previousChildCount; ordinal++) {
|
||||
int index = getNthBit(previousChildMask, ordinal);
|
||||
assert(index != -1);
|
||||
//assert(index != -1);
|
||||
if (index < childIndex) {
|
||||
newExternalList[ordinal - 1] = _children.external[ordinal - 1];
|
||||
} else {
|
||||
|
@ -997,7 +1006,7 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
|
|||
_externalChildrenMemoryUsage -= previousChildCount * sizeof(VoxelNode*);
|
||||
_externalChildrenMemoryUsage += newChildCount * sizeof(VoxelNode*);
|
||||
} else {
|
||||
assert(false);
|
||||
//assert(false);
|
||||
qDebug("THIS SHOULD NOT HAPPEN previousChildCount == %d && newChildCount == %d\n",previousChildCount, newChildCount);
|
||||
}
|
||||
|
||||
|
@ -1024,7 +1033,6 @@ VoxelNode* VoxelNode::addChildAtIndex(int childIndex) {
|
|||
|
||||
childAt = new VoxelNode(childOctalCode(getOctalCode(), childIndex));
|
||||
childAt->setVoxelSystem(getVoxelSystem()); // our child is always part of our voxel system NULL ok
|
||||
|
||||
setChildAtIndex(childIndex, childAt);
|
||||
|
||||
_isDirty = true;
|
||||
|
|
Loading…
Reference in a new issue