From e6571d334afa4cd7ec149bd01658dd3b131f711f Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Thu, 31 Jul 2014 22:37:02 +0200 Subject: [PATCH 01/94] Oculus SDK 0.4 support for Windows (tested with DK2 HMD) --- interface/src/devices/OculusManager.cpp | 52 +++++++++++++++++++++---- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 49164cc8dd..0ffc7f405f 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -44,7 +44,7 @@ ovrFovPort OculusManager::_eyeFov[ovrEye_Count]; ovrEyeRenderDesc OculusManager::_eyeRenderDesc[ovrEye_Count]; ovrSizei OculusManager::_renderTargetSize; ovrVector2f OculusManager::_UVScaleOffset[ovrEye_Count][2]; -GLuint OculusManager::_vertices[ovrEye_Count] = { 0, 0 }; +GLuint OculusManager::_vertices[ovrEye_Count] = { 0, 0 }; GLuint OculusManager::_indices[ovrEye_Count] = { 0, 0 }; GLsizei OculusManager::_meshSize[ovrEye_Count] = { 0, 0 }; ovrFrameTiming OculusManager::_hmdFrameTiming; @@ -66,12 +66,13 @@ void OculusManager::connect() { UserActivityLogger::getInstance().connectedDevice("hmd", "oculus"); } _isConnected = true; - - ovrHmd_GetDesc(_ovrHmd, &_ovrHmdDesc); - +#ifdef _WIN32 + _eyeFov[0] = _ovrHmd->DefaultEyeFov[0]; + _eyeFov[1] = _ovrHmd->DefaultEyeFov[1]; +#else _eyeFov[0] = _ovrHmdDesc.DefaultEyeFov[0]; _eyeFov[1] = _ovrHmdDesc.DefaultEyeFov[1]; - +#endif //Get texture size ovrSizei recommendedTex0Size = ovrHmd_GetFovTextureSize(_ovrHmd, ovrEye_Left, _eyeFov[0], 1.0f); @@ -86,11 +87,21 @@ void OculusManager::connect() { _eyeRenderDesc[0] = ovrHmd_GetRenderDesc(_ovrHmd, ovrEye_Left, _eyeFov[0]); _eyeRenderDesc[1] = ovrHmd_GetRenderDesc(_ovrHmd, ovrEye_Right, _eyeFov[1]); +#ifdef _WIN32 + ovrHmd_SetEnabledCaps(_ovrHmd, ovrHmdCap_LowPersistence); +#else ovrHmd_SetEnabledCaps(_ovrHmd, ovrHmdCap_LowPersistence | ovrHmdCap_LatencyTest); +#endif +#ifdef _WIN32 + ovrHmd_ConfigureTracking(_ovrHmd, ovrTrackingCap_Orientation | ovrTrackingCap_Position | + ovrTrackingCap_MagYawCorrection, + ovrTrackingCap_Orientation); +#else ovrHmd_StartSensor(_ovrHmd, ovrSensorCap_Orientation | ovrSensorCap_YawCorrection | ovrSensorCap_Position, ovrSensorCap_Orientation); +#endif if (!_camera) { _camera = new Camera; @@ -183,6 +194,16 @@ void OculusManager::generateDistortionMesh() { DistortionVertex* v = pVBVerts; ovrDistortionVertex* ov = meshData.pVertexData; for (unsigned int vertNum = 0; vertNum < meshData.VertexCount; vertNum++) { +#ifdef _WIN32 + v->pos.x = ov->ScreenPosNDC.x; + v->pos.y = ov->ScreenPosNDC.y; + v->texR.x = ov->TanEyeAnglesR.x; + v->texR.y = ov->TanEyeAnglesR.y; + v->texG.x = ov->TanEyeAnglesG.x; + v->texG.y = ov->TanEyeAnglesG.y; + v->texB.x = ov->TanEyeAnglesB.x; + v->texB.y = ov->TanEyeAnglesB.y; +#else v->pos.x = ov->Pos.x; v->pos.y = ov->Pos.y; v->texR.x = ov->TexR.x; @@ -191,6 +212,7 @@ void OculusManager::generateDistortionMesh() { v->texG.y = ov->TexG.y; v->texB.x = ov->TexB.x; v->texB.y = ov->TexB.y; +#endif v->color.r = v->color.g = v->color.b = (GLubyte)(ov->VignetteFactor * 255.99f); v->color.a = (GLubyte)(ov->TimeWarpFactor * 255.99f); v++; @@ -294,9 +316,11 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p //Render each eye into an fbo for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++) { - +#ifdef _WIN32 + ovrEyeType eye = _ovrHmd->EyeRenderOrder[eyeIndex]; +#else ovrEyeType eye = _ovrHmdDesc.EyeRenderOrder[eyeIndex]; - +#endif //Set the camera rotation for this eye eyeRenderPose[eye] = ovrHmd_GetEyePose(_ovrHmd, eye); orientation.x = eyeRenderPose[eye].Orientation.x; @@ -433,10 +457,22 @@ void OculusManager::reset() { //Gets the current predicted angles from the oculus sensors void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) { #ifdef HAVE_LIBOVR +#ifdef _WIN32 + ovrTrackingState ts = ovrHmd_GetTrackingState(_ovrHmd, ovr_GetTimeInSeconds()); +#else ovrSensorState ss = ovrHmd_GetSensorState(_ovrHmd, _hmdFrameTiming.ScanoutMidpointSeconds); - +#endif +#ifdef _WIN32 + if (ts.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) { +#else if (ss.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) { +#endif + +#ifdef _WIN32 + ovrPosef pose = ts.CameraPose; +#else ovrPosef pose = ss.Predicted.Pose; +#endif Quatf orientation = Quatf(pose.Orientation); orientation.GetEulerAngles(&yaw, &pitch, &roll); } else { From 11b1425196da577227ca8766c5c6d59664f7581b Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Thu, 31 Jul 2014 22:51:23 +0200 Subject: [PATCH 02/94] Windows requires ws2_32.lib for LIBOVR 0.4 --- interface/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 7336b55852..d3c204a021 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -258,5 +258,8 @@ else (APPLE) add_definitions(-Dssize_t=long) target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib) + if (LIBOVR_FOUND) + target_link_libraries(${TARGET_NAME} ws2_32.lib) + endif() endif() endif (APPLE) From fe3f1dbe837b47fecfca5545cc8832a11fa04e7b Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Thu, 31 Jul 2014 22:56:47 +0200 Subject: [PATCH 03/94] forgot to put back one line of code --- interface/src/devices/OculusManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 0ffc7f405f..ab30ee7c8b 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -70,6 +70,7 @@ void OculusManager::connect() { _eyeFov[0] = _ovrHmd->DefaultEyeFov[0]; _eyeFov[1] = _ovrHmd->DefaultEyeFov[1]; #else + ovrHmd_GetDesc(_ovrHmd, &_ovrHmdDesc); _eyeFov[0] = _ovrHmdDesc.DefaultEyeFov[0]; _eyeFov[1] = _ovrHmdDesc.DefaultEyeFov[1]; #endif From cb8c0792b2c9977281b103a30f0124f4eded97cc Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 6 Aug 2014 10:43:56 -0700 Subject: [PATCH 04/94] make main ragdoll and entity special also addded some logic (unused) to add ragdolls of other avatars --- interface/src/avatar/MyAvatar.cpp | 68 ++++++----- libraries/shared/src/PhysicsSimulation.cpp | 127 ++++++++++++--------- libraries/shared/src/PhysicsSimulation.h | 10 +- 3 files changed, 121 insertions(+), 84 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 4d2d679956..41eba45ac4 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -85,12 +85,12 @@ MyAvatar::MyAvatar() : _skeletonModel.setEnableShapes(true); // The skeleton is both a PhysicsEntity and Ragdoll, so we add it to the simulation once for each type. _physicsSimulation.addEntity(&_skeletonModel); - _physicsSimulation.addRagdoll(&_skeletonModel); + _physicsSimulation.setRagdoll(&_skeletonModel); } MyAvatar::~MyAvatar() { + _physicsSimulation.setRagdoll(NULL); _physicsSimulation.removeEntity(&_skeletonModel); - _physicsSimulation.removeRagdoll(&_skeletonModel); _lookAtTargetAvatar.clear(); } @@ -1532,41 +1532,53 @@ void MyAvatar::updateCollisionWithAvatars(float deltaTime) { } float myBoundingRadius = getBoundingRadius(); - const float BODY_COLLISION_RESOLUTION_FACTOR = glm::max(1.0f, deltaTime / BODY_COLLISION_RESOLUTION_TIMESCALE); - + // find nearest avatar + float nearestDistance2 = std::numeric_limits::max(); + Avatar* nearestAvatar = NULL; foreach (const AvatarSharedPointer& avatarPointer, avatars) { Avatar* avatar = static_cast(avatarPointer.data()); if (static_cast(this) == avatar) { // don't collide with ourselves continue; } - float distance = glm::length(_position - avatar->getPosition()); - if (_distanceToNearestAvatar > distance) { - _distanceToNearestAvatar = distance; + float distance2 = glm::distance2(_position, avatar->getPosition()); + if (nearestDistance2 > distance2) { + nearestDistance2 = distance2; + nearestAvatar = avatar; } - float theirBoundingRadius = avatar->getBoundingRadius(); - if (distance < myBoundingRadius + theirBoundingRadius) { - // collide our body against theirs - QVector myShapes; - _skeletonModel.getBodyShapes(myShapes); - QVector theirShapes; - avatar->getSkeletonModel().getBodyShapes(theirShapes); + } + _distanceToNearestAvatar = glm::sqrt(nearestDistance2); - CollisionInfo collision; - if (ShapeCollider::collideShapesCoarse(myShapes, theirShapes, collision)) { - float penetrationDepth = glm::length(collision._penetration); - if (penetrationDepth > myBoundingRadius) { - qDebug() << "WARNING: ignoring avatar-avatar penetration depth " << penetrationDepth; - } - else if (penetrationDepth > EPSILON) { - setPosition(getPosition() - BODY_COLLISION_RESOLUTION_FACTOR * collision._penetration); - _lastBodyPenetration += collision._penetration; - emit collisionWithAvatar(getSessionUUID(), avatar->getSessionUUID(), collision); - } + if (Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll)) { + if (nearestAvatar != NULL) { + if (_distanceToNearestAvatar > myBoundingRadius + nearestAvatar->getBoundingRadius()) { + // they aren't close enough to put into the _physicsSimulation + // so we clear the pointer + nearestAvatar = NULL; + } + } + + foreach (const AvatarSharedPointer& avatarPointer, avatars) { + Avatar* avatar = static_cast(avatarPointer.data()); + if (static_cast(this) == avatar) { + // don't collide with ourselves + continue; + } + SkeletonModel* skeleton = &(avatar->getSkeletonModel()); + PhysicsSimulation* simulation = skeleton->getSimulation(); + if (avatar == nearestAvatar) { + if (simulation != &(_physicsSimulation)) { + std::cout << "adebug adding other avatar " << avatar << " to simulation" << std::endl; // adebug + skeleton->setEnableShapes(true); + _physicsSimulation.addEntity(skeleton); + _physicsSimulation.addRagdoll(skeleton); + } + } else if (simulation == &(_physicsSimulation)) { + std::cout << "adebug removing other avatar " << avatar << " from simulation" << std::endl; // adebug + _physicsSimulation.removeRagdoll(skeleton); + _physicsSimulation.removeEntity(skeleton); + skeleton->setEnableShapes(false); } - - // collide their hands against us - avatar->getHand()->collideAgainstAvatar(this, false); } } } diff --git a/libraries/shared/src/PhysicsSimulation.cpp b/libraries/shared/src/PhysicsSimulation.cpp index c2a852c32b..5fd40543e7 100644 --- a/libraries/shared/src/PhysicsSimulation.cpp +++ b/libraries/shared/src/PhysicsSimulation.cpp @@ -24,19 +24,37 @@ int MAX_ENTITIES_PER_SIMULATION = 64; int MAX_COLLISIONS_PER_SIMULATION = 256; -PhysicsSimulation::PhysicsSimulation() : _frame(0), _collisions(MAX_COLLISIONS_PER_SIMULATION) { +PhysicsSimulation::PhysicsSimulation() : _frame(0), _entity(NULL), _ragdoll(NULL), _collisions(MAX_COLLISIONS_PER_SIMULATION) { } PhysicsSimulation::~PhysicsSimulation() { // entities have a backpointer to this simulator that must be cleaned up - int numEntities = _entities.size(); + int numEntities = _otherEntities.size(); for (int i = 0; i < numEntities; ++i) { - _entities[i]->_simulation = NULL; + _otherEntities[i]->_simulation = NULL; + } + _otherEntities.clear(); + if (_entity) { + _entity->_simulation = NULL; } - _entities.clear(); // but Ragdolls do not - _dolls.clear(); + _ragdoll = NULL; + _otherRagdolls.clear(); +} + +void PhysicsSimulation::setEntity(PhysicsEntity* entity) { + if (_entity != entity) { + if (_entity) { + assert(_entity->_simulation == this); + _entity->_simulation = NULL; + } + _entity = entity; + if (_entity) { + assert(!(_entity->_simulation)); + _entity->_simulation = this; + } + } } bool PhysicsSimulation::addEntity(PhysicsEntity* entity) { @@ -44,25 +62,24 @@ bool PhysicsSimulation::addEntity(PhysicsEntity* entity) { return false; } if (entity->_simulation == this) { - int numEntities = _entities.size(); + int numEntities = _otherEntities.size(); for (int i = 0; i < numEntities; ++i) { - if (entity == _entities.at(i)) { + if (entity == _otherEntities.at(i)) { // already in list - assert(entity->_simulation == this); return true; } } // belongs to some other simulation return false; } - int numEntities = _entities.size(); + int numEntities = _otherEntities.size(); if (numEntities > MAX_ENTITIES_PER_SIMULATION) { // list is full return false; } // add to list entity->_simulation = this; - _entities.push_back(entity); + _otherEntities.push_back(entity); return true; } @@ -71,17 +88,17 @@ void PhysicsSimulation::removeEntity(PhysicsEntity* entity) { return; } removeShapes(entity); - int numEntities = _entities.size(); + int numEntities = _otherEntities.size(); for (int i = 0; i < numEntities; ++i) { - if (entity == _entities.at(i)) { + if (entity == _otherEntities.at(i)) { if (i == numEntities - 1) { // remove it - _entities.pop_back(); + _otherEntities.pop_back(); } else { // swap the last for this one - PhysicsEntity* lastEntity = _entities[numEntities - 1]; - _entities.pop_back(); - _entities[i] = lastEntity; + PhysicsEntity* lastEntity = _otherEntities[numEntities - 1]; + _otherEntities.pop_back(); + _otherEntities[i] = lastEntity; } entity->_simulation = NULL; break; @@ -105,34 +122,34 @@ bool PhysicsSimulation::addRagdoll(Ragdoll* doll) { if (!doll) { return false; } - int numDolls = _dolls.size(); + int numDolls = _otherRagdolls.size(); if (numDolls > MAX_DOLLS_PER_SIMULATION) { // list is full return false; } for (int i = 0; i < numDolls; ++i) { - if (doll == _dolls[i]) { + if (doll == _otherRagdolls[i]) { // already in list return true; } } // add to list - _dolls.push_back(doll); + _otherRagdolls.push_back(doll); return true; } void PhysicsSimulation::removeRagdoll(Ragdoll* doll) { - int numDolls = _dolls.size(); + int numDolls = _otherRagdolls.size(); for (int i = 0; i < numDolls; ++i) { - if (doll == _dolls[i]) { + if (doll == _otherRagdolls[i]) { if (i == numDolls - 1) { // remove it - _dolls.pop_back(); + _otherRagdolls.pop_back(); } else { // swap the last for this one - Ragdoll* lastDoll = _dolls[numDolls - 1]; - _dolls.pop_back(); - _dolls[i] = lastDoll; + Ragdoll* lastDoll = _otherRagdolls[numDolls - 1]; + _otherRagdolls.pop_back(); + _otherRagdolls[i] = lastDoll; } break; } @@ -141,17 +158,21 @@ void PhysicsSimulation::removeRagdoll(Ragdoll* doll) { void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) { ++_frame; + if (!_ragdoll) { + return; + } quint64 now = usecTimestampNow(); quint64 startTime = now; quint64 expiry = startTime + maxUsec; moveRagdolls(deltaTime); buildContactConstraints(); - int numDolls = _dolls.size(); + int numDolls = _otherRagdolls.size(); { PerformanceTimer perfTimer("enforce"); + _ragdoll->enforceRagdollConstraints(); for (int i = 0; i < numDolls; ++i) { - _dolls[i]->enforceRagdollConstraints(); + _otherRagdolls[i]->enforceRagdollConstraints(); } } @@ -164,9 +185,9 @@ void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIter { // enforce constraints PerformanceTimer perfTimer("enforce"); - error = 0.0f; + error = _ragdoll->enforceRagdollConstraints(); for (int i = 0; i < numDolls; ++i) { - error = glm::max(error, _dolls[i]->enforceRagdollConstraints()); + error = glm::max(error, _otherRagdolls[i]->enforceRagdollConstraints()); } } enforceContactConstraints(); @@ -180,40 +201,38 @@ void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIter void PhysicsSimulation::moveRagdolls(float deltaTime) { PerformanceTimer perfTimer("integrate"); - int numDolls = _dolls.size(); + _ragdoll->stepRagdollForward(deltaTime); + int numDolls = _otherRagdolls.size(); for (int i = 0; i < numDolls; ++i) { - _dolls.at(i)->stepRagdollForward(deltaTime); + _otherRagdolls.at(i)->stepRagdollForward(deltaTime); } } void PhysicsSimulation::computeCollisions() { PerformanceTimer perfTimer("collide"); _collisions.clear(); - // TODO: keep track of QSet collidedEntities; - int numEntities = _entities.size(); - for (int i = 0; i < numEntities; ++i) { - PhysicsEntity* entity = _entities.at(i); - const QVector shapes = entity->getShapes(); - int numShapes = shapes.size(); - // collide with self - for (int j = 0; j < numShapes; ++j) { - const Shape* shape = shapes.at(j); - if (!shape) { - continue; - } - for (int k = j+1; k < numShapes; ++k) { - const Shape* otherShape = shapes.at(k); - if (otherShape && entity->collisionsAreEnabled(j, k)) { - ShapeCollider::collideShapes(shape, otherShape, _collisions); - } - } - } - // collide with others - for (int j = i+1; j < numEntities; ++j) { - const QVector otherShapes = _entities.at(j)->getShapes(); - ShapeCollider::collideShapesWithShapes(shapes, otherShapes, _collisions); + const QVector shapes = _entity->getShapes(); + int numShapes = shapes.size(); + // collide with self + for (int i = 0; i < numShapes; ++i) { + const Shape* shape = shapes.at(i); + if (!shape) { + continue; } + for (int j = i+1; j < numShapes; ++j) { + const Shape* otherShape = shapes.at(j); + if (otherShape && _entity->collisionsAreEnabled(i, j)) { + ShapeCollider::collideShapes(shape, otherShape, _collisions); + } + } + } + + // collide with others + int numEntities = _otherEntities.size(); + for (int i = 0; i < numEntities; ++i) { + const QVector otherShapes = _otherEntities.at(i)->getShapes(); + ShapeCollider::collideShapesWithShapes(shapes, otherShapes, _collisions); } } diff --git a/libraries/shared/src/PhysicsSimulation.h b/libraries/shared/src/PhysicsSimulation.h index 506b37533a..c8f41bb656 100644 --- a/libraries/shared/src/PhysicsSimulation.h +++ b/libraries/shared/src/PhysicsSimulation.h @@ -28,6 +28,9 @@ public: PhysicsSimulation(); ~PhysicsSimulation(); + void setRagdoll(Ragdoll* ragdoll) { _ragdoll = ragdoll; } + void setEntity(PhysicsEntity* entity); + /// \return true if entity was added to or is already in the list bool addEntity(PhysicsEntity* entity); @@ -58,8 +61,11 @@ protected: private: quint32 _frame; - QVector _dolls; - QVector _entities; + PhysicsEntity* _entity; + Ragdoll* _ragdoll; + + QVector _otherRagdolls; + QVector _otherEntities; CollisionList _collisions; QMap _contacts; }; From 62e6493456711da6c71f999c0154b0caa3f9c6c6 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 6 Aug 2014 17:09:22 -0700 Subject: [PATCH 05/94] Started on heightfield brush tool, added simple query for heightfield height (accessible from scripts). --- interface/src/ui/MetavoxelEditor.cpp | 44 +++++++++++ interface/src/ui/MetavoxelEditor.h | 31 +++++++- .../metavoxels/src/MetavoxelClientManager.cpp | 73 +++++++++++++++++++ .../metavoxels/src/MetavoxelClientManager.h | 2 + 4 files changed, 149 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 096798e77e..32ffedf0c8 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -118,6 +118,7 @@ MetavoxelEditor::MetavoxelEditor() : addTool(new SetSpannerTool(this)); addTool(new ImportHeightfieldTool(this)); addTool(new EraseHeightfieldTool(this)); + addTool(new HeightBrushTool(this)); updateAttributes(); @@ -1080,3 +1081,46 @@ void EraseHeightfieldTool::apply() { message.edit = QVariant::fromValue(edit); Application::getInstance()->getMetavoxels()->applyEdit(message, true); } + +HeightfieldBrushTool::HeightfieldBrushTool(MetavoxelEditor* editor, const QString& name) : + MetavoxelTool(editor, name, false) { + + QWidget* widget = new QWidget(); + widget->setLayout(_form = new QFormLayout()); + layout()->addWidget(widget); + + _form->addRow("Radius:", _radius = new QDoubleSpinBox()); + _radius->setSingleStep(0.01); + _radius->setMaximum(FLT_MAX); + _radius->setValue(1.0); +} + +void HeightfieldBrushTool::render() { + // find the intersection with the heightfield + glm::vec3 origin = Application::getInstance()->getMouseRayOrigin(); + glm::vec3 direction = Application::getInstance()->getMouseRayDirection(); + + float distance = -origin.y / direction.y; + glm::vec3 point = origin + distance * direction; + + point.y = Application::getInstance()->getMetavoxels()->getHeight(point); + + glPushMatrix(); + glTranslatef(point.x, point.y, point.z); + + glColor4f(1.0f, 0.0f, 0.0f, 1.0f); + + glutSolidSphere(0.1f, 8, 8); + + glPopMatrix(); +} + +HeightBrushTool::HeightBrushTool(MetavoxelEditor* editor) : + HeightfieldBrushTool(editor, "Height Brush") { + + _form->addRow("Height:", _height = new QDoubleSpinBox()); + _height->setMinimum(-FLT_MAX); + _height->setMaximum(FLT_MAX); + _height->setValue(1.0); +} + diff --git a/interface/src/ui/MetavoxelEditor.h b/interface/src/ui/MetavoxelEditor.h index cc30896c49..50b477a2bf 100644 --- a/interface/src/ui/MetavoxelEditor.h +++ b/interface/src/ui/MetavoxelEditor.h @@ -282,7 +282,7 @@ private: HeightfieldPreview _preview; }; -// Allows clearing heighfield blocks. +/// Allows clearing heighfield blocks. class EraseHeightfieldTool : public HeightfieldTool { Q_OBJECT @@ -302,4 +302,33 @@ private: QSpinBox* _length; }; +/// Base class for tools that allow painting on heightfields. +class HeightfieldBrushTool : public MetavoxelTool { + Q_OBJECT + +public: + + HeightfieldBrushTool(MetavoxelEditor* editor, const QString& name); + + virtual void render(); + +protected: + + QFormLayout* _form; + QDoubleSpinBox* _radius; +}; + +/// Allows raising or lowering parts of the heightfield. +class HeightBrushTool : public HeightfieldBrushTool { + Q_OBJECT + +public: + + HeightBrushTool(MetavoxelEditor* editor); + +private: + + QDoubleSpinBox* _height; +}; + #endif // hifi_MetavoxelEditor_h diff --git a/libraries/metavoxels/src/MetavoxelClientManager.cpp b/libraries/metavoxels/src/MetavoxelClientManager.cpp index a2d3410314..d86ad86df4 100644 --- a/libraries/metavoxels/src/MetavoxelClientManager.cpp +++ b/libraries/metavoxels/src/MetavoxelClientManager.cpp @@ -78,6 +78,79 @@ void MetavoxelClientManager::applyEdit(const MetavoxelEditMessage& edit, bool re QMetaObject::invokeMethod(_updater, "applyEdit", Q_ARG(const MetavoxelEditMessage&, edit), Q_ARG(bool, reliable)); } +class HeightVisitor : public MetavoxelVisitor { +public: + + float height; + + HeightVisitor(const MetavoxelLOD& lod, const glm::vec3& location); + + virtual int visit(MetavoxelInfo& info); + +private: + + glm::vec3 _location; +}; + +HeightVisitor::HeightVisitor(const MetavoxelLOD& lod, const glm::vec3& location) : + MetavoxelVisitor(QVector() << AttributeRegistry::getInstance()->getHeightfieldAttribute(), + QVector(), lod), + height(-FLT_MAX), + _location(location) { +} + +static const int REVERSE_ORDER = MetavoxelVisitor::encodeOrder(7, 6, 5, 4, 3, 2, 1, 0); +static const float EIGHT_BIT_MAXIMUM_RECIPROCAL = 1.0f / 255.0f; + +int HeightVisitor::visit(MetavoxelInfo& info) { + glm::vec3 relative = _location - info.minimum; + if (relative.x < 0.0f || relative.z < 0.0f || relative.x > info.size || relative.z > info.size || + height >= info.minimum.y + info.size) { + return STOP_RECURSION; + } + if (!info.isLeaf) { + return REVERSE_ORDER; + } + HeightfieldDataPointer pointer = info.inputValues.at(0).getInlineValue(); + if (!pointer) { + return STOP_RECURSION; + } + const QByteArray& contents = pointer->getContents(); + const uchar* src = (const uchar*)contents.constData(); + int size = glm::sqrt((float)contents.size()); + int highest = size - 1; + relative *= highest / info.size; + glm::vec3 floors = glm::floor(relative); + glm::vec3 ceils = glm::ceil(relative); + glm::vec3 fracts = glm::fract(relative); + int floorX = qMin(qMax((int)floors.x, 0), highest); + int floorZ = qMin(qMax((int)floors.z, 0), highest); + int ceilX = qMin(qMax((int)ceils.x, 0), highest); + int ceilZ = qMin(qMax((int)ceils.z, 0), highest); + float upperLeft = src[floorZ * size + floorX]; + float lowerRight = src[ceilZ * size + ceilX]; + float interpolatedHeight; + if (fracts.x > fracts.z) { + float upperRight = src[floorZ * size + ceilX]; + interpolatedHeight = glm::mix(glm::mix(upperLeft, upperRight, fracts.x), lowerRight, fracts.z); + + } else { + float lowerLeft = src[ceilZ * size + floorX]; + interpolatedHeight = glm::mix(upperLeft, glm::mix(lowerLeft, lowerRight, fracts.x), fracts.z); + } + if (interpolatedHeight == 0.0f) { + return STOP_RECURSION; + } + height = qMax(height, info.minimum.y + interpolatedHeight * info.size * EIGHT_BIT_MAXIMUM_RECIPROCAL); + return SHORT_CIRCUIT; +} + +float MetavoxelClientManager::getHeight(const glm::vec3& location) { + HeightVisitor visitor(getLOD(), location); + guide(visitor); + return visitor.height; +} + MetavoxelLOD MetavoxelClientManager::getLOD() { return MetavoxelLOD(); } diff --git a/libraries/metavoxels/src/MetavoxelClientManager.h b/libraries/metavoxels/src/MetavoxelClientManager.h index 333b709b9e..22c71bd63b 100644 --- a/libraries/metavoxels/src/MetavoxelClientManager.h +++ b/libraries/metavoxels/src/MetavoxelClientManager.h @@ -43,6 +43,8 @@ public: Q_INVOKABLE void applyEdit(const MetavoxelEditMessage& edit, bool reliable = false); + Q_INVOKABLE float getHeight(const glm::vec3& location); + /// Returns the current LOD. This must be thread-safe, as it will be called from the updater thread. virtual MetavoxelLOD getLOD(); From acb973d245475d00f29970ee23685563bc0f7019 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 6 Aug 2014 19:41:25 -0700 Subject: [PATCH 06/94] Working on ray intersection testing. --- interface/src/ui/MetavoxelEditor.cpp | 2 +- .../metavoxels/src/MetavoxelClientManager.cpp | 91 +++++++++++++++++-- .../metavoxels/src/MetavoxelClientManager.h | 4 +- 3 files changed, 88 insertions(+), 9 deletions(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 32ffedf0c8..a2bb1770b2 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1103,7 +1103,7 @@ void HeightfieldBrushTool::render() { float distance = -origin.y / direction.y; glm::vec3 point = origin + distance * direction; - point.y = Application::getInstance()->getMetavoxels()->getHeight(point); + point.y = Application::getInstance()->getMetavoxels()->getHeightfieldHeight(point); glPushMatrix(); glTranslatef(point.x, point.y, point.z); diff --git a/libraries/metavoxels/src/MetavoxelClientManager.cpp b/libraries/metavoxels/src/MetavoxelClientManager.cpp index d86ad86df4..51eb4c653c 100644 --- a/libraries/metavoxels/src/MetavoxelClientManager.cpp +++ b/libraries/metavoxels/src/MetavoxelClientManager.cpp @@ -61,6 +61,84 @@ SharedObjectPointer MetavoxelClientManager::findFirstRaySpannerIntersection(cons return closestSpanner; } +class RayHeightfieldIntersectionVisitor : public RayIntersectionVisitor { +public: + + RayHeightfieldIntersectionVisitor(const glm::vec3& origin, const glm::vec3& direction, const MetavoxelLOD& lod); + + virtual int visit(MetavoxelInfo& info, float distance); +}; + +RayHeightfieldIntersectionVisitor::RayHeightfieldIntersectionVisitor(const glm::vec3& origin, + const glm::vec3& direction, const MetavoxelLOD& lod) : + RayIntersectionVisitor(origin, direction, QVector() << + AttributeRegistry::getInstance()->getHeightfieldAttribute(), QVector(), lod) { +} + +static const float EIGHT_BIT_MAXIMUM_RECIPROCAL = 1.0f / 255.0f; + +int RayHeightfieldIntersectionVisitor::visit(MetavoxelInfo& info, float distance) { + if (!info.isLeaf) { + return _order; + } + HeightfieldDataPointer pointer = info.inputValues.at(0).getInlineValue(); + if (!pointer) { + return STOP_RECURSION; + } + const QByteArray& contents = pointer->getContents(); + const uchar* src = (const uchar*)contents.constData(); + int size = glm::sqrt((float)contents.size()); + int highest = size - 1; + float heightScale = highest / EIGHT_BIT_MAXIMUM_RECIPROCAL; + + // find the initial location + glm::vec3 location = (_origin + distance * _direction - info.minimum) * (float)highest / info.size; + + glm::vec3 floors = glm::floor(location); + glm::vec3 ceils = glm::ceil(location); + int floorX = qMin(qMax((int)floors.x, 0), highest); + int floorZ = qMin(qMax((int)floors.z, 0), highest); + int ceilX = qMin(qMax((int)ceils.x, 0), highest); + int ceilZ = qMin(qMax((int)ceils.z, 0), highest); + float upperLeft = src[floorZ * size + floorX] * heightScale; + float upperRight = src[floorZ * size + ceilX] * heightScale; + float lowerLeft = src[ceilZ * size + floorX] * heightScale; + float lowerRight = src[ceilZ * size + ceilX] * heightScale; + + glm::vec3 relativeLocation = location - glm::vec3(floors.x, upperLeft, floors.z); + + glm::vec3 lowerNormal(lowerLeft - lowerRight, 1.0f, upperLeft - lowerLeft); + float lowerProduct = glm::dot(lowerNormal, _direction); + if (lowerProduct < EPSILON) { + float distance = -glm::dot(lowerNormal, relativeLocation) / lowerProduct; + glm::vec3 intersection = relativeLocation + distance * _direction; + if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && + intersection.z >= intersection.x) { + return SHORT_CIRCUIT; + } + } + + glm::vec3 upperNormal(upperLeft - upperRight, 1.0f, upperRight - lowerRight); + float upperProduct = glm::dot(upperNormal, _direction); + if (upperProduct < EPSILON) { + float distance = -glm::dot(upperNormal, relativeLocation) / upperProduct; + glm::vec3 intersection = relativeLocation + distance * _direction; + if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && + intersection.x >= intersection.z) { + return SHORT_CIRCUIT; + } + } + + return STOP_RECURSION; +} + +bool MetavoxelClientManager::findFirstRayHeightfieldIntersection(const glm::vec3& origin, + const glm::vec3& direction, float& distance) { + RayHeightfieldIntersectionVisitor visitor(origin, direction, getLOD()); + guide(visitor); + return false; +} + void MetavoxelClientManager::setSphere(const glm::vec3& center, float radius, const QColor& color) { Sphere* sphere = new Sphere(); sphere->setTranslation(center); @@ -78,12 +156,12 @@ void MetavoxelClientManager::applyEdit(const MetavoxelEditMessage& edit, bool re QMetaObject::invokeMethod(_updater, "applyEdit", Q_ARG(const MetavoxelEditMessage&, edit), Q_ARG(bool, reliable)); } -class HeightVisitor : public MetavoxelVisitor { +class HeightfieldHeightVisitor : public MetavoxelVisitor { public: float height; - HeightVisitor(const MetavoxelLOD& lod, const glm::vec3& location); + HeightfieldHeightVisitor(const MetavoxelLOD& lod, const glm::vec3& location); virtual int visit(MetavoxelInfo& info); @@ -92,7 +170,7 @@ private: glm::vec3 _location; }; -HeightVisitor::HeightVisitor(const MetavoxelLOD& lod, const glm::vec3& location) : +HeightfieldHeightVisitor::HeightfieldHeightVisitor(const MetavoxelLOD& lod, const glm::vec3& location) : MetavoxelVisitor(QVector() << AttributeRegistry::getInstance()->getHeightfieldAttribute(), QVector(), lod), height(-FLT_MAX), @@ -100,9 +178,8 @@ HeightVisitor::HeightVisitor(const MetavoxelLOD& lod, const glm::vec3& location) } static const int REVERSE_ORDER = MetavoxelVisitor::encodeOrder(7, 6, 5, 4, 3, 2, 1, 0); -static const float EIGHT_BIT_MAXIMUM_RECIPROCAL = 1.0f / 255.0f; -int HeightVisitor::visit(MetavoxelInfo& info) { +int HeightfieldHeightVisitor::visit(MetavoxelInfo& info) { glm::vec3 relative = _location - info.minimum; if (relative.x < 0.0f || relative.z < 0.0f || relative.x > info.size || relative.z > info.size || height >= info.minimum.y + info.size) { @@ -145,8 +222,8 @@ int HeightVisitor::visit(MetavoxelInfo& info) { return SHORT_CIRCUIT; } -float MetavoxelClientManager::getHeight(const glm::vec3& location) { - HeightVisitor visitor(getLOD(), location); +float MetavoxelClientManager::getHeightfieldHeight(const glm::vec3& location) { + HeightfieldHeightVisitor visitor(getLOD(), location); guide(visitor); return visitor.height; } diff --git a/libraries/metavoxels/src/MetavoxelClientManager.h b/libraries/metavoxels/src/MetavoxelClientManager.h index 22c71bd63b..8fc9bcd38d 100644 --- a/libraries/metavoxels/src/MetavoxelClientManager.h +++ b/libraries/metavoxels/src/MetavoxelClientManager.h @@ -37,13 +37,15 @@ public: SharedObjectPointer findFirstRaySpannerIntersection(const glm::vec3& origin, const glm::vec3& direction, const AttributePointer& attribute, float& distance); + bool findFirstRayHeightfieldIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance); + Q_INVOKABLE void setSphere(const glm::vec3& center, float radius, const QColor& color = QColor(Qt::gray)); Q_INVOKABLE void setSpanner(const SharedObjectPointer& object, bool reliable = false); Q_INVOKABLE void applyEdit(const MetavoxelEditMessage& edit, bool reliable = false); - Q_INVOKABLE float getHeight(const glm::vec3& location); + Q_INVOKABLE float getHeightfieldHeight(const glm::vec3& location); /// Returns the current LOD. This must be thread-safe, as it will be called from the updater thread. virtual MetavoxelLOD getLOD(); From 6191db3a7f590ae6ee8d95ba4a1ae866a6e694e3 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Thu, 7 Aug 2014 09:59:07 -0600 Subject: [PATCH 07/94] Fixing bug with visage find_library --- cmake/modules/FindVisage.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index b461926604..070905d6ff 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -30,7 +30,7 @@ if (APPLE) find_library(VISAGE_CORE_LIBRARY NAME vscore PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) - find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib ${VISAGE_SEARCH_DIRS}) + find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib HINTS ${VISAGE_SEARCH_DIRS}) elseif (WIN32) find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS}) From 27b876e84cc40342e7b982ee33b3fead0c03ca19 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 7 Aug 2014 09:02:31 -0700 Subject: [PATCH 08/94] namechange _frame --> _frameCount --- libraries/shared/src/PhysicsSimulation.cpp | 10 +++++----- libraries/shared/src/PhysicsSimulation.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/shared/src/PhysicsSimulation.cpp b/libraries/shared/src/PhysicsSimulation.cpp index 5fd40543e7..8fed575889 100644 --- a/libraries/shared/src/PhysicsSimulation.cpp +++ b/libraries/shared/src/PhysicsSimulation.cpp @@ -24,7 +24,7 @@ int MAX_ENTITIES_PER_SIMULATION = 64; int MAX_COLLISIONS_PER_SIMULATION = 256; -PhysicsSimulation::PhysicsSimulation() : _frame(0), _entity(NULL), _ragdoll(NULL), _collisions(MAX_COLLISIONS_PER_SIMULATION) { +PhysicsSimulation::PhysicsSimulation() : _frameCount(0), _entity(NULL), _ragdoll(NULL), _collisions(MAX_COLLISIONS_PER_SIMULATION) { } PhysicsSimulation::~PhysicsSimulation() { @@ -157,7 +157,7 @@ void PhysicsSimulation::removeRagdoll(Ragdoll* doll) { } void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) { - ++_frame; + ++_frameCount; if (!_ragdoll) { return; } @@ -288,9 +288,9 @@ void PhysicsSimulation::updateContacts() { } QMap::iterator itr = _contacts.find(key); if (itr == _contacts.end()) { - _contacts.insert(key, ContactPoint(*collision, _frame)); + _contacts.insert(key, ContactPoint(*collision, _frameCount)); } else { - itr.value().updateContact(*collision, _frame); + itr.value().updateContact(*collision, _frameCount); } } } @@ -300,7 +300,7 @@ const quint32 MAX_CONTACT_FRAME_LIFETIME = 2; void PhysicsSimulation::pruneContacts() { QMap::iterator itr = _contacts.begin(); while (itr != _contacts.end()) { - if (_frame - itr.value().getLastFrame() > MAX_CONTACT_FRAME_LIFETIME) { + if (_frameCount - itr.value().getLastFrame() > MAX_CONTACT_FRAME_LIFETIME) { itr = _contacts.erase(itr); } else { ++itr; diff --git a/libraries/shared/src/PhysicsSimulation.h b/libraries/shared/src/PhysicsSimulation.h index c8f41bb656..613440e71c 100644 --- a/libraries/shared/src/PhysicsSimulation.h +++ b/libraries/shared/src/PhysicsSimulation.h @@ -59,7 +59,7 @@ protected: void pruneContacts(); private: - quint32 _frame; + quint32 _frameCount; PhysicsEntity* _entity; Ragdoll* _ragdoll; From db1d6c8b49885113e9fe0ff394fae2e5fc0d2ed4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 7 Aug 2014 09:23:05 -0700 Subject: [PATCH 09/94] MyAvatar's ragdoll is the main simulation ragdoll --- interface/src/avatar/MyAvatar.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 41eba45ac4..de85f1fe63 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -84,13 +84,13 @@ MyAvatar::MyAvatar() : } _skeletonModel.setEnableShapes(true); // The skeleton is both a PhysicsEntity and Ragdoll, so we add it to the simulation once for each type. - _physicsSimulation.addEntity(&_skeletonModel); + _physicsSimulation.setEntity(&_skeletonModel); _physicsSimulation.setRagdoll(&_skeletonModel); } MyAvatar::~MyAvatar() { _physicsSimulation.setRagdoll(NULL); - _physicsSimulation.removeEntity(&_skeletonModel); + _physicsSimulation.setEntity(NULL); _lookAtTargetAvatar.clear(); } @@ -1520,8 +1520,6 @@ bool findAvatarAvatarPenetration(const glm::vec3 positionA, float radiusA, float return false; } -const float BODY_COLLISION_RESOLUTION_TIMESCALE = 0.5f; // seconds - void MyAvatar::updateCollisionWithAvatars(float deltaTime) { // Reset detector for nearest avatar _distanceToNearestAvatar = std::numeric_limits::max(); From 87350ad2d0e03213e6d8da964ee5cdd7e85707a1 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 7 Aug 2014 11:45:06 -0700 Subject: [PATCH 10/94] ragdoll simulation now in model-relative frame (same rotation as world-frame, but translated to MyAvatar origin) --- interface/src/avatar/SkeletonModel.cpp | 85 +++++++++++++++++++--- interface/src/avatar/SkeletonModel.h | 1 + interface/src/renderer/Model.cpp | 50 +------------ interface/src/renderer/Model.h | 2 +- libraries/shared/src/FixedConstraint.cpp | 21 +++--- libraries/shared/src/FixedConstraint.h | 10 ++- libraries/shared/src/PhysicsSimulation.cpp | 5 +- libraries/shared/src/PhysicsSimulation.h | 5 ++ libraries/shared/src/Ragdoll.cpp | 67 +++++++++++++++-- libraries/shared/src/Ragdoll.h | 29 +++++++- libraries/shared/src/VerletPoint.cpp | 7 ++ libraries/shared/src/VerletPoint.h | 3 + 12 files changed, 199 insertions(+), 86 deletions(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index c8e7451fc1..463ed28faf 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -490,11 +490,13 @@ void SkeletonModel::renderRagdoll() { float alpha = 0.3f; float radius1 = 0.008f; float radius2 = 0.01f; + glm::vec3 simulationTranslation = getTranslationInSimulationFrame(); for (int i = 0; i < numPoints; ++i) { glPushMatrix(); - // draw each point as a yellow hexagon with black border - glm::vec3 position = _rotation * _ragdollPoints[i]._position; + // NOTE: ragdollPoints are in simulation-frame but we want them to be model-relative + glm::vec3 position = _ragdollPoints[i]._position - simulationTranslation; glTranslatef(position.x, position.y, position.z); + // draw each point as a yellow hexagon with black border glColor4f(0.0f, 0.0f, 0.0f, alpha); glutSolidSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); glColor4f(1.0f, 1.0f, 0.0f, alpha); @@ -511,13 +513,14 @@ void SkeletonModel::initRagdollPoints() { clearRagdollConstraintsAndPoints(); _muscleConstraints.clear(); + initRagdollTransform(); // one point for each joint int numJoints = _jointStates.size(); _ragdollPoints.fill(VerletPoint(), numJoints); for (int i = 0; i < numJoints; ++i) { const JointState& state = _jointStates.at(i); - glm::vec3 position = state.getPosition(); - _ragdollPoints[i].initPosition(position); + // _ragdollPoints start in model-frame + _ragdollPoints[i].initPosition(state.getPosition()); } } @@ -534,12 +537,12 @@ void SkeletonModel::buildRagdollConstraints() { const JointState& state = _jointStates.at(i); int parentIndex = state.getParentIndex(); if (parentIndex == -1) { - FixedConstraint* anchor = new FixedConstraint(&(_ragdollPoints[i]), glm::vec3(0.0f)); - _ragdollConstraints.push_back(anchor); + FixedConstraint* anchor = new FixedConstraint(&_translationInSimulationFrame, &(_ragdollPoints[i])); + _fixedConstraints.push_back(anchor); } else { DistanceConstraint* bone = new DistanceConstraint(&(_ragdollPoints[i]), &(_ragdollPoints[parentIndex])); bone->setDistance(state.getDistanceToParent()); - _ragdollConstraints.push_back(bone); + _boneConstraints.push_back(bone); families.insert(parentIndex, i); } float boneLength = glm::length(state.getPositionInParentFrame()); @@ -558,11 +561,11 @@ void SkeletonModel::buildRagdollConstraints() { if (numChildren > 1) { for (int i = 1; i < numChildren; ++i) { DistanceConstraint* bone = new DistanceConstraint(&(_ragdollPoints[children[i-1]]), &(_ragdollPoints[children[i]])); - _ragdollConstraints.push_back(bone); + _boneConstraints.push_back(bone); } if (numChildren > 2) { DistanceConstraint* bone = new DistanceConstraint(&(_ragdollPoints[children[numChildren-1]]), &(_ragdollPoints[children[0]])); - _ragdollConstraints.push_back(bone); + _boneConstraints.push_back(bone); } } ++itr; @@ -604,6 +607,7 @@ void SkeletonModel::updateVisibleJointStates() { } QVector points; points.reserve(_jointStates.size()); + glm::quat invRotation = glm::inverse(_rotation); for (int i = 0; i < _jointStates.size(); i++) { JointState& state = _jointStates[i]; points.push_back(_ragdollPoints[i]._position); @@ -628,8 +632,9 @@ void SkeletonModel::updateVisibleJointStates() { // we're looking for the rotation that moves visible bone parallel to ragdoll bone // rotationBetween(jointTip - jointPivot, shapeTip - shapePivot) + // NOTE: points are in simulation-frame so rotate line segment into model-frame glm::quat delta = rotationBetween(state.getVisiblePosition() - extractTranslation(parentTransform), - points[i] - points[parentIndex]); + invRotation * (points[i] - points[parentIndex])); // apply parentState.mixVisibleRotationDelta(delta, 0.01f); @@ -641,6 +646,7 @@ void SkeletonModel::updateVisibleJointStates() { // virtual void SkeletonModel::stepRagdollForward(float deltaTime) { + setRagdollTransform(_translation, _rotation); Ragdoll::stepRagdollForward(deltaTime); updateMuscles(); int numConstraints = _muscleConstraints.size(); @@ -714,6 +720,7 @@ void SkeletonModel::buildShapes() { if (_ragdollPoints.size() == numStates) { int numJoints = _jointStates.size(); for (int i = 0; i < numJoints; ++i) { + // ragdollPoints start in model-frame _ragdollPoints[i].initPosition(_jointStates.at(i).getPosition()); } } @@ -735,9 +742,11 @@ void SkeletonModel::moveShapesTowardJoints(float deltaTime) { float fraction = glm::clamp(deltaTime / RAGDOLL_FOLLOWS_JOINTS_TIMESCALE, 0.0f, 1.0f); float oneMinusFraction = 1.0f - fraction; + glm::vec3 simulationTranslation = getTranslationInSimulationFrame(); for (int i = 0; i < numStates; ++i) { + // ragdollPoints are in simulation-frame but jointStates are in model-frame _ragdollPoints[i].initPosition(oneMinusFraction * _ragdollPoints[i]._position + - fraction * _jointStates.at(i).getPosition()); + fraction * (simulationTranslation + _rotation * (_jointStates.at(i).getPosition()))); } } @@ -748,7 +757,8 @@ void SkeletonModel::updateMuscles() { int j = constraint->getParentIndex(); int k = constraint->getChildIndex(); assert(j != -1 && k != -1); - constraint->setChildOffset(_jointStates.at(k).getPosition() - _jointStates.at(j).getPosition()); + // ragdollPoints are in simulation-frame but jointStates are in model-frame + constraint->setChildOffset(_rotation * (_jointStates.at(k).getPosition() - _jointStates.at(j).getPosition())); } } @@ -891,3 +901,54 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) { glPopMatrix(); } +const int BALL_SUBDIVISIONS = 10; + +// virtual +void SkeletonModel::renderJointCollisionShapes(float alpha) { + glPushMatrix(); + Application::getInstance()->loadTranslatedViewMatrix(_translation); + glm::vec3 simulationTranslation = getTranslationInSimulationFrame(); + for (int i = 0; i < _shapes.size(); i++) { + Shape* shape = _shapes[i]; + if (!shape) { + continue; + } + + glPushMatrix(); + // shapes are stored in simulation-frame but we want position to be model-relative + if (shape->getType() == Shape::SPHERE_SHAPE) { + glm::vec3 position = shape->getTranslation() - simulationTranslation; + glTranslatef(position.x, position.y, position.z); + // draw a grey sphere at shape position + glColor4f(0.75f, 0.75f, 0.75f, alpha); + glutSolidSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); + } else if (shape->getType() == Shape::CAPSULE_SHAPE) { + CapsuleShape* capsule = static_cast(shape); + + // draw a blue sphere at the capsule endpoint + glm::vec3 endPoint; + capsule->getEndPoint(endPoint); + endPoint = endPoint - simulationTranslation; + glTranslatef(endPoint.x, endPoint.y, endPoint.z); + glColor4f(0.6f, 0.6f, 0.8f, alpha); + glutSolidSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); + + // draw a yellow sphere at the capsule startpoint + glm::vec3 startPoint; + capsule->getStartPoint(startPoint); + startPoint = startPoint - simulationTranslation; + glm::vec3 axis = endPoint - startPoint; + glTranslatef(-axis.x, -axis.y, -axis.z); + glColor4f(0.8f, 0.8f, 0.6f, alpha); + glutSolidSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); + + // draw a green cylinder between the two points + glm::vec3 origin(0.0f); + glColor4f(0.6f, 0.8f, 0.6f, alpha); + Avatar::renderJointConnectingCone( origin, axis, capsule->getRadius(), capsule->getRadius()); + } + glPopMatrix(); + } + glPopMatrix(); +} + diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index 5cb89f5e44..55fedbcb6b 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -105,6 +105,7 @@ public: void computeBoundingShape(const FBXGeometry& geometry); void renderBoundingCollisionShapes(float alpha); + void renderJointCollisionShapes(float alpha); float getBoundingShapeRadius() const { return _boundingShape.getRadius(); } const CapsuleShape& getBoundingShape() const { return _boundingShape; } diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 63a94772a7..025971db4b 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -1243,55 +1243,7 @@ float Model::getLimbLength(int jointIndex) const { const int BALL_SUBDIVISIONS = 10; void Model::renderJointCollisionShapes(float alpha) { - glPushMatrix(); - Application::getInstance()->loadTranslatedViewMatrix(_translation); - for (int i = 0; i < _shapes.size(); i++) { - Shape* shape = _shapes[i]; - if (!shape) { - continue; - } - - glPushMatrix(); - // NOTE: the shapes are in the avatar local-frame - if (shape->getType() == Shape::SPHERE_SHAPE) { - // shapes are stored in world-frame, so we have to transform into model frame - glm::vec3 position = _rotation * shape->getTranslation(); - glTranslatef(position.x, position.y, position.z); - const glm::quat& rotation = shape->getRotation(); - glm::vec3 axis = glm::axis(rotation); - glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); - - // draw a grey sphere at shape position - glColor4f(0.75f, 0.75f, 0.75f, alpha); - glutSolidSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); - } else if (shape->getType() == Shape::CAPSULE_SHAPE) { - CapsuleShape* capsule = static_cast(shape); - - // draw a blue sphere at the capsule endpoint - glm::vec3 endPoint; - capsule->getEndPoint(endPoint); - endPoint = _rotation * endPoint; - glTranslatef(endPoint.x, endPoint.y, endPoint.z); - glColor4f(0.6f, 0.6f, 0.8f, alpha); - glutSolidSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); - - // draw a yellow sphere at the capsule startpoint - glm::vec3 startPoint; - capsule->getStartPoint(startPoint); - startPoint = _rotation * startPoint; - glm::vec3 axis = endPoint - startPoint; - glTranslatef(-axis.x, -axis.y, -axis.z); - glColor4f(0.8f, 0.8f, 0.6f, alpha); - glutSolidSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS); - - // draw a green cylinder between the two points - glm::vec3 origin(0.0f); - glColor4f(0.6f, 0.8f, 0.6f, alpha); - Avatar::renderJointConnectingCone( origin, axis, capsule->getRadius(), capsule->getRadius()); - } - glPopMatrix(); - } - glPopMatrix(); + // implement this when we have shapes for regular models } void Model::setBlendedVertices(const QVector& vertices, const QVector& normals) { diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index cbed941791..7a29b61420 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -149,7 +149,7 @@ public: virtual void buildShapes(); virtual void updateShapePositions(); - void renderJointCollisionShapes(float alpha); + virtual void renderJointCollisionShapes(float alpha); /// Sets blended vertices computed in a separate thread. void setBlendedVertices(const QVector& vertices, const QVector& normals); diff --git a/libraries/shared/src/FixedConstraint.cpp b/libraries/shared/src/FixedConstraint.cpp index 099c6d7bac..539978db5d 100644 --- a/libraries/shared/src/FixedConstraint.cpp +++ b/libraries/shared/src/FixedConstraint.cpp @@ -13,15 +13,22 @@ #include "Shape.h" // for MAX_SHAPE_MASS #include "VerletPoint.h" -FixedConstraint::FixedConstraint(VerletPoint* point, const glm::vec3& anchor) : _point(point), _anchor(anchor) { +FixedConstraint::FixedConstraint(glm::vec3* anchor, VerletPoint* point) : _anchor(anchor), _point(point) { + assert(anchor); + assert(point); + _point->_mass = MAX_SHAPE_MASS; } float FixedConstraint::enforce() { assert(_point != NULL); - // TODO: use fast approximate sqrt here - float distance = glm::distance(_anchor, _point->_position); - _point->_position = _anchor; - return distance; + _point->_position = *_anchor; + _point->_lastPosition = *_anchor; + return 0.0f; +} + +void FixedConstraint::setAnchor(glm::vec3* anchor) { + assert(anchor); + _anchor = anchor; } void FixedConstraint::setPoint(VerletPoint* point) { @@ -29,7 +36,3 @@ void FixedConstraint::setPoint(VerletPoint* point) { _point = point; _point->_mass = MAX_SHAPE_MASS; } - -void FixedConstraint::setAnchor(const glm::vec3& anchor) { - _anchor = anchor; -} diff --git a/libraries/shared/src/FixedConstraint.h b/libraries/shared/src/FixedConstraint.h index 050232a027..66a27369ce 100644 --- a/libraries/shared/src/FixedConstraint.h +++ b/libraries/shared/src/FixedConstraint.h @@ -18,15 +18,19 @@ class VerletPoint; +// FixedConstraint takes pointers to a glm::vec3 and a VerletPoint. +// The enforcement will copy the value of the vec3 into the VerletPoint. + class FixedConstraint : public Constraint { public: - FixedConstraint(VerletPoint* point, const glm::vec3& anchor); + FixedConstraint(glm::vec3* anchor, VerletPoint* point); + ~FixedConstraint() {} float enforce(); + void setAnchor(glm::vec3* anchor); void setPoint(VerletPoint* point); - void setAnchor(const glm::vec3& anchor); private: + glm::vec3* _anchor; VerletPoint* _point; - glm::vec3 _anchor; }; #endif // hifi_FixedConstraint_h diff --git a/libraries/shared/src/PhysicsSimulation.cpp b/libraries/shared/src/PhysicsSimulation.cpp index 8fed575889..8ae30ce699 100644 --- a/libraries/shared/src/PhysicsSimulation.cpp +++ b/libraries/shared/src/PhysicsSimulation.cpp @@ -24,7 +24,8 @@ int MAX_ENTITIES_PER_SIMULATION = 64; int MAX_COLLISIONS_PER_SIMULATION = 256; -PhysicsSimulation::PhysicsSimulation() : _frameCount(0), _entity(NULL), _ragdoll(NULL), _collisions(MAX_COLLISIONS_PER_SIMULATION) { +PhysicsSimulation::PhysicsSimulation() : _translation(0.0f), _frameCount(0), _entity(NULL), _ragdoll(NULL), + _collisions(MAX_COLLISIONS_PER_SIMULATION) { } PhysicsSimulation::~PhysicsSimulation() { @@ -204,7 +205,7 @@ void PhysicsSimulation::moveRagdolls(float deltaTime) { _ragdoll->stepRagdollForward(deltaTime); int numDolls = _otherRagdolls.size(); for (int i = 0; i < numDolls; ++i) { - _otherRagdolls.at(i)->stepRagdollForward(deltaTime); + _otherRagdolls[i]->stepRagdollForward(deltaTime); } } diff --git a/libraries/shared/src/PhysicsSimulation.h b/libraries/shared/src/PhysicsSimulation.h index 613440e71c..be1f2fb366 100644 --- a/libraries/shared/src/PhysicsSimulation.h +++ b/libraries/shared/src/PhysicsSimulation.h @@ -28,6 +28,9 @@ public: PhysicsSimulation(); ~PhysicsSimulation(); + void setTranslation(const glm::vec3& translation) { _translation = translation; } + const glm::vec3& getTranslation() const { return _translation; } + void setRagdoll(Ragdoll* ragdoll) { _ragdoll = ragdoll; } void setEntity(PhysicsEntity* entity); @@ -59,6 +62,8 @@ protected: void pruneContacts(); private: + glm::vec3 _translation; // origin of simulation in world-frame + quint32 _frameCount; PhysicsEntity* _entity; diff --git a/libraries/shared/src/Ragdoll.cpp b/libraries/shared/src/Ragdoll.cpp index 6282db4dfb..5b21687bbd 100644 --- a/libraries/shared/src/Ragdoll.cpp +++ b/libraries/shared/src/Ragdoll.cpp @@ -9,13 +9,17 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include + #include "Ragdoll.h" #include "Constraint.h" #include "DistanceConstraint.h" #include "FixedConstraint.h" +#include "PhysicsSimulation.h" +#include "SharedUtil.h" // for EPSILON -Ragdoll::Ragdoll() { +Ragdoll::Ragdoll() : _ragdollTranslation(0.0f), _translationInSimulationFrame(0.0f), _ragdollSimulation(NULL) { } Ragdoll::~Ragdoll() { @@ -23,6 +27,9 @@ Ragdoll::~Ragdoll() { } void Ragdoll::stepRagdollForward(float deltaTime) { + if (_ragdollSimulation) { + updateSimulationTransforms(_ragdollTranslation - _ragdollSimulation->getTranslation(), _ragdollRotation); + } int numPoints = _ragdollPoints.size(); for (int i = 0; i < numPoints; ++i) { _ragdollPoints[i].integrateForward(); @@ -30,21 +37,65 @@ void Ragdoll::stepRagdollForward(float deltaTime) { } void Ragdoll::clearRagdollConstraintsAndPoints() { - int numConstraints = _ragdollConstraints.size(); + int numConstraints = _boneConstraints.size(); for (int i = 0; i < numConstraints; ++i) { - delete _ragdollConstraints[i]; + delete _boneConstraints[i]; } - _ragdollConstraints.clear(); + _boneConstraints.clear(); + numConstraints = _fixedConstraints.size(); + for (int i = 0; i < numConstraints; ++i) { + delete _fixedConstraints[i]; + } + _fixedConstraints.clear(); _ragdollPoints.clear(); } float Ragdoll::enforceRagdollConstraints() { float maxDistance = 0.0f; - const int numConstraints = _ragdollConstraints.size(); + // enforce the bone constraints first + int numConstraints = _boneConstraints.size(); for (int i = 0; i < numConstraints; ++i) { - DistanceConstraint* c = static_cast(_ragdollConstraints[i]); - //maxDistance = glm::max(maxDistance, _ragdollConstraints[i]->enforce()); - maxDistance = glm::max(maxDistance, c->enforce()); + maxDistance = glm::max(maxDistance, _boneConstraints[i]->enforce()); + } + // enforce FixedConstraints second + numConstraints = _fixedConstraints.size(); + for (int i = 0; i < _fixedConstraints.size(); ++i) { + maxDistance = glm::max(maxDistance, _fixedConstraints[i]->enforce()); } return maxDistance; } + +void Ragdoll::initRagdollTransform() { + _ragdollTranslation = glm::vec3(0.0f); + _ragdollRotation = glm::quat(); + _translationInSimulationFrame = glm::vec3(0.0f); + _rotationInSimulationFrame = glm::quat(); +} + +void Ragdoll::setRagdollTransform(const glm::vec3& translation, const glm::quat& rotation) { + _ragdollTranslation = translation; + _ragdollRotation = rotation; +} + +void Ragdoll::updateSimulationTransforms(const glm::vec3& translation, const glm::quat& rotation) { + const float EPSILON2 = EPSILON * EPSILON; + if (glm::distance2(translation, _translationInSimulationFrame) < EPSILON2 && + glm::abs(1.0f - glm::abs(glm::dot(rotation, _rotationInSimulationFrame))) < EPSILON2) { + // nothing to do + return; + } + + // compute linear and angular deltas + glm::vec3 deltaPosition = translation - _translationInSimulationFrame; + glm::quat deltaRotation = rotation * glm::inverse(_rotationInSimulationFrame); + + // apply the deltas to all ragdollPoints + int numPoints = _ragdollPoints.size(); + for (int i = 0; i < numPoints; ++i) { + _ragdollPoints[i].move(deltaPosition, deltaRotation, _translationInSimulationFrame); + } + + // remember the current transform + _translationInSimulationFrame = translation; + _rotationInSimulationFrame = rotation; +} diff --git a/libraries/shared/src/Ragdoll.h b/libraries/shared/src/Ragdoll.h index 91a7e7330e..421e8e3ff8 100644 --- a/libraries/shared/src/Ragdoll.h +++ b/libraries/shared/src/Ragdoll.h @@ -18,7 +18,14 @@ #include -class Constraint; +//#include "PhysicsSimulation.h" + +class DistanceConstraint; +class FixedConstraint; +class PhysicsSimulation; + +// TODO: don't derive SkeletonModel from Ragdoll so we can clean up the Ragdoll API +// (==> won't need to worry about namespace conflicts between Entity and Ragdoll). class Ragdoll { public: @@ -35,13 +42,31 @@ public: const QVector& getRagdollPoints() const { return _ragdollPoints; } QVector& getRagdollPoints() { return _ragdollPoints; } + void initRagdollTransform(); + + /// set the translation and rotation of the Ragdoll and adjust all VerletPoints. + void setRagdollTransform(const glm::vec3& translation, const glm::quat& rotation); + + const glm::vec3& getTranslationInSimulationFrame() const { return _translationInSimulationFrame; } + protected: void clearRagdollConstraintsAndPoints(); virtual void initRagdollPoints() = 0; virtual void buildRagdollConstraints() = 0; + glm::vec3 _ragdollTranslation; // world-frame + glm::quat _ragdollRotation; // world-frame + glm::vec3 _translationInSimulationFrame; + glm::quat _rotationInSimulationFrame; + QVector _ragdollPoints; - QVector _ragdollConstraints; + QVector _boneConstraints; + QVector _fixedConstraints; +private: + void updateSimulationTransforms(const glm::vec3& translation, const glm::quat& rotation); + + friend class PhysicsSimulation; + PhysicsSimulation* _ragdollSimulation; }; #endif // hifi_Ragdoll_h diff --git a/libraries/shared/src/VerletPoint.cpp b/libraries/shared/src/VerletPoint.cpp index 654a74d7ac..dae861a7ab 100644 --- a/libraries/shared/src/VerletPoint.cpp +++ b/libraries/shared/src/VerletPoint.cpp @@ -31,3 +31,10 @@ void VerletPoint::applyAccumulatedDelta() { _numDeltas = 0; } } + +void VerletPoint::move(const glm::vec3& deltaPosition, const glm::quat& deltaRotation, const glm::vec3& oldPivot) { + glm::vec3 arm = _position - oldPivot; + _position += deltaPosition + (deltaRotation * arm - arm); + arm = _lastPosition - oldPivot; + _lastPosition += deltaPosition + (deltaRotation * arm - arm); +} diff --git a/libraries/shared/src/VerletPoint.h b/libraries/shared/src/VerletPoint.h index f59afb16c5..a1dca3e955 100644 --- a/libraries/shared/src/VerletPoint.h +++ b/libraries/shared/src/VerletPoint.h @@ -13,6 +13,8 @@ #define hifi_VerletPoint_h #include +#include + class VerletPoint { public: @@ -22,6 +24,7 @@ public: void integrateForward(); void accumulateDelta(const glm::vec3& delta); void applyAccumulatedDelta(); + void move(const glm::vec3& deltaPosition, const glm::quat& deltaRotation, const glm::vec3& oldPivot); glm::vec3 _position; glm::vec3 _lastPosition; From 0f784a9cc514ec38887e7d25a48c0a1b35be31be Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 7 Aug 2014 13:09:05 -0700 Subject: [PATCH 11/94] add other ragdolls to simulation --- interface/src/avatar/MyAvatar.cpp | 5 +--- libraries/shared/src/PhysicsSimulation.cpp | 30 +++++++++++++++++++--- libraries/shared/src/PhysicsSimulation.h | 2 +- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index de85f1fe63..33c053464c 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -204,6 +204,7 @@ void MyAvatar::simulate(float deltaTime) { const int minError = 0.01f; const float maxIterations = 10; const quint64 maxUsec = 2000; + _physicsSimulation.setTranslation(_position); _physicsSimulation.stepForward(deltaTime, minError, maxIterations, maxUsec); } else { _skeletonModel.moveShapesTowardJoints(1.0f); @@ -230,12 +231,10 @@ void MyAvatar::simulate(float deltaTime) { } else { _trapDuration = 0.0f; } - /* TODO: Andrew to make this work if (_collisionGroups & COLLISION_GROUP_AVATARS) { PerformanceTimer perfTimer("avatars"); updateCollisionWithAvatars(deltaTime); } - */ } // consider updating our billboard @@ -1566,13 +1565,11 @@ void MyAvatar::updateCollisionWithAvatars(float deltaTime) { PhysicsSimulation* simulation = skeleton->getSimulation(); if (avatar == nearestAvatar) { if (simulation != &(_physicsSimulation)) { - std::cout << "adebug adding other avatar " << avatar << " to simulation" << std::endl; // adebug skeleton->setEnableShapes(true); _physicsSimulation.addEntity(skeleton); _physicsSimulation.addRagdoll(skeleton); } } else if (simulation == &(_physicsSimulation)) { - std::cout << "adebug removing other avatar " << avatar << " from simulation" << std::endl; // adebug _physicsSimulation.removeRagdoll(skeleton); _physicsSimulation.removeEntity(skeleton); skeleton->setEnableShapes(false); diff --git a/libraries/shared/src/PhysicsSimulation.cpp b/libraries/shared/src/PhysicsSimulation.cpp index 8ae30ce699..1007998b56 100644 --- a/libraries/shared/src/PhysicsSimulation.cpp +++ b/libraries/shared/src/PhysicsSimulation.cpp @@ -44,6 +44,19 @@ PhysicsSimulation::~PhysicsSimulation() { _otherRagdolls.clear(); } +void PhysicsSimulation::setRagdoll(Ragdoll* ragdoll) { + if (_ragdoll != ragdoll) { + if (_ragdoll) { + _ragdoll->_ragdollSimulation = NULL; + } + _ragdoll = ragdoll; + if (_ragdoll) { + assert(!(_ragdoll->_ragdollSimulation)); + _ragdoll->_ragdollSimulation = this; + } + } +} + void PhysicsSimulation::setEntity(PhysicsEntity* entity) { if (_entity != entity) { if (_entity) { @@ -79,6 +92,7 @@ bool PhysicsSimulation::addEntity(PhysicsEntity* entity) { return false; } // add to list + assert(!(entity->_simulation)); entity->_simulation = this; _otherEntities.push_back(entity); return true; @@ -128,19 +142,26 @@ bool PhysicsSimulation::addRagdoll(Ragdoll* doll) { // list is full return false; } - for (int i = 0; i < numDolls; ++i) { - if (doll == _otherRagdolls[i]) { - // already in list - return true; + if (doll->_ragdollSimulation == this) { + for (int i = 0; i < numDolls; ++i) { + if (doll == _otherRagdolls[i]) { + // already in list + return true; + } } } // add to list + assert(!(doll->_ragdollSimulation)); + doll->_ragdollSimulation = this; _otherRagdolls.push_back(doll); return true; } void PhysicsSimulation::removeRagdoll(Ragdoll* doll) { int numDolls = _otherRagdolls.size(); + if (doll->_ragdollSimulation != this) { + return; + } for (int i = 0; i < numDolls; ++i) { if (doll == _otherRagdolls[i]) { if (i == numDolls - 1) { @@ -152,6 +173,7 @@ void PhysicsSimulation::removeRagdoll(Ragdoll* doll) { _otherRagdolls.pop_back(); _otherRagdolls[i] = lastDoll; } + doll->_ragdollSimulation = NULL; break; } } diff --git a/libraries/shared/src/PhysicsSimulation.h b/libraries/shared/src/PhysicsSimulation.h index be1f2fb366..61ab1bf177 100644 --- a/libraries/shared/src/PhysicsSimulation.h +++ b/libraries/shared/src/PhysicsSimulation.h @@ -31,7 +31,7 @@ public: void setTranslation(const glm::vec3& translation) { _translation = translation; } const glm::vec3& getTranslation() const { return _translation; } - void setRagdoll(Ragdoll* ragdoll) { _ragdoll = ragdoll; } + void setRagdoll(Ragdoll* ragdoll); void setEntity(PhysicsEntity* entity); /// \return true if entity was added to or is already in the list From 94da63006c420e79b759a7d9ee62b4b2d63a4d8b Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 7 Aug 2014 14:35:32 -0700 Subject: [PATCH 12/94] VerletPoint::_mass is now private We set the mass of other avatars artificially high so they are less movable. --- interface/src/avatar/SkeletonModel.cpp | 7 ++++--- libraries/shared/src/FixedConstraint.cpp | 3 --- libraries/shared/src/PhysicsSimulation.cpp | 10 ++++++++-- libraries/shared/src/Ragdoll.cpp | 16 +++++++++++++++- libraries/shared/src/Ragdoll.h | 4 ++++ libraries/shared/src/VerletCapsuleShape.cpp | 2 +- libraries/shared/src/VerletPoint.cpp | 9 +++++++++ libraries/shared/src/VerletPoint.h | 5 ++++- libraries/shared/src/VerletSphereShape.cpp | 2 +- 9 files changed, 46 insertions(+), 12 deletions(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 463ed28faf..6b77e1c2f1 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -671,6 +671,7 @@ void SkeletonModel::buildShapes() { } initRagdollPoints(); + float massScale = getMassScale(); float uniformScale = extractUniformScale(_scale); const int numStates = _jointStates.size(); @@ -689,12 +690,12 @@ void SkeletonModel::buildShapes() { if (type == Shape::SPHERE_SHAPE) { shape = new VerletSphereShape(radius, &(_ragdollPoints[i])); shape->setEntity(this); - _ragdollPoints[i]._mass = glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume()); + _ragdollPoints[i].setMass(massScale * glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume())); } else if (type == Shape::CAPSULE_SHAPE) { assert(parentIndex != -1); shape = new VerletCapsuleShape(radius, &(_ragdollPoints[parentIndex]), &(_ragdollPoints[i])); shape->setEntity(this); - _ragdollPoints[i]._mass = glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume()); + _ragdollPoints[i].setMass(massScale * glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume())); } if (parentIndex != -1) { // always disable collisions between joint and its parent @@ -702,7 +703,7 @@ void SkeletonModel::buildShapes() { } else { // give the base joint a very large mass since it doesn't actually move // in the local-frame simulation (it defines the origin) - _ragdollPoints[i]._mass = VERY_BIG_MASS; + _ragdollPoints[i].setMass(VERY_BIG_MASS); } _shapes.push_back(shape); } diff --git a/libraries/shared/src/FixedConstraint.cpp b/libraries/shared/src/FixedConstraint.cpp index 539978db5d..8f1edc1fb5 100644 --- a/libraries/shared/src/FixedConstraint.cpp +++ b/libraries/shared/src/FixedConstraint.cpp @@ -10,13 +10,11 @@ // #include "FixedConstraint.h" -#include "Shape.h" // for MAX_SHAPE_MASS #include "VerletPoint.h" FixedConstraint::FixedConstraint(glm::vec3* anchor, VerletPoint* point) : _anchor(anchor), _point(point) { assert(anchor); assert(point); - _point->_mass = MAX_SHAPE_MASS; } float FixedConstraint::enforce() { @@ -34,5 +32,4 @@ void FixedConstraint::setAnchor(glm::vec3* anchor) { void FixedConstraint::setPoint(VerletPoint* point) { assert(point); _point = point; - _point->_mass = MAX_SHAPE_MASS; } diff --git a/libraries/shared/src/PhysicsSimulation.cpp b/libraries/shared/src/PhysicsSimulation.cpp index 1007998b56..6dcafc6a54 100644 --- a/libraries/shared/src/PhysicsSimulation.cpp +++ b/libraries/shared/src/PhysicsSimulation.cpp @@ -133,6 +133,8 @@ void PhysicsSimulation::removeShapes(const PhysicsEntity* entity) { } } +const float OTHER_RAGDOLL_MASS_SCALE = 10.0f; + bool PhysicsSimulation::addRagdoll(Ragdoll* doll) { if (!doll) { return false; @@ -154,6 +156,9 @@ bool PhysicsSimulation::addRagdoll(Ragdoll* doll) { assert(!(doll->_ragdollSimulation)); doll->_ragdollSimulation = this; _otherRagdolls.push_back(doll); + + // set the massScale of otherRagdolls artificially high + doll->setMassScale(OTHER_RAGDOLL_MASS_SCALE); return true; } @@ -174,6 +179,7 @@ void PhysicsSimulation::removeRagdoll(Ragdoll* doll) { _otherRagdolls[i] = lastDoll; } doll->_ragdollSimulation = NULL; + doll->setMassScale(1.0f); break; } } @@ -237,7 +243,7 @@ void PhysicsSimulation::computeCollisions() { const QVector shapes = _entity->getShapes(); int numShapes = shapes.size(); - // collide with self + // collide main ragdoll with self for (int i = 0; i < numShapes; ++i) { const Shape* shape = shapes.at(i); if (!shape) { @@ -251,7 +257,7 @@ void PhysicsSimulation::computeCollisions() { } } - // collide with others + // collide main ragdoll with others int numEntities = _otherEntities.size(); for (int i = 0; i < numEntities; ++i) { const QVector otherShapes = _otherEntities.at(i)->getShapes(); diff --git a/libraries/shared/src/Ragdoll.cpp b/libraries/shared/src/Ragdoll.cpp index 5b21687bbd..e10e1620ae 100644 --- a/libraries/shared/src/Ragdoll.cpp +++ b/libraries/shared/src/Ragdoll.cpp @@ -19,7 +19,7 @@ #include "PhysicsSimulation.h" #include "SharedUtil.h" // for EPSILON -Ragdoll::Ragdoll() : _ragdollTranslation(0.0f), _translationInSimulationFrame(0.0f), _ragdollSimulation(NULL) { +Ragdoll::Ragdoll() : _massScale(1.0f), _ragdollTranslation(0.0f), _translationInSimulationFrame(0.0f), _ragdollSimulation(NULL) { } Ragdoll::~Ragdoll() { @@ -99,3 +99,17 @@ void Ragdoll::updateSimulationTransforms(const glm::vec3& translation, const glm _translationInSimulationFrame = translation; _rotationInSimulationFrame = rotation; } + +void Ragdoll::setMassScale(float scale) { + const float MIN_SCALE = 1.0e-2f; + const float MAX_SCALE = 1.0e6f; + scale = glm::clamp(glm::abs(scale), MIN_SCALE, MAX_SCALE); + if (scale != _massScale) { + float rescale = scale / _massScale; + int numPoints = _ragdollPoints.size(); + for (int i = 0; i < numPoints; ++i) { + _ragdollPoints[i].setMass(rescale * _ragdollPoints[i].getMass()); + } + _massScale = scale; + } +} diff --git a/libraries/shared/src/Ragdoll.h b/libraries/shared/src/Ragdoll.h index 421e8e3ff8..ec5a561d1a 100644 --- a/libraries/shared/src/Ragdoll.h +++ b/libraries/shared/src/Ragdoll.h @@ -49,11 +49,15 @@ public: const glm::vec3& getTranslationInSimulationFrame() const { return _translationInSimulationFrame; } + void setMassScale(float scale); + float getMassScale() const { return _massScale; } + protected: void clearRagdollConstraintsAndPoints(); virtual void initRagdollPoints() = 0; virtual void buildRagdollConstraints() = 0; + float _massScale; glm::vec3 _ragdollTranslation; // world-frame glm::quat _ragdollRotation; // world-frame glm::vec3 _translationInSimulationFrame; diff --git a/libraries/shared/src/VerletCapsuleShape.cpp b/libraries/shared/src/VerletCapsuleShape.cpp index 6f547d2048..ce324a781a 100644 --- a/libraries/shared/src/VerletCapsuleShape.cpp +++ b/libraries/shared/src/VerletCapsuleShape.cpp @@ -97,7 +97,7 @@ float VerletCapsuleShape::computeEffectiveMass(const glm::vec3& penetration, con _endLagrangeCoef = 1.0f; } // the effective mass is the weighted sum of the two endpoints - return _startLagrangeCoef * _startPoint->_mass + _endLagrangeCoef * _endPoint->_mass; + return _startLagrangeCoef * _startPoint->getMass() + _endLagrangeCoef * _endPoint->getMass(); } void VerletCapsuleShape::accumulateDelta(float relativeMassFactor, const glm::vec3& penetration) { diff --git a/libraries/shared/src/VerletPoint.cpp b/libraries/shared/src/VerletPoint.cpp index dae861a7ab..d2dd985587 100644 --- a/libraries/shared/src/VerletPoint.cpp +++ b/libraries/shared/src/VerletPoint.cpp @@ -38,3 +38,12 @@ void VerletPoint::move(const glm::vec3& deltaPosition, const glm::quat& deltaRot arm = _lastPosition - oldPivot; _lastPosition += deltaPosition + (deltaRotation * arm - arm); } + +void VerletPoint::setMass(float mass) { + const float MIN_MASS = 1.0e-6f; + const float MAX_MASS = 1.0e18f; + if (glm::isnan(mass)) { + mass = MIN_MASS; + } + _mass = glm::clamp(glm::abs(mass), MIN_MASS, MAX_MASS); +} diff --git a/libraries/shared/src/VerletPoint.h b/libraries/shared/src/VerletPoint.h index a1dca3e955..6f94656966 100644 --- a/libraries/shared/src/VerletPoint.h +++ b/libraries/shared/src/VerletPoint.h @@ -26,11 +26,14 @@ public: void applyAccumulatedDelta(); void move(const glm::vec3& deltaPosition, const glm::quat& deltaRotation, const glm::vec3& oldPivot); + void setMass(float mass); + float getMass() const { return _mass; } + glm::vec3 _position; glm::vec3 _lastPosition; - float _mass; private: + float _mass; glm::vec3 _accumulatedDelta; int _numDeltas; }; diff --git a/libraries/shared/src/VerletSphereShape.cpp b/libraries/shared/src/VerletSphereShape.cpp index e24465fd89..da8242f26a 100644 --- a/libraries/shared/src/VerletSphereShape.cpp +++ b/libraries/shared/src/VerletSphereShape.cpp @@ -36,7 +36,7 @@ const glm::vec3& VerletSphereShape::getTranslation() const { // virtual float VerletSphereShape::computeEffectiveMass(const glm::vec3& penetration, const glm::vec3& contactPoint) { - return _point->_mass; + return _point->getMass(); } // virtual From 8de2dd9485373a5f5e2cdcde0cbab2756f2b2fed Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 7 Aug 2014 14:38:47 -0700 Subject: [PATCH 13/94] Working on ray intersection testing. --- interface/src/ui/MetavoxelEditor.cpp | 8 +- .../metavoxels/src/MetavoxelClientManager.cpp | 170 ++++++++++++++---- 2 files changed, 140 insertions(+), 38 deletions(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index a2bb1770b2..a5186567bd 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1100,11 +1100,13 @@ void HeightfieldBrushTool::render() { glm::vec3 origin = Application::getInstance()->getMouseRayOrigin(); glm::vec3 direction = Application::getInstance()->getMouseRayDirection(); - float distance = -origin.y / direction.y; + float distance; + if (!Application::getInstance()->getMetavoxels()->findFirstRayHeightfieldIntersection(origin, direction, distance)) { + return; + } + qDebug() << distance; glm::vec3 point = origin + distance * direction; - point.y = Application::getInstance()->getMetavoxels()->getHeightfieldHeight(point); - glPushMatrix(); glTranslatef(point.x, point.y, point.z); diff --git a/libraries/metavoxels/src/MetavoxelClientManager.cpp b/libraries/metavoxels/src/MetavoxelClientManager.cpp index 51eb4c653c..a9eff58f33 100644 --- a/libraries/metavoxels/src/MetavoxelClientManager.cpp +++ b/libraries/metavoxels/src/MetavoxelClientManager.cpp @@ -64,6 +64,8 @@ SharedObjectPointer MetavoxelClientManager::findFirstRaySpannerIntersection(cons class RayHeightfieldIntersectionVisitor : public RayIntersectionVisitor { public: + float intersectionDistance; + RayHeightfieldIntersectionVisitor(const glm::vec3& origin, const glm::vec3& direction, const MetavoxelLOD& lod); virtual int visit(MetavoxelInfo& info, float distance); @@ -72,7 +74,8 @@ public: RayHeightfieldIntersectionVisitor::RayHeightfieldIntersectionVisitor(const glm::vec3& origin, const glm::vec3& direction, const MetavoxelLOD& lod) : RayIntersectionVisitor(origin, direction, QVector() << - AttributeRegistry::getInstance()->getHeightfieldAttribute(), QVector(), lod) { + AttributeRegistry::getInstance()->getHeightfieldAttribute(), QVector(), lod), + intersectionDistance(FLT_MAX) { } static const float EIGHT_BIT_MAXIMUM_RECIPROCAL = 1.0f / 255.0f; @@ -91,42 +94,129 @@ int RayHeightfieldIntersectionVisitor::visit(MetavoxelInfo& info, float distance int highest = size - 1; float heightScale = highest / EIGHT_BIT_MAXIMUM_RECIPROCAL; - // find the initial location - glm::vec3 location = (_origin + distance * _direction - info.minimum) * (float)highest / info.size; - - glm::vec3 floors = glm::floor(location); - glm::vec3 ceils = glm::ceil(location); - int floorX = qMin(qMax((int)floors.x, 0), highest); - int floorZ = qMin(qMax((int)floors.z, 0), highest); - int ceilX = qMin(qMax((int)ceils.x, 0), highest); - int ceilZ = qMin(qMax((int)ceils.z, 0), highest); - float upperLeft = src[floorZ * size + floorX] * heightScale; - float upperRight = src[floorZ * size + ceilX] * heightScale; - float lowerLeft = src[ceilZ * size + floorX] * heightScale; - float lowerRight = src[ceilZ * size + ceilX] * heightScale; - - glm::vec3 relativeLocation = location - glm::vec3(floors.x, upperLeft, floors.z); - - glm::vec3 lowerNormal(lowerLeft - lowerRight, 1.0f, upperLeft - lowerLeft); - float lowerProduct = glm::dot(lowerNormal, _direction); - if (lowerProduct < EPSILON) { - float distance = -glm::dot(lowerNormal, relativeLocation) / lowerProduct; - glm::vec3 intersection = relativeLocation + distance * _direction; - if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && - intersection.z >= intersection.x) { - return SHORT_CIRCUIT; + // find the initial location in heightfield coordinates + glm::vec3 entry = (_origin + distance * _direction - info.minimum) * (float)highest / info.size; + glm::vec3 floors = glm::floor(entry); + glm::vec3 ceils = glm::ceil(entry); + if (floors.x == ceils.x) { + if (_direction.x > 0.0f) { + ceils.x += 1.0f; + } else { + floors.x -= 1.0f; + } + } + if (floors.z == ceils.z) { + if (_direction.z > 0.0f) { + ceils.z += 1.0f; + } else { + floors.z -= 1.0f; } } - glm::vec3 upperNormal(upperLeft - upperRight, 1.0f, upperRight - lowerRight); - float upperProduct = glm::dot(upperNormal, _direction); - if (upperProduct < EPSILON) { - float distance = -glm::dot(upperNormal, relativeLocation) / upperProduct; - glm::vec3 intersection = relativeLocation + distance * _direction; - if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && - intersection.x >= intersection.z) { - return SHORT_CIRCUIT; + bool withinBounds = true; + float accumulatedDistance = 0.0f; + while (withinBounds) { + // find the heights at the corners of the current cell + int floorX = qMin(qMax((int)floors.x, 0), highest); + int floorZ = qMin(qMax((int)floors.z, 0), highest); + int ceilX = qMin(qMax((int)ceils.x, 0), highest); + int ceilZ = qMin(qMax((int)ceils.z, 0), highest); + float upperLeft = src[floorZ * size + floorX] * heightScale; + float upperRight = src[floorZ * size + ceilX] * heightScale; + float lowerLeft = src[ceilZ * size + floorX] * heightScale; + float lowerRight = src[ceilZ * size + ceilX] * heightScale; + + // find the distance to the next x coordinate + float xDistance = FLT_MAX; + if (_direction.x > 0.0f) { + xDistance = (ceils.x - entry.x) / _direction.x; + } else if (_direction.x < 0.0f) { + xDistance = (floors.x - entry.x) / _direction.x; } + + // and the distance to the next z coordinate + float zDistance = FLT_MAX; + if (_direction.z > 0.0f) { + zDistance = (ceils.z - entry.z) / _direction.z; + } else if (_direction.z < 0.0f) { + zDistance = (floors.z - entry.z) / _direction.z; + } + + // the exit distance is the lower of those two + float exitDistance = qMin(xDistance, zDistance); + glm::vec3 exit, nextFloors = floors, nextCeils = ceils; + if (exitDistance == FLT_MAX) { + if (_direction.y > 0.0f) { + return SHORT_CIRCUIT; // line points upwards; no collisions possible + } + withinBounds = false; // line points downwards; check this cell only + + } else { + // find the exit point and the next cell, and determine whether it's still within the bounds + exit = entry + exitDistance * _direction; + withinBounds = (exit.y >= 0.0f && exit.y <= highest); + if (exitDistance == xDistance) { + if (_direction.x > 0.0f) { + nextFloors.x += 1.0f; + withinBounds &= (nextCeils.x += 1.0f) <= highest; + } else { + withinBounds &= (nextFloors.x -= 1.0f) >= 0.0f; + nextCeils.x -= 1.0f; + } + } + if (exitDistance == zDistance) { + if (_direction.z > 0.0f) { + nextFloors.z += 1.0f; + withinBounds &= (nextCeils.z += 1.0f) <= highest; + } else { + withinBounds &= (nextFloors.z -= 1.0f) >= 0.0f; + nextCeils.z -= 1.0f; + } + } + // check the vertical range of the ray against the ranges of the cell heights + if (qMin(entry.y, exit.y) > qMax(qMax(upperLeft, upperRight), qMax(lowerLeft, lowerRight)) || + qMax(entry.y, exit.y) < qMin(qMin(upperLeft, upperRight), qMin(lowerLeft, lowerRight))) { + entry = exit; + floors = nextFloors; + ceils = nextCeils; + accumulatedDistance += exitDistance; + continue; + } + } + // having passed the bounds check, we must check against the planes + glm::vec3 relativeEntry = entry - glm::vec3(floors.x, upperLeft, floors.z); + + // first check the triangle including the Z+ segment + glm::vec3 lowerNormal(lowerLeft - lowerRight, 1.0f, upperLeft - lowerLeft); + float lowerProduct = glm::dot(lowerNormal, _direction); + if (lowerProduct < 0.0f) { + float planeDistance = -glm::dot(lowerNormal, relativeEntry) / lowerProduct; + glm::vec3 intersection = relativeEntry + planeDistance * _direction; + if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && + intersection.z >= intersection.x) { + intersectionDistance = distance + (accumulatedDistance + planeDistance) * (info.size / highest); + return SHORT_CIRCUIT; + } + } + + // then the one with the X+ segment + glm::vec3 upperNormal(upperLeft - upperRight, 1.0f, upperRight - lowerRight); + float upperProduct = glm::dot(upperNormal, _direction); + if (upperProduct < 0.0f) { + float planeDistance = -glm::dot(upperNormal, relativeEntry) / upperProduct; + glm::vec3 intersection = relativeEntry + planeDistance * _direction; + if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && + intersection.x >= intersection.z) { + intersectionDistance = distance + (accumulatedDistance + planeDistance) * (info.size / highest); + return SHORT_CIRCUIT; + } + } + + // no joy; continue on our way + entry = exit; + floors = nextFloors; + ceils = nextCeils; + accumulatedDistance += exitDistance; } return STOP_RECURSION; @@ -136,7 +226,11 @@ bool MetavoxelClientManager::findFirstRayHeightfieldIntersection(const glm::vec3 const glm::vec3& direction, float& distance) { RayHeightfieldIntersectionVisitor visitor(origin, direction, getLOD()); guide(visitor); - return false; + if (visitor.intersectionDistance == FLT_MAX) { + return false; + } + distance = visitor.intersectionDistance; + return true; } void MetavoxelClientManager::setSphere(const glm::vec3& center, float radius, const QColor& color) { @@ -197,6 +291,8 @@ int HeightfieldHeightVisitor::visit(MetavoxelInfo& info) { int size = glm::sqrt((float)contents.size()); int highest = size - 1; relative *= highest / info.size; + + // find the bounds of the cell containing the point and the shared vertex heights glm::vec3 floors = glm::floor(relative); glm::vec3 ceils = glm::ceil(relative); glm::vec3 fracts = glm::fract(relative); @@ -207,6 +303,8 @@ int HeightfieldHeightVisitor::visit(MetavoxelInfo& info) { float upperLeft = src[floorZ * size + floorX]; float lowerRight = src[ceilZ * size + ceilX]; float interpolatedHeight; + + // the final vertex (and thus which triangle we check) depends on which half we're on if (fracts.x > fracts.z) { float upperRight = src[floorZ * size + ceilX]; interpolatedHeight = glm::mix(glm::mix(upperLeft, upperRight, fracts.x), lowerRight, fracts.z); @@ -216,8 +314,10 @@ int HeightfieldHeightVisitor::visit(MetavoxelInfo& info) { interpolatedHeight = glm::mix(upperLeft, glm::mix(lowerLeft, lowerRight, fracts.x), fracts.z); } if (interpolatedHeight == 0.0f) { - return STOP_RECURSION; + return STOP_RECURSION; // ignore zero values } + + // convert the interpolated height into world space height = qMax(height, info.minimum.y + interpolatedHeight * info.size * EIGHT_BIT_MAXIMUM_RECIPROCAL); return SHORT_CIRCUIT; } From 8c2dad1476bb4d2f9467be7f96f4030ebd53b783 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 7 Aug 2014 14:40:06 -0700 Subject: [PATCH 14/94] remove animation server --- animation-server/CMakeLists.txt | 39 -- animation-server/src/AnimationServer.cpp | 852 ----------------------- animation-server/src/AnimationServer.h | 27 - animation-server/src/main.cpp | 17 - 4 files changed, 935 deletions(-) delete mode 100644 animation-server/CMakeLists.txt delete mode 100644 animation-server/src/AnimationServer.cpp delete mode 100644 animation-server/src/AnimationServer.h delete mode 100644 animation-server/src/main.cpp diff --git a/animation-server/CMakeLists.txt b/animation-server/CMakeLists.txt deleted file mode 100644 index 116ee0e942..0000000000 --- a/animation-server/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -if (WIN32) - cmake_policy (SET CMP0020 NEW) -endif (WIN32) - -set(TARGET_NAME animation-server) - -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -find_package(Qt5 COMPONENTS Script) -include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") - -# set up the external glm library -include("${MACRO_DIR}/IncludeGLM.cmake") -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -include("${MACRO_DIR}/SetupHifiProject.cmake") -setup_hifi_project(${TARGET_NAME} TRUE) - -# link in the shared library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi octree library -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi voxels library -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") - -# link the hifi networking library -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () diff --git a/animation-server/src/AnimationServer.cpp b/animation-server/src/AnimationServer.cpp deleted file mode 100644 index 32a95b48ea..0000000000 --- a/animation-server/src/AnimationServer.cpp +++ /dev/null @@ -1,852 +0,0 @@ -// -// AnimationServer.cpp -// animation-server/src -// -// Created by Stephen Birarda on 12/5/2013. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "AnimationServer.h" - -bool shouldShowPacketsPerSecond = false; // do we want to debug packets per second -bool includeBillboard = true; -bool includeBorderTracer = true; -bool includeMovingBug = true; -bool includeBlinkingVoxel = false; -bool includeDanceFloor = true; -bool buildStreet = false; -bool nonThreadedPacketSender = false; -int packetsPerSecond = PacketSender::DEFAULT_PACKETS_PER_SECOND; -bool waitForVoxelServer = true; - - -const int ANIMATION_LISTEN_PORT = 40107; -int ANIMATE_FPS = 60; -double ANIMATE_FPS_IN_MILLISECONDS = 1000.0/ANIMATE_FPS; // determines FPS from our desired FPS -quint64 ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000); // converts from milliseconds to usecs - - -int PROCESSING_FPS = 60; -double PROCESSING_FPS_IN_MILLISECONDS = 1000.0/PROCESSING_FPS; // determines FPS from our desired FPS -int FUDGE_USECS = 650; // a little bit of fudge to actually do some processing -quint64 PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000) - FUDGE_USECS; // converts from milliseconds to usecs - -bool wantLocalDomain = false; - -unsigned long packetsSent = 0; -unsigned long bytesSent = 0; - -JurisdictionListener* jurisdictionListener = NULL; -VoxelEditPacketSender* voxelEditPacketSender = NULL; -pthread_t animateVoxelThread; - -glm::vec3 rotatePoint(glm::vec3 point, float angle) { - // First, create the quaternion based on this angle of rotation - glm::quat q(glm::vec3(0, -angle, 0)); - - // Next, create a rotation matrix from that quaternion - glm::mat4 rotation = glm::mat4_cast(q); - - // Transform the original vectors by the rotation matrix to get the new vectors - glm::vec4 quatPoint(point.x, point.y, point.z, 0); - glm::vec4 newPoint = quatPoint * rotation; - - return glm::vec3(newPoint.x, newPoint.y, newPoint.z); -} - - -const float BUG_VOXEL_SIZE = 0.0625f / TREE_SCALE; -glm::vec3 bugPosition = glm::vec3(BUG_VOXEL_SIZE * 20.0, BUG_VOXEL_SIZE * 30.0, BUG_VOXEL_SIZE * 20.0); -glm::vec3 bugDirection = glm::vec3(0, 0, 1); -const int VOXELS_PER_BUG = 18; -glm::vec3 bugPathCenter = glm::vec3(0.25f,0.15f,0.25f); // glm::vec3(BUG_VOXEL_SIZE * 150.0, BUG_VOXEL_SIZE * 30.0, BUG_VOXEL_SIZE * 150.0); -float bugPathRadius = 0.2f; //BUG_VOXEL_SIZE * 140.0; -float bugPathTheta = 0.0f * RADIANS_PER_DEGREE; -float bugRotation = 0.0f * RADIANS_PER_DEGREE; -float bugAngleDelta = 0.2f * RADIANS_PER_DEGREE; -bool moveBugInLine = false; - -class BugPart { -public: - glm::vec3 partLocation; - unsigned char partColor[3]; - - BugPart(const glm::vec3& location, unsigned char red, unsigned char green, unsigned char blue ) { - partLocation = location; - partColor[0] = red; - partColor[1] = green; - partColor[2] = blue; - } -}; - -const BugPart bugParts[VOXELS_PER_BUG] = { - - // tail - BugPart(glm::vec3( 0, 0, -3), 51, 51, 153) , - BugPart(glm::vec3( 0, 0, -2), 51, 51, 153) , - BugPart(glm::vec3( 0, 0, -1), 51, 51, 153) , - - // body - BugPart(glm::vec3( 0, 0, 0), 255, 200, 0) , - BugPart(glm::vec3( 0, 0, 1), 255, 200, 0) , - - // head - BugPart(glm::vec3( 0, 0, 2), 200, 0, 0) , - - // eyes - BugPart(glm::vec3( 1, 0, 3), 64, 64, 64) , - BugPart(glm::vec3(-1, 0, 3), 64, 64, 64) , - - // wings - BugPart(glm::vec3( 3, 1, 1), 0, 153, 0) , - BugPart(glm::vec3( 2, 1, 1), 0, 153, 0) , - BugPart(glm::vec3( 1, 0, 1), 0, 153, 0) , - BugPart(glm::vec3(-1, 0, 1), 0, 153, 0) , - BugPart(glm::vec3(-2, 1, 1), 0, 153, 0) , - BugPart(glm::vec3(-3, 1, 1), 0, 153, 0) , - - - BugPart(glm::vec3( 2, -1, 0), 153, 200, 0) , - BugPart(glm::vec3( 1, -1, 0), 153, 200, 0) , - BugPart(glm::vec3(-1, -1, 0), 153, 200, 0) , - BugPart(glm::vec3(-2, -1, 0), 153, 200, 0) , -}; - -static void renderMovingBug() { - VoxelDetail details[VOXELS_PER_BUG]; - - // Generate voxels for where bug used to be - for (int i = 0; i < VOXELS_PER_BUG; i++) { - details[i].s = BUG_VOXEL_SIZE; - - glm::vec3 partAt = bugParts[i].partLocation * BUG_VOXEL_SIZE * (bugDirection.x < 0 ? -1.0f : 1.0f); - glm::vec3 rotatedPartAt = rotatePoint(partAt, bugRotation); - glm::vec3 offsetPartAt = rotatedPartAt + bugPosition; - - details[i].x = offsetPartAt.x; - details[i].y = offsetPartAt.y; - details[i].z = offsetPartAt.z; - - details[i].red = bugParts[i].partColor[0]; - details[i].green = bugParts[i].partColor[1]; - details[i].blue = bugParts[i].partColor[2]; - } - - // send the "erase message" first... - PacketType message = PacketTypeVoxelErase; - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_BUG, (VoxelDetail*)&details); - - // Move the bug... - if (moveBugInLine) { - bugPosition.x += (bugDirection.x * BUG_VOXEL_SIZE); - bugPosition.y += (bugDirection.y * BUG_VOXEL_SIZE); - bugPosition.z += (bugDirection.z * BUG_VOXEL_SIZE); - - // Check boundaries - if (bugPosition.z > 1.0f) { - bugDirection.z = -1.f; - } - if (bugPosition.z < BUG_VOXEL_SIZE) { - bugDirection.z = 1.f; - } - } else { - - //qDebug("bugPathCenter=(%f,%f,%f)", bugPathCenter.x, bugPathCenter.y, bugPathCenter.z); - - bugPathTheta += bugAngleDelta; // move slightly - bugRotation -= bugAngleDelta; // rotate slightly - - // If we loop past end of circle, just reset back into normal range - if (bugPathTheta > TWO_PI) { - bugPathTheta = 0.f; - bugRotation = 0.f; - } - - float x = bugPathCenter.x + bugPathRadius * cos(bugPathTheta); - float z = bugPathCenter.z + bugPathRadius * sin(bugPathTheta); - float y = bugPathCenter.y; - - bugPosition = glm::vec3(x, y, z); - //qDebug("bugPathTheta=%f", bugPathTheta); - //qDebug("bugRotation=%f", bugRotation); - } - - //qDebug("bugPosition=(%f,%f,%f)", bugPosition.x, bugPosition.y, bugPosition.z); - //qDebug("bugDirection=(%f,%f,%f)", bugDirection.x, bugDirection.y, bugDirection.z); - // would be nice to add some randomness here... - - // Generate voxels for where bug is going to - for (int i = 0; i < VOXELS_PER_BUG; i++) { - details[i].s = BUG_VOXEL_SIZE; - - glm::vec3 partAt = bugParts[i].partLocation * BUG_VOXEL_SIZE * (bugDirection.x < 0 ? -1.0f : 1.0f); - glm::vec3 rotatedPartAt = rotatePoint(partAt, bugRotation); - glm::vec3 offsetPartAt = rotatedPartAt + bugPosition; - - details[i].x = offsetPartAt.x; - details[i].y = offsetPartAt.y; - details[i].z = offsetPartAt.z; - - details[i].red = bugParts[i].partColor[0]; - details[i].green = bugParts[i].partColor[1]; - details[i].blue = bugParts[i].partColor[2]; - } - - // send the "create message" ... - message = PacketTypeVoxelSetDestructive; - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_BUG, (VoxelDetail*)&details); -} - - -float intensity = 0.5f; -float intensityIncrement = 0.1f; -const float MAX_INTENSITY = 1.0f; -const float MIN_INTENSITY = 0.5f; -const float BEACON_SIZE = 0.25f / TREE_SCALE; // approximately 1/4th meter - -static void sendVoxelBlinkMessage() { - VoxelDetail detail; - detail.s = BEACON_SIZE; - - glm::vec3 position = glm::vec3(0.f, 0.f, detail.s); - - detail.x = detail.s * floor(position.x / detail.s); - detail.y = detail.s * floor(position.y / detail.s); - detail.z = detail.s * floor(position.z / detail.s); - - ::intensity += ::intensityIncrement; - if (::intensity >= MAX_INTENSITY) { - ::intensity = MAX_INTENSITY; - ::intensityIncrement = -::intensityIncrement; - } - if (::intensity <= MIN_INTENSITY) { - ::intensity = MIN_INTENSITY; - ::intensityIncrement = -::intensityIncrement; - } - - detail.red = 255 * ::intensity; - detail.green = 0 * ::intensity; - detail.blue = 0 * ::intensity; - - PacketType message = PacketTypeVoxelSetDestructive; - - ::voxelEditPacketSender->sendVoxelEditMessage(message, detail); -} - -bool stringOfLightsInitialized = false; -int currentLight = 0; -int lightMovementDirection = 1; -const int SEGMENT_COUNT = 4; -const int LIGHTS_PER_SEGMENT = 80; -const int LIGHT_COUNT = LIGHTS_PER_SEGMENT * SEGMENT_COUNT; -glm::vec3 stringOfLights[LIGHT_COUNT]; -unsigned char offColor[3] = { 240, 240, 240 }; -unsigned char onColor[3] = { 0, 255, 255 }; -const float STRING_OF_LIGHTS_SIZE = 0.125f / TREE_SCALE; // approximately 1/8th meter - -static void sendBlinkingStringOfLights() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = STRING_OF_LIGHTS_SIZE; - static VoxelDetail details[LIGHTS_PER_SEGMENT]; - - // first initialized the string of lights if needed... - if (!stringOfLightsInitialized) { - for (int segment = 0; segment < SEGMENT_COUNT; segment++) { - for (int indexInSegment = 0; indexInSegment < LIGHTS_PER_SEGMENT; indexInSegment++) { - - int i = (segment * LIGHTS_PER_SEGMENT) + indexInSegment; - - // four different segments on sides of initial platform - switch (segment) { - case 0: - // along x axis - stringOfLights[i] = glm::vec3(indexInSegment * lightScale, 0, 0); - break; - case 1: - // parallel to Z axis at outer X edge - stringOfLights[i] = glm::vec3(LIGHTS_PER_SEGMENT * lightScale, 0, indexInSegment * lightScale); - break; - case 2: - // parallel to X axis at outer Z edge - stringOfLights[i] = glm::vec3((LIGHTS_PER_SEGMENT-indexInSegment) * lightScale, 0, - LIGHTS_PER_SEGMENT * lightScale); - break; - case 3: - // on Z axis - stringOfLights[i] = glm::vec3(0, 0, (LIGHTS_PER_SEGMENT-indexInSegment) * lightScale); - break; - } - - details[indexInSegment].s = STRING_OF_LIGHTS_SIZE; - details[indexInSegment].x = stringOfLights[i].x; - details[indexInSegment].y = stringOfLights[i].y; - details[indexInSegment].z = stringOfLights[i].z; - - details[indexInSegment].red = offColor[0]; - details[indexInSegment].green = offColor[1]; - details[indexInSegment].blue = offColor[2]; - } - - ::voxelEditPacketSender->queueVoxelEditMessages(message, LIGHTS_PER_SEGMENT, (VoxelDetail*)&details); - } - stringOfLightsInitialized = true; - } else { - // turn off current light - details[0].x = stringOfLights[currentLight].x; - details[0].y = stringOfLights[currentLight].y; - details[0].z = stringOfLights[currentLight].z; - details[0].red = offColor[0]; - details[0].green = offColor[1]; - details[0].blue = offColor[2]; - - // move current light... - // if we're at the end of our string, then change direction - if (currentLight == LIGHT_COUNT-1) { - lightMovementDirection = -1; - } - if (currentLight == 0) { - lightMovementDirection = 1; - } - currentLight += lightMovementDirection; - - // turn on new current light - details[1].x = stringOfLights[currentLight].x; - details[1].y = stringOfLights[currentLight].y; - details[1].z = stringOfLights[currentLight].z; - details[1].red = onColor[0]; - details[1].green = onColor[1]; - details[1].blue = onColor[2]; - - // send both changes in same message - ::voxelEditPacketSender->queueVoxelEditMessages(message, 2, (VoxelDetail*)&details); - } -} - -bool danceFloorInitialized = false; -const float DANCE_FLOOR_LIGHT_SIZE = 1.0f / TREE_SCALE; // approximately 1 meter -const int DANCE_FLOOR_LENGTH = 10; -const int DANCE_FLOOR_WIDTH = 10; -glm::vec3 danceFloorPosition(100.0f / TREE_SCALE, 30.0f / TREE_SCALE, 10.0f / TREE_SCALE); -glm::vec3 danceFloorLights[DANCE_FLOOR_LENGTH][DANCE_FLOOR_WIDTH]; -unsigned char danceFloorOffColor[3] = { 240, 240, 240 }; -const int DANCE_FLOOR_COLORS = 6; - -unsigned char danceFloorOnColorA[DANCE_FLOOR_COLORS][3] = { - { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 }, - { 0, 191, 255 }, { 0, 250, 154 }, { 255, 69, 0 }, -}; -unsigned char danceFloorOnColorB[DANCE_FLOOR_COLORS][3] = { - { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } , - { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } -}; -float danceFloorGradient = 0.5f; -const float BEATS_PER_MINUTE = 118.0f; -const float SECONDS_PER_MINUTE = 60.0f; -const float FRAMES_PER_BEAT = (SECONDS_PER_MINUTE * ANIMATE_FPS) / BEATS_PER_MINUTE; -float danceFloorGradientIncrement = 1.0f / FRAMES_PER_BEAT; -const float DANCE_FLOOR_MAX_GRADIENT = 1.0f; -const float DANCE_FLOOR_MIN_GRADIENT = 0.0f; -const int DANCE_FLOOR_VOXELS_PER_PACKET = 100; -int danceFloorColors[DANCE_FLOOR_WIDTH][DANCE_FLOOR_LENGTH]; - -void sendDanceFloor() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = DANCE_FLOOR_LIGHT_SIZE; - static VoxelDetail details[DANCE_FLOOR_VOXELS_PER_PACKET]; - - // first initialized the billboard of lights if needed... - if (!::danceFloorInitialized) { - for (int i = 0; i < DANCE_FLOOR_WIDTH; i++) { - for (int j = 0; j < DANCE_FLOOR_LENGTH; j++) { - - int randomColorIndex = randIntInRange(-DANCE_FLOOR_COLORS, DANCE_FLOOR_COLORS); - ::danceFloorColors[i][j] = randomColorIndex; - ::danceFloorLights[i][j] = ::danceFloorPosition + - glm::vec3(i * DANCE_FLOOR_LIGHT_SIZE, 0, j * DANCE_FLOOR_LIGHT_SIZE); - } - } - ::danceFloorInitialized = true; - } - - ::danceFloorGradient += ::danceFloorGradientIncrement; - - if (::danceFloorGradient >= DANCE_FLOOR_MAX_GRADIENT) { - ::danceFloorGradient = DANCE_FLOOR_MAX_GRADIENT; - ::danceFloorGradientIncrement = -::danceFloorGradientIncrement; - } - if (::danceFloorGradient <= DANCE_FLOOR_MIN_GRADIENT) { - ::danceFloorGradient = DANCE_FLOOR_MIN_GRADIENT; - ::danceFloorGradientIncrement = -::danceFloorGradientIncrement; - } - - for (int i = 0; i < DANCE_FLOOR_LENGTH; i++) { - for (int j = 0; j < DANCE_FLOOR_WIDTH; j++) { - - int nthVoxel = ((i * DANCE_FLOOR_WIDTH) + j); - int item = nthVoxel % DANCE_FLOOR_VOXELS_PER_PACKET; - - ::danceFloorLights[i][j] = ::danceFloorPosition + - glm::vec3(i * DANCE_FLOOR_LIGHT_SIZE, 0, j * DANCE_FLOOR_LIGHT_SIZE); - - details[item].s = lightScale; - details[item].x = ::danceFloorLights[i][j].x; - details[item].y = ::danceFloorLights[i][j].y; - details[item].z = ::danceFloorLights[i][j].z; - - if (danceFloorColors[i][j] > 0) { - int color = danceFloorColors[i][j] - 1; - details[item].red = (::danceFloorOnColorA[color][0] + - ((::danceFloorOnColorB[color][0] - ::danceFloorOnColorA[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorA[color][1] + - ((::danceFloorOnColorB[color][1] - ::danceFloorOnColorA[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorA[color][2] + - ((::danceFloorOnColorB[color][2] - ::danceFloorOnColorA[color][2]) - * ::danceFloorGradient)); - } else if (::danceFloorColors[i][j] < 0) { - int color = -(::danceFloorColors[i][j] + 1); - details[item].red = (::danceFloorOnColorB[color][0] + - ((::danceFloorOnColorA[color][0] - ::danceFloorOnColorB[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorB[color][1] + - ((::danceFloorOnColorA[color][1] - ::danceFloorOnColorB[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorB[color][2] + - ((::danceFloorOnColorA[color][2] - ::danceFloorOnColorB[color][2]) - * ::danceFloorGradient)); - } else { - int color = 0; - details[item].red = (::danceFloorOnColorB[color][0] + - ((::danceFloorOnColorA[color][0] - ::danceFloorOnColorB[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorB[color][1] + - ((::danceFloorOnColorA[color][1] - ::danceFloorOnColorB[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorB[color][2] + - ((::danceFloorOnColorA[color][2] - ::danceFloorOnColorB[color][2]) - * ::danceFloorGradient)); - } - - if (item == DANCE_FLOOR_VOXELS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, DANCE_FLOOR_VOXELS_PER_PACKET, (VoxelDetail*)&details); - } - } - } -} - -bool billboardInitialized = false; -const int BILLBOARD_HEIGHT = 9; -const int BILLBOARD_WIDTH = 45; -glm::vec3 billboardPosition((0.125f / TREE_SCALE),(0.125f / TREE_SCALE),0); -glm::vec3 billboardLights[BILLBOARD_HEIGHT][BILLBOARD_WIDTH]; -unsigned char billboardOffColor[3] = { 240, 240, 240 }; -unsigned char billboardOnColorA[3] = { 0, 0, 255 }; -unsigned char billboardOnColorB[3] = { 0, 255, 0 }; -float billboardGradient = 0.5f; -float billboardGradientIncrement = 0.01f; -const float BILLBOARD_MAX_GRADIENT = 1.0f; -const float BILLBOARD_MIN_GRADIENT = 0.0f; -const float BILLBOARD_LIGHT_SIZE = 0.125f / TREE_SCALE; // approximately 1/8 meter per light -const int VOXELS_PER_PACKET = 81; - -// top to bottom... -bool billboardMessage[BILLBOARD_HEIGHT][BILLBOARD_WIDTH] = { - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, - { 0,0,1,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,0,0 }, - { 0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,1,1,1,0,0,0,0,0 }, - { 0,0,1,1,1,1,0,1,0,1,1,1,0,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0,1,0,1,0 }, - { 0,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,1,0 }, - { 0,0,1,0,0,1,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0,1,1,1,0 }, - { 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 }, - { 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0 }, - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } -}; - -static void sendBillboard() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = BILLBOARD_LIGHT_SIZE; - static VoxelDetail details[VOXELS_PER_PACKET]; - - // first initialized the billboard of lights if needed... - if (!billboardInitialized) { - for (int i = 0; i < BILLBOARD_HEIGHT; i++) { - for (int j = 0; j < BILLBOARD_WIDTH; j++) { - - billboardLights[i][j] = billboardPosition + glm::vec3(j * lightScale, (float)((BILLBOARD_HEIGHT - i) * lightScale), 0); - } - } - billboardInitialized = true; - } - - ::billboardGradient += ::billboardGradientIncrement; - - if (::billboardGradient >= BILLBOARD_MAX_GRADIENT) { - ::billboardGradient = BILLBOARD_MAX_GRADIENT; - ::billboardGradientIncrement = -::billboardGradientIncrement; - } - if (::billboardGradient <= BILLBOARD_MIN_GRADIENT) { - ::billboardGradient = BILLBOARD_MIN_GRADIENT; - ::billboardGradientIncrement = -::billboardGradientIncrement; - } - - for (int i = 0; i < BILLBOARD_HEIGHT; i++) { - for (int j = 0; j < BILLBOARD_WIDTH; j++) { - - int nthVoxel = ((i * BILLBOARD_WIDTH) + j); - int item = nthVoxel % VOXELS_PER_PACKET; - - billboardLights[i][j] = billboardPosition + glm::vec3(j * lightScale, (float)((BILLBOARD_HEIGHT - i) * lightScale), 0); - - details[item].s = lightScale; - details[item].x = billboardLights[i][j].x; - details[item].y = billboardLights[i][j].y; - details[item].z = billboardLights[i][j].z; - - if (billboardMessage[i][j]) { - details[item].red = (billboardOnColorA[0] + ((billboardOnColorB[0] - billboardOnColorA[0]) * ::billboardGradient)); - details[item].green = (billboardOnColorA[1] + ((billboardOnColorB[1] - billboardOnColorA[1]) * ::billboardGradient)); - details[item].blue = (billboardOnColorA[2] + ((billboardOnColorB[2] - billboardOnColorA[2]) * ::billboardGradient)); - } else { - details[item].red = billboardOffColor[0]; - details[item].green = billboardOffColor[1]; - details[item].blue = billboardOffColor[2]; - } - - if (item == VOXELS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_PACKET, (VoxelDetail*)&details); - } - } - } -} - -bool roadInitialized = false; -const int BRICKS_ACROSS_ROAD = 32; -const float ROAD_BRICK_SIZE = 0.125f/TREE_SCALE; //(ROAD_WIDTH_METERS / TREE_SCALE) / BRICKS_ACROSS_ROAD; // in voxel units -const int ROAD_LENGTH = 1.0f / ROAD_BRICK_SIZE; // in bricks -const int ROAD_WIDTH = BRICKS_ACROSS_ROAD; // in bricks -glm::vec3 roadPosition(0.5f - (ROAD_BRICK_SIZE * BRICKS_ACROSS_ROAD), 0.0f, 0.0f); -const int BRICKS_PER_PACKET = 32; // guessing - -void doBuildStreet() { - if (roadInitialized) { - return; - } - - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - static VoxelDetail details[BRICKS_PER_PACKET]; - - for (int z = 0; z < ROAD_LENGTH; z++) { - for (int x = 0; x < ROAD_WIDTH; x++) { - - int nthVoxel = ((z * ROAD_WIDTH) + x); - int item = nthVoxel % BRICKS_PER_PACKET; - - glm::vec3 brick = roadPosition + glm::vec3(x * ROAD_BRICK_SIZE, 0, z * ROAD_BRICK_SIZE); - - details[item].s = ROAD_BRICK_SIZE; - details[item].x = brick.x; - details[item].y = brick.y; - details[item].z = brick.z; - - unsigned char randomTone = randIntInRange(118,138); - details[item].red = randomTone; - details[item].green = randomTone; - details[item].blue = randomTone; - - if (item == BRICKS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, BRICKS_PER_PACKET, (VoxelDetail*)&details); - } - } - } - roadInitialized = true; -} - - -double start = 0; - - -void* animateVoxels(void* args) { - - quint64 lastAnimateTime = 0; - quint64 lastProcessTime = 0; - int processesPerAnimate = 0; - - bool firstTime = true; - - qDebug() << "Setting PPS to " << ::packetsPerSecond; - ::voxelEditPacketSender->setPacketsPerSecond(::packetsPerSecond); - - qDebug() << "PPS set to " << ::voxelEditPacketSender->getPacketsPerSecond(); - - while (true) { - - // If we're asked to wait for voxel servers, and there isn't one available yet, then - // let the voxelEditPacketSender process and move on. - if (::waitForVoxelServer && !::voxelEditPacketSender->voxelServersExist()) { - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->process(); - } - } else { - if (firstTime) { - lastAnimateTime = usecTimestampNow(); - firstTime = false; - } - lastProcessTime = usecTimestampNow(); - - // The while loop will be running at PROCESSING_FPS, but we only want to call these animation functions at - // ANIMATE_FPS. So we check out last animate time and only call these if we've elapsed that time. - quint64 now = usecTimestampNow(); - quint64 animationElapsed = now - lastAnimateTime; - int withinAnimationTarget = ANIMATE_VOXELS_INTERVAL_USECS - animationElapsed; - const int CLOSE_ENOUGH_TO_ANIMATE = 2000; // approximately 2 ms - - int animateLoopsPerAnimate = 0; - while (withinAnimationTarget < CLOSE_ENOUGH_TO_ANIMATE) { - processesPerAnimate = 0; - animateLoopsPerAnimate++; - - lastAnimateTime = now; - // some animations - //sendVoxelBlinkMessage(); - - if (::includeBillboard) { - sendBillboard(); - } - if (::includeBorderTracer) { - sendBlinkingStringOfLights(); - } - if (::includeMovingBug) { - renderMovingBug(); - } - if (::includeBlinkingVoxel) { - sendVoxelBlinkMessage(); - } - if (::includeDanceFloor) { - sendDanceFloor(); - } - - if (::buildStreet) { - doBuildStreet(); - } - - if (animationElapsed > ANIMATE_VOXELS_INTERVAL_USECS) { - animationElapsed -= ANIMATE_VOXELS_INTERVAL_USECS; // credit ourselves one animation frame - } else { - animationElapsed = 0; - } - withinAnimationTarget = ANIMATE_VOXELS_INTERVAL_USECS - animationElapsed; - - ::voxelEditPacketSender->releaseQueuedMessages(); - } - - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->process(); - } - processesPerAnimate++; - } - // dynamically sleep until we need to fire off the next set of voxels - quint64 usecToSleep = ::PROCESSING_INTERVAL_USECS - (usecTimestampNow() - lastProcessTime); - if (usecToSleep > ::PROCESSING_INTERVAL_USECS) { - usecToSleep = ::PROCESSING_INTERVAL_USECS; - } - - if (usecToSleep > 0) { - usleep(usecToSleep); - } - } - - pthread_exit(0); -} - -AnimationServer::AnimationServer(int &argc, char **argv) : - QCoreApplication(argc, argv) -{ - ::start = usecTimestampNow(); - - NodeList* nodeList = NodeList::createInstance(NodeType::AnimationServer, ANIMATION_LISTEN_PORT); - setvbuf(stdout, NULL, _IOLBF, 0); - - // Handle Local Domain testing with the --local command line - const char* NON_THREADED_PACKETSENDER = "--NonThreadedPacketSender"; - ::nonThreadedPacketSender = cmdOptionExists(argc, (const char**) argv, NON_THREADED_PACKETSENDER); - qDebug("nonThreadedPacketSender=%s", debug::valueOf(::nonThreadedPacketSender)); - - // Handle Local Domain testing with the --local command line - const char* NO_BILLBOARD = "--NoBillboard"; - ::includeBillboard = !cmdOptionExists(argc, (const char**) argv, NO_BILLBOARD); - qDebug("includeBillboard=%s", debug::valueOf(::includeBillboard)); - - const char* NO_BORDER_TRACER = "--NoBorderTracer"; - ::includeBorderTracer = !cmdOptionExists(argc, (const char**) argv, NO_BORDER_TRACER); - qDebug("includeBorderTracer=%s", debug::valueOf(::includeBorderTracer)); - - const char* NO_MOVING_BUG = "--NoMovingBug"; - ::includeMovingBug = !cmdOptionExists(argc, (const char**) argv, NO_MOVING_BUG); - qDebug("includeMovingBug=%s", debug::valueOf(::includeMovingBug)); - - const char* INCLUDE_BLINKING_VOXEL = "--includeBlinkingVoxel"; - ::includeBlinkingVoxel = cmdOptionExists(argc, (const char**) argv, INCLUDE_BLINKING_VOXEL); - qDebug("includeBlinkingVoxel=%s", debug::valueOf(::includeBlinkingVoxel)); - - const char* NO_DANCE_FLOOR = "--NoDanceFloor"; - ::includeDanceFloor = !cmdOptionExists(argc, (const char**) argv, NO_DANCE_FLOOR); - qDebug("includeDanceFloor=%s", debug::valueOf(::includeDanceFloor)); - - const char* BUILD_STREET = "--BuildStreet"; - ::buildStreet = cmdOptionExists(argc, (const char**) argv, BUILD_STREET); - qDebug("buildStreet=%s", debug::valueOf(::buildStreet)); - - // Handle Local Domain testing with the --local command line - const char* showPPS = "--showPPS"; - ::shouldShowPacketsPerSecond = cmdOptionExists(argc, (const char**) argv, showPPS); - - // Handle Local Domain testing with the --local command line - const char* local = "--local"; - ::wantLocalDomain = cmdOptionExists(argc, (const char**) argv,local); - if (::wantLocalDomain) { - qDebug("Local Domain MODE!"); - nodeList->getDomainHandler().setIPToLocalhost(); - } - - const char* domainHostname = getCmdOption(argc, (const char**) argv, "--domain"); - if (domainHostname) { - NodeList::getInstance()->getDomainHandler().setHostname(domainHostname); - } - - const char* packetsPerSecondCommand = getCmdOption(argc, (const char**) argv, "--pps"); - if (packetsPerSecondCommand) { - ::packetsPerSecond = atoi(packetsPerSecondCommand); - } - qDebug("packetsPerSecond=%d",packetsPerSecond); - - const char* animateFPSCommand = getCmdOption(argc, (const char**) argv, "--AnimateFPS"); - const char* animateIntervalCommand = getCmdOption(argc, (const char**) argv, "--AnimateInterval"); - if (animateFPSCommand || animateIntervalCommand) { - if (animateIntervalCommand) { - ::ANIMATE_FPS_IN_MILLISECONDS = atoi(animateIntervalCommand); - ::ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000.0); // converts from milliseconds to usecs - ::ANIMATE_FPS = PacketSender::USECS_PER_SECOND / ::ANIMATE_VOXELS_INTERVAL_USECS; - } else { - ::ANIMATE_FPS = atoi(animateFPSCommand); - ::ANIMATE_FPS_IN_MILLISECONDS = 1000.0/ANIMATE_FPS; // determines FPS from our desired FPS - ::ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000.0); // converts from milliseconds to usecs - } - } - qDebug("ANIMATE_FPS=%d",ANIMATE_FPS); - qDebug("ANIMATE_VOXELS_INTERVAL_USECS=%llu",ANIMATE_VOXELS_INTERVAL_USECS); - - const char* processingFPSCommand = getCmdOption(argc, (const char**) argv, "--ProcessingFPS"); - const char* processingIntervalCommand = getCmdOption(argc, (const char**) argv, "--ProcessingInterval"); - if (processingFPSCommand || processingIntervalCommand) { - if (processingIntervalCommand) { - ::PROCESSING_FPS_IN_MILLISECONDS = atoi(processingIntervalCommand); - ::PROCESSING_INTERVAL_USECS = ::PROCESSING_FPS_IN_MILLISECONDS * 1000.0; - ::PROCESSING_FPS = PacketSender::USECS_PER_SECOND / ::PROCESSING_INTERVAL_USECS; - } else { - ::PROCESSING_FPS = atoi(processingFPSCommand); - ::PROCESSING_FPS_IN_MILLISECONDS = 1000.0/PROCESSING_FPS; // determines FPS from our desired FPS - ::PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000.0) - FUDGE_USECS; // converts from milliseconds to usecs - } - } - qDebug("PROCESSING_FPS=%d",PROCESSING_FPS); - qDebug("PROCESSING_INTERVAL_USECS=%llu",PROCESSING_INTERVAL_USECS); - - nodeList->linkedDataCreateCallback = NULL; // do we need a callback? - - // Create our JurisdictionListener so we'll know where to send edit packets - ::jurisdictionListener = new JurisdictionListener(); - if (::jurisdictionListener) { - ::jurisdictionListener->initialize(true); - } - - // Create out VoxelEditPacketSender - ::voxelEditPacketSender = new VoxelEditPacketSender; - ::voxelEditPacketSender->initialize(!::nonThreadedPacketSender); - - if (::jurisdictionListener) { - ::voxelEditPacketSender->setVoxelServerJurisdictions(::jurisdictionListener->getJurisdictions()); - } - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->setProcessCallIntervalHint(PROCESSING_INTERVAL_USECS); - } - - srand((unsigned)time(0)); - - - pthread_create(&::animateVoxelThread, NULL, animateVoxels, NULL); - - NodeList::getInstance()->addNodeTypeToInterestSet(NodeType::VoxelServer); - - QTimer* domainServerTimer = new QTimer(this); - connect(domainServerTimer, SIGNAL(timeout()), nodeList, SLOT(sendDomainServerCheckIn())); - domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); - - QTimer* silentNodeTimer = new QTimer(this); - connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); - silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS); - - connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(readPendingDatagrams())); -} - -void AnimationServer::readPendingDatagrams() { - NodeList* nodeList = NodeList::getInstance(); - - static QByteArray receivedPacket; - static HifiSockAddr nodeSockAddr; - - // Nodes sending messages to us... - while (nodeList->getNodeSocket().hasPendingDatagrams()) { - receivedPacket.resize(nodeList->getNodeSocket().pendingDatagramSize()); - nodeList->getNodeSocket().readDatagram(receivedPacket.data(), receivedPacket.size(), - nodeSockAddr.getAddressPointer(), nodeSockAddr.getPortPointer()); - if (nodeList->packetVersionAndHashMatch(receivedPacket)) { - if (packetTypeForPacket(receivedPacket) == PacketTypeJurisdiction) { - int headerBytes = numBytesForPacketHeader(receivedPacket); - // PacketType_JURISDICTION, first byte is the node type... - if (receivedPacket.data()[headerBytes] == NodeType::VoxelServer && ::jurisdictionListener) { - - SharedNodePointer matchedNode = NodeList::getInstance()->sendingNodeForPacket(receivedPacket); - if (matchedNode) { - ::jurisdictionListener->queueReceivedPacket(matchedNode, receivedPacket); - } - } - } - NodeList::getInstance()->processNodeData(nodeSockAddr, receivedPacket); - } - } -} - -AnimationServer::~AnimationServer() { - pthread_join(animateVoxelThread, NULL); - - if (::jurisdictionListener) { - ::jurisdictionListener->terminate(); - delete ::jurisdictionListener; - } - - if (::voxelEditPacketSender) { - ::voxelEditPacketSender->terminate(); - delete ::voxelEditPacketSender; - } -} diff --git a/animation-server/src/AnimationServer.h b/animation-server/src/AnimationServer.h deleted file mode 100644 index 58f05c32c5..0000000000 --- a/animation-server/src/AnimationServer.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// AnimationServer.h -// animation-server/src -// -// Created by Stephen Birarda on 12/5/2013. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_AnimationServer_h -#define hifi_AnimationServer_h - -#include - -class AnimationServer : public QCoreApplication { - Q_OBJECT -public: - AnimationServer(int &argc, char **argv); - ~AnimationServer(); -private slots: - void readPendingDatagrams(); -}; - - -#endif // hifi_AnimationServer_h diff --git a/animation-server/src/main.cpp b/animation-server/src/main.cpp deleted file mode 100644 index 8acf3b8db2..0000000000 --- a/animation-server/src/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.cpp -// animation-server/src -// -// Created by Brad Hefta-Gaub on 05/16/2013. -// Copyright 2012 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "AnimationServer.h" - -int main(int argc, char * argv[]) { - AnimationServer animationServer(argc, argv); - return animationServer.exec(); -} From 64699a213a7088274f78b452718f6a42947e7859 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 7 Aug 2014 14:48:51 -0700 Subject: [PATCH 15/94] remove animation server --- CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dbc89b75f..578c36841d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,11 +44,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -# targets not supported on windows -if (NOT WIN32) - add_subdirectory(animation-server) -endif () - # targets on all platforms add_subdirectory(assignment-client) add_subdirectory(domain-server) From 4e1886dfcbbcfc28d06a190f83c7a03c962f27eb Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 7 Aug 2014 15:04:55 -0700 Subject: [PATCH 16/94] Divided when I should have multiplied. --- interface/src/ui/MetavoxelEditor.cpp | 3 +-- libraries/metavoxels/src/MetavoxelClientManager.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index a5186567bd..01b5ad0718 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1104,7 +1104,6 @@ void HeightfieldBrushTool::render() { if (!Application::getInstance()->getMetavoxels()->findFirstRayHeightfieldIntersection(origin, direction, distance)) { return; } - qDebug() << distance; glm::vec3 point = origin + distance * direction; glPushMatrix(); @@ -1112,7 +1111,7 @@ void HeightfieldBrushTool::render() { glColor4f(1.0f, 0.0f, 0.0f, 1.0f); - glutSolidSphere(0.1f, 8, 8); + glutSolidSphere(1.0f, 8, 8); glPopMatrix(); } diff --git a/libraries/metavoxels/src/MetavoxelClientManager.cpp b/libraries/metavoxels/src/MetavoxelClientManager.cpp index a9eff58f33..0ffdefd134 100644 --- a/libraries/metavoxels/src/MetavoxelClientManager.cpp +++ b/libraries/metavoxels/src/MetavoxelClientManager.cpp @@ -92,7 +92,7 @@ int RayHeightfieldIntersectionVisitor::visit(MetavoxelInfo& info, float distance const uchar* src = (const uchar*)contents.constData(); int size = glm::sqrt((float)contents.size()); int highest = size - 1; - float heightScale = highest / EIGHT_BIT_MAXIMUM_RECIPROCAL; + float heightScale = highest * EIGHT_BIT_MAXIMUM_RECIPROCAL; // find the initial location in heightfield coordinates glm::vec3 entry = (_origin + distance * _direction - info.minimum) * (float)highest / info.size; From 84f3ede32f04acdba5ed09feeb9544c256844e56 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 7 Aug 2014 15:09:24 -0700 Subject: [PATCH 17/94] small change to force rebuild --- libraries/shared/src/SharedUtil.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index 18494d48e4..4a9de2cc18 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -191,4 +191,5 @@ QByteArray createByteArray(const glm::vec3& vector); QString formatUsecTime(float usecs, int prec = 3); + #endif // hifi_SharedUtil_h From 9a55252587f1c02fe5fa88ce8e88c55e8aabf46f Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 7 Aug 2014 17:02:28 -0700 Subject: [PATCH 18/94] remove extraneous roots from Model::_jointStates --- interface/src/avatar/SkeletonModel.cpp | 24 +++++++--------- interface/src/renderer/Model.cpp | 40 ++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 6b77e1c2f1..f759dc99a3 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -515,9 +515,9 @@ void SkeletonModel::initRagdollPoints() { initRagdollTransform(); // one point for each joint - int numJoints = _jointStates.size(); - _ragdollPoints.fill(VerletPoint(), numJoints); - for (int i = 0; i < numJoints; ++i) { + int numStates = _jointStates.size(); + _ragdollPoints.fill(VerletPoint(), numStates); + for (int i = 0; i < numStates; ++i) { const JointState& state = _jointStates.at(i); // _ragdollPoints start in model-frame _ragdollPoints[i].initPosition(state.getPosition()); @@ -719,8 +719,8 @@ void SkeletonModel::buildShapes() { // ... then move shapes back to current joint positions if (_ragdollPoints.size() == numStates) { - int numJoints = _jointStates.size(); - for (int i = 0; i < numJoints; ++i) { + int numStates = _jointStates.size(); + for (int i = 0; i < numStates; ++i) { // ragdollPoints start in model-frame _ragdollPoints[i].initPosition(_jointStates.at(i).getPosition()); } @@ -765,17 +765,15 @@ void SkeletonModel::updateMuscles() { void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) { // compute default joint transforms - int numJoints = geometry.joints.size(); - if (numJoints != _ragdollPoints.size()) { - return; - } + int numStates = _jointStates.size(); QVector transforms; - transforms.fill(glm::mat4(), numJoints); + transforms.fill(glm::mat4(), numStates); // compute the default transforms and slam the ragdoll positions accordingly // (which puts the shapes where we want them) - for (int i = 0; i < numJoints; i++) { - const FBXJoint& joint = geometry.joints.at(i); + for (int i = 0; i < numStates; i++) { + JointState& state = _jointStates[i]; + const FBXJoint& joint = state.getFBXJoint(); int parentIndex = joint.parentIndex; if (parentIndex == -1) { transforms[i] = _jointStates[i].getTransform(); @@ -847,7 +845,7 @@ void SkeletonModel::resetShapePositionsToDefaultPose() { } const FBXGeometry& geometry = _geometry->getFBXGeometry(); - if (geometry.joints.isEmpty() || _shapes.size() != geometry.joints.size()) { + if (geometry.joints.isEmpty()) { return; } diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 025971db4b..73b65b6d41 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -188,10 +188,38 @@ void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locati QVector Model::createJointStates(const FBXGeometry& geometry) { QVector jointStates; - foreach (const FBXJoint& joint, geometry.joints) { - // NOTE: the state keeps a pointer to an FBXJoint + QVector roots; + roots.fill(-1, geometry.joints.size()); + for (int i = 0; i < geometry.joints.size(); ++i) { + const FBXJoint& joint = geometry.joints[i]; + int parentIndex = joint.parentIndex; + + // Some models may have multiple roots (?!), but these are causing problems in + // the Avatar Ragdoll simulation, so we prune them out of the JointState tree. + int rootIndex = 0; + if (parentIndex == -1) { + if (i != 0) { + // skip other root + continue; + } + } else { + rootIndex = roots[parentIndex]; + if (rootIndex == -1) { + roots[i] = parentIndex; + rootIndex = parentIndex; + } else { + roots[i] = rootIndex; + } + if (rootIndex != 0) { + // skip child of other root + continue; + } + } + + // store a pointer to the FBXJoint in the JointState JointState state; state.setFBXJoint(&joint); + jointStates.append(state); } return jointStates; @@ -199,8 +227,8 @@ QVector Model::createJointStates(const FBXGeometry& geometry) { void Model::initJointTransforms() { // compute model transforms - int numJoints = _jointStates.size(); - for (int i = 0; i < numJoints; ++i) { + int numStates = _jointStates.size(); + for (int i = 0; i < numStates; ++i) { JointState& state = _jointStates[i]; const FBXJoint& joint = state.getFBXJoint(); int parentIndex = joint.parentIndex; @@ -538,9 +566,9 @@ void Model::setJointStates(QVector states) { _jointStates = states; initJointTransforms(); - int numJoints = _jointStates.size(); + int numStates = _jointStates.size(); float radius = 0.0f; - for (int i = 0; i < numJoints; ++i) { + for (int i = 0; i < numStates; ++i) { float distance = glm::length(_jointStates[i].getPosition()); if (distance > radius) { radius = distance; From 0fc34a47aacdfcec1480dd8c91fc9d30e20adcb8 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 7 Aug 2014 18:19:58 -0700 Subject: [PATCH 19/94] Show heightfield cursor. --- .../shaders/metavoxel_heightfield_cursor.frag | 20 +++ .../shaders/metavoxel_heightfield_cursor.vert | 31 ++++ interface/src/MetavoxelSystem.cpp | 140 +++++++++++++++++- interface/src/MetavoxelSystem.h | 19 ++- interface/src/ui/MetavoxelEditor.cpp | 10 +- .../metavoxels/src/MetavoxelClientManager.cpp | 6 +- 6 files changed, 204 insertions(+), 22 deletions(-) create mode 100644 interface/resources/shaders/metavoxel_heightfield_cursor.frag create mode 100644 interface/resources/shaders/metavoxel_heightfield_cursor.vert diff --git a/interface/resources/shaders/metavoxel_heightfield_cursor.frag b/interface/resources/shaders/metavoxel_heightfield_cursor.frag new file mode 100644 index 0000000000..20efc51e08 --- /dev/null +++ b/interface/resources/shaders/metavoxel_heightfield_cursor.frag @@ -0,0 +1,20 @@ +#version 120 + +// +// metavoxel_heightfield_cursor.frag +// fragment shader +// +// Created by Andrzej Kapolka on 8/7/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +// the cursor texture +uniform sampler2D cursorMap; + +void main(void) { + // just multiply the color by the cursor texture + gl_FragColor = gl_Color * texture2D(cursorMap, gl_TexCoord[0].st); +} diff --git a/interface/resources/shaders/metavoxel_heightfield_cursor.vert b/interface/resources/shaders/metavoxel_heightfield_cursor.vert new file mode 100644 index 0000000000..20502fbdce --- /dev/null +++ b/interface/resources/shaders/metavoxel_heightfield_cursor.vert @@ -0,0 +1,31 @@ +#version 120 + +// +// metavoxel_heighfield_cursor.vert +// vertex shader +// +// Created by Andrzej Kapolka on 8/7/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +// the height texture +uniform sampler2D heightMap; + +// the distance between height points in texture space +uniform float heightScale; + +void main(void) { + // compute the view space coordinates + float height = texture2D(heightMap, gl_MultiTexCoord0.st).r; + vec4 viewPosition = gl_ModelViewMatrix * (gl_Vertex + vec4(0.0, height, 0.0, 0.0)); + gl_Position = gl_ProjectionMatrix * viewPosition; + + // generate the texture coordinates from the view position + gl_TexCoord[0] = vec4(dot(viewPosition, gl_EyePlaneS[4]), dot(viewPosition, gl_EyePlaneT[4]), 0.0, 1.0); + + // the zero height should be invisible + gl_FrontColor = vec4(1.0, 1.0, 1.0, 1.0 - step(height, 0.0)); +} diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index f66d71070a..85a1f5a1fc 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -31,6 +31,10 @@ REGISTER_META_OBJECT(StaticModelRenderer) static int bufferPointVectorMetaTypeId = qRegisterMetaType(); +MetavoxelSystem::MetavoxelSystem() : + _cursorTexture(QOpenGLTexture::Target2D) { +} + void MetavoxelSystem::init() { MetavoxelClientManager::init(); DefaultMetavoxelRendererImplementation::init(); @@ -118,6 +122,105 @@ void MetavoxelSystem::render() { guideToAugmented(renderVisitor); } +class HeightfieldCursorRenderVisitor : public MetavoxelVisitor { +public: + + HeightfieldCursorRenderVisitor(const MetavoxelLOD& lod, const Box& bounds); + + virtual int visit(MetavoxelInfo& info); + +private: + + Box _bounds; +}; + +HeightfieldCursorRenderVisitor::HeightfieldCursorRenderVisitor(const MetavoxelLOD& lod, const Box& bounds) : + MetavoxelVisitor(QVector() << + Application::getInstance()->getMetavoxels()->getHeightfieldBufferAttribute(), QVector(), lod), + _bounds(bounds) { +} + +int HeightfieldCursorRenderVisitor::visit(MetavoxelInfo& info) { + if (!info.getBounds().intersects(_bounds)) { + return STOP_RECURSION; + } + if (!info.isLeaf) { + return DEFAULT_ORDER; + } + BufferDataPointer buffer = info.inputValues.at(0).getInlineValue(); + if (buffer) { + buffer->render(true); + } + return STOP_RECURSION; +} + +void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float radius) { + // create the cursor texture lazily + if (!_cursorTexture.isCreated()) { + const int CURSOR_TEXTURE_SIZE = 512; + QImage cursorImage(CURSOR_TEXTURE_SIZE, CURSOR_TEXTURE_SIZE, QImage::Format_ARGB32_Premultiplied); + cursorImage.fill(0x0); + { + QPainter painter(&cursorImage); + const int ELLIPSE_EDGE = 10; + const int OUTER_WIDTH = 10; + QPen outerPen; + outerPen.setWidth(OUTER_WIDTH); + painter.setPen(outerPen); + const int HALF_TEXTURE_SIZE = CURSOR_TEXTURE_SIZE / 2; + painter.drawEllipse(QPoint(HALF_TEXTURE_SIZE, HALF_TEXTURE_SIZE), HALF_TEXTURE_SIZE - ELLIPSE_EDGE, + HALF_TEXTURE_SIZE - ELLIPSE_EDGE); + QPen innerPen(Qt::white); + const int INNER_WIDTH = 6; + innerPen.setWidth(INNER_WIDTH); + painter.setPen(innerPen); + painter.drawEllipse(QPoint(HALF_TEXTURE_SIZE, HALF_TEXTURE_SIZE), HALF_TEXTURE_SIZE - ELLIPSE_EDGE, + HALF_TEXTURE_SIZE - ELLIPSE_EDGE); + } + _cursorTexture.setData(cursorImage, QOpenGLTexture::DontGenerateMipMaps); + _cursorTexture.setWrapMode(QOpenGLTexture::ClampToEdge); + _cursorTexture.setMinificationFilter(QOpenGLTexture::Linear); + } + + glDepthFunc(GL_LEQUAL); + glEnable(GL_CULL_FACE); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -1.0f); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().bind(); + + glActiveTexture(GL_TEXTURE4); + float scale = 1.0f / radius; + glm::vec4 sCoefficients(scale, 0.0f, 0.0f, 0.5f - scale * position.x); + glm::vec4 tCoefficients(0.0f, 0.0f, scale, 0.5f - scale * position.z); + glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients); + glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients); + + _cursorTexture.bind(1); + glActiveTexture(GL_TEXTURE0); + + glm::vec3 extents(radius, radius, radius); + HeightfieldCursorRenderVisitor visitor(getLOD(), Box(position - extents, position + extents)); + guideToAugmented(visitor); + + _cursorTexture.release(1); + glActiveTexture(GL_TEXTURE0); + + DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().release(); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + + glDisable(GL_POLYGON_OFFSET_FILL); + glDisable(GL_CULL_FACE); + glDepthFunc(GL_LESS); +} + void MetavoxelSystem::deleteTextures(int heightID, int colorID) { glDeleteTextures(1, (GLuint*)&heightID); glDeleteTextures(1, (GLuint*)&colorID); @@ -239,7 +342,7 @@ PointBuffer::PointBuffer(const BufferPointVector& points) : _points(points) { } -void PointBuffer::render() { +void PointBuffer::render(bool cursor) { // initialize buffer, etc. on first render if (!_buffer.isCreated()) { _buffer.setUsagePattern(QOpenGLBuffer::StaticDraw); @@ -294,7 +397,7 @@ public: glm::vec3 vertex; }; -void HeightfieldBuffer::render() { +void HeightfieldBuffer::render(bool cursor) { // initialize textures, etc. on first render if (_heightTextureID == 0) { glGenTextures(1, &_heightTextureID); @@ -385,17 +488,24 @@ void HeightfieldBuffer::render() { glBindTexture(GL_TEXTURE_2D, _heightTextureID); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, _colorTextureID); + int heightScaleLocation; + if (cursor) { + heightScaleLocation = DefaultMetavoxelRendererImplementation::getCursorHeightScaleLocation(); + } else { + heightScaleLocation = DefaultMetavoxelRendererImplementation::getHeightScaleLocation(); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, _colorTextureID); + } - DefaultMetavoxelRendererImplementation::getHeightfieldProgram().setUniformValue( - DefaultMetavoxelRendererImplementation::getHeightScaleLocation(), 1.0f / _heightSize); + DefaultMetavoxelRendererImplementation::getHeightfieldProgram().setUniformValue(heightScaleLocation, 1.0f / _heightSize); glDrawRangeElements(GL_QUADS, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0); - glBindTexture(GL_TEXTURE_2D, 0); + if (!cursor) { + glBindTexture(GL_TEXTURE_2D, 0); + glActiveTexture(GL_TEXTURE0); + } - glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); glPopMatrix(); @@ -475,6 +585,18 @@ void DefaultMetavoxelRendererImplementation::init() { _heightfieldProgram.setUniformValue("diffuseMap", 1); _heightScaleLocation = _heightfieldProgram.uniformLocation("heightScale"); _heightfieldProgram.release(); + + _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + + "shaders/metavoxel_heightfield_cursor.vert"); + _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + + "shaders/metavoxel_heightfield_cursor.frag"); + _heightfieldCursorProgram.link(); + + _heightfieldCursorProgram.bind(); + _heightfieldCursorProgram.setUniformValue("heightMap", 0); + _heightfieldCursorProgram.setUniformValue("cursorMap", 1); + _cursorHeightScaleLocation = _heightfieldCursorProgram.uniformLocation("heightScale"); + _heightfieldCursorProgram.release(); } } @@ -771,6 +893,8 @@ ProgramObject DefaultMetavoxelRendererImplementation::_pointProgram; int DefaultMetavoxelRendererImplementation::_pointScaleLocation; ProgramObject DefaultMetavoxelRendererImplementation::_heightfieldProgram; int DefaultMetavoxelRendererImplementation::_heightScaleLocation; +ProgramObject DefaultMetavoxelRendererImplementation::_heightfieldCursorProgram; +int DefaultMetavoxelRendererImplementation::_cursorHeightScaleLocation; static void enableClipPlane(GLenum plane, float x, float y, float z, float w) { GLdouble coefficients[] = { x, y, z, w }; diff --git a/interface/src/MetavoxelSystem.h b/interface/src/MetavoxelSystem.h index e7ee0d2c18..a2d3128cb7 100644 --- a/interface/src/MetavoxelSystem.h +++ b/interface/src/MetavoxelSystem.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -31,6 +32,8 @@ class MetavoxelSystem : public MetavoxelClientManager { public: + MetavoxelSystem(); + virtual void init(); virtual MetavoxelLOD getLOD(); @@ -43,6 +46,8 @@ public: void simulate(float deltaTime); void render(); + void renderHeightfieldCursor(const glm::vec3& position, float radius); + Q_INVOKABLE void deleteTextures(int heightID, int colorID); protected: @@ -59,6 +64,8 @@ private: MetavoxelLOD _lod; QReadWriteLock _lodLock; Frustum _frustum; + + QOpenGLTexture _cursorTexture; }; /// Describes contents of a point in a point buffer. @@ -105,7 +112,7 @@ public: virtual ~BufferData(); - virtual void render() = 0; + virtual void render(bool cursor = false) = 0; }; typedef QExplicitlySharedDataPointer BufferDataPointer; @@ -116,7 +123,7 @@ public: PointBuffer(const BufferPointVector& points); - virtual void render(); + virtual void render(bool cursor = false); private: @@ -140,7 +147,7 @@ public: const QByteArray& getHeight() const { return _height; } const QByteArray& getColor() const { return _color; } - virtual void render(); + virtual void render(bool cursor = false); private: @@ -193,6 +200,9 @@ public: static ProgramObject& getHeightfieldProgram() { return _heightfieldProgram; } static int getHeightScaleLocation() { return _heightScaleLocation; } + static ProgramObject& getHeightfieldCursorProgram() { return _heightfieldCursorProgram; } + static int getCursorHeightScaleLocation() { return _cursorHeightScaleLocation; } + Q_INVOKABLE DefaultMetavoxelRendererImplementation(); virtual void augment(MetavoxelData& data, const MetavoxelData& previous, MetavoxelInfo& info, const MetavoxelLOD& lod); @@ -206,6 +216,9 @@ private: static ProgramObject _heightfieldProgram; static int _heightScaleLocation; + + static ProgramObject _heightfieldCursorProgram; + static int _cursorHeightScaleLocation; }; /// Base class for spanner renderers; provides clipping. diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 01b5ad0718..28a4d6da27 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1105,15 +1105,7 @@ void HeightfieldBrushTool::render() { return; } glm::vec3 point = origin + distance * direction; - - glPushMatrix(); - glTranslatef(point.x, point.y, point.z); - - glColor4f(1.0f, 0.0f, 0.0f, 1.0f); - - glutSolidSphere(1.0f, 8, 8); - - glPopMatrix(); + Application::getInstance()->getMetavoxels()->renderHeightfieldCursor(point, _radius->value()); } HeightBrushTool::HeightBrushTool(MetavoxelEditor* editor) : diff --git a/libraries/metavoxels/src/MetavoxelClientManager.cpp b/libraries/metavoxels/src/MetavoxelClientManager.cpp index 0ffdefd134..70b574d2a2 100644 --- a/libraries/metavoxels/src/MetavoxelClientManager.cpp +++ b/libraries/metavoxels/src/MetavoxelClientManager.cpp @@ -194,7 +194,8 @@ int RayHeightfieldIntersectionVisitor::visit(MetavoxelInfo& info, float distance glm::vec3 intersection = relativeEntry + planeDistance * _direction; if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && intersection.z >= intersection.x) { - intersectionDistance = distance + (accumulatedDistance + planeDistance) * (info.size / highest); + intersectionDistance = qMin(intersectionDistance, distance + + (accumulatedDistance + planeDistance) * (info.size / highest)); return SHORT_CIRCUIT; } } @@ -207,7 +208,8 @@ int RayHeightfieldIntersectionVisitor::visit(MetavoxelInfo& info, float distance glm::vec3 intersection = relativeEntry + planeDistance * _direction; if (intersection.x >= 0.0f && intersection.x <= 1.0f && intersection.z >= 0.0f && intersection.z <= 1.0f && intersection.x >= intersection.z) { - intersectionDistance = distance + (accumulatedDistance + planeDistance) * (info.size / highest); + intersectionDistance = qMin(intersectionDistance, distance + + (accumulatedDistance + planeDistance) * (info.size / highest)); return SHORT_CIRCUIT; } } From 6930174a9ecc9b4adf0846d13c38cfe2160deb47 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 7 Aug 2014 18:30:33 -0700 Subject: [PATCH 20/94] Hide the cursor when the mouse pointer is hidden. --- interface/src/ui/MetavoxelEditor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 28a4d6da27..48fa2ed070 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1096,6 +1096,10 @@ HeightfieldBrushTool::HeightfieldBrushTool(MetavoxelEditor* editor, const QStrin } void HeightfieldBrushTool::render() { + if (Application::getInstance()->isMouseHidden()) { + return; + } + // find the intersection with the heightfield glm::vec3 origin = Application::getInstance()->getMouseRayOrigin(); glm::vec3 direction = Application::getInstance()->getMouseRayDirection(); From 5de762361a70f12e560eb12ae6c1f12c22abc447 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 8 Aug 2014 08:20:42 -0700 Subject: [PATCH 21/94] remove cleanup of Model::_jointStates tree the cleanup causes crashes and broken models --- interface/src/renderer/Model.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 73b65b6d41..a915406f8e 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -188,34 +188,8 @@ void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locati QVector Model::createJointStates(const FBXGeometry& geometry) { QVector jointStates; - QVector roots; - roots.fill(-1, geometry.joints.size()); for (int i = 0; i < geometry.joints.size(); ++i) { const FBXJoint& joint = geometry.joints[i]; - int parentIndex = joint.parentIndex; - - // Some models may have multiple roots (?!), but these are causing problems in - // the Avatar Ragdoll simulation, so we prune them out of the JointState tree. - int rootIndex = 0; - if (parentIndex == -1) { - if (i != 0) { - // skip other root - continue; - } - } else { - rootIndex = roots[parentIndex]; - if (rootIndex == -1) { - roots[i] = parentIndex; - rootIndex = parentIndex; - } else { - roots[i] = rootIndex; - } - if (rootIndex != 0) { - // skip child of other root - continue; - } - } - // store a pointer to the FBXJoint in the JointState JointState state; state.setFBXJoint(&joint); From bcb0cb2c3c09ea77d0c3f85d7f0c6bc959c2afb6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 8 Aug 2014 08:26:25 -0700 Subject: [PATCH 22/94] fix bug: variable should be float rather than int --- interface/src/avatar/MyAvatar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 0b940dc3df..f59064732c 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -206,7 +206,7 @@ void MyAvatar::simulate(float deltaTime) { { PerformanceTimer perfTimer("ragdoll"); if (Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll)) { - const int minError = 0.01f; + const float minError = 0.01f; const float maxIterations = 10; const quint64 maxUsec = 2000; _physicsSimulation.setTranslation(_position); From 05318acc7f4472d6e8e40449586c596b3b82ddf6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 8 Aug 2014 08:37:28 -0700 Subject: [PATCH 23/94] don't make shapes for joints with zero radius --- interface/src/avatar/SkeletonModel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index f759dc99a3..5e593526be 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -685,6 +685,9 @@ void SkeletonModel::buildShapes() { // this shape is forced to be a sphere type = Shape::SPHERE_SHAPE; } + if (radius < EPSILON) { + type = Shape::UNKNOWN_SHAPE; + } Shape* shape = NULL; int parentIndex = joint.parentIndex; if (type == Shape::SPHERE_SHAPE) { @@ -699,7 +702,9 @@ void SkeletonModel::buildShapes() { } if (parentIndex != -1) { // always disable collisions between joint and its parent - disableCollisions(i, parentIndex); + if (shape) { + disableCollisions(i, parentIndex); + } } else { // give the base joint a very large mass since it doesn't actually move // in the local-frame simulation (it defines the origin) From b7b1b018eedc7e79b21d7d9b27bedbf907ec28b4 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 8 Aug 2014 11:24:57 -0700 Subject: [PATCH 24/94] No need to use a texture for the cursor; we can just use a fragment shader. --- .../shaders/metavoxel_heightfield_cursor.frag | 20 ++++++++-- interface/src/MetavoxelSystem.cpp | 40 +------------------ interface/src/MetavoxelSystem.h | 5 --- 3 files changed, 18 insertions(+), 47 deletions(-) diff --git a/interface/resources/shaders/metavoxel_heightfield_cursor.frag b/interface/resources/shaders/metavoxel_heightfield_cursor.frag index 20efc51e08..0bb5e21e7d 100644 --- a/interface/resources/shaders/metavoxel_heightfield_cursor.frag +++ b/interface/resources/shaders/metavoxel_heightfield_cursor.frag @@ -11,10 +11,22 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// the cursor texture -uniform sampler2D cursorMap; +// the inner radius of the outline, squared +const float SQUARED_OUTLINE_INNER_RADIUS = 0.81; + +// the outer radius of the outline, squared +const float SQUARED_OUTLINE_OUTER_RADIUS = 1.0; + +// the inner radius of the inset, squared +const float SQUARED_INSET_INNER_RADIUS = 0.855625; + +// the outer radius of the inset, squared +const float SQUARED_INSET_OUTER_RADIUS = 0.950625; void main(void) { - // just multiply the color by the cursor texture - gl_FragColor = gl_Color * texture2D(cursorMap, gl_TexCoord[0].st); + // use the distance to compute the ring color, then multiply it by the varying color + float squaredDistance = dot(gl_TexCoord[0].st, gl_TexCoord[0].st); + float alpha = step(SQUARED_OUTLINE_INNER_RADIUS, squaredDistance) * step(squaredDistance, SQUARED_OUTLINE_OUTER_RADIUS); + float white = step(SQUARED_INSET_INNER_RADIUS, squaredDistance) * step(squaredDistance, SQUARED_INSET_OUTER_RADIUS); + gl_FragColor = gl_Color * vec4(white, white, white, alpha); } diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index 85a1f5a1fc..f62a85025b 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -31,10 +31,6 @@ REGISTER_META_OBJECT(StaticModelRenderer) static int bufferPointVectorMetaTypeId = qRegisterMetaType(); -MetavoxelSystem::MetavoxelSystem() : - _cursorTexture(QOpenGLTexture::Target2D) { -} - void MetavoxelSystem::init() { MetavoxelClientManager::init(); DefaultMetavoxelRendererImplementation::init(); @@ -155,33 +151,6 @@ int HeightfieldCursorRenderVisitor::visit(MetavoxelInfo& info) { } void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float radius) { - // create the cursor texture lazily - if (!_cursorTexture.isCreated()) { - const int CURSOR_TEXTURE_SIZE = 512; - QImage cursorImage(CURSOR_TEXTURE_SIZE, CURSOR_TEXTURE_SIZE, QImage::Format_ARGB32_Premultiplied); - cursorImage.fill(0x0); - { - QPainter painter(&cursorImage); - const int ELLIPSE_EDGE = 10; - const int OUTER_WIDTH = 10; - QPen outerPen; - outerPen.setWidth(OUTER_WIDTH); - painter.setPen(outerPen); - const int HALF_TEXTURE_SIZE = CURSOR_TEXTURE_SIZE / 2; - painter.drawEllipse(QPoint(HALF_TEXTURE_SIZE, HALF_TEXTURE_SIZE), HALF_TEXTURE_SIZE - ELLIPSE_EDGE, - HALF_TEXTURE_SIZE - ELLIPSE_EDGE); - QPen innerPen(Qt::white); - const int INNER_WIDTH = 6; - innerPen.setWidth(INNER_WIDTH); - painter.setPen(innerPen); - painter.drawEllipse(QPoint(HALF_TEXTURE_SIZE, HALF_TEXTURE_SIZE), HALF_TEXTURE_SIZE - ELLIPSE_EDGE, - HALF_TEXTURE_SIZE - ELLIPSE_EDGE); - } - _cursorTexture.setData(cursorImage, QOpenGLTexture::DontGenerateMipMaps); - _cursorTexture.setWrapMode(QOpenGLTexture::ClampToEdge); - _cursorTexture.setMinificationFilter(QOpenGLTexture::Linear); - } - glDepthFunc(GL_LEQUAL); glEnable(GL_CULL_FACE); glEnable(GL_POLYGON_OFFSET_FILL); @@ -196,21 +165,16 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r glActiveTexture(GL_TEXTURE4); float scale = 1.0f / radius; - glm::vec4 sCoefficients(scale, 0.0f, 0.0f, 0.5f - scale * position.x); - glm::vec4 tCoefficients(0.0f, 0.0f, scale, 0.5f - scale * position.z); + glm::vec4 sCoefficients(scale, 0.0f, 0.0f, -scale * position.x); + glm::vec4 tCoefficients(0.0f, 0.0f, scale, -scale * position.z); glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients); glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients); - - _cursorTexture.bind(1); glActiveTexture(GL_TEXTURE0); glm::vec3 extents(radius, radius, radius); HeightfieldCursorRenderVisitor visitor(getLOD(), Box(position - extents, position + extents)); guideToAugmented(visitor); - _cursorTexture.release(1); - glActiveTexture(GL_TEXTURE0); - DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().release(); glDisableClientState(GL_TEXTURE_COORD_ARRAY); diff --git a/interface/src/MetavoxelSystem.h b/interface/src/MetavoxelSystem.h index a2d3128cb7..7b681ff3a9 100644 --- a/interface/src/MetavoxelSystem.h +++ b/interface/src/MetavoxelSystem.h @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -32,8 +31,6 @@ class MetavoxelSystem : public MetavoxelClientManager { public: - MetavoxelSystem(); - virtual void init(); virtual MetavoxelLOD getLOD(); @@ -64,8 +61,6 @@ private: MetavoxelLOD _lod; QReadWriteLock _lodLock; Frustum _frustum; - - QOpenGLTexture _cursorTexture; }; /// Describes contents of a point in a point buffer. From 45afce48f748ccfdd80088b98befc88213d91b72 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 11:29:13 -0700 Subject: [PATCH 25/94] remember old session UUID in AvatarHashMap to work around ghosting --- interface/src/Application.cpp | 3 +- libraries/avatars/src/AvatarData.h | 2 +- libraries/avatars/src/AvatarHashMap.cpp | 30 ++++++++++++++------ libraries/avatars/src/AvatarHashMap.h | 8 ++++-- libraries/networking/src/LimitedNodeList.cpp | 2 +- libraries/networking/src/LimitedNodeList.h | 2 +- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7eb087c531..6f7212e68f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -261,8 +261,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); - connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle); - connect(nodeList, SIGNAL(uuidChanged(const QUuid&)), _myAvatar, SLOT(setSessionUUID(const QUuid&))); + connect(nodeList, &NodeList::uuidChanged, _myAvatar, &MyAvatar::setSessionUUID); connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset); // connect to appropriate slots on AccountManager diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 2971598c1d..a4bb0d48bb 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -290,7 +290,7 @@ public slots: void sendBillboardPacket(); void setBillboardFromNetworkReply(); void setJointMappingsFromNetworkReply(); - void setSessionUUID(const QUuid& id) { _sessionUUID = id; } + void setSessionUUID(const QUuid& sessionUUID) { _sessionUUID = sessionUUID; } bool hasReferential(); protected: diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 8e3797cbc0..202121bad3 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -9,19 +9,21 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include #include "AvatarHashMap.h" AvatarHashMap::AvatarHashMap() : - _avatarHash() + _avatarHash(), + _lastOwnerSessionUUID() { - + connect(NodeList::getInstance(), &NodeList::uuidChanged, this, &AvatarHashMap::sessionUUIDChanged); } -void AvatarHashMap::insert(const QUuid& id, AvatarSharedPointer avatar) { - _avatarHash.insert(id, avatar); - avatar->setSessionUUID(id); +void AvatarHashMap::insert(const QUuid& sessionUUID, AvatarSharedPointer avatar) { + _avatarHash.insert(sessionUUID, avatar); + avatar->setSessionUUID(sessionUUID); } AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator) { @@ -110,10 +112,16 @@ void AvatarHashMap::processAvatarDataPacket(const QByteArray &datagram, const QW QUuid sessionUUID = QUuid::fromRfc4122(datagram.mid(bytesRead, NUM_BYTES_RFC4122_UUID)); bytesRead += NUM_BYTES_RFC4122_UUID; - AvatarSharedPointer matchingAvatarData = matchingOrNewAvatar(sessionUUID, mixerWeakPointer); - - // have the matching (or new) avatar parse the data from the packet - bytesRead += matchingAvatarData->parseDataAtOffset(datagram, bytesRead); + if (sessionUUID != _lastOwnerSessionUUID) { + AvatarSharedPointer matchingAvatarData = matchingOrNewAvatar(sessionUUID, mixerWeakPointer); + + // have the matching (or new) avatar parse the data from the packet + bytesRead += matchingAvatarData->parseDataAtOffset(datagram, bytesRead); + } else { + // create a dummy AvatarData class to throw this data on the ground + AvatarData dummyData; + bytesRead += dummyData.parseDataAtOffset(datagram, bytesRead); + } } } @@ -177,3 +185,7 @@ void AvatarHashMap::processKillAvatar(const QByteArray& datagram) { erase(matchedAvatar); } } + +void AvatarHashMap::sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID) { + _lastOwnerSessionUUID = oldUUID; +} \ No newline at end of file diff --git a/libraries/avatars/src/AvatarHashMap.h b/libraries/avatars/src/AvatarHashMap.h index 542a2d62ab..fe9ab3d634 100644 --- a/libraries/avatars/src/AvatarHashMap.h +++ b/libraries/avatars/src/AvatarHashMap.h @@ -31,12 +31,15 @@ public: const AvatarHash& getAvatarHash() { return _avatarHash; } int size() const { return _avatarHash.size(); } - virtual void insert(const QUuid& id, AvatarSharedPointer avatar); + virtual void insert(const QUuid& sessionUUID, AvatarSharedPointer avatar); public slots: void processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer& mixerWeakPointer); bool containsAvatarWithDisplayName(const QString& displayName); - + +private slots: + void sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID); + protected: virtual AvatarHash::iterator erase(const AvatarHash::iterator& iterator); @@ -51,6 +54,7 @@ protected: void processKillAvatar(const QByteArray& datagram); AvatarHash _avatarHash; + QUuid _lastOwnerSessionUUID; }; #endif // hifi_AvatarHashMap_h diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index c0d7941edf..13dc558687 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -95,7 +95,7 @@ void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) { if (sessionUUID != oldUUID) { qDebug() << "NodeList UUID changed from" << uuidStringWithoutCurlyBraces(oldUUID) << "to" << uuidStringWithoutCurlyBraces(_sessionUUID); - emit uuidChanged(sessionUUID); + emit uuidChanged(sessionUUID, oldUUID); } } diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index a4bc8022bf..3e62d4aaab 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -107,7 +107,7 @@ public slots: void killNodeWithUUID(const QUuid& nodeUUID); signals: - void uuidChanged(const QUuid& ownerUUID); + void uuidChanged(const QUuid& ownerUUID, const QUuid& oldUUID); void nodeAdded(SharedNodePointer); void nodeKilled(SharedNodePointer); protected: From 9a50532b1f1fa55b4f0b668abfc5947b88f8f87b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 14:22:42 -0700 Subject: [PATCH 26/94] bubble up sub dependencies to link_hifi_library --- cmake/macros/LinkHifiLibrary.cmake | 2 +- interface/CMakeLists.txt | 6 ------ libraries/octree/CMakeLists.txt | 10 ++++++++-- libraries/shared/CMakeLists.txt | 5 ++++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 6300e50c34..577f0c9f37 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -16,7 +16,7 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") add_dependencies(${TARGET} ${LIBRARY}) - target_link_libraries(${TARGET} ${LIBRARY}) + target_link_libraries(${TARGET} ${LIBRARY} ${REQUIRED_DEPENDENCY_LIBRARIES}) if (APPLE) # currently the "shared" library requires CoreServices diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 7336b55852..5c1bec0321 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -126,7 +126,6 @@ find_package(LeapMotion) find_package(ZLIB) find_package(Qxmpp) find_package(RtMidi) -find_package(OpenSSL REQUIRED) # perform standard include and linking for found externals foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) @@ -180,14 +179,9 @@ endif () # include headers for interface and InterfaceConfig. include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") -# include external library headers -# use system flag so warnings are supressed -include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") - target_link_libraries( ${TARGET_NAME} "${ZLIB_LIBRARIES}" - ${OPENSSL_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml Qt5::UiTools ) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 031f7ef69a..398bf80157 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -20,9 +20,15 @@ link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") # link ZLIB find_package(ZLIB) +find_package(OpenSSL REQUIRED) -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) +include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") + +# bubble up the libraries we are dependent on +set(REQUIRED_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} + "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" Qt5::Widgets PARENT_SCOPE) + +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index f099f424e9..c0d59c8b75 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -30,4 +30,7 @@ endif (UNIX AND NOT APPLE) # directory when Qt5 (5.2.1) is compiled from source and is not in a standard place. include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets) +# bubble up the libraries we are dependent on and link them to ourselves +set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) +set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file From 33e58268423babe05d0f36c21b33fc9509a999b5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 14:57:09 -0700 Subject: [PATCH 27/94] remove animation server, bubble up qt modules --- CMakeLists.txt | 5 - animation-server/CMakeLists.txt | 39 -- animation-server/src/AnimationServer.cpp | 852 ----------------------- animation-server/src/AnimationServer.h | 27 - animation-server/src/main.cpp | 17 - assignment-client/CMakeLists.txt | 4 - cmake/macros/LinkHifiLibrary.cmake | 8 +- libraries/networking/CMakeLists.txt | 7 +- libraries/octree/CMakeLists.txt | 4 +- libraries/shared/CMakeLists.txt | 20 +- 10 files changed, 18 insertions(+), 965 deletions(-) delete mode 100644 animation-server/CMakeLists.txt delete mode 100644 animation-server/src/AnimationServer.cpp delete mode 100644 animation-server/src/AnimationServer.h delete mode 100644 animation-server/src/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dbc89b75f..578c36841d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,11 +44,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -# targets not supported on windows -if (NOT WIN32) - add_subdirectory(animation-server) -endif () - # targets on all platforms add_subdirectory(assignment-client) add_subdirectory(domain-server) diff --git a/animation-server/CMakeLists.txt b/animation-server/CMakeLists.txt deleted file mode 100644 index 116ee0e942..0000000000 --- a/animation-server/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -if (WIN32) - cmake_policy (SET CMP0020 NEW) -endif (WIN32) - -set(TARGET_NAME animation-server) - -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -find_package(Qt5 COMPONENTS Script) -include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") - -# set up the external glm library -include("${MACRO_DIR}/IncludeGLM.cmake") -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -include("${MACRO_DIR}/SetupHifiProject.cmake") -setup_hifi_project(${TARGET_NAME} TRUE) - -# link in the shared library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi octree library -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi voxels library -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") - -# link the hifi networking library -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () diff --git a/animation-server/src/AnimationServer.cpp b/animation-server/src/AnimationServer.cpp deleted file mode 100644 index 32a95b48ea..0000000000 --- a/animation-server/src/AnimationServer.cpp +++ /dev/null @@ -1,852 +0,0 @@ -// -// AnimationServer.cpp -// animation-server/src -// -// Created by Stephen Birarda on 12/5/2013. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "AnimationServer.h" - -bool shouldShowPacketsPerSecond = false; // do we want to debug packets per second -bool includeBillboard = true; -bool includeBorderTracer = true; -bool includeMovingBug = true; -bool includeBlinkingVoxel = false; -bool includeDanceFloor = true; -bool buildStreet = false; -bool nonThreadedPacketSender = false; -int packetsPerSecond = PacketSender::DEFAULT_PACKETS_PER_SECOND; -bool waitForVoxelServer = true; - - -const int ANIMATION_LISTEN_PORT = 40107; -int ANIMATE_FPS = 60; -double ANIMATE_FPS_IN_MILLISECONDS = 1000.0/ANIMATE_FPS; // determines FPS from our desired FPS -quint64 ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000); // converts from milliseconds to usecs - - -int PROCESSING_FPS = 60; -double PROCESSING_FPS_IN_MILLISECONDS = 1000.0/PROCESSING_FPS; // determines FPS from our desired FPS -int FUDGE_USECS = 650; // a little bit of fudge to actually do some processing -quint64 PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000) - FUDGE_USECS; // converts from milliseconds to usecs - -bool wantLocalDomain = false; - -unsigned long packetsSent = 0; -unsigned long bytesSent = 0; - -JurisdictionListener* jurisdictionListener = NULL; -VoxelEditPacketSender* voxelEditPacketSender = NULL; -pthread_t animateVoxelThread; - -glm::vec3 rotatePoint(glm::vec3 point, float angle) { - // First, create the quaternion based on this angle of rotation - glm::quat q(glm::vec3(0, -angle, 0)); - - // Next, create a rotation matrix from that quaternion - glm::mat4 rotation = glm::mat4_cast(q); - - // Transform the original vectors by the rotation matrix to get the new vectors - glm::vec4 quatPoint(point.x, point.y, point.z, 0); - glm::vec4 newPoint = quatPoint * rotation; - - return glm::vec3(newPoint.x, newPoint.y, newPoint.z); -} - - -const float BUG_VOXEL_SIZE = 0.0625f / TREE_SCALE; -glm::vec3 bugPosition = glm::vec3(BUG_VOXEL_SIZE * 20.0, BUG_VOXEL_SIZE * 30.0, BUG_VOXEL_SIZE * 20.0); -glm::vec3 bugDirection = glm::vec3(0, 0, 1); -const int VOXELS_PER_BUG = 18; -glm::vec3 bugPathCenter = glm::vec3(0.25f,0.15f,0.25f); // glm::vec3(BUG_VOXEL_SIZE * 150.0, BUG_VOXEL_SIZE * 30.0, BUG_VOXEL_SIZE * 150.0); -float bugPathRadius = 0.2f; //BUG_VOXEL_SIZE * 140.0; -float bugPathTheta = 0.0f * RADIANS_PER_DEGREE; -float bugRotation = 0.0f * RADIANS_PER_DEGREE; -float bugAngleDelta = 0.2f * RADIANS_PER_DEGREE; -bool moveBugInLine = false; - -class BugPart { -public: - glm::vec3 partLocation; - unsigned char partColor[3]; - - BugPart(const glm::vec3& location, unsigned char red, unsigned char green, unsigned char blue ) { - partLocation = location; - partColor[0] = red; - partColor[1] = green; - partColor[2] = blue; - } -}; - -const BugPart bugParts[VOXELS_PER_BUG] = { - - // tail - BugPart(glm::vec3( 0, 0, -3), 51, 51, 153) , - BugPart(glm::vec3( 0, 0, -2), 51, 51, 153) , - BugPart(glm::vec3( 0, 0, -1), 51, 51, 153) , - - // body - BugPart(glm::vec3( 0, 0, 0), 255, 200, 0) , - BugPart(glm::vec3( 0, 0, 1), 255, 200, 0) , - - // head - BugPart(glm::vec3( 0, 0, 2), 200, 0, 0) , - - // eyes - BugPart(glm::vec3( 1, 0, 3), 64, 64, 64) , - BugPart(glm::vec3(-1, 0, 3), 64, 64, 64) , - - // wings - BugPart(glm::vec3( 3, 1, 1), 0, 153, 0) , - BugPart(glm::vec3( 2, 1, 1), 0, 153, 0) , - BugPart(glm::vec3( 1, 0, 1), 0, 153, 0) , - BugPart(glm::vec3(-1, 0, 1), 0, 153, 0) , - BugPart(glm::vec3(-2, 1, 1), 0, 153, 0) , - BugPart(glm::vec3(-3, 1, 1), 0, 153, 0) , - - - BugPart(glm::vec3( 2, -1, 0), 153, 200, 0) , - BugPart(glm::vec3( 1, -1, 0), 153, 200, 0) , - BugPart(glm::vec3(-1, -1, 0), 153, 200, 0) , - BugPart(glm::vec3(-2, -1, 0), 153, 200, 0) , -}; - -static void renderMovingBug() { - VoxelDetail details[VOXELS_PER_BUG]; - - // Generate voxels for where bug used to be - for (int i = 0; i < VOXELS_PER_BUG; i++) { - details[i].s = BUG_VOXEL_SIZE; - - glm::vec3 partAt = bugParts[i].partLocation * BUG_VOXEL_SIZE * (bugDirection.x < 0 ? -1.0f : 1.0f); - glm::vec3 rotatedPartAt = rotatePoint(partAt, bugRotation); - glm::vec3 offsetPartAt = rotatedPartAt + bugPosition; - - details[i].x = offsetPartAt.x; - details[i].y = offsetPartAt.y; - details[i].z = offsetPartAt.z; - - details[i].red = bugParts[i].partColor[0]; - details[i].green = bugParts[i].partColor[1]; - details[i].blue = bugParts[i].partColor[2]; - } - - // send the "erase message" first... - PacketType message = PacketTypeVoxelErase; - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_BUG, (VoxelDetail*)&details); - - // Move the bug... - if (moveBugInLine) { - bugPosition.x += (bugDirection.x * BUG_VOXEL_SIZE); - bugPosition.y += (bugDirection.y * BUG_VOXEL_SIZE); - bugPosition.z += (bugDirection.z * BUG_VOXEL_SIZE); - - // Check boundaries - if (bugPosition.z > 1.0f) { - bugDirection.z = -1.f; - } - if (bugPosition.z < BUG_VOXEL_SIZE) { - bugDirection.z = 1.f; - } - } else { - - //qDebug("bugPathCenter=(%f,%f,%f)", bugPathCenter.x, bugPathCenter.y, bugPathCenter.z); - - bugPathTheta += bugAngleDelta; // move slightly - bugRotation -= bugAngleDelta; // rotate slightly - - // If we loop past end of circle, just reset back into normal range - if (bugPathTheta > TWO_PI) { - bugPathTheta = 0.f; - bugRotation = 0.f; - } - - float x = bugPathCenter.x + bugPathRadius * cos(bugPathTheta); - float z = bugPathCenter.z + bugPathRadius * sin(bugPathTheta); - float y = bugPathCenter.y; - - bugPosition = glm::vec3(x, y, z); - //qDebug("bugPathTheta=%f", bugPathTheta); - //qDebug("bugRotation=%f", bugRotation); - } - - //qDebug("bugPosition=(%f,%f,%f)", bugPosition.x, bugPosition.y, bugPosition.z); - //qDebug("bugDirection=(%f,%f,%f)", bugDirection.x, bugDirection.y, bugDirection.z); - // would be nice to add some randomness here... - - // Generate voxels for where bug is going to - for (int i = 0; i < VOXELS_PER_BUG; i++) { - details[i].s = BUG_VOXEL_SIZE; - - glm::vec3 partAt = bugParts[i].partLocation * BUG_VOXEL_SIZE * (bugDirection.x < 0 ? -1.0f : 1.0f); - glm::vec3 rotatedPartAt = rotatePoint(partAt, bugRotation); - glm::vec3 offsetPartAt = rotatedPartAt + bugPosition; - - details[i].x = offsetPartAt.x; - details[i].y = offsetPartAt.y; - details[i].z = offsetPartAt.z; - - details[i].red = bugParts[i].partColor[0]; - details[i].green = bugParts[i].partColor[1]; - details[i].blue = bugParts[i].partColor[2]; - } - - // send the "create message" ... - message = PacketTypeVoxelSetDestructive; - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_BUG, (VoxelDetail*)&details); -} - - -float intensity = 0.5f; -float intensityIncrement = 0.1f; -const float MAX_INTENSITY = 1.0f; -const float MIN_INTENSITY = 0.5f; -const float BEACON_SIZE = 0.25f / TREE_SCALE; // approximately 1/4th meter - -static void sendVoxelBlinkMessage() { - VoxelDetail detail; - detail.s = BEACON_SIZE; - - glm::vec3 position = glm::vec3(0.f, 0.f, detail.s); - - detail.x = detail.s * floor(position.x / detail.s); - detail.y = detail.s * floor(position.y / detail.s); - detail.z = detail.s * floor(position.z / detail.s); - - ::intensity += ::intensityIncrement; - if (::intensity >= MAX_INTENSITY) { - ::intensity = MAX_INTENSITY; - ::intensityIncrement = -::intensityIncrement; - } - if (::intensity <= MIN_INTENSITY) { - ::intensity = MIN_INTENSITY; - ::intensityIncrement = -::intensityIncrement; - } - - detail.red = 255 * ::intensity; - detail.green = 0 * ::intensity; - detail.blue = 0 * ::intensity; - - PacketType message = PacketTypeVoxelSetDestructive; - - ::voxelEditPacketSender->sendVoxelEditMessage(message, detail); -} - -bool stringOfLightsInitialized = false; -int currentLight = 0; -int lightMovementDirection = 1; -const int SEGMENT_COUNT = 4; -const int LIGHTS_PER_SEGMENT = 80; -const int LIGHT_COUNT = LIGHTS_PER_SEGMENT * SEGMENT_COUNT; -glm::vec3 stringOfLights[LIGHT_COUNT]; -unsigned char offColor[3] = { 240, 240, 240 }; -unsigned char onColor[3] = { 0, 255, 255 }; -const float STRING_OF_LIGHTS_SIZE = 0.125f / TREE_SCALE; // approximately 1/8th meter - -static void sendBlinkingStringOfLights() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = STRING_OF_LIGHTS_SIZE; - static VoxelDetail details[LIGHTS_PER_SEGMENT]; - - // first initialized the string of lights if needed... - if (!stringOfLightsInitialized) { - for (int segment = 0; segment < SEGMENT_COUNT; segment++) { - for (int indexInSegment = 0; indexInSegment < LIGHTS_PER_SEGMENT; indexInSegment++) { - - int i = (segment * LIGHTS_PER_SEGMENT) + indexInSegment; - - // four different segments on sides of initial platform - switch (segment) { - case 0: - // along x axis - stringOfLights[i] = glm::vec3(indexInSegment * lightScale, 0, 0); - break; - case 1: - // parallel to Z axis at outer X edge - stringOfLights[i] = glm::vec3(LIGHTS_PER_SEGMENT * lightScale, 0, indexInSegment * lightScale); - break; - case 2: - // parallel to X axis at outer Z edge - stringOfLights[i] = glm::vec3((LIGHTS_PER_SEGMENT-indexInSegment) * lightScale, 0, - LIGHTS_PER_SEGMENT * lightScale); - break; - case 3: - // on Z axis - stringOfLights[i] = glm::vec3(0, 0, (LIGHTS_PER_SEGMENT-indexInSegment) * lightScale); - break; - } - - details[indexInSegment].s = STRING_OF_LIGHTS_SIZE; - details[indexInSegment].x = stringOfLights[i].x; - details[indexInSegment].y = stringOfLights[i].y; - details[indexInSegment].z = stringOfLights[i].z; - - details[indexInSegment].red = offColor[0]; - details[indexInSegment].green = offColor[1]; - details[indexInSegment].blue = offColor[2]; - } - - ::voxelEditPacketSender->queueVoxelEditMessages(message, LIGHTS_PER_SEGMENT, (VoxelDetail*)&details); - } - stringOfLightsInitialized = true; - } else { - // turn off current light - details[0].x = stringOfLights[currentLight].x; - details[0].y = stringOfLights[currentLight].y; - details[0].z = stringOfLights[currentLight].z; - details[0].red = offColor[0]; - details[0].green = offColor[1]; - details[0].blue = offColor[2]; - - // move current light... - // if we're at the end of our string, then change direction - if (currentLight == LIGHT_COUNT-1) { - lightMovementDirection = -1; - } - if (currentLight == 0) { - lightMovementDirection = 1; - } - currentLight += lightMovementDirection; - - // turn on new current light - details[1].x = stringOfLights[currentLight].x; - details[1].y = stringOfLights[currentLight].y; - details[1].z = stringOfLights[currentLight].z; - details[1].red = onColor[0]; - details[1].green = onColor[1]; - details[1].blue = onColor[2]; - - // send both changes in same message - ::voxelEditPacketSender->queueVoxelEditMessages(message, 2, (VoxelDetail*)&details); - } -} - -bool danceFloorInitialized = false; -const float DANCE_FLOOR_LIGHT_SIZE = 1.0f / TREE_SCALE; // approximately 1 meter -const int DANCE_FLOOR_LENGTH = 10; -const int DANCE_FLOOR_WIDTH = 10; -glm::vec3 danceFloorPosition(100.0f / TREE_SCALE, 30.0f / TREE_SCALE, 10.0f / TREE_SCALE); -glm::vec3 danceFloorLights[DANCE_FLOOR_LENGTH][DANCE_FLOOR_WIDTH]; -unsigned char danceFloorOffColor[3] = { 240, 240, 240 }; -const int DANCE_FLOOR_COLORS = 6; - -unsigned char danceFloorOnColorA[DANCE_FLOOR_COLORS][3] = { - { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 }, - { 0, 191, 255 }, { 0, 250, 154 }, { 255, 69, 0 }, -}; -unsigned char danceFloorOnColorB[DANCE_FLOOR_COLORS][3] = { - { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } , - { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } -}; -float danceFloorGradient = 0.5f; -const float BEATS_PER_MINUTE = 118.0f; -const float SECONDS_PER_MINUTE = 60.0f; -const float FRAMES_PER_BEAT = (SECONDS_PER_MINUTE * ANIMATE_FPS) / BEATS_PER_MINUTE; -float danceFloorGradientIncrement = 1.0f / FRAMES_PER_BEAT; -const float DANCE_FLOOR_MAX_GRADIENT = 1.0f; -const float DANCE_FLOOR_MIN_GRADIENT = 0.0f; -const int DANCE_FLOOR_VOXELS_PER_PACKET = 100; -int danceFloorColors[DANCE_FLOOR_WIDTH][DANCE_FLOOR_LENGTH]; - -void sendDanceFloor() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = DANCE_FLOOR_LIGHT_SIZE; - static VoxelDetail details[DANCE_FLOOR_VOXELS_PER_PACKET]; - - // first initialized the billboard of lights if needed... - if (!::danceFloorInitialized) { - for (int i = 0; i < DANCE_FLOOR_WIDTH; i++) { - for (int j = 0; j < DANCE_FLOOR_LENGTH; j++) { - - int randomColorIndex = randIntInRange(-DANCE_FLOOR_COLORS, DANCE_FLOOR_COLORS); - ::danceFloorColors[i][j] = randomColorIndex; - ::danceFloorLights[i][j] = ::danceFloorPosition + - glm::vec3(i * DANCE_FLOOR_LIGHT_SIZE, 0, j * DANCE_FLOOR_LIGHT_SIZE); - } - } - ::danceFloorInitialized = true; - } - - ::danceFloorGradient += ::danceFloorGradientIncrement; - - if (::danceFloorGradient >= DANCE_FLOOR_MAX_GRADIENT) { - ::danceFloorGradient = DANCE_FLOOR_MAX_GRADIENT; - ::danceFloorGradientIncrement = -::danceFloorGradientIncrement; - } - if (::danceFloorGradient <= DANCE_FLOOR_MIN_GRADIENT) { - ::danceFloorGradient = DANCE_FLOOR_MIN_GRADIENT; - ::danceFloorGradientIncrement = -::danceFloorGradientIncrement; - } - - for (int i = 0; i < DANCE_FLOOR_LENGTH; i++) { - for (int j = 0; j < DANCE_FLOOR_WIDTH; j++) { - - int nthVoxel = ((i * DANCE_FLOOR_WIDTH) + j); - int item = nthVoxel % DANCE_FLOOR_VOXELS_PER_PACKET; - - ::danceFloorLights[i][j] = ::danceFloorPosition + - glm::vec3(i * DANCE_FLOOR_LIGHT_SIZE, 0, j * DANCE_FLOOR_LIGHT_SIZE); - - details[item].s = lightScale; - details[item].x = ::danceFloorLights[i][j].x; - details[item].y = ::danceFloorLights[i][j].y; - details[item].z = ::danceFloorLights[i][j].z; - - if (danceFloorColors[i][j] > 0) { - int color = danceFloorColors[i][j] - 1; - details[item].red = (::danceFloorOnColorA[color][0] + - ((::danceFloorOnColorB[color][0] - ::danceFloorOnColorA[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorA[color][1] + - ((::danceFloorOnColorB[color][1] - ::danceFloorOnColorA[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorA[color][2] + - ((::danceFloorOnColorB[color][2] - ::danceFloorOnColorA[color][2]) - * ::danceFloorGradient)); - } else if (::danceFloorColors[i][j] < 0) { - int color = -(::danceFloorColors[i][j] + 1); - details[item].red = (::danceFloorOnColorB[color][0] + - ((::danceFloorOnColorA[color][0] - ::danceFloorOnColorB[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorB[color][1] + - ((::danceFloorOnColorA[color][1] - ::danceFloorOnColorB[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorB[color][2] + - ((::danceFloorOnColorA[color][2] - ::danceFloorOnColorB[color][2]) - * ::danceFloorGradient)); - } else { - int color = 0; - details[item].red = (::danceFloorOnColorB[color][0] + - ((::danceFloorOnColorA[color][0] - ::danceFloorOnColorB[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorB[color][1] + - ((::danceFloorOnColorA[color][1] - ::danceFloorOnColorB[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorB[color][2] + - ((::danceFloorOnColorA[color][2] - ::danceFloorOnColorB[color][2]) - * ::danceFloorGradient)); - } - - if (item == DANCE_FLOOR_VOXELS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, DANCE_FLOOR_VOXELS_PER_PACKET, (VoxelDetail*)&details); - } - } - } -} - -bool billboardInitialized = false; -const int BILLBOARD_HEIGHT = 9; -const int BILLBOARD_WIDTH = 45; -glm::vec3 billboardPosition((0.125f / TREE_SCALE),(0.125f / TREE_SCALE),0); -glm::vec3 billboardLights[BILLBOARD_HEIGHT][BILLBOARD_WIDTH]; -unsigned char billboardOffColor[3] = { 240, 240, 240 }; -unsigned char billboardOnColorA[3] = { 0, 0, 255 }; -unsigned char billboardOnColorB[3] = { 0, 255, 0 }; -float billboardGradient = 0.5f; -float billboardGradientIncrement = 0.01f; -const float BILLBOARD_MAX_GRADIENT = 1.0f; -const float BILLBOARD_MIN_GRADIENT = 0.0f; -const float BILLBOARD_LIGHT_SIZE = 0.125f / TREE_SCALE; // approximately 1/8 meter per light -const int VOXELS_PER_PACKET = 81; - -// top to bottom... -bool billboardMessage[BILLBOARD_HEIGHT][BILLBOARD_WIDTH] = { - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, - { 0,0,1,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,0,0 }, - { 0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,1,1,1,0,0,0,0,0 }, - { 0,0,1,1,1,1,0,1,0,1,1,1,0,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0,1,0,1,0 }, - { 0,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,1,0 }, - { 0,0,1,0,0,1,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0,1,1,1,0 }, - { 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 }, - { 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0 }, - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } -}; - -static void sendBillboard() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = BILLBOARD_LIGHT_SIZE; - static VoxelDetail details[VOXELS_PER_PACKET]; - - // first initialized the billboard of lights if needed... - if (!billboardInitialized) { - for (int i = 0; i < BILLBOARD_HEIGHT; i++) { - for (int j = 0; j < BILLBOARD_WIDTH; j++) { - - billboardLights[i][j] = billboardPosition + glm::vec3(j * lightScale, (float)((BILLBOARD_HEIGHT - i) * lightScale), 0); - } - } - billboardInitialized = true; - } - - ::billboardGradient += ::billboardGradientIncrement; - - if (::billboardGradient >= BILLBOARD_MAX_GRADIENT) { - ::billboardGradient = BILLBOARD_MAX_GRADIENT; - ::billboardGradientIncrement = -::billboardGradientIncrement; - } - if (::billboardGradient <= BILLBOARD_MIN_GRADIENT) { - ::billboardGradient = BILLBOARD_MIN_GRADIENT; - ::billboardGradientIncrement = -::billboardGradientIncrement; - } - - for (int i = 0; i < BILLBOARD_HEIGHT; i++) { - for (int j = 0; j < BILLBOARD_WIDTH; j++) { - - int nthVoxel = ((i * BILLBOARD_WIDTH) + j); - int item = nthVoxel % VOXELS_PER_PACKET; - - billboardLights[i][j] = billboardPosition + glm::vec3(j * lightScale, (float)((BILLBOARD_HEIGHT - i) * lightScale), 0); - - details[item].s = lightScale; - details[item].x = billboardLights[i][j].x; - details[item].y = billboardLights[i][j].y; - details[item].z = billboardLights[i][j].z; - - if (billboardMessage[i][j]) { - details[item].red = (billboardOnColorA[0] + ((billboardOnColorB[0] - billboardOnColorA[0]) * ::billboardGradient)); - details[item].green = (billboardOnColorA[1] + ((billboardOnColorB[1] - billboardOnColorA[1]) * ::billboardGradient)); - details[item].blue = (billboardOnColorA[2] + ((billboardOnColorB[2] - billboardOnColorA[2]) * ::billboardGradient)); - } else { - details[item].red = billboardOffColor[0]; - details[item].green = billboardOffColor[1]; - details[item].blue = billboardOffColor[2]; - } - - if (item == VOXELS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_PACKET, (VoxelDetail*)&details); - } - } - } -} - -bool roadInitialized = false; -const int BRICKS_ACROSS_ROAD = 32; -const float ROAD_BRICK_SIZE = 0.125f/TREE_SCALE; //(ROAD_WIDTH_METERS / TREE_SCALE) / BRICKS_ACROSS_ROAD; // in voxel units -const int ROAD_LENGTH = 1.0f / ROAD_BRICK_SIZE; // in bricks -const int ROAD_WIDTH = BRICKS_ACROSS_ROAD; // in bricks -glm::vec3 roadPosition(0.5f - (ROAD_BRICK_SIZE * BRICKS_ACROSS_ROAD), 0.0f, 0.0f); -const int BRICKS_PER_PACKET = 32; // guessing - -void doBuildStreet() { - if (roadInitialized) { - return; - } - - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - static VoxelDetail details[BRICKS_PER_PACKET]; - - for (int z = 0; z < ROAD_LENGTH; z++) { - for (int x = 0; x < ROAD_WIDTH; x++) { - - int nthVoxel = ((z * ROAD_WIDTH) + x); - int item = nthVoxel % BRICKS_PER_PACKET; - - glm::vec3 brick = roadPosition + glm::vec3(x * ROAD_BRICK_SIZE, 0, z * ROAD_BRICK_SIZE); - - details[item].s = ROAD_BRICK_SIZE; - details[item].x = brick.x; - details[item].y = brick.y; - details[item].z = brick.z; - - unsigned char randomTone = randIntInRange(118,138); - details[item].red = randomTone; - details[item].green = randomTone; - details[item].blue = randomTone; - - if (item == BRICKS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, BRICKS_PER_PACKET, (VoxelDetail*)&details); - } - } - } - roadInitialized = true; -} - - -double start = 0; - - -void* animateVoxels(void* args) { - - quint64 lastAnimateTime = 0; - quint64 lastProcessTime = 0; - int processesPerAnimate = 0; - - bool firstTime = true; - - qDebug() << "Setting PPS to " << ::packetsPerSecond; - ::voxelEditPacketSender->setPacketsPerSecond(::packetsPerSecond); - - qDebug() << "PPS set to " << ::voxelEditPacketSender->getPacketsPerSecond(); - - while (true) { - - // If we're asked to wait for voxel servers, and there isn't one available yet, then - // let the voxelEditPacketSender process and move on. - if (::waitForVoxelServer && !::voxelEditPacketSender->voxelServersExist()) { - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->process(); - } - } else { - if (firstTime) { - lastAnimateTime = usecTimestampNow(); - firstTime = false; - } - lastProcessTime = usecTimestampNow(); - - // The while loop will be running at PROCESSING_FPS, but we only want to call these animation functions at - // ANIMATE_FPS. So we check out last animate time and only call these if we've elapsed that time. - quint64 now = usecTimestampNow(); - quint64 animationElapsed = now - lastAnimateTime; - int withinAnimationTarget = ANIMATE_VOXELS_INTERVAL_USECS - animationElapsed; - const int CLOSE_ENOUGH_TO_ANIMATE = 2000; // approximately 2 ms - - int animateLoopsPerAnimate = 0; - while (withinAnimationTarget < CLOSE_ENOUGH_TO_ANIMATE) { - processesPerAnimate = 0; - animateLoopsPerAnimate++; - - lastAnimateTime = now; - // some animations - //sendVoxelBlinkMessage(); - - if (::includeBillboard) { - sendBillboard(); - } - if (::includeBorderTracer) { - sendBlinkingStringOfLights(); - } - if (::includeMovingBug) { - renderMovingBug(); - } - if (::includeBlinkingVoxel) { - sendVoxelBlinkMessage(); - } - if (::includeDanceFloor) { - sendDanceFloor(); - } - - if (::buildStreet) { - doBuildStreet(); - } - - if (animationElapsed > ANIMATE_VOXELS_INTERVAL_USECS) { - animationElapsed -= ANIMATE_VOXELS_INTERVAL_USECS; // credit ourselves one animation frame - } else { - animationElapsed = 0; - } - withinAnimationTarget = ANIMATE_VOXELS_INTERVAL_USECS - animationElapsed; - - ::voxelEditPacketSender->releaseQueuedMessages(); - } - - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->process(); - } - processesPerAnimate++; - } - // dynamically sleep until we need to fire off the next set of voxels - quint64 usecToSleep = ::PROCESSING_INTERVAL_USECS - (usecTimestampNow() - lastProcessTime); - if (usecToSleep > ::PROCESSING_INTERVAL_USECS) { - usecToSleep = ::PROCESSING_INTERVAL_USECS; - } - - if (usecToSleep > 0) { - usleep(usecToSleep); - } - } - - pthread_exit(0); -} - -AnimationServer::AnimationServer(int &argc, char **argv) : - QCoreApplication(argc, argv) -{ - ::start = usecTimestampNow(); - - NodeList* nodeList = NodeList::createInstance(NodeType::AnimationServer, ANIMATION_LISTEN_PORT); - setvbuf(stdout, NULL, _IOLBF, 0); - - // Handle Local Domain testing with the --local command line - const char* NON_THREADED_PACKETSENDER = "--NonThreadedPacketSender"; - ::nonThreadedPacketSender = cmdOptionExists(argc, (const char**) argv, NON_THREADED_PACKETSENDER); - qDebug("nonThreadedPacketSender=%s", debug::valueOf(::nonThreadedPacketSender)); - - // Handle Local Domain testing with the --local command line - const char* NO_BILLBOARD = "--NoBillboard"; - ::includeBillboard = !cmdOptionExists(argc, (const char**) argv, NO_BILLBOARD); - qDebug("includeBillboard=%s", debug::valueOf(::includeBillboard)); - - const char* NO_BORDER_TRACER = "--NoBorderTracer"; - ::includeBorderTracer = !cmdOptionExists(argc, (const char**) argv, NO_BORDER_TRACER); - qDebug("includeBorderTracer=%s", debug::valueOf(::includeBorderTracer)); - - const char* NO_MOVING_BUG = "--NoMovingBug"; - ::includeMovingBug = !cmdOptionExists(argc, (const char**) argv, NO_MOVING_BUG); - qDebug("includeMovingBug=%s", debug::valueOf(::includeMovingBug)); - - const char* INCLUDE_BLINKING_VOXEL = "--includeBlinkingVoxel"; - ::includeBlinkingVoxel = cmdOptionExists(argc, (const char**) argv, INCLUDE_BLINKING_VOXEL); - qDebug("includeBlinkingVoxel=%s", debug::valueOf(::includeBlinkingVoxel)); - - const char* NO_DANCE_FLOOR = "--NoDanceFloor"; - ::includeDanceFloor = !cmdOptionExists(argc, (const char**) argv, NO_DANCE_FLOOR); - qDebug("includeDanceFloor=%s", debug::valueOf(::includeDanceFloor)); - - const char* BUILD_STREET = "--BuildStreet"; - ::buildStreet = cmdOptionExists(argc, (const char**) argv, BUILD_STREET); - qDebug("buildStreet=%s", debug::valueOf(::buildStreet)); - - // Handle Local Domain testing with the --local command line - const char* showPPS = "--showPPS"; - ::shouldShowPacketsPerSecond = cmdOptionExists(argc, (const char**) argv, showPPS); - - // Handle Local Domain testing with the --local command line - const char* local = "--local"; - ::wantLocalDomain = cmdOptionExists(argc, (const char**) argv,local); - if (::wantLocalDomain) { - qDebug("Local Domain MODE!"); - nodeList->getDomainHandler().setIPToLocalhost(); - } - - const char* domainHostname = getCmdOption(argc, (const char**) argv, "--domain"); - if (domainHostname) { - NodeList::getInstance()->getDomainHandler().setHostname(domainHostname); - } - - const char* packetsPerSecondCommand = getCmdOption(argc, (const char**) argv, "--pps"); - if (packetsPerSecondCommand) { - ::packetsPerSecond = atoi(packetsPerSecondCommand); - } - qDebug("packetsPerSecond=%d",packetsPerSecond); - - const char* animateFPSCommand = getCmdOption(argc, (const char**) argv, "--AnimateFPS"); - const char* animateIntervalCommand = getCmdOption(argc, (const char**) argv, "--AnimateInterval"); - if (animateFPSCommand || animateIntervalCommand) { - if (animateIntervalCommand) { - ::ANIMATE_FPS_IN_MILLISECONDS = atoi(animateIntervalCommand); - ::ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000.0); // converts from milliseconds to usecs - ::ANIMATE_FPS = PacketSender::USECS_PER_SECOND / ::ANIMATE_VOXELS_INTERVAL_USECS; - } else { - ::ANIMATE_FPS = atoi(animateFPSCommand); - ::ANIMATE_FPS_IN_MILLISECONDS = 1000.0/ANIMATE_FPS; // determines FPS from our desired FPS - ::ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000.0); // converts from milliseconds to usecs - } - } - qDebug("ANIMATE_FPS=%d",ANIMATE_FPS); - qDebug("ANIMATE_VOXELS_INTERVAL_USECS=%llu",ANIMATE_VOXELS_INTERVAL_USECS); - - const char* processingFPSCommand = getCmdOption(argc, (const char**) argv, "--ProcessingFPS"); - const char* processingIntervalCommand = getCmdOption(argc, (const char**) argv, "--ProcessingInterval"); - if (processingFPSCommand || processingIntervalCommand) { - if (processingIntervalCommand) { - ::PROCESSING_FPS_IN_MILLISECONDS = atoi(processingIntervalCommand); - ::PROCESSING_INTERVAL_USECS = ::PROCESSING_FPS_IN_MILLISECONDS * 1000.0; - ::PROCESSING_FPS = PacketSender::USECS_PER_SECOND / ::PROCESSING_INTERVAL_USECS; - } else { - ::PROCESSING_FPS = atoi(processingFPSCommand); - ::PROCESSING_FPS_IN_MILLISECONDS = 1000.0/PROCESSING_FPS; // determines FPS from our desired FPS - ::PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000.0) - FUDGE_USECS; // converts from milliseconds to usecs - } - } - qDebug("PROCESSING_FPS=%d",PROCESSING_FPS); - qDebug("PROCESSING_INTERVAL_USECS=%llu",PROCESSING_INTERVAL_USECS); - - nodeList->linkedDataCreateCallback = NULL; // do we need a callback? - - // Create our JurisdictionListener so we'll know where to send edit packets - ::jurisdictionListener = new JurisdictionListener(); - if (::jurisdictionListener) { - ::jurisdictionListener->initialize(true); - } - - // Create out VoxelEditPacketSender - ::voxelEditPacketSender = new VoxelEditPacketSender; - ::voxelEditPacketSender->initialize(!::nonThreadedPacketSender); - - if (::jurisdictionListener) { - ::voxelEditPacketSender->setVoxelServerJurisdictions(::jurisdictionListener->getJurisdictions()); - } - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->setProcessCallIntervalHint(PROCESSING_INTERVAL_USECS); - } - - srand((unsigned)time(0)); - - - pthread_create(&::animateVoxelThread, NULL, animateVoxels, NULL); - - NodeList::getInstance()->addNodeTypeToInterestSet(NodeType::VoxelServer); - - QTimer* domainServerTimer = new QTimer(this); - connect(domainServerTimer, SIGNAL(timeout()), nodeList, SLOT(sendDomainServerCheckIn())); - domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); - - QTimer* silentNodeTimer = new QTimer(this); - connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); - silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS); - - connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(readPendingDatagrams())); -} - -void AnimationServer::readPendingDatagrams() { - NodeList* nodeList = NodeList::getInstance(); - - static QByteArray receivedPacket; - static HifiSockAddr nodeSockAddr; - - // Nodes sending messages to us... - while (nodeList->getNodeSocket().hasPendingDatagrams()) { - receivedPacket.resize(nodeList->getNodeSocket().pendingDatagramSize()); - nodeList->getNodeSocket().readDatagram(receivedPacket.data(), receivedPacket.size(), - nodeSockAddr.getAddressPointer(), nodeSockAddr.getPortPointer()); - if (nodeList->packetVersionAndHashMatch(receivedPacket)) { - if (packetTypeForPacket(receivedPacket) == PacketTypeJurisdiction) { - int headerBytes = numBytesForPacketHeader(receivedPacket); - // PacketType_JURISDICTION, first byte is the node type... - if (receivedPacket.data()[headerBytes] == NodeType::VoxelServer && ::jurisdictionListener) { - - SharedNodePointer matchedNode = NodeList::getInstance()->sendingNodeForPacket(receivedPacket); - if (matchedNode) { - ::jurisdictionListener->queueReceivedPacket(matchedNode, receivedPacket); - } - } - } - NodeList::getInstance()->processNodeData(nodeSockAddr, receivedPacket); - } - } -} - -AnimationServer::~AnimationServer() { - pthread_join(animateVoxelThread, NULL); - - if (::jurisdictionListener) { - ::jurisdictionListener->terminate(); - delete ::jurisdictionListener; - } - - if (::voxelEditPacketSender) { - ::voxelEditPacketSender->terminate(); - delete ::voxelEditPacketSender; - } -} diff --git a/animation-server/src/AnimationServer.h b/animation-server/src/AnimationServer.h deleted file mode 100644 index 58f05c32c5..0000000000 --- a/animation-server/src/AnimationServer.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// AnimationServer.h -// animation-server/src -// -// Created by Stephen Birarda on 12/5/2013. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_AnimationServer_h -#define hifi_AnimationServer_h - -#include - -class AnimationServer : public QCoreApplication { - Q_OBJECT -public: - AnimationServer(int &argc, char **argv); - ~AnimationServer(); -private slots: - void readPendingDatagrams(); -}; - - -#endif // hifi_AnimationServer_h diff --git a/animation-server/src/main.cpp b/animation-server/src/main.cpp deleted file mode 100644 index 8acf3b8db2..0000000000 --- a/animation-server/src/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.cpp -// animation-server/src -// -// Created by Brad Hefta-Gaub on 05/16/2013. -// Copyright 2012 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "AnimationServer.h" - -int main(int argc, char * argv[]) { - AnimationServer animationServer(argc, argv); - return animationServer.exec(); -} diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 5ca021b175..fec0aedfdd 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -6,8 +6,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") -find_package(Qt5 COMPONENTS Network Script Widgets) - include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) @@ -39,8 +37,6 @@ IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) ENDIF(WIN32) -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 577f0c9f37..0728abf8c9 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -16,12 +16,10 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") add_dependencies(${TARGET} ${LIBRARY}) + target_link_libraries(${TARGET} ${LIBRARY} ${REQUIRED_DEPENDENCY_LIBRARIES}) - if (APPLE) - # currently the "shared" library requires CoreServices - # link in required OS X framework - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreServices") + if (REQUIRED_DEPENDENCY_QT_MODULES) + qt5_use_modules(${TARGET_NAME} ${REQUIRED_DEPENDENCY_QT_MODULES}) endif () - endmacro(LINK_HIFI_LIBRARY _library _target _root_dir) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 9a13374a4f..8f8366d4d3 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -4,8 +4,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(TARGET_NAME networking) project(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -13,7 +11,10 @@ setup_hifi_library(${TARGET_NAME}) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -target_link_libraries(${TARGET_NAME} Qt5::Network) +find_package(Qt5Network REQUIRED) +set(DEPENDENCY_QT_MODULES Network) +set(REQUIRED_DEPENDENCY_QT_MODULES ${DEPENDENCY_QT_MODULES} PARENT_SCOPE) +qt5_use_modules(${TARGET_NAME} ${DEPENDENCY_QT_MODULES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 398bf80157..99da8d1bf2 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME octree) -find_package(Qt5Widgets REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -26,7 +24,7 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") # bubble up the libraries we are dependent on set(REQUIRED_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} - "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" Qt5::Widgets PARENT_SCOPE) + "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" PARENT_SCOPE) target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index c0d59c8b75..f7f05c88a7 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -4,7 +4,8 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(TARGET_NAME shared) project(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network Widgets Xml Script) +find_package(Qt5 COMPONENTS Network) +find_package(Qt5Widgets REQUIRED) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -21,16 +22,15 @@ if (WIN32) endif (WIN32) # link required libraries on UNIX -if (UNIX AND NOT APPLE) - find_package(Threads REQUIRED) - target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}") -endif (UNIX AND NOT APPLE) - -# There is something special (bug) about Qt5Scripts, that we have to explicitly add its include -# directory when Qt5 (5.2.1) is compiled from source and is not in a standard place. -include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") +if (APPLE) + find_library(CoreServices CoreServices) + list(APPEND REQUIRED_DEPENDENCY_LIBRARIES ${CoreServices}) +elseif (UNIX) + find_package(Threads REQUIRED) + LIST(APPEND REQUIRED_DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") +endif () # bubble up the libraries we are dependent on and link them to ourselves -set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) +list(APPEND REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file From fa26957b230051b8af7c447d861f7c0900191ea2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 15:20:26 -0700 Subject: [PATCH 28/94] more CMakeLists cleanup for sub-dependencies --- assignment-client/CMakeLists.txt | 4 - cmake/macros/LinkHifiLibrary.cmake | 6 +- domain-server/CMakeLists.txt | 13 - libraries/animation/CMakeLists.txt | 10 +- libraries/avatars/CMakeLists.txt | 5 - libraries/embedded-webserver/CMakeLists.txt | 9 +- libraries/networking/CMakeLists.txt | 10 +- libraries/particles/CMakeLists.txt | 8 - libraries/shared/CMakeLists.txt | 13 +- libraries/shared/external/pthread.h | 1403 ------------------- libraries/shared/external/sched.h | 189 --- 11 files changed, 18 insertions(+), 1652 deletions(-) delete mode 100644 libraries/shared/external/pthread.h delete mode 100644 libraries/shared/external/sched.h diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index fec0aedfdd..a4e26899fb 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,10 +9,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) -# include glm -include("${MACRO_DIR}/IncludeGLM.cmake") -include_glm(${TARGET_NAME} "${ROOT_DIR}") - # link in the shared libraries include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 0728abf8c9..afb1f1febd 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -17,9 +17,5 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) add_dependencies(${TARGET} ${LIBRARY}) - target_link_libraries(${TARGET} ${LIBRARY} ${REQUIRED_DEPENDENCY_LIBRARIES}) - - if (REQUIRED_DEPENDENCY_QT_MODULES) - qt5_use_modules(${TARGET_NAME} ${REQUIRED_DEPENDENCY_QT_MODULES}) - endif () + target_link_libraries(${TARGET} ${LIBRARY} ${SUB_DEPENDENCY_LIBRARIES}) endmacro(LINK_HIFI_LIBRARY _library _target _root_dir) \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 6ee794f7c6..26f07cf776 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,7 +1,3 @@ -if (WIN32) - cmake_policy (SET CMP0020 NEW) -endif (WIN32) - set(TARGET_NAME domain-server) set(ROOT_DIR ..) @@ -10,12 +6,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") -# set up the external glm library -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -find_package(Qt5Network REQUIRED) - include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) @@ -39,9 +29,6 @@ IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) ENDIF(WIN32) -# link QtNetwork -target_link_libraries(${TARGET_NAME} Qt5::Network) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index b1dc59fff8..be6ed47898 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -6,22 +6,16 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME animation) -find_package(Qt5Widgets REQUIRED) +find_package(Qt5 COMPONENTS Script) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -# link ZLIB -find_package(ZLIB) - -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) +target_link_libraries(${TARGET_NAME} Qt5::Script) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index ca4a2630b4..feb1e68557 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME avatars) -find_package(Qt5Script REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -17,13 +15,10 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -# link in the hifi voxels library link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -target_link_libraries(${TARGET_NAME} Qt5::Script) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index 1386bcc392..f1681cdd12 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -6,9 +6,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME embedded-webserver) -find_package(Qt5Network REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -target_link_libraries(${TARGET_NAME} Qt5::Network) \ No newline at end of file +find_package(Qt5Network REQUIRED) + +# bubble up the libraries we are dependent on and link them to ourselves +set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network) +set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 8f8366d4d3..215d406133 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -11,10 +11,12 @@ setup_hifi_library(${TARGET_NAME}) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network REQUIRED) -set(DEPENDENCY_QT_MODULES Network) -set(REQUIRED_DEPENDENCY_QT_MODULES ${DEPENDENCY_QT_MODULES} PARENT_SCOPE) -qt5_use_modules(${TARGET_NAME} ${DEPENDENCY_QT_MODULES}) +find_package(Qt5Network) + +# bubble up the libraries we are dependent on and link them to ourselves +set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network) +set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 76b3373466..cecbdaaa21 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME particles) -find_package(Qt5Widgets REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -21,12 +19,6 @@ link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -# link ZLIB -find_package(ZLIB) - -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index f7f05c88a7..067551ba31 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -4,9 +4,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(TARGET_NAME shared) project(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network) -find_package(Qt5Widgets REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -14,13 +11,6 @@ setup_hifi_library(${TARGET_NAME}) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -set(EXTERNAL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external") - -if (WIN32) - # include headers for external libraries and InterfaceConfig. - include_directories("${EXTERNAL_ROOT_DIR}") -endif (WIN32) - # link required libraries on UNIX if (APPLE) find_library(CoreServices CoreServices) @@ -30,6 +20,9 @@ elseif (UNIX) LIST(APPEND REQUIRED_DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif () +find_package(Qt5Network) +find_package(Qt5Widgets) + # bubble up the libraries we are dependent on and link them to ourselves list(APPEND REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) diff --git a/libraries/shared/external/pthread.h b/libraries/shared/external/pthread.h deleted file mode 100644 index f910eb4b0e..0000000000 --- a/libraries/shared/external/pthread.h +++ /dev/null @@ -1,1403 +0,0 @@ -/* This is an implementation of the threads API of POSIX 1003.1-2001. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * The current list of contributors is contained - * in the file CONTRIBUTORS included with the source - * code distribution. The list can also be seen at the - * following World Wide Web location: - * http://sources.redhat.com/pthreads-win32/contributors.html - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#if !defined( PTHREAD_H ) -#define PTHREAD_H - -#define PTW32_STATIC_LIB - -/* - * See the README file for an explanation of the pthreads-win32 version - * numbering scheme and how the DLL is named etc. - */ -#define PTW32_VERSION 2,10,0,0 -#define PTW32_VERSION_STRING "2, 10, 0, 0\0" - -/* There are three implementations of cancel cleanup. - * Note that pthread.h is included in both application - * compilation units and also internally for the library. - * The code here and within the library aims to work - * for all reasonable combinations of environments. - * - * The three implementations are: - * - * WIN32 SEH - * C - * C++ - * - * Please note that exiting a push/pop block via - * "return", "exit", "break", or "continue" will - * lead to different behaviour amongst applications - * depending upon whether the library was built - * using SEH, C++, or C. For example, a library built - * with SEH will call the cleanup routine, while both - * C++ and C built versions will not. - */ - -/* - * Define defaults for cleanup code. - * Note: Unless the build explicitly defines one of the following, then - * we default to standard C style cleanup. This style uses setjmp/longjmp - * in the cancellation and thread exit implementations and therefore won't - * do stack unwinding if linked to applications that have it (e.g. - * C++ apps). This is currently consistent with most/all commercial Unix - * POSIX threads implementations. - */ -#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C ) -/* - [i_a] fix for apps using pthreads-Win32: when they do not define __CLEANUP_SEH themselves, - they're screwed as they'll receive the '__CLEANUP_C' macros which do NOT work when - the pthreads library code itself has actually been build with __CLEANUP_SEH, - which is the case when building this stuff in MSVC. - - Hence this section is made to 'sensibly autodetect' the cleanup mode, when it hasn't - been hardwired in the makefiles / project files. - - After all, who expects he MUST define one of these __CLEANUP_XXX defines in his own - code when using pthreads-Win32, for whatever reason. - */ -#if (defined(_MSC_VER) || defined(PTW32_RC_MSC)) -#define __CLEANUP_SEH -#elif defined(__cplusplus) -#define __CLEANUP_CXX -#else -#define __CLEANUP_C -#endif -#endif - -#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC)) -#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler. -#endif - -/* - * Stop here if we are being included by the resource compiler. - */ -#if !defined(RC_INVOKED) - -#undef PTW32_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_LEVEL_MAX 3 - -#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX -/* Include everything */ -#endif - -#if defined(_UWIN) -# define HAVE_STRUCT_TIMESPEC 1 -# define HAVE_SIGNAL_H 1 -# undef HAVE_PTW32_CONFIG_H -# pragma comment(lib, "pthread") -#endif - -#if defined(__MINGW32__) || defined(__MINGW64__) -# define PTW32_CONFIG_MINGW -#endif -#if defined(_MSC_VER) -# if _MSC_VER < 1300 -# define PTW32_CONFIG_MSVC6 -# endif -# if _MSC_VER < 1400 -# define PTW32_CONFIG_MSVC7 -# endif -#endif - -/* - * ------------------------------------------------------------- - * - * - * Module: pthread.h - * - * Purpose: - * Provides an implementation of PThreads based upon the - * standard: - * - * POSIX 1003.1-2001 - * and - * The Single Unix Specification version 3 - * - * (these two are equivalent) - * - * in order to enhance code portability between Windows, - * various commercial Unix implementations, and Linux. - * - * See the ANNOUNCE file for a full list of conforming - * routines and defined constants, and a list of missing - * routines and constants not defined in this implementation. - * - * Authors: - * There have been many contributors to this library. - * The initial implementation was contributed by - * John Bossom, and several others have provided major - * sections or revisions of parts of the implementation. - * Often significant effort has been contributed to - * find and fix important bugs and other problems to - * improve the reliability of the library, which sometimes - * is not reflected in the amount of code which changed as - * result. - * As much as possible, the contributors are acknowledged - * in the ChangeLog file in the source code distribution - * where their changes are noted in detail. - * - * Contributors are listed in the CONTRIBUTORS file. - * - * As usual, all bouquets go to the contributors, and all - * brickbats go to the project maintainer. - * - * Maintainer: - * The code base for this project is coordinated and - * eventually pre-tested, packaged, and made available by - * - * Ross Johnson - * - * QA Testers: - * Ultimately, the library is tested in the real world by - * a host of competent and demanding scientists and - * engineers who report bugs and/or provide solutions - * which are then fixed or incorporated into subsequent - * versions of the library. Each time a bug is fixed, a - * test case is written to prove the fix and ensure - * that later changes to the code don't reintroduce the - * same error. The number of test cases is slowly growing - * and therefore so is the code reliability. - * - * Compliance: - * See the file ANNOUNCE for the list of implemented - * and not-implemented routines and defined options. - * Of course, these are all defined is this file as well. - * - * Web site: - * The source code and other information about this library - * are available from - * - * http://sources.redhat.com/pthreads-win32/ - * - * ------------------------------------------------------------- - */ - -/* Try to avoid including windows.h */ -#if defined(PTW32_CONFIG_MINGW) && defined(__cplusplus) -#define PTW32_INCLUDE_WINDOWS_H -#endif - -#if defined(PTW32_INCLUDE_WINDOWS_H) -#include -#endif - -#if defined(PTW32_CONFIG_MSVC6) || defined(__DMC__) -/* - * VC++6.0 or early compiler's header has no DWORD_PTR type. - */ -typedef unsigned long DWORD_PTR; -typedef unsigned long ULONG_PTR; -#endif -/* - * ----------------- - * autoconf switches - * ----------------- - */ - -#if defined(HAVE_PTW32_CONFIG_H) -#include "config.h" -#endif /* HAVE_PTW32_CONFIG_H */ - -#if !defined(NEED_FTIME) -#include -#else /* NEED_FTIME */ -/* use native WIN32 time API */ -#endif /* NEED_FTIME */ - -#if defined(HAVE_SIGNAL_H) -#include -#endif /* HAVE_SIGNAL_H */ - -#include - -/* - * Boolean values to make us independent of system includes. - */ -enum { - PTW32_FALSE = 0, - PTW32_TRUE = (! PTW32_FALSE) -}; - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Several systems don't define some error numbers. - */ -#if !defined(ENOTSUP) -# define ENOTSUP 48 /* This is the value in Solaris. */ -#endif - -#if !defined(ETIMEDOUT) -# define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */ -#endif - -#if !defined(ENOSYS) -# define ENOSYS 140 /* Semi-arbitrary value */ -#endif - -#if !defined(EDEADLK) -# if defined(EDEADLOCK) -# define EDEADLK EDEADLOCK -# else -# define EDEADLK 36 /* This is the value in MSVC. */ -# endif -#endif - -/* POSIX 2008 - related to robust mutexes */ -#if !defined(EOWNERDEAD) -# define EOWNERDEAD 43 -#endif -#if !defined(ENOTRECOVERABLE) -# define ENOTRECOVERABLE 44 -#endif - -#include - -/* - * To avoid including windows.h we define only those things that we - * actually need from it. - */ -#if !defined(PTW32_INCLUDE_WINDOWS_H) -#if !defined(HANDLE) -# define PTW32__HANDLE_DEF -# define HANDLE void * -#endif -#if !defined(DWORD) -# define PTW32__DWORD_DEF -# define DWORD unsigned long -#endif -#endif - -#if !defined(HAVE_STRUCT_TIMESPEC) -#define HAVE_STRUCT_TIMESPEC -#if !defined(_TIMESPEC_DEFINED) -#define _TIMESPEC_DEFINED -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -#endif /* _TIMESPEC_DEFINED */ -#endif /* HAVE_STRUCT_TIMESPEC */ - -#if !defined(SIG_BLOCK) -#define SIG_BLOCK 0 -#endif /* SIG_BLOCK */ - -#if !defined(SIG_UNBLOCK) -#define SIG_UNBLOCK 1 -#endif /* SIG_UNBLOCK */ - -#if !defined(SIG_SETMASK) -#define SIG_SETMASK 2 -#endif /* SIG_SETMASK */ - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -/* - * ------------------------------------------------------------- - * - * POSIX 1003.1-2001 Options - * ========================= - * - * Options are normally set in , which is not provided - * with pthreads-win32. - * - * For conformance with the Single Unix Specification (version 3), all of the - * options below are defined, and have a value of either -1 (not supported) - * or 200112L (supported). - * - * These options can neither be left undefined nor have a value of 0, because - * either indicates that sysconf(), which is not implemented, may be used at - * runtime to check the status of the option. - * - * _POSIX_THREADS (== 200112L) - * If == 200112L, you can use threads - * - * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L) - * If == 200112L, you can control the size of a thread's - * stack - * pthread_attr_getstacksize - * pthread_attr_setstacksize - * - * _POSIX_THREAD_ATTR_STACKADDR (== -1) - * If == 200112L, you can allocate and control a thread's - * stack. If not supported, the following functions - * will return ENOSYS, indicating they are not - * supported: - * pthread_attr_getstackaddr - * pthread_attr_setstackaddr - * - * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1) - * If == 200112L, you can use realtime scheduling. - * This option indicates that the behaviour of some - * implemented functions conforms to the additional TPS - * requirements in the standard. E.g. rwlocks favour - * writers over readers when threads have equal priority. - * - * _POSIX_THREAD_PRIO_INHERIT (== -1) - * If == 200112L, you can create priority inheritance - * mutexes. - * pthread_mutexattr_getprotocol + - * pthread_mutexattr_setprotocol + - * - * _POSIX_THREAD_PRIO_PROTECT (== -1) - * If == 200112L, you can create priority ceiling mutexes - * Indicates the availability of: - * pthread_mutex_getprioceiling - * pthread_mutex_setprioceiling - * pthread_mutexattr_getprioceiling - * pthread_mutexattr_getprotocol + - * pthread_mutexattr_setprioceiling - * pthread_mutexattr_setprotocol + - * - * _POSIX_THREAD_PROCESS_SHARED (== -1) - * If set, you can create mutexes and condition - * variables that can be shared with another - * process.If set, indicates the availability - * of: - * pthread_mutexattr_getpshared - * pthread_mutexattr_setpshared - * pthread_condattr_getpshared - * pthread_condattr_setpshared - * - * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L) - * If == 200112L you can use the special *_r library - * functions that provide thread-safe behaviour - * - * _POSIX_READER_WRITER_LOCKS (== 200112L) - * If == 200112L, you can use read/write locks - * - * _POSIX_SPIN_LOCKS (== 200112L) - * If == 200112L, you can use spin locks - * - * _POSIX_BARRIERS (== 200112L) - * If == 200112L, you can use barriers - * - * + These functions provide both 'inherit' and/or - * 'protect' protocol, based upon these macro - * settings. - * - * ------------------------------------------------------------- - */ - -/* - * POSIX Options - */ -#undef _POSIX_THREADS -#define _POSIX_THREADS 200809L - -#undef _POSIX_READER_WRITER_LOCKS -#define _POSIX_READER_WRITER_LOCKS 200809L - -#undef _POSIX_SPIN_LOCKS -#define _POSIX_SPIN_LOCKS 200809L - -#undef _POSIX_BARRIERS -#define _POSIX_BARRIERS 200809L - -#undef _POSIX_THREAD_SAFE_FUNCTIONS -#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L - -#undef _POSIX_THREAD_ATTR_STACKSIZE -#define _POSIX_THREAD_ATTR_STACKSIZE 200809L - -/* - * The following options are not supported - */ -#undef _POSIX_THREAD_ATTR_STACKADDR -#define _POSIX_THREAD_ATTR_STACKADDR -1 - -#undef _POSIX_THREAD_PRIO_INHERIT -#define _POSIX_THREAD_PRIO_INHERIT -1 - -#undef _POSIX_THREAD_PRIO_PROTECT -#define _POSIX_THREAD_PRIO_PROTECT -1 - -/* TPS is not fully supported. */ -#undef _POSIX_THREAD_PRIORITY_SCHEDULING -#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 - -#undef _POSIX_THREAD_PROCESS_SHARED -#define _POSIX_THREAD_PROCESS_SHARED -1 - - -/* - * POSIX 1003.1-2001 Limits - * =========================== - * - * These limits are normally set in , which is not provided with - * pthreads-win32. - * - * PTHREAD_DESTRUCTOR_ITERATIONS - * Maximum number of attempts to destroy - * a thread's thread-specific data on - * termination (must be at least 4) - * - * PTHREAD_KEYS_MAX - * Maximum number of thread-specific data keys - * available per process (must be at least 128) - * - * PTHREAD_STACK_MIN - * Minimum supported stack size for a thread - * - * PTHREAD_THREADS_MAX - * Maximum number of threads supported per - * process (must be at least 64). - * - * SEM_NSEMS_MAX - * The maximum number of semaphores a process can have. - * (must be at least 256) - * - * SEM_VALUE_MAX - * The maximum value a semaphore can have. - * (must be at least 32767) - * - */ -#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 - -#undef PTHREAD_DESTRUCTOR_ITERATIONS -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS - -#undef _POSIX_THREAD_KEYS_MAX -#define _POSIX_THREAD_KEYS_MAX 128 - -#undef PTHREAD_KEYS_MAX -#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX - -#undef PTHREAD_STACK_MIN -#define PTHREAD_STACK_MIN 0 - -#undef _POSIX_THREAD_THREADS_MAX -#define _POSIX_THREAD_THREADS_MAX 64 - - /* Arbitrary value */ -#undef PTHREAD_THREADS_MAX -#define PTHREAD_THREADS_MAX 2019 - -#undef _POSIX_SEM_NSEMS_MAX -#define _POSIX_SEM_NSEMS_MAX 256 - - /* Arbitrary value */ -#undef SEM_NSEMS_MAX -#define SEM_NSEMS_MAX 1024 - -#undef _POSIX_SEM_VALUE_MAX -#define _POSIX_SEM_VALUE_MAX 32767 - -#undef SEM_VALUE_MAX -#define SEM_VALUE_MAX INT_MAX - - -#if defined(__GNUC__) && !defined(__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the library, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the library, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * The Open Watcom C/C++ compiler uses a non-standard calling convention - * that passes function args in registers unless __cdecl is explicitly specified - * in exposed function prototypes. - * - * We force all calls to cdecl even though this could slow Watcom code down - * slightly. If you know that the Watcom compiler will be used to build both - * the DLL and application, then you can probably define this as a null string. - * Remember that pthread.h (this file) is used for both the DLL and application builds. - */ -#define PTW32_CDECL __cdecl - -#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX -# include -#else -/* - * Generic handle type - intended to extend uniqueness beyond - * that available with a simple pointer. It should scale for either - * IA-32 or IA-64. - */ -typedef struct { - void * p; /* Pointer to actual object */ - unsigned int x; /* Extra information - reuse count etc */ -} ptw32_handle_t; - -typedef ptw32_handle_t pthread_t; -typedef struct pthread_attr_t_ * pthread_attr_t; -typedef struct pthread_once_t_ pthread_once_t; -typedef struct pthread_key_t_ * pthread_key_t; -typedef struct pthread_mutex_t_ * pthread_mutex_t; -typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t; -typedef struct pthread_cond_t_ * pthread_cond_t; -typedef struct pthread_condattr_t_ * pthread_condattr_t; -#endif -typedef struct pthread_rwlock_t_ * pthread_rwlock_t; -typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t; -typedef struct pthread_spinlock_t_ * pthread_spinlock_t; -typedef struct pthread_barrier_t_ * pthread_barrier_t; -typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; - -/* - * ==================== - * ==================== - * POSIX Threads - * ==================== - * ==================== - */ - -enum { -/* - * pthread_attr_{get,set}detachstate - */ - PTHREAD_CREATE_JOINABLE = 0, /* Default */ - PTHREAD_CREATE_DETACHED = 1, - -/* - * pthread_attr_{get,set}inheritsched - */ - PTHREAD_INHERIT_SCHED = 0, - PTHREAD_EXPLICIT_SCHED = 1, /* Default */ - -/* - * pthread_{get,set}scope - */ - PTHREAD_SCOPE_PROCESS = 0, - PTHREAD_SCOPE_SYSTEM = 1, /* Default */ - -/* - * pthread_setcancelstate paramters - */ - PTHREAD_CANCEL_ENABLE = 0, /* Default */ - PTHREAD_CANCEL_DISABLE = 1, - -/* - * pthread_setcanceltype parameters - */ - PTHREAD_CANCEL_ASYNCHRONOUS = 0, - PTHREAD_CANCEL_DEFERRED = 1, /* Default */ - -/* - * pthread_mutexattr_{get,set}pshared - * pthread_condattr_{get,set}pshared - */ - PTHREAD_PROCESS_PRIVATE = 0, - PTHREAD_PROCESS_SHARED = 1, - -/* - * pthread_mutexattr_{get,set}robust - */ - PTHREAD_MUTEX_STALLED = 0, /* Default */ - PTHREAD_MUTEX_ROBUST = 1, - -/* - * pthread_barrier_wait - */ - PTHREAD_BARRIER_SERIAL_THREAD = -1 -}; - -/* - * ==================== - * ==================== - * cancellation - * ==================== - * ==================== - */ -#define PTHREAD_CANCELED ((void *)(size_t) -1) - - -/* - * ==================== - * ==================== - * Once Key - * ==================== - * ==================== - */ -#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0} - -struct pthread_once_t_ -{ - int done; /* indicates if user function has been executed */ - void * lock; - int reserved1; - int reserved2; -}; - - -/* - * ==================== - * ==================== - * Object initialisers - * ==================== - * ==================== - */ -#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -1) -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -2) -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -3) - -/* - * Compatibility with LinuxThreads - */ -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER - -#define PTHREAD_COND_INITIALIZER ((pthread_cond_t)(size_t) -1) - -#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t)(size_t) -1) - -#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t)(size_t) -1) - - -/* - * Mutex types. - */ -enum -{ - /* Compatibility with LinuxThreads */ - PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, - /* For compatibility with POSIX */ - PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL -}; - - -typedef struct ptw32_cleanup_t ptw32_cleanup_t; - -#if defined(_MSC_VER) -/* Disable MSVC 'anachronism used' warning */ -#pragma warning( disable : 4229 ) -#endif - -typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *); - -#if defined(_MSC_VER) -#pragma warning( default : 4229 ) -#endif - -struct ptw32_cleanup_t -{ - ptw32_cleanup_callback_t routine; - void *arg; - struct ptw32_cleanup_t *prev; -}; - -#if defined(__CLEANUP_SEH) - /* - * WIN32 SEH version of cancel cleanup. - */ - -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - ptw32_cleanup_t _cleanup; \ - \ - _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \ - _cleanup.arg = (_arg); \ - __try \ - { \ - -#define pthread_cleanup_pop( _execute ) \ - } \ - __finally \ - { \ - if( _execute || AbnormalTermination()) \ - { \ - (*(_cleanup.routine))( _cleanup.arg ); \ - } \ - } \ - } - -#else /* __CLEANUP_SEH */ - -#if defined(__CLEANUP_C) - - /* - * C implementation of PThreads cancel cleanup - */ - -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - ptw32_cleanup_t _cleanup; \ - \ - ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \ - -#define pthread_cleanup_pop( _execute ) \ - (void) ptw32_pop_cleanup( _execute ); \ - } - -#else /* __CLEANUP_C */ - -#if defined(__CLEANUP_CXX) - - /* - * C++ version of cancel cleanup. - * - John E. Bossom. - */ - - class PThreadCleanup { - /* - * PThreadCleanup - * - * Purpose - * This class is a C++ helper class that is - * used to implement pthread_cleanup_push/ - * pthread_cleanup_pop. - * The destructor of this class automatically - * pops the pushed cleanup routine regardless - * of how the code exits the scope - * (i.e. such as by an exception) - */ - ptw32_cleanup_callback_t cleanUpRout; - void * obj; - int executeIt; - - public: - PThreadCleanup() : - cleanUpRout( 0 ), - obj( 0 ), - executeIt( 0 ) - /* - * No cleanup performed - */ - { - } - - PThreadCleanup( - ptw32_cleanup_callback_t routine, - void * arg ) : - cleanUpRout( routine ), - obj( arg ), - executeIt( 1 ) - /* - * Registers a cleanup routine for 'arg' - */ - { - } - - ~PThreadCleanup() - { - if ( executeIt && ((void *) cleanUpRout != (void *) 0) ) - { - (void) (*cleanUpRout)( obj ); - } - } - - void execute( int exec ) - { - executeIt = exec; - } - }; - - /* - * C++ implementation of PThreads cancel cleanup; - * This implementation takes advantage of a helper - * class who's destructor automatically calls the - * cleanup routine if we exit our scope weirdly - */ -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ - (void *) (_arg) ); - -#define pthread_cleanup_pop( _execute ) \ - cleanup.execute( _execute ); \ - } - -#else - -#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. - -#endif /* __CLEANUP_CXX */ - -#endif /* __CLEANUP_C */ - -#endif /* __CLEANUP_SEH */ - -/* - * =============== - * =============== - * Methods - * =============== - * =============== - */ - -/* - * PThread Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, - int *detachstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, - void **stackaddr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, - size_t * stacksize); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, - int detachstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, - void *stackaddr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, - size_t stacksize); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, - struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, - const struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, - int); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, - int *); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, - int inheritsched); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, - int * inheritsched); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, - int); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, - int *); - -/* - * PThread Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, - const pthread_attr_t * attr, - void *(PTW32_CDECL *start) (void *), - void *arg); - -PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); - -PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1, - pthread_t t2); - -PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr); - -PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread, - void **value_ptr); - -PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void); - -PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread); - -PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state, - int *oldstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, - int *oldtype); - -PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); - -PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, - void (PTW32_CDECL *init_routine) (void)); - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); - -PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, - ptw32_cleanup_callback_t routine, - void *arg); -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Thread Specific Data Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, - void (PTW32_CDECL *destructor) (void *)); - -PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); - -PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key, - const void *value); - -PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key); - - -/* - * Mutex Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t - * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, - int pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setrobust( - pthread_mutexattr_t *attr, - int robust); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getrobust( - const pthread_mutexattr_t * attr, - int * robust); - -/* - * Barrier Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t - * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, - int pshared); - -/* - * Mutex Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, - const pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex); - -/* - * Spinlock Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); - -/* - * Barrier Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, - const pthread_barrierattr_t * attr, - unsigned int count); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); - -/* - * Condition Variable Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, - int pshared); - -/* - * Condition Variable Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, - const pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, - pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); - -/* - * Scheduling - */ -PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread, - int policy, - const struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread, - int *policy, - struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int); - -PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void); - -/* - * Read-Write Lock Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, - const pthread_rwlockattr_t *attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, - int pshared); - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 - -/* - * Signal Functions. Should be defined in but MSVC and MinGW32 - * already have signal.h that don't define these. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); - -/* - * Non-portable functions - */ - -/* - * Compatibility with Linux. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, - int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, - int *kind); -PTW32_DLLPORT int PTW32_CDECL pthread_timedjoin_np(pthread_t thread, - void **value_ptr, - const struct timespec *abstime); - -/* - * Possibly supported by other POSIX threads implementations - */ -PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); -PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); -PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread); - -/* - * Useful if an application wants to statically link - * the lib rather than load the DLL at run-time. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void); - -/* - * Features that are auto-detected at load/run time. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int); -enum ptw32_features { - PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */ - PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */ -}; - -/* - * Register a system time change with the library. - * Causes the library to perform various functions - * in response to the change. Should be called whenever - * the application's top level window receives a - * WM_TIMECHANGE message. It can be passed directly to - * pthread_create() as a new thread if desired. - */ -PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); - -#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - -/* - * Returns the Win32 HANDLE for the POSIX thread. - */ -PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); -/* - * Returns the win32 thread ID for POSIX thread. - */ -PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); - - -/* - * Protected Methods - * - * This function blocks until the given WIN32 handle - * is signaled or pthread_cancel had been called. - * This function allows the caller to hook into the - * PThreads cancel mechanism. It is implemented using - * - * WaitForMultipleObjects - * - * on 'waitHandle' and a manually reset WIN32 Event - * used to implement pthread_cancel. The 'timeout' - * argument to TimedWait is simply passed to - * WaitForMultipleObjects. - */ -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle); -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, - DWORD timeout); - -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Thread-Safe C Runtime Library Mappings. - */ -#if !defined(_UWIN) -# if defined(NEED_ERRNO) - PTW32_DLLPORT int * PTW32_CDECL _errno( void ); -# else -# if !defined(errno) -# if (defined(_MT) || defined(_DLL)) - __declspec(dllimport) extern int * __cdecl _errno(void); -# define errno (*_errno()) -# endif -# endif -# endif -#endif - -/* - * Some compiler environments don't define some things. - */ -#if defined(__BORLANDC__) -# define _ftime ftime -# define _timeb timeb -#endif - -#if defined(__cplusplus) - -/* - * Internal exceptions - */ -class ptw32_exception {}; -class ptw32_exception_cancel : public ptw32_exception {}; -class ptw32_exception_exit : public ptw32_exception {}; - -#endif - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - -/* FIXME: This is only required if the library was built using SEH */ -/* - * Get internal SEH tag - */ -PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); - -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -#if !defined(PTW32_BUILD) - -#if defined(__CLEANUP_SEH) - -/* - * Redefine the SEH __except keyword to ensure that applications - * propagate our internal exceptions up to the library's internal handlers. - */ -#define __except( E ) \ - __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ - ? EXCEPTION_CONTINUE_SEARCH : ( E ) ) - -#endif /* __CLEANUP_SEH */ - -#if defined(__CLEANUP_CXX) - -/* - * Redefine the C++ catch keyword to ensure that applications - * propagate our internal exceptions up to the library's internal handlers. - */ -#if defined(_MSC_VER) - /* - * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' - * if you want Pthread-Win32 cancellation and pthread_exit to work. - */ - -#if !defined(PtW32NoCatchWarn) - -#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.") -#pragma message("------------------------------------------------------------------") -#pragma message("When compiling applications with MSVC++ and C++ exception handling:") -#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads") -#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread") -#pragma message(" cancellation and pthread_exit to work. For example:") -#pragma message("") -#pragma message(" #if defined(PtW32CatchAll)") -#pragma message(" PtW32CatchAll") -#pragma message(" #else") -#pragma message(" catch(...)") -#pragma message(" #endif") -#pragma message(" {") -#pragma message(" /* Catchall block processing */") -#pragma message(" }") -#pragma message("------------------------------------------------------------------") - -#endif - -#define PtW32CatchAll \ - catch( ptw32_exception & ) { throw; } \ - catch( ... ) - -#else /* _MSC_VER */ - -#define catch( E ) \ - catch( ptw32_exception & ) { throw; } \ - catch( E ) - -#endif /* _MSC_VER */ - -#endif /* __CLEANUP_CXX */ - -#endif /* ! PTW32_BUILD */ - -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#if defined(PTW32__HANDLE_DEF) -# undef HANDLE -#endif -#if defined(PTW32__DWORD_DEF) -# undef DWORD -#endif - -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX - -#endif /* ! RC_INVOKED */ - -#endif /* PTHREAD_H */ diff --git a/libraries/shared/external/sched.h b/libraries/shared/external/sched.h deleted file mode 100644 index d43ff8dcb2..0000000000 --- a/libraries/shared/external/sched.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Module: sched.h - * - * Purpose: - * Provides an implementation of POSIX realtime extensions - * as defined in - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * The current list of contributors is contained - * in the file CONTRIBUTORS included with the source - * code distribution. The list can also be seen at the - * following World Wide Web location: - * http://sources.redhat.com/pthreads-win32/contributors.html - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ -#if !defined(_SCHED_H) -#define _SCHED_H - -#undef PTW32_SCHED_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_SCHED_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_SCHED_LEVEL -#define PTW32_SCHED_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_SCHED_LEVEL -#define PTW32_SCHED_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_SCHED_LEVEL_MAX 3 - -#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL) -#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX -/* Include everything */ -#endif - - -#if defined(__GNUC__) && !defined(__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the library, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the library, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */ - -#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN) -# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX -/* For pid_t */ -# include -/* Required by Unix 98 */ -# include -# else - typedef int pid_t; -# endif -#else - /* [i_a] fix for using pthread_win32 with mongoose code, which #define's its own pid_t akin to typedef HANDLE pid_t; */ - #undef pid_t -# if defined(_MSC_VER) - typedef void *pid_t; -# else - typedef int pid_t; -# endif -#endif - -/* Thread scheduling policies */ - -enum { - SCHED_OTHER = 0, - SCHED_FIFO, - SCHED_RR, - SCHED_MIN = SCHED_OTHER, - SCHED_MAX = SCHED_RR -}; - -struct sched_param { - int sched_priority; -}; - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -PTW32_DLLPORT int __cdecl sched_yield (void); - -PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy); - -PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy); - -PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy); - -PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); - -/* - * Note that this macro returns ENOTSUP rather than - * ENOSYS as might be expected. However, returning ENOSYS - * should mean that sched_get_priority_{min,max} are - * not implemented as well as sched_rr_get_interval. - * This is not the case, since we just don't support - * round-robin scheduling. Therefore I have chosen to - * return the same value as sched_setscheduler when - * SCHED_RR is passed to it. - */ -#define sched_rr_get_interval(_pid, _interval) \ - ( errno = ENOTSUP, (int) -1 ) - - -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#undef PTW32_SCHED_LEVEL -#undef PTW32_SCHED_LEVEL_MAX - -#endif /* !_SCHED_H */ - From b5c8a4d2c635d4788b7c7fc6597293861fe66849 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 15:47:57 -0700 Subject: [PATCH 29/94] fix requirement of networking in audio library --- cmake/macros/LinkHifiLibrary.cmake | 9 ++++++++- libraries/animation/CMakeLists.txt | 9 ++++++--- libraries/audio/CMakeLists.txt | 7 +++++++ libraries/embedded-webserver/CMakeLists.txt | 8 ++++---- libraries/fbx/CMakeLists.txt | 6 +++++- libraries/metavoxels/CMakeLists.txt | 10 +++++++--- libraries/models/CMakeLists.txt | 11 +---------- libraries/networking/CMakeLists.txt | 13 ++++--------- libraries/shared/CMakeLists.txt | 10 +++++----- 9 files changed, 47 insertions(+), 36 deletions(-) diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index afb1f1febd..227ddf066a 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -17,5 +17,12 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) add_dependencies(${TARGET} ${LIBRARY}) - target_link_libraries(${TARGET} ${LIBRARY} ${SUB_DEPENDENCY_LIBRARIES}) + get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${LIBRARY} DEPENDENCY_LIBRARIES) + + if (LINKED_TARGET_DEPENDENCY_LIBRARIES) + target_link_libraries(${TARGET} ${LIBRARY} ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) + else () + target_link_libraries(${TARGET} ${LIBRARY}) + endif () + endmacro(LINK_HIFI_LIBRARY _library _target _root_dir) \ No newline at end of file diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index be6ed47898..20f4a59181 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME animation) -find_package(Qt5 COMPONENTS Script) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -15,7 +13,12 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -target_link_libraries(${TARGET_NAME} Qt5::Script) +find_package(Qt5Script) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Script) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 2ad8a4b0bc..69cc61ca6d 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -20,6 +20,13 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +find_package(Qt5Network) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index f1681cdd12..eb28cae1b3 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -11,7 +11,7 @@ setup_hifi_library(${TARGET_NAME}) find_package(Qt5Network REQUIRED) -# bubble up the libraries we are dependent on and link them to ourselves -set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network) -set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 45d1051dc6..a125de1320 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -22,7 +22,11 @@ link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") find_package(ZLIB) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) + +# bubble up the libraries we are dependent on and link them to ourselves +set(REQUIRED_DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") +set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index c79631ce06..c419f664a0 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME metavoxels) -find_package(Qt5 COMPONENTS Network Script Widgets) - include(${MACRO_DIR}/AutoMTC.cmake) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") @@ -21,7 +19,13 @@ link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) +find_package(Qt5Script) +find_package(Qt5Widgets) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 8056d215da..142faee2b3 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -8,11 +8,8 @@ set(TARGET_NAME models) find_package(Qt5Widgets REQUIRED) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} "${ROOT_DIR}") - include(${MACRO_DIR}/SetupHifiLibrary.cmake) -setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") +setup_hifi_library(${TARGET_NAME}) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") @@ -27,12 +24,6 @@ link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") # for streamable link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -# link ZLIB -find_package(ZLIB) - -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 215d406133..2d47f7df9b 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -2,21 +2,16 @@ set(ROOT_DIR ../..) set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(TARGET_NAME networking) -project(${TARGET_NAME}) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -# include GLM -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - find_package(Qt5Network) -# bubble up the libraries we are dependent on and link them to ourselves -set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network) -set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 067551ba31..5faedff6ed 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -14,16 +14,16 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") # link required libraries on UNIX if (APPLE) find_library(CoreServices CoreServices) - list(APPEND REQUIRED_DEPENDENCY_LIBRARIES ${CoreServices}) + set(DEPENDENCY_LIBRARIES ${CoreServices}) elseif (UNIX) find_package(Threads REQUIRED) - LIST(APPEND REQUIRED_DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") + set(DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif () find_package(Qt5Network) find_package(Qt5Widgets) # bubble up the libraries we are dependent on and link them to ourselves -list(APPEND REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) -set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file +list(APPEND DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file From 1059e9a6355b1d72f0d9020e4c0b5f681ea908a0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 15:50:15 -0700 Subject: [PATCH 30/94] add back more required Qt modules --- libraries/avatars/CMakeLists.txt | 7 +++++++ libraries/fbx/CMakeLists.txt | 8 ++++---- libraries/metavoxels/CMakeLists.txt | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index feb1e68557..c7defaafe2 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -19,6 +19,13 @@ link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +find_package(Qt5Network) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index a125de1320..ba51fe2e06 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -23,10 +23,10 @@ find_package(ZLIB) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -# bubble up the libraries we are dependent on and link them to ourselves -set(REQUIRED_DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") -set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index c419f664a0..10feb55199 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -21,9 +21,10 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") find_package(Qt5Script) find_package(Qt5Widgets) +find_package(Qt5Network) # set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets) +set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) From 2bb37f2d64b313e701dd7d6817d7e6970dd1853a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 15:56:39 -0700 Subject: [PATCH 31/94] more Qt module dependencies sorted out for libraries --- libraries/animation/CMakeLists.txt | 3 ++- libraries/avatars/CMakeLists.txt | 5 +++-- libraries/models/CMakeLists.txt | 8 ++++++++ libraries/octree/CMakeLists.txt | 9 ++++----- libraries/particles/CMakeLists.txt | 8 ++++++++ 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 20f4a59181..1ed0275a72 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -14,9 +14,10 @@ link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") find_package(Qt5Script) +find_package(Qt5Network) # set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script) +set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index c7defaafe2..2aae671146 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -20,10 +20,11 @@ link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") find_package(Qt5Network) +find_package(Qt5Script) # set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 142faee2b3..0d7b3cf4fc 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -24,6 +24,14 @@ link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") # for streamable link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") +find_package(Qt5Network) +find_package(Qt5Script) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 99da8d1bf2..d0beade108 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -21,12 +21,11 @@ find_package(ZLIB) find_package(OpenSSL REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") - -# bubble up the libraries we are dependent on -set(REQUIRED_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} - "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index cecbdaaa21..ceac4324c0 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -19,6 +19,14 @@ link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") +find_package(Qt5Network) +find_package(Qt5Script) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) From 892e30c5e17e09f44a1a3514d75151250a760b57 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 16:13:29 -0700 Subject: [PATCH 32/94] get past assignment-client build after cmake auditing --- assignment-client/CMakeLists.txt | 14 +++++- interface/CMakeLists.txt | 52 ++++++++++----------- libraries/animation/CMakeLists.txt | 3 +- libraries/audio/CMakeLists.txt | 2 +- libraries/audio/src/AudioRingBuffer.cpp | 4 +- libraries/audio/src/AudioRingBuffer.h | 6 +-- libraries/avatars/CMakeLists.txt | 3 +- libraries/embedded-webserver/CMakeLists.txt | 2 +- libraries/metavoxels/CMakeLists.txt | 4 +- libraries/models/CMakeLists.txt | 3 +- libraries/networking/CMakeLists.txt | 2 +- libraries/particles/CMakeLists.txt | 5 +- libraries/script-engine/CMakeLists.txt | 11 ++--- libraries/shared/CMakeLists.txt | 5 +- 14 files changed, 57 insertions(+), 59 deletions(-) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index a4e26899fb..3fb0f574a5 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,6 +9,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) +include(${MACRO_DIR}/IncludeGLM.cmake) +include_glm(${TARGET_NAME} "${ROOT_DIR}") + # link in the shared libraries include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") @@ -26,13 +29,20 @@ link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}") if (UNIX) - target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS}) + list(APPEND DEPENDENCY_LIBRARIES ${CMAKE_DL_LIBS}) endif (UNIX) IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) + list(APPEND DEPENDENCY_LIBRARIES Winmm Ws2_32) ENDIF(WIN32) +find_package(Qt5 COMPONENTS Gui Network Script Widgets) + +# set a property indicating the libraries we are dependent on and link them to ourselves +list(APPEND DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 5c1bec0321..e624388408 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -52,7 +52,7 @@ foreach(SUBDIR avatar devices renderer ui starfield location scripting voxels pa set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}") endforeach(SUBDIR) -find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools) +# find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools) # grab the ui files in resources/ui file (GLOB_RECURSE QT_UI_FILES ui/*.ui) @@ -182,8 +182,6 @@ include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes" target_link_libraries( ${TARGET_NAME} "${ZLIB_LIBRARIES}" - Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL - Qt5::Script Qt5::Svg Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml Qt5::UiTools ) # assume we are using a Qt build without bearer management @@ -191,30 +189,30 @@ add_definitions(-DQT_NO_BEARERMANAGEMENT) if (APPLE) # link in required OS X frameworks and include the right GL headers - find_library(AppKit AppKit) - find_library(CoreAudio CoreAudio) - find_library(CoreServices CoreServices) - find_library(Carbon Carbon) - find_library(Foundation Foundation) - find_library(GLUT GLUT) - find_library(OpenGL OpenGL) - find_library(IOKit IOKit) - find_library(QTKit QTKit) - find_library(QuartzCore QuartzCore) - - target_link_libraries( - ${TARGET_NAME} - ${AppKit} - ${CoreAudio} - ${CoreServices} - ${Carbon} - ${Foundation} - ${GLUT} - ${OpenGL} - ${IOKit} - ${QTKit} - ${QuartzCore} - ) + # find_library(AppKit AppKit) + # find_library(CoreAudio CoreAudio) + # find_library(CoreServices CoreServices) + # find_library(Carbon Carbon) + # find_library(Foundation Foundation) + # find_library(GLUT GLUT) + # find_library(OpenGL OpenGL) + # find_library(IOKit IOKit) + # find_library(QTKit QTKit) + # find_library(QuartzCore QuartzCore) + # + # target_link_libraries( + # ${TARGET_NAME} + # ${AppKit} + # ${CoreAudio} + # ${CoreServices} + # ${Carbon} + # ${Foundation} + # ${GLUT} + # ${OpenGL} + # ${IOKit} + # ${QTKit} + # ${QuartzCore} + # ) # install command for OS X bundle INSTALL(TARGETS ${TARGET_NAME} diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 1ed0275a72..7891c65dcc 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -13,8 +13,7 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Script) -find_package(Qt5Network) +find_package(Qt5 COMPONENTS Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 69cc61ca6d..ace5f9292c 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -20,7 +20,7 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network) +find_package(Qt5 COMPONENTS Network) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network) diff --git a/libraries/audio/src/AudioRingBuffer.cpp b/libraries/audio/src/AudioRingBuffer.cpp index c687ab8648..cae663758d 100644 --- a/libraries/audio/src/AudioRingBuffer.cpp +++ b/libraries/audio/src/AudioRingBuffer.cpp @@ -15,9 +15,9 @@ #include -#include "PacketHeaders.h" -#include "AudioRingBuffer.h" +#include +#include "AudioRingBuffer.h" AudioRingBuffer::AudioRingBuffer(int numFrameSamples, bool randomAccessMode, int numFramesCapacity) : _frameCapacity(numFramesCapacity), diff --git a/libraries/audio/src/AudioRingBuffer.h b/libraries/audio/src/AudioRingBuffer.h index ed680b18b1..b4b30b1f56 100644 --- a/libraries/audio/src/AudioRingBuffer.h +++ b/libraries/audio/src/AudioRingBuffer.h @@ -15,12 +15,10 @@ #include #include -#include - #include -#include "NodeData.h" -#include "SharedUtil.h" +#include +#include const int SAMPLE_RATE = 24000; diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 2aae671146..1300a2e733 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -19,8 +19,7 @@ link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network) -find_package(Qt5Script) +find_package(Qt5 COMPONENTS Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index eb28cae1b3..5b815625ba 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -9,7 +9,7 @@ set(TARGET_NAME embedded-webserver) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -find_package(Qt5Network REQUIRED) +find_package(Qt5 COMPONENTS Network) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 10feb55199..799a549a3b 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -19,9 +19,7 @@ link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Script) -find_package(Qt5Widgets) -find_package(Qt5Network) +find_package(Qt5 COMPONENTS Network Script Widgets) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 0d7b3cf4fc..8128741ef6 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -24,8 +24,7 @@ link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") # for streamable link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network) -find_package(Qt5Script) +find_package(Qt5 COMPONENTS Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 2d47f7df9b..7bd210623b 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -6,7 +6,7 @@ set(TARGET_NAME networking) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -find_package(Qt5Network) +find_package(Qt5 COMPONENTS Network) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network) diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index ceac4324c0..54398ac252 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -19,11 +19,10 @@ link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network) -find_package(Qt5Script) +find_package(Qt5 COMPONENTS Gui Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) +set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script Qt5::Gui) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 2dd40c7ece..1b0199977f 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME script-engine) -find_package(Qt5Widgets REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -23,11 +21,12 @@ link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -# link ZLIB -find_package(ZLIB) +find_package(Qt5 COMPONENTS Gui Network Script Widgets) -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 5faedff6ed..6badb10f8e 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -20,10 +20,9 @@ elseif (UNIX) set(DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif () -find_package(Qt5Network) -find_package(Qt5Widgets) +find_package(Qt5 COMPONENTS Network Widgets) # bubble up the libraries we are dependent on and link them to ourselves list(APPEND DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file From 0378fb30491b934c537e6b3d48325442f16f9e9b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 17:09:27 -0700 Subject: [PATCH 33/94] break glm helpers out of SharedUtil --- assignment-client/CMakeLists.txt | 13 +- domain-server/CMakeLists.txt | 5 +- libraries/shared/src/AngularConstraint.cpp | 3 +- libraries/shared/src/AngularConstraint.h | 1 - libraries/shared/src/GLMHelpers.cpp | 299 +++++++++++++++++++++ libraries/shared/src/GLMHelpers.h | 89 ++++++ libraries/shared/src/SharedUtil.cpp | 290 -------------------- libraries/shared/src/SharedUtil.h | 69 ----- 8 files changed, 397 insertions(+), 372 deletions(-) create mode 100644 libraries/shared/src/GLMHelpers.cpp create mode 100644 libraries/shared/src/GLMHelpers.h diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 3fb0f574a5..2f3739485a 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,9 +9,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - # link in the shared libraries include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") @@ -29,19 +26,15 @@ link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}") if (UNIX) - list(APPEND DEPENDENCY_LIBRARIES ${CMAKE_DL_LIBS}) + target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) endif (UNIX) IF (WIN32) - list(APPEND DEPENDENCY_LIBRARIES Winmm Ws2_32) + target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} Winmm Ws2_32) ENDIF(WIN32) find_package(Qt5 COMPONENTS Gui Network Script Widgets) - -# set a property indicating the libraries we are dependent on and link them to ourselves -list(APPEND DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 26f07cf776..656760957d 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -32,4 +32,7 @@ ENDIF(WIN32) # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +endif () + +find_package(Qt5 COMPONENTS Network) +target_link_libraries(${TARGET_NAME} Qt5::Network) diff --git a/libraries/shared/src/AngularConstraint.cpp b/libraries/shared/src/AngularConstraint.cpp index 4689568ac8..b39823ee3b 100644 --- a/libraries/shared/src/AngularConstraint.cpp +++ b/libraries/shared/src/AngularConstraint.cpp @@ -11,8 +11,9 @@ #include +#include "GLMHelpers.h" + #include "AngularConstraint.h" -#include "SharedUtil.h" // helper function /// \param angle radian angle to be clamped within angleMin and angleMax diff --git a/libraries/shared/src/AngularConstraint.h b/libraries/shared/src/AngularConstraint.h index 929a58959b..74d3fdb82b 100644 --- a/libraries/shared/src/AngularConstraint.h +++ b/libraries/shared/src/AngularConstraint.h @@ -14,7 +14,6 @@ #include - class AngularConstraint { public: /// \param minAngles minumum euler angles for the constraint diff --git a/libraries/shared/src/GLMHelpers.cpp b/libraries/shared/src/GLMHelpers.cpp new file mode 100644 index 0000000000..566983679b --- /dev/null +++ b/libraries/shared/src/GLMHelpers.cpp @@ -0,0 +1,299 @@ +// +// GLMHelpers.cpp +// libraries/shared/src +// +// Created by Stephen Birarda on 2014-08-07. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "GLMHelpers.h" + +// Safe version of glm::mix; based on the code in Nick Bobick's article, +// http://www.gamasutra.com/features/19980703/quaternions_01.htm (via Clyde, +// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java) +glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float proportion) { + float cosa = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; + float ox = q2.x, oy = q2.y, oz = q2.z, ow = q2.w, s0, s1; + + // adjust signs if necessary + if (cosa < 0.0f) { + cosa = -cosa; + ox = -ox; + oy = -oy; + oz = -oz; + ow = -ow; + } + + // calculate coefficients; if the angle is too close to zero, we must fall back + // to linear interpolation + if ((1.0f - cosa) > EPSILON) { + float angle = acosf(cosa), sina = sinf(angle); + s0 = sinf((1.0f - proportion) * angle) / sina; + s1 = sinf(proportion * angle) / sina; + + } else { + s0 = 1.0f - proportion; + s1 = proportion; + } + + return glm::normalize(glm::quat(s0 * q1.w + s1 * ow, s0 * q1.x + s1 * ox, s0 * q1.y + s1 * oy, s0 * q1.z + s1 * oz)); +} + +// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc +int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix) { + int16_t outVal = (int16_t)(scalar * (float)(1 << radix)); + memcpy(buffer, &outVal, sizeof(uint16_t)); + return sizeof(uint16_t); +} + +int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix) { + *destinationPointer = *byteFixedPointer / (float)(1 << radix); + return sizeof(int16_t); +} + +int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix) { + const unsigned char* startPosition = destBuffer; + destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.x, radix); + destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.y, radix); + destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.z, radix); + return destBuffer - startPosition; +} + +int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix) { + const unsigned char* startPosition = sourceBuffer; + sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.x), radix); + sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.y), radix); + sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.z), radix); + return sourceBuffer - startPosition; +} + + +int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) { + const float ANGLE_CONVERSION_RATIO = (std::numeric_limits::max() / 360.f); + + uint16_t angleHolder = floorf((degrees + 180.f) * ANGLE_CONVERSION_RATIO); + memcpy(buffer, &angleHolder, sizeof(uint16_t)); + + return sizeof(uint16_t); +} + +int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) { + *destinationPointer = (*byteAnglePointer / (float) std::numeric_limits::max()) * 360.f - 180.f; + return sizeof(uint16_t); +} + +int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) { + const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits::max() / 2.f); + uint16_t quatParts[4]; + quatParts[0] = floorf((quatInput.x + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[1] = floorf((quatInput.y + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[2] = floorf((quatInput.z + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[3] = floorf((quatInput.w + 1.f) * QUAT_PART_CONVERSION_RATIO); + + memcpy(buffer, &quatParts, sizeof(quatParts)); + return sizeof(quatParts); +} + +int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput) { + uint16_t quatParts[4]; + memcpy(&quatParts, buffer, sizeof(quatParts)); + + quatOutput.x = ((quatParts[0] / (float) std::numeric_limits::max()) * 2.f) - 1.f; + quatOutput.y = ((quatParts[1] / (float) std::numeric_limits::max()) * 2.f) - 1.f; + quatOutput.z = ((quatParts[2] / (float) std::numeric_limits::max()) * 2.f) - 1.f; + quatOutput.w = ((quatParts[3] / (float) std::numeric_limits::max()) * 2.f) - 1.f; + + return sizeof(quatParts); +} + +// Safe version of glm::eulerAngles; uses the factorization method described in David Eberly's +// http://www.geometrictools.com/Documentation/EulerAngles.pdf (via Clyde, +// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java) +glm::vec3 safeEulerAngles(const glm::quat& q) { + float sy = 2.0f * (q.y * q.w - q.x * q.z); + glm::vec3 eulers; + if (sy < 1.0f - EPSILON) { + if (sy > -1.0f + EPSILON) { + eulers = glm::vec3( + atan2f(q.y * q.z + q.x * q.w, 0.5f - (q.x * q.x + q.y * q.y)), + asinf(sy), + atan2f(q.x * q.y + q.z * q.w, 0.5f - (q.y * q.y + q.z * q.z))); + + } else { + // not a unique solution; x + z = atan2(-m21, m11) + eulers = glm::vec3( + 0.0f, + - PI_OVER_TWO, + atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z))); + } + } else { + // not a unique solution; x - z = atan2(-m21, m11) + eulers = glm::vec3( + 0.0f, + PI_OVER_TWO, + -atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z))); + } + + // adjust so that z, rather than y, is in [-pi/2, pi/2] + if (eulers.z < -PI_OVER_TWO) { + if (eulers.x < 0.0f) { + eulers.x += PI; + } else { + eulers.x -= PI; + } + eulers.y = -eulers.y; + if (eulers.y < 0.0f) { + eulers.y += PI; + } else { + eulers.y -= PI; + } + eulers.z += PI; + + } else if (eulers.z > PI_OVER_TWO) { + if (eulers.x < 0.0f) { + eulers.x += PI; + } else { + eulers.x -= PI; + } + eulers.y = -eulers.y; + if (eulers.y < 0.0f) { + eulers.y += PI; + } else { + eulers.y -= PI; + } + eulers.z -= PI; + } + return eulers; +} + +// Helper function returns the positive angle (in radians) between two 3D vectors +float angleBetween(const glm::vec3& v1, const glm::vec3& v2) { + return acosf((glm::dot(v1, v2)) / (glm::length(v1) * glm::length(v2))); +} + +// Helper function return the rotation from the first vector onto the second +glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2) { + float angle = angleBetween(v1, v2); + if (glm::isnan(angle) || angle < EPSILON) { + return glm::quat(); + } + glm::vec3 axis; + if (angle > 179.99f * RADIANS_PER_DEGREE) { // 180 degree rotation; must use another axis + axis = glm::cross(v1, glm::vec3(1.0f, 0.0f, 0.0f)); + float axisLength = glm::length(axis); + if (axisLength < EPSILON) { // parallel to x; y will work + axis = glm::normalize(glm::cross(v1, glm::vec3(0.0f, 1.0f, 0.0f))); + } else { + axis /= axisLength; + } + } else { + axis = glm::normalize(glm::cross(v1, v2)); + // It is possible for axis to be nan even when angle is not less than EPSILON. + // For example when angle is small but not tiny but v1 and v2 and have very short lengths. + if (glm::isnan(glm::dot(axis, axis))) { + // set angle and axis to values that will generate an identity rotation + angle = 0.0f; + axis = glm::vec3(1.0f, 0.0f, 0.0f); + } + } + return glm::angleAxis(angle, axis); +} + +glm::vec3 extractTranslation(const glm::mat4& matrix) { + return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]); +} + +void setTranslation(glm::mat4& matrix, const glm::vec3& translation) { + matrix[3][0] = translation.x; + matrix[3][1] = translation.y; + matrix[3][2] = translation.z; +} + +glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal) { + // uses the iterative polar decomposition algorithm described by Ken Shoemake at + // http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf + // code adapted from Clyde, https://github.com/threerings/clyde/blob/master/core/src/main/java/com/threerings/math/Matrix4f.java + // start with the contents of the upper 3x3 portion of the matrix + glm::mat3 upper = glm::mat3(matrix); + if (!assumeOrthogonal) { + for (int i = 0; i < 10; i++) { + // store the results of the previous iteration + glm::mat3 previous = upper; + + // compute average of the matrix with its inverse transpose + float sd00 = previous[1][1] * previous[2][2] - previous[2][1] * previous[1][2]; + float sd10 = previous[0][1] * previous[2][2] - previous[2][1] * previous[0][2]; + float sd20 = previous[0][1] * previous[1][2] - previous[1][1] * previous[0][2]; + float det = previous[0][0] * sd00 + previous[2][0] * sd20 - previous[1][0] * sd10; + if (fabs(det) == 0.0f) { + // determinant is zero; matrix is not invertible + break; + } + float hrdet = 0.5f / det; + upper[0][0] = +sd00 * hrdet + previous[0][0] * 0.5f; + upper[1][0] = -sd10 * hrdet + previous[1][0] * 0.5f; + upper[2][0] = +sd20 * hrdet + previous[2][0] * 0.5f; + + upper[0][1] = -(previous[1][0] * previous[2][2] - previous[2][0] * previous[1][2]) * hrdet + previous[0][1] * 0.5f; + upper[1][1] = +(previous[0][0] * previous[2][2] - previous[2][0] * previous[0][2]) * hrdet + previous[1][1] * 0.5f; + upper[2][1] = -(previous[0][0] * previous[1][2] - previous[1][0] * previous[0][2]) * hrdet + previous[2][1] * 0.5f; + + upper[0][2] = +(previous[1][0] * previous[2][1] - previous[2][0] * previous[1][1]) * hrdet + previous[0][2] * 0.5f; + upper[1][2] = -(previous[0][0] * previous[2][1] - previous[2][0] * previous[0][1]) * hrdet + previous[1][2] * 0.5f; + upper[2][2] = +(previous[0][0] * previous[1][1] - previous[1][0] * previous[0][1]) * hrdet + previous[2][2] * 0.5f; + + // compute the difference; if it's small enough, we're done + glm::mat3 diff = upper - previous; + if (diff[0][0] * diff[0][0] + diff[1][0] * diff[1][0] + diff[2][0] * diff[2][0] + diff[0][1] * diff[0][1] + + diff[1][1] * diff[1][1] + diff[2][1] * diff[2][1] + diff[0][2] * diff[0][2] + diff[1][2] * diff[1][2] + + diff[2][2] * diff[2][2] < EPSILON) { + break; + } + } + } + + // now that we have a nice orthogonal matrix, we can extract the rotation quaternion + // using the method described in http://en.wikipedia.org/wiki/Rotation_matrix#Conversions + float x2 = fabs(1.0f + upper[0][0] - upper[1][1] - upper[2][2]); + float y2 = fabs(1.0f - upper[0][0] + upper[1][1] - upper[2][2]); + float z2 = fabs(1.0f - upper[0][0] - upper[1][1] + upper[2][2]); + float w2 = fabs(1.0f + upper[0][0] + upper[1][1] + upper[2][2]); + return glm::normalize(glm::quat(0.5f * sqrtf(w2), + 0.5f * sqrtf(x2) * (upper[1][2] >= upper[2][1] ? 1.0f : -1.0f), + 0.5f * sqrtf(y2) * (upper[2][0] >= upper[0][2] ? 1.0f : -1.0f), + 0.5f * sqrtf(z2) * (upper[0][1] >= upper[1][0] ? 1.0f : -1.0f))); +} + +glm::vec3 extractScale(const glm::mat4& matrix) { + return glm::vec3(glm::length(matrix[0]), glm::length(matrix[1]), glm::length(matrix[2])); +} + +float extractUniformScale(const glm::mat4& matrix) { + return extractUniformScale(extractScale(matrix)); +} + +float extractUniformScale(const glm::vec3& scale) { + return (scale.x + scale.y + scale.z) / 3.0f; +} + +QByteArray createByteArray(const glm::vec3& vector) { + return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z); +} + +bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) { + // Compute the angular distance between the two orientations + float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB))); + if (isNaN(angleOrientation)) { + angleOrientation = 0.0f; + } + return (angleOrientation <= similarEnough); +} + +bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough) { + // Compute the distance between the two points + float positionDistance = glm::distance(positionA, positionB); + return (positionDistance <= similarEnough); +} \ No newline at end of file diff --git a/libraries/shared/src/GLMHelpers.h b/libraries/shared/src/GLMHelpers.h new file mode 100644 index 0000000000..43a1d09722 --- /dev/null +++ b/libraries/shared/src/GLMHelpers.h @@ -0,0 +1,89 @@ +// +// GLMHelpers.h +// libraries/shared/src +// +// Created by Stephen Birarda on 2014-08-07. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_GLMHelpers_h +#define hifi_GLMHelpers_h + +#include + +#include +#include + +#include + +#include "SharedUtil.h" + +glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float alpha); + +// These pack/unpack functions are designed to start specific known types in as efficient a manner +// as possible. Taking advantage of the known characteristics of the semantic types. + +// Angles are known to be between 0 and 360 degrees, this allows us to encode in 16bits with great accuracy +int packFloatAngleToTwoByte(unsigned char* buffer, float degrees); +int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer); + +// Orientation Quats are known to have 4 normalized components be between -1.0 and 1.0 +// this allows us to encode each component in 16bits with great accuracy +int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput); +int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput); + +// Ratios need the be highly accurate when less than 10, but not very accurate above 10, and they +// are never greater than 1000 to 1, this allows us to encode each component in 16bits +int packFloatRatioToTwoByte(unsigned char* buffer, float ratio); +int unpackFloatRatioFromTwoByte(const unsigned char* buffer, float& ratio); + +// Near/Far Clip values need the be highly accurate when less than 10, but only integer accuracy above 10 and +// they are never greater than 16,000, this allows us to encode each component in 16bits +int packClipValueToTwoByte(unsigned char* buffer, float clipValue); +int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue); + +// Positive floats that don't need to be very precise +int packFloatToByte(unsigned char* buffer, float value, float scaleBy); +int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy); + +// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc +int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix); +int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix); + +// A convenience for sending vec3's as fixed-point floats +int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix); +int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix); + +/// \return vec3 with euler angles in radians +glm::vec3 safeEulerAngles(const glm::quat& q); + +float angleBetween(const glm::vec3& v1, const glm::vec3& v2); + +glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2); + +glm::vec3 extractTranslation(const glm::mat4& matrix); + +void setTranslation(glm::mat4& matrix, const glm::vec3& translation); + +glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal = false); + +glm::vec3 extractScale(const glm::mat4& matrix); + +float extractUniformScale(const glm::mat4& matrix); + +float extractUniformScale(const glm::vec3& scale); + +QByteArray createByteArray(const glm::vec3& vector); + +/// \return bool are two orientations similar to each other +const float ORIENTATION_SIMILAR_ENOUGH = 5.0f; // 10 degrees in any direction +bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, + float similarEnough = ORIENTATION_SIMILAR_ENOUGH); +const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter +bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH); + + +#endif // hifi_GLMHelpers_h \ No newline at end of file diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 2b8b9929e5..470dfffd13 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -79,40 +79,6 @@ bool shouldDo(float desiredInterval, float deltaTime) { return randFloat() < deltaTime / desiredInterval; } -// Safe version of glm::mix; based on the code in Nick Bobick's article, -// http://www.gamasutra.com/features/19980703/quaternions_01.htm (via Clyde, -// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java) -glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float proportion) { - float cosa = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; - float ox = q2.x, oy = q2.y, oz = q2.z, ow = q2.w, s0, s1; - - // adjust signs if necessary - if (cosa < 0.0f) { - cosa = -cosa; - ox = -ox; - oy = -oy; - oz = -oz; - ow = -ow; - } - - // calculate coefficients; if the angle is too close to zero, we must fall back - // to linear interpolation - if ((1.0f - cosa) > EPSILON) { - float angle = acosf(cosa), sina = sinf(angle); - s0 = sinf((1.0f - proportion) * angle) / sina; - s1 = sinf(proportion * angle) / sina; - - } else { - s0 = 1.0f - proportion; - s1 = proportion; - } - - return glm::normalize(glm::quat(s0 * q1.w + s1 * ow, s0 * q1.x + s1 * ox, s0 * q1.y + s1 * oy, s0 * q1.z + s1 * oz)); -} - - - - void outputBufferBits(const unsigned char* buffer, int length, QDebug* continuedDebug) { for (int i = 0; i < length; i++) { outputBits(buffer[i], continuedDebug); @@ -489,73 +455,6 @@ int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int* return -1; // error case } -// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc -int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix) { - int16_t outVal = (int16_t)(scalar * (float)(1 << radix)); - memcpy(buffer, &outVal, sizeof(uint16_t)); - return sizeof(uint16_t); -} - -int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix) { - *destinationPointer = *byteFixedPointer / (float)(1 << radix); - return sizeof(int16_t); -} - -int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix) { - const unsigned char* startPosition = destBuffer; - destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.x, radix); - destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.y, radix); - destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.z, radix); - return destBuffer - startPosition; -} - -int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix) { - const unsigned char* startPosition = sourceBuffer; - sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.x), radix); - sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.y), radix); - sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.z), radix); - return sourceBuffer - startPosition; -} - - -int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) { - const float ANGLE_CONVERSION_RATIO = (std::numeric_limits::max() / 360.f); - - uint16_t angleHolder = floorf((degrees + 180.f) * ANGLE_CONVERSION_RATIO); - memcpy(buffer, &angleHolder, sizeof(uint16_t)); - - return sizeof(uint16_t); -} - -int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) { - *destinationPointer = (*byteAnglePointer / (float) std::numeric_limits::max()) * 360.f - 180.f; - return sizeof(uint16_t); -} - -int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) { - const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits::max() / 2.f); - uint16_t quatParts[4]; - quatParts[0] = floorf((quatInput.x + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[1] = floorf((quatInput.y + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[2] = floorf((quatInput.z + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[3] = floorf((quatInput.w + 1.f) * QUAT_PART_CONVERSION_RATIO); - - memcpy(buffer, &quatParts, sizeof(quatParts)); - return sizeof(quatParts); -} - -int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput) { - uint16_t quatParts[4]; - memcpy(&quatParts, buffer, sizeof(quatParts)); - - quatOutput.x = ((quatParts[0] / (float) std::numeric_limits::max()) * 2.f) - 1.f; - quatOutput.y = ((quatParts[1] / (float) std::numeric_limits::max()) * 2.f) - 1.f; - quatOutput.z = ((quatParts[2] / (float) std::numeric_limits::max()) * 2.f) - 1.f; - quatOutput.w = ((quatParts[3] / (float) std::numeric_limits::max()) * 2.f) - 1.f; - - return sizeof(quatParts); -} - float SMALL_LIMIT = 10.f; float LARGE_LIMIT = 1000.f; @@ -651,199 +550,10 @@ void debug::checkDeadBeef(void* memoryVoid, int size) { assert(memcmp((unsigned char*)memoryVoid, DEADBEEF, std::min(size, DEADBEEF_SIZE)) != 0); } -// Safe version of glm::eulerAngles; uses the factorization method described in David Eberly's -// http://www.geometrictools.com/Documentation/EulerAngles.pdf (via Clyde, -// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java) -glm::vec3 safeEulerAngles(const glm::quat& q) { - float sy = 2.0f * (q.y * q.w - q.x * q.z); - glm::vec3 eulers; - if (sy < 1.0f - EPSILON) { - if (sy > -1.0f + EPSILON) { - eulers = glm::vec3( - atan2f(q.y * q.z + q.x * q.w, 0.5f - (q.x * q.x + q.y * q.y)), - asinf(sy), - atan2f(q.x * q.y + q.z * q.w, 0.5f - (q.y * q.y + q.z * q.z))); - - } else { - // not a unique solution; x + z = atan2(-m21, m11) - eulers = glm::vec3( - 0.0f, - - PI_OVER_TWO, - atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z))); - } - } else { - // not a unique solution; x - z = atan2(-m21, m11) - eulers = glm::vec3( - 0.0f, - PI_OVER_TWO, - -atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z))); - } - - // adjust so that z, rather than y, is in [-pi/2, pi/2] - if (eulers.z < -PI_OVER_TWO) { - if (eulers.x < 0.0f) { - eulers.x += PI; - } else { - eulers.x -= PI; - } - eulers.y = -eulers.y; - if (eulers.y < 0.0f) { - eulers.y += PI; - } else { - eulers.y -= PI; - } - eulers.z += PI; - - } else if (eulers.z > PI_OVER_TWO) { - if (eulers.x < 0.0f) { - eulers.x += PI; - } else { - eulers.x -= PI; - } - eulers.y = -eulers.y; - if (eulers.y < 0.0f) { - eulers.y += PI; - } else { - eulers.y -= PI; - } - eulers.z -= PI; - } - return eulers; -} - -// Helper function returns the positive angle (in radians) between two 3D vectors -float angleBetween(const glm::vec3& v1, const glm::vec3& v2) { - return acosf((glm::dot(v1, v2)) / (glm::length(v1) * glm::length(v2))); -} - -// Helper function return the rotation from the first vector onto the second -glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2) { - float angle = angleBetween(v1, v2); - if (glm::isnan(angle) || angle < EPSILON) { - return glm::quat(); - } - glm::vec3 axis; - if (angle > 179.99f * RADIANS_PER_DEGREE) { // 180 degree rotation; must use another axis - axis = glm::cross(v1, glm::vec3(1.0f, 0.0f, 0.0f)); - float axisLength = glm::length(axis); - if (axisLength < EPSILON) { // parallel to x; y will work - axis = glm::normalize(glm::cross(v1, glm::vec3(0.0f, 1.0f, 0.0f))); - } else { - axis /= axisLength; - } - } else { - axis = glm::normalize(glm::cross(v1, v2)); - // It is possible for axis to be nan even when angle is not less than EPSILON. - // For example when angle is small but not tiny but v1 and v2 and have very short lengths. - if (glm::isnan(glm::dot(axis, axis))) { - // set angle and axis to values that will generate an identity rotation - angle = 0.0f; - axis = glm::vec3(1.0f, 0.0f, 0.0f); - } - } - return glm::angleAxis(angle, axis); -} - -glm::vec3 extractTranslation(const glm::mat4& matrix) { - return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]); -} - -void setTranslation(glm::mat4& matrix, const glm::vec3& translation) { - matrix[3][0] = translation.x; - matrix[3][1] = translation.y; - matrix[3][2] = translation.z; -} - -glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal) { - // uses the iterative polar decomposition algorithm described by Ken Shoemake at - // http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf - // code adapted from Clyde, https://github.com/threerings/clyde/blob/master/core/src/main/java/com/threerings/math/Matrix4f.java - // start with the contents of the upper 3x3 portion of the matrix - glm::mat3 upper = glm::mat3(matrix); - if (!assumeOrthogonal) { - for (int i = 0; i < 10; i++) { - // store the results of the previous iteration - glm::mat3 previous = upper; - - // compute average of the matrix with its inverse transpose - float sd00 = previous[1][1] * previous[2][2] - previous[2][1] * previous[1][2]; - float sd10 = previous[0][1] * previous[2][2] - previous[2][1] * previous[0][2]; - float sd20 = previous[0][1] * previous[1][2] - previous[1][1] * previous[0][2]; - float det = previous[0][0] * sd00 + previous[2][0] * sd20 - previous[1][0] * sd10; - if (fabs(det) == 0.0f) { - // determinant is zero; matrix is not invertible - break; - } - float hrdet = 0.5f / det; - upper[0][0] = +sd00 * hrdet + previous[0][0] * 0.5f; - upper[1][0] = -sd10 * hrdet + previous[1][0] * 0.5f; - upper[2][0] = +sd20 * hrdet + previous[2][0] * 0.5f; - - upper[0][1] = -(previous[1][0] * previous[2][2] - previous[2][0] * previous[1][2]) * hrdet + previous[0][1] * 0.5f; - upper[1][1] = +(previous[0][0] * previous[2][2] - previous[2][0] * previous[0][2]) * hrdet + previous[1][1] * 0.5f; - upper[2][1] = -(previous[0][0] * previous[1][2] - previous[1][0] * previous[0][2]) * hrdet + previous[2][1] * 0.5f; - - upper[0][2] = +(previous[1][0] * previous[2][1] - previous[2][0] * previous[1][1]) * hrdet + previous[0][2] * 0.5f; - upper[1][2] = -(previous[0][0] * previous[2][1] - previous[2][0] * previous[0][1]) * hrdet + previous[1][2] * 0.5f; - upper[2][2] = +(previous[0][0] * previous[1][1] - previous[1][0] * previous[0][1]) * hrdet + previous[2][2] * 0.5f; - - // compute the difference; if it's small enough, we're done - glm::mat3 diff = upper - previous; - if (diff[0][0] * diff[0][0] + diff[1][0] * diff[1][0] + diff[2][0] * diff[2][0] + diff[0][1] * diff[0][1] + - diff[1][1] * diff[1][1] + diff[2][1] * diff[2][1] + diff[0][2] * diff[0][2] + diff[1][2] * diff[1][2] + - diff[2][2] * diff[2][2] < EPSILON) { - break; - } - } - } - - // now that we have a nice orthogonal matrix, we can extract the rotation quaternion - // using the method described in http://en.wikipedia.org/wiki/Rotation_matrix#Conversions - float x2 = fabs(1.0f + upper[0][0] - upper[1][1] - upper[2][2]); - float y2 = fabs(1.0f - upper[0][0] + upper[1][1] - upper[2][2]); - float z2 = fabs(1.0f - upper[0][0] - upper[1][1] + upper[2][2]); - float w2 = fabs(1.0f + upper[0][0] + upper[1][1] + upper[2][2]); - return glm::normalize(glm::quat(0.5f * sqrtf(w2), - 0.5f * sqrtf(x2) * (upper[1][2] >= upper[2][1] ? 1.0f : -1.0f), - 0.5f * sqrtf(y2) * (upper[2][0] >= upper[0][2] ? 1.0f : -1.0f), - 0.5f * sqrtf(z2) * (upper[0][1] >= upper[1][0] ? 1.0f : -1.0f))); -} - -glm::vec3 extractScale(const glm::mat4& matrix) { - return glm::vec3(glm::length(matrix[0]), glm::length(matrix[1]), glm::length(matrix[2])); -} - -float extractUniformScale(const glm::mat4& matrix) { - return extractUniformScale(extractScale(matrix)); -} - -float extractUniformScale(const glm::vec3& scale) { - return (scale.x + scale.y + scale.z) / 3.0f; -} - bool isNaN(float value) { return value != value; } -bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) { - // Compute the angular distance between the two orientations - float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB))); - if (isNaN(angleOrientation)) { - angleOrientation = 0.0f; - } - return (angleOrientation <= similarEnough); -} - -bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough) { - // Compute the distance between the two points - float positionDistance = glm::distance(positionA, positionB); - return (positionDistance <= similarEnough); -} - -QByteArray createByteArray(const glm::vec3& vector) { - return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z); -} - QString formatUsecTime(float usecs, int prec) { static const quint64 SECONDS_PER_MINUTE = 60; static const quint64 USECS_PER_MINUTE = USECS_PER_SECOND * SECONDS_PER_MINUTE; diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index 18494d48e4..015758427a 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -19,9 +19,6 @@ #include // not on windows, not needed for mac or windows #endif -#include -#include - #include const int BYTES_PER_COLOR = 3; @@ -71,8 +68,6 @@ float randomSign(); /// \return -1.0 or 1.0 unsigned char randomColorValue(int minimum = 0); bool randomBoolean(); -glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float alpha); - bool shouldDo(float desiredInterval, float deltaTime); void outputBufferBits(const unsigned char* buffer, int length, QDebug* continuedDebug = NULL); @@ -108,8 +103,6 @@ int insertIntoSortedArrays(void* value, float key, int originalIndex, int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount); - - // Helper Class for debugging class debug { public: @@ -124,71 +117,9 @@ private: bool isBetween(int64_t value, int64_t max, int64_t min); -// These pack/unpack functions are designed to start specific known types in as efficient a manner -// as possible. Taking advantage of the known characteristics of the semantic types. - -// Angles are known to be between 0 and 360 degrees, this allows us to encode in 16bits with great accuracy -int packFloatAngleToTwoByte(unsigned char* buffer, float degrees); -int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer); - -// Orientation Quats are known to have 4 normalized components be between -1.0 and 1.0 -// this allows us to encode each component in 16bits with great accuracy -int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput); -int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput); - -// Ratios need the be highly accurate when less than 10, but not very accurate above 10, and they -// are never greater than 1000 to 1, this allows us to encode each component in 16bits -int packFloatRatioToTwoByte(unsigned char* buffer, float ratio); -int unpackFloatRatioFromTwoByte(const unsigned char* buffer, float& ratio); - -// Near/Far Clip values need the be highly accurate when less than 10, but only integer accuracy above 10 and -// they are never greater than 16,000, this allows us to encode each component in 16bits -int packClipValueToTwoByte(unsigned char* buffer, float clipValue); -int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue); - -// Positive floats that don't need to be very precise -int packFloatToByte(unsigned char* buffer, float value, float scaleBy); -int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy); - -// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc -int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix); -int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix); - -// A convenience for sending vec3's as fixed-point floats -int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix); -int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix); - -/// \return vec3 with euler angles in radians -glm::vec3 safeEulerAngles(const glm::quat& q); - -float angleBetween(const glm::vec3& v1, const glm::vec3& v2); - -glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2); - -glm::vec3 extractTranslation(const glm::mat4& matrix); - -void setTranslation(glm::mat4& matrix, const glm::vec3& translation); - -glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal = false); - -glm::vec3 extractScale(const glm::mat4& matrix); - -float extractUniformScale(const glm::mat4& matrix); - -float extractUniformScale(const glm::vec3& scale); - -/// \return bool are two orientations similar to each other -const float ORIENTATION_SIMILAR_ENOUGH = 5.0f; // 10 degrees in any direction -bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, - float similarEnough = ORIENTATION_SIMILAR_ENOUGH); -const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter -bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH); - /// \return bool is the float NaN bool isNaN(float value); -QByteArray createByteArray(const glm::vec3& vector); - QString formatUsecTime(float usecs, int prec = 3); #endif // hifi_SharedUtil_h From 31488e72fe95ff5b459e4d82664ec84cffbb5682 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 08:38:35 -0700 Subject: [PATCH 34/94] repairs for interface build to succeed --- assignment-client/CMakeLists.txt | 3 ++ .../src/avatars/ScriptableAvatar.cpp | 2 ++ cmake/macros/IncludeHifiLibraryHeaders.cmake | 16 +++++++++ cmake/macros/SetupHifiProject.cmake | 6 ++-- cmake/modules/FindLibOVR.cmake | 10 ++++-- domain-server/CMakeLists.txt | 3 +- interface/CMakeLists.txt | 35 +++++-------------- interface/src/devices/CaraFaceTracker.cpp | 2 +- interface/src/renderer/JointState.h | 1 + interface/src/ui/overlays/Base3DOverlay.h | 2 ++ libraries/audio/src/InboundAudioStream.cpp | 2 ++ libraries/avatars/src/AvatarData.cpp | 2 +- libraries/avatars/src/HeadData.cpp | 1 + libraries/avatars/src/Referential.cpp | 2 +- libraries/fbx/src/FBXReader.cpp | 2 +- libraries/metavoxels/src/MetavoxelUtil.cpp | 2 ++ libraries/models/src/ModelItem.cpp | 9 +---- libraries/octree/src/OctreePacketData.cpp | 2 ++ libraries/octree/src/OctreePacketData.h | 1 - libraries/octree/src/OctreeQuery.cpp | 2 +- libraries/particles/src/Particle.cpp | 2 +- libraries/script-engine/src/Quat.cpp | 2 +- 22 files changed, 58 insertions(+), 51 deletions(-) create mode 100644 cmake/macros/IncludeHifiLibraryHeaders.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 2f3739485a..702c4a68ea 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,6 +9,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) +include(${MACRO_DIR}/IncludeGLM.cmake) +include_glm(${TARGET_NAME} "${ROOT_DIR}") + # link in the shared libraries include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") diff --git a/assignment-client/src/avatars/ScriptableAvatar.cpp b/assignment-client/src/avatars/ScriptableAvatar.cpp index 150e364ed7..0f721ac98c 100644 --- a/assignment-client/src/avatars/ScriptableAvatar.cpp +++ b/assignment-client/src/avatars/ScriptableAvatar.cpp @@ -11,6 +11,8 @@ #include +#include + #include "ScriptableAvatar.h" ScriptableAvatar::ScriptableAvatar(ScriptEngine* scriptEngine) : _scriptEngine(scriptEngine), _animation(NULL) { diff --git a/cmake/macros/IncludeHifiLibraryHeaders.cmake b/cmake/macros/IncludeHifiLibraryHeaders.cmake new file mode 100644 index 0000000000..aa7e1118c6 --- /dev/null +++ b/cmake/macros/IncludeHifiLibraryHeaders.cmake @@ -0,0 +1,16 @@ +# +# IncludeHifiLibraryHeaders.cmake +# cmake/macros +# +# Copyright 2014 High Fidelity, Inc. +# Created by Stephen Birarda on August 8, 2014 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +macro(include_hifi_library_headers LIBRARY ROOT_DIR) + + include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") + +endmacro(include_hifi_library_headers _library _root_dir) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index ec731859d4..281aa42650 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -26,9 +26,7 @@ macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) add_executable(${TARGET} ${TARGET_SRCS} ${ARGN}) if (${INCLUDE_QT}) - find_package(Qt5Core REQUIRED) - qt5_use_modules(${TARGET} Core) + find_package(Qt5 COMPONENTS Core) + target_link_libraries(${TARGET} Qt5::Core) endif () - - target_link_libraries(${TARGET} ${QT_LIBRARIES}) endmacro() \ No newline at end of file diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index e90afe29e4..505fd90b51 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -29,6 +29,8 @@ include(SelectLibraryConfigurations) if (APPLE) find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/MacOS/Debug HINTS ${OCULUS_SEARCH_DIRS}) find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/MacOS/Release HINTS ${OCULUS_SEARCH_DIRS}) + find_library(ApplicationServices ApplicationServices) + find_library(IOKit IOKit) elseif (UNIX) find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/) find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/) @@ -53,12 +55,16 @@ endif () select_library_configurations(LIBOVR) set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARY}") -if (UNIX AND NOT APPLE) +if (APPLE) + set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" ${IOKit} ${ApplicationServices}) +elseif (UNIX) set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}") endif () include(FindPackageHandleStandardArgs) -if (UNIX AND NOT APPLE) +if (APPLE) + find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES IOKit ApplicationServices) +elseif (UNIX) find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY) else () find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 656760957d..4a030179e1 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -7,7 +7,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") include(${MACRO_DIR}/SetupHifiProject.cmake) - setup_hifi_project(${TARGET_NAME} TRUE) # remove and then copy the files for the webserver @@ -34,5 +33,5 @@ if (WIN32) add_definitions(-Dssize_t=long) endif () -find_package(Qt5 COMPONENTS Network) +find_package(Qt5 COMPONENTS Network Widgets) target_link_libraries(${TARGET_NAME} Qt5::Network) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index e624388408..f30fcc68ff 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -52,7 +52,7 @@ foreach(SUBDIR avatar devices renderer ui starfield location scripting voxels pa set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}") endforeach(SUBDIR) -# find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools) +find_package(Qt5 COMPONENTS Gui Multimedia Network OpenGL Script Svg WebKitWidgets) # grab the ui files in resources/ui file (GLOB_RECURSE QT_UI_FILES ui/*.ui) @@ -180,8 +180,8 @@ endif () include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") target_link_libraries( - ${TARGET_NAME} - "${ZLIB_LIBRARIES}" + ${TARGET_NAME} "${ZLIB_LIBRARIES}" + Qt5::Gui Qt5::Network Qt5::Multimedia Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKitWidgets ) # assume we are using a Qt build without bearer management @@ -189,30 +189,11 @@ add_definitions(-DQT_NO_BEARERMANAGEMENT) if (APPLE) # link in required OS X frameworks and include the right GL headers - # find_library(AppKit AppKit) - # find_library(CoreAudio CoreAudio) - # find_library(CoreServices CoreServices) - # find_library(Carbon Carbon) - # find_library(Foundation Foundation) - # find_library(GLUT GLUT) - # find_library(OpenGL OpenGL) - # find_library(IOKit IOKit) - # find_library(QTKit QTKit) - # find_library(QuartzCore QuartzCore) - # - # target_link_libraries( - # ${TARGET_NAME} - # ${AppKit} - # ${CoreAudio} - # ${CoreServices} - # ${Carbon} - # ${Foundation} - # ${GLUT} - # ${OpenGL} - # ${IOKit} - # ${QTKit} - # ${QuartzCore} - # ) + find_library(CoreAudio CoreAudio) + find_library(GLUT GLUT) + find_library(OpenGL OpenGL) + + target_link_libraries(${TARGET_NAME} ${CoreAudio} ${GLUT} ${OpenGL}) # install command for OS X bundle INSTALL(TARGETS ${TARGET_NAME} diff --git a/interface/src/devices/CaraFaceTracker.cpp b/interface/src/devices/CaraFaceTracker.cpp index c7ae322ae8..27cf3b175b 100644 --- a/interface/src/devices/CaraFaceTracker.cpp +++ b/interface/src/devices/CaraFaceTracker.cpp @@ -10,7 +10,7 @@ // #include "CaraFaceTracker.h" -#include +#include //qt #include diff --git a/interface/src/renderer/JointState.h b/interface/src/renderer/JointState.h index 81591e816b..21961ba48c 100644 --- a/interface/src/renderer/JointState.h +++ b/interface/src/renderer/JointState.h @@ -16,6 +16,7 @@ #include #include +#include #include class AngularConstraint; diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index e2dcb82454..ffe73f0023 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -11,6 +11,8 @@ #ifndef hifi_Base3DOverlay_h #define hifi_Base3DOverlay_h +#include + #include "Overlay.h" class Base3DOverlay : public Overlay { diff --git a/libraries/audio/src/InboundAudioStream.cpp b/libraries/audio/src/InboundAudioStream.cpp index 0cd9be4a18..ba8d9481b5 100644 --- a/libraries/audio/src/InboundAudioStream.cpp +++ b/libraries/audio/src/InboundAudioStream.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include + #include "InboundAudioStream.h" #include "PacketHeaders.h" diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 96a5f2425b..039ccae4e9 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index b29277ddeb..538085af30 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -11,6 +11,7 @@ #include +#include #include #include "AvatarData.h" diff --git a/libraries/avatars/src/Referential.cpp b/libraries/avatars/src/Referential.cpp index a5a7e7e3e5..784ad3963c 100644 --- a/libraries/avatars/src/Referential.cpp +++ b/libraries/avatars/src/Referential.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "AvatarData.h" #include "Referential.h" diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index cf726800a1..1a152dc217 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -23,9 +23,9 @@ #include #include +#include #include #include -#include #include diff --git a/libraries/metavoxels/src/MetavoxelUtil.cpp b/libraries/metavoxels/src/MetavoxelUtil.cpp index e414c8ebb9..2b46330961 100644 --- a/libraries/metavoxels/src/MetavoxelUtil.cpp +++ b/libraries/metavoxels/src/MetavoxelUtil.cpp @@ -24,6 +24,8 @@ #include #include +#include + #include "MetavoxelUtil.h" #include "ScriptCache.h" #include "StreamUtils.h" diff --git a/libraries/models/src/ModelItem.cpp b/libraries/models/src/ModelItem.cpp index 2a3a88fb65..d6cd8aebc5 100644 --- a/libraries/models/src/ModelItem.cpp +++ b/libraries/models/src/ModelItem.cpp @@ -11,19 +11,12 @@ #include +#include #include #include -#include // usecTimestampNow() #include #include - -// This is not ideal, but adding script-engine as a linked library, will cause a circular reference -// I'm open to other potential solutions. Could we change cmake to allow libraries to reference each others -// headers, but not link to each other, this is essentially what this construct is doing, but would be -// better to add includes to the include path, but not link -#include "../../script-engine/src/ScriptEngine.h" - #include "ModelsScriptingInterface.h" #include "ModelItem.h" #include "ModelTree.h" diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index b54a87bef8..718f2534f8 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -9,7 +9,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include + #include "OctreePacketData.h" bool OctreePacketData::_debug = false; diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index d704923a11..9a6ebfa9ff 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -22,7 +22,6 @@ #ifndef hifi_OctreePacketData_h #define hifi_OctreePacketData_h -#include #include "OctreeConstants.h" #include "OctreeElement.h" diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 687dd18037..94d9bf458e 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "OctreeConstants.h" #include "OctreeQuery.h" diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index 5fffefd8b1..fef2b95fdc 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -13,7 +13,7 @@ #include #include -#include // usecTimestampNow() +#include #include #include diff --git a/libraries/script-engine/src/Quat.cpp b/libraries/script-engine/src/Quat.cpp index 66281883f0..5985858026 100644 --- a/libraries/script-engine/src/Quat.cpp +++ b/libraries/script-engine/src/Quat.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include "Quat.h" From 107cbc3f87205815a6ec97dd035a7538da2d523b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 09:22:19 -0700 Subject: [PATCH 35/94] more simplification of hifi macros to find libraries --- CMakeLists.txt | 10 ++++++++ assignment-client/CMakeLists.txt | 37 +++++++++++------------------- cmake/macros/IncludeGLM.cmake | 4 ++-- cmake/macros/LinkHifiLibrary.cmake | 10 ++++---- domain-server/CMakeLists.txt | 14 +++-------- 5 files changed, 35 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 578c36841d..9f033e5184 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,16 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) +set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries") +set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") +# setup for find modules +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") + +file(GLOB HIFI_CUSTOM_MACROS "cmake/macros/*.cmake") +foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS}) + include(${CUSTOM_MACRO}) +endforeach() + # targets on all platforms add_subdirectory(assignment-client) add_subdirectory(domain-server) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 702c4a68ea..2d7d43227a 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -1,32 +1,23 @@ set(TARGET_NAME assignment-client) -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm(${TARGET_NAME}) # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(audio ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(avatars ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_library(shared ${TARGET_NAME}) +link_hifi_library(audio ${TARGET_NAME}) +link_hifi_library(avatars ${TARGET_NAME}) +link_hifi_library(octree ${TARGET_NAME}) +link_hifi_library(voxels ${TARGET_NAME}) +link_hifi_library(fbx ${TARGET_NAME}) +link_hifi_library(particles ${TARGET_NAME}) +link_hifi_library(models ${TARGET_NAME}) +link_hifi_library(metavoxels ${TARGET_NAME}) +link_hifi_library(networking ${TARGET_NAME}) +link_hifi_library(animation ${TARGET_NAME}) +link_hifi_library(script-engine ${TARGET_NAME}) +link_hifi_library(embedded-webserver ${TARGET_NAME}) if (UNIX) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/cmake/macros/IncludeGLM.cmake b/cmake/macros/IncludeGLM.cmake index a31324993e..ec7816770f 100644 --- a/cmake/macros/IncludeGLM.cmake +++ b/cmake/macros/IncludeGLM.cmake @@ -7,7 +7,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(INCLUDE_GLM TARGET ROOT_DIR) +macro(INCLUDE_GLM TARGET) find_package(GLM REQUIRED) include_directories("${GLM_INCLUDE_DIRS}") @@ -16,4 +16,4 @@ macro(INCLUDE_GLM TARGET ROOT_DIR) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GLM_INCLUDE_DIRS}") endif () -endmacro(INCLUDE_GLM _target _root_dir) \ No newline at end of file +endmacro(INCLUDE_GLM _target) \ No newline at end of file diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 227ddf066a..95af4c6fd0 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -7,13 +7,15 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) +macro(LINK_HIFI_LIBRARY LIBRARY TARGET) + + file(RELATIVE_PATH RELATIVE_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}/${LIBRARY}") if (NOT TARGET ${LIBRARY}) - add_subdirectory("${ROOT_DIR}/libraries/${LIBRARY}" "${ROOT_DIR}/libraries/${LIBRARY}") + add_subdirectory(${RELATIVE_LIBRARY_PATH} ${RELATIVE_LIBRARY_PATH}) endif () - include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") + include_directories("${HIFI_LIBRARY_DIR}/${LIBRARY}/src") add_dependencies(${TARGET} ${LIBRARY}) @@ -25,4 +27,4 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) target_link_libraries(${TARGET} ${LIBRARY}) endif () -endmacro(LINK_HIFI_LIBRARY _library _target _root_dir) \ No newline at end of file +endmacro(LINK_HIFI_LIBRARY _library _target) \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 4a030179e1..e98cee7437 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,12 +1,5 @@ set(TARGET_NAME domain-server) -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) # remove and then copy the files for the webserver @@ -19,10 +12,9 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD $/resources/web) # link the shared hifi library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_library(networking ${TARGET_NAME}) +link_hifi_library(shared ${TARGET_NAME}) +link_hifi_library(embedded-webserver ${TARGET_NAME}) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) From 87cf262b9e49f48ca760f3b34f4d8108fbb4a78f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 09:38:17 -0700 Subject: [PATCH 36/94] get to successful cmake after library link macro changes --- assignment-client/CMakeLists.txt | 14 +----------- cmake/macros/LinkHifiLibraries.cmake | 34 ++++++++++++++++++++++++++++ cmake/macros/LinkHifiLibrary.cmake | 30 ------------------------ domain-server/CMakeLists.txt | 4 +--- interface/CMakeLists.txt | 16 +------------ libraries/audio/CMakeLists.txt | 16 +------------ libraries/metavoxels/CMakeLists.txt | 12 +--------- libraries/octree/CMakeLists.txt | 12 +--------- libraries/shared/CMakeLists.txt | 19 ---------------- tests/audio/CMakeLists.txt | 22 +----------------- tests/jitter/CMakeLists.txt | 24 +------------------- tests/metavoxels/CMakeLists.txt | 17 +------------- tests/networking/CMakeLists.txt | 24 +------------------- tests/octree/CMakeLists.txt | 29 +----------------------- tests/physics/CMakeLists.txt | 27 +--------------------- tests/shared/CMakeLists.txt | 28 +---------------------- tools/bitstream2json/CMakeLists.txt | 25 +------------------- tools/json2bitstream/CMakeLists.txt | 25 +------------------- voxel-edit/CMakeLists.txt | 32 -------------------------- 19 files changed, 49 insertions(+), 361 deletions(-) create mode 100644 cmake/macros/LinkHifiLibraries.cmake delete mode 100644 cmake/macros/LinkHifiLibrary.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 2d7d43227a..628e473853 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -5,19 +5,7 @@ setup_hifi_project(${TARGET_NAME} TRUE) include_glm(${TARGET_NAME}) # link in the shared libraries -link_hifi_library(shared ${TARGET_NAME}) -link_hifi_library(audio ${TARGET_NAME}) -link_hifi_library(avatars ${TARGET_NAME}) -link_hifi_library(octree ${TARGET_NAME}) -link_hifi_library(voxels ${TARGET_NAME}) -link_hifi_library(fbx ${TARGET_NAME}) -link_hifi_library(particles ${TARGET_NAME}) -link_hifi_library(models ${TARGET_NAME}) -link_hifi_library(metavoxels ${TARGET_NAME}) -link_hifi_library(networking ${TARGET_NAME}) -link_hifi_library(animation ${TARGET_NAME}) -link_hifi_library(script-engine ${TARGET_NAME}) -link_hifi_library(embedded-webserver ${TARGET_NAME}) +link_hifi_libraries(${TARGET_NAME} audio avatars octree voxels fbx particles models metavoxels networking animation script-engine embedded-webserver) if (UNIX) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake new file mode 100644 index 0000000000..cf7499c763 --- /dev/null +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -0,0 +1,34 @@ +# +# LinkHifiLibrary.cmake +# +# Copyright 2013 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +macro(LINK_HIFI_LIBRARIES TARGET LIBRARIES) + + file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}") + + foreach(HIFI_LIBRARY ${LIBRARIES}) + + if (NOT TARGET ${HIFI_LIBRARY}) + add_subdirectory("${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}" "${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}") + endif () + + include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src") + + add_dependencies(${TARGET} ${HIFI_LIBRARY}) + + get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES) + + if (LINKED_TARGET_DEPENDENCY_LIBRARIES) + target_link_libraries(${TARGET} ${HIFI_LIBRARY} ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) + else () + target_link_libraries(${TARGET} ${HIFI_LIBRARY}) + endif () + + endforeach() + +endmacro(LINK_HIFI_LIBRARIES _target _libraries) \ No newline at end of file diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake deleted file mode 100644 index 95af4c6fd0..0000000000 --- a/cmake/macros/LinkHifiLibrary.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# -# LinkHifiLibrary.cmake -# -# Copyright 2013 High Fidelity, Inc. -# -# Distributed under the Apache License, Version 2.0. -# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -# - -macro(LINK_HIFI_LIBRARY LIBRARY TARGET) - - file(RELATIVE_PATH RELATIVE_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}/${LIBRARY}") - - if (NOT TARGET ${LIBRARY}) - add_subdirectory(${RELATIVE_LIBRARY_PATH} ${RELATIVE_LIBRARY_PATH}) - endif () - - include_directories("${HIFI_LIBRARY_DIR}/${LIBRARY}/src") - - add_dependencies(${TARGET} ${LIBRARY}) - - get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${LIBRARY} DEPENDENCY_LIBRARIES) - - if (LINKED_TARGET_DEPENDENCY_LIBRARIES) - target_link_libraries(${TARGET} ${LIBRARY} ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) - else () - target_link_libraries(${TARGET} ${LIBRARY}) - endif () - -endmacro(LINK_HIFI_LIBRARY _library _target) \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index e98cee7437..ae130af5ed 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -12,9 +12,7 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD $/resources/web) # link the shared hifi library -link_hifi_library(networking ${TARGET_NAME}) -link_hifi_library(shared ${TARGET_NAME}) -link_hifi_library(embedded-webserver ${TARGET_NAME}) +link_hifi_libraries(${TARGET_NAME} embedded-webserver networking shared) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index f30fcc68ff..ed280846fe 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -97,22 +97,8 @@ endif() # create the executable, make it a bundle on OS X add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) -# link in the hifi shared library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) - # link required hifi libraries -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(avatars ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(audio ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx metavoxels networking particles models avatars audio animation script-engine) # find any optional and required libraries find_package(Faceplus) diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index ace5f9292c..73d15f0b73 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -1,24 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME audio) -find_package(Qt5 COMPONENTS Script) -include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") - -# set up the external glm library -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} networking shared) find_package(Qt5 COMPONENTS Network) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 799a549a3b..88b74194ac 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -1,22 +1,12 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME metavoxels) -include(${MACRO_DIR}/AutoMTC.cmake) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") # link in the networking library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} networking) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") find_package(Qt5 COMPONENTS Network Script Widgets) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index d0beade108..efdb1bc70a 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -1,20 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME octree) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared networking) # link ZLIB find_package(ZLIB) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 6badb10f8e..b8e34739b8 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,25 +1,6 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - set(TARGET_NAME shared) -project(${TARGET_NAME}) - -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -# include GLM -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -# link required libraries on UNIX -if (APPLE) - find_library(CoreServices CoreServices) - set(DEPENDENCY_LIBRARIES ${CoreServices}) -elseif (UNIX) - find_package(Threads REQUIRED) - set(DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") -endif () - find_package(Qt5 COMPONENTS Network Widgets) # bubble up the libraries we are dependent on and link them to ourselves diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index b7375a0086..15da1afaa1 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -1,32 +1,12 @@ set(TARGET_NAME audio-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - #include glm -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_libraries(${TARGET_NAME} shared audio networking) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 8000e4af50..3b1d544690 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -1,31 +1,9 @@ set(TARGET_NAME jitter-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -#include(${MACRO_DIR}/AutoMTC.cmake) -#auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm - because it's a dependency of shared utils... -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_libraries(${TARGET_NAME} shared networking) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index f4c0695362..233988f849 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -1,28 +1,13 @@ set(TARGET_NAME metavoxel-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - find_package(Qt5 COMPONENTS Network Script Widgets) -include(${MACRO_DIR}/AutoMTC.cmake) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE "${AUTOMTC_SRC}") -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 64b5f273d1..819229d28f 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -1,31 +1,9 @@ set(TARGET_NAME networking-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_libraries(${TARGET_NAME} shared networking) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index c7a6500b6d..a4888b2c66 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -1,36 +1,9 @@ set(TARGET_NAME octree-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -find_package(Qt5Network REQUIRED) -find_package(Qt5Script REQUIRED) -find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(models ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(octree ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(animation ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(fbx ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_libraries(${TARGET_NAME} octree) IF (WIN32) # add a definition for ssize_t so that windows doesn't bail diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 643d318f7d..2161723619 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -1,32 +1,7 @@ set(TARGET_NAME physics-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) - -IF (WIN32) - #target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) +link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index 0785314d36..bea8448f5e 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -1,32 +1,6 @@ set(TARGET_NAME shared-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) - -IF (WIN32) - #target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - +link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 576406e787..3b3a65c259 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,25 +1,2 @@ set(TARGET_NAME bitstream2json) - -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -find_package(Qt5 COMPONENTS Network Script Widgets) - -include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME} TRUE) - -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) +setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 5ff4673298..452f845356 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,25 +1,2 @@ set(TARGET_NAME json2bitstream) - -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -find_package(Qt5 COMPONENTS Network Script Widgets) - -include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME} TRUE) - -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) +setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index 006dfb0599..8c315c92a0 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,39 +1,7 @@ set(TARGET_NAME voxel-edit) -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -# set up the external glm library -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -find_package(Qt5Script REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -# link in the shared library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi octree library -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi voxels library -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi networking library -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - -target_link_libraries(${TARGET_NAME} Qt5::Script) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) From 93b6f167f5d5b5ee5fd5aeae96b9b85334aefc0c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 09:51:20 -0700 Subject: [PATCH 37/94] change more CMakeLists to use simplified hifi library linker --- cmake/macros/LinkHifiLibraries.cmake | 7 ++++--- libraries/animation/CMakeLists.txt | 11 +---------- libraries/avatars/CMakeLists.txt | 15 +-------------- libraries/fbx/CMakeLists.txt | 14 +------------- libraries/models/CMakeLists.txt | 20 +------------------- libraries/networking/CMakeLists.txt | 6 ++---- libraries/particles/CMakeLists.txt | 15 +-------------- libraries/script-engine/CMakeLists.txt | 17 +---------------- libraries/voxels/CMakeLists.txt | 16 ++-------------- 9 files changed, 14 insertions(+), 107 deletions(-) diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index cf7499c763..4c6e2c3215 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -7,12 +7,13 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(LINK_HIFI_LIBRARIES TARGET LIBRARIES) +macro(LINK_HIFI_LIBRARIES TARGET) file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}") - foreach(HIFI_LIBRARY ${LIBRARIES}) - + set(LIBRARIES_TO_LINK ${ARGN}) + + foreach(HIFI_LIBRARY ${LIBRARIES_TO_LINK}) if (NOT TARGET ${HIFI_LIBRARY}) add_subdirectory("${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}" "${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}") endif () diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 7891c65dcc..186067ba3f 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -1,17 +1,8 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME animation) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared fbx) find_package(Qt5 COMPONENTS Network Script) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 1300a2e733..10507f7836 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -1,23 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME avatars) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) find_package(Qt5 COMPONENTS Network Script) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index ba51fe2e06..3f6a969cbc 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -1,22 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME fbx) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared networking octree voxels) # link ZLIB find_package(ZLIB) diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 8128741ef6..20f6ef1ef8 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -1,28 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME models) -find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") - -# for streamable -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) find_package(Qt5 COMPONENTS Network Script) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 7bd210623b..f41d410ce8 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,11 +1,9 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - set(TARGET_NAME networking) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) +link_hifi_libraries(${TARGET_NAME} shared) + find_package(Qt5 COMPONENTS Network) # set a property indicating the libraries we are dependent on and link them to ourselves diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 54398ac252..0f8a555cb5 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -1,23 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME particles) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) find_package(Qt5 COMPONENTS Gui Network Script) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 1b0199977f..f9b4b7d60f 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,25 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME script-engine) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) find_package(Qt5 COMPONENTS Gui Network Script Widgets) diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 2ae35da2c0..c421f6514f 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -1,26 +1,14 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME voxels) -find_package(Qt5 COMPONENTS Widgets Script) - -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree networking) # link ZLIB find_package(ZLIB) +find_package(Qt5 COMPONENTS Widgets Script) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script) From 1a71d655b9de1974696574e69347284b035d4007 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 09:58:27 -0700 Subject: [PATCH 38/94] more cmake cleanup to remove ROOT_DIR passing --- CMakeLists.txt | 2 ++ assignment-client/CMakeLists.txt | 5 ++++- cmake/macros/AutoMTC.cmake | 2 +- cmake/macros/IncludeHifiLibraryHeaders.cmake | 4 ++-- interface/CMakeLists.txt | 7 ------- libraries/metavoxels/CMakeLists.txt | 2 +- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f033e5184..fb54bcbd8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,8 +44,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) +set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries") set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") + # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 628e473853..fd11be5122 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -5,7 +5,10 @@ setup_hifi_project(${TARGET_NAME} TRUE) include_glm(${TARGET_NAME}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} audio avatars octree voxels fbx particles models metavoxels networking animation script-engine embedded-webserver) +link_hifi_libraries(${TARGET_NAME} + audio avatars octree voxels fbx particles models metavoxels + networking animation shared script-engine embedded-webserver +) if (UNIX) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/cmake/macros/AutoMTC.cmake b/cmake/macros/AutoMTC.cmake index 6f0216de7f..0e376fc176 100644 --- a/cmake/macros/AutoMTC.cmake +++ b/cmake/macros/AutoMTC.cmake @@ -8,7 +8,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(AUTO_MTC TARGET ROOT_DIR) +macro(AUTO_MTC TARGET) set(AUTOMTC_SRC ${TARGET}_automtc.cpp) file(GLOB INCLUDE_FILES src/*.h) diff --git a/cmake/macros/IncludeHifiLibraryHeaders.cmake b/cmake/macros/IncludeHifiLibraryHeaders.cmake index aa7e1118c6..7ac31f5259 100644 --- a/cmake/macros/IncludeHifiLibraryHeaders.cmake +++ b/cmake/macros/IncludeHifiLibraryHeaders.cmake @@ -9,8 +9,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(include_hifi_library_headers LIBRARY ROOT_DIR) +macro(include_hifi_library_headers LIBRARY) - include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") + include_directories("${HIFI_LIBRARY_DIR}/libraries/${LIBRARY}/src") endmacro(include_hifi_library_headers _library _root_dir) \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index ed280846fe..cb2065e256 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -1,12 +1,6 @@ -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - set(TARGET_NAME interface) project(${TARGET_NAME}) -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - # set a default root dir for each of our optional externals if it was not passed set(OPTIONAL_EXTERNALS "faceplus" "faceshift" "oculus" "priovr" "sixense" "visage" "leapmotion" "rtmidi" "qxmpp") foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) @@ -38,7 +32,6 @@ elseif (WIN32) endif () # set up the external glm library -include("${MACRO_DIR}/IncludeGLM.cmake") include_glm(${TARGET_NAME} "${ROOT_DIR}") # create the InterfaceConfig.h file based on GL_HEADERS above diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 88b74194ac..29f7f85f9c 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -5,7 +5,7 @@ auto_mtc(${TARGET_NAME} "${ROOT_DIR}") setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") # link in the networking library -link_hifi_libraries(${TARGET_NAME} networking) +link_hifi_libraries(${TARGET_NAME} shared networking) include_glm(${TARGET_NAME} "${ROOT_DIR}") From c63e886444294bdfaf2c12c8082a6df0c0b5c0a5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:04:34 -0700 Subject: [PATCH 39/94] don't look backwards for fbx header from avatars library --- cmake/macros/IncludeHifiLibraryHeaders.cmake | 4 +--- libraries/avatars/CMakeLists.txt | 1 + libraries/avatars/src/HeadData.cpp | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmake/macros/IncludeHifiLibraryHeaders.cmake b/cmake/macros/IncludeHifiLibraryHeaders.cmake index 7ac31f5259..913d1e1181 100644 --- a/cmake/macros/IncludeHifiLibraryHeaders.cmake +++ b/cmake/macros/IncludeHifiLibraryHeaders.cmake @@ -10,7 +10,5 @@ # macro(include_hifi_library_headers LIBRARY) - - include_directories("${HIFI_LIBRARY_DIR}/libraries/${LIBRARY}/src") - + include_directories("${HIFI_LIBRARY_DIR}/${LIBRARY}/src") endmacro(include_hifi_library_headers _library _root_dir) \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 10507f7836..138b218381 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -5,6 +5,7 @@ setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) +include_hifi_library_headers(fbx) find_package(Qt5 COMPONENTS Network Script) diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index 538085af30..2bdb203034 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -11,14 +11,13 @@ #include +#include #include #include #include "AvatarData.h" #include "HeadData.h" -#include "../fbx/src/FBXReader.h" - HeadData::HeadData(AvatarData* owningAvatar) : _baseYaw(0.0f), _basePitch(0.0f), From a75a3f943482f5886ef87187978428cce12f66fc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:06:56 -0700 Subject: [PATCH 40/94] don't look backwards for script-engine headers from particles library --- libraries/particles/CMakeLists.txt | 1 + libraries/particles/src/Particle.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 0f8a555cb5..0ab11e3f82 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -5,6 +5,7 @@ setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) +include_hifi_library_headers(script-engine) find_package(Qt5 COMPONENTS Gui Network Script) diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index fef2b95fdc..5db285ebeb 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -22,7 +22,7 @@ // I'm open to other potential solutions. Could we change cmake to allow libraries to reference each others // headers, but not link to each other, this is essentially what this construct is doing, but would be // better to add includes to the include path, but not link -#include "../../script-engine/src/ScriptEngine.h" +#include #include "ParticlesScriptingInterface.h" #include "Particle.h" From 17df6484d426666e4e22b053f85299a4a02aa26d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:14:31 -0700 Subject: [PATCH 41/94] remove ssize_t and replace with size_t or int where appropriate --- assignment-client/CMakeLists.txt | 5 ----- assignment-client/src/Agent.cpp | 2 +- domain-server/CMakeLists.txt | 5 ----- interface/CMakeLists.txt | 3 --- interface/src/voxels/OctreePacketProcessor.cpp | 2 +- libraries/animation/CMakeLists.txt | 5 ----- libraries/audio/CMakeLists.txt | 5 ----- libraries/avatars/CMakeLists.txt | 5 ----- libraries/fbx/CMakeLists.txt | 5 ----- libraries/metavoxels/CMakeLists.txt | 7 +------ libraries/models/CMakeLists.txt | 5 ----- libraries/models/src/ModelEditPacketSender.cpp | 2 +- libraries/models/src/ModelEditPacketSender.h | 2 +- libraries/models/src/ModelItem.cpp | 2 +- libraries/models/src/ModelItem.h | 2 +- libraries/networking/CMakeLists.txt | 5 ----- libraries/networking/src/PacketSender.h | 4 ---- libraries/networking/src/ReceivedPacketProcessor.h | 4 ---- libraries/octree/CMakeLists.txt | 5 ----- libraries/octree/src/EditPacketBuffer.cpp | 2 +- libraries/octree/src/EditPacketBuffer.h | 4 ++-- libraries/octree/src/JurisdictionListener.cpp | 2 +- libraries/octree/src/JurisdictionListener.h | 4 ---- libraries/octree/src/JurisdictionSender.cpp | 2 +- libraries/octree/src/OctreeEditPacketSender.cpp | 8 ++++---- libraries/octree/src/OctreeEditPacketSender.h | 10 +++++----- libraries/particles/CMakeLists.txt | 7 +------ libraries/particles/src/Particle.cpp | 2 +- libraries/particles/src/Particle.h | 2 +- libraries/particles/src/ParticleEditPacketSender.cpp | 2 +- libraries/particles/src/ParticleEditPacketSender.h | 2 +- libraries/script-engine/CMakeLists.txt | 7 +------ libraries/voxels/CMakeLists.txt | 5 ----- libraries/voxels/src/VoxelEditPacketSender.h | 2 +- tests/octree/CMakeLists.txt | 8 +------- voxel-edit/CMakeLists.txt | 7 +------ 36 files changed, 30 insertions(+), 121 deletions(-) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index fd11be5122..d4281eb185 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -20,8 +20,3 @@ ENDIF(WIN32) find_package(Qt5 COMPONENTS Gui Network Script Widgets) target_link_libraries(${TARGET_NAME} Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index dbb1620252..09496f0179 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -115,7 +115,7 @@ void Agent::readPendingDatagrams() { sourceNode->setLastHeardMicrostamp(usecTimestampNow()); QByteArray mutablePacket = receivedPacket; - ssize_t messageLength = mutablePacket.size(); + int messageLength = mutablePacket.size(); if (datagramPacketType == PacketTypeOctreeStats) { diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index ae130af5ed..c04ba33a5d 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -18,10 +18,5 @@ IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) ENDIF(WIN32) -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () - find_package(Qt5 COMPONENTS Network Widgets) target_link_libraries(${TARGET_NAME} Qt5::Network) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index cb2065e256..ea4b54257b 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -206,9 +206,6 @@ else (APPLE) # we're using static GLEW, so define GLEW_STATIC add_definitions(-DGLEW_STATIC) - # add a definition for ssize_t so that windows doesn't bail - add_definitions(-Dssize_t=long) - target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib) endif() endif (APPLE) diff --git a/interface/src/voxels/OctreePacketProcessor.cpp b/interface/src/voxels/OctreePacketProcessor.cpp index 66190a5689..ee139ccf1d 100644 --- a/interface/src/voxels/OctreePacketProcessor.cpp +++ b/interface/src/voxels/OctreePacketProcessor.cpp @@ -26,7 +26,7 @@ void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode, if (packetsToProcessCount() > WAY_BEHIND && Application::getInstance()->getLogger()->extraDebugging()) { qDebug("OctreePacketProcessor::processPacket() packets to process=%d", packetsToProcessCount()); } - ssize_t messageLength = mutablePacket.size(); + int messageLength = mutablePacket.size(); Application* app = Application::getInstance(); bool wasStatsPacket = false; diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 186067ba3f..26b98ca17f 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -10,8 +10,3 @@ find_package(Qt5 COMPONENTS Network Script) set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 73d15f0b73..a066c3a73b 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -12,8 +12,3 @@ find_package(Qt5 COMPONENTS Network) set(DEPENDENCY_LIBRARIES Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 138b218381..9d7d452696 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -13,8 +13,3 @@ find_package(Qt5 COMPONENTS Network Script) set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 3f6a969cbc..12047498c2 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -15,8 +15,3 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 29f7f85f9c..b0e8f14374 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -14,9 +14,4 @@ find_package(Qt5 COMPONENTS Network Script Widgets) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 20f6ef1ef8..45d0ab0b70 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -12,8 +12,3 @@ find_package(Qt5 COMPONENTS Network Script) set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/models/src/ModelEditPacketSender.cpp b/libraries/models/src/ModelEditPacketSender.cpp index 5059b8891b..c21a4a236a 100644 --- a/libraries/models/src/ModelEditPacketSender.cpp +++ b/libraries/models/src/ModelEditPacketSender.cpp @@ -38,7 +38,7 @@ void ModelEditPacketSender::sendEditModelMessage(PacketType type, ModelItemID mo } } -void ModelEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { +void ModelEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { ModelItem::adjustEditPacketForClockSkew(codeColorBuffer, length, clockSkew); } diff --git a/libraries/models/src/ModelEditPacketSender.h b/libraries/models/src/ModelEditPacketSender.h index 198c9a3be2..332f7f729d 100644 --- a/libraries/models/src/ModelEditPacketSender.h +++ b/libraries/models/src/ModelEditPacketSender.h @@ -32,6 +32,6 @@ public: // My server type is the model server virtual char getMyNodeType() const { return NodeType::ModelServer; } - virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); + virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); }; #endif // hifi_ModelEditPacketSender_h diff --git a/libraries/models/src/ModelItem.cpp b/libraries/models/src/ModelItem.cpp index d6cd8aebc5..e555aff7ed 100644 --- a/libraries/models/src/ModelItem.cpp +++ b/libraries/models/src/ModelItem.cpp @@ -634,7 +634,7 @@ bool ModelItem::encodeModelEditMessageDetails(PacketType command, ModelItemID id } // adjust any internal timestamps to fix clock skew for this server -void ModelItem::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { +void ModelItem::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { unsigned char* dataAt = codeColorBuffer; int octets = numberOfThreeBitSectionsInCode(dataAt); int lengthOfOctcode = bytesRequiredForCodeLength(octets); diff --git a/libraries/models/src/ModelItem.h b/libraries/models/src/ModelItem.h index 4a9a2af2c4..be52b1e235 100644 --- a/libraries/models/src/ModelItem.h +++ b/libraries/models/src/ModelItem.h @@ -270,7 +270,7 @@ public: static bool encodeModelEditMessageDetails(PacketType command, ModelItemID id, const ModelItemProperties& details, unsigned char* bufferOut, int sizeIn, int& sizeOut); - static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); + static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); void update(const quint64& now); diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index f41d410ce8..fe8cd003a3 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -10,8 +10,3 @@ find_package(Qt5 COMPONENTS Network) set(DEPENDENCY_LIBRARIES Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/networking/src/PacketSender.h b/libraries/networking/src/PacketSender.h index 7d2c0dc8aa..29d9287127 100644 --- a/libraries/networking/src/PacketSender.h +++ b/libraries/networking/src/PacketSender.h @@ -39,10 +39,6 @@ public: ~PacketSender(); /// Add packet to outbound queue. - /// \param HifiSockAddr& address the destination address - /// \param packetData pointer to data - /// \param ssize_t packetLength size of data - /// \thread any thread, typically the application thread void queuePacketForSending(const SharedNodePointer& destinationNode, const QByteArray& packet); void setPacketsPerSecond(int packetsPerSecond); diff --git a/libraries/networking/src/ReceivedPacketProcessor.h b/libraries/networking/src/ReceivedPacketProcessor.h index 607f9e54c2..d5fc006882 100644 --- a/libraries/networking/src/ReceivedPacketProcessor.h +++ b/libraries/networking/src/ReceivedPacketProcessor.h @@ -24,10 +24,6 @@ public: ReceivedPacketProcessor() { } /// Add packet from network receive thread to the processing queue. - /// \param sockaddr& senderAddress the address of the sender - /// \param packetData pointer to received data - /// \param ssize_t packetLength size of received data - /// \thread network receive thread void queueReceivedPacket(const SharedNodePointer& sendingNode, const QByteArray& packet); /// Are there received packets waiting to be processed diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index efdb1bc70a..ca4e5caafd 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -16,8 +16,3 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/octree/src/EditPacketBuffer.cpp b/libraries/octree/src/EditPacketBuffer.cpp index d6e7bf0183..6d2d8cc085 100644 --- a/libraries/octree/src/EditPacketBuffer.cpp +++ b/libraries/octree/src/EditPacketBuffer.cpp @@ -20,7 +20,7 @@ EditPacketBuffer::EditPacketBuffer() : } -EditPacketBuffer::EditPacketBuffer(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost, QUuid nodeUUID) : +EditPacketBuffer::EditPacketBuffer(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost, QUuid nodeUUID) : _nodeUUID(nodeUUID), _currentType(type), _currentSize(length), diff --git a/libraries/octree/src/EditPacketBuffer.h b/libraries/octree/src/EditPacketBuffer.h index 9b52cbc5e4..e816bf6558 100644 --- a/libraries/octree/src/EditPacketBuffer.h +++ b/libraries/octree/src/EditPacketBuffer.h @@ -21,13 +21,13 @@ class EditPacketBuffer { public: EditPacketBuffer(); - EditPacketBuffer(PacketType type, unsigned char* codeColorBuffer, ssize_t length, + EditPacketBuffer(PacketType type, unsigned char* codeColorBuffer, size_t length, qint64 satoshiCost = 0, const QUuid nodeUUID = QUuid()); QUuid _nodeUUID; PacketType _currentType; unsigned char _currentBuffer[MAX_PACKET_SIZE]; - ssize_t _currentSize; + size_t _currentSize; qint64 _satoshiCost; }; diff --git a/libraries/octree/src/JurisdictionListener.cpp b/libraries/octree/src/JurisdictionListener.cpp index 453ff10a42..f3d9e31acc 100644 --- a/libraries/octree/src/JurisdictionListener.cpp +++ b/libraries/octree/src/JurisdictionListener.cpp @@ -35,7 +35,7 @@ void JurisdictionListener::nodeKilled(SharedNodePointer node) { bool JurisdictionListener::queueJurisdictionRequest() { static unsigned char buffer[MAX_PACKET_SIZE]; unsigned char* bufferOut = &buffer[0]; - ssize_t sizeOut = populatePacketHeader(reinterpret_cast(bufferOut), PacketTypeJurisdictionRequest); + int sizeOut = populatePacketHeader(reinterpret_cast(bufferOut), PacketTypeJurisdictionRequest); int nodeCount = 0; NodeList* nodeList = NodeList::getInstance(); diff --git a/libraries/octree/src/JurisdictionListener.h b/libraries/octree/src/JurisdictionListener.h index 01f0392796..eb1c27f2ff 100644 --- a/libraries/octree/src/JurisdictionListener.h +++ b/libraries/octree/src/JurisdictionListener.h @@ -47,10 +47,6 @@ public slots: protected: /// Callback for processing of received packets. Will process any queued PacketType_JURISDICTION and update the /// jurisdiction map member variable - /// \param sockaddr& senderAddress the address of the sender - /// \param packetData pointer to received data - /// \param ssize_t packetLength size of received data - /// \thread "this" individual processing thread virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet); private: diff --git a/libraries/octree/src/JurisdictionSender.cpp b/libraries/octree/src/JurisdictionSender.cpp index c151999305..d78d883204 100644 --- a/libraries/octree/src/JurisdictionSender.cpp +++ b/libraries/octree/src/JurisdictionSender.cpp @@ -47,7 +47,7 @@ bool JurisdictionSender::process() { // add our packet to our own queue, then let the PacketSender class do the rest of the work. static unsigned char buffer[MAX_PACKET_SIZE]; unsigned char* bufferOut = &buffer[0]; - ssize_t sizeOut = 0; + int sizeOut = 0; if (_jurisdictionMap) { sizeOut = _jurisdictionMap->packIntoMessage(bufferOut, MAX_PACKET_SIZE); diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index 543f47273c..d4bdcaa59e 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -83,7 +83,7 @@ bool OctreeEditPacketSender::serversExist() const { // This method is called when the edit packet layer has determined that it has a fully formed packet destined for // a known nodeID. void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned char* buffer, - ssize_t length, qint64 satoshiCost) { + size_t length, qint64 satoshiCost) { NodeList* nodeList = NodeList::getInstance(); foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { @@ -161,7 +161,7 @@ void OctreeEditPacketSender::processPreServerExistsPackets() { } void OctreeEditPacketSender::queuePendingPacketToNodes(PacketType type, unsigned char* buffer, - ssize_t length, qint64 satoshiCost) { + size_t length, qint64 satoshiCost) { // If we're asked to save messages while waiting for voxel servers to arrive, then do so... if (_maxPendingMessages > 0) { @@ -179,7 +179,7 @@ void OctreeEditPacketSender::queuePendingPacketToNodes(PacketType type, unsigned } } -void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t length, qint64 satoshiCost) { +void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, size_t length, qint64 satoshiCost) { if (!_shouldSend) { return; // bail early } @@ -215,7 +215,7 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t l // NOTE: codeColorBuffer - is JUST the octcode/color and does not contain the packet header! void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, unsigned char* codeColorBuffer, - ssize_t length, qint64 satoshiCost) { + size_t length, qint64 satoshiCost) { if (!_shouldSend) { return; // bail early diff --git a/libraries/octree/src/OctreeEditPacketSender.h b/libraries/octree/src/OctreeEditPacketSender.h index a11c626003..cefa5cefb0 100644 --- a/libraries/octree/src/OctreeEditPacketSender.h +++ b/libraries/octree/src/OctreeEditPacketSender.h @@ -30,7 +30,7 @@ public: /// Queues a single edit message. Will potentially send a pending multi-command packet. Determines which server /// node or nodes the packet should be sent to. Can be called even before servers are known, in which case up to /// MaxPendingMessages will be buffered and processed when servers are known. - void queueOctreeEditMessage(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0); + void queueOctreeEditMessage(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0); /// Releases all queued messages even if those messages haven't filled an MTU packet. This will move the packed message /// packets onto the send queue. If running in threaded mode, the caller does not need to do any further processing to @@ -81,7 +81,7 @@ public: // you must override these... virtual char getMyNodeType() const = 0; - virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { }; + virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { }; bool hasDestinationWalletUUID() const { return !_destinationWalletUUID.isNull(); } void setDestinationWalletUUID(const QUuid& destinationWalletUUID) { _destinationWalletUUID = destinationWalletUUID; } @@ -97,9 +97,9 @@ signals: protected: bool _shouldSend; - void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0); - void queuePendingPacketToNodes(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0); - void queuePacketToNodes(unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0); + void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, size_t length, qint64 satoshiCost = 0); + void queuePendingPacketToNodes(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0); + void queuePacketToNodes(unsigned char* buffer, size_t length, qint64 satoshiCost = 0); void initializePacket(EditPacketBuffer& packetBuffer, PacketType type); void releaseQueuedPacket(EditPacketBuffer& packetBuffer); // releases specific queued packet diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 0ab11e3f82..8efeedc9d9 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -12,9 +12,4 @@ find_package(Qt5 COMPONENTS Gui Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script Qt5::Gui) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index 5db285ebeb..e3b568365b 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -856,7 +856,7 @@ bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID i } // adjust any internal timestamps to fix clock skew for this server -void Particle::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { +void Particle::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { unsigned char* dataAt = codeColorBuffer; int octets = numberOfThreeBitSectionsInCode(dataAt); int lengthOfOctcode = bytesRequiredForCodeLength(octets); diff --git a/libraries/particles/src/Particle.h b/libraries/particles/src/Particle.h index c243363241..1ee0f6e79b 100644 --- a/libraries/particles/src/Particle.h +++ b/libraries/particles/src/Particle.h @@ -292,7 +292,7 @@ public: static bool encodeParticleEditMessageDetails(PacketType command, ParticleID id, const ParticleProperties& details, unsigned char* bufferOut, int sizeIn, int& sizeOut); - static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); + static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); void applyHardCollision(const CollisionInfo& collisionInfo); diff --git a/libraries/particles/src/ParticleEditPacketSender.cpp b/libraries/particles/src/ParticleEditPacketSender.cpp index 21a910ff16..689b734521 100644 --- a/libraries/particles/src/ParticleEditPacketSender.cpp +++ b/libraries/particles/src/ParticleEditPacketSender.cpp @@ -38,7 +38,7 @@ void ParticleEditPacketSender::sendEditParticleMessage(PacketType type, Particle } } -void ParticleEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { +void ParticleEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { Particle::adjustEditPacketForClockSkew(codeColorBuffer, length, clockSkew); } diff --git a/libraries/particles/src/ParticleEditPacketSender.h b/libraries/particles/src/ParticleEditPacketSender.h index 5a367347ea..2ee6d84eb8 100644 --- a/libraries/particles/src/ParticleEditPacketSender.h +++ b/libraries/particles/src/ParticleEditPacketSender.h @@ -31,6 +31,6 @@ public: // My server type is the particle server virtual char getMyNodeType() const { return NodeType::ParticleServer; } - virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); + virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); }; #endif // hifi_ParticleEditPacketSender_h diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index f9b4b7d60f..0b79530210 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -11,9 +11,4 @@ find_package(Qt5 COMPONENTS Gui Network Script Widgets) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index c421f6514f..739fe3ef62 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -12,8 +12,3 @@ find_package(Qt5 COMPONENTS Widgets Script) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/voxels/src/VoxelEditPacketSender.h b/libraries/voxels/src/VoxelEditPacketSender.h index 560c585ed5..3b85155036 100644 --- a/libraries/voxels/src/VoxelEditPacketSender.h +++ b/libraries/voxels/src/VoxelEditPacketSender.h @@ -28,7 +28,7 @@ public: /// Queues a single voxel edit message. Will potentially send a pending multi-command packet. Determines which voxel-server /// node or nodes the packet should be sent to. Can be called even before voxel servers are known, in which case up to /// MaxPendingMessages will be buffered and processed when voxel servers are known. - void queueVoxelEditMessage(PacketType type, unsigned char* codeColorBuffer, ssize_t length) { + void queueVoxelEditMessage(PacketType type, unsigned char* codeColorBuffer, size_t length) { queueOctreeEditMessage(type, codeColorBuffer, length); } diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index a4888b2c66..85442db783 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -6,11 +6,5 @@ setup_hifi_project(${TARGET_NAME} TRUE) link_hifi_libraries(${TARGET_NAME} octree) IF (WIN32) - # add a definition for ssize_t so that windows doesn't bail - add_definitions(-Dssize_t=long) - - #target_link_libraries(${TARGET_NAME} Winmm Ws2_32) - target_link_libraries(${TARGET_NAME} wsock32.lib) + target_link_libraries(${TARGET_NAME} wsock32.lib) ENDIF(WIN32) - - diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index 8c315c92a0..db22f040b7 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,8 +1,3 @@ set(TARGET_NAME voxel-edit) -setup_hifi_project(${TARGET_NAME} TRUE) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file From 1f0a722d0db68c11419102223911697959cdf077 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:17:29 -0700 Subject: [PATCH 42/94] remove antequated windows libraries that have been replaced by Qt usage --- assignment-client/CMakeLists.txt | 4 ---- domain-server/CMakeLists.txt | 4 ---- tests/audio/CMakeLists.txt | 5 ----- tests/jitter/CMakeLists.txt | 7 +------ tests/metavoxels/CMakeLists.txt | 4 ---- tests/networking/CMakeLists.txt | 4 ---- 6 files changed, 1 insertion(+), 27 deletions(-) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index d4281eb185..ab448bc5bd 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -14,9 +14,5 @@ if (UNIX) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) endif (UNIX) -IF (WIN32) - target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} Winmm Ws2_32) -ENDIF(WIN32) - find_package(Qt5 COMPONENTS Gui Network Script Widgets) target_link_libraries(${TARGET_NAME} Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index c04ba33a5d..7f9dc2db37 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -14,9 +14,5 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD # link the shared hifi library link_hifi_libraries(${TARGET_NAME} embedded-webserver networking shared) -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - find_package(Qt5 COMPONENTS Network Widgets) target_link_libraries(${TARGET_NAME} Qt5::Network) diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 15da1afaa1..51b42780c8 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -7,8 +7,3 @@ include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared audio networking) - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 3b1d544690..4fb3d56492 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -3,9 +3,4 @@ set(TARGET_NAME jitter-tests) setup_hifi_project(${TARGET_NAME} TRUE) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared networking) - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - +link_hifi_libraries(${TARGET_NAME} shared networking) \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 233988f849..d459ea1fed 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -9,9 +9,5 @@ setup_hifi_project(${TARGET_NAME} TRUE "${AUTOMTC_SRC}") # link in the shared libraries link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 819229d28f..ec48bb80cd 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -5,7 +5,3 @@ setup_hifi_project(${TARGET_NAME} TRUE) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared networking) -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - From c9f8433a2dba2c78951cb5a35ef0fe17ceb0f3a1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:44:58 -0700 Subject: [PATCH 43/94] tweak setup_hifi_library to bubble up full path of Qt modules --- cmake/macros/SetupHifiLibrary.cmake | 28 +++++++++++++++------ libraries/animation/CMakeLists.txt | 12 +++------ libraries/audio/CMakeLists.txt | 12 +++------ libraries/avatars/CMakeLists.txt | 12 +++------ libraries/embedded-webserver/CMakeLists.txt | 17 ++----------- libraries/fbx/CMakeLists.txt | 1 + libraries/metavoxels/CMakeLists.txt | 12 +++------ libraries/models/CMakeLists.txt | 12 +++------ libraries/networking/CMakeLists.txt | 12 +++------ libraries/octree/CMakeLists.txt | 3 ++- libraries/particles/CMakeLists.txt | 12 +++------ libraries/script-engine/CMakeLists.txt | 12 +++------ libraries/shared/CMakeLists.txt | 9 ++----- libraries/voxels/CMakeLists.txt | 10 +++++--- tests/audio/CMakeLists.txt | 2 +- tools/CMakeLists.txt | 1 - tools/mtc/CMakeLists.txt | 5 ---- 17 files changed, 59 insertions(+), 113 deletions(-) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index ff4ae3b4f3..6da3755ea4 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -13,14 +13,28 @@ macro(SETUP_HIFI_LIBRARY TARGET) # grab the implemenation and header files file(GLOB LIB_SRCS src/*.h src/*.cpp) - set(LIB_SRCS ${LIB_SRCS} ${WRAPPED_SRCS}) + set(LIB_SRCS ${LIB_SRCS}) - # create a library and set the property so it can be referenced later - add_library(${TARGET} ${LIB_SRCS} ${ARGN}) + # create a library and set the property so it can be referenced later + add_library(${TARGET} ${LIB_SRCS} ${AUTOMTC_SRC}) - find_package(Qt5Core REQUIRED) - qt5_use_modules(${TARGET} Core) - - target_link_libraries(${TARGET} ${QT_LIBRARIES}) + set(QT_MODULES_TO_LINK ${ARGN}) + list(APPEND QT_MODULES_TO_LINK Core) + + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + + foreach(QT_MODULE ${QT_MODULES_TO_LINK}) + # link this Qt module to ourselves + target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + + get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) + + # add the actual path to the Qt module to a QT_LIBRARIES variable + list(APPEND QT_LIBRARIES ${QT_LIBRARY_LOCATION}) + endforeach() + + if (QT_LIBRARIES) + set_target_properties(${TARGET} PROPERTIES DEPENDENCY_LIBRARIES "${QT_LIBRARIES}") + endif () endmacro(SETUP_HIFI_LIBRARY _target) \ No newline at end of file diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 26b98ca17f..9c419d9369 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -1,12 +1,6 @@ set(TARGET_NAME animation) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) -link_hifi_libraries(${TARGET_NAME} shared fbx) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared fbx) \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index a066c3a73b..354a3772dd 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME audio) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} networking shared) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} networking shared) \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 9d7d452696..d05faf3b27 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -1,15 +1,9 @@ set(TARGET_NAME avatars) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) -include_hifi_library_headers(fbx) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +include_hifi_library_headers(fbx) \ No newline at end of file diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index 5b815625ba..c299aa654d 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -1,17 +1,4 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME embedded-webserver) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) -setup_hifi_library(${TARGET_NAME}) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 12047498c2..e9658de4a2 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -1,5 +1,6 @@ set(TARGET_NAME fbx) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index b0e8f14374..20b448725f 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -2,16 +2,10 @@ set(TARGET_NAME metavoxels) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Scripts Widgets) # link in the networking library link_hifi_libraries(${TARGET_NAME} shared networking) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -find_package(Qt5 COMPONENTS Network Script Widgets) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +include_glm(${TARGET_NAME} "${ROOT_DIR}") \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 45d0ab0b70..c0610b0501 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME models) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index fe8cd003a3..fb9f07b81a 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,12 +1,6 @@ set(TARGET_NAME networking) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) -link_hifi_libraries(${TARGET_NAME} shared) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared) \ No newline at end of file diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index ca4e5caafd..340b2393e6 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -1,5 +1,6 @@ set(TARGET_NAME octree) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") @@ -15,4 +16,4 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 8efeedc9d9..2f523b22f7 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -1,15 +1,9 @@ set(TARGET_NAME particles) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Gui Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) -include_hifi_library_headers(script-engine) - -find_package(Qt5 COMPONENTS Gui Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script Qt5::Gui) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +include_hifi_library_headers(script-engine) \ No newline at end of file diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 0b79530210..cce7d8d07b 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME script-engine) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Gui Network Script Widgets) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) - -find_package(Qt5 COMPONENTS Gui Network Script Widgets) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) \ No newline at end of file diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index b8e34739b8..9cc1b968dc 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,9 +1,4 @@ set(TARGET_NAME shared) -setup_hifi_library(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network Widgets) - -# bubble up the libraries we are dependent on and link them to ourselves -list(APPEND DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Widgets) \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 739fe3ef62..7f200523de 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -1,6 +1,7 @@ set(TARGET_NAME voxels) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Widgets Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") @@ -8,7 +9,8 @@ link_hifi_libraries(${TARGET_NAME} shared octree networking) # link ZLIB find_package(ZLIB) -find_package(Qt5 COMPONENTS Widgets Script) - include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script) + +get_target_property(LINKED_LIBRARIES ${TARGET_NAME} DEPENDENCY_LIBRARIES) +list(APPEND DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") +list(REMOVE_DUPLICATES DEPENDENCY_LIBRARIES) \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 51b42780c8..34d053b008 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -6,4 +6,4 @@ setup_hifi_project(${TARGET_NAME} TRUE) include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared audio networking) +link_hifi_libraries(${TARGET_NAME} shared audio networking) \ No newline at end of file diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index c9c0690cc7..32a82627a3 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,4 +1,3 @@ - # add the tool directories add_subdirectory(bitstream2json) add_subdirectory(json2bitstream) diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 582c5e3bfd..467d03d241 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,7 +1,2 @@ set(TARGET_NAME mtc) - -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file From fc92b93326755028d74bf0ba951da6ae6d85c3ac Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:46:05 -0700 Subject: [PATCH 44/94] fix typo in metavoxels library setup --- libraries/metavoxels/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 20b448725f..a8d6de698b 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -3,7 +3,7 @@ set(TARGET_NAME metavoxels) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Scripts Widgets) +setup_hifi_library(${TARGET_NAME} Network Script Widgets) # link in the networking library link_hifi_libraries(${TARGET_NAME} shared networking) From 26f7b1ba62bf37cb1c0e0f780bac16be7f651d3e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 11:45:10 -0700 Subject: [PATCH 45/94] add macro to link shared dependencies to target --- assignment-client/CMakeLists.txt | 7 +++--- cmake/macros/LinkHifiLibraries.cmake | 11 ++++---- .../LinkSharedDependenciesToTarget.cmake | 25 +++++++++++++++++++ cmake/macros/SetupHifiLibrary.cmake | 15 +++-------- cmake/macros/SetupHifiProject.cmake | 21 +++++++++++----- domain-server/CMakeLists.txt | 2 +- libraries/animation/CMakeLists.txt | 5 +++- libraries/audio/CMakeLists.txt | 5 +++- libraries/avatars/CMakeLists.txt | 5 +++- libraries/embedded-webserver/CMakeLists.txt | 5 +++- libraries/fbx/CMakeLists.txt | 9 +++---- libraries/metavoxels/CMakeLists.txt | 5 +++- libraries/models/CMakeLists.txt | 5 +++- libraries/networking/CMakeLists.txt | 5 +++- libraries/octree/CMakeLists.txt | 14 ++++++----- libraries/particles/CMakeLists.txt | 5 +++- libraries/script-engine/CMakeLists.txt | 5 +++- libraries/shared/CMakeLists.txt | 5 +++- libraries/voxels/CMakeLists.txt | 10 +++++--- tests/audio/CMakeLists.txt | 2 +- tests/jitter/CMakeLists.txt | 2 +- tests/metavoxels/CMakeLists.txt | 2 +- tests/networking/CMakeLists.txt | 2 +- tests/octree/CMakeLists.txt | 2 +- tests/physics/CMakeLists.txt | 2 +- tests/shared/CMakeLists.txt | 2 +- tools/bitstream2json/CMakeLists.txt | 2 +- tools/json2bitstream/CMakeLists.txt | 2 +- tools/mtc/CMakeLists.txt | 2 +- voxel-edit/CMakeLists.txt | 2 +- 30 files changed, 121 insertions(+), 65 deletions(-) create mode 100644 cmake/macros/LinkSharedDependenciesToTarget.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index ab448bc5bd..9f8542c42e 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME assignment-client) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME} Core Gui Network Script Widgets) include_glm(${TARGET_NAME}) @@ -11,8 +11,7 @@ link_hifi_libraries(${TARGET_NAME} ) if (UNIX) - target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) + list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${CMAKE_DL_LIBS}) endif (UNIX) -find_package(Qt5 COMPONENTS Gui Network Script Widgets) -target_link_libraries(${TARGET_NAME} Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index 4c6e2c3215..96c5d82cae 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -22,13 +22,12 @@ macro(LINK_HIFI_LIBRARIES TARGET) add_dependencies(${TARGET} ${HIFI_LIBRARY}) + # link the actual library + list(APPEND ${TARGET}_LIBRARIES_TO_LINK ${HIFI_LIBRARY}) + + # ask the library what its dynamic dependencies are and link them get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES) - - if (LINKED_TARGET_DEPENDENCY_LIBRARIES) - target_link_libraries(${TARGET} ${HIFI_LIBRARY} ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) - else () - target_link_libraries(${TARGET} ${HIFI_LIBRARY}) - endif () + list(APPEND ${TARGET}_LIBRARIES_TO_LINK ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) endforeach() diff --git a/cmake/macros/LinkSharedDependenciesToTarget.cmake b/cmake/macros/LinkSharedDependenciesToTarget.cmake new file mode 100644 index 0000000000..42f7109807 --- /dev/null +++ b/cmake/macros/LinkSharedDependenciesToTarget.cmake @@ -0,0 +1,25 @@ +# +# LinkHifiLibrary.cmake +# cmake/macros +# +# Copyright 2014 High Fidelity, Inc. +# Created by Stephen Birarda on August 8, 2014 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +macro(LINK_SHARED_DEPENDENCIES_TO_TARGET TARGET) + if (${TARGET}_LIBRARIES_TO_LINK) + list(REMOVE_DUPLICATES ${TARGET}_LIBRARIES_TO_LINK) + + # link these libraries to our target + target_link_libraries(${TARGET} ${${TARGET}_LIBRARIES_TO_LINK}) + endif () + + # we've already linked our Qt modules, but we need to bubble them up to parents + list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${${TARGET}_QT_MODULES_TO_LINK}") + + # set the property on this target so it can be retreived by targets linking to us + set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${${TARGET}_LIBRARIES_TO_LINK}") +endmacro(LINK_SHARED_DEPENDENCIES_TO_TARGET _target) \ No newline at end of file diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 6da3755ea4..73ee208b98 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -15,7 +15,7 @@ macro(SETUP_HIFI_LIBRARY TARGET) file(GLOB LIB_SRCS src/*.h src/*.cpp) set(LIB_SRCS ${LIB_SRCS}) - # create a library and set the property so it can be referenced later + # create a library and set the property so it can be referenced later add_library(${TARGET} ${LIB_SRCS} ${AUTOMTC_SRC}) set(QT_MODULES_TO_LINK ${ARGN}) @@ -24,17 +24,10 @@ macro(SETUP_HIFI_LIBRARY TARGET) find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) foreach(QT_MODULE ${QT_MODULES_TO_LINK}) - # link this Qt module to ourselves - target_link_libraries(${TARGET} Qt5::${QT_MODULE}) - get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) - # add the actual path to the Qt module to a QT_LIBRARIES variable - list(APPEND QT_LIBRARIES ${QT_LIBRARY_LOCATION}) + # add the actual path to the Qt module to our LIBRARIES_TO_LINK variable + target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + list(APPEND ${TARGET}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) endforeach() - - if (QT_LIBRARIES) - set_target_properties(${TARGET} PROPERTIES DEPENDENCY_LIBRARIES "${QT_LIBRARIES}") - endif () - endmacro(SETUP_HIFI_LIBRARY _target) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index 281aa42650..c680790f02 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -7,7 +7,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) +macro(SETUP_HIFI_PROJECT TARGET) project(${TARGET}) # grab the implemenation and header files @@ -23,10 +23,19 @@ macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) endforeach() # add the executable, include additional optional sources - add_executable(${TARGET} ${TARGET_SRCS} ${ARGN}) + add_executable(${TARGET} ${TARGET_SRCS} "${AUTOMTC_SRC}") + + set(QT_MODULES_TO_LINK ${ARGN}) + list(APPEND QT_MODULES_TO_LINK Core) + + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + + foreach(QT_MODULE ${QT_MODULES_TO_LINK}) + target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + + # add the actual path to the Qt module to our LIBRARIES_TO_LINK variable + get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) + list(APPEND ${TARGET}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) + endforeach() - if (${INCLUDE_QT}) - find_package(Qt5 COMPONENTS Core) - target_link_libraries(${TARGET} Qt5::Core) - endif () endmacro() \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 7f9dc2db37..3c1d34ba01 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME domain-server) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # remove and then copy the files for the webserver add_custom_command(TARGET ${TARGET_NAME} POST_BUILD diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 9c419d9369..19fa087092 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -3,4 +3,7 @@ set(TARGET_NAME animation) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME} Network Script) -link_hifi_libraries(${TARGET_NAME} shared fbx) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared fbx) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 354a3772dd..8487f48ad3 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -5,4 +5,7 @@ setup_hifi_library(${TARGET_NAME} Network) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} networking shared) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} networking shared) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index d05faf3b27..2791589abb 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -6,4 +6,7 @@ setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) -include_hifi_library_headers(fbx) \ No newline at end of file +include_hifi_library_headers(fbx) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index c299aa654d..b397003133 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -1,4 +1,7 @@ set(TARGET_NAME embedded-webserver) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network) \ No newline at end of file +setup_hifi_library(${TARGET_NAME} Network) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index e9658de4a2..d02cc918fc 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -7,12 +7,9 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared networking octree voxels) -# link ZLIB find_package(ZLIB) - include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") +list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index a8d6de698b..b9a03bf0f4 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -8,4 +8,7 @@ setup_hifi_library(${TARGET_NAME} Network Script Widgets) # link in the networking library link_hifi_libraries(${TARGET_NAME} shared networking) -include_glm(${TARGET_NAME} "${ROOT_DIR}") \ No newline at end of file +include_glm(${TARGET_NAME} "${ROOT_DIR}") + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index c0610b0501..89178f193a 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -5,4 +5,7 @@ setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index fb9f07b81a..c2b86e2218 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -3,4 +3,7 @@ set(TARGET_NAME networking) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME} Network) -link_hifi_libraries(${TARGET_NAME} shared) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 340b2393e6..1fa730aad7 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -7,13 +7,15 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared networking) -# link ZLIB +# find ZLIB and OpenSSL find_package(ZLIB) find_package(OpenSSL REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file + +# append ZLIB and OpenSSL to our list of libraries to link +list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") +list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}") + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 2f523b22f7..f306c0a749 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -6,4 +6,7 @@ setup_hifi_library(${TARGET_NAME} Gui Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) -include_hifi_library_headers(script-engine) \ No newline at end of file +include_hifi_library_headers(script-engine) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index cce7d8d07b..a16d6270c9 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -5,4 +5,7 @@ setup_hifi_library(${TARGET_NAME} Gui Network Script Widgets) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 9cc1b968dc..1a6b39ea59 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,4 +1,7 @@ set(TARGET_NAME shared) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Widgets) \ No newline at end of file +setup_hifi_library(${TARGET_NAME} Network Widgets) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 7f200523de..87841ca29f 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -7,10 +7,12 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree networking) -# link ZLIB +# find ZLIB find_package(ZLIB) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -get_target_property(LINKED_LIBRARIES ${TARGET_NAME} DEPENDENCY_LIBRARIES) -list(APPEND DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") -list(REMOVE_DUPLICATES DEPENDENCY_LIBRARIES) \ No newline at end of file +# add it to our list of libraries to link +list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 34d053b008..f5d9388508 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME audio-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) #include glm include_glm(${TARGET_NAME} ${ROOT_DIR}) diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 4fb3d56492..9c861eac3e 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME jitter-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared networking) \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index d459ea1fed..358a959eb0 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -4,7 +4,7 @@ find_package(Qt5 COMPONENTS Network Script Widgets) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -setup_hifi_project(${TARGET_NAME} TRUE "${AUTOMTC_SRC}") +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index ec48bb80cd..68de37a1d2 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME networking-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared networking) diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index 85442db783..a8e27e0084 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME octree-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} octree) diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 2161723619..01bdf5a96b 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME physics-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index bea8448f5e..828559936b 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME shared-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 3b3a65c259..a5077dc181 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,2 +1,2 @@ set(TARGET_NAME bitstream2json) -setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 452f845356..28c18f6762 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,2 +1,2 @@ set(TARGET_NAME json2bitstream) -setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) \ No newline at end of file diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 467d03d241..0b1c438393 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,2 +1,2 @@ set(TARGET_NAME mtc) -setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index db22f040b7..5fa4061117 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,3 +1,3 @@ set(TARGET_NAME voxel-edit) -setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) \ No newline at end of file From e4d01d269c9d53739a0b315ce78adcaba15e1ffb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 11:51:12 -0700 Subject: [PATCH 46/94] use shared dependency linking macro in hifi projects --- domain-server/CMakeLists.txt | 9 +++++---- interface/CMakeLists.txt | 3 +++ tests/audio/CMakeLists.txt | 5 ++++- tests/jitter/CMakeLists.txt | 5 ++++- tests/metavoxels/CMakeLists.txt | 8 +++----- tests/networking/CMakeLists.txt | 2 ++ tests/octree/CMakeLists.txt | 5 ++--- tests/physics/CMakeLists.txt | 2 ++ tests/shared/CMakeLists.txt | 3 +++ tools/bitstream2json/CMakeLists.txt | 5 ++++- tools/mtc/CMakeLists.txt | 5 ++++- voxel-edit/CMakeLists.txt | 5 ++++- 12 files changed, 40 insertions(+), 17 deletions(-) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 3c1d34ba01..99e57cb0e6 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,6 +1,7 @@ set(TARGET_NAME domain-server) -setup_hifi_project(${TARGET_NAME}) +# setup the project and link required Qt modules +setup_hifi_project(${TARGET_NAME} Network) # remove and then copy the files for the webserver add_custom_command(TARGET ${TARGET_NAME} POST_BUILD @@ -11,8 +12,8 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD "${PROJECT_SOURCE_DIR}/resources/web" $/resources/web) -# link the shared hifi library +# link the shared hifi libraries link_hifi_libraries(${TARGET_NAME} embedded-webserver networking shared) -find_package(Qt5 COMPONENTS Network Widgets) -target_link_libraries(${TARGET_NAME} Qt5::Network) +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index ea4b54257b..a2770943a7 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -209,3 +209,6 @@ else (APPLE) target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib) endif() endif (APPLE) + +# link any dependencies bubbled up from our linked dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index f5d9388508..973726852d 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -6,4 +6,7 @@ setup_hifi_project(${TARGET_NAME}) include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared audio networking) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared audio networking) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 9c861eac3e..577591227f 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -3,4 +3,7 @@ set(TARGET_NAME jitter-tests) setup_hifi_project(${TARGET_NAME}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared networking) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared networking) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 358a959eb0..6432b9a259 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -1,13 +1,11 @@ set(TARGET_NAME metavoxel-tests) -find_package(Qt5 COMPONENTS Network Script Widgets) - auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} Network Script Widgets) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) - +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 68de37a1d2..214b66fd1f 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -5,3 +5,5 @@ setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared networking) +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index a8e27e0084..e9a06bd1c1 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -5,6 +5,5 @@ setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} octree) -IF (WIN32) - target_link_libraries(${TARGET_NAME} wsock32.lib) -ENDIF(WIN32) +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 01bdf5a96b..74049b158b 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -5,3 +5,5 @@ setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index 828559936b..294a60d130 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -4,3 +4,6 @@ setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index a5077dc181..884f9f9c2c 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,2 +1,5 @@ set(TARGET_NAME bitstream2json) -setup_hifi_project(${TARGET_NAME}) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 0b1c438393..dc30da8098 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,2 +1,5 @@ set(TARGET_NAME mtc) -setup_hifi_project(${TARGET_NAME}) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index 5fa4061117..f9f8ed185b 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,3 +1,6 @@ set(TARGET_NAME voxel-edit) -setup_hifi_project(${TARGET_NAME}) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file From 0449660f66adf279ef09e0e74dd3a0ffaa33fe2c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 11:52:41 -0700 Subject: [PATCH 47/94] don't bubble up hifi libraries since they are static --- cmake/macros/LinkHifiLibraries.cmake | 4 ++-- tools/json2bitstream/CMakeLists.txt | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index 96c5d82cae..00020cc059 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -22,8 +22,8 @@ macro(LINK_HIFI_LIBRARIES TARGET) add_dependencies(${TARGET} ${HIFI_LIBRARY}) - # link the actual library - list(APPEND ${TARGET}_LIBRARIES_TO_LINK ${HIFI_LIBRARY}) + # link the actual library - it is static so don't bubble it up + target_link_libraries(${TARGET} ${HIFI_LIBRARY}) # ask the library what its dynamic dependencies are and link them get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES) diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 28c18f6762..3868b551ea 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,2 +1,5 @@ set(TARGET_NAME json2bitstream) -setup_hifi_project(${TARGET_NAME}) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file From 27419b7b6b9b8b7bbb089f771ac07419159e6ae1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 12:41:41 -0700 Subject: [PATCH 48/94] fix some build blockers in test directory --- libraries/shared/src/MovingMinMaxAvg.h | 1 + tests/metavoxels/CMakeLists.txt | 2 ++ tests/networking/src/SequenceNumberStatsTests.cpp | 7 ++++--- tests/octree/CMakeLists.txt | 6 ++++-- tests/physics/CMakeLists.txt | 2 ++ tests/shared/CMakeLists.txt | 2 ++ 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/shared/src/MovingMinMaxAvg.h b/libraries/shared/src/MovingMinMaxAvg.h index 734018b469..7d4b3df124 100644 --- a/libraries/shared/src/MovingMinMaxAvg.h +++ b/libraries/shared/src/MovingMinMaxAvg.h @@ -12,6 +12,7 @@ #ifndef hifi_MovingMinMaxAvg_h #define hifi_MovingMinMaxAvg_h +#include #include #include "RingBufferHistory.h" diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 6432b9a259..0fad728764 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -2,6 +2,8 @@ set(TARGET_NAME metavoxel-tests) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") +include_glm(${TARGET_NAME}) + setup_hifi_project(${TARGET_NAME} Network Script Widgets) # link in the shared libraries diff --git a/tests/networking/src/SequenceNumberStatsTests.cpp b/tests/networking/src/SequenceNumberStatsTests.cpp index 901a018235..ded67b1ab6 100644 --- a/tests/networking/src/SequenceNumberStatsTests.cpp +++ b/tests/networking/src/SequenceNumberStatsTests.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "SequenceNumberStatsTests.h" - -#include "SharedUtil.h" +#include #include +#include + +#include "SequenceNumberStatsTests.h" void SequenceNumberStatsTests::runAllTests() { rolloverTest(); diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index e9a06bd1c1..baae258643 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -1,9 +1,11 @@ set(TARGET_NAME octree-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} Script Network) + +include_glm(${TARGET_NAME}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} octree) +link_hifi_libraries(${TARGET_NAME} animation fbx models networking octree shared) # link any shared dependencies link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 74049b158b..e2affa7b47 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -2,6 +2,8 @@ set(TARGET_NAME physics-tests) setup_hifi_project(${TARGET_NAME}) +include_glm(${TARGET_NAME}) + # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index 294a60d130..f819a2734b 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -2,6 +2,8 @@ set(TARGET_NAME shared-tests) setup_hifi_project(${TARGET_NAME}) +include_glm(${TARGET_NAME}) + # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) From b1310c065ce7e37d1c61026e53614b99207d6311 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 12:55:06 -0700 Subject: [PATCH 49/94] remove TARGET_NAME from cmake macros where it is not required --- assignment-client/CMakeLists.txt | 8 ++++---- cmake/macros/AutoMTC.cmake | 4 ++-- cmake/macros/IncludeGLM.cmake | 4 ++-- cmake/macros/LinkHifiLibraries.cmake | 10 +++++----- ...ToTarget.cmake => LinkSharedDependencies.cmake} | 14 +++++++------- cmake/macros/SetupHifiLibrary.cmake | 12 ++++++------ cmake/macros/SetupHifiProject.cmake | 10 +++++----- domain-server/CMakeLists.txt | 6 +++--- interface/CMakeLists.txt | 6 +++--- libraries/animation/CMakeLists.txt | 6 +++--- libraries/audio/CMakeLists.txt | 8 ++++---- libraries/avatars/CMakeLists.txt | 8 ++++---- libraries/embedded-webserver/CMakeLists.txt | 4 ++-- libraries/fbx/CMakeLists.txt | 8 ++++---- libraries/metavoxels/CMakeLists.txt | 10 +++++----- libraries/models/CMakeLists.txt | 8 ++++---- libraries/networking/CMakeLists.txt | 6 +++--- libraries/octree/CMakeLists.txt | 8 ++++---- libraries/particles/CMakeLists.txt | 8 ++++---- libraries/script-engine/CMakeLists.txt | 8 ++++---- libraries/shared/CMakeLists.txt | 4 ++-- libraries/voxels/CMakeLists.txt | 8 ++++---- tests/audio/CMakeLists.txt | 9 ++++----- tests/jitter/CMakeLists.txt | 6 +++--- tests/metavoxels/CMakeLists.txt | 10 +++++----- tests/networking/CMakeLists.txt | 6 +++--- tests/octree/CMakeLists.txt | 8 ++++---- tests/physics/CMakeLists.txt | 8 ++++---- tests/shared/CMakeLists.txt | 8 ++++---- tools/bitstream2json/CMakeLists.txt | 4 ++-- tools/json2bitstream/CMakeLists.txt | 4 ++-- tools/mtc/CMakeLists.txt | 4 ++-- voxel-edit/CMakeLists.txt | 4 ++-- 33 files changed, 119 insertions(+), 120 deletions(-) rename cmake/macros/{LinkSharedDependenciesToTarget.cmake => LinkSharedDependencies.cmake} (61%) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 9f8542c42e..972c6ac220 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME assignment-client) -setup_hifi_project(${TARGET_NAME} Core Gui Network Script Widgets) +setup_hifi_project(Core Gui Network Script Widgets) -include_glm(${TARGET_NAME}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} +link_hifi_libraries( audio avatars octree voxels fbx particles models metavoxels networking animation shared script-engine embedded-webserver ) @@ -14,4 +14,4 @@ if (UNIX) list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${CMAKE_DL_LIBS}) endif (UNIX) -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/cmake/macros/AutoMTC.cmake b/cmake/macros/AutoMTC.cmake index 0e376fc176..4d433e7b69 100644 --- a/cmake/macros/AutoMTC.cmake +++ b/cmake/macros/AutoMTC.cmake @@ -8,8 +8,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(AUTO_MTC TARGET) - set(AUTOMTC_SRC ${TARGET}_automtc.cpp) +macro(AUTO_MTC) + set(AUTOMTC_SRC ${TARGET_NAME}_automtc.cpp) file(GLOB INCLUDE_FILES src/*.h) diff --git a/cmake/macros/IncludeGLM.cmake b/cmake/macros/IncludeGLM.cmake index ec7816770f..e2fa981a3b 100644 --- a/cmake/macros/IncludeGLM.cmake +++ b/cmake/macros/IncludeGLM.cmake @@ -7,7 +7,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(INCLUDE_GLM TARGET) +macro(INCLUDE_GLM) find_package(GLM REQUIRED) include_directories("${GLM_INCLUDE_DIRS}") @@ -16,4 +16,4 @@ macro(INCLUDE_GLM TARGET) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GLM_INCLUDE_DIRS}") endif () -endmacro(INCLUDE_GLM _target) \ No newline at end of file +endmacro(INCLUDE_GLM) \ No newline at end of file diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index 00020cc059..9d73963fea 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -7,7 +7,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(LINK_HIFI_LIBRARIES TARGET) +macro(LINK_HIFI_LIBRARIES) file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}") @@ -20,15 +20,15 @@ macro(LINK_HIFI_LIBRARIES TARGET) include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src") - add_dependencies(${TARGET} ${HIFI_LIBRARY}) + add_dependencies(${TARGET_NAME} ${HIFI_LIBRARY}) # link the actual library - it is static so don't bubble it up - target_link_libraries(${TARGET} ${HIFI_LIBRARY}) + target_link_libraries(${TARGET_NAME} ${HIFI_LIBRARY}) # ask the library what its dynamic dependencies are and link them get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES) - list(APPEND ${TARGET}_LIBRARIES_TO_LINK ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) + list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) endforeach() -endmacro(LINK_HIFI_LIBRARIES _target _libraries) \ No newline at end of file +endmacro(LINK_HIFI_LIBRARIES) \ No newline at end of file diff --git a/cmake/macros/LinkSharedDependenciesToTarget.cmake b/cmake/macros/LinkSharedDependencies.cmake similarity index 61% rename from cmake/macros/LinkSharedDependenciesToTarget.cmake rename to cmake/macros/LinkSharedDependencies.cmake index 42f7109807..ae478ca530 100644 --- a/cmake/macros/LinkSharedDependenciesToTarget.cmake +++ b/cmake/macros/LinkSharedDependencies.cmake @@ -1,5 +1,5 @@ # -# LinkHifiLibrary.cmake +# LinkSharedDependencies.cmake # cmake/macros # # Copyright 2014 High Fidelity, Inc. @@ -9,17 +9,17 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(LINK_SHARED_DEPENDENCIES_TO_TARGET TARGET) - if (${TARGET}_LIBRARIES_TO_LINK) - list(REMOVE_DUPLICATES ${TARGET}_LIBRARIES_TO_LINK) +macro(LINK_SHARED_DEPENDENCIES) + if (${TARGET_NAME}_LIBRARIES_TO_LINK) + list(REMOVE_DUPLICATES ${TARGET_NAME}_LIBRARIES_TO_LINK) # link these libraries to our target - target_link_libraries(${TARGET} ${${TARGET}_LIBRARIES_TO_LINK}) + target_link_libraries(${TARGET_NAME} ${${TARGET_NAME}_LIBRARIES_TO_LINK}) endif () # we've already linked our Qt modules, but we need to bubble them up to parents - list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${${TARGET}_QT_MODULES_TO_LINK}") + list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${${TARGET}_QT_MODULES_TO_LINK}") # set the property on this target so it can be retreived by targets linking to us set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${${TARGET}_LIBRARIES_TO_LINK}") -endmacro(LINK_SHARED_DEPENDENCIES_TO_TARGET _target) \ No newline at end of file +endmacro(LINK_SHARED_DEPENDENCIES) \ No newline at end of file diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 73ee208b98..3c2590d38d 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -7,16 +7,16 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(SETUP_HIFI_LIBRARY TARGET) +macro(SETUP_HIFI_LIBRARY) - project(${TARGET}) + project(${TARGET_NAME}) # grab the implemenation and header files file(GLOB LIB_SRCS src/*.h src/*.cpp) set(LIB_SRCS ${LIB_SRCS}) # create a library and set the property so it can be referenced later - add_library(${TARGET} ${LIB_SRCS} ${AUTOMTC_SRC}) + add_library(${TARGET_NAME} ${LIB_SRCS} ${AUTOMTC_SRC}) set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) @@ -27,7 +27,7 @@ macro(SETUP_HIFI_LIBRARY TARGET) get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) # add the actual path to the Qt module to our LIBRARIES_TO_LINK variable - target_link_libraries(${TARGET} Qt5::${QT_MODULE}) - list(APPEND ${TARGET}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) + target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) + list(APPEND ${TARGET_NAME}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) endforeach() -endmacro(SETUP_HIFI_LIBRARY _target) \ No newline at end of file +endmacro(SETUP_HIFI_LIBRARY) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index c680790f02..62c215e595 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -7,8 +7,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(SETUP_HIFI_PROJECT TARGET) - project(${TARGET}) +macro(SETUP_HIFI_PROJECT) + project(${TARGET_NAME}) # grab the implemenation and header files file(GLOB TARGET_SRCS src/*) @@ -23,7 +23,7 @@ macro(SETUP_HIFI_PROJECT TARGET) endforeach() # add the executable, include additional optional sources - add_executable(${TARGET} ${TARGET_SRCS} "${AUTOMTC_SRC}") + add_executable(${TARGET_NAME} ${TARGET_SRCS} "${AUTOMTC_SRC}") set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) @@ -31,11 +31,11 @@ macro(SETUP_HIFI_PROJECT TARGET) find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) foreach(QT_MODULE ${QT_MODULES_TO_LINK}) - target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) # add the actual path to the Qt module to our LIBRARIES_TO_LINK variable get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) - list(APPEND ${TARGET}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) + list(APPEND ${TARGET_NAME}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) endforeach() endmacro() \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 99e57cb0e6..bc9269b9ce 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,7 +1,7 @@ set(TARGET_NAME domain-server) # setup the project and link required Qt modules -setup_hifi_project(${TARGET_NAME} Network) +setup_hifi_project(Network) # remove and then copy the files for the webserver add_custom_command(TARGET ${TARGET_NAME} POST_BUILD @@ -13,7 +13,7 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD $/resources/web) # link the shared hifi libraries -link_hifi_libraries(${TARGET_NAME} embedded-webserver networking shared) +link_hifi_libraries(embedded-webserver networking shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index a2770943a7..d58bea6f9e 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -32,7 +32,7 @@ elseif (WIN32) endif () # set up the external glm library -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() # create the InterfaceConfig.h file based on GL_HEADERS above configure_file(InterfaceConfig.h.in "${PROJECT_BINARY_DIR}/includes/InterfaceConfig.h") @@ -91,7 +91,7 @@ endif() add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) # link required hifi libraries -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx metavoxels networking particles models avatars audio animation script-engine) +link_hifi_libraries(shared octree voxels fbx metavoxels networking particles models avatars audio animation script-engine) # find any optional and required libraries find_package(Faceplus) @@ -211,4 +211,4 @@ else (APPLE) endif (APPLE) # link any dependencies bubbled up from our linked dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) +link_shared_dependencies() diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 19fa087092..3f65c1ab6c 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -1,9 +1,9 @@ set(TARGET_NAME animation) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Script) +setup_hifi_library(Network Script) -link_hifi_libraries(${TARGET_NAME} shared fbx) +link_hifi_libraries(shared fbx) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 8487f48ad3..6ade1fc423 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME audio) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network) +setup_hifi_library(Network) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} networking shared) +link_hifi_libraries(networking shared) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 2791589abb..1d287ee7a2 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -1,12 +1,12 @@ set(TARGET_NAME avatars) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Script) +setup_hifi_library(Network Script) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) +link_hifi_libraries(shared octree voxels networking) include_hifi_library_headers(fbx) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index b397003133..6e4b92e217 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -1,7 +1,7 @@ set(TARGET_NAME embedded-webserver) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network) +setup_hifi_library(Network) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index d02cc918fc..3cc510aed9 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -1,15 +1,15 @@ set(TARGET_NAME fbx) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME}) +setup_hifi_library() -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm("${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared networking octree voxels) +link_hifi_libraries(shared networking octree voxels) find_package(ZLIB) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) +link_shared_dependencies() diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index b9a03bf0f4..aab8d2184d 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -1,14 +1,14 @@ set(TARGET_NAME metavoxels) -auto_mtc(${TARGET_NAME} "${ROOT_DIR}") +auto_mtc() # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Script Widgets) +setup_hifi_library(Network Script Widgets) # link in the networking library -link_hifi_libraries(${TARGET_NAME} shared networking) +link_hifi_libraries(shared networking) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 89178f193a..858d01efa1 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME models) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Script) +setup_hifi_library(Network Script) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) +link_hifi_libraries(shared octree fbx networking animation) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index c2b86e2218..3191cfe67b 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,9 +1,9 @@ set(TARGET_NAME networking) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network) +setup_hifi_library(Network) -link_hifi_libraries(${TARGET_NAME} shared) +link_hifi_libraries(shared) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 1fa730aad7..193b058466 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME octree) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME}) +setup_hifi_library() -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared networking) +link_hifi_libraries(shared networking) # find ZLIB and OpenSSL find_package(ZLIB) @@ -18,4 +18,4 @@ list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}") # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index f306c0a749..27fc816530 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -1,12 +1,12 @@ set(TARGET_NAME particles) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Gui Network Script) +setup_hifi_library(Gui Network Script) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) +link_hifi_libraries(shared octree fbx networking animation) include_hifi_library_headers(script-engine) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index a16d6270c9..dd28e77b7e 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME script-engine) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Gui Network Script Widgets) +setup_hifi_library(Gui Network Script Widgets) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) +link_hifi_libraries(shared octree voxels fbx particles models animation) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 1a6b39ea59..17ccbdc6ce 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,7 +1,7 @@ set(TARGET_NAME shared) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Widgets) +setup_hifi_library(Network Widgets) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 87841ca29f..d9d8717fba 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME voxels) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Widgets Script) +setup_hifi_library(Widgets Script) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree networking) +link_hifi_libraries(shared octree networking) # find ZLIB find_package(ZLIB) @@ -15,4 +15,4 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 973726852d..3ef87ede28 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -1,12 +1,11 @@ set(TARGET_NAME audio-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() -#include glm -include_glm(${TARGET_NAME} ${ROOT_DIR}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared audio networking) +link_hifi_libraries(shared audio networking) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 577591227f..28a312540f 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -1,9 +1,9 @@ set(TARGET_NAME jitter-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared networking) +link_hifi_libraries(shared networking) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 0fad728764..53b6da4301 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -1,13 +1,13 @@ set(TARGET_NAME metavoxel-tests) -auto_mtc(${TARGET_NAME} "${ROOT_DIR}") +auto_mtc() -include_glm(${TARGET_NAME}) +include_glm() -setup_hifi_project(${TARGET_NAME} Network Script Widgets) +setup_hifi_project(Network Script Widgets) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) +link_hifi_libraries(metavoxels networking shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 214b66fd1f..28fdb539b7 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -1,9 +1,9 @@ set(TARGET_NAME networking-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared networking) +link_hifi_libraries(shared networking) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index baae258643..b59344f7f0 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME octree-tests) -setup_hifi_project(${TARGET_NAME} Script Network) +setup_hifi_project(Script Network) -include_glm(${TARGET_NAME}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} animation fbx models networking octree shared) +link_hifi_libraries(animation fbx models networking octree shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index e2affa7b47..c2c9327fa0 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME physics-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() -include_glm(${TARGET_NAME}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared) +link_hifi_libraries(shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index f819a2734b..8fa2a1c3c4 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME shared-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() -include_glm(${TARGET_NAME}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared) +link_hifi_libraries(shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 884f9f9c2c..5cf833eaef 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,5 +1,5 @@ set(TARGET_NAME bitstream2json) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 3868b551ea..d8619d95a3 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,5 +1,5 @@ set(TARGET_NAME json2bitstream) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index dc30da8098..2a530f3c66 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,5 +1,5 @@ set(TARGET_NAME mtc) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index f9f8ed185b..fea2e27ab1 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME voxel-edit) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file From a99b19d28ac8757cf48cacff335aca3583f9516d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 12:57:46 -0700 Subject: [PATCH 50/94] make Qt5 and ZLIB required finds, add OpenSSL to interface --- cmake/macros/SetupHifiLibrary.cmake | 2 +- cmake/macros/SetupHifiProject.cmake | 2 +- interface/CMakeLists.txt | 7 +++++-- libraries/fbx/CMakeLists.txt | 2 +- libraries/octree/CMakeLists.txt | 2 +- libraries/voxels/CMakeLists.txt | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 3c2590d38d..7bb85f68f5 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -21,7 +21,7 @@ macro(SETUP_HIFI_LIBRARY) set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) - find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK} REQUIRED) foreach(QT_MODULE ${QT_MODULES_TO_LINK}) get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index 62c215e595..d21e2c11bb 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -28,7 +28,7 @@ macro(SETUP_HIFI_PROJECT) set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) - find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK} REQUIRED) foreach(QT_MODULE ${QT_MODULES_TO_LINK}) target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index d58bea6f9e..a042cfd1c1 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -102,10 +102,12 @@ find_package(SDL) find_package(Sixense) find_package(Visage) find_package(LeapMotion) -find_package(ZLIB) find_package(Qxmpp) find_package(RtMidi) +find_package(ZLIB REQUIRED) +find_package(OpenSSL REQUIRED) + # perform standard include and linking for found externals foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) string(TOUPPER ${EXTERNAL} UPPER_EXTERNAL) @@ -157,9 +159,10 @@ endif () # include headers for interface and InterfaceConfig. include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") +include_directories("${OPENSSL_INCLUDE_DIR}") target_link_libraries( - ${TARGET_NAME} "${ZLIB_LIBRARIES}" + ${TARGET_NAME} "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" Qt5::Gui Qt5::Network Qt5::Multimedia Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKitWidgets ) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 3cc510aed9..794c6edbe6 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -7,7 +7,7 @@ include_glm("${ROOT_DIR}") link_hifi_libraries(shared networking octree voxels) -find_package(ZLIB) +find_package(ZLIB REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 193b058466..da641d1524 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -8,7 +8,7 @@ include_glm() link_hifi_libraries(shared networking) # find ZLIB and OpenSSL -find_package(ZLIB) +find_package(ZLIB REQUIRED) find_package(OpenSSL REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index d9d8717fba..3214978a2a 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -8,7 +8,7 @@ include_glm() link_hifi_libraries(shared octree networking) # find ZLIB -find_package(ZLIB) +find_package(ZLIB REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") # add it to our list of libraries to link From 2fda95ae8fda3cfb7231d2d0c92dee33e9253f8a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:06:23 -0700 Subject: [PATCH 51/94] repair build of various tools --- domain-server/CMakeLists.txt | 1 - tests/audio/CMakeLists.txt | 1 - tests/jitter/CMakeLists.txt | 1 - tests/metavoxels/CMakeLists.txt | 1 - tests/networking/CMakeLists.txt | 1 - tests/octree/CMakeLists.txt | 1 - tests/physics/CMakeLists.txt | 1 - tests/shared/CMakeLists.txt | 1 - tools/bitstream2json/CMakeLists.txt | 7 +++++-- tools/json2bitstream/CMakeLists.txt | 7 +++++-- tools/mtc/CMakeLists.txt | 1 - voxel-edit/CMakeLists.txt | 5 ++++- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index bc9269b9ce..0fb9d25b5f 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -15,5 +15,4 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD # link the shared hifi libraries link_hifi_libraries(embedded-webserver networking shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 3ef87ede28..974b4dcd09 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -7,5 +7,4 @@ include_glm() # link in the shared libraries link_hifi_libraries(shared audio networking) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 28a312540f..d0b366e7ef 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -5,5 +5,4 @@ setup_hifi_project() # link in the shared libraries link_hifi_libraries(shared networking) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 53b6da4301..732c974f95 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -9,5 +9,4 @@ setup_hifi_project(Network Script Widgets) # link in the shared libraries link_hifi_libraries(metavoxels networking shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 28fdb539b7..a7293226b3 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -5,5 +5,4 @@ setup_hifi_project() # link in the shared libraries link_hifi_libraries(shared networking) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index b59344f7f0..5d37b51abe 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -7,5 +7,4 @@ include_glm() # link in the shared libraries link_hifi_libraries(animation fbx models networking octree shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index c2c9327fa0..96aaf48860 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -7,5 +7,4 @@ include_glm() # link in the shared libraries link_hifi_libraries(shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index 8fa2a1c3c4..fe3843e9eb 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -7,5 +7,4 @@ include_glm() # link in the shared libraries link_hifi_libraries(shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 5cf833eaef..bc23a1e193 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,5 +1,8 @@ set(TARGET_NAME bitstream2json) -setup_hifi_project() +setup_hifi_project(Widgets Script) + +include_glm() + +link_hifi_libraries(metavoxels) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index d8619d95a3..91b56c18fd 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,5 +1,8 @@ set(TARGET_NAME json2bitstream) -setup_hifi_project() +setup_hifi_project(Widgets Script) + +include_glm() + +link_hifi_libraries(metavoxels) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 2a530f3c66..4dfa8421ff 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,5 +1,4 @@ set(TARGET_NAME mtc) setup_hifi_project() -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index fea2e27ab1..b61ee6d132 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -2,5 +2,8 @@ set(TARGET_NAME voxel-edit) setup_hifi_project() -# link any shared dependencies +include_glm() + +link_hifi_libraries(networking octree shared voxels) + link_shared_dependencies() \ No newline at end of file From 9d8818eee53287689dd01cfba42f1c4ea5faf278 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:18:32 -0700 Subject: [PATCH 52/94] remove OpenSSL requirement from octree library --- libraries/octree/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index da641d1524..c302a082be 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -7,15 +7,13 @@ include_glm() link_hifi_libraries(shared networking) -# find ZLIB and OpenSSL +# find ZLIB find_package(ZLIB REQUIRED) -find_package(OpenSSL REQUIRED) -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") +include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") # append ZLIB and OpenSSL to our list of libraries to link list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") -list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}") # call macro to link our dependencies and bubble them up via a property on our target link_shared_dependencies() \ No newline at end of file From 92b2fe6d68f17a0209df58a2712a34ad5e9ed0ae Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:22:00 -0700 Subject: [PATCH 53/94] remove ROOT_DIR param in include_glm, remove ROOT_DIR from root CMakeLists --- CMakeLists.txt | 4 ++-- libraries/fbx/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb54bcbd8a..28ff00cc96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,13 +44,13 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries") -set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") +set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") + file(GLOB HIFI_CUSTOM_MACROS "cmake/macros/*.cmake") foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS}) include(${CUSTOM_MACRO}) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 794c6edbe6..894fa14c33 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -3,7 +3,7 @@ set(TARGET_NAME fbx) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() -include_glm("${ROOT_DIR}") +include_glm() link_hifi_libraries(shared networking octree voxels) From 6eb2c736247180a1cfdcdc955d9e10411b657264 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:23:54 -0700 Subject: [PATCH 54/94] add assert include to SharedUtil --- libraries/shared/src/SharedUtil.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 470dfffd13..ecf96e0190 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include #include #include From d8dadc3199b83379361e26fc5060cdf6e4e26eff Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:31:09 -0700 Subject: [PATCH 55/94] link the socket library to the hifi networking library --- libraries/networking/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 3191cfe67b..501437fab2 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -5,5 +5,10 @@ setup_hifi_library(Network) link_hifi_libraries(shared) +if (WIN32) + # we need ws2_32.lib on windows, but it's static so we don't bubble it up + target_link_libraries(${TARGET_NAME} ws2_32.lib) +endif () + # call macro to link our dependencies and bubble them up via a property on our target link_shared_dependencies() \ No newline at end of file From 0dfbc8b8ba7288ddad1144c0726956561710c9a9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:32:34 -0700 Subject: [PATCH 56/94] add the xml library to QXMPP_LIBRARIES --- cmake/modules/FindQxmpp.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindQxmpp.cmake b/cmake/modules/FindQxmpp.cmake index e5b6e6506a..3c0e97c998 100644 --- a/cmake/modules/FindQxmpp.cmake +++ b/cmake/modules/FindQxmpp.cmake @@ -26,10 +26,12 @@ find_path(QXMPP_INCLUDE_DIRS QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${Q find_library(QXMPP_LIBRARY_RELEASE NAMES qxmpp PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS}) find_library(QXMPP_LIBRARY_DEBUG NAMES qxmpp_d PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS}) +find_package(Qt5 COMPONENTS Xml REQUIRED) + include(SelectLibraryConfigurations) select_library_configurations(QXMPP) -set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}") +set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}" Qt5::Xml) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) From 2badf9ab1a5d8fefa4c987b918c14d4f0ee38dc6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:42:07 -0700 Subject: [PATCH 57/94] don't quote linked ZLIB and OpenSSL libs for interface --- interface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index a042cfd1c1..82b102adf3 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -162,7 +162,7 @@ include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes" include_directories("${OPENSSL_INCLUDE_DIR}") target_link_libraries( - ${TARGET_NAME} "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" + ${TARGET_NAME} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} Qt5::Gui Qt5::Network Qt5::Multimedia Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKitWidgets ) From 234920b5bce2ccf4583a035ef380ad07c0269612 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:04:22 -0700 Subject: [PATCH 58/94] add QuartzCore to FindVisage module --- cmake/modules/FindVisage.cmake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 070905d6ff..36981827b1 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -32,6 +32,7 @@ if (APPLE) find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib HINTS ${VISAGE_SEARCH_DIRS}) + find_library(QuartzCore QuartzCore) elseif (WIN32) find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS}) find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h PATH_SUFFIXES dependencies/OpenCV/include HINTS ${VISAGE_SEARCH_DIRS}) @@ -43,14 +44,26 @@ elseif (WIN32) endif () include(FindPackageHandleStandardArgs) + +set(VISAGE_ARGS_LIST "VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR + VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY") + +if (APPLE) + list(APPEND VISAGE_ARGS_LIST QuartzCore) +endif () + find_package_handle_standard_args(VISAGE DEFAULT_MSG - VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY + VISAGE_ARGS_LIST ) set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR}" "${VISAGE_OPENCV2_INCLUDE_DIR}" "${VISAGE_BASE_INCLUDE_DIR}") set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") +if (APPLE) + list(APPEND VISAGE_LIBRARIES ${QuartzCore}) +endif () + mark_as_advanced( VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR From e74c8f5e56a00c65c30b265852c4bd0620ff0abd Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:08:18 -0700 Subject: [PATCH 59/94] don't set visage find args list as quoted string --- cmake/modules/FindVisage.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 36981827b1..d84bfbb69d 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -45,9 +45,9 @@ endif () include(FindPackageHandleStandardArgs) -set(VISAGE_ARGS_LIST "VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR +set(VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY") + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) if (APPLE) list(APPEND VISAGE_ARGS_LIST QuartzCore) From e24ff0130f03c0255c7647a081fa828a767e3268 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 8 Aug 2014 14:10:44 -0700 Subject: [PATCH 60/94] Basic color/height painting. --- interface/src/ui/MetavoxelEditor.cpp | 37 +++- interface/src/ui/MetavoxelEditor.h | 32 +++- .../metavoxels/src/MetavoxelMessages.cpp | 163 ++++++++++++++++++ libraries/metavoxels/src/MetavoxelMessages.h | 34 ++++ libraries/metavoxels/src/MetavoxelUtil.h | 2 + 5 files changed, 262 insertions(+), 6 deletions(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 48fa2ed070..bac8c56bc5 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -118,7 +118,8 @@ MetavoxelEditor::MetavoxelEditor() : addTool(new SetSpannerTool(this)); addTool(new ImportHeightfieldTool(this)); addTool(new EraseHeightfieldTool(this)); - addTool(new HeightBrushTool(this)); + addTool(new HeightfieldHeightBrushTool(this)); + addTool(new HeightfieldColorBrushTool(this)); updateAttributes(); @@ -1108,11 +1109,26 @@ void HeightfieldBrushTool::render() { if (!Application::getInstance()->getMetavoxels()->findFirstRayHeightfieldIntersection(origin, direction, distance)) { return; } - glm::vec3 point = origin + distance * direction; - Application::getInstance()->getMetavoxels()->renderHeightfieldCursor(point, _radius->value()); + Application::getInstance()->getMetavoxels()->renderHeightfieldCursor( + _position = origin + distance * direction, _radius->value()); } -HeightBrushTool::HeightBrushTool(MetavoxelEditor* editor) : +bool HeightfieldBrushTool::eventFilter(QObject* watched, QEvent* event) { + if (event->type() == QEvent::Wheel) { + float angle = static_cast(event)->angleDelta().y(); + const float ANGLE_SCALE = 1.0f / 1000.0f; + _radius->setValue(_radius->value() * glm::pow(2.0f, angle * ANGLE_SCALE)); + return true; + + } else if (event->type() == QEvent::MouseButtonPress) { + MetavoxelEditMessage message = { createEdit(static_cast(event)->button() == Qt::RightButton) }; + Application::getInstance()->getMetavoxels()->applyEdit(message, true); + return true; + } + return false; +} + +HeightfieldHeightBrushTool::HeightfieldHeightBrushTool(MetavoxelEditor* editor) : HeightfieldBrushTool(editor, "Height Brush") { _form->addRow("Height:", _height = new QDoubleSpinBox()); @@ -1121,3 +1137,16 @@ HeightBrushTool::HeightBrushTool(MetavoxelEditor* editor) : _height->setValue(1.0); } +QVariant HeightfieldHeightBrushTool::createEdit(bool alternate) { + return QVariant::fromValue(PaintHeightfieldHeightEdit(_position, _radius->value(), _height->value())); +} + +HeightfieldColorBrushTool::HeightfieldColorBrushTool(MetavoxelEditor* editor) : + HeightfieldBrushTool(editor, "Color Brush") { + + _form->addRow("Color:", _color = new QColorEditor(this)); +} + +QVariant HeightfieldColorBrushTool::createEdit(bool alternate) { + return QVariant::fromValue(PaintHeightfieldColorEdit(_position, _radius->value(), _color->getColor())); +} diff --git a/interface/src/ui/MetavoxelEditor.h b/interface/src/ui/MetavoxelEditor.h index 50b477a2bf..87d95a6927 100644 --- a/interface/src/ui/MetavoxelEditor.h +++ b/interface/src/ui/MetavoxelEditor.h @@ -18,6 +18,7 @@ #include "MetavoxelSystem.h" #include "renderer/ProgramObject.h" +class QColorEditor; class QComboBox; class QDoubleSpinBox; class QGroupBox; @@ -312,23 +313,50 @@ public: virtual void render(); + virtual bool eventFilter(QObject* watched, QEvent* event); + protected: + virtual QVariant createEdit(bool alternate) = 0; + QFormLayout* _form; QDoubleSpinBox* _radius; + + glm::vec3 _position; }; /// Allows raising or lowering parts of the heightfield. -class HeightBrushTool : public HeightfieldBrushTool { +class HeightfieldHeightBrushTool : public HeightfieldBrushTool { Q_OBJECT public: - HeightBrushTool(MetavoxelEditor* editor); + HeightfieldHeightBrushTool(MetavoxelEditor* editor); + +protected: + + virtual QVariant createEdit(bool alternate); private: QDoubleSpinBox* _height; }; +/// Allows coloring parts of the heightfield. +class HeightfieldColorBrushTool : public HeightfieldBrushTool { + Q_OBJECT + +public: + + HeightfieldColorBrushTool(MetavoxelEditor* editor); + +protected: + + virtual QVariant createEdit(bool alternate); + +private: + + QColorEditor* _color; +}; + #endif // hifi_MetavoxelEditor_h diff --git a/libraries/metavoxels/src/MetavoxelMessages.cpp b/libraries/metavoxels/src/MetavoxelMessages.cpp index dba9bc9c5c..dfd647fdb5 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.cpp +++ b/libraries/metavoxels/src/MetavoxelMessages.cpp @@ -318,3 +318,166 @@ SetDataEdit::SetDataEdit(const glm::vec3& minimum, const MetavoxelData& data, bo void SetDataEdit::apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const { data.set(minimum, this->data, blend); } + +PaintHeightfieldHeightEdit::PaintHeightfieldHeightEdit(const glm::vec3& position, float radius, float height) : + position(position), + radius(radius), + height(height) { +} + +class PaintHeightfieldHeightEditVisitor : public MetavoxelVisitor { +public: + + PaintHeightfieldHeightEditVisitor(const PaintHeightfieldHeightEdit& edit); + + virtual int visit(MetavoxelInfo& info); + +private: + + PaintHeightfieldHeightEdit _edit; + Box _bounds; +}; + +PaintHeightfieldHeightEditVisitor::PaintHeightfieldHeightEditVisitor(const PaintHeightfieldHeightEdit& edit) : + MetavoxelVisitor(QVector() << AttributeRegistry::getInstance()->getHeightfieldAttribute(), + QVector() << AttributeRegistry::getInstance()->getHeightfieldAttribute()), + _edit(edit) { + + glm::vec3 extents(_edit.radius, _edit.radius, _edit.radius); + _bounds = Box(_edit.position - extents, _edit.position + extents); +} + +int PaintHeightfieldHeightEditVisitor::visit(MetavoxelInfo& info) { + if (!info.getBounds().intersects(_bounds)) { + return STOP_RECURSION; + } + if (!info.isLeaf) { + return DEFAULT_ORDER; + } + HeightfieldDataPointer pointer = info.inputValues.at(0).getInlineValue(); + if (!pointer) { + return STOP_RECURSION; + } + QByteArray contents(pointer->getContents()); + int size = glm::sqrt((float)contents.size()); + int highest = size - 1; + float heightScale = highest / info.size; + + glm::vec3 center = (_edit.position - info.minimum) * heightScale; + float scaledRadius = _edit.radius * heightScale; + glm::vec3 extents(scaledRadius, scaledRadius, scaledRadius); + + glm::vec3 start = glm::floor(center - extents); + glm::vec3 end = glm::ceil(center + extents); + + float z = qMax(start.z, 0.0f); + float startX = qMax(start.x, 0.0f), endX = qMin(end.x, (float)highest); + uchar* lineDest = (uchar*)contents.data() + (int)z * size + (int)startX; + float squaredRadius = scaledRadius * scaledRadius; + float squaredRadiusReciprocal = 1.0f / squaredRadius; + const int EIGHT_BIT_MAXIMUM = 255; + float scaledHeight = _edit.height * EIGHT_BIT_MAXIMUM / info.size; + for (float endZ = qMin(end.z, (float)highest); z <= endZ; z += 1.0f) { + uchar* dest = lineDest; + for (float x = startX; x <= endX; x += 1.0f, dest++) { + float dx = x - center.x, dz = z - center.z; + float distanceSquared = dx * dx + dz * dz; + if (distanceSquared <= squaredRadius) { + int value = *dest + scaledHeight * (squaredRadius - distanceSquared) * squaredRadiusReciprocal; + *dest = qMin(qMax(value, 0), EIGHT_BIT_MAXIMUM); + } + } + lineDest += size; + } + + HeightfieldDataPointer newPointer(new HeightfieldData(contents)); + info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(newPointer)); + return STOP_RECURSION; +} + +void PaintHeightfieldHeightEdit::apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const { + PaintHeightfieldHeightEditVisitor visitor(*this); + data.guide(visitor); +} + +PaintHeightfieldColorEdit::PaintHeightfieldColorEdit(const glm::vec3& position, float radius, const QColor& color) : + position(position), + radius(radius), + color(color) { +} + +class PaintHeightfieldColorEditVisitor : public MetavoxelVisitor { +public: + + PaintHeightfieldColorEditVisitor(const PaintHeightfieldColorEdit& edit); + + virtual int visit(MetavoxelInfo& info); + +private: + + PaintHeightfieldColorEdit _edit; + Box _bounds; +}; + +PaintHeightfieldColorEditVisitor::PaintHeightfieldColorEditVisitor(const PaintHeightfieldColorEdit& edit) : + MetavoxelVisitor(QVector() << AttributeRegistry::getInstance()->getHeightfieldColorAttribute(), + QVector() << AttributeRegistry::getInstance()->getHeightfieldColorAttribute()), + _edit(edit) { + + glm::vec3 extents(_edit.radius, _edit.radius, _edit.radius); + _bounds = Box(_edit.position - extents, _edit.position + extents); +} + +int PaintHeightfieldColorEditVisitor::visit(MetavoxelInfo& info) { + if (!info.getBounds().intersects(_bounds)) { + return STOP_RECURSION; + } + if (!info.isLeaf) { + return DEFAULT_ORDER; + } + HeightfieldDataPointer pointer = info.inputValues.at(0).getInlineValue(); + if (!pointer) { + return STOP_RECURSION; + } + QByteArray contents(pointer->getContents()); + const int BYTES_PER_PIXEL = 3; + int size = glm::sqrt((float)contents.size() / BYTES_PER_PIXEL); + int highest = size - 1; + float heightScale = highest / info.size; + + glm::vec3 center = (_edit.position - info.minimum) * heightScale; + float scaledRadius = _edit.radius * heightScale; + glm::vec3 extents(scaledRadius, scaledRadius, scaledRadius); + + glm::vec3 start = glm::floor(center - extents); + glm::vec3 end = glm::ceil(center + extents); + + float z = qMax(start.z, 0.0f); + float startX = qMax(start.x, 0.0f), endX = qMin(end.x, (float)highest); + int stride = size * BYTES_PER_PIXEL; + char* lineDest = contents.data() + (int)z * stride + (int)startX * BYTES_PER_PIXEL; + float squaredRadius = scaledRadius * scaledRadius; + char red = _edit.color.red(), green = _edit.color.green(), blue = _edit.color.blue(); + for (float endZ = qMin(end.z, (float)highest); z <= endZ; z += 1.0f) { + char* dest = lineDest; + for (float x = startX; x <= endX; x += 1.0f, dest += BYTES_PER_PIXEL) { + float dx = x - center.x, dz = z - center.z; + if (dx * dx + dz * dz <= squaredRadius) { + dest[0] = red; + dest[1] = green; + dest[2] = blue; + } + } + lineDest += stride; + } + + HeightfieldDataPointer newPointer(new HeightfieldData(contents)); + info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(newPointer)); + return STOP_RECURSION; +} + +void PaintHeightfieldColorEdit::apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const { + PaintHeightfieldColorEditVisitor visitor(*this); + data.guide(visitor); +} + diff --git a/libraries/metavoxels/src/MetavoxelMessages.h b/libraries/metavoxels/src/MetavoxelMessages.h index 91d73c08a9..2fc8cbf030 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.h +++ b/libraries/metavoxels/src/MetavoxelMessages.h @@ -207,4 +207,38 @@ public: DECLARE_STREAMABLE_METATYPE(SetDataEdit) +/// An edit that sets a region of a heightfield height. +class PaintHeightfieldHeightEdit : public MetavoxelEdit { + STREAMABLE + +public: + + STREAM glm::vec3 position; + STREAM float radius; + STREAM float height; + + PaintHeightfieldHeightEdit(const glm::vec3& position = glm::vec3(), float radius = 0.0f, float height = 0.0f); + + virtual void apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const; +}; + +DECLARE_STREAMABLE_METATYPE(PaintHeightfieldHeightEdit) + +/// An edit that sets a region of a heightfield color. +class PaintHeightfieldColorEdit : public MetavoxelEdit { + STREAMABLE + +public: + + STREAM glm::vec3 position; + STREAM float radius; + STREAM QColor color; + + PaintHeightfieldColorEdit(const glm::vec3& position = glm::vec3(), float radius = 0.0f, const QColor& color = QColor()); + + virtual void apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const; +}; + +DECLARE_STREAMABLE_METATYPE(PaintHeightfieldColorEdit) + #endif // hifi_MetavoxelMessages_h diff --git a/libraries/metavoxels/src/MetavoxelUtil.h b/libraries/metavoxels/src/MetavoxelUtil.h index a2b0586708..339c07a21e 100644 --- a/libraries/metavoxels/src/MetavoxelUtil.h +++ b/libraries/metavoxels/src/MetavoxelUtil.h @@ -138,6 +138,8 @@ public: QColorEditor(QWidget* parent); + const QColor& getColor() const { return _color; } + signals: void colorChanged(const QColor& color); From e638bbca3a766718981fe3ea54d658e65e379232 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:10:58 -0700 Subject: [PATCH 61/94] fix find package standard args call for visage --- cmake/modules/FindVisage.cmake | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index d84bfbb69d..6c8d4f5b76 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -45,17 +45,15 @@ endif () include(FindPackageHandleStandardArgs) -set(VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR +set(VISAGE_ARGS_LIST "VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY") if (APPLE) list(APPEND VISAGE_ARGS_LIST QuartzCore) endif () -find_package_handle_standard_args(VISAGE DEFAULT_MSG - VISAGE_ARGS_LIST -) +find_package_handle_standard_args(VISAGE DEFAULT_MSG ${VISAGE_ARGS_LIST}) set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR}" "${VISAGE_OPENCV2_INCLUDE_DIR}" "${VISAGE_BASE_INCLUDE_DIR}") set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") @@ -64,8 +62,4 @@ if (APPLE) list(APPEND VISAGE_LIBRARIES ${QuartzCore}) endif () -mark_as_advanced( - VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES - VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY VISAGE_SEARCH_DIRS -) +mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES) From 768410ca0b1c8b5f8a6322a31990b0ef81c0e38a Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 8 Aug 2014 14:14:35 -0700 Subject: [PATCH 62/94] A couple comments, let right mouse button decrease height. --- interface/src/ui/MetavoxelEditor.cpp | 3 ++- libraries/metavoxels/src/MetavoxelMessages.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index bac8c56bc5..b6f5eb11b3 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1138,7 +1138,8 @@ HeightfieldHeightBrushTool::HeightfieldHeightBrushTool(MetavoxelEditor* editor) } QVariant HeightfieldHeightBrushTool::createEdit(bool alternate) { - return QVariant::fromValue(PaintHeightfieldHeightEdit(_position, _radius->value(), _height->value())); + return QVariant::fromValue(PaintHeightfieldHeightEdit(_position, _radius->value(), + alternate ? (-_height->value() : _height->value()))); } HeightfieldColorBrushTool::HeightfieldColorBrushTool(MetavoxelEditor* editor) : diff --git a/libraries/metavoxels/src/MetavoxelMessages.cpp b/libraries/metavoxels/src/MetavoxelMessages.cpp index dfd647fdb5..926d839991 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.cpp +++ b/libraries/metavoxels/src/MetavoxelMessages.cpp @@ -370,6 +370,7 @@ int PaintHeightfieldHeightEditVisitor::visit(MetavoxelInfo& info) { glm::vec3 start = glm::floor(center - extents); glm::vec3 end = glm::ceil(center + extents); + // raise/lower all points within the radius float z = qMax(start.z, 0.0f); float startX = qMax(start.x, 0.0f), endX = qMin(end.x, (float)highest); uchar* lineDest = (uchar*)contents.data() + (int)z * size + (int)startX; @@ -383,6 +384,7 @@ int PaintHeightfieldHeightEditVisitor::visit(MetavoxelInfo& info) { float dx = x - center.x, dz = z - center.z; float distanceSquared = dx * dx + dz * dz; if (distanceSquared <= squaredRadius) { + // height falls off towards edges int value = *dest + scaledHeight * (squaredRadius - distanceSquared) * squaredRadiusReciprocal; *dest = qMin(qMax(value, 0), EIGHT_BIT_MAXIMUM); } @@ -452,6 +454,7 @@ int PaintHeightfieldColorEditVisitor::visit(MetavoxelInfo& info) { glm::vec3 start = glm::floor(center - extents); glm::vec3 end = glm::ceil(center + extents); + // paint all points within the radius float z = qMax(start.z, 0.0f); float startX = qMax(start.x, 0.0f), endX = qMin(end.x, (float)highest); int stride = size * BYTES_PER_PIXEL; From 2f6ff36d2239dfafc14bfb069cd38ef9114126e8 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:17:36 -0700 Subject: [PATCH 63/94] fix list of args for visage find module --- cmake/modules/FindVisage.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 6c8d4f5b76..5c420fb0b5 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -45,9 +45,9 @@ endif () include(FindPackageHandleStandardArgs) -set(VISAGE_ARGS_LIST "VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR +list(APPEND VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY") + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) if (APPLE) list(APPEND VISAGE_ARGS_LIST QuartzCore) From 468a3d4d67d7c888db3e6926ff5169d95ac3e42c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 8 Aug 2014 14:18:32 -0700 Subject: [PATCH 64/94] Bump up the packet version. --- interface/src/ui/MetavoxelEditor.cpp | 2 +- libraries/networking/src/PacketHeaders.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index b6f5eb11b3..d35ed93f1b 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1139,7 +1139,7 @@ HeightfieldHeightBrushTool::HeightfieldHeightBrushTool(MetavoxelEditor* editor) QVariant HeightfieldHeightBrushTool::createEdit(bool alternate) { return QVariant::fromValue(PaintHeightfieldHeightEdit(_position, _radius->value(), - alternate ? (-_height->value() : _height->value()))); + alternate ? -_height->value() : _height->value())); } HeightfieldColorBrushTool::HeightfieldColorBrushTool(MetavoxelEditor* editor) : diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index f17715ddfe..1b48a2e333 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -80,6 +80,8 @@ PacketVersion versionForPacketType(PacketType type) { return 1; case PacketTypeAudioStreamStats: return 1; + case PacketTypeMetavoxelData: + return 1; default: return 0; } From 18256a657e812405da4b91f566eb0ffc6893abd3 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 8 Aug 2014 14:25:02 -0700 Subject: [PATCH 65/94] Removed unused uniform. --- interface/src/MetavoxelSystem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index f62a85025b..597542778a 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -558,7 +558,6 @@ void DefaultMetavoxelRendererImplementation::init() { _heightfieldCursorProgram.bind(); _heightfieldCursorProgram.setUniformValue("heightMap", 0); - _heightfieldCursorProgram.setUniformValue("cursorMap", 1); _cursorHeightScaleLocation = _heightfieldCursorProgram.uniformLocation("heightScale"); _heightfieldCursorProgram.release(); } From 36a3bc40d6d01988550dc4010b34376f83211aed Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:44:37 -0700 Subject: [PATCH 66/94] add AppKit to required Visage libraries --- cmake/modules/FindVisage.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 5c420fb0b5..e2e66ec993 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -32,6 +32,7 @@ if (APPLE) find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib HINTS ${VISAGE_SEARCH_DIRS}) + find_library(AppKit AppKit) find_library(QuartzCore QuartzCore) elseif (WIN32) find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS}) @@ -50,7 +51,7 @@ list(APPEND VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) if (APPLE) - list(APPEND VISAGE_ARGS_LIST QuartzCore) + list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit) endif () find_package_handle_standard_args(VISAGE DEFAULT_MSG ${VISAGE_ARGS_LIST}) @@ -59,7 +60,7 @@ set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") if (APPLE) - list(APPEND VISAGE_LIBRARIES ${QuartzCore}) + list(APPEND VISAGE_LIBRARIES ${QuartzCore} ${AppKit}) endif () mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES) From b09cc55d6f91b0511858201f133b2f5475c741c9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 15:01:47 -0700 Subject: [PATCH 67/94] add QTKit to frameworks required for Visage --- cmake/modules/FindVisage.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index e2e66ec993..f14f15515a 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -34,6 +34,7 @@ if (APPLE) find_library(AppKit AppKit) find_library(QuartzCore QuartzCore) + find_library(QTKit QTKit) elseif (WIN32) find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS}) find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h PATH_SUFFIXES dependencies/OpenCV/include HINTS ${VISAGE_SEARCH_DIRS}) @@ -51,7 +52,7 @@ list(APPEND VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) if (APPLE) - list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit) + list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit QTKit) endif () find_package_handle_standard_args(VISAGE DEFAULT_MSG ${VISAGE_ARGS_LIST}) @@ -60,7 +61,7 @@ set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") if (APPLE) - list(APPEND VISAGE_LIBRARIES ${QuartzCore} ${AppKit}) + list(APPEND VISAGE_LIBRARIES ${QuartzCore} ${AppKit} ${QTKit}) endif () mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES) From 481108ecd1f14db4d8dc71fc37a7021c64598493 Mon Sep 17 00:00:00 2001 From: Craig Hansen-Sturm Date: Sun, 10 Aug 2014 22:47:27 -0700 Subject: [PATCH 68/94] added support for biquad, parametric, and multi-band filter eq --- interface/src/Audio.cpp | 44 ++++- interface/src/Audio.h | 17 +- interface/src/Menu.cpp | 42 ++++ interface/src/Menu.h | 5 + libraries/audio/src/AudioFilter.cpp | 23 +++ libraries/audio/src/AudioFilter.h | 295 ++++++++++++++++++++++++++++ 6 files changed, 421 insertions(+), 5 deletions(-) create mode 100644 libraries/audio/src/AudioFilter.cpp create mode 100644 libraries/audio/src/AudioFilter.h diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 2cba22b630..0484860c65 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -56,7 +56,6 @@ static const int MUTE_ICON_SIZE = 24; static const int RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES = 100; - Audio::Audio(QObject* parent) : AbstractAudioInterface(parent), _audioInput(NULL), @@ -83,6 +82,7 @@ Audio::Audio(QObject* parent) : _noiseGateSampleCounter(0), _noiseGateOpen(false), _noiseGateEnabled(true), + _peqEnabled(false), _toneInjectionEnabled(false), _noiseGateFramesToClose(0), _totalInputAudioSamples(0), @@ -132,6 +132,7 @@ void Audio::init(QGLWidget *parent) { void Audio::reset() { _receivedAudioStream.reset(); resetStats(); + _peq.reset(); } void Audio::resetStats() { @@ -418,9 +419,15 @@ void Audio::start() { if (!outputFormatSupported) { qDebug() << "Unable to set up audio output because of a problem with output format."; } + + _peq.initialize( _inputFormat.sampleRate(), _audioInput->bufferSize() ); + } void Audio::stop() { + + _peq.finalize(); + // "switch" to invalid devices in order to shut down the state switchInputToAudioDevice(QAudioDeviceInfo()); switchOutputToAudioDevice(QAudioDeviceInfo()); @@ -462,7 +469,15 @@ void Audio::handleAudioInput() { int inputSamplesRequired = (int)((float)NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL * inputToNetworkInputRatio); QByteArray inputByteArray = _inputDevice->readAll(); - + + if (_peqEnabled && !_muted) { + // we wish to pre-filter our captured input, prior to loopback + + int16_t* ioBuffer = (int16_t*)inputByteArray.data(); + + _peq.render( ioBuffer, ioBuffer, inputByteArray.size() / sizeof(int16_t) ); + } + if (Menu::getInstance()->isOptionChecked(MenuOption::EchoLocalAudio) && !_muted && _audioOutput) { // if this person wants local loopback add that to the locally injected audio @@ -1172,6 +1187,31 @@ void Audio::renderToolBox(int x, int y, bool boxed) { glDisable(GL_TEXTURE_2D); } +void Audio::toggleAudioFilter() { + _peqEnabled = !_peqEnabled; +} + +void Audio::selectAudioFilterFlat() { + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioFilterFlat)) { + _peq.loadProfile(0); + } +} +void Audio::selectAudioFilterTrebleCut() { + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioFilterTrebleCut)) { + _peq.loadProfile(1); + } +} +void Audio::selectAudioFilterBassCut() { + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioFilterBassCut)) { + _peq.loadProfile(2); + } +} +void Audio::selectAudioFilterSmiley() { + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioFilterSmiley)) { + _peq.loadProfile(3); + } +} + void Audio::toggleScope() { _scopeEnabled = !_scopeEnabled; if (_scopeEnabled) { diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 8fae6f3bdd..4fb54218af 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -19,6 +19,7 @@ #include "AudioStreamStats.h" #include "RingBufferHistory.h" #include "MovingMinMaxAvg.h" +#include "AudioFilter.h" #include #include @@ -125,7 +126,12 @@ public slots: void selectAudioScopeFiveFrames(); void selectAudioScopeTwentyFrames(); void selectAudioScopeFiftyFrames(); - + void toggleAudioFilter(); + void selectAudioFilterFlat(); + void selectAudioFilterTrebleCut(); + void selectAudioFilterBassCut(); + void selectAudioFilterSmiley(); + virtual void handleAudioByteArray(const QByteArray& audioByteArray); void sendDownstreamAudioStatsPacket(); @@ -252,12 +258,12 @@ private: // Audio scope methods for rendering void renderBackground(const float* color, int x, int y, int width, int height); void renderGrid(const float* color, int x, int y, int width, int height, int rows, int cols); - void renderLineStrip(const float* color, int x, int y, int n, int offset, const QByteArray* byteArray); + void renderLineStrip(const float* color, int x, int y, int n, int offset, const QByteArray* byteArray); // audio stats methods for rendering void renderAudioStreamStats(const AudioStreamStats& streamStats, int horizontalOffset, int& verticalOffset, float scale, float rotation, int font, const float* color, bool isDownstreamStats = false); - + // Audio scope data static const unsigned int NETWORK_SAMPLES_PER_FRAME = NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL; static const unsigned int DEFAULT_FRAMES_PER_SCOPE = 5; @@ -270,6 +276,11 @@ private: int _scopeOutputOffset; int _framesPerScope; int _samplesPerScope; + + // Multi-band parametric EQ + bool _peqEnabled; + AudioFilterPEQ3 _peq; + QMutex _guard; QByteArray* _scopeInput; QByteArray* _scopeOutputLeft; diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 43d9fde01a..e6850aac6d 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -486,6 +486,48 @@ Menu::Menu() : true, appInstance->getAudio(), SLOT(toggleAudioNoiseReduction())); + + addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioFilter, + 0, + false, + appInstance->getAudio(), + SLOT(toggleAudioFilter())); + + QMenu* audioFilterMenu = audioDebugMenu->addMenu("Audio Filter Options"); + addDisabledActionAndSeparator(audioFilterMenu, "Filter Response"); + { + QAction *flat = addCheckableActionToQMenuAndActionHash(audioFilterMenu, MenuOption::AudioFilterFlat, + 0, + true, + appInstance->getAudio(), + SLOT(selectAudioFilterFlat())); + + QAction *trebleCut = addCheckableActionToQMenuAndActionHash(audioFilterMenu, MenuOption::AudioFilterTrebleCut, + 0, + false, + appInstance->getAudio(), + SLOT(selectAudioFilterTrebleCut())); + + QAction *bassCut = addCheckableActionToQMenuAndActionHash(audioFilterMenu, MenuOption::AudioFilterBassCut, + 0, + false, + appInstance->getAudio(), + SLOT(selectAudioFilterBassCut())); + + QAction *smiley = addCheckableActionToQMenuAndActionHash(audioFilterMenu, MenuOption::AudioFilterSmiley, + 0, + false, + appInstance->getAudio(), + SLOT(selectAudioFilterSmiley())); + + + QActionGroup* audioFilterGroup = new QActionGroup(audioFilterMenu); + audioFilterGroup->addAction(flat); + audioFilterGroup->addAction(trebleCut); + audioFilterGroup->addAction(bassCut); + audioFilterGroup->addAction(smiley); + } + addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoServerAudio); addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoLocalAudio); addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::StereoAudio, 0, false, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 3bef306bef..7ef744e62e 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -311,6 +311,11 @@ namespace MenuOption { const QString Animations = "Animations..."; const QString Atmosphere = "Atmosphere"; const QString Attachments = "Attachments..."; + const QString AudioFilter = "Audio Filter Bank"; + const QString AudioFilterFlat = "Flat Response"; + const QString AudioFilterTrebleCut= "Treble Cut"; + const QString AudioFilterBassCut = "Bass Cut"; + const QString AudioFilterSmiley = "Smiley Curve"; const QString AudioNoiseReduction = "Audio Noise Reduction"; const QString AudioScope = "Audio Scope"; const QString AudioScopeFiftyFrames = "Fifty"; diff --git a/libraries/audio/src/AudioFilter.cpp b/libraries/audio/src/AudioFilter.cpp new file mode 100644 index 0000000000..61e5e20171 --- /dev/null +++ b/libraries/audio/src/AudioFilter.cpp @@ -0,0 +1,23 @@ +// +// AudioFilter.cpp +// hifi +// +// Created by Craig Hansen-Sturm on 8/10/14. +// +// + +#include +#include +#include +#include "AudioRingBuffer.h" +#include "AudioFilter.h" + +template<> +AudioFilterPEQ3::FilterParameter AudioFilterPEQ3::_profiles[ AudioFilterPEQ3::_profileCount ][ AudioFilterPEQ3::_filterCount ] = { + + { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // flat response (default) + { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., .1, 1. } }, // treble cut + { { 300., .1, 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // bass cut + { { 300., 1.5, 0.71 }, { 1000., .5, 1. }, { 4000., 1.5, 0.71 } } // smiley curve +}; + diff --git a/libraries/audio/src/AudioFilter.h b/libraries/audio/src/AudioFilter.h new file mode 100644 index 0000000000..44dcd261d6 --- /dev/null +++ b/libraries/audio/src/AudioFilter.h @@ -0,0 +1,295 @@ +// +// AudioFilter.h +// hifi +// +// Created by Craig Hansen-Sturm on 8/9/14. +// +// + +#ifndef hifi_AudioFilter_h +#define hifi_AudioFilter_h + +//////////////////////////////////////////////////////////////////////////////////////////// +// Implements a standard biquad filter in "Direct Form 1" +// Reference http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt +// +class AudioBiquad { + + // + // private data + // + float _a0; // gain + float _a1; // feedforward 1 + float _a2; // feedforward 2 + float _b1; // feedback 1 + float _b2; // feedback 2 + + float _xm1; + float _xm2; + float _ym1; + float _ym2; + +public: + + // + // ctor/dtor + // + AudioBiquad() + : _xm1(0.) + , _xm2(0.) + , _ym1(0.) + , _ym2(0.) { + setParameters(0.,0.,0.,0.,0.); + } + + ~AudioBiquad() { + } + + // + // public interface + // + void setParameters( const float a0, const float a1, const float a2, const float b1, const float b2 ) { + _a0 = a0; _a1 = a1; _a2 = a2; _b1 = b1; _b2 = b2; + } + + void getParameters( float& a0, float& a1, float& a2, float& b1, float& b2 ) { + a0 = _a0; a1 = _a1; a2 = _a2; b1 = _b1; b2 = _b2; + } + + void render( const float* in, float* out, const int frames) { + + float x; + float y; + + for (int i = 0; i < frames; ++i) { + + x = *in++; + + // biquad + y = (_a0 * x) + + (_a1 * _xm1) + + (_a2 * _xm2) + - (_b1 * _ym1) + - (_b2 * _ym2); + + // update delay line + _xm2 = _xm1; + _xm1 = x; + _ym2 = _ym1; + _ym1 = y; + + *out++ = y; + } + } + + void reset() { + _xm1 = _xm2 = _ym1 = _ym2 = 0.; + } +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +// Implements a single-band parametric EQ using a biquad "peaking EQ" configuration +// +// gain > 1.0 boosts the center frequency +// gain < 1.0 cuts the center frequency +// +class AudioParametricEQ { + + // + // private data + // + AudioBiquad _kernel; + float _sampleRate; + float _frequency; + float _gain; + float _slope; + + // helpers + void updateKernel() { + + /* + a0 = 1 + alpha*A + a1 = -2*cos(w0) + a2 = 1 - alpha*A + b1 = -2*cos(w0) + b2 = 1 - alpha/A + */ + + const float a = _gain; + const float omega = TWO_PI * _frequency / _sampleRate; + const float alpha = 0.5 * sinf(omega) / _slope; + const float gamma = 1.0 / ( 1.0 + (alpha/a) ); + + const float a0 = 1.0 + (alpha*a); + const float a1 = -2.0 * cosf(omega); + const float a2 = 1.0 - (alpha*a); + const float b1 = a1; + const float b2 = 1.0 - (alpha/a); + + _kernel.setParameters( a0*gamma,a1*gamma,a2*gamma,b1*gamma,b2*gamma ); + } + +public: + // + // ctor/dtor + // + AudioParametricEQ() { + + setParameters(0.,0.,0.,0.); + updateKernel(); + } + + ~AudioParametricEQ() { + } + + // + // public interface + // + void setParameters( const float sampleRate, const float frequency, const float gain, const float slope ) { + + _sampleRate = std::max(sampleRate,1.0f); + _frequency = std::max(frequency,2.0f); + _gain = std::max(gain,0.0f); + _slope = std::max(slope,0.00001f); + + updateKernel(); + } + + void getParameters( float& sampleRate, float& frequency, float& gain, float& slope ) { + sampleRate = _sampleRate; frequency = _frequency; gain = _gain; slope = _slope; + } + + void render(const float* in, float* out, const int frames ) { + _kernel.render(in,out,frames); + } + + void reset() { + _kernel.reset(); + } +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +// Helper/convenience class that implements a bank of EQ objects +// +template< typename T, const int N> +class AudioFilterBank { + + // + // types + // + struct FilterParameter { + float _p1; + float _p2; + float _p3; + }; + + // + // private static data + // + static const int _filterCount = N; + static const int _profileCount = 4; + + static FilterParameter _profiles[_profileCount][_filterCount]; + + // + // private data + // + T _filters[ _filterCount ]; + float* _buffer; + float _sampleRate; + uint16_t _frameCount; + +public: + + // + // ctor/dtor + // + AudioFilterBank() + : _buffer(NULL) + , _sampleRate(0.) + , _frameCount(0) { + } + + ~AudioFilterBank() { + finalize(); + } + + // + // public interface + // + void initialize( const float sampleRate, const int frameCount ) { + finalize(); + + _buffer = (float*)malloc( frameCount * sizeof(float) ); + if(!_buffer) { + return; + } + + _sampleRate = sampleRate; + _frameCount = frameCount; + + reset(); + loadProfile(0); // load default profile "flat response" into the bank (see AudioFilter.cpp) + } + + void finalize() { + if (_buffer ) { + free (_buffer); + _buffer = NULL; + } + } + + void loadProfile( int profileIndex ) { + if (profileIndex >= 0 && profileIndex < _profileCount) { + + for (int i = 0; i < _filterCount; ++i) { + FilterParameter p = _profiles[profileIndex][i]; + + _filters[i].setParameters(_sampleRate,p._p1,p._p2,p._p3); + } + } + } + + void render( const float* in, float* out, const int frameCount ) { + for (int i = 0; i < _filterCount; ++i) { + _filters[i].render( in, out, frameCount ); + } + } + + void render( const int16_t* in, int16_t* out, const int frameCount ) { + if( !_buffer || ( frameCount > _frameCount ) ) + return; + + const int scale = (2 << ((8*sizeof(int16_t))-1)); + + // convert int16_t to float32 (normalized to -1. ... 1.) + for (int i = 0; i < frameCount; ++i) { + _buffer[i] = ((float)(*in++)) / scale; + } + // for this filter, we share input/output buffers at each stage, but our design does not mandate this + render( _buffer, _buffer, frameCount ); + + // convert float32 to int16_t + for (int i = 0; i < frameCount; ++i) { + *out++ = (int16_t)(_buffer[i] * scale); + } + } + + void reset() { + for (int i = 0; i < _filterCount; ++i ) { + _filters[i].reset(); + } + } + +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +// Specializations of AudioFilterBank +// +typedef AudioFilterBank< AudioParametricEQ, 1> AudioFilterPEQ1; // bank with one band of PEQ +typedef AudioFilterBank< AudioParametricEQ, 2> AudioFilterPEQ2; // bank with two bands of PEQ +typedef AudioFilterBank< AudioParametricEQ, 3> AudioFilterPEQ3; // bank with three bands of PEQ +// etc.... + + +#endif // hifi_AudioFilter_h From 405e79fe6d7f329e71875e9a8ecfbe2972ebbc76 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 11 Aug 2014 09:51:36 -0700 Subject: [PATCH 69/94] allow command line specification that an external be required --- cmake/modules/FindFaceplus.cmake | 2 +- cmake/modules/FindFaceshift.cmake | 2 +- cmake/modules/FindLeapMotion.cmake | 2 +- cmake/modules/FindLibOVR.cmake | 24 ++++++------ cmake/modules/FindPrioVR.cmake | 2 +- cmake/modules/FindQxmpp.cmake | 2 +- cmake/modules/FindRtMidi.cmake | 2 +- cmake/modules/FindSixense.cmake | 2 +- cmake/modules/FindVisage.cmake | 2 +- interface/CMakeLists.txt | 39 +++++++------------ .../external/{oculus => libovr}/readme.txt | 0 11 files changed, 35 insertions(+), 44 deletions(-) rename interface/external/{oculus => libovr}/readme.txt (100%) diff --git a/cmake/modules/FindFaceplus.cmake b/cmake/modules/FindFaceplus.cmake index 1050493c69..e97fce3edb 100644 --- a/cmake/modules/FindFaceplus.cmake +++ b/cmake/modules/FindFaceplus.cmake @@ -19,6 +19,6 @@ if (WIN32) endif (WIN32) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FACEPLUS DEFAULT_MSG FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES) +find_package_handle_standard_args(Faceplus DEFAULT_MSG FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES) mark_as_advanced(FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindFaceshift.cmake b/cmake/modules/FindFaceshift.cmake index 2641475fa3..0dcbcbb7dd 100644 --- a/cmake/modules/FindFaceshift.cmake +++ b/cmake/modules/FindFaceshift.cmake @@ -40,6 +40,6 @@ select_library_configurations(FACESHIFT) set(FACESHIFT_LIBRARIES ${FACESHIFT_LIBRARY}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FACESHIFT DEFAULT_MSG FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES) +find_package_handle_standard_args(Faceshift DEFAULT_MSG FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES) mark_as_advanced(FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES FACESHIFT_SEARCH_DIRS) \ No newline at end of file diff --git a/cmake/modules/FindLeapMotion.cmake b/cmake/modules/FindLeapMotion.cmake index a64fc22e48..cb49ceb597 100644 --- a/cmake/modules/FindLeapMotion.cmake +++ b/cmake/modules/FindLeapMotion.cmake @@ -30,6 +30,6 @@ select_library_configurations(LEAPMOTION) set(LEAPMOTION_LIBRARIES "${LEAPMOTION_LIBRARY}") include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LEAPMOTION DEFAULT_MSG LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) +find_package_handle_standard_args(LeapMotion DEFAULT_MSG LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) mark_as_advanced(LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES LEAPMOTION_SEARCH_DIRS) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index 505fd90b51..e1fce969e5 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -19,16 +19,16 @@ # include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") -hifi_library_search_hints("oculus") +hifi_library_search_hints("libovr") -find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${OCULUS_SEARCH_DIRS}) -find_path(LIBOVR_SRC_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${OCULUS_SEARCH_DIRS}) +find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${LIBOVR_SEARCH_DIRS}) +find_path(LIBOVR_SRC_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${LIBOVR_SEARCH_DIRS}) include(SelectLibraryConfigurations) if (APPLE) - find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/MacOS/Debug HINTS ${OCULUS_SEARCH_DIRS}) - find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/MacOS/Release HINTS ${OCULUS_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/MacOS/Debug HINTS ${LIBOVR_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/MacOS/Release HINTS ${LIBOVR_SEARCH_DIRS}) find_library(ApplicationServices ApplicationServices) find_library(IOKit IOKit) elseif (UNIX) @@ -41,15 +41,15 @@ elseif (UNIX) set(LINUX_ARCH_DIR "x86_64") endif() - find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Linux/Debug/${LINUX_ARCH_DIR} HINTS ${OCULUS_SEARCH_DIRS}) - find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Linux/Release/${LINUX_ARCH_DIR} HINTS ${OCULUS_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Linux/Debug/${LINUX_ARCH_DIR} HINTS ${LIBOVR_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Linux/Release/${LINUX_ARCH_DIR} HINTS ${LIBOVR_SEARCH_DIRS}) select_library_configurations(UDEV) select_library_configurations(XINERAMA) elseif (WIN32) - find_library(LIBOVR_LIBRARY_DEBUG NAMES libovrd PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${OCULUS_SEARCH_DIRS}) - find_library(LIBOVR_LIBRARY_RELEASE NAMES libovr PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${OCULUS_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_DEBUG NAMES libovrd PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${LIBOVR_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_RELEASE NAMES libovr PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${LIBOVR_SEARCH_DIRS}) endif () select_library_configurations(LIBOVR) @@ -63,11 +63,11 @@ endif () include(FindPackageHandleStandardArgs) if (APPLE) - find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES IOKit ApplicationServices) + find_package_handle_standard_args(LibOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES IOKit ApplicationServices) elseif (UNIX) - find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY) + find_package_handle_standard_args(LibOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY) else () - find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES) + find_package_handle_standard_args(LibOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES) endif () mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES OCULUS_SEARCH_DIRS) diff --git a/cmake/modules/FindPrioVR.cmake b/cmake/modules/FindPrioVR.cmake index af2c0aca52..691ba85689 100644 --- a/cmake/modules/FindPrioVR.cmake +++ b/cmake/modules/FindPrioVR.cmake @@ -19,6 +19,6 @@ if (WIN32) endif (WIN32) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(PRIOVR DEFAULT_MSG PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) +find_package_handle_standard_args(PrioVR DEFAULT_MSG PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) mark_as_advanced(PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindQxmpp.cmake b/cmake/modules/FindQxmpp.cmake index 3c0e97c998..8d8c0e22a2 100644 --- a/cmake/modules/FindQxmpp.cmake +++ b/cmake/modules/FindQxmpp.cmake @@ -34,6 +34,6 @@ select_library_configurations(QXMPP) set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}" Qt5::Xml) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) +find_package_handle_standard_args(QXmpp DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) mark_as_advanced(QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES QXMPP_SEARCH_DIRS) \ No newline at end of file diff --git a/cmake/modules/FindRtMidi.cmake b/cmake/modules/FindRtMidi.cmake index 93f1cc69cc..3b57c76f25 100644 --- a/cmake/modules/FindRtMidi.cmake +++ b/cmake/modules/FindRtMidi.cmake @@ -25,6 +25,6 @@ find_path(RTMIDI_INCLUDE_DIRS RtMidi.h PATH_SUFFIXES include HINTS ${RTMIDI_SEAR find_library(RTMIDI_LIBRARIES NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEARCH_DIRS}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(RTMIDI DEFAULT_MSG RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES) +find_package_handle_standard_args(RtMidi DEFAULT_MSG RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES) mark_as_advanced(RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES RTMIDI_SEARCH_DIRS) \ No newline at end of file diff --git a/cmake/modules/FindSixense.cmake b/cmake/modules/FindSixense.cmake index a24131698b..f772c42e41 100644 --- a/cmake/modules/FindSixense.cmake +++ b/cmake/modules/FindSixense.cmake @@ -40,6 +40,6 @@ select_library_configurations(SIXENSE) set(SIXENSE_LIBRARIES "${SIXENSE_LIBRARY}") include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SIXENSE DEFAULT_MSG SIXENSE_INCLUDE_DIRS SIXENSE_LIBRARIES) +find_package_handle_standard_args(Sixense DEFAULT_MSG SIXENSE_INCLUDE_DIRS SIXENSE_LIBRARIES) mark_as_advanced(SIXENSE_LIBRARIES SIXENSE_INCLUDE_DIRS SIXENSE_SEARCH_DIRS) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index f14f15515a..96176a2648 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -55,7 +55,7 @@ if (APPLE) list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit QTKit) endif () -find_package_handle_standard_args(VISAGE DEFAULT_MSG ${VISAGE_ARGS_LIST}) +find_package_handle_standard_args(Visage DEFAULT_MSG ${VISAGE_ARGS_LIST}) set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR}" "${VISAGE_OPENCV2_INCLUDE_DIR}" "${VISAGE_BASE_INCLUDE_DIR}") set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 82b102adf3..44b8a88d6d 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -2,11 +2,13 @@ set(TARGET_NAME interface) project(${TARGET_NAME}) # set a default root dir for each of our optional externals if it was not passed -set(OPTIONAL_EXTERNALS "faceplus" "faceshift" "oculus" "priovr" "sixense" "visage" "leapmotion" "rtmidi" "qxmpp") +set(OPTIONAL_EXTERNALS "Faceplus" "Faceshift" "LibOVR" "PrioVR" "Sixense" "Visage" "LeapMotion" "RtMidi" "Qxmpp") foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) - string(TOUPPER ${EXTERNAL} UPPER_EXTERNAL) - if (NOT ${UPPER_EXTERNAL}_ROOT_DIR) - set(${UPPER_EXTERNAL}_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/${EXTERNAL}") + string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE) + if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR) + string(TOLOWER ${EXTERNAL} ${EXTERNAL}_LOWERCASE) + set(${${EXTERNAL}_UPPERCASE}_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/${${EXTERNAL}_LOWERCASE}") + message("Dir for ${EXTERNAL} is ${${${EXTERNAL}_UPPERCASE}_ROOT_DIR}") endif () endforeach() @@ -94,43 +96,32 @@ add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) link_hifi_libraries(shared octree voxels fbx metavoxels networking particles models avatars audio animation script-engine) # find any optional and required libraries -find_package(Faceplus) -find_package(Faceshift) -find_package(LibOVR) -find_package(PrioVR) -find_package(SDL) -find_package(Sixense) -find_package(Visage) -find_package(LeapMotion) -find_package(Qxmpp) -find_package(RtMidi) - find_package(ZLIB REQUIRED) find_package(OpenSSL REQUIRED) # perform standard include and linking for found externals foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) - string(TOUPPER ${EXTERNAL} UPPER_EXTERNAL) - if (${UPPER_EXTERNAL} MATCHES "OCULUS") - # the oculus directory is named OCULUS and not LIBOVR so hack to fix that here - set(UPPER_EXTERNAL "LIBOVR") + if (${${EXTERNAL}_UPPERCASE}_REQUIRED) + find_package(${EXTERNAL} REQUIRED) + else () + find_package(${EXTERNAL}) endif () - if (${UPPER_EXTERNAL}_FOUND AND NOT DISABLE_${UPPER_EXTERNAL}) - add_definitions(-DHAVE_${UPPER_EXTERNAL}) + if (${${EXTERNAL}_UPPERCASE}_FOUND AND NOT DISABLE_${${EXTERNAL}_UPPERCASE}) + add_definitions(-DHAVE_${${EXTERNAL}_UPPERCASE}) # include the library directories (ignoring warnings) - include_directories(SYSTEM ${${UPPER_EXTERNAL}_INCLUDE_DIRS}) + include_directories(SYSTEM ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS}) # perform the system include hack for OS X to ignore warnings if (APPLE) - foreach(EXTERNAL_INCLUDE_DIR ${${UPPER_EXTERNAL}_INCLUDE_DIRS}) + foreach(EXTERNAL_INCLUDE_DIR ${${${EXTERNAL}_UPPERCASE}_INCLUDE_DIRS}) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${EXTERNAL_INCLUDE_DIR}") endforeach() endif () - target_link_libraries(${TARGET_NAME} ${${UPPER_EXTERNAL}_LIBRARIES}) + target_link_libraries(${TARGET_NAME} ${${${EXTERNAL}_UPPERCASE}_LIBRARIES}) endif () endforeach() diff --git a/interface/external/oculus/readme.txt b/interface/external/libovr/readme.txt similarity index 100% rename from interface/external/oculus/readme.txt rename to interface/external/libovr/readme.txt From 2469d958d6b750ed5ddf02780bb6f94aee815cf8 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 11 Aug 2014 09:57:13 -0700 Subject: [PATCH 70/94] include CoreFoundation for Audio.cpp defaultAudioDeviceForMode --- interface/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 82b102adf3..d705464479 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -172,10 +172,11 @@ add_definitions(-DQT_NO_BEARERMANAGEMENT) if (APPLE) # link in required OS X frameworks and include the right GL headers find_library(CoreAudio CoreAudio) + find_library(CoreFoundation CoreFoundation) find_library(GLUT GLUT) find_library(OpenGL OpenGL) - target_link_libraries(${TARGET_NAME} ${CoreAudio} ${GLUT} ${OpenGL}) + target_link_libraries(${TARGET_NAME} ${CoreFoundation} ${CoreAudio} ${GLUT} ${OpenGL}) # install command for OS X bundle INSTALL(TARGETS ${TARGET_NAME} From cadfaab770d894759f410862cd7f03f6c87a1ceb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 11 Aug 2014 09:58:21 -0700 Subject: [PATCH 71/94] fix order now that I know my ABCs --- interface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index d705464479..ce8400a413 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -176,7 +176,7 @@ if (APPLE) find_library(GLUT GLUT) find_library(OpenGL OpenGL) - target_link_libraries(${TARGET_NAME} ${CoreFoundation} ${CoreAudio} ${GLUT} ${OpenGL}) + target_link_libraries(${TARGET_NAME} ${CoreAudio} ${CoreFoundation} ${GLUT} ${OpenGL}) # install command for OS X bundle INSTALL(TARGETS ${TARGET_NAME} From 3d95f28fb9a1efbbed78087372f0c65eeb576f9f Mon Sep 17 00:00:00 2001 From: Craig Hansen-Sturm Date: Mon, 11 Aug 2014 11:51:49 -0700 Subject: [PATCH 72/94] added apache licensing/removed implicit double<->float conversions/addressed style guide issues --- libraries/audio/src/AudioFilter.cpp | 13 ++++++++----- libraries/audio/src/AudioFilter.h | 17 ++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/libraries/audio/src/AudioFilter.cpp b/libraries/audio/src/AudioFilter.cpp index 61e5e20171..28e7716578 100644 --- a/libraries/audio/src/AudioFilter.cpp +++ b/libraries/audio/src/AudioFilter.cpp @@ -3,7 +3,10 @@ // hifi // // Created by Craig Hansen-Sturm on 8/10/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -15,9 +18,9 @@ template<> AudioFilterPEQ3::FilterParameter AudioFilterPEQ3::_profiles[ AudioFilterPEQ3::_profileCount ][ AudioFilterPEQ3::_filterCount ] = { - { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // flat response (default) - { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., .1, 1. } }, // treble cut - { { 300., .1, 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // bass cut - { { 300., 1.5, 0.71 }, { 1000., .5, 1. }, { 4000., 1.5, 0.71 } } // smiley curve + // Freq Gain Q Freq Gain Q Freq Gain Q + { { 300.0f, 1.0f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 1.0f, 1.0f } }, // flat response (default) + { { 300.0f, 1.0f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 0.1f, 1.0f } }, // treble cut + { { 300.0f, 0.1f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 1.0f, 1.0f } }, // bass cut + { { 300.0f, 1.5f, 0.71f }, { 1000.0f, 0.5f, 1.0f }, { 4000.0f, 1.50f, 0.71f } } // smiley curve }; - diff --git a/libraries/audio/src/AudioFilter.h b/libraries/audio/src/AudioFilter.h index 44dcd261d6..0f3ec06f64 100644 --- a/libraries/audio/src/AudioFilter.h +++ b/libraries/audio/src/AudioFilter.h @@ -3,7 +3,10 @@ // hifi // // Created by Craig Hansen-Sturm on 8/9/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_AudioFilter_h @@ -117,14 +120,14 @@ class AudioParametricEQ { const float a = _gain; const float omega = TWO_PI * _frequency / _sampleRate; - const float alpha = 0.5 * sinf(omega) / _slope; - const float gamma = 1.0 / ( 1.0 + (alpha/a) ); + const float alpha = 0.5f * sinf(omega) / _slope; + const float gamma = 1.0f / ( 1.0f + (alpha/a) ); - const float a0 = 1.0 + (alpha*a); - const float a1 = -2.0 * cosf(omega); - const float a2 = 1.0 - (alpha*a); + const float a0 = 1.0f + (alpha*a); + const float a1 = -2.0f * cosf(omega); + const float a2 = 1.0f - (alpha*a); const float b1 = a1; - const float b2 = 1.0 - (alpha/a); + const float b2 = 1.0f - (alpha/a); _kernel.setParameters( a0*gamma,a1*gamma,a2*gamma,b1*gamma,b2*gamma ); } @@ -257,7 +260,7 @@ public: } void render( const int16_t* in, int16_t* out, const int frameCount ) { - if( !_buffer || ( frameCount > _frameCount ) ) + if (!_buffer || ( frameCount > _frameCount )) return; const int scale = (2 << ((8*sizeof(int16_t))-1)); From 4ff7ff61e8c8e2379224cc1eb3eeaf63826636b8 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Tue, 12 Aug 2014 13:25:22 +0200 Subject: [PATCH 73/94] OSX compatibility with SDK 0.4.1 --- interface/src/devices/OculusManager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index ab30ee7c8b..96df5b6c7c 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -66,7 +66,7 @@ void OculusManager::connect() { UserActivityLogger::getInstance().connectedDevice("hmd", "oculus"); } _isConnected = true; -#ifdef _WIN32 +#if defined(__APPLE__) || defined(_WIN32) _eyeFov[0] = _ovrHmd->DefaultEyeFov[0]; _eyeFov[1] = _ovrHmd->DefaultEyeFov[1]; #else @@ -88,13 +88,13 @@ void OculusManager::connect() { _eyeRenderDesc[0] = ovrHmd_GetRenderDesc(_ovrHmd, ovrEye_Left, _eyeFov[0]); _eyeRenderDesc[1] = ovrHmd_GetRenderDesc(_ovrHmd, ovrEye_Right, _eyeFov[1]); -#ifdef _WIN32 +#if defined(__APPLE__) || defined(_WIN32) ovrHmd_SetEnabledCaps(_ovrHmd, ovrHmdCap_LowPersistence); #else ovrHmd_SetEnabledCaps(_ovrHmd, ovrHmdCap_LowPersistence | ovrHmdCap_LatencyTest); #endif -#ifdef _WIN32 +#if defined(__APPLE__) || defined(_WIN32) ovrHmd_ConfigureTracking(_ovrHmd, ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, ovrTrackingCap_Orientation); @@ -195,7 +195,7 @@ void OculusManager::generateDistortionMesh() { DistortionVertex* v = pVBVerts; ovrDistortionVertex* ov = meshData.pVertexData; for (unsigned int vertNum = 0; vertNum < meshData.VertexCount; vertNum++) { -#ifdef _WIN32 +#if defined(__APPLE__) || defined(_WIN32) v->pos.x = ov->ScreenPosNDC.x; v->pos.y = ov->ScreenPosNDC.y; v->texR.x = ov->TanEyeAnglesR.x; @@ -317,7 +317,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p //Render each eye into an fbo for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++) { -#ifdef _WIN32 +#if defined(__APPLE__) || defined(_WIN32) ovrEyeType eye = _ovrHmd->EyeRenderOrder[eyeIndex]; #else ovrEyeType eye = _ovrHmdDesc.EyeRenderOrder[eyeIndex]; @@ -458,18 +458,18 @@ void OculusManager::reset() { //Gets the current predicted angles from the oculus sensors void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) { #ifdef HAVE_LIBOVR -#ifdef _WIN32 +#if defined(__APPLE__) || defined(_WIN32) ovrTrackingState ts = ovrHmd_GetTrackingState(_ovrHmd, ovr_GetTimeInSeconds()); #else ovrSensorState ss = ovrHmd_GetSensorState(_ovrHmd, _hmdFrameTiming.ScanoutMidpointSeconds); #endif -#ifdef _WIN32 +#if defined(__APPLE__) || defined(_WIN32) if (ts.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) { #else if (ss.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) { #endif -#ifdef _WIN32 +#if defined(__APPLE__) || defined(_WIN32) ovrPosef pose = ts.CameraPose; #else ovrPosef pose = ss.Predicted.Pose; From 446c88824285e045da519a4b8c4424aeb8ce4ccf Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 12:22:32 -0700 Subject: [PATCH 74/94] AudioMixer print added; untested --- assignment-client/src/audio/AudioMixer.cpp | 11 ++++- assignment-client/src/audio/AudioMixer.h | 2 + .../src/audio/AudioMixerClientData.cpp | 45 ++++++++++++++++++- .../src/audio/AudioMixerClientData.h | 5 +++ .../resources/web/settings/describe.json | 6 +++ 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 5900e1f151..fb1f3333a4 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -71,6 +71,8 @@ bool AudioMixer::_useDynamicJitterBuffers = false; int AudioMixer::_staticDesiredJitterBufferFrames = 0; int AudioMixer::_maxFramesOverDesired = 0; +bool AudioMixer::_printStreamStats = false; + AudioMixer::AudioMixer(const QByteArray& packet) : ThreadedAssignment(packet), _trailingSleepRatio(1.0f), @@ -448,7 +450,11 @@ void AudioMixer::run() { } qDebug() << "Max frames over desired:" << _maxFramesOverDesired; - + const QString PRINT_STREAM_STATS_JSON_KEY = "H-print-stream-stats"; + _printStreamStats = audioGroupObject[PRINT_STREAM_STATS_JSON_KEY].toBool(); + if (_printStreamStats) { + qDebug() << "Stream stats will be printed to stdout"; + } const QString UNATTENUATED_ZONE_KEY = "D-unattenuated-zone"; @@ -581,6 +587,9 @@ void AudioMixer::run() { // send an audio stream stats packet if it's time if (sendAudioStreamStats) { nodeData->sendAudioStreamStatsPackets(node); + + printf("\nStats for agent %s\n:", node->getUUID().toString().toLatin1().data()); + nodeData->printUpstreamDownstreamStats(); } ++_sumListeners; diff --git a/assignment-client/src/audio/AudioMixer.h b/assignment-client/src/audio/AudioMixer.h index 83769a4209..d11539e22e 100644 --- a/assignment-client/src/audio/AudioMixer.h +++ b/assignment-client/src/audio/AudioMixer.h @@ -66,6 +66,8 @@ private: static int _staticDesiredJitterBufferFrames; static int _maxFramesOverDesired; + static bool _printStreamStats; + quint64 _lastSendAudioStreamStatsTime; }; diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index fb805e11d8..ade34e2dae 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -22,7 +22,8 @@ AudioMixerClientData::AudioMixerClientData() : _audioStreams(), - _outgoingMixedAudioSequenceNumber(0) + _outgoingMixedAudioSequenceNumber(0), + _downstreamAudioStreamStats() { } @@ -263,3 +264,45 @@ QString AudioMixerClientData::getAudioStreamStatsString() const { } return result; } + +void AudioMixerClientData::printUpstreamDownstreamStats() const { + // print the upstream (mic stream) stats if the mic stream exists + if (_audioStreams.contains(QUuid())) { + printf(" Upstream:\n"); + printAudioStreamStats(_audioStreams.value(QUuid())->getAudioStreamStats()); + } + // print the downstream stats if they contain valid info + if (_downstreamAudioStreamStats._packetStreamStats._received > 0) { + printf(" Downstream:\n"); + printAudioStreamStats(_downstreamAudioStreamStats); + } +} + +void AudioMixerClientData::printAudioStreamStats(const AudioStreamStats& streamStats) const { + printf(" Packet loss | overall: %5.2f%% (%d lost), last_30s: %5.2f%% (%d lost)", + streamStats._packetStreamStats.getLostRate() * 100.0f, + streamStats._packetStreamStats._lost, + streamStats._packetStreamWindowStats.getLostRate() * 100.0f, + streamStats._packetStreamWindowStats._lost); + + printf(" Ringbuffer frames | desired: %u, avg_available(10s): %u, available: %u", + streamStats._desiredJitterBufferFrames, + streamStats._framesAvailableAverage, + streamStats._framesAvailable); + + printf(" Ringbuffer stats | starves: %u, prev_starve_lasted: %u, frames_dropped: %u, overflows: %u", + streamStats._starveCount, + streamStats._consecutiveNotMixedCount, + streamStats._framesDropped, + streamStats._overflowCount); + + printf(" Inter-packet timegaps (overall) | min: %9s, max: %9s, avg: %9s", + formatUsecTime(streamStats._timeGapMin).toLatin1().data(), + formatUsecTime(streamStats._timeGapMax).toLatin1().data(), + formatUsecTime(streamStats._timeGapAverage).toLatin1().data()); + + printf(" Inter-packet timegaps (last 30s) | min: %9s, max: %9s, avg: %9s", + formatUsecTime(streamStats._timeGapWindowMin).toLatin1().data(), + formatUsecTime(streamStats._timeGapWindowMax).toLatin1().data(), + formatUsecTime(streamStats._timeGapWindowAverage).toLatin1().data()); +} diff --git a/assignment-client/src/audio/AudioMixerClientData.h b/assignment-client/src/audio/AudioMixerClientData.h index 80f3f9e3ca..0ce4ecc36a 100644 --- a/assignment-client/src/audio/AudioMixerClientData.h +++ b/assignment-client/src/audio/AudioMixerClientData.h @@ -38,6 +38,11 @@ public: void incrementOutgoingMixedAudioSequenceNumber() { _outgoingMixedAudioSequenceNumber++; } quint16 getOutgoingSequenceNumber() const { return _outgoingMixedAudioSequenceNumber; } + void printUpstreamDownstreamStats() const; + +private: + void printAudioStreamStats(const AudioStreamStats& streamStats) const; + private: QHash _audioStreams; // mic stream stored under key of null UUID diff --git a/domain-server/resources/web/settings/describe.json b/domain-server/resources/web/settings/describe.json index f4920a7b50..788a3ad551 100644 --- a/domain-server/resources/web/settings/describe.json +++ b/domain-server/resources/web/settings/describe.json @@ -21,6 +21,12 @@ "placeholder": "10", "default": "10" }, + "H-print-stream-stats": { + "type": "checkbox", + "label": "Print Stream Stats:", + "help": "If enabled, audio upstream and downstream stats of each agent will be printed each second to stdout", + "default": false + }, "D-unattenuated-zone": { "label": "Unattenuated Zone", "help": "Boxes for source and listener (corner x, corner y, corner z, size x, size y, size z, corner x, corner y, corner z, size x, size y, size z)", From 0007104b6a1f11709d26b48483fb70af9f866ed9 Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 12:58:30 -0700 Subject: [PATCH 75/94] stats working --- assignment-client/src/audio/AudioMixer.cpp | 13 ++++++++++--- .../src/audio/AudioMixerClientData.cpp | 14 +++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index fb1f3333a4..914d5ae63b 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -553,6 +553,7 @@ void AudioMixer::run() { sendAudioStreamStats = true; } + bool streamStatsPrinted = false; foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getLinkedData()) { AudioMixerClientData* nodeData = (AudioMixerClientData*)node->getLinkedData(); @@ -587,15 +588,21 @@ void AudioMixer::run() { // send an audio stream stats packet if it's time if (sendAudioStreamStats) { nodeData->sendAudioStreamStatsPackets(node); - - printf("\nStats for agent %s\n:", node->getUUID().toString().toLatin1().data()); - nodeData->printUpstreamDownstreamStats(); + + if (_printStreamStats) { + printf("\nStats for agent %s:\n", node->getUUID().toString().toLatin1().data()); + nodeData->printUpstreamDownstreamStats(); + streamStatsPrinted = true; + } } ++_sumListeners; } } } + if (streamStatsPrinted) { + printf("\n----------------------------------------------------------------\n"); + } ++_numStatFrames; diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index ade34e2dae..9a8a85c3d1 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -268,40 +268,40 @@ QString AudioMixerClientData::getAudioStreamStatsString() const { void AudioMixerClientData::printUpstreamDownstreamStats() const { // print the upstream (mic stream) stats if the mic stream exists if (_audioStreams.contains(QUuid())) { - printf(" Upstream:\n"); + printf("Upstream:\n"); printAudioStreamStats(_audioStreams.value(QUuid())->getAudioStreamStats()); } // print the downstream stats if they contain valid info if (_downstreamAudioStreamStats._packetStreamStats._received > 0) { - printf(" Downstream:\n"); + printf("Downstream:\n"); printAudioStreamStats(_downstreamAudioStreamStats); } } void AudioMixerClientData::printAudioStreamStats(const AudioStreamStats& streamStats) const { - printf(" Packet loss | overall: %5.2f%% (%d lost), last_30s: %5.2f%% (%d lost)", + printf(" Packet loss | overall: %5.2f%% (%d lost), last_30s: %5.2f%% (%d lost)\n", streamStats._packetStreamStats.getLostRate() * 100.0f, streamStats._packetStreamStats._lost, streamStats._packetStreamWindowStats.getLostRate() * 100.0f, streamStats._packetStreamWindowStats._lost); - printf(" Ringbuffer frames | desired: %u, avg_available(10s): %u, available: %u", + printf(" Ringbuffer frames | desired: %u, avg_available(10s): %u, available: %u\n", streamStats._desiredJitterBufferFrames, streamStats._framesAvailableAverage, streamStats._framesAvailable); - printf(" Ringbuffer stats | starves: %u, prev_starve_lasted: %u, frames_dropped: %u, overflows: %u", + printf(" Ringbuffer stats | starves: %u, prev_starve_lasted: %u, frames_dropped: %u, overflows: %u\n", streamStats._starveCount, streamStats._consecutiveNotMixedCount, streamStats._framesDropped, streamStats._overflowCount); - printf(" Inter-packet timegaps (overall) | min: %9s, max: %9s, avg: %9s", + printf(" Inter-packet timegaps (overall) | min: %9s, max: %9s, avg: %9s\n", formatUsecTime(streamStats._timeGapMin).toLatin1().data(), formatUsecTime(streamStats._timeGapMax).toLatin1().data(), formatUsecTime(streamStats._timeGapAverage).toLatin1().data()); - printf(" Inter-packet timegaps (last 30s) | min: %9s, max: %9s, avg: %9s", + printf(" Inter-packet timegaps (last 30s) | min: %9s, max: %9s, avg: %9s\n", formatUsecTime(streamStats._timeGapWindowMin).toLatin1().data(), formatUsecTime(streamStats._timeGapWindowMax).toLatin1().data(), formatUsecTime(streamStats._timeGapWindowAverage).toLatin1().data()); From 406be72f41a61a0ebf436d481fd8899eaf154cf3 Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 13:46:55 -0700 Subject: [PATCH 76/94] per-report stats added to jitter tests --- tests/jitter/src/main.cpp | 46 +++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index aefed73ccf..c4e6472439 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -74,6 +74,12 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) std::cout << "SAMPLES_FOR_30_SECONDS:" << SAMPLES_FOR_30_SECONDS << "\n"; MovingMinMaxAvg timeGaps(1, SAMPLES_FOR_30_SECONDS); // stats + + const int SAMPLES_PER_REPORT = report * MSEC_TO_USEC / gap; + + std::cout << "SAMPLES_PER_REPORT:" << SAMPLES_PER_REPORT << "\n"; + + MovingMinMaxAvg timeGapsPerReport(1, SAMPLES_PER_REPORT); quint64 last = usecTimestampNow(); quint64 lastReport = 0; @@ -89,16 +95,24 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) int gapDifferece = actualGap - gap; timeGaps.update(gapDifferece); + timeGapsPerReport.update(gapDifferece); last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { - std::cout << "SEND gap Difference From Expected " + std::cout << "\n" + << "SEND gap Difference From Expected\n" + << "Overall:\n" << "min: " << timeGaps.getMin() << " usecs, " << "max: " << timeGaps.getMax() << " usecs, " - << "avg: " << timeGaps.getAverage() << " usecs, " - << "min last 30: " << timeGaps.getWindowMin() << " usecs, " - << "max last 30: " << timeGaps.getWindowMax() << " usecs, " - << "avg last 30: " << timeGaps.getWindowAverage() << " usecs " + << "avg: " << timeGaps.getAverage() << " usecs\n" + << "Last 30s:\n" + << "min: " << timeGaps.getWindowMin() << " usecs, " + << "max: " << timeGaps.getWindowMax() << " usecs, " + << "avg: " << timeGaps.getWindowAverage() << " usecs\n" + << "Last report interval:\n" + << "min: " << timeGapsPerReport.getWindowMin() << " usecs, " + << "max: " << timeGapsPerReport.getWindowMax() << " usecs, " + << "avg: " << timeGapsPerReport.getWindowAverage() << " usecs\n" << "\n"; lastReport = now; } @@ -129,6 +143,12 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo MovingMinMaxAvg timeGaps(1, SAMPLES_FOR_30_SECONDS); // stats + const int SAMPLES_PER_REPORT = report * MSEC_TO_USEC / gap; + + std::cout << "SAMPLES_PER_REPORT:" << SAMPLES_PER_REPORT << "\n"; + + MovingMinMaxAvg timeGapsPerReport(1, SAMPLES_PER_REPORT); + if (bind(sockfd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { std::cout << "bind failed\n"; return; @@ -148,17 +168,25 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo int actualGap = now - last; int gapDifferece = actualGap - gap; timeGaps.update(gapDifferece); + timeGapsPerReport.update(gapDifferece); last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { std::cout << "RECEIVE gap Difference From Expected " + << "Overall:\n" << "min: " << timeGaps.getMin() << " usecs, " << "max: " << timeGaps.getMax() << " usecs, " - << "avg: " << timeGaps.getAverage() << " usecs, " - << "min last 30: " << timeGaps.getWindowMin() << " usecs, " - << "max last 30: " << timeGaps.getWindowMax() << " usecs, " - << "avg last 30: " << timeGaps.getWindowAverage() << " usecs " + << "avg: " << timeGaps.getAverage() << " usecs\n" + << "Last 30s:\n" + << "min: " << timeGaps.getWindowMin() << " usecs, " + << "max: " << timeGaps.getWindowMax() << " usecs, " + << "avg: " << timeGaps.getWindowAverage() << " usecs\n" + << "Last report interval:\n" + << "min: " << timeGapsPerReport.getWindowMin() << " usecs, " + << "max: " << timeGapsPerReport.getWindowMax() << " usecs, " + << "avg: " << timeGapsPerReport.getWindowAverage() << " usecs\n" << "\n"; + lastReport = now; } } From 75aedae300a5e445837c0c5aec7edb618042083a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 12 Aug 2014 14:12:13 -0700 Subject: [PATCH 77/94] integration of positional tracking with DK2 --- cmake/modules/FindLibOVR.cmake | 4 +-- interface/src/avatar/MyAvatar.cpp | 6 ++++ interface/src/devices/OculusManager.cpp | 39 ++++++++++++++++++++----- interface/src/devices/OculusManager.h | 1 + 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index 505fd90b51..5fbe01d06b 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -27,8 +27,8 @@ find_path(LIBOVR_SRC_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${OCU include(SelectLibraryConfigurations) if (APPLE) - find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/MacOS/Debug HINTS ${OCULUS_SEARCH_DIRS}) - find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/MacOS/Release HINTS ${OCULUS_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Mac/Debug HINTS ${OCULUS_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Mac/Release HINTS ${OCULUS_SEARCH_DIRS}) find_library(ApplicationServices ApplicationServices) find_library(IOKit IOKit) elseif (UNIX) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index f59064732c..08d33ff252 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -255,6 +255,12 @@ void MyAvatar::updateFromTrackers(float deltaTime) { estimatedRotation.x *= -1.0f; estimatedRotation.z *= -1.0f; + } else if (OculusManager::isConnected()) { + estimatedPosition = OculusManager::getRelativePosition(); + estimatedPosition.x *= -1.0f; + + const float OCULUS_LEAN_SCALE = 0.05f; + estimatedPosition /= OCULUS_LEAN_SCALE; } else { FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); if (tracker) { diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 96df5b6c7c..6ce77e3ca2 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -314,7 +314,16 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p glPushMatrix(); glm::quat orientation; - + glm::vec3 trackerPosition; + +#if defined(__APPLE__) || defined(_WIN32) + ovrTrackingState ts = ovrHmd_GetTrackingState(_ovrHmd, ovr_GetTimeInSeconds()); + ovrVector3f ovrHeadPosition = ts.HeadPose.ThePose.Position; + + trackerPosition = glm::vec3(ovrHeadPosition.x, ovrHeadPosition.y, ovrHeadPosition.z); + trackerPosition = bodyOrientation * trackerPosition; +#endif + //Render each eye into an fbo for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++) { #if defined(__APPLE__) || defined(_WIN32) @@ -330,7 +339,8 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p orientation.w = eyeRenderPose[eye].Orientation.w; _camera->setTargetRotation(bodyOrientation * orientation); - _camera->setTargetPosition(position); + _camera->setTargetPosition(position + trackerPosition); + _camera->update(1.0f / Application::getInstance()->getFps()); Matrix4f proj = ovrMatrix4f_Projection(_eyeRenderDesc[eye].Fov, whichCamera.getNearClip(), whichCamera.getFarClip(), true); @@ -450,8 +460,9 @@ void OculusManager::renderDistortionMesh(ovrPosef eyeRenderPose[ovrEye_Count]) { //Tries to reconnect to the sensors void OculusManager::reset() { #ifdef HAVE_LIBOVR - disconnect(); - connect(); + if (_isConnected) { + ovrHmd_RecenterPose(_ovrHmd); + } #endif } @@ -463,18 +474,18 @@ void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) { #else ovrSensorState ss = ovrHmd_GetSensorState(_ovrHmd, _hmdFrameTiming.ScanoutMidpointSeconds); #endif -#if defined(__APPLE__) || defined(_WIN32) +#if defined(__APPLE__) || defined(_WIN32) if (ts.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) { #else if (ss.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) { #endif #if defined(__APPLE__) || defined(_WIN32) - ovrPosef pose = ts.CameraPose; + ovrPosef headPose = ts.HeadPose.ThePose; #else - ovrPosef pose = ss.Predicted.Pose; + ovrPosef headPose = ss.Predicted.Pose; #endif - Quatf orientation = Quatf(pose.Orientation); + Quatf orientation = Quatf(headPose.Orientation); orientation.GetEulerAngles(&yaw, &pitch, &roll); } else { yaw = 0.0f; @@ -487,6 +498,18 @@ void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) { roll = 0.0f; #endif } + +glm::vec3 OculusManager::getRelativePosition() { +#if defined(__APPLE__) || defined(_WIN32) + ovrTrackingState trackingState = ovrHmd_GetTrackingState(_ovrHmd, ovr_GetTimeInSeconds()); + ovrVector3f headPosition = trackingState.HeadPose.ThePose.Position; + + return glm::vec3(headPosition.x, headPosition.y, headPosition.z); +#else + // no positional tracking in Linux yet + return glm::vec3(0.0f, 0.0f, 0.0f); +#endif +} //Used to set the size of the glow framebuffers QSize OculusManager::getRenderTargetSize() { diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index 8c929bb50a..3959ea1ab7 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -40,6 +40,7 @@ public: /// param \pitch[out] pitch in radians /// param \roll[out] roll in radians static void getEulerAngles(float& yaw, float& pitch, float& roll); + static glm::vec3 getRelativePosition(); static QSize getRenderTargetSize(); private: From a68af15b8271af84e51add5714c6da683143f686 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 12 Aug 2014 14:26:14 -0700 Subject: [PATCH 78/94] DDE Face tracker tweaks to start adding long term averaging --- interface/src/devices/DdeFaceTracker.cpp | 47 +++++++++++++++++++++--- interface/src/devices/DdeFaceTracker.h | 4 ++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 3dc5a818cc..ae5beb8c85 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -178,6 +178,31 @@ float rescaleCoef(float ddeCoef) { return (ddeCoef - DDE_MIN_RANGE) / (DDE_MAX_RANGE - DDE_MIN_RANGE); } +const int MIN = 0; +const int AVG = 1; +const int MAX = 2; +const float LONG_TERM_AVERAGE = 0.999f; + + +void resetCoefficient(float * coefficient, float currentValue) { + coefficient[MIN] = coefficient[MAX] = coefficient[AVG] = currentValue; +} + +float updateAndGetCoefficient(float * coefficient, float currentValue, bool scaleToRange = false) { + coefficient[MIN] = (currentValue < coefficient[MIN]) ? currentValue : coefficient[MIN]; + coefficient[MAX] = (currentValue > coefficient[MAX]) ? currentValue : coefficient[MAX]; + coefficient[AVG] = LONG_TERM_AVERAGE * coefficient[AVG] + (1.f - LONG_TERM_AVERAGE) * currentValue; + if (coefficient[MAX] > coefficient[MIN]) { + if (scaleToRange) { + return glm::clamp((currentValue - coefficient[AVG]) / (coefficient[MAX] - coefficient[MIN]), 0.f, 1.f); + } else { + return glm::clamp(currentValue - coefficient[AVG], 0.f, 1.f); + } + } else { + return 0.f; + } +} + void DdeFaceTracker::decodePacket(const QByteArray& buffer) { if(buffer.size() > MIN_PACKET_SIZE) { Packet packet; @@ -189,14 +214,17 @@ void DdeFaceTracker::decodePacket(const QByteArray& buffer) { memcpy(&translation, packet.translation, sizeof(packet.translation)); glm::quat rotation; memcpy(&rotation, &packet.rotation, sizeof(packet.rotation)); - if (_reset) { + if (_reset || (_lastReceiveTimestamp == 0)) { memcpy(&_referenceTranslation, &translation, sizeof(glm::vec3)); memcpy(&_referenceRotation, &rotation, sizeof(glm::quat)); + + resetCoefficient(_rightEye, packet.expressions[0]); + resetCoefficient(_leftEye, packet.expressions[1]); _reset = false; } // Compute relative translation - float LEAN_DAMPING_FACTOR = 40; + float LEAN_DAMPING_FACTOR = 200.0f; translation -= _referenceTranslation; translation /= LEAN_DAMPING_FACTOR; translation.x *= -1; @@ -208,10 +236,19 @@ void DdeFaceTracker::decodePacket(const QByteArray& buffer) { _headTranslation = translation; _headRotation = rotation; + if (_lastReceiveTimestamp == 0) { + // On first packet, reset coefficients + } + // Set blendshapes - float BLINK_MAGNIFIER = 2.0f; - _blendshapeCoefficients[_leftBlinkIndex] = rescaleCoef(packet.expressions[1]) * BLINK_MAGNIFIER; - _blendshapeCoefficients[_rightBlinkIndex] = rescaleCoef(packet.expressions[0]) * BLINK_MAGNIFIER; + float EYE_MAGNIFIER = 4.0f; + + float rightEye = (updateAndGetCoefficient(_rightEye, packet.expressions[0])) * EYE_MAGNIFIER; + _blendshapeCoefficients[_rightBlinkIndex] = rightEye; + float leftEye = (updateAndGetCoefficient(_leftEye, packet.expressions[1])) * EYE_MAGNIFIER; + _blendshapeCoefficients[_leftBlinkIndex] = leftEye; + + // Right eye = packet.expressions[0]; float leftBrow = 1.0f - rescaleCoef(packet.expressions[14]); if (leftBrow < 0.5f) { diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index 96707ac94c..68d9e7d487 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -84,6 +84,10 @@ private: int _mouthSmileRightIndex; int _jawOpenIndex; + + float _leftEye[3]; + float _rightEye[3]; + }; #endif // hifi_DdeFaceTracker_h \ No newline at end of file From 9933c011d7e6a6d48dd5352d8ce84233f4a7081d Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 12 Aug 2014 14:31:40 -0700 Subject: [PATCH 79/94] Remove filtered eye position from head --- interface/src/Application.cpp | 4 ++-- interface/src/avatar/Head.cpp | 3 --- interface/src/avatar/Head.h | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6f7212e68f..3007943643 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -599,7 +599,7 @@ void Application::paintGL() { if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay - _myCamera.setTargetPosition(_myAvatar->getHead()->getFilteredEyePosition()); + _myCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition()); _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { @@ -621,7 +621,7 @@ void Application::paintGL() { _myCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition() + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)); } else { _myCamera.setTightness(0.0f); - glm::vec3 eyePosition = _myAvatar->getHead()->getFilteredEyePosition(); + glm::vec3 eyePosition = _myAvatar->getHead()->getEyePosition(); float headHeight = eyePosition.y - _myAvatar->getPosition().y; _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0)); diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 995f3f2390..b0333b1acf 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -163,9 +163,6 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) { } _eyePosition = calculateAverageEyePosition(); - float velocityFilter = glm::clamp(1.0f - glm::length(_filteredEyePosition - _eyePosition), 0.0f, 1.0f); - _filteredEyePosition = velocityFilter * _filteredEyePosition + (1.0f - velocityFilter) * _eyePosition; - } void Head::relaxLean(float deltaTime) { diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 6d1e82b97f..1de5ea7dd1 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -88,7 +88,6 @@ public: const bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected) float getAverageLoudness() const { return _averageLoudness; } - glm::vec3 getFilteredEyePosition() const { return _filteredEyePosition; } /// \return the point about which scaling occurs. glm::vec3 getScalePivot() const; @@ -121,7 +120,6 @@ private: glm::vec3 _leftEyePosition; glm::vec3 _rightEyePosition; glm::vec3 _eyePosition; - glm::vec3 _filteredEyePosition; // velocity filtered world space eye position float _scale; float _lastLoudness; From 184e4b8bde60ffe05a115959c5a3fa5a8f3cb411 Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 14:38:28 -0700 Subject: [PATCH 80/94] sestets added to jitter tester --- .../networking/src/SequenceNumberStats.cpp | 25 +++++++------ .../networking/src/SequenceNumberStats.h | 13 +++++++ tests/jitter/src/main.cpp | 36 +++++++++++++++++++ 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/libraries/networking/src/SequenceNumberStats.cpp b/libraries/networking/src/SequenceNumberStats.cpp index 6a7f5e1964..f472159164 100644 --- a/libraries/networking/src/SequenceNumberStats.cpp +++ b/libraries/networking/src/SequenceNumberStats.cpp @@ -253,14 +253,19 @@ PacketStreamStats SequenceNumberStats::getStatsForHistoryWindow() const { } // calculate difference between newest stats and oldest stats to get window stats - PacketStreamStats windowStats; - windowStats._received = newestStats->_received - oldestStats->_received; - windowStats._unreasonable = newestStats->_unreasonable - oldestStats->_unreasonable; - windowStats._early = newestStats->_early - oldestStats->_early; - windowStats._late = newestStats->_late - oldestStats->_late; - windowStats._lost = newestStats->_lost - oldestStats->_lost; - windowStats._recovered = newestStats->_recovered - oldestStats->_recovered; - windowStats._expectedReceived = newestStats->_expectedReceived - oldestStats->_expectedReceived; - - return windowStats; + return *newestStats - *oldestStats; } + +PacketStreamStats SequenceNumberStats::getStatsForLastHistoryInterval() const { + + const PacketStreamStats* newestStats = _statsHistory.getNewestEntry(); + const PacketStreamStats* secondNewestStats = _statsHistory.get(1); + + // this catches cases where history is length 1 or 0 (both are NULL in case of 0) + if (newestStats == NULL || secondNewestStats == NULL) { + return PacketStreamStats(); + } + + return *newestStats - *secondNewestStats; +} + diff --git a/libraries/networking/src/SequenceNumberStats.h b/libraries/networking/src/SequenceNumberStats.h index 5e02dbc850..434d5a18db 100644 --- a/libraries/networking/src/SequenceNumberStats.h +++ b/libraries/networking/src/SequenceNumberStats.h @@ -31,6 +31,18 @@ public: _expectedReceived(0) {} + PacketStreamStats operator-(const PacketStreamStats& rhs) const { + PacketStreamStats diff; + diff._received = _received - rhs._received; + diff._unreasonable = _unreasonable - rhs._unreasonable; + diff._early = _early - rhs._early; + diff._late = _late - rhs._late; + diff._lost = _lost - rhs._lost; + diff._recovered = _recovered - rhs._recovered; + diff._expectedReceived = _expectedReceived - rhs._expectedReceived; + return diff; + } + float getLostRate() const { return (float)_lost / _expectedReceived; } quint32 _received; @@ -76,6 +88,7 @@ public: const PacketStreamStats& getStats() const { return _stats; } PacketStreamStats getStatsForHistoryWindow() const; + PacketStreamStats getStatsForLastHistoryInterval() const; const QSet& getMissingSet() const { return _missingSet; } private: diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index c4e6472439..bb6d902e86 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -16,6 +16,7 @@ #include #include // for MovingMinMaxAvg +#include #include // for usecTimestampNow const quint64 MSEC_TO_USEC = 1000; @@ -61,6 +62,8 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) char* outputBuffer = new char[size]; memset(outputBuffer, 0, size); + + quint16 outgoingSequenceNumber = 0; sockfd=socket(AF_INET,SOCK_DGRAM,0); @@ -91,7 +94,12 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) if (actualGap >= gap) { + + // pack seq num + memcpy(outputBuffer, &outgoingSequenceNumber, sizeof(quint16)); + sendto(sockfd, outputBuffer, size, 0, (struct sockaddr *)&servaddr, sizeof(servaddr)); + outgoingSequenceNumber++; int gapDifferece = actualGap - gap; timeGaps.update(gapDifferece); @@ -148,6 +156,12 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo std::cout << "SAMPLES_PER_REPORT:" << SAMPLES_PER_REPORT << "\n"; MovingMinMaxAvg timeGapsPerReport(1, SAMPLES_PER_REPORT); + + const int REPORTS_FOR_30_SECONDS = 30 * MSECS_PER_SECOND / report; + + std::cout << "REPORTS_FOR_30_SECONDS:" << REPORTS_FOR_30_SECONDS << "\n"; + + SequenceNumberStats seqStats(REPORTS_FOR_30_SECONDS); if (bind(sockfd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { std::cout << "bind failed\n"; @@ -159,6 +173,10 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo while (true) { n = recvfrom(sockfd, inputBuffer, size, 0, NULL, NULL); // we don't care about where it came from + + // parse seq num + quint16 incomingSequenceNumber = *(reinterpret_cast(inputBuffer)); + seqStats.sequenceNumberReceived(incomingSequenceNumber); if (last == 0) { last = usecTimestampNow(); @@ -172,6 +190,9 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { + + seqStats.pushStatsToHistory(); + std::cout << "RECEIVE gap Difference From Expected " << "Overall:\n" << "min: " << timeGaps.getMin() << " usecs, " @@ -187,6 +208,21 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo << "avg: " << timeGapsPerReport.getWindowAverage() << " usecs\n" << "\n"; + PacketStreamStats packetStatsLast30s = seqStats.getStatsForHistoryWindow(); + PacketStreamStats packetStatsLastReportInterval = seqStats.getStatsForLastHistoryInterval(); + + std::cout << "RECEIVE Packet Stats " + << "Overall:\n" + << "lost: " << seqStats.getLost() << ", " + << "lost %: " << seqStats.getStats().getLostRate() * 100.0f << "%\n" + << "Last 30s:\n" + << "lost: " << packetStatsLast30s._lost << ", " + << "lost %: " << packetStatsLast30s.getLostRate() * 100.0f << "%\n" + << "Last report interval:\n" + << "lost: " << packetStatsLastReportInterval._lost << ", " + << "lost %: " << packetStatsLastReportInterval.getLostRate() * 100.0f << "%\n" + << "\n\n"; + lastReport = now; } } From 00087e81d86a4e6d450fd05b1d4ee18d288d05d9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 12 Aug 2014 14:44:49 -0700 Subject: [PATCH 81/94] remove a line of debug that shouldn't have made its way in --- interface/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 1d91723f4d..fefdcb0ab5 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -8,7 +8,6 @@ foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR) string(TOLOWER ${EXTERNAL} ${EXTERNAL}_LOWERCASE) set(${${EXTERNAL}_UPPERCASE}_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/${${EXTERNAL}_LOWERCASE}") - message("Dir for ${EXTERNAL} is ${${${EXTERNAL}_UPPERCASE}_ROOT_DIR}") endif () endforeach() From ac4d20bb431009726fc98ea12edd51069b204bec Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 12 Aug 2014 14:49:30 -0700 Subject: [PATCH 82/94] repairs to FindLibOVR for OS X new structure --- cmake/modules/FindLibOVR.cmake | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index 6c5556fb85..9c703f9cfe 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -27,8 +27,8 @@ find_path(LIBOVR_SRC_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${LIB include(SelectLibraryConfigurations) if (APPLE) - find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Mac/Debug HINTS ${OCULUS_SEARCH_DIRS}) - find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Mac/Release HINTS ${OCULUS_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Mac/Debug HINTS ${LIBOVR_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Mac/Release HINTS ${LIBOVR_SEARCH_DIRS}) find_library(ApplicationServices ApplicationServices) find_library(IOKit IOKit) elseif (UNIX) @@ -53,21 +53,20 @@ elseif (WIN32) endif () select_library_configurations(LIBOVR) -set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARY}") +set(LIBOVR_LIBRARIES ${LIBOVR_LIBRARY}) + +list(APPEND LIBOVR_ARGS_LIST LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARY) if (APPLE) - set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" ${IOKit} ${ApplicationServices}) + list(APPEND LIBOVR_LIBRARIES ${IOKit} ${ApplicationServices}) + list(APPEND LIBOVR_ARGS_LIST IOKit ApplicationServices) elseif (UNIX) - set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}") + list(APPEND LIBOVR_LIBRARIES "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}") + list(APPEND LIBOVR_ARGS_LIST UDEV_LIBRARY XINERAMA_LIBRARY) endif () include(FindPackageHandleStandardArgs) -if (APPLE) - find_package_handle_standard_args(LibOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES IOKit ApplicationServices) -elseif (UNIX) - find_package_handle_standard_args(LibOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY) -else () - find_package_handle_standard_args(LibOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES) -endif () -mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES OCULUS_SEARCH_DIRS) +find_package_handle_standard_args(LibOVR DEFAULT_MSG ${LIBOVR_ARGS_LIST}) + +mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES LIBOVR_SEARCH_DIRS) From 4bf7bbe0df8d2f5a8fb0ae34ede916dcf9e3ac63 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 12 Aug 2014 15:20:04 -0700 Subject: [PATCH 83/94] if enable VR mode is re-checked then attempt to re-connect to Oculus --- interface/src/Application.cpp | 9 +++++++++ interface/src/devices/OculusManager.cpp | 4 ++++ interface/src/devices/SixenseManager.cpp | 4 +++- interface/src/devices/SixenseManager.h | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3007943643..9d49dc6281 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1440,6 +1440,15 @@ void Application::setEnable3DTVMode(bool enable3DTVMode) { } void Application::setEnableVRMode(bool enableVRMode) { + if (enableVRMode) { + if (!OculusManager::isConnected()) { + // attempt to reconnect the Oculus manager - it's possible this was a workaround + // for the sixense crash + OculusManager::disconnect(); + OculusManager::connect(); + } + } + resizeGL(_glWidget->width(), _glWidget->height()); } diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 6ce77e3ca2..7d7375fad5 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -135,6 +135,10 @@ void OculusManager::connect() { } else { _isConnected = false; + + // we're definitely not in "VR mode" so tell the menu that + Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(false); + ovrHmd_Destroy(_ovrHmd); ovr_Shutdown(); } diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index 089d478198..803060e5d3 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -19,6 +19,7 @@ #include "UserActivityLogger.h" #ifdef HAVE_SIXENSE + const int CALIBRATION_STATE_IDLE = 0; const int CALIBRATION_STATE_X = 1; const int CALIBRATION_STATE_Y = 2; @@ -41,8 +42,9 @@ SixenseManager::SixenseManager() { // By default we assume the _neckBase (in orb frame) is as high above the orb // as the "torso" is below it. _neckBase = glm::vec3(NECK_X, -NECK_Y, NECK_Z); - + sixenseInit(); + #endif _hydrasConnected = false; _triggerPressed[0] = false; diff --git a/interface/src/devices/SixenseManager.h b/interface/src/devices/SixenseManager.h index 91f9e9884f..664c102f76 100644 --- a/interface/src/devices/SixenseManager.h +++ b/interface/src/devices/SixenseManager.h @@ -71,7 +71,7 @@ private: glm::vec3 _reachUp; glm::vec3 _reachForward; float _lastDistance; - + #endif bool _hydrasConnected; quint64 _lastMovement; From 4dce4c49194103935c0c550be045f27672d821e7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 12 Aug 2014 15:23:12 -0700 Subject: [PATCH 84/94] link to ws2_32.lib if LibOVR is being linked to --- cmake/modules/FindLibOVR.cmake | 2 ++ interface/CMakeLists.txt | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index 9c703f9cfe..62ac572f2f 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -63,6 +63,8 @@ if (APPLE) elseif (UNIX) list(APPEND LIBOVR_LIBRARIES "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}") list(APPEND LIBOVR_ARGS_LIST UDEV_LIBRARY XINERAMA_LIBRARY) +elseif (WIN32) + list(APPEND LIBOVR_LIBRARIES ws2_32.lib) endif () include(FindPackageHandleStandardArgs) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index fefdcb0ab5..32070a4427 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -201,9 +201,6 @@ else (APPLE) add_definitions(-DGLEW_STATIC) target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib) - if (LIBOVR_FOUND) - target_link_libraries(${TARGET_NAME} ws2_32.lib) - endif() endif() endif (APPLE) From dc46d6b80fd1c9e544ae99ffd563dff5354fba47 Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 15:27:17 -0700 Subject: [PATCH 85/94] added stdev to jitter tester --- tests/jitter/src/main.cpp | 40 +++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index bb6d902e86..158860c627 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -17,6 +17,7 @@ #include // for MovingMinMaxAvg #include +#include #include // for usecTimestampNow const quint64 MSEC_TO_USEC = 1000; @@ -83,6 +84,10 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) std::cout << "SAMPLES_PER_REPORT:" << SAMPLES_PER_REPORT << "\n"; MovingMinMaxAvg timeGapsPerReport(1, SAMPLES_PER_REPORT); + + StDev stDevReportInterval; + StDev stDev30s; + StDev stDev; quint64 last = usecTimestampNow(); quint64 lastReport = 0; @@ -104,24 +109,35 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) int gapDifferece = actualGap - gap; timeGaps.update(gapDifferece); timeGapsPerReport.update(gapDifferece); + stDev.addValue(gapDifferece); last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { + std::cout << "\n" << "SEND gap Difference From Expected\n" << "Overall:\n" << "min: " << timeGaps.getMin() << " usecs, " << "max: " << timeGaps.getMax() << " usecs, " - << "avg: " << timeGaps.getAverage() << " usecs\n" + << "avg: " << timeGaps.getAverage() << " usecs, " + << "stdev: " << stDev.getStDev() << " usecs\n" << "Last 30s:\n" << "min: " << timeGaps.getWindowMin() << " usecs, " << "max: " << timeGaps.getWindowMax() << " usecs, " - << "avg: " << timeGaps.getWindowAverage() << " usecs\n" + << "avg: " << timeGaps.getWindowAverage() << " usecs, " + << "stdev: " << stDev30s.getStDev() << " usecs\n" << "Last report interval:\n" << "min: " << timeGapsPerReport.getWindowMin() << " usecs, " << "max: " << timeGapsPerReport.getWindowMax() << " usecs, " - << "avg: " << timeGapsPerReport.getWindowAverage() << " usecs\n" + << "avg: " << timeGapsPerReport.getWindowAverage() << " usecs, " + << "stdev: " << stDevReportInterval.getStDev() << " usecs\n" << "\n"; + + stDevReportInterval.reset(); + if (stDev30s.getSamples() > SAMPLES_FOR_30_SECONDS) { + stDev30s.reset(); + } + lastReport = now; } } @@ -162,6 +178,10 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo std::cout << "REPORTS_FOR_30_SECONDS:" << REPORTS_FOR_30_SECONDS << "\n"; SequenceNumberStats seqStats(REPORTS_FOR_30_SECONDS); + + StDev stDevReportInterval; + StDev stDev30s; + StDev stDev; if (bind(sockfd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { std::cout << "bind failed\n"; @@ -197,17 +217,25 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo << "Overall:\n" << "min: " << timeGaps.getMin() << " usecs, " << "max: " << timeGaps.getMax() << " usecs, " - << "avg: " << timeGaps.getAverage() << " usecs\n" + << "avg: " << timeGaps.getAverage() << " usecs, " + << "stdev: " << stDev.getStDev() << " usecs\n" << "Last 30s:\n" << "min: " << timeGaps.getWindowMin() << " usecs, " << "max: " << timeGaps.getWindowMax() << " usecs, " - << "avg: " << timeGaps.getWindowAverage() << " usecs\n" + << "avg: " << timeGaps.getWindowAverage() << " usecs, " + << "stdev: " << stDev30s.getStDev() << " usecs\n" << "Last report interval:\n" << "min: " << timeGapsPerReport.getWindowMin() << " usecs, " << "max: " << timeGapsPerReport.getWindowMax() << " usecs, " - << "avg: " << timeGapsPerReport.getWindowAverage() << " usecs\n" + << "avg: " << timeGapsPerReport.getWindowAverage() << " usecs, " + << "stdev: " << stDevReportInterval.getStDev() << " usecs\n" << "\n"; + stDevReportInterval.reset(); + if (stDev30s.getSamples() > SAMPLES_FOR_30_SECONDS) { + stDev30s.reset(); + } + PacketStreamStats packetStatsLast30s = seqStats.getStatsForHistoryWindow(); PacketStreamStats packetStatsLastReportInterval = seqStats.getStatsForLastHistoryInterval(); From d43c39fd574447b95ed8d6cf8c368af63a21d380 Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 15:28:36 -0700 Subject: [PATCH 86/94] forgot a line --- tests/jitter/src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index 158860c627..79c157c298 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -207,6 +207,7 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo int gapDifferece = actualGap - gap; timeGaps.update(gapDifferece); timeGapsPerReport.update(gapDifferece); + stDev.addValue(gapDifferece); last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { From 53d6cdd67cadbaf10cf54e0079368273f9685d43 Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 15:36:51 -0700 Subject: [PATCH 87/94] forgot more lines --- tests/jitter/src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index 79c157c298..5ece1b8e86 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -110,6 +110,8 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) timeGaps.update(gapDifferece); timeGapsPerReport.update(gapDifferece); stDev.addValue(gapDifferece); + stDev30s.addValue(gapDifferece); + stDevReportInterval.addValue(gapDifferece); last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { @@ -208,6 +210,8 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo timeGaps.update(gapDifferece); timeGapsPerReport.update(gapDifferece); stDev.addValue(gapDifferece); + stDev30s.addValue(gapDifferece); + stDevReportInterval.addValue(gapDifferece); last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { From 3c73fd5e0b86f58b002c134f41d50eb3a2e24428 Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 15:39:03 -0700 Subject: [PATCH 88/94] forgot newline --- tests/jitter/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index 5ece1b8e86..8b8d0a00fc 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -218,7 +218,7 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo seqStats.pushStatsToHistory(); - std::cout << "RECEIVE gap Difference From Expected " + std::cout << "RECEIVE gap Difference From Expected\n" << "Overall:\n" << "min: " << timeGaps.getMin() << " usecs, " << "max: " << timeGaps.getMax() << " usecs, " From 737228e7bb9feb1d4d7d069d9185173d186d3b62 Mon Sep 17 00:00:00 2001 From: wangyix Date: Tue, 12 Aug 2014 15:40:58 -0700 Subject: [PATCH 89/94] another newline --- tests/jitter/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index 8b8d0a00fc..a33347f9ef 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -244,7 +244,7 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo PacketStreamStats packetStatsLast30s = seqStats.getStatsForHistoryWindow(); PacketStreamStats packetStatsLastReportInterval = seqStats.getStatsForLastHistoryInterval(); - std::cout << "RECEIVE Packet Stats " + std::cout << "RECEIVE Packet Stats\n" << "Overall:\n" << "lost: " << seqStats.getLost() << ", " << "lost %: " << seqStats.getStats().getLostRate() * 100.0f << "%\n" From acda466c7656ed76a9ebca6029e100229c536f2a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 13 Aug 2014 09:11:43 -0700 Subject: [PATCH 90/94] add atls as requirement for LibOVR --- cmake/modules/FindLibOVR.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index 62ac572f2f..f950bdba58 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -64,6 +64,7 @@ elseif (UNIX) list(APPEND LIBOVR_LIBRARIES "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}") list(APPEND LIBOVR_ARGS_LIST UDEV_LIBRARY XINERAMA_LIBRARY) elseif (WIN32) + list(APPEND LIBOVR_LIRARIES "DEBUG atlsd.lib OPTIMIZED atls.lib") list(APPEND LIBOVR_LIBRARIES ws2_32.lib) endif () From 1ee58b7bd0355ef35b72278a6261fca08356f163 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 13 Aug 2014 09:19:45 -0700 Subject: [PATCH 91/94] find the ATL library on windows for LibOVR --- cmake/modules/FindLibOVR.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index f950bdba58..a1d75add3f 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -50,6 +50,7 @@ elseif (UNIX) elseif (WIN32) find_library(LIBOVR_LIBRARY_DEBUG NAMES libovrd PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${LIBOVR_SEARCH_DIRS}) find_library(LIBOVR_LIBRARY_RELEASE NAMES libovr PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${LIBOVR_SEARCH_DIRS}) + find_package(ATL) endif () select_library_configurations(LIBOVR) @@ -64,8 +65,8 @@ elseif (UNIX) list(APPEND LIBOVR_LIBRARIES "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}") list(APPEND LIBOVR_ARGS_LIST UDEV_LIBRARY XINERAMA_LIBRARY) elseif (WIN32) - list(APPEND LIBOVR_LIRARIES "DEBUG atlsd.lib OPTIMIZED atls.lib") - list(APPEND LIBOVR_LIBRARIES ws2_32.lib) + list(APPEND LIBOVR_LIBRARIES ${ATL_LIBRARIES}) + list(APPEND LIBOVR_ARGS_LIST ATL_LIBRARIES) endif () include(FindPackageHandleStandardArgs) From 83952cb85cf42020bb0330fbf10e496f943d1405 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 13 Aug 2014 09:22:07 -0700 Subject: [PATCH 92/94] add the FindATL cmake module --- cmake/modules/FindATL.cmake | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 cmake/modules/FindATL.cmake diff --git a/cmake/modules/FindATL.cmake b/cmake/modules/FindATL.cmake new file mode 100644 index 0000000000..f3affbb49e --- /dev/null +++ b/cmake/modules/FindATL.cmake @@ -0,0 +1,29 @@ +# +# FindATL.cmake +# +# Try to find the ATL library needed to use the LibOVR +# +# Once done this will define +# +# ATL_FOUND - system found ATL +# ATL_LIBRARIES - Link this to use ATL +# +# Created on 8/13/2013 by Stephen Birarda +# Copyright 2014 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +if (WIN32) + find_library(ATL_LIBRARY_RELEASE atl PATH_SUFFIXES "7600.16385.1/lib/ATL/i386" HINTS "C:\\WinDDK") + find_library(ATL_LIBRARY_DEBUG atld PATH_SUFFIXES "7600.16385.1/lib/ATL/i386" HINTS "C:\\WinDDK") + + include(SelectLibraryConfigurations) + select_library_configurations(ATL) +endif () + +set(ATL_LIBRARIES "${ATL_LIBRARY}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ATL DEFAULT_MSG ATL_LIBRARIES) \ No newline at end of file From da7f3d18e4cc04e7ed16a5da0df1c3a1b5d6b7b9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 13 Aug 2014 09:27:44 -0700 Subject: [PATCH 93/94] require QXMPP_LIBRARY to be found for FindQXMPP to succeed --- cmake/modules/FindQxmpp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/FindQxmpp.cmake b/cmake/modules/FindQxmpp.cmake index 8d8c0e22a2..8fbc63e9dc 100644 --- a/cmake/modules/FindQxmpp.cmake +++ b/cmake/modules/FindQxmpp.cmake @@ -34,6 +34,6 @@ select_library_configurations(QXMPP) set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}" Qt5::Xml) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(QXmpp DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) +find_package_handle_standard_args(QXmpp DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES QXMPP_LIBRARY) mark_as_advanced(QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES QXMPP_SEARCH_DIRS) \ No newline at end of file From b055e07d72fa62375d3f70ab58f140101029cd9b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 13 Aug 2014 09:29:49 -0700 Subject: [PATCH 94/94] look for atls not atl in FindATL --- cmake/modules/FindATL.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindATL.cmake b/cmake/modules/FindATL.cmake index f3affbb49e..f95b0267eb 100644 --- a/cmake/modules/FindATL.cmake +++ b/cmake/modules/FindATL.cmake @@ -16,8 +16,8 @@ # if (WIN32) - find_library(ATL_LIBRARY_RELEASE atl PATH_SUFFIXES "7600.16385.1/lib/ATL/i386" HINTS "C:\\WinDDK") - find_library(ATL_LIBRARY_DEBUG atld PATH_SUFFIXES "7600.16385.1/lib/ATL/i386" HINTS "C:\\WinDDK") + find_library(ATL_LIBRARY_RELEASE atls PATH_SUFFIXES "7600.16385.1/lib/ATL/i386" HINTS "C:\\WinDDK") + find_library(ATL_LIBRARY_DEBUG atlsd PATH_SUFFIXES "7600.16385.1/lib/ATL/i386" HINTS "C:\\WinDDK") include(SelectLibraryConfigurations) select_library_configurations(ATL)