diff --git a/examples/swissArmyJetpack.js b/examples/swissArmyJetpack.js index db3368d251..fb4dc1dc04 100644 --- a/examples/swissArmyJetpack.js +++ b/examples/swissArmyJetpack.js @@ -19,7 +19,7 @@ var DOWN = { x: 0.0, y: -1.0, z: 0.0 }; var MAX_VOXEL_SCAN_DISTANCE = 30.0; // behavior transition thresholds -var MIN_FLYING_SPEED = 1.0; +var MIN_FLYING_SPEED = 3.0; var MIN_COLLISIONLESS_SPEED = 5.0; var MAX_WALKING_SPEED = 30.0; var MAX_COLLIDABLE_SPEED = 35.0; @@ -38,11 +38,16 @@ var TEXT_HEIGHT = BUTTON_HEIGHT; var TEXT_WIDTH = 210; var MSEC_PER_SECOND = 1000; -var EXPIRY_PERIOD = 2 * MSEC_PER_SECOND; +var RAYCAST_EXPIRY_PERIOD = MSEC_PER_SECOND / 16; +var COLLISION_EXPIRY_PERIOD = 2 * MSEC_PER_SECOND; +var GRAVITY_ON_EXPIRY_PERIOD = MSEC_PER_SECOND / 2; +var GRAVITY_OFF_EXPIRY_PERIOD = MSEC_PER_SECOND / 8; var dater = new Date(); -var collisionOnExpiry = dater.getTime() + EXPIRY_PERIOD; -var gravityOnExpiry = dater.getTime() + EXPIRY_PERIOD; +var raycastExpiry = dater.getTime() + RAYCAST_EXPIRY_PERIOD; +var gravityOnExpiry = dater.getTime() + GRAVITY_ON_EXPIRY_PERIOD; +var gravityOffExpiry = dater.getTime() + GRAVITY_OFF_EXPIRY_PERIOD; +var collisionOnExpiry = dater.getTime() + COLLISION_EXPIRY_PERIOD; // avatar state var velocity = { x: 0.0, y: 0.0, z: 0.0 }; @@ -169,6 +174,19 @@ function updateSpeedometerDisplay() { } Script.setInterval(updateSpeedometerDisplay, 100); +function disableArtificialGravity() { + MyAvatar.motionBehaviors = MyAvatar.motionBehaviors & ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY; + updateButton(3, false); +} + +function enableArtificialGravity() { + // NOTE: setting the gravity automatically sets the AVATAR_MOTION_OBEY_LOCAL_GRAVITY behavior bit. + MyAvatar.gravity = DOWN; + updateButton(3, true); + // also enable collisions with voxels + groupBits |= COLLISION_GROUP_VOXELS; + updateButton(1, groupBits & COLLISION_GROUP_VOXELS); +} // Our update() function is called at approximately 60fps, and we will use it to animate our various overlays function update(deltaTime) { @@ -187,31 +205,57 @@ function update(deltaTime) { dater = new Date(); var now = dater.getTime(); - if (speed < MIN_FLYING_SPEED) { + // transition gravity + if (raycastExpiry < now) { // scan for landing platform ray = { origin: MyAvatar.position, direction: DOWN }; var intersection = Voxels.findRayIntersection(ray); + // NOTE: it is possible for intersection.intersects to be false when it should be true + // (perhaps the raycast failed to lock the octree thread?). To workaround this problem + // we only transition on repeated failures. + if (intersection.intersects) { - if (!(MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY)) { - var v = intersection.voxel; - var maxCorner = Vec3.sum({ x: v.x, y: v.y, z: v.z }, {x: v.s, y: v.s, z: v.s }); - var distance = lastPosition.y - maxCorner.y; - if ((gravityOnExpiry < now) && (distance < MAX_VOXEL_SCAN_DISTANCE)) { - // NOTE: setting the gravity automatically sets the AVATAR_MOTION_OBEY_LOCAL_GRAVITY behavior bit. - MyAvatar.gravity = DOWN; - updateButton(3, true); + // compute distance to voxel + var v = intersection.voxel; + var maxCorner = Vec3.sum({ x: v.x, y: v.y, z: v.z }, {x: v.s, y: v.s, z: v.s }); + var distance = lastPosition.y - maxCorner.y; + + if (distance < MAX_VOXEL_SCAN_DISTANCE) { + if (speed < MIN_FLYING_SPEED && + gravityOnExpiry < now && + !(MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY)) { + enableArtificialGravity(); } + if (speed < MAX_WALKING_SPEED) { + gravityOffExpiry = now + GRAVITY_OFF_EXPIRY_PERIOD; + } else if (gravityOffExpiry < now && MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { + disableArtificialGravity(); + } + } else { + // distance too far + if (gravityOffExpiry < now && MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { + disableArtificialGravity(); + } + gravityOnExpiry = now + GRAVITY_ON_EXPIRY_PERIOD; } } else { - if (MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { - MyAvatar.motionBehaviors = MyAvatar.motionBehaviors & ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY; - updateButton(3, false); + // no intersection + if (gravityOffExpiry < now && MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { + disableArtificialGravity(); } - gravityOnExpiry = now + EXPIRY_PERIOD; + gravityOnExpiry = now + GRAVITY_ON_EXPIRY_PERIOD; } - } else { - gravityOnExpiry = now + EXPIRY_PERIOD; } + if (speed > MAX_WALKING_SPEED && gravityOffExpiry < now) { + if (MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { + // turn off gravity + MyAvatar.motionBehaviors = MyAvatar.motionBehaviors & ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY; + updateButton(3, false); + } + gravityOnExpiry = now + GRAVITY_ON_EXPIRY_PERIOD; + } + + // transition collidability with voxels if (speed < MIN_COLLISIONLESS_SPEED) { if (collisionOnExpiry < now && !(MyAvatar.collisionGroups & COLLISION_GROUP_VOXELS)) { // TODO: check to make sure not already colliding @@ -220,14 +264,7 @@ function update(deltaTime) { updateButton(1, groupBits & COLLISION_GROUP_VOXELS); } } else { - collisionOnExpiry = now + EXPIRY_PERIOD; - } - if (speed > MAX_WALKING_SPEED) { - if (MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { - // turn off gravity - MyAvatar.motionBehaviors = MyAvatar.motionBehaviors & ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY; - updateButton(3, false); - } + collisionOnExpiry = now + COLLISION_EXPIRY_PERIOD; } if (speed > MAX_COLLIDABLE_SPEED) { if (MyAvatar.collisionGroups & COLLISION_GROUP_VOXELS) { diff --git a/interface/resources/styles/log_dialog.qss b/interface/resources/styles/log_dialog.qss index b7387c1ee7..330356e750 100644 --- a/interface/resources/styles/log_dialog.qss +++ b/interface/resources/styles/log_dialog.qss @@ -33,6 +33,7 @@ QPushButton#searchButton { } QPushButton#revealLogButton { + font-family: Helvetica, Arial, sans-serif; background: url(styles/txt-file.svg); background-repeat: none; background-position: left center; @@ -50,9 +51,9 @@ QCheckBox { } QCheckBox::indicator:unchecked { - image: url(:/styles/unchecked.svg); + image: url(styles/unchecked.svg); } QCheckBox::indicator:checked { - image: url(:/styles/checked.svg); + image: url(styles/checked.svg); } \ No newline at end of file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 558ba31d80..7ee4fdc90d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -316,6 +316,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : Particle::setVoxelEditPacketSender(&_voxelEditSender); Particle::setParticleEditPacketSender(&_particleEditSender); + // when -url in command line, teleport to location + urlGoTo(argc, constArgv); + // For now we're going to set the PPS for outbound packets to be super high, this is // probably not the right long term solution. But for now, we're going to do this to // allow you to move a particle around in your hand @@ -352,8 +355,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : QMutexLocker locker(&_settingsMutex); _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); } - //When -url in command line, teleport to location - urlGoTo(argc, constArgv); } Application::~Application() { @@ -3576,34 +3577,33 @@ void Application::takeSnapshot() { void Application::urlGoTo(int argc, const char * constArgv[]) { //Gets the url (hifi://domain/destination/orientation) QString customUrl = getCmdOption(argc, constArgv, "-url"); - - if (customUrl.startsWith("hifi://")) { + if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) { QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); - if (urlParts.count() > 1) { + if (urlParts.count() == 1) { + // location coordinates or place name + QString domain = urlParts[0]; + Menu::goToDomain(domain); + } else if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name QString domain = urlParts[0]; - + // second part is either a destination coordinate or // a place name QString destination = urlParts[1]; - + // any third part is an avatar orientation. QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - + Menu::goToDomain(domain); - + // goto either @user, #place, or x-xx,y-yy,z-zz // style co-ordinate. Menu::goTo(destination); - + if (!orientation.isEmpty()) { // location orientation Menu::goToOrientation(orientation); } - } else if (urlParts.count() == 1) { - // location coordinates or place name - QString destination = urlParts[0]; - Menu::goTo(destination); - } + } } } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 00ed3c8eef..59da23dc88 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -903,7 +903,12 @@ void Menu::goTo() { if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) { QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); - if (urlParts.count() > 1) { + if (urlParts.count() == 1) { + // location coordinates or place name + QString domain = urlParts[0]; + goToDomain(domain); + } + else if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name QString domain = urlParts[0]; @@ -924,12 +929,7 @@ void Menu::goTo() { // location orientation goToOrientation(orientation); } - } else if (urlParts.count() == 1) { - // location coordinates or place name - QString destination = urlParts[0]; - goTo(destination); } - } else { goToUser(gotoDialog.textValue()); } diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index 29238220e1..0955759097 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -62,6 +62,8 @@ PacketVersion versionForPacketType(PacketType type) { case PacketTypeVoxelSet: case PacketTypeVoxelSetDestructive: return 1; + case PacketTypeOctreeStats: + return 1; default: return 0; } diff --git a/libraries/octree/src/OctreeSceneStats.cpp b/libraries/octree/src/OctreeSceneStats.cpp index e7d34680a7..1dc1459771 100644 --- a/libraries/octree/src/OctreeSceneStats.cpp +++ b/libraries/octree/src/OctreeSceneStats.cpp @@ -646,70 +646,70 @@ int OctreeSceneStats::unpackFromMessage(const unsigned char* sourceBuffer, int a void OctreeSceneStats::printDebugDetails() { - qDebug("\n------------------------------"); - qDebug("OctreeSceneStats:"); - qDebug(" start : %llu", (long long unsigned int)_start); - qDebug(" end : %llu", (long long unsigned int)_end); - qDebug(" elapsed : %llu", (long long unsigned int)_elapsed); - qDebug(" encoding : %llu", (long long unsigned int)_totalEncodeTime); + qDebug() << "\n------------------------------"; + qDebug() << "OctreeSceneStats:"; + qDebug() << "start: " << _start; + qDebug() << "end: " << _end; + qDebug() << "elapsed: " << _elapsed; + qDebug() << "encoding: " << _totalEncodeTime; qDebug(); - qDebug(" full scene: %s", debug::valueOf(_isFullScene)); - qDebug(" moving: %s", debug::valueOf(_isMoving)); + qDebug() << "full scene: " << debug::valueOf(_isFullScene); + qDebug() << "moving: " << debug::valueOf(_isMoving); qDebug(); - qDebug(" packets: %d", _packets); - qDebug(" bytes : %ld", _bytes); + qDebug() << "packets: " << _packets; + qDebug() << "bytes: " << _bytes; qDebug(); - qDebug(" total elements : %lu", _totalElements ); - qDebug(" internal : %lu", _totalInternal ); - qDebug(" leaves : %lu", _totalLeaves ); - qDebug(" traversed : %lu", _traversed ); - qDebug(" internal : %lu", _internal ); - qDebug(" leaves : %lu", _leaves ); - qDebug(" skipped distance : %lu", _skippedDistance ); - qDebug(" internal : %lu", _internalSkippedDistance ); - qDebug(" leaves : %lu", _leavesSkippedDistance ); - qDebug(" skipped out of view : %lu", _skippedOutOfView ); - qDebug(" internal : %lu", _internalSkippedOutOfView ); - qDebug(" leaves : %lu", _leavesSkippedOutOfView ); - qDebug(" skipped was in view : %lu", _skippedWasInView ); - qDebug(" internal : %lu", _internalSkippedWasInView ); - qDebug(" leaves : %lu", _leavesSkippedWasInView ); - qDebug(" skipped no change : %lu", _skippedNoChange ); - qDebug(" internal : %lu", _internalSkippedNoChange ); - qDebug(" leaves : %lu", _leavesSkippedNoChange ); - qDebug(" skipped occluded : %lu", _skippedOccluded ); - qDebug(" internal : %lu", _internalSkippedOccluded ); - qDebug(" leaves : %lu", _leavesSkippedOccluded ); + qDebug() << "total elements: " << _totalElements; + qDebug() << "internal: " << _totalInternal; + qDebug() << "leaves: " << _totalLeaves; + qDebug() << "traversed: " << _traversed; + qDebug() << "internal: " << _internal; + qDebug() << "leaves: " << _leaves; + qDebug() << "skipped distance: " << _skippedDistance; + qDebug() << "internal: " << _internalSkippedDistance; + qDebug() << "leaves: " << _leavesSkippedDistance; + qDebug() << "skipped out of view: " << _skippedOutOfView; + qDebug() << "internal: " << _internalSkippedOutOfView; + qDebug() << "leaves: " << _leavesSkippedOutOfView; + qDebug() << "skipped was in view: " << _skippedWasInView; + qDebug() << "internal: " << _internalSkippedWasInView; + qDebug() << "leaves: " << _leavesSkippedWasInView; + qDebug() << "skipped no change: " << _skippedNoChange; + qDebug() << "internal: " << _internalSkippedNoChange; + qDebug() << "leaves: " << _leavesSkippedNoChange; + qDebug() << "skipped occluded: " << _skippedOccluded; + qDebug() << "internal: " << _internalSkippedOccluded; + qDebug() << "leaves: " << _leavesSkippedOccluded; qDebug(); - qDebug(" color sent : %lu", _colorSent ); - qDebug(" internal : %lu", _internalColorSent ); - qDebug(" leaves : %lu", _leavesColorSent ); - qDebug(" Didn't Fit : %lu", _didntFit ); - qDebug(" internal : %lu", _internalDidntFit ); - qDebug(" leaves : %lu", _leavesDidntFit ); - qDebug(" color bits : %lu", _colorBitsWritten ); - qDebug(" exists bits : %lu", _existsBitsWritten ); - qDebug(" in packet bit : %lu", _existsInPacketBitsWritten); - qDebug(" trees removed : %lu", _treesRemoved ); + qDebug() << "color sent: " << _colorSent; + qDebug() << "internal: " << _internalColorSent; + qDebug() << "leaves: " << _leavesColorSent; + qDebug() << "Didn't Fit: " << _didntFit; + qDebug() << "internal: " << _internalDidntFit; + qDebug() << "leaves: " << _leavesDidntFit; + qDebug() << "color bits: " << _colorBitsWritten; + qDebug() << "exists bits: " << _existsBitsWritten; + qDebug() << "in packet bit: " << _existsInPacketBitsWritten; + qDebug() << "trees removed: " << _treesRemoved; } OctreeSceneStats::ItemInfo OctreeSceneStats::_ITEMS[] = { - { "Elapsed" , GREENISH , 2 , "Elapsed,fps" }, - { "Encode" , YELLOWISH , 2 , "Time,fps" }, - { "Network" , GREYISH , 3 , "Packets,Bytes,KBPS" }, - { "Octrees on Server" , GREENISH , 3 , "Total,Internal,Leaves" }, - { "Octrees Sent" , YELLOWISH , 5 , "Total,Bits/Octree,Avg Bits/Octree,Internal,Leaves" }, - { "Colors Sent" , GREYISH , 3 , "Total,Internal,Leaves" }, - { "Bitmasks Sent" , GREENISH , 3 , "Colors,Exists,In Packets" }, - { "Traversed" , YELLOWISH , 3 , "Total,Internal,Leaves" }, - { "Skipped - Total" , GREYISH , 3 , "Total,Internal,Leaves" }, - { "Skipped - Distance" , GREENISH , 3 , "Total,Internal,Leaves" }, - { "Skipped - Out of View", YELLOWISH , 3 , "Total,Internal,Leaves" }, - { "Skipped - Was in View", GREYISH , 3 , "Total,Internal,Leaves" }, - { "Skipped - No Change" , GREENISH , 3 , "Total,Internal,Leaves" }, - { "Skipped - Occluded" , YELLOWISH , 3 , "Total,Internal,Leaves" }, - { "Didn't fit in packet" , GREYISH , 4 , "Total,Internal,Leaves,Removed" }, - { "Mode" , GREENISH , 4 , "Moving,Stationary,Partial,Full" }, + { "Elapsed", GREENISH, 2, "Elapsed,fps" }, + { "Encode", YELLOWISH, 2, "Time,fps" }, + { "Network", GREYISH, 3, "Packets,Bytes,KBPS" }, + { "Octrees on Server", GREENISH, 3, "Total,Internal,Leaves" }, + { "Octrees Sent", YELLOWISH, 5, "Total,Bits/Octree,Avg Bits/Octree,Internal,Leaves" }, + { "Colors Sent", GREYISH, 3, "Total,Internal,Leaves" }, + { "Bitmasks Sent", GREENISH, 3, "Colors,Exists,In Packets" }, + { "Traversed", YELLOWISH, 3, "Total,Internal,Leaves" }, + { "Skipped - Total", GREYISH, 3, "Total,Internal,Leaves" }, + { "Skipped - Distance", GREENISH, 3, "Total,Internal,Leaves" }, + { "Skipped - Out of View", YELLOWISH, 3, "Total,Internal,Leaves" }, + { "Skipped - Was in View", GREYISH, 3, "Total,Internal,Leaves" }, + { "Skipped - No Change", GREENISH, 3, "Total,Internal,Leaves" }, + { "Skipped - Occluded", YELLOWISH, 3, "Total,Internal,Leaves" }, + { "Didn't fit in packet", GREYISH, 4, "Total,Internal,Leaves,Removed" }, + { "Mode", GREENISH, 4, "Moving,Stationary,Partial,Full" }, }; const char* OctreeSceneStats::getItemValue(Item item) { @@ -732,12 +732,14 @@ const char* OctreeSceneStats::getItemValue(Item item) { case ITEM_PACKETS: { float elapsedSecs = ((float)_elapsed / (float)USECS_PER_SECOND); calculatedKBPS = elapsedSecs == 0 ? 0 : ((_bytes * 8) / elapsedSecs) / 1000; - sprintf(_itemValueBuffer, "%d packets %lu bytes (%d kbps)", _packets, _bytes, calculatedKBPS); + sprintf(_itemValueBuffer, "%d packets %lu bytes (%d kbps)", _packets, (long unsigned int)_bytes, calculatedKBPS); break; } case ITEM_VOXELS_SERVER: { - sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", - _totalElements, _totalInternal, _totalLeaves); + sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", + (long unsigned int)_totalElements, + (long unsigned int)_totalInternal, + (long unsigned int)_totalLeaves); break; } case ITEM_VOXELS: { @@ -745,12 +747,14 @@ const char* OctreeSceneStats::getItemValue(Item item) { float calculatedBPV = total == 0 ? 0 : (_bytes * 8) / total; float averageBPV = _bitsPerOctreeAverage.getAverage(); sprintf(_itemValueBuffer, "%lu (%.2f bits/octree Average: %.2f bits/octree) %lu internal %lu leaves", - total, calculatedBPV, averageBPV, _existsInPacketBitsWritten, _colorSent); + total, calculatedBPV, averageBPV, + (long unsigned int)_existsInPacketBitsWritten, + (long unsigned int)_colorSent); break; } case ITEM_TRAVERSED: { sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", - _traversed, _internal, _leaves); + (long unsigned int)_traversed, (long unsigned int)_internal, (long unsigned int)_leaves); break; } case ITEM_SKIPPED: { @@ -769,42 +773,59 @@ const char* OctreeSceneStats::getItemValue(Item item) { } case ITEM_SKIPPED_DISTANCE: { sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", - _skippedDistance, _internalSkippedDistance, _leavesSkippedDistance); + (long unsigned int)_skippedDistance, + (long unsigned int)_internalSkippedDistance, + (long unsigned int)_leavesSkippedDistance); break; } case ITEM_SKIPPED_OUT_OF_VIEW: { sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", - _skippedOutOfView, _internalSkippedOutOfView, _leavesSkippedOutOfView); + (long unsigned int)_skippedOutOfView, + (long unsigned int)_internalSkippedOutOfView, + (long unsigned int)_leavesSkippedOutOfView); break; } case ITEM_SKIPPED_WAS_IN_VIEW: { sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", - _skippedWasInView, _internalSkippedWasInView, _leavesSkippedWasInView); + (long unsigned int)_skippedWasInView, + (long unsigned int)_internalSkippedWasInView, + (long unsigned int)_leavesSkippedWasInView); break; } case ITEM_SKIPPED_NO_CHANGE: { sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", - _skippedNoChange, _internalSkippedNoChange, _leavesSkippedNoChange); + (long unsigned int)_skippedNoChange, + (long unsigned int)_internalSkippedNoChange, + (long unsigned int)_leavesSkippedNoChange); break; } case ITEM_SKIPPED_OCCLUDED: { sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", - _skippedOccluded, _internalSkippedOccluded, _leavesSkippedOccluded); + (long unsigned int)_skippedOccluded, + (long unsigned int)_internalSkippedOccluded, + (long unsigned int)_leavesSkippedOccluded); break; } case ITEM_COLORS: { sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves", - _colorSent, _internalColorSent, _leavesColorSent); + (long unsigned int)_colorSent, + (long unsigned int)_internalColorSent, + (long unsigned int)_leavesColorSent); break; } case ITEM_DIDNT_FIT: { sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves (removed: %lu)", - _didntFit, _internalDidntFit, _leavesDidntFit, _treesRemoved); + (long unsigned int)_didntFit, + (long unsigned int)_internalDidntFit, + (long unsigned int)_leavesDidntFit, + (long unsigned int)_treesRemoved); break; } case ITEM_BITS: { sprintf(_itemValueBuffer, "colors: %lu, exists: %lu, in packets: %lu", - _colorBitsWritten, _existsBitsWritten, _existsInPacketBitsWritten); + (long unsigned int)_colorBitsWritten, + (long unsigned int)_existsBitsWritten, + (long unsigned int)_existsInPacketBitsWritten); break; } case ITEM_MODE: { diff --git a/libraries/octree/src/OctreeSceneStats.h b/libraries/octree/src/OctreeSceneStats.h index 140e33aedf..ef22fd7c1c 100644 --- a/libraries/octree/src/OctreeSceneStats.h +++ b/libraries/octree/src/OctreeSceneStats.h @@ -146,30 +146,30 @@ public: const std::vector& getJurisdictionEndNodes() const { return _jurisdictionEndNodes; } bool isMoving() const { return _isMoving; }; - unsigned long getTotalElements() const { return _totalElements; } - unsigned long getTotalInternal() const { return _totalInternal; } - unsigned long getTotalLeaves() const { return _totalLeaves; } - unsigned long getTotalEncodeTime() const { return _totalEncodeTime; } - unsigned long getElapsedTime() const { return _elapsed; } + quint64 getTotalElements() const { return _totalElements; } + quint64 getTotalInternal() const { return _totalInternal; } + quint64 getTotalLeaves() const { return _totalLeaves; } + quint64 getTotalEncodeTime() const { return _totalEncodeTime; } + quint64 getElapsedTime() const { return _elapsed; } - unsigned long getLastFullElapsedTime() const { return _lastFullElapsed; } - unsigned long getLastFullTotalEncodeTime() const { return _lastFullTotalEncodeTime; } - unsigned int getLastFullTotalPackets() const { return _lastFullTotalPackets; } - unsigned long getLastFullTotalBytes() const { return _lastFullTotalBytes; } + quint64 getLastFullElapsedTime() const { return _lastFullElapsed; } + quint64 getLastFullTotalEncodeTime() const { return _lastFullTotalEncodeTime; } + quint32 getLastFullTotalPackets() const { return _lastFullTotalPackets; } + quint64 getLastFullTotalBytes() const { return _lastFullTotalBytes; } // Used in client implementations to track individual octree packets void trackIncomingOctreePacket(const QByteArray& packet, bool wasStatsPacket, int nodeClockSkewUsec); - unsigned int getIncomingPackets() const { return _incomingPacket; } - unsigned long getIncomingBytes() const { return _incomingBytes; } - unsigned long getIncomingWastedBytes() const { return _incomingWastedBytes; } - unsigned int getIncomingOutOfOrder() const { return _incomingLate + _incomingEarly; } - unsigned int getIncomingLikelyLost() const { return _incomingLikelyLost; } - unsigned int getIncomingRecovered() const { return _incomingRecovered; } - unsigned int getIncomingEarly() const { return _incomingEarly; } - unsigned int getIncomingLate() const { return _incomingLate; } - unsigned int getIncomingReallyLate() const { return _incomingReallyLate; } - unsigned int getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; } + quint32 getIncomingPackets() const { return _incomingPacket; } + quint64 getIncomingBytes() const { return _incomingBytes; } + quint64 getIncomingWastedBytes() const { return _incomingWastedBytes; } + quint32 getIncomingOutOfOrder() const { return _incomingLate + _incomingEarly; } + quint32 getIncomingLikelyLost() const { return _incomingLikelyLost; } + quint32 getIncomingRecovered() const { return _incomingRecovered; } + quint32 getIncomingEarly() const { return _incomingEarly; } + quint32 getIncomingLate() const { return _incomingLate; } + quint32 getIncomingReallyLate() const { return _incomingReallyLate; } + quint32 getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; } float getIncomingFlightTimeAverage() { return _incomingFlightTimeAverage.getAverage(); } private: @@ -178,7 +178,8 @@ private: bool _isReadyToSend; unsigned char _statsMessage[MAX_PACKET_SIZE]; - int _statsMessageLength; + + qint32 _statsMessageLength; // scene timing data in usecs bool _isStarted; @@ -188,8 +189,8 @@ private: quint64 _lastFullElapsed; quint64 _lastFullTotalEncodeTime; - unsigned int _lastFullTotalPackets; - unsigned long _lastFullTotalBytes; + quint32 _lastFullTotalPackets; + quint64 _lastFullTotalBytes; SimpleMovingAverage _elapsedAverage; SimpleMovingAverage _bitsPerOctreeAverage; @@ -198,46 +199,46 @@ private: quint64 _encodeStart; // scene octree related data - unsigned long _totalElements; - unsigned long _totalInternal; - unsigned long _totalLeaves; + quint64 _totalElements; + quint64 _totalInternal; + quint64 _totalLeaves; - unsigned long _traversed; - unsigned long _internal; - unsigned long _leaves; + quint64 _traversed; + quint64 _internal; + quint64 _leaves; - unsigned long _skippedDistance; - unsigned long _internalSkippedDistance; - unsigned long _leavesSkippedDistance; + quint64 _skippedDistance; + quint64 _internalSkippedDistance; + quint64 _leavesSkippedDistance; - unsigned long _skippedOutOfView; - unsigned long _internalSkippedOutOfView; - unsigned long _leavesSkippedOutOfView; + quint64 _skippedOutOfView; + quint64 _internalSkippedOutOfView; + quint64 _leavesSkippedOutOfView; - unsigned long _skippedWasInView; - unsigned long _internalSkippedWasInView; - unsigned long _leavesSkippedWasInView; + quint64 _skippedWasInView; + quint64 _internalSkippedWasInView; + quint64 _leavesSkippedWasInView; - unsigned long _skippedNoChange; - unsigned long _internalSkippedNoChange; - unsigned long _leavesSkippedNoChange; + quint64 _skippedNoChange; + quint64 _internalSkippedNoChange; + quint64 _leavesSkippedNoChange; - unsigned long _skippedOccluded; - unsigned long _internalSkippedOccluded; - unsigned long _leavesSkippedOccluded; + quint64 _skippedOccluded; + quint64 _internalSkippedOccluded; + quint64 _leavesSkippedOccluded; - unsigned long _colorSent; - unsigned long _internalColorSent; - unsigned long _leavesColorSent; + quint64 _colorSent; + quint64 _internalColorSent; + quint64 _leavesColorSent; - unsigned long _didntFit; - unsigned long _internalDidntFit; - unsigned long _leavesDidntFit; + quint64 _didntFit; + quint64 _internalDidntFit; + quint64 _leavesDidntFit; - unsigned long _colorBitsWritten; - unsigned long _existsBitsWritten; - unsigned long _existsInPacketBitsWritten; - unsigned long _treesRemoved; + quint64 _colorBitsWritten; + quint64 _existsBitsWritten; + quint64 _existsInPacketBitsWritten; + quint64 _treesRemoved; // Accounting Notes: // @@ -255,22 +256,22 @@ private: // // scene network related data - unsigned int _packets; - unsigned long _bytes; - unsigned int _passes; + quint32 _packets; + quint64 _bytes; + quint32 _passes; // incoming packets stats - unsigned int _incomingPacket; - unsigned long _incomingBytes; - unsigned long _incomingWastedBytes; + quint32 _incomingPacket; + quint64 _incomingBytes; + quint64 _incomingWastedBytes; - uint16_t _incomingLastSequence; /// last incoming sequence number - unsigned int _incomingLikelyLost; /// count of packets likely lost, may be off by _incomingReallyLate count - unsigned int _incomingRecovered; /// packets that were late, and we had in our missing list, we consider recovered - unsigned int _incomingEarly; /// out of order earlier than expected - unsigned int _incomingLate; /// out of order later than expected - unsigned int _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late - unsigned int _incomingPossibleDuplicate; /// out of order possibly a duplicate + quint16 _incomingLastSequence; /// last incoming sequence number + quint32 _incomingLikelyLost; /// count of packets likely lost, may be off by _incomingReallyLate count + quint32 _incomingRecovered; /// packets that were late, and we had in our missing list, we consider recovered + quint32 _incomingEarly; /// out of order earlier than expected + quint32 _incomingLate; /// out of order later than expected + quint32 _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late + quint32 _incomingPossibleDuplicate; /// out of order possibly a duplicate QSet _missingSequenceNumbers; SimpleMovingAverage _incomingFlightTimeAverage; @@ -280,7 +281,7 @@ private: static ItemInfo _ITEMS[]; - static int const MAX_ITEM_VALUE_LENGTH = 128; + static const int MAX_ITEM_VALUE_LENGTH = 128; char _itemValueBuffer[MAX_ITEM_VALUE_LENGTH]; unsigned char* _jurisdictionRoot; diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index c65b7505ee..5cfd8961ec 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -615,7 +615,7 @@ int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue) { } int packFloatToByte(unsigned char* buffer, float value, float scaleBy) { - unsigned char holder; + quint8 holder; const float CONVERSION_RATIO = (255 / scaleBy); holder = floorf(value * CONVERSION_RATIO); memcpy(buffer, &holder, sizeof(holder)); @@ -623,7 +623,7 @@ int packFloatToByte(unsigned char* buffer, float value, float scaleBy) { } int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy) { - unsigned char holder; + quint8 holder; memcpy(&holder, buffer, sizeof(holder)); value = ((float)holder / (float) 255) * scaleBy; return sizeof(holder);