From 5efc046316d658bca622c585c7983b839734076f Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Thu, 22 Jan 2015 15:03:13 -0600 Subject: [PATCH 1/8] Adding http monitoring for ICE server --- ice-server/CMakeLists.txt | 16 +++++++++++++++- ice-server/src/IceServer.cpp | 36 +++++++++++++++++++++++++++++++++++- ice-server/src/IceServer.h | 14 ++++++++++---- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/ice-server/CMakeLists.txt b/ice-server/CMakeLists.txt index 24e780f9aa..a7b2a206e4 100644 --- a/ice-server/CMakeLists.txt +++ b/ice-server/CMakeLists.txt @@ -4,6 +4,20 @@ set(TARGET_NAME ice-server) setup_hifi_project(Network) # link the shared hifi libraries -link_hifi_libraries(networking shared) +link_hifi_libraries(embedded-webserver networking shared) + +# find OpenSSL +find_package(OpenSSL REQUIRED) + +if (APPLE AND ${OPENSSL_INCLUDE_DIR} STREQUAL "/usr/include") +# this is a user on OS X using system OpenSSL, which is going to throw warnings since they're deprecating for their common crypto +message(WARNING "The found version of OpenSSL is the OS X system version. This will produce deprecation warnings." +"\nWe recommend you install a newer version (at least 1.0.1h) in a different directory and set OPENSSL_ROOT_DIR in your env so Cmake can find it.") +endif () + +include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") + +# append OpenSSL to our list of libraries to link +target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES}) include_dependency_includes() \ No newline at end of file diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp index c06bb0fc88..531dd4ea22 100644 --- a/ice-server/src/IceServer.cpp +++ b/ice-server/src/IceServer.cpp @@ -20,14 +20,19 @@ const int CLEAR_INACTIVE_PEERS_INTERVAL_MSECS = 1 * 1000; const int PEER_SILENCE_THRESHOLD_MSECS = 5 * 1000; +const quint16 ICE_SERVER_MONITORING_PORT = 40110; + IceServer::IceServer(int argc, char* argv[]) : QCoreApplication(argc, argv), _id(QUuid::createUuid()), _serverSocket(), - _activePeers() + _activePeers(), + _httpManager(ICE_SERVER_MONITORING_PORT, QString("%1/web/").arg(QCoreApplication::applicationDirPath()), this), + _httpsManager(NULL) { // start the ice-server socket qDebug() << "ice-server socket is listening on" << ICE_SERVER_DEFAULT_PORT; + qDebug() << "monitoring http endpoint is listening on " << ICE_SERVER_MONITORING_PORT; _serverSocket.bind(QHostAddress::AnyIPv4, ICE_SERVER_DEFAULT_PORT); // call our process datagrams slot when the UDP socket has packets ready @@ -165,3 +170,32 @@ void IceServer::clearInactivePeers() { } } } + +bool IceServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { + // + // We need an HTTP handler in order to monitor the health of the ice server + // The correct functioning of the ICE server will first be determined by its HTTP availability, + // and then by the existence of a minimum number of peers in the list, matching the minimum number of + // domains in production by High Fidelity. + // + + int MINIMUM_PEERS = 3; + bool IS_HEALTHY = false; + + IS_HEALTHY = _activePeers.size() >= MINIMUM_PEERS ? true : false; + + if (connection->requestOperation() == QNetworkAccessManager::GetOperation) { + if (url.path() == "/status") { + if (IS_HEALTHY) { + connection->respond(HTTPConnection::StatusCode200, QByteArray::number(_activePeers.size())); + } else { + connection->respond(HTTPConnection::StatusCode404, QByteArray::number(_activePeers.size())); + } + } + } + return true; +} + +bool IceServer::handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler) { + return true; +} diff --git a/ice-server/src/IceServer.h b/ice-server/src/IceServer.h index e15bda1211..effc8b8154 100644 --- a/ice-server/src/IceServer.h +++ b/ice-server/src/IceServer.h @@ -12,17 +12,21 @@ #ifndef hifi_IceServer_h #define hifi_IceServer_h -#include -#include -#include +#include +#include +#include #include +#include typedef QHash NetworkPeerHash; -class IceServer : public QCoreApplication { +class IceServer : public QCoreApplication, public HTTPSRequestHandler { + Q_OBJECT public: IceServer(int argc, char* argv[]); + bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false); + bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false); private slots: void processDatagrams(); void clearInactivePeers(); @@ -34,6 +38,8 @@ private: QUdpSocket _serverSocket; NetworkPeerHash _activePeers; QHash > _currentConnections; + HTTPManager _httpManager; + HTTPSManager* _httpsManager; }; #endif // hifi_IceServer_h \ No newline at end of file From 14c7dc8eb9bff4342ebda4b99f27845244aa4ecf Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 22 Jan 2015 13:13:18 -0800 Subject: [PATCH 2/8] debugging stutter --- .../entities/src/EntityEditPacketSender.cpp | 7 +++ libraries/entities/src/EntityItem.cpp | 6 +++ libraries/entities/src/EntityTree.cpp | 4 ++ libraries/entities/src/EntityTreeElement.cpp | 2 + libraries/physics/src/EntityMotionState.cpp | 13 +++++ libraries/physics/src/ObjectMotionState.cpp | 49 ++++++++++++++++++- libraries/physics/src/PhysicsEngine.cpp | 3 ++ 7 files changed, 82 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp index f2588d0493..9129cd875e 100644 --- a/libraries/entities/src/EntityEditPacketSender.cpp +++ b/libraries/entities/src/EntityEditPacketSender.cpp @@ -27,7 +27,13 @@ void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type, void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemID modelID, const EntityItemProperties& properties) { + + qDebug() << "EntityEditPacketSender::queueEditEntityMessage()..."; + qDebug() << " ID:" << modelID; + qDebug() << " properties:" << properties; + if (!_shouldSend) { + qDebug() << " BAIL EARLY! _shouldSend:" << _shouldSend; return; // bail early } @@ -36,6 +42,7 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemI int sizeOut = 0; if (EntityItemProperties::encodeEntityEditPacket(type, modelID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) { + qDebug() << " queueOctreeEditMessage() sizeOut:" << sizeOut; queueOctreeEditMessage(type, bufferOut, sizeOut); } } diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 7e3e982fb8..b413ea2b23 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1064,6 +1064,9 @@ const float MIN_SPIN_DELTA = 0.0003f; void EntityItem::updatePosition(const glm::vec3& value) { if (glm::distance(_position, value) * (float)TREE_SCALE > MIN_POSITION_DELTA) { + qDebug() << "EntityItem::updatePosition()... "; + qDebug() << " new position:" << value; + qDebug() << " in meters:" << (value * (float) TREE_SCALE); _position = value; recalculateCollisionShape(); _dirtyFlags |= EntityItem::DIRTY_POSITION; @@ -1073,6 +1076,9 @@ void EntityItem::updatePosition(const glm::vec3& value) { void EntityItem::updatePositionInMeters(const glm::vec3& value) { glm::vec3 position = glm::clamp(value / (float) TREE_SCALE, 0.0f, 1.0f); if (glm::distance(_position, position) * (float)TREE_SCALE > MIN_POSITION_DELTA) { + qDebug() << "EntityItem::updatePositionInMeters()... "; + qDebug() << " new position:" << position; + qDebug() << " in meters:" << value; _position = position; recalculateCollisionShape(); _dirtyFlags |= EntityItem::DIRTY_POSITION; diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 580fed8790..1e6fe51916 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -305,6 +305,7 @@ void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator) /// we're not changing the content of the tree, we're only changing the internal IDs that map entities from creator /// based to known IDs. This means we don't have to recurse the tree to mark the changed path as dirty. void EntityTree::handleAddEntityResponse(const QByteArray& packet) { + qDebug() << "EntityTree::handleAddEntityResponse()"; if (!getIsClient()) { qDebug() << "UNEXPECTED!!! EntityTree::handleAddEntityResponse() with !getIsClient() ***"; @@ -329,6 +330,9 @@ void EntityTree::handleAddEntityResponse(const QByteArray& packet) { searchEntityID.id = entityID; searchEntityID.creatorTokenID = creatorTokenID; + qDebug() << " creatorTokenID:" << creatorTokenID; + qDebug() << " entityID:" << entityID; + lockForWrite(); // find the creator token version, it's containing element, and the entity itself diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index aff6e64f57..923ab8a9ca 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -795,11 +795,13 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int } } else { + qDebug() << "EntityTreeElement::readElementDataFromBuffer() about to construct entity item"; entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args); if (entityItem) { bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args); addEntityItem(entityItem); // add this new entity to this elements entities entityItemID = entityItem->getEntityItemID(); + qDebug() << " entityItemID:" << entityItemID; _myTree->setContainingElement(entityItemID, this); _myTree->postAddEntity(entityItem); } diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 8b6fb1ea9f..f08683455c 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -159,15 +159,23 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ return; // never update entities that are unknown } if (_outgoingPacketFlags) { + qDebug() << "EntityMotionState::sendUpdate()..."; + qDebug() << " _outgoingPacketFlags:" << _outgoingPacketFlags; + EntityItemProperties properties = _entity->getProperties(); + qDebug() << " _entity->getProperties():" << properties << "line:" << __LINE__; if (_outgoingPacketFlags & EntityItem::DIRTY_POSITION) { btTransform worldTrans = _body->getWorldTransform(); _sentPosition = bulletToGLM(worldTrans.getOrigin()); properties.setPosition(_sentPosition + ObjectMotionState::getWorldOffset()); + qDebug() << " _sentPosition:" << _sentPosition << "line:" << __LINE__; + qDebug() << " ObjectMotionState::getWorldOffset():" << ObjectMotionState::getWorldOffset() << "line:" << __LINE__; _sentRotation = bulletToGLM(worldTrans.getRotation()); properties.setRotation(_sentRotation); + + qDebug() << " after position properties:" << properties << "line:" << __LINE__; } if (_outgoingPacketFlags & EntityItem::DIRTY_VELOCITY) { @@ -197,6 +205,8 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ properties.setGravity(_sentAcceleration); // DANGER! EntityItem stores angularVelocity in degrees/sec!!! properties.setAngularVelocity(glm::degrees(_sentAngularVelocity)); + + qDebug() << " after velocity properties:" << properties << "line:" << __LINE__; } // RELIABLE_SEND_HACK: count number of updates for entities at rest so we can stop sending them after some limit. @@ -217,6 +227,9 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ EntityItemID id(_entity->getID()); EntityEditPacketSender* entityPacketSender = static_cast(packetSender); + qDebug() << "EntityMotionState::sendUpdate()... about to call queueEditEntityMessage()"; + qDebug() << " id:" << id; + qDebug() << " properties:" << properties; entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties); // The outgoing flags only itemized WHAT to send, not WHETHER to send, hence we always set them diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index cab36b8370..cacaab614f 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -108,6 +108,18 @@ bool ObjectMotionState::doesNotNeedToSendUpdate() const { bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { assert(_body); + + + // if we've never checked before, our _sentFrame will be 0, and we need to initialize our state + if (_sentFrame == 0) { + _sentPosition = bulletToGLM(_body->getWorldTransform().getOrigin()); + _sentVelocity = bulletToGLM(_body->getLinearVelocity()); + _sentAngularVelocity = bulletToGLM(_body->getAngularVelocity()); + _sentFrame = simulationFrame; + return false; + } + + uint32_t wasSentFrame = _sentFrame; float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP; _sentFrame = simulationFrame; bool isActive = _body->isActive(); @@ -131,6 +143,10 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { // NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame // due to _worldOffset. + + glm::vec3 wasPosition = _sentPosition; + glm::vec3 wasVelocity = _sentVelocity; + glm::vec3 wasAcceleration = _sentAcceleration; // compute position error if (glm::length2(_sentVelocity) > 0.0f) { @@ -141,11 +157,40 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { btTransform worldTrans = _body->getWorldTransform(); glm::vec3 position = bulletToGLM(worldTrans.getOrigin()); - + float dx2 = glm::distance2(position, _sentPosition); const float MAX_POSITION_ERROR_SQUARED = 0.001f; // 0.001 m^2 ~~> 0.03 m if (dx2 > MAX_POSITION_ERROR_SQUARED) { - return true; +qDebug() << "ObjectMotionState::shouldSendUpdate()... computing position error"; + + glm::vec3 bulletVelocity = bulletToGLM(_body->getLinearVelocity()); + +qDebug() << " was _sentFrame:" << wasSentFrame; +qDebug() << " now _sentFrame:" << _sentFrame; +qDebug() << " dt:" << dt; + +qDebug() << " was _sentAcceleration:" << wasAcceleration; +qDebug() << " now _sentAcceleration:" << _sentAcceleration; + +qDebug() << " bulletVelocity:" << bulletVelocity; +qDebug() << " was _sentVelocity:" << wasVelocity; +qDebug() << " now _sentVelocity:" << _sentVelocity; + +qDebug() << " was _sentPosition:" << wasPosition; +qDebug() << " now _sentPosition:" << _sentPosition; +qDebug() << " bullet position:" << position; + +qDebug() << " dx2:" << dx2; +qDebug() << " (dx2 > MAX_POSITION_ERROR_SQUARED)... considering"; + if (wasSentFrame > 0) { +qDebug() << " (wasSentFrame > 0)... return TRUE"; + return true; + } else { +qDebug() << " (wasSentFrame == 0)... ignore use bullet position for next _sentPosition"; + _sentPosition = position; + } + } else { + //qDebug() << " (dx2 <= MAX_POSITION_ERROR_SQUARED)... FALL THROUGH... likely return false"; } if (glm::length2(_sentAngularVelocity) > 0.0f) { diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 7f2b139058..58253d1bd4 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -35,6 +35,9 @@ void PhysicsEngine::updateEntitiesInternal(const quint64& now) { // (3) synchronize outgoing motion states // (4) send outgoing packets + + //qDebug() << "_numSubsteps:" << _numSubsteps; + // this is step (4) QSet::iterator stateItr = _outgoingPackets.begin(); while (stateItr != _outgoingPackets.end()) { From 838a549abefa3549d2f7362686f7c2d2e114276d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 22 Jan 2015 13:31:09 -0800 Subject: [PATCH 3/8] debugging stutter --- .../entities/src/EntityEditPacketSender.cpp | 7 ---- libraries/entities/src/EntityItem.cpp | 6 --- libraries/entities/src/EntityTree.cpp | 4 -- libraries/entities/src/EntityTreeElement.cpp | 2 - libraries/physics/src/EntityMotionState.cpp | 15 -------- libraries/physics/src/ObjectMotionState.cpp | 38 +------------------ libraries/physics/src/PhysicsEngine.cpp | 3 -- 7 files changed, 1 insertion(+), 74 deletions(-) diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp index 9129cd875e..f2588d0493 100644 --- a/libraries/entities/src/EntityEditPacketSender.cpp +++ b/libraries/entities/src/EntityEditPacketSender.cpp @@ -27,13 +27,7 @@ void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type, void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemID modelID, const EntityItemProperties& properties) { - - qDebug() << "EntityEditPacketSender::queueEditEntityMessage()..."; - qDebug() << " ID:" << modelID; - qDebug() << " properties:" << properties; - if (!_shouldSend) { - qDebug() << " BAIL EARLY! _shouldSend:" << _shouldSend; return; // bail early } @@ -42,7 +36,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemI int sizeOut = 0; if (EntityItemProperties::encodeEntityEditPacket(type, modelID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) { - qDebug() << " queueOctreeEditMessage() sizeOut:" << sizeOut; queueOctreeEditMessage(type, bufferOut, sizeOut); } } diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index b413ea2b23..7e3e982fb8 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1064,9 +1064,6 @@ const float MIN_SPIN_DELTA = 0.0003f; void EntityItem::updatePosition(const glm::vec3& value) { if (glm::distance(_position, value) * (float)TREE_SCALE > MIN_POSITION_DELTA) { - qDebug() << "EntityItem::updatePosition()... "; - qDebug() << " new position:" << value; - qDebug() << " in meters:" << (value * (float) TREE_SCALE); _position = value; recalculateCollisionShape(); _dirtyFlags |= EntityItem::DIRTY_POSITION; @@ -1076,9 +1073,6 @@ void EntityItem::updatePosition(const glm::vec3& value) { void EntityItem::updatePositionInMeters(const glm::vec3& value) { glm::vec3 position = glm::clamp(value / (float) TREE_SCALE, 0.0f, 1.0f); if (glm::distance(_position, position) * (float)TREE_SCALE > MIN_POSITION_DELTA) { - qDebug() << "EntityItem::updatePositionInMeters()... "; - qDebug() << " new position:" << position; - qDebug() << " in meters:" << value; _position = position; recalculateCollisionShape(); _dirtyFlags |= EntityItem::DIRTY_POSITION; diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 1e6fe51916..580fed8790 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -305,7 +305,6 @@ void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator) /// we're not changing the content of the tree, we're only changing the internal IDs that map entities from creator /// based to known IDs. This means we don't have to recurse the tree to mark the changed path as dirty. void EntityTree::handleAddEntityResponse(const QByteArray& packet) { - qDebug() << "EntityTree::handleAddEntityResponse()"; if (!getIsClient()) { qDebug() << "UNEXPECTED!!! EntityTree::handleAddEntityResponse() with !getIsClient() ***"; @@ -330,9 +329,6 @@ void EntityTree::handleAddEntityResponse(const QByteArray& packet) { searchEntityID.id = entityID; searchEntityID.creatorTokenID = creatorTokenID; - qDebug() << " creatorTokenID:" << creatorTokenID; - qDebug() << " entityID:" << entityID; - lockForWrite(); // find the creator token version, it's containing element, and the entity itself diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index 923ab8a9ca..aff6e64f57 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -795,13 +795,11 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int } } else { - qDebug() << "EntityTreeElement::readElementDataFromBuffer() about to construct entity item"; entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args); if (entityItem) { bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args); addEntityItem(entityItem); // add this new entity to this elements entities entityItemID = entityItem->getEntityItemID(); - qDebug() << " entityItemID:" << entityItemID; _myTree->setContainingElement(entityItemID, this); _myTree->postAddEntity(entityItem); } diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index f08683455c..9453501407 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -159,23 +159,13 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ return; // never update entities that are unknown } if (_outgoingPacketFlags) { - qDebug() << "EntityMotionState::sendUpdate()..."; - qDebug() << " _outgoingPacketFlags:" << _outgoingPacketFlags; - EntityItemProperties properties = _entity->getProperties(); - qDebug() << " _entity->getProperties():" << properties << "line:" << __LINE__; - if (_outgoingPacketFlags & EntityItem::DIRTY_POSITION) { btTransform worldTrans = _body->getWorldTransform(); _sentPosition = bulletToGLM(worldTrans.getOrigin()); properties.setPosition(_sentPosition + ObjectMotionState::getWorldOffset()); - qDebug() << " _sentPosition:" << _sentPosition << "line:" << __LINE__; - qDebug() << " ObjectMotionState::getWorldOffset():" << ObjectMotionState::getWorldOffset() << "line:" << __LINE__; - _sentRotation = bulletToGLM(worldTrans.getRotation()); properties.setRotation(_sentRotation); - - qDebug() << " after position properties:" << properties << "line:" << __LINE__; } if (_outgoingPacketFlags & EntityItem::DIRTY_VELOCITY) { @@ -205,8 +195,6 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ properties.setGravity(_sentAcceleration); // DANGER! EntityItem stores angularVelocity in degrees/sec!!! properties.setAngularVelocity(glm::degrees(_sentAngularVelocity)); - - qDebug() << " after velocity properties:" << properties << "line:" << __LINE__; } // RELIABLE_SEND_HACK: count number of updates for entities at rest so we can stop sending them after some limit. @@ -227,9 +215,6 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ EntityItemID id(_entity->getID()); EntityEditPacketSender* entityPacketSender = static_cast(packetSender); - qDebug() << "EntityMotionState::sendUpdate()... about to call queueEditEntityMessage()"; - qDebug() << " id:" << id; - qDebug() << " properties:" << properties; entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties); // The outgoing flags only itemized WHAT to send, not WHETHER to send, hence we always set them diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index cacaab614f..effd7c3e4d 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -109,7 +109,6 @@ bool ObjectMotionState::doesNotNeedToSendUpdate() const { bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { assert(_body); - // if we've never checked before, our _sentFrame will be 0, and we need to initialize our state if (_sentFrame == 0) { _sentPosition = bulletToGLM(_body->getWorldTransform().getOrigin()); @@ -119,7 +118,6 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { return false; } - uint32_t wasSentFrame = _sentFrame; float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP; _sentFrame = simulationFrame; bool isActive = _body->isActive(); @@ -143,11 +141,6 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { // NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame // due to _worldOffset. - - glm::vec3 wasPosition = _sentPosition; - glm::vec3 wasVelocity = _sentVelocity; - glm::vec3 wasAcceleration = _sentAcceleration; - // compute position error if (glm::length2(_sentVelocity) > 0.0f) { _sentVelocity += _sentAcceleration * dt; @@ -161,36 +154,7 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { float dx2 = glm::distance2(position, _sentPosition); const float MAX_POSITION_ERROR_SQUARED = 0.001f; // 0.001 m^2 ~~> 0.03 m if (dx2 > MAX_POSITION_ERROR_SQUARED) { -qDebug() << "ObjectMotionState::shouldSendUpdate()... computing position error"; - - glm::vec3 bulletVelocity = bulletToGLM(_body->getLinearVelocity()); - -qDebug() << " was _sentFrame:" << wasSentFrame; -qDebug() << " now _sentFrame:" << _sentFrame; -qDebug() << " dt:" << dt; - -qDebug() << " was _sentAcceleration:" << wasAcceleration; -qDebug() << " now _sentAcceleration:" << _sentAcceleration; - -qDebug() << " bulletVelocity:" << bulletVelocity; -qDebug() << " was _sentVelocity:" << wasVelocity; -qDebug() << " now _sentVelocity:" << _sentVelocity; - -qDebug() << " was _sentPosition:" << wasPosition; -qDebug() << " now _sentPosition:" << _sentPosition; -qDebug() << " bullet position:" << position; - -qDebug() << " dx2:" << dx2; -qDebug() << " (dx2 > MAX_POSITION_ERROR_SQUARED)... considering"; - if (wasSentFrame > 0) { -qDebug() << " (wasSentFrame > 0)... return TRUE"; - return true; - } else { -qDebug() << " (wasSentFrame == 0)... ignore use bullet position for next _sentPosition"; - _sentPosition = position; - } - } else { - //qDebug() << " (dx2 <= MAX_POSITION_ERROR_SQUARED)... FALL THROUGH... likely return false"; + return true; } if (glm::length2(_sentAngularVelocity) > 0.0f) { diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 58253d1bd4..7f2b139058 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -35,9 +35,6 @@ void PhysicsEngine::updateEntitiesInternal(const quint64& now) { // (3) synchronize outgoing motion states // (4) send outgoing packets - - //qDebug() << "_numSubsteps:" << _numSubsteps; - // this is step (4) QSet::iterator stateItr = _outgoingPackets.begin(); while (stateItr != _outgoingPackets.end()) { From c6ad1462e603a71af72727cdea5c112a80b25784 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 22 Jan 2015 13:31:59 -0800 Subject: [PATCH 4/8] debugging stutter --- libraries/physics/src/EntityMotionState.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 9453501407..9be8a8f50e 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -160,10 +160,12 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ } if (_outgoingPacketFlags) { EntityItemProperties properties = _entity->getProperties(); + if (_outgoingPacketFlags & EntityItem::DIRTY_POSITION) { btTransform worldTrans = _body->getWorldTransform(); _sentPosition = bulletToGLM(worldTrans.getOrigin()); properties.setPosition(_sentPosition + ObjectMotionState::getWorldOffset()); + _sentRotation = bulletToGLM(worldTrans.getRotation()); properties.setRotation(_sentRotation); } From 6a9a6968f2ec0e33fbcff24e7f1ddeff5e2db220 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 22 Jan 2015 13:32:57 -0800 Subject: [PATCH 5/8] debugging stutter --- libraries/physics/src/EntityMotionState.cpp | 2 +- libraries/physics/src/ObjectMotionState.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 9be8a8f50e..8b6fb1ea9f 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -165,7 +165,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ btTransform worldTrans = _body->getWorldTransform(); _sentPosition = bulletToGLM(worldTrans.getOrigin()); properties.setPosition(_sentPosition + ObjectMotionState::getWorldOffset()); - + _sentRotation = bulletToGLM(worldTrans.getRotation()); properties.setRotation(_sentRotation); } diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index effd7c3e4d..25910556ff 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -141,6 +141,7 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { // NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame // due to _worldOffset. + // compute position error if (glm::length2(_sentVelocity) > 0.0f) { _sentVelocity += _sentAcceleration * dt; From 162c2f031bd16d5e1a5c33b2397405d6c36463ae Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Thu, 22 Jan 2015 15:33:37 -0600 Subject: [PATCH 6/8] Remove https unneeded crust --- ice-server/CMakeLists.txt | 14 -------------- ice-server/src/IceServer.cpp | 7 +------ ice-server/src/IceServer.h | 4 +--- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/ice-server/CMakeLists.txt b/ice-server/CMakeLists.txt index a7b2a206e4..6a8ca5bd9f 100644 --- a/ice-server/CMakeLists.txt +++ b/ice-server/CMakeLists.txt @@ -6,18 +6,4 @@ setup_hifi_project(Network) # link the shared hifi libraries link_hifi_libraries(embedded-webserver networking shared) -# find OpenSSL -find_package(OpenSSL REQUIRED) - -if (APPLE AND ${OPENSSL_INCLUDE_DIR} STREQUAL "/usr/include") -# this is a user on OS X using system OpenSSL, which is going to throw warnings since they're deprecating for their common crypto -message(WARNING "The found version of OpenSSL is the OS X system version. This will produce deprecation warnings." -"\nWe recommend you install a newer version (at least 1.0.1h) in a different directory and set OPENSSL_ROOT_DIR in your env so Cmake can find it.") -endif () - -include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") - -# append OpenSSL to our list of libraries to link -target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES}) - include_dependency_includes() \ No newline at end of file diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp index 531dd4ea22..4648656e87 100644 --- a/ice-server/src/IceServer.cpp +++ b/ice-server/src/IceServer.cpp @@ -27,8 +27,7 @@ IceServer::IceServer(int argc, char* argv[]) : _id(QUuid::createUuid()), _serverSocket(), _activePeers(), - _httpManager(ICE_SERVER_MONITORING_PORT, QString("%1/web/").arg(QCoreApplication::applicationDirPath()), this), - _httpsManager(NULL) + _httpManager(ICE_SERVER_MONITORING_PORT, QString("%1/web/").arg(QCoreApplication::applicationDirPath()), this) { // start the ice-server socket qDebug() << "ice-server socket is listening on" << ICE_SERVER_DEFAULT_PORT; @@ -195,7 +194,3 @@ bool IceServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, b } return true; } - -bool IceServer::handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler) { - return true; -} diff --git a/ice-server/src/IceServer.h b/ice-server/src/IceServer.h index effc8b8154..5367786d01 100644 --- a/ice-server/src/IceServer.h +++ b/ice-server/src/IceServer.h @@ -21,12 +21,11 @@ typedef QHash NetworkPeerHash; -class IceServer : public QCoreApplication, public HTTPSRequestHandler { +class IceServer : public QCoreApplication, public HTTPRequestHandler { Q_OBJECT public: IceServer(int argc, char* argv[]); bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false); - bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false); private slots: void processDatagrams(); void clearInactivePeers(); @@ -39,7 +38,6 @@ private: NetworkPeerHash _activePeers; QHash > _currentConnections; HTTPManager _httpManager; - HTTPSManager* _httpsManager; }; #endif // hifi_IceServer_h \ No newline at end of file From d34764bd557c811e800b03894b9b9e2319006f5a Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 22 Jan 2015 13:33:59 -0800 Subject: [PATCH 7/8] fix whitespace diff --- libraries/physics/src/ObjectMotionState.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 25910556ff..03f4c47bfa 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -141,7 +141,7 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { // NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame // due to _worldOffset. - + // compute position error if (glm::length2(_sentVelocity) > 0.0f) { _sentVelocity += _sentAcceleration * dt; @@ -151,7 +151,7 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { btTransform worldTrans = _body->getWorldTransform(); glm::vec3 position = bulletToGLM(worldTrans.getOrigin()); - + float dx2 = glm::distance2(position, _sentPosition); const float MAX_POSITION_ERROR_SQUARED = 0.001f; // 0.001 m^2 ~~> 0.03 m if (dx2 > MAX_POSITION_ERROR_SQUARED) { From 001d6896464cf0f6c3123f99c8b6308b816f96eb Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Thu, 22 Jan 2015 15:37:58 -0600 Subject: [PATCH 8/8] Fixing includes --- ice-server/src/IceServer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ice-server/src/IceServer.h b/ice-server/src/IceServer.h index 5367786d01..be6d298e3d 100644 --- a/ice-server/src/IceServer.h +++ b/ice-server/src/IceServer.h @@ -17,7 +17,8 @@ #include #include -#include +#include +#include typedef QHash NetworkPeerHash;