diff --git a/animation-server/src/main.cpp b/animation-server/src/main.cpp index 8a3d70d83d..8123fa439c 100644 --- a/animation-server/src/main.cpp +++ b/animation-server/src/main.cpp @@ -10,14 +10,16 @@ #include #include #include -#include +#include + +#include #include #include -#include -#include -#include +#include #include #include +#include +#include #ifdef _WIN32 #include "Syssocket.h" @@ -643,14 +645,14 @@ void* animateVoxels(void* args) { sendDanceFloor(); } - long long end = usecTimestampNow(); - long long elapsedSeconds = (end - ::start) / 1000000; + uint64_t end = usecTimestampNow(); + int elapsedSeconds = (end - ::start) / 1000000; if (::shouldShowPacketsPerSecond) { printf("packetsSent=%ld, bytesSent=%ld pps=%f bps=%f\n",packetsSent,bytesSent, (float)(packetsSent/elapsedSeconds),(float)(bytesSent/elapsedSeconds)); } // dynamically sleep until we need to fire off the next set of voxels - long long usecToSleep = ANIMATE_VOXELS_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSendTime)); + uint64_t usecToSleep = ANIMATE_VOXELS_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSendTime)); if (usecToSleep > 0) { usleep(usecToSleep); diff --git a/audio-mixer/src/main.cpp b/audio-mixer/src/main.cpp index 26f4bb23f8..68d66ac7ac 100644 --- a/audio-mixer/src/main.cpp +++ b/audio-mixer/src/main.cpp @@ -47,7 +47,7 @@ const unsigned short MIXER_LISTEN_PORT = 55443; const short JITTER_BUFFER_MSECS = 12; const short JITTER_BUFFER_SAMPLES = JITTER_BUFFER_MSECS * (SAMPLE_RATE / 1000.0); -const long long BUFFER_SEND_INTERVAL_USECS = floorf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL / SAMPLE_RATE) * 1000000); +const unsigned int BUFFER_SEND_INTERVAL_USECS = floorf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL / SAMPLE_RATE) * 1000000); const long MAX_SAMPLE_VALUE = std::numeric_limits::max(); const long MIN_SAMPLE_VALUE = std::numeric_limits::min(); @@ -412,7 +412,7 @@ int main(int argc, const char* argv[]) { numStatCollections++; } - long long usecToSleep = usecTimestamp(&startTime) + (++nextFrame * BUFFER_SEND_INTERVAL_USECS) - usecTimestampNow(); + int usecToSleep = usecTimestamp(&startTime) + (++nextFrame * BUFFER_SEND_INTERVAL_USECS) - usecTimestampNow(); if (usecToSleep > 0) { usleep(usecToSleep); diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index 6fd5fae887..b4174d986f 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -159,7 +159,7 @@ int main(int argc, const char * argv[]) } // update last receive to now - long long timeNow = usecTimestampNow(); + uint64_t timeNow = usecTimestampNow(); newNode->setLastHeardMicrostamp(timeNow); if (packetData[0] == PACKET_HEADER_DOMAIN_REPORT_FOR_DUTY diff --git a/eve/src/main.cpp b/eve/src/main.cpp index 8a03dc453b..5e7eb5d541 100644 --- a/eve/src/main.cpp +++ b/eve/src/main.cpp @@ -128,7 +128,7 @@ int main(int argc, const char* argv[]) { broadcastPacket[0] = PACKET_HEADER_HEAD_DATA; timeval thisSend; - long long numMicrosecondsSleep = 0; + int numMicrosecondsSleep = 0; int handStateTimer = 0; diff --git a/interface/external/Leap/readme.txt b/interface/external/Leap/readme.txt new file mode 100644 index 0000000000..24a79299c0 --- /dev/null +++ b/interface/external/Leap/readme.txt @@ -0,0 +1,11 @@ + +Instructions for adding the Leap driver to Interface +Eric Johnston, July 10, 2013 + +NOTE: Without doing step 2, you will crash at program start time. + +1. Copy the Leap sdk folders (lib, include, etc.) into the interface/external/Leap folder. There should be a folder already there called "stub", and this read me.txt should be there as well. + +2. IMPORTANT: Copy the file interface/external/Leap/lib/libc++/libLeap.dylib to /usr/lib + +3. Delete your build directory, run cmake and build, and you should be all set. diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2e903a6464..6cde05397c 100755 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -906,7 +906,7 @@ void Application::wheelEvent(QWheelEvent* event) { void Application::sendPingPackets() { char nodeTypesOfInterest[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER}; - long long currentTime = usecTimestampNow(); + uint64_t currentTime = usecTimestampNow(); unsigned char pingPacket[1 + sizeof(currentTime)]; pingPacket[0] = PACKET_HEADER_PING; @@ -2250,6 +2250,15 @@ void Application::displayOculus(Camera& whichCamera) { void Application::displaySide(Camera& whichCamera) { // transform by eye offset + // flip x if in mirror mode (also requires reversing winding order for backface culling) + if (_lookingInMirror->isChecked()) { + glScalef(-1.0f, 1.0f, 1.0f); + glFrontFace(GL_CW); + + } else { + glFrontFace(GL_CCW); + } + glm::vec3 eyeOffsetPos = whichCamera.getEyeOffsetPosition(); glm::quat eyeOffsetOrient = whichCamera.getEyeOffsetOrientation(); glm::vec3 eyeOffsetAxis = glm::axis(eyeOffsetOrient); @@ -2450,7 +2459,7 @@ void Application::displayOverlay() { // Show on-screen msec timer if (_renderFrameTimerOn->isChecked()) { char frameTimer[10]; - long long mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); + uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); drawtext(_glWidget->width() - 100, _glWidget->height() - 20, 0.30, 0, 1.0, 0, frameTimer, 0, 0, 0); drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30, 0, 1.0, 0, frameTimer, 1, 1, 1); diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 00bf65fd7d..426aad57b3 100755 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -324,7 +324,7 @@ void Avatar::updateFromGyrosAndOrWebcam(bool gyroLook, const glm::vec3& amplifyA // Update torso lean distance based on accelerometer data const float TORSO_LENGTH = 0.5f; const float MAX_LEAN = 45.0f; - _head.setLeanSideways(glm::clamp(glm::degrees(atanf(-estimatedPosition.x * _leanScale / TORSO_LENGTH)), + _head.setLeanSideways(glm::clamp(glm::degrees(atanf(estimatedPosition.x * _leanScale / TORSO_LENGTH)), -MAX_LEAN, MAX_LEAN)); _head.setLeanForward(glm::clamp(glm::degrees(atanf(estimatedPosition.z * _leanScale / TORSO_LENGTH)), -MAX_LEAN, MAX_LEAN)); @@ -1222,7 +1222,7 @@ void Avatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) { // Always render other people, and render myself when beyond threshold distance if (b == BODY_BALL_HEAD_BASE) { // the head is rendered as a special if (alpha > 0.0f) { - _head.render(lookingInMirror, alpha); + _head.render(alpha); } } else if (alpha > 0.0f) { // Render the body ball sphere diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 39f0da3ca9..8b116b48ff 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -67,7 +67,6 @@ Head::Head(Avatar* owningAvatar) : _audioAttack(0.0f), _returnSpringScale(1.0f), _bodyRotation(0.0f, 0.0f, 0.0f), - _lookingInMirror(false), _renderLookatVectors(false), _mohawkTriangleFan(NULL), _mohawkColors(NULL), @@ -283,11 +282,10 @@ void Head::calculateGeometry() { } -void Head::render(bool lookingInMirror, float alpha) { +void Head::render(float alpha) { _renderAlpha = alpha; - _lookingInMirror = lookingInMirror; - + calculateGeometry(); glEnable(GL_DEPTH_TEST); @@ -375,8 +373,8 @@ void Head::renderMohawk() { } else { glPushMatrix(); glTranslatef(_position.x, _position.y, _position.z); - glRotatef((_lookingInMirror ? (_bodyRotation.y - _yaw) : (_bodyRotation.y + _yaw)), 0, 1, 0); - glRotatef(_lookingInMirror ? _roll: -_roll, 0, 0, 1); + glRotatef(_bodyRotation.y + _yaw, 0, 1, 0); + glRotatef(-_roll, 0, 0, 1); glRotatef(-_pitch - _bodyRotation.x, 1, 0, 0); glBegin(GL_TRIANGLE_FAN); @@ -391,8 +389,7 @@ void Head::renderMohawk() { } glm::quat Head::getOrientation() const { - return glm::quat(glm::radians(_bodyRotation)) * glm::quat(glm::radians(_lookingInMirror ? - glm::vec3(_pitch, -_yaw, -_roll) : glm::vec3(_pitch, _yaw, _roll))); + return glm::quat(glm::radians(_bodyRotation)) * glm::quat(glm::radians(glm::vec3(_pitch, _yaw, _roll))); } glm::quat Head::getCameraOrientation () const { diff --git a/interface/src/Head.h b/interface/src/Head.h index e8bcfb5277..2b1b7aabfb 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -35,7 +35,7 @@ public: void init(); void reset(); void simulate(float deltaTime, bool isMine); - void render(bool lookingInMirror, float alpha); + void render(float alpha); void renderMohawk(); void setScale (float scale ) { _scale = scale; } @@ -102,7 +102,6 @@ private: float _audioAttack; float _returnSpringScale; //strength of return springs glm::vec3 _bodyRotation; - bool _lookingInMirror; bool _renderLookatVectors; HairTuft _hairTuft[NUM_HAIR_TUFTS]; glm::vec3* _mohawkTriangleFan; diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 791729a442..dbaf0760df 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -169,15 +169,15 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { void VoxelSystem::setupNewVoxelsForDrawing() { PerformanceWarning warn(_renderWarningsOn, "setupNewVoxelsForDrawing()"); // would like to include _voxelsInArrays, _voxelsUpdated - long long start = usecTimestampNow(); - long long sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; + uint64_t start = usecTimestampNow(); + int sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; bool iAmDebugging = false; // if you're debugging set this to true, so you won't get skipped for slow debugging if (!iAmDebugging && sinceLastTime <= std::max(_setupNewVoxelsForDrawingLastElapsed, SIXTY_FPS_IN_MILLISECONDS)) { return; // bail early, it hasn't been long enough since the last time we ran } - long long sinceLastViewCulling = (start - _lastViewCulling) / 1000; + int sinceLastViewCulling = (start - _lastViewCulling) / 1000; // If the view frustum is no longer changing, but has changed, since last time, then remove nodes that are out of view if ((sinceLastViewCulling >= std::max(_lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) && !isViewChanging() && hasViewChanged()) { @@ -193,7 +193,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { // VBO reubuilding. Possibly we should do this only if our actual VBO usage crosses some lower boundary. cleanupRemovedVoxels(); - long long endViewCulling = usecTimestampNow(); + uint64_t endViewCulling = usecTimestampNow(); _lastViewCullingElapsed = (endViewCulling - start) / 1000; } @@ -230,8 +230,8 @@ void VoxelSystem::setupNewVoxelsForDrawing() { pthread_mutex_unlock(&_bufferWriteLock); - long long end = usecTimestampNow(); - long long elapsedmsec = (end - start) / 1000; + uint64_t end = usecTimestampNow(); + int elapsedmsec = (end - start) / 1000; _setupNewVoxelsForDrawingLastFinished = end; _setupNewVoxelsForDrawingLastElapsed = elapsedmsec; } diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index 6c7006c5f4..1a5aa9fa7c 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -191,8 +191,8 @@ void Webcam::setFrame(const Mat& frame, int format, const Mat& depth, const Rota const int MAX_FPS = 60; const int MIN_FRAME_DELAY = 1000000 / MAX_FPS; - long long now = usecTimestampNow(); - long long remaining = MIN_FRAME_DELAY; + uint64_t now = usecTimestampNow(); + int remaining = MIN_FRAME_DELAY; if (_startTimestamp == 0) { _startTimestamp = now; } else { diff --git a/interface/src/Webcam.h b/interface/src/Webcam.h index f0910c7bce..c39f8660da 100644 --- a/interface/src/Webcam.h +++ b/interface/src/Webcam.h @@ -73,10 +73,10 @@ private: cv::RotatedRect _initialFaceRect; JointVector _joints; - long long _startTimestamp; + uint64_t _startTimestamp; int _frameCount; - long long _lastFrameTimestamp; + uint64_t _lastFrameTimestamp; glm::vec3 _estimatedPosition; glm::vec3 _estimatedRotation; diff --git a/libraries/audio/src/AudioInjector.cpp b/libraries/audio/src/AudioInjector.cpp index 16c381a036..d97ea8abdd 100644 --- a/libraries/audio/src/AudioInjector.cpp +++ b/libraries/audio/src/AudioInjector.cpp @@ -115,7 +115,7 @@ void AudioInjector::injectAudio(UDPSocket* injectorSocket, sockaddr* destination injectorSocket->send(destinationSocket, dataPacket, sizeof(dataPacket)); - long long usecToSleep = usecTimestamp(&startTime) + (++nextFrame * INJECT_INTERVAL_USECS) - usecTimestampNow(); + int usecToSleep = usecTimestamp(&startTime) + (++nextFrame * INJECT_INTERVAL_USECS) - usecTimestampNow(); if (usecToSleep > 0) { usleep(usecToSleep); } diff --git a/libraries/audio/src/AudioInjector.h b/libraries/audio/src/AudioInjector.h index 29ff920317..875bc815ce 100644 --- a/libraries/audio/src/AudioInjector.h +++ b/libraries/audio/src/AudioInjector.h @@ -21,7 +21,7 @@ const int STREAM_IDENTIFIER_NUM_BYTES = 8; const int MAX_INJECTOR_VOLUME = 0xFF; -const long long INJECT_INTERVAL_USECS = floorf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL / SAMPLE_RATE) * 1000000); +const int INJECT_INTERVAL_USECS = floorf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL / SAMPLE_RATE) * 1000000); class AudioInjector { public: diff --git a/libraries/shared/src/Node.h b/libraries/shared/src/Node.h index 7bafbd5b58..de43558b7a 100644 --- a/libraries/shared/src/Node.h +++ b/libraries/shared/src/Node.h @@ -37,11 +37,11 @@ public: uint16_t getNodeID() const { return _nodeID; } void setNodeID(uint16_t nodeID) { _nodeID = nodeID;} - long long getWakeMicrostamp() const { return _wakeMicrostamp; } - void setWakeMicrostamp(long long wakeMicrostamp) { _wakeMicrostamp = wakeMicrostamp; } + uint64_t getWakeMicrostamp() const { return _wakeMicrostamp; } + void setWakeMicrostamp(uint64_t wakeMicrostamp) { _wakeMicrostamp = wakeMicrostamp; } - long long getLastHeardMicrostamp() const { return _lastHeardMicrostamp; } - void setLastHeardMicrostamp(long long lastHeardMicrostamp) { _lastHeardMicrostamp = lastHeardMicrostamp; } + uint64_t getLastHeardMicrostamp() const { return _lastHeardMicrostamp; } + void setLastHeardMicrostamp(uint64_t lastHeardMicrostamp) { _lastHeardMicrostamp = lastHeardMicrostamp; } sockaddr* getPublicSocket() const { return _publicSocket; } void setPublicSocket(sockaddr* publicSocket) { _publicSocket = publicSocket; } @@ -74,8 +74,8 @@ private: char _type; uint16_t _nodeID; - long long _wakeMicrostamp; - long long _lastHeardMicrostamp; + uint64_t _wakeMicrostamp; + uint64_t _lastHeardMicrostamp; sockaddr* _publicSocket; sockaddr* _localSocket; sockaddr* _activeSocket; diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 832c81cd24..75fa0ed1d9 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -81,7 +81,7 @@ void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) { for(NodeList::iterator node = begin(); node != end(); node++) { if (socketMatch(node->getPublicSocket(), nodeAddress) || socketMatch(node->getLocalSocket(), nodeAddress)) { - int pingTime = usecTimestampNow() - *(long long *)(packetData + 1); + int pingTime = usecTimestampNow() - *(uint64_t *)(packetData + 1); node->setPingMs(pingTime / 1000); break; } @@ -422,7 +422,7 @@ void *pingUnknownNodes(void *args) { } } - long long usecToSleep = PING_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSend)); + int usecToSleep = PING_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSend)); if (usecToSleep > 0) { usleep(usecToSleep); @@ -443,7 +443,8 @@ void NodeList::stopPingUnknownNodesThread() { void *removeSilentNodes(void *args) { NodeList* nodeList = (NodeList*) args; - long long checkTimeUSecs, sleepTime; + uint64_t checkTimeUSecs; + int sleepTime; while (!silentNodeThreadStopFlag) { checkTimeUSecs = usecTimestampNow(); diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp index 9bceb0b790..d3547b384e 100644 --- a/libraries/shared/src/PerfStat.cpp +++ b/libraries/shared/src/PerfStat.cpp @@ -105,7 +105,7 @@ int PerfStat::DumpStats(char** array) { // Destructor handles recording all of our stats PerformanceWarning::~PerformanceWarning() { - long long end = usecTimestampNow(); + uint64_t end = usecTimestampNow(); double elapsedmsec = (end - _start) / 1000.0; if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) { if (elapsedmsec > 1000) { diff --git a/libraries/shared/src/PerfStat.h b/libraries/shared/src/PerfStat.h index d39c1f31fb..22eb5d38b5 100644 --- a/libraries/shared/src/PerfStat.h +++ b/libraries/shared/src/PerfStat.h @@ -85,7 +85,7 @@ typedef std::map >::iterator class PerformanceWarning { private: - long long _start; + uint64_t _start; const char* _message; bool _renderWarningsOn; bool _alwaysDisplay; diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index aaa21a5a7b..a32b567f34 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -22,11 +22,11 @@ #include #endif -long long usecTimestamp(timeval *time) { +uint64_t usecTimestamp(timeval *time) { return (time->tv_sec * 1000000 + time->tv_usec); } -long long usecTimestampNow() { +uint64_t usecTimestampNow() { timeval now; gettimeofday(&now, NULL); return (now.tv_sec * 1000000 + now.tv_usec); diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index f134828945..6973e4cec4 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -36,8 +36,8 @@ static const float DECIMETER = 0.1f; static const float CENTIMETER = 0.01f; static const float MILLIIMETER = 0.001f; -long long usecTimestamp(timeval *time); -long long usecTimestampNow(); +uint64_t usecTimestamp(timeval *time); +uint64_t usecTimestampNow(); float randFloat(); int randIntInRange (int min, int max); diff --git a/libraries/shared/src/SimpleMovingAverage.h b/libraries/shared/src/SimpleMovingAverage.h index 7c8605db5d..e8a6bc22d0 100644 --- a/libraries/shared/src/SimpleMovingAverage.h +++ b/libraries/shared/src/SimpleMovingAverage.h @@ -11,7 +11,7 @@ #ifndef __hifi__Stats__ #define __hifi__Stats__ -#include +#include class SimpleMovingAverage { public: @@ -26,7 +26,7 @@ public: float getAverageSampleValuePerSecond(); private: int _numSamples; - long long _lastEventTimestamp; + uint64_t _lastEventTimestamp; float _average; float _eventDeltaAverage; diff --git a/libraries/voxels/src/SceneUtils.cpp b/libraries/voxels/src/SceneUtils.cpp index da92734350..bd126ebf31 100644 --- a/libraries/voxels/src/SceneUtils.cpp +++ b/libraries/voxels/src/SceneUtils.cpp @@ -3,12 +3,15 @@ // hifi // // Created by Brad Hefta-Gaub on 5/7/2013. -// +// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. // -#include "SceneUtils.h" +#include + #include +#include "SceneUtils.h" + void addCornersAndAxisLines(VoxelTree* tree) { // We want our corner voxels to be about 1/2 meter high, and our TREE_SCALE is in meters, so... float voxelSize = 0.5f / TREE_SCALE; diff --git a/libraries/voxels/src/SquarePixelMap.cpp b/libraries/voxels/src/SquarePixelMap.cpp index bdc97624a7..f37bee4757 100644 --- a/libraries/voxels/src/SquarePixelMap.cpp +++ b/libraries/voxels/src/SquarePixelMap.cpp @@ -3,12 +3,15 @@ // hifi // // Created by Tomáš Horáček on 6/25/13. -// +// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. // -#include "SquarePixelMap.h" -#include +#include +#include #include +#include + +#include "SquarePixelMap.h" #define CHILD_COORD_X_IS_1 0x1 #define CHILD_COORD_Y_IS_1 0x2 diff --git a/libraries/voxels/src/VoxelNode.h b/libraries/voxels/src/VoxelNode.h index 048612f6b8..a92c562a7e 100644 --- a/libraries/voxels/src/VoxelNode.h +++ b/libraries/voxels/src/VoxelNode.h @@ -29,7 +29,7 @@ private: #endif glBufferIndex _glBufferIndex; bool _isDirty; - long long _lastChanged; + uint64_t _lastChanged; bool _shouldRender; bool _isStagedForDeletion; AABox _box; @@ -80,7 +80,7 @@ public: void printDebugDetails(const char* label) const; bool isDirty() const { return _isDirty; }; void clearDirtyBit() { _isDirty = false; }; - bool hasChangedSince(long long time) const { return (_lastChanged > time); }; + bool hasChangedSince(uint64_t time) const { return (_lastChanged > time); }; void markWithChangedTime() { _lastChanged = usecTimestampNow(); }; void handleSubtreeChanged(VoxelTree* myTree); diff --git a/voxel-server/src/VoxelNodeData.h b/voxel-server/src/VoxelNodeData.h index 66fa096a3a..c4f3d555cc 100644 --- a/voxel-server/src/VoxelNodeData.h +++ b/voxel-server/src/VoxelNodeData.h @@ -50,8 +50,8 @@ public: bool getViewSent() const { return _viewSent; }; void setViewSent(bool viewSent) { _viewSent = viewSent; } - long long getLastTimeBagEmpty() const { return _lastTimeBagEmpty; }; - void setLastTimeBagEmpty(long long lastTimeBagEmpty) { _lastTimeBagEmpty = lastTimeBagEmpty; }; + uint64_t getLastTimeBagEmpty() const { return _lastTimeBagEmpty; }; + void setLastTimeBagEmpty(uint64_t lastTimeBagEmpty) { _lastTimeBagEmpty = lastTimeBagEmpty; }; private: VoxelNodeData(const VoxelNodeData &); @@ -66,9 +66,8 @@ private: int _maxLevelReachedInLastSearch; ViewFrustum _currentViewFrustum; ViewFrustum _lastKnownViewFrustum; - long long _lastTimeBagEmpty; + uint64_t _lastTimeBagEmpty; bool _viewFrustumChanging; - }; #endif /* defined(__hifi__VoxelNodeData__) */ diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index b6a3833275..e6d8342eb6 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -32,7 +32,7 @@ const char* LOCAL_VOXELS_PERSIST_FILE = "resources/voxels.svo"; const char* VOXELS_PERSIST_FILE = "/etc/highfidelity/voxel-server/resources/voxels.svo"; -const long long VOXEL_PERSIST_INTERVAL = 1000 * 30; // every 30 seconds +const int VOXEL_PERSIST_INTERVAL = 1000 * 30; // every 30 seconds const int VOXEL_LISTEN_PORT = 40106; @@ -110,8 +110,6 @@ void eraseVoxelTreeAndCleanupNodeVisitData() { } } - - pthread_mutex_t treeLock; // Version of voxel distributor that sends the deepest LOD level at once @@ -124,7 +122,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList, pthread_mutex_lock(&::treeLock); int maxLevelReached = 0; - long long start = usecTimestampNow(); + uint64_t start = usecTimestampNow(); // FOR NOW... node tells us if it wants to receive only view frustum deltas bool wantDelta = viewFrustumChanged && nodeData->getWantDelta(); @@ -145,7 +143,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList, if (::debugVoxelSending) { printf("(viewFrustumChanged=%s || nodeData->nodeBag.isEmpty() =%s)...\n", debug::valueOf(viewFrustumChanged), debug::valueOf(nodeData->nodeBag.isEmpty())); - long long now = usecTimestampNow(); + uint64_t now = usecTimestampNow(); if (nodeData->getLastTimeBagEmpty() > 0) { float elapsedSceneSend = (now - nodeData->getLastTimeBagEmpty()) / 1000000.0f; if (viewFrustumChanged) { @@ -182,7 +180,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList, nodeData->nodeBag.insert(serverTree.rootNode); } } - long long end = usecTimestampNow(); + uint64_t end = usecTimestampNow(); int elapsedmsec = (end - start)/1000; if (elapsedmsec > 100) { if (elapsedmsec > 1000) { @@ -205,12 +203,12 @@ void deepestLevelVoxelDistributor(NodeList* nodeList, int packetsSentThisInterval = 0; int truePacketsSent = 0; int trueBytesSent = 0; - long long start = usecTimestampNow(); + uint64_t start = usecTimestampNow(); bool shouldSendEnvironments = shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS); while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL - (shouldSendEnvironments ? 1 : 0)) { // Check to see if we're taking too long, and if so bail early... - long long now = usecTimestampNow(); + uint64_t now = usecTimestampNow(); long elapsedUsec = (now - start); long elapsedUsecPerPacket = (truePacketsSent == 0) ? 0 : (elapsedUsec / truePacketsSent); long usecRemaining = (VOXEL_SEND_INTERVAL_USECS - elapsedUsec); @@ -275,7 +273,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList, truePacketsSent++; } - long long end = usecTimestampNow(); + uint64_t end = usecTimestampNow(); int elapsedmsec = (end - start)/1000; if (elapsedmsec > 100) { if (elapsedmsec > 1000) { @@ -307,10 +305,10 @@ void deepestLevelVoxelDistributor(NodeList* nodeList, pthread_mutex_unlock(&::treeLock); } -long long lastPersistVoxels = 0; +uint64_t lastPersistVoxels = 0; void persistVoxelsWhenDirty() { - long long now = usecTimestampNow(); - long long sinceLastTime = (now - ::lastPersistVoxels) / 1000; + uint64_t now = usecTimestampNow(); + int sinceLastTime = (now - ::lastPersistVoxels) / 1000; // check the dirty bit and persist here... if (::wantVoxelPersist && ::serverTree.isDirty() && sinceLastTime > VOXEL_PERSIST_INTERVAL) { @@ -350,7 +348,7 @@ void *distributeVoxelsToListeners(void *args) { } // dynamically sleep until we need to fire off the next set of voxels - long long usecToSleep = VOXEL_SEND_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSendTime)); + int usecToSleep = VOXEL_SEND_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSendTime)); if (usecToSleep > 0) { usleep(usecToSleep);