From 36b323c6f302e359ec34235b69f53e38b190c245 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Sat, 21 Feb 2015 15:37:09 +0530 Subject: [PATCH 01/31] Added VHACD dependency Provide link to github source. The source tree has necessary cmke changes to allow 32 bit build specific to hifi --- BUILD.md | 2 +- BUILD_WIN.md | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/BUILD.md b/BUILD.md index f7dc22882a..b956f0e70b 100644 --- a/BUILD.md +++ b/BUILD.md @@ -8,7 +8,7 @@ * [Soxr](http://sourceforge.net/projects/soxr/) ~> 0.1.1 * [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82 * [Gverb](https://github.com/highfidelity/gverb/archive/master.zip) (direct download to latest version) - +* [VHACD](https://github.com/virneo/v-hacd) #### CMake External Project Dependencies The following dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build` directory in each of the subfolders for each external project. These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. diff --git a/BUILD_WIN.md b/BUILD_WIN.md index f5bc3e09b5..0f806f3bf7 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -67,6 +67,9 @@ The recommended route for CMake to find the external dependencies is to place al -> include -> lib -> test + -> vhacd + -> include + -> lib For many of the external libraries where precompiled binaries are readily available you should be able to simply copy the extracted folder that you get from the download links provided at the top of the guide. Otherwise you may need to build from source and install the built product to this directory. The `root_lib_dir` in the above example can be wherever you choose on your system - as long as the environment variable HIFI_LIB_DIR is set to it. From here on, whenever you see %HIFI_LIB_DIR% you should substitute the directory that you chose. @@ -114,6 +117,15 @@ Add to the PATH: `%HIFI_LIB_DIR%\zlib` Important! This should be added at the beginning of the path, not the end (your system likely has many copies of zlib1.dll, and you want High Fidelity to use the correct version). If High Fidelity picks up the wrong zlib1.dll then it might be unable to use it, and that would cause it to fail to start, showing only the cryptic error "The application was unable to start correctly: 0xc0000022". +###vhacd +Download it directly from https://github.com/virneo/v-hacd +cd src\ +mkdir build +cd build +cmake .. +Build using visual studio 2013. Build ALL_BUILD and INSTALL targets both in Release and Debug. This create a output folder with include and lib directory. +Either copy that folder to ENV %HIFI_LIB_DIR%/vhacd or create an environment variable VHACD_ROOT_DIR to this output directory. + ###freeglut Download the binary package: `freeglut-MSVC-2.8.1-1.mp.zip`. Extract to %HIFI_LIB_DIR%\freeglut. From b9befc208bd494abf266b3d1a4e29326b48d6ddd Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Sat, 21 Feb 2015 15:38:16 +0530 Subject: [PATCH 02/31] Cmake module to find VHACD library FindVHACD will look for VHACD_ROOT_DIR env variable or HIFI_LIB_DIR/vhacd folder --- cmake/modules/FindVHACD.cmake | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 cmake/modules/FindVHACD.cmake diff --git a/cmake/modules/FindVHACD.cmake b/cmake/modules/FindVHACD.cmake new file mode 100644 index 0000000000..d84ab30dff --- /dev/null +++ b/cmake/modules/FindVHACD.cmake @@ -0,0 +1,55 @@ +# +# FindVHACD.cmake +# +# Try to find the V-HACD library that decomposes a 3D surface into a set of "near" convex parts. +# +# Once done this will define +# +# VHACD_FOUND - system found V-HACD +# VHACD_INCLUDE_DIRS - the V-HACD include directory +# VHACD_LIBRARIES - link to this to use V-HACD +# +# Created on 2/20/2015 by Virendra Singh +# Copyright 2015 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("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("vhacd") + +macro(_FIND_VHACD_LIBRARY _var) + set(_${_var}_NAMES ${ARGN}) + find_library(${_var}_LIBRARY_RELEASE + NAMES ${_${_var}_NAMES} + HINTS + ${VHACD_SEARCH_DIRS} + $ENV{VHACD_ROOT_DIR} + PATH_SUFFIXES lib lib/Release + ) + + find_library(${_var}_LIBRARY_DEBUG + NAMES ${_${_var}_NAMES} + HINTS + ${VHACD_SEARCH_DIRS} + $ENV{VHACD_ROOT_DIR} + PATH_SUFFIXES lib lib/Debug + ) + + select_library_configurations(${_var}) + + mark_as_advanced(${_var}_LIBRARY) + mark_as_advanced(${_var}_LIBRARY) +endmacro() + + +find_path(VHACD_INCLUDE_DIRS VHACD.h PATH_SUFFIXES include HINTS ${VHACD_SEARCH_DIRS} $ENV{VHACD_ROOT_DIR}) +_FIND_VHACD_LIBRARY(VHACD VHACD_LIB) +set(VHACD_LIBRARIES ${VHACD_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VHACD "Could NOT find VHACD, try to set the path to VHACD root folder in the system variable VHACD_ROOT_DIR or create a directory vhacd in HIFI_LIB_DIR and paste the necessary files there" + VHACD_INCLUDE_DIRS VHACD_LIBRARIES) + +mark_as_advanced(VHACD_INCLUDE_DIRS VHACD_LIBRARIES VHACD_SEARCH_DIRS) \ No newline at end of file From ddd137ed60ff96800531a17adee0dc4a8c2921e7 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Sat, 21 Feb 2015 15:39:16 +0530 Subject: [PATCH 03/31] cmake changes for vhacd cmake changes to create a new project vhacd as a seperate executable in tools directory --- tools/CMakeLists.txt | 1 + tools/vhacd/CMakeLists.txt | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tools/vhacd/CMakeLists.txt diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index a13933ba5e..57fe18c53f 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -3,3 +3,4 @@ add_subdirectory(bitstream2json) add_subdirectory(json2bitstream) add_subdirectory(mtc) add_subdirectory(scribe) +add_subdirectory(vhacd) diff --git a/tools/vhacd/CMakeLists.txt b/tools/vhacd/CMakeLists.txt new file mode 100644 index 0000000000..ee82cd599d --- /dev/null +++ b/tools/vhacd/CMakeLists.txt @@ -0,0 +1,13 @@ +set(TARGET_NAME vhacd) +setup_hifi_project() +link_hifi_libraries(shared model fbx gpu networking octree) + +find_package(VHACD REQUIRED) +target_include_directories(${TARGET_NAME} PUBLIC ${VHACD_INCLUDE_DIRS}) +target_link_libraries(${TARGET_NAME} ${VHACD_LIBRARIES}) + +add_dependency_external_project(glm) +find_package(GLM REQUIRED) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) + +include_dependency_includes() \ No newline at end of file From ce04b1accb2690edcf43cfa1676c34e8fd519e80 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Sat, 21 Feb 2015 15:40:39 +0530 Subject: [PATCH 04/31] vhacd tool this tool is as per joblist #20305. Its provides an executable to test VHACD computation on simple fbx models. --- tools/vhacd/src/VHACDUtil.cpp | 130 ++++++++++++++++++++++++++++++++++ tools/vhacd/src/VHACDUtil.h | 55 ++++++++++++++ tools/vhacd/src/main.cpp | 102 ++++++++++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 tools/vhacd/src/VHACDUtil.cpp create mode 100644 tools/vhacd/src/VHACDUtil.h create mode 100644 tools/vhacd/src/main.cpp diff --git a/tools/vhacd/src/VHACDUtil.cpp b/tools/vhacd/src/VHACDUtil.cpp new file mode 100644 index 0000000000..bfcdb74634 --- /dev/null +++ b/tools/vhacd/src/VHACDUtil.cpp @@ -0,0 +1,130 @@ +// +// VHACDUtil.cpp +// tools/vhacd/src +// +// Created by Virendra Singh on 2/20/15. +// Copyright 2015 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 "VHACDUtil.h" + + +//Read all the meshes from provided FBX file +bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *results) +{ + + // open the fbx file + QFile fbx(filename); + if (!fbx.open(QIODevice::ReadOnly)) { + return false; + } + std::cout << "Reading FBX.....\n"; + + QByteArray fbxContents = fbx.readAll(); + FBXGeometry geometry = readFBX(fbxContents, QVariantHash()); + //results->meshCount = geometry.meshes.count(); + + int count = 0; + foreach(FBXMesh mesh, geometry.meshes) + { + //get vertices for each mesh + QVector vertices = mesh.vertices; + + //get the triangle indices for each mesh + QVector triangles; + foreach(FBXMeshPart part, mesh.parts) + { + QVector indices = part.triangleIndices; + triangles += indices; + } + + //only read meshes with triangles + if (triangles.count() <= 0) + continue; + results->perMeshVertices.append(vertices); + results->perMeshTriangleIndices.append(triangles); + count++; + } + + results->meshCount = count; + return true; +} + +bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const +{ + VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD(); + int meshCount = meshes->meshCount; + int count = 0; + std::cout << "Performing V-HACD computation on " << meshCount <<" meshes ..... " << std::endl; + + for (int i = 0; i < meshCount; i++) + { + + std::vector vertices = meshes->perMeshVertices.at(i).toStdVector(); + std::vector triangles = meshes->perMeshTriangleIndices.at(i).toStdVector(); + int nPoints = (unsigned int)vertices.size(); + int nTriangles = (unsigned int)triangles.size() / 3; + std::cout << "Mesh " << i + 1 << " : "; + // compute approximate convex decomposition + bool res = interfaceVHACD->Compute(&vertices[0].x, 3, nPoints, &triangles[0], 3, nTriangles, params); + if (!res) + { + std::cout << "V-HACD computation failed for Mesh : " << i + 1 << std::endl; + continue; + } + count++; //For counting number of successfull computations + + //Number of hulls for the mesh + unsigned int nConvexHulls = interfaceVHACD->GetNConvexHulls(); + results->convexHullsCountList.append(nConvexHulls); + + //get all the convex hulls for this mesh + QVector convexHulls; + for (unsigned int j = 0; j < nConvexHulls; j++) + { + VHACD::IVHACD::ConvexHull hull; + interfaceVHACD->GetConvexHull(j, hull); + convexHulls.append(hull); + } + results->convexHullList.append(convexHulls); + } //end of for loop + + results->meshCount = count; + + //release memory + interfaceVHACD->Clean(); + interfaceVHACD->Release(); + + if (count > 0) + return true; + else + return false; +} + +vhacd::VHACDUtil:: ~VHACDUtil() +{ + //nothing to be cleaned +} + +//ProgressClaback implementation +void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation) +{ + int progress = (int)(overallProgress + 0.5); + + if (progress < 10) + std::cout << "\b\b"; + else + std::cout << "\b\b\b"; + std::cout << progress << "%"; + + if (progress >= 100) + std::cout << std::endl; + +} + +vhacd::ProgressCallback::ProgressCallback(void){} +vhacd::ProgressCallback::~ProgressCallback(){} \ No newline at end of file diff --git a/tools/vhacd/src/VHACDUtil.h b/tools/vhacd/src/VHACDUtil.h new file mode 100644 index 0000000000..a9df5d7f2a --- /dev/null +++ b/tools/vhacd/src/VHACDUtil.h @@ -0,0 +1,55 @@ +// +// VHACDUtil.h +// tools/vhacd/src +// +// Created by Virendra Singh on 2/20/15. +// Copyright 2015 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_VHACDUtil_h +#define hifi_VHACDUtil_h + +#include +#include +#include +#include + +#include +#include +#include + +namespace vhacd{ + + typedef struct{ + int meshCount; + QVector convexHullsCountList; + QVector> convexHullList; + }ComputeResults; + + typedef struct{ + int meshCount; + QVector> perMeshVertices; + QVector> perMeshTriangleIndices; + }LoadFBXResults; + + class VHACDUtil{ + public: + bool loadFBX(const QString filename, vhacd::LoadFBXResults *results); + bool computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const; + ~VHACDUtil(); + }; + + class ProgressCallback : public VHACD::IVHACD::IUserCallback + { + public: + ProgressCallback(void); + ~ProgressCallback(); + + //Couldn't follow coding guideline here due to virtual function declared in IUserCallback + void Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation); + }; +} +#endif //hifi_VHACDUtil_h \ No newline at end of file diff --git a/tools/vhacd/src/main.cpp b/tools/vhacd/src/main.cpp new file mode 100644 index 0000000000..55a152c179 --- /dev/null +++ b/tools/vhacd/src/main.cpp @@ -0,0 +1,102 @@ +// +// main.cpp +// tools/vhacd/src +// +// Created by Virendra Singh on 2/20/15. +// Copyright 2015 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 "VHACDUtil.h" + +using namespace std; +using namespace VHACD; + +int main(int argc, char * argv[]) +{ + vector triangles; // array of indexes + vector points; // array of coordinates + vhacd::VHACDUtil vUtil; + vhacd::LoadFBXResults fbx; //mesh data from loaded fbx file + vhacd::ComputeResults results; // results after computing vhacd + VHACD::IVHACD::Parameters params; + vhacd::ProgressCallback pCallBack; + + + QString fname = "F:/models/ship/Sample_Ship.fbx"; + + //set parameters for V-HACD + params.m_callback = &pCallBack; //progress callback + params.m_resolution = 50000; + params.m_depth = 10; + params.m_concavity = 0.003; + params.m_alpha = 0.05; // controls the bias toward clipping along symmetry planes + params.m_pca = 1; // enable/disable normalizing the mesh before applying the convex decomposition + params.m_mode = 1; // 0: voxel - based approximate convex decomposition, 1 : tetrahedron - based approximate convex decomposition + params.m_maxNumVerticesPerCH = 128; + params.m_minVolumePerCH = 0.0001; // controls the adaptive sampling of the generated convex - hulls + + // load the mesh + if (!vUtil.loadFBX(fname, &fbx)) + { + cout << "Error in opening FBX file...."; + return 1; + } + + if (!vUtil.computeVHACD(&fbx, params, &results)) + { + cout << "Compute Failed..."; + return 1; + } + + int totalVertices = 0; + for (int i = 0; i < fbx.meshCount; i++) + { + totalVertices += fbx.perMeshVertices.at(i).count(); + } + + int totalTriangles = 0; + for (int i = 0; i < fbx.meshCount; i++) + { + totalTriangles += fbx.perMeshTriangleIndices.at(i).count(); + } + + int totalHulls = 0; + QVector hullCounts = results.convexHullsCountList; + for (int i = 0; i < results.meshCount; i++) + { + totalHulls += hullCounts.at(i); + } + cout << endl << "Summary of V-HACD Computation..................." << endl; + cout << "File Path : " << fname.toStdString() << endl; + cout << "Number Of Meshes : " << fbx.meshCount << endl; + cout << "Processed Meshes : " << results.meshCount << endl; + cout << "Total vertices : " << totalVertices << endl; + cout << "Total Triangles : " << totalTriangles << endl; + cout << "Total Convex Hulls : " << totalHulls << endl; + cout << endl << "Summary per convex hull ........................" << endl < chList = results.convexHullList.at(i); + cout << "\t" << "Number Of Hulls : " << chList.count() << endl; + + for (int j = 0; j < results.convexHullList.at(i).count(); j++) + { + + cout << "\tHUll : " << j + 1 << endl; + cout << "\t\tNumber Of Points : " << chList.at(j).m_nPoints << endl; + cout << "\t\tNumber Of Triangles : " << chList.at(j).m_nTriangles << endl; + } + } + + getchar(); + return 0; +} \ No newline at end of file From 8212f86bfb614fb8fe507dc7bbce18fed98fe4ce Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Mon, 23 Feb 2015 12:19:45 +0530 Subject: [PATCH 05/31] Minor grammar corrections Corrected line breaks. --- BUILD.md | 3 ++- BUILD_WIN.md | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/BUILD.md b/BUILD.md index b956f0e70b..b94ab1ff50 100644 --- a/BUILD.md +++ b/BUILD.md @@ -8,7 +8,8 @@ * [Soxr](http://sourceforge.net/projects/soxr/) ~> 0.1.1 * [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82 * [Gverb](https://github.com/highfidelity/gverb/archive/master.zip) (direct download to latest version) -* [VHACD](https://github.com/virneo/v-hacd) +* [VHACD](https://github.com/virneo/v-hacd)(clone this repository) + #### CMake External Project Dependencies The following dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build` directory in each of the subfolders for each external project. These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. diff --git a/BUILD_WIN.md b/BUILD_WIN.md index 0f806f3bf7..f735936d0a 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -119,11 +119,17 @@ system likely has many copies of zlib1.dll, and you want High Fidelity to use th ###vhacd Download it directly from https://github.com/virneo/v-hacd -cd src\ -mkdir build -cd build -cmake .. -Build using visual studio 2013. Build ALL_BUILD and INSTALL targets both in Release and Debug. This create a output folder with include and lib directory. + +To build it run the following commands + 1. cd src\ + 2. mkdir build + 3. cd build + 4. cmake .. + +Build using visual studio 2013. Build ALL_BUILD and INSTALL targets both in Release and Debug. + +This will create an output folder with include and lib directory inside it. + Either copy that folder to ENV %HIFI_LIB_DIR%/vhacd or create an environment variable VHACD_ROOT_DIR to this output directory. ###freeglut From c15c549881c8e6c5aaace851a37142d361b4effd Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Wed, 25 Feb 2015 07:47:00 +0530 Subject: [PATCH 06/31] Code formatting --- tools/vhacd/src/VHACDUtil.cpp | 29 ++++++++++------------------- tools/vhacd/src/VHACDUtil.h | 3 +-- tools/vhacd/src/main.cpp | 24 ++++++++---------------- 3 files changed, 19 insertions(+), 37 deletions(-) diff --git a/tools/vhacd/src/VHACDUtil.cpp b/tools/vhacd/src/VHACDUtil.cpp index bfcdb74634..dcfd7e447f 100644 --- a/tools/vhacd/src/VHACDUtil.cpp +++ b/tools/vhacd/src/VHACDUtil.cpp @@ -9,13 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "VHACDUtil.h" //Read all the meshes from provided FBX file -bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *results) -{ +bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *results){ // open the fbx file QFile fbx(filename); @@ -29,15 +28,13 @@ bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *re //results->meshCount = geometry.meshes.count(); int count = 0; - foreach(FBXMesh mesh, geometry.meshes) - { + foreach(FBXMesh mesh, geometry.meshes) { //get vertices for each mesh QVector vertices = mesh.vertices; //get the triangle indices for each mesh QVector triangles; - foreach(FBXMeshPart part, mesh.parts) - { + foreach(FBXMeshPart part, mesh.parts) { QVector indices = part.triangleIndices; triangles += indices; } @@ -54,15 +51,13 @@ bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *re return true; } -bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const -{ +bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const{ VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD(); int meshCount = meshes->meshCount; int count = 0; std::cout << "Performing V-HACD computation on " << meshCount <<" meshes ..... " << std::endl; - for (int i = 0; i < meshCount; i++) - { + for (int i = 0; i < meshCount; i++){ std::vector vertices = meshes->perMeshVertices.at(i).toStdVector(); std::vector triangles = meshes->perMeshTriangleIndices.at(i).toStdVector(); @@ -71,8 +66,7 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD std::cout << "Mesh " << i + 1 << " : "; // compute approximate convex decomposition bool res = interfaceVHACD->Compute(&vertices[0].x, 3, nPoints, &triangles[0], 3, nTriangles, params); - if (!res) - { + if (!res){ std::cout << "V-HACD computation failed for Mesh : " << i + 1 << std::endl; continue; } @@ -84,8 +78,7 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD //get all the convex hulls for this mesh QVector convexHulls; - for (unsigned int j = 0; j < nConvexHulls; j++) - { + for (unsigned int j = 0; j < nConvexHulls; j++){ VHACD::IVHACD::ConvexHull hull; interfaceVHACD->GetConvexHull(j, hull); convexHulls.append(hull); @@ -105,14 +98,12 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD return false; } -vhacd::VHACDUtil:: ~VHACDUtil() -{ +vhacd::VHACDUtil:: ~VHACDUtil(){ //nothing to be cleaned } //ProgressClaback implementation -void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation) -{ +void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation){ int progress = (int)(overallProgress + 0.5); if (progress < 10) diff --git a/tools/vhacd/src/VHACDUtil.h b/tools/vhacd/src/VHACDUtil.h index a9df5d7f2a..aaabcdf904 100644 --- a/tools/vhacd/src/VHACDUtil.h +++ b/tools/vhacd/src/VHACDUtil.h @@ -42,8 +42,7 @@ namespace vhacd{ ~VHACDUtil(); }; - class ProgressCallback : public VHACD::IVHACD::IUserCallback - { + class ProgressCallback : public VHACD::IVHACD::IUserCallback{ public: ProgressCallback(void); ~ProgressCallback(); diff --git a/tools/vhacd/src/main.cpp b/tools/vhacd/src/main.cpp index 55a152c179..a80a57bb3e 100644 --- a/tools/vhacd/src/main.cpp +++ b/tools/vhacd/src/main.cpp @@ -19,8 +19,7 @@ using namespace std; using namespace VHACD; -int main(int argc, char * argv[]) -{ +int main(int argc, char * argv[]){ vector triangles; // array of indexes vector points; // array of coordinates vhacd::VHACDUtil vUtil; @@ -44,34 +43,29 @@ int main(int argc, char * argv[]) params.m_minVolumePerCH = 0.0001; // controls the adaptive sampling of the generated convex - hulls // load the mesh - if (!vUtil.loadFBX(fname, &fbx)) - { + if (!vUtil.loadFBX(fname, &fbx)){ cout << "Error in opening FBX file...."; return 1; } - if (!vUtil.computeVHACD(&fbx, params, &results)) - { + if (!vUtil.computeVHACD(&fbx, params, &results)){ cout << "Compute Failed..."; return 1; } int totalVertices = 0; - for (int i = 0; i < fbx.meshCount; i++) - { + for (int i = 0; i < fbx.meshCount; i++){ totalVertices += fbx.perMeshVertices.at(i).count(); } int totalTriangles = 0; - for (int i = 0; i < fbx.meshCount; i++) - { + for (int i = 0; i < fbx.meshCount; i++){ totalTriangles += fbx.perMeshTriangleIndices.at(i).count(); } int totalHulls = 0; QVector hullCounts = results.convexHullsCountList; - for (int i = 0; i < results.meshCount; i++) - { + for (int i = 0; i < results.meshCount; i++){ totalHulls += hullCounts.at(i); } cout << endl << "Summary of V-HACD Computation..................." << endl; @@ -82,14 +76,12 @@ int main(int argc, char * argv[]) cout << "Total Triangles : " << totalTriangles << endl; cout << "Total Convex Hulls : " << totalHulls << endl; cout << endl << "Summary per convex hull ........................" << endl < chList = results.convexHullList.at(i); cout << "\t" << "Number Of Hulls : " << chList.count() << endl; - for (int j = 0; j < results.convexHullList.at(i).count(); j++) - { + for (int j = 0; j < results.convexHullList.at(i).count(); j++){ cout << "\tHUll : " << j + 1 << endl; cout << "\t\tNumber Of Points : " << chList.at(j).m_nPoints << endl; From 9a153a6506cb6a70da655176daaf58a36261b595 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Wed, 25 Feb 2015 08:36:58 +0530 Subject: [PATCH 07/31] Time measurement Used c++11 chrono class to measure elapsed time. --- tools/vhacd/src/VHACDUtil.h | 2 +- tools/vhacd/src/main.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/vhacd/src/VHACDUtil.h b/tools/vhacd/src/VHACDUtil.h index aaabcdf904..036d4ce526 100644 --- a/tools/vhacd/src/VHACDUtil.h +++ b/tools/vhacd/src/VHACDUtil.h @@ -16,7 +16,7 @@ #include #include #include - +#include //c++11 feature #include #include #include diff --git a/tools/vhacd/src/main.cpp b/tools/vhacd/src/main.cpp index a80a57bb3e..31866a7cfc 100644 --- a/tools/vhacd/src/main.cpp +++ b/tools/vhacd/src/main.cpp @@ -27,9 +27,14 @@ int main(int argc, char * argv[]){ vhacd::ComputeResults results; // results after computing vhacd VHACD::IVHACD::Parameters params; vhacd::ProgressCallback pCallBack; - - QString fname = "F:/models/ship/Sample_Ship.fbx"; + string filename(argv[1]); + if (filename.empty()){ + cout << "please provide a FBX file as argument\n "; + return 1; + } + + QString fname = QString::fromStdString(filename); //set parameters for V-HACD params.m_callback = &pCallBack; //progress callback @@ -43,15 +48,23 @@ int main(int argc, char * argv[]){ params.m_minVolumePerCH = 0.0001; // controls the adaptive sampling of the generated convex - hulls // load the mesh + + auto begin = std::chrono::high_resolution_clock::now(); if (!vUtil.loadFBX(fname, &fbx)){ cout << "Error in opening FBX file...."; return 1; } + auto end = std::chrono::high_resolution_clock::now(); + auto loadDuration = std::chrono::duration_cast(end - begin).count(); + //perform vhacd computation + begin = std::chrono::high_resolution_clock::now(); if (!vUtil.computeVHACD(&fbx, params, &results)){ cout << "Compute Failed..."; return 1; } + end = std::chrono::high_resolution_clock::now(); + auto computeDuration = std::chrono::duration_cast(end - begin).count(); int totalVertices = 0; for (int i = 0; i < fbx.meshCount; i++){ @@ -75,6 +88,8 @@ int main(int argc, char * argv[]){ cout << "Total vertices : " << totalVertices << endl; cout << "Total Triangles : " << totalTriangles << endl; cout << "Total Convex Hulls : " << totalHulls << endl; + cout << "Total FBX load time: " << (double)loadDuration / 1000000000.00 << " seconds" << endl; + cout << "V-HACD Compute time: " << (double)computeDuration / 1000000000.00 << " seconds" << endl; cout << endl << "Summary per convex hull ........................" << endl < Date: Wed, 25 Feb 2015 08:45:00 +0530 Subject: [PATCH 08/31] cmake changes for building on linux --- cmake/modules/FindVHACD.cmake | 4 ++-- tools/vhacd/CMakeLists.txt | 14 +++++++++++++- tools/vhacd/src/VHACDUtil.cpp | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cmake/modules/FindVHACD.cmake b/cmake/modules/FindVHACD.cmake index d84ab30dff..f7eee44737 100644 --- a/cmake/modules/FindVHACD.cmake +++ b/cmake/modules/FindVHACD.cmake @@ -45,11 +45,11 @@ endmacro() find_path(VHACD_INCLUDE_DIRS VHACD.h PATH_SUFFIXES include HINTS ${VHACD_SEARCH_DIRS} $ENV{VHACD_ROOT_DIR}) -_FIND_VHACD_LIBRARY(VHACD VHACD_LIB) +_FIND_VHACD_LIBRARY(VHACD libVHACD.a) set(VHACD_LIBRARIES ${VHACD_LIBRARY}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(VHACD "Could NOT find VHACD, try to set the path to VHACD root folder in the system variable VHACD_ROOT_DIR or create a directory vhacd in HIFI_LIB_DIR and paste the necessary files there" VHACD_INCLUDE_DIRS VHACD_LIBRARIES) -mark_as_advanced(VHACD_INCLUDE_DIRS VHACD_LIBRARIES VHACD_SEARCH_DIRS) \ No newline at end of file +mark_as_advanced(VHACD_INCLUDE_DIRS VHACD_LIBRARIES VHACD_SEARCH_DIRS) diff --git a/tools/vhacd/CMakeLists.txt b/tools/vhacd/CMakeLists.txt index ee82cd599d..51e15c8239 100644 --- a/tools/vhacd/CMakeLists.txt +++ b/tools/vhacd/CMakeLists.txt @@ -6,8 +6,20 @@ find_package(VHACD REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${VHACD_INCLUDE_DIRS}) target_link_libraries(${TARGET_NAME} ${VHACD_LIBRARIES}) +if(NOT WIN32) + find_package( Threads) + target_link_libraries(${TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT}) + + include(FindOpenMP) + if(OPENMP_FOUND) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + endif() +endif() + add_dependency_external_project(glm) find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) -include_dependency_includes() \ No newline at end of file +include_dependency_includes() diff --git a/tools/vhacd/src/VHACDUtil.cpp b/tools/vhacd/src/VHACDUtil.cpp index bfcdb74634..71ee2740c1 100644 --- a/tools/vhacd/src/VHACDUtil.cpp +++ b/tools/vhacd/src/VHACDUtil.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "VHACDUtil.h" @@ -127,4 +127,4 @@ void vhacd::ProgressCallback::Update(const double overallProgress, const double } vhacd::ProgressCallback::ProgressCallback(void){} -vhacd::ProgressCallback::~ProgressCallback(){} \ No newline at end of file +vhacd::ProgressCallback::~ProgressCallback(){} From ed09b619d14a50de8c3c741851dad969e80f92e2 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Wed, 25 Feb 2015 09:12:19 +0530 Subject: [PATCH 09/31] OS check check OS for different filenames --- cmake/modules/FindVHACD.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/modules/FindVHACD.cmake b/cmake/modules/FindVHACD.cmake index f7eee44737..03e30b41d4 100644 --- a/cmake/modules/FindVHACD.cmake +++ b/cmake/modules/FindVHACD.cmake @@ -45,7 +45,11 @@ endmacro() find_path(VHACD_INCLUDE_DIRS VHACD.h PATH_SUFFIXES include HINTS ${VHACD_SEARCH_DIRS} $ENV{VHACD_ROOT_DIR}) +if(NOT WIN32) _FIND_VHACD_LIBRARY(VHACD libVHACD.a) +else() +_FIND_VHACD_LIBRARY(VHACD VHACD_LIB) +endif() set(VHACD_LIBRARIES ${VHACD_LIBRARY}) include(FindPackageHandleStandardArgs) From 5776df10122322b25bc59f4d9aa527f5eb7bcf1d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 25 Feb 2015 12:07:19 -0800 Subject: [PATCH 10/31] load dynamic obj as inactive when not moving --- libraries/physics/src/EntityMotionState.cpp | 4 ++++ libraries/physics/src/EntityMotionState.h | 26 +++++++++++---------- libraries/physics/src/ObjectMotionState.h | 2 ++ libraries/physics/src/PhysicsEngine.cpp | 4 ++++ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 810bf9a6a8..699b4cc386 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -63,6 +63,10 @@ void EntityMotionState::stepKinematicSimulation(quint64 now) { _entity->simulate(now); } +bool EntityMotionState::isMoving() const { + return _entity->isMoving(); +} + // This callback is invoked by the physics simulation in two cases: // (1) when the RigidBody is first added to the world // (irregardless of MotionType: STATIC, DYNAMIC, or KINEMATIC) diff --git a/libraries/physics/src/EntityMotionState.h b/libraries/physics/src/EntityMotionState.h index 5d98e545d9..7214626fc4 100644 --- a/libraries/physics/src/EntityMotionState.h +++ b/libraries/physics/src/EntityMotionState.h @@ -36,28 +36,30 @@ public: virtual ~EntityMotionState(); /// \return MOTION_TYPE_DYNAMIC or MOTION_TYPE_STATIC based on params set in EntityItem - MotionType computeMotionType() const; + virtual MotionType computeMotionType() const; - void updateKinematicState(uint32_t substep); - void stepKinematicSimulation(quint64 now); + virtual void updateKinematicState(uint32_t substep); + virtual void stepKinematicSimulation(quint64 now); + + virtual bool isMoving() const; // this relays incoming position/rotation to the RigidBody - void getWorldTransform(btTransform& worldTrans) const; + virtual void getWorldTransform(btTransform& worldTrans) const; // this relays outgoing position/rotation to the EntityItem - void setWorldTransform(const btTransform& worldTrans); + virtual void setWorldTransform(const btTransform& worldTrans); // these relay incoming values to the RigidBody - void updateObjectEasy(uint32_t flags, uint32_t frame); - void updateObjectVelocities(); + virtual void updateObjectEasy(uint32_t flags, uint32_t frame); + virtual void updateObjectVelocities(); - void computeShapeInfo(ShapeInfo& shapeInfo); - float computeMass(const ShapeInfo& shapeInfo) const; + virtual void computeShapeInfo(ShapeInfo& shapeInfo); + virtual float computeMass(const ShapeInfo& shapeInfo) const; - void sendUpdate(OctreeEditPacketSender* packetSender, uint32_t frame); + virtual void sendUpdate(OctreeEditPacketSender* packetSender, uint32_t frame); - uint32_t getIncomingDirtyFlags() const; - void clearIncomingDirtyFlags(uint32_t flags) { _entity->clearDirtyFlags(flags); } + virtual uint32_t getIncomingDirtyFlags() const; + virtual void clearIncomingDirtyFlags(uint32_t flags) { _entity->clearDirtyFlags(flags); } EntityItem* getEntity() const { return _entity; } diff --git a/libraries/physics/src/ObjectMotionState.h b/libraries/physics/src/ObjectMotionState.h index ceeea219cf..fb402a178d 100644 --- a/libraries/physics/src/ObjectMotionState.h +++ b/libraries/physics/src/ObjectMotionState.h @@ -101,6 +101,8 @@ public: void setKinematic(bool kinematic, uint32_t substep); virtual void stepKinematicSimulation(quint64 now) = 0; + virtual bool isMoving() const = 0; + friend class PhysicsEngine; protected: void setRigidBody(btRigidBody* body); diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 461d15114c..10c7f42546 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -439,6 +439,10 @@ void PhysicsEngine::addObject(const ShapeInfo& shapeInfo, btCollisionShape* shap const float DYNAMIC_LINEAR_VELOCITY_THRESHOLD = 0.05f; // 5 cm/sec const float DYNAMIC_ANGULAR_VELOCITY_THRESHOLD = 0.087266f; // ~5 deg/sec body->setSleepingThresholds(DYNAMIC_LINEAR_VELOCITY_THRESHOLD, DYNAMIC_ANGULAR_VELOCITY_THRESHOLD); + if (!motionState->isMoving()) { + // try to initialize this object as inactive + body->forceActivationState(ISLAND_SLEEPING); + } break; } case MOTION_TYPE_STATIC: From 434c0b569f51c10825acd0cbde7299803912a58e Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Thu, 26 Feb 2015 06:28:28 +0530 Subject: [PATCH 11/31] Make vhacd tool optional --- tools/CMakeLists.txt | 4 ++++ tools/vhacd/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 57fe18c53f..003920a442 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -3,4 +3,8 @@ add_subdirectory(bitstream2json) add_subdirectory(json2bitstream) add_subdirectory(mtc) add_subdirectory(scribe) + +find_package(VHACD) +if(VHACD_FOUND) add_subdirectory(vhacd) +endif() diff --git a/tools/vhacd/CMakeLists.txt b/tools/vhacd/CMakeLists.txt index 51e15c8239..db0cc13e67 100644 --- a/tools/vhacd/CMakeLists.txt +++ b/tools/vhacd/CMakeLists.txt @@ -2,7 +2,7 @@ set(TARGET_NAME vhacd) setup_hifi_project() link_hifi_libraries(shared model fbx gpu networking octree) -find_package(VHACD REQUIRED) +#find_package(VHACD REQUIRED) done in CMakeList.txt in parent directory target_include_directories(${TARGET_NAME} PUBLIC ${VHACD_INCLUDE_DIRS}) target_link_libraries(${TARGET_NAME} ${VHACD_LIBRARIES}) From ce60bb40d73aa24e4e338ed42dbfe10c5422f739 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Thu, 26 Feb 2015 22:32:47 +0530 Subject: [PATCH 12/31] removed tags for *.md files --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index aee74ebddc..3b44b99e68 100644 --- a/.gitignore +++ b/.gitignore @@ -46,5 +46,4 @@ libraries/audio-client/external/*/* gvr-interface/assets/oculussig* gvr-interface/libs/* -TAGS -*.md \ No newline at end of file +TAGS \ No newline at end of file From bdb79f261952f5c081c1b377ca8fe556bd098cef Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Thu, 26 Feb 2015 22:56:21 +0530 Subject: [PATCH 13/31] Resetting from master --- BUILD.md | 9 +-------- BUILD_WIN.md | 43 +++++++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/BUILD.md b/BUILD.md index b94ab1ff50..82cbf6628c 100644 --- a/BUILD.md +++ b/BUILD.md @@ -2,20 +2,13 @@ * [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2 * [Qt](http://qt-project.org/downloads) ~> 5.3.2 +* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4 * [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g * IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability. * [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3 * [Soxr](http://sourceforge.net/projects/soxr/) ~> 0.1.1 * [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82 * [Gverb](https://github.com/highfidelity/gverb/archive/master.zip) (direct download to latest version) -* [VHACD](https://github.com/virneo/v-hacd)(clone this repository) - -#### CMake External Project Dependencies - -The following dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build` directory in each of the subfolders for each external project. These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. - -* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4 -* [gverb](https://github.com/highfidelity/gverb) ### OS Specific Build Guides * [BUILD_OSX.md](BUILD_OSX.md) - additional instructions for OS X. diff --git a/BUILD_WIN.md b/BUILD_WIN.md index f735936d0a..8022fae5b8 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -56,6 +56,9 @@ The recommended route for CMake to find the external dependencies is to place al -> bin -> include -> lib + -> glm + -> glm + -> glm.hpp -> openssl -> bin -> include @@ -67,9 +70,6 @@ The recommended route for CMake to find the external dependencies is to place al -> include -> lib -> test - -> vhacd - -> include - -> lib For many of the external libraries where precompiled binaries are readily available you should be able to simply copy the extracted folder that you get from the download links provided at the top of the guide. Otherwise you may need to build from source and install the built product to this directory. The `root_lib_dir` in the above example can be wherever you choose on your system - as long as the environment variable HIFI_LIB_DIR is set to it. From here on, whenever you see %HIFI_LIB_DIR% you should substitute the directory that you chose. @@ -117,21 +117,6 @@ Add to the PATH: `%HIFI_LIB_DIR%\zlib` Important! This should be added at the beginning of the path, not the end (your system likely has many copies of zlib1.dll, and you want High Fidelity to use the correct version). If High Fidelity picks up the wrong zlib1.dll then it might be unable to use it, and that would cause it to fail to start, showing only the cryptic error "The application was unable to start correctly: 0xc0000022". -###vhacd -Download it directly from https://github.com/virneo/v-hacd - -To build it run the following commands - 1. cd src\ - 2. mkdir build - 3. cd build - 4. cmake .. - -Build using visual studio 2013. Build ALL_BUILD and INSTALL targets both in Release and Debug. - -This will create an output folder with include and lib directory inside it. - -Either copy that folder to ENV %HIFI_LIB_DIR%/vhacd or create an environment variable VHACD_ROOT_DIR to this output directory. - ###freeglut Download the binary package: `freeglut-MSVC-2.8.1-1.mp.zip`. Extract to %HIFI_LIB_DIR%\freeglut. @@ -144,6 +129,26 @@ Download the binary package: `glew-1.10.0-win32.zip`. Extract to %HIFI_LIB_DIR%\ Add to the PATH: `%HIFI_LIB_DIR%\glew\bin\Release\Win32` +###GLM + +This package contains only headers, so there's nothing to add to the PATH. + +Be careful with glm. For the folder other libraries would normally call 'include', the folder containing the headers, glm opts to use 'glm'. You will have a glm folder nested inside the top-level glm folder. + +###Gverb + +1. Go to https://github.com/highfidelity/gverb + Or download the sources directly via this link: + https://github.com/highfidelity/gverb/archive/master.zip + +2. Extract the archive + +3. Place the directories “include” and “src” in interface/external/gverb + (Normally next to this readme) + +4. Clear your build directory, run cmake, build and you should be all set. + + ###Bullet Bullet 2.82 source can be [downloaded here](https://code.google.com/p/bullet/downloads/detail?name=bullet-2.82-r2704.zip). Bullet does not come with prebuilt libraries, you need to make those yourself. @@ -181,8 +186,6 @@ We recommend you install it to %HIFI_LIB_DIR%\soxr. This will help our FindSoxr Extract the soxr archive wherever you like. Then, inside the extracted folder, create a directory called `build`. From that build directory, the following commands will build and then install soxr to `%HIFI_LIB_DIR%`. -(Make sure to run the following inside Visual Studio) - ``` cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%HIFI_LIB_DIR%/soxr nmake From 0918d4989b342f9380e77dc6cd2e00cbaa0483df Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 26 Feb 2015 09:53:23 -0800 Subject: [PATCH 14/31] mv ShutdownEventListener into class which is a child of QCoreApplication --- assignment-client/src/AssignmentClientApp.cpp | 8 ++++++++ assignment-client/src/AssignmentClientMonitor.cpp | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/assignment-client/src/AssignmentClientApp.cpp b/assignment-client/src/AssignmentClientApp.cpp index 26b6b8675a..6e269f35b7 100644 --- a/assignment-client/src/AssignmentClientApp.cpp +++ b/assignment-client/src/AssignmentClientApp.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "Assignment.h" #include "AssignmentClient.h" @@ -173,6 +174,13 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : if (numForks || minForks || maxForks) { + // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us +# ifdef _WIN32 + installNativeEventFilter(&ShutdownEventListener::getInstance()); +# else + ShutdownEventListener::getInstance(); +# endif + AssignmentClientMonitor monitor(numForks, minForks, maxForks, assignmentPool, walletUUID, assignmentServerHostname, assignmentServerPort); exec(); diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 29fda05ee1..ffc402c04d 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include "AssignmentClientMonitor.h" @@ -40,13 +39,6 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen { // start the Logging class with the parent's target name LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_MONITOR_TARGET_NAME); - - // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us -#ifdef _WIN32 - installNativeEventFilter(&ShutdownEventListener::getInstance()); -#else - ShutdownEventListener::getInstance(); -#endif // create a NodeList so we can receive stats from children DependencyManager::registerInheritance(); From 7c7d727b55a878d4a3610dff083be0067502f5cb Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 26 Feb 2015 10:07:48 -0800 Subject: [PATCH 15/31] mv ShutdownEventListener into class which is a child of QCoreApplication --- assignment-client/src/AssignmentClient.cpp | 7 ------- assignment-client/src/AssignmentClientApp.cpp | 15 +++++++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index 38f5c7cc55..86680d2f03 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -58,13 +58,6 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri // when the domain server hands over an assignment. QUuid nodeUUID = QUuid::createUuid(); nodeList->setSessionUUID(nodeUUID); - - // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us -#ifdef _WIN32 - installNativeEventFilter(&ShutdownEventListener::getInstance()); -#else - ShutdownEventListener::getInstance(); -#endif // set the logging target to the the CHILD_TARGET_NAME LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME); diff --git a/assignment-client/src/AssignmentClientApp.cpp b/assignment-client/src/AssignmentClientApp.cpp index 6e269f35b7..7c6fb50db2 100644 --- a/assignment-client/src/AssignmentClientApp.cpp +++ b/assignment-client/src/AssignmentClientApp.cpp @@ -29,6 +29,14 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : setvbuf(stdout, NULL, _IOLBF, 0); # endif + +# ifdef _WIN32 + installNativeEventFilter(&ShutdownEventListener::getInstance()); +# else + ShutdownEventListener::getInstance(); +# endif + + setOrganizationName("High Fidelity"); setOrganizationDomain("highfidelity.io"); setApplicationName("assignment-client"); @@ -175,16 +183,11 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : if (numForks || minForks || maxForks) { // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us -# ifdef _WIN32 - installNativeEventFilter(&ShutdownEventListener::getInstance()); -# else - ShutdownEventListener::getInstance(); -# endif - AssignmentClientMonitor monitor(numForks, minForks, maxForks, assignmentPool, walletUUID, assignmentServerHostname, assignmentServerPort); exec(); } else { + // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us AssignmentClient client(requestAssignmentType, assignmentPool, walletUUID, assignmentServerHostname, assignmentServerPort); exec(); From 8eb4abc49cb8c23c344be69a2e50e813b6b32bf2 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 26 Feb 2015 19:14:09 +0100 Subject: [PATCH 16/31] Rework FaceTracker --- interface/src/devices/FaceTracker.cpp | 5 ++--- interface/src/devices/FaceTracker.h | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/interface/src/devices/FaceTracker.cpp b/interface/src/devices/FaceTracker.cpp index 52fe04de77..8d61789715 100644 --- a/interface/src/devices/FaceTracker.cpp +++ b/interface/src/devices/FaceTracker.cpp @@ -11,7 +11,6 @@ #include "FaceTracker.h" -FaceTracker::FaceTracker() : - _estimatedEyePitch(0.0f), - _estimatedEyeYaw(0.0f) { +inline float FaceTracker::getBlendshapeCoefficient(int index) const { + return isValidBlendshapeIndex(index) ? _blendshapeCoefficients[index] : 0.0f; } diff --git a/interface/src/devices/FaceTracker.h b/interface/src/devices/FaceTracker.h index 7c367b7899..07c479e3e3 100644 --- a/interface/src/devices/FaceTracker.h +++ b/interface/src/devices/FaceTracker.h @@ -18,13 +18,17 @@ #include #include -/// Base class for face trackers (Faceshift, Visage). +/// Base class for face trackers (Faceshift, Visage, DDE). class FaceTracker : public QObject { Q_OBJECT public: - FaceTracker(); - virtual ~FaceTracker() {} + virtual bool isActive() const { return false; } + virtual bool isTracking() const { return false; } + + virtual void init() {} + virtual void update(float deltaTime) {} + virtual void reset() {} const glm::vec3& getHeadTranslation() const { return _headTranslation; } const glm::quat& getHeadRotation() const { return _headRotation; } @@ -32,15 +36,21 @@ public: float getEstimatedEyePitch() const { return _estimatedEyePitch; } float getEstimatedEyeYaw() const { return _estimatedEyeYaw; } + int getNumBlendshapes() const { return _blendshapeCoefficients.size(); } + bool isValidBlendshapeIndex(int index) const { return index >= 0 && index < getNumBlendshapes(); } const QVector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } + float getBlendshapeCoefficient(int index) const; protected: - glm::vec3 _headTranslation; - glm::quat _headRotation; - float _estimatedEyePitch; - float _estimatedEyeYaw; + + glm::vec3 _headTranslation = glm::vec3(0.0f); + glm::quat _headRotation = glm::quat(); + float _estimatedEyePitch = 0.0f; + float _estimatedEyeYaw = 0.0f; QVector _blendshapeCoefficients; + + float _fadeCoefficient = 0.0f; }; #endif // hifi_FaceTracker_h From b6968a6b1538875504b4f90b6d71038b13b75850 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 26 Feb 2015 19:15:49 +0100 Subject: [PATCH 17/31] Update Facetrackers --- interface/src/devices/DdeFaceTracker.cpp | 18 +---- interface/src/devices/DdeFaceTracker.h | 10 ++- interface/src/devices/Faceshift.cpp | 73 ++++++------------- interface/src/devices/Faceshift.h | 89 ++++++++++++------------ interface/src/devices/Visage.cpp | 3 +- interface/src/devices/Visage.h | 10 +-- 6 files changed, 77 insertions(+), 126 deletions(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 87a180bd1e..ed0e4057ef 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -50,6 +50,8 @@ DdeFaceTracker::DdeFaceTracker() : } DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 port) : + _host(host), + _port(port), _lastReceiveTimestamp(0), _reset(false), _leftBlinkIndex(0), // see http://support.faceshift.com/support/articles/35129-export-of-blendshapes @@ -63,9 +65,7 @@ DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 port) : _browUpRightIndex(18), _mouthSmileLeftIndex(28), _mouthSmileRightIndex(29), - _jawOpenIndex(21), - _host(host), - _port(port) + _jawOpenIndex(21) { _blendshapeCoefficients.resize(NUM_EXPRESSION); @@ -80,18 +80,6 @@ DdeFaceTracker::~DdeFaceTracker() { } } -void DdeFaceTracker::init() { - -} - -void DdeFaceTracker::reset() { - _reset = true; -} - -void DdeFaceTracker::update() { - -} - void DdeFaceTracker::setEnabled(bool enabled) { // isOpen() does not work as one might expect on QUdpSocket; don't test isOpen() before closing socket. _udpSocket.close(); diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index bd5d066732..88528370a2 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -23,12 +23,10 @@ class DdeFaceTracker : public FaceTracker, public Dependency { SINGLETON_DEPENDENCY public: - //initialization - void init(); - void reset(); - void update(); - - bool isActive() const; + virtual void reset() { _reset = true; } + + virtual bool isActive() const; + virtual bool isTracking() const { return isActive(); } float getLeftBlink() const { return getBlendshapeCoefficient(_leftBlinkIndex); } float getRightBlink() const { return getBlendshapeCoefficient(_rightBlinkIndex); } diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 2f541c1c4e..87ee0ef31c 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -25,37 +25,11 @@ using namespace fs; using namespace std; +const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost"; const quint16 FACESHIFT_PORT = 33433; -float STARTING_FACESHIFT_FRAME_TIME = 0.033f; +const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; Faceshift::Faceshift() : - _tcpEnabled(true), - _tcpRetryCount(0), - _lastTrackingStateReceived(0), - _averageFrameTime(STARTING_FACESHIFT_FRAME_TIME), - _headAngularVelocity(0), - _headLinearVelocity(0), - _lastHeadTranslation(0), - _filteredHeadTranslation(0), - _eyeGazeLeftPitch(0.0f), - _eyeGazeLeftYaw(0.0f), - _eyeGazeRightPitch(0.0f), - _eyeGazeRightYaw(0.0f), - _leftBlinkIndex(0), // see http://support.faceshift.com/support/articles/35129-export-of-blendshapes - _rightBlinkIndex(1), - _leftEyeOpenIndex(8), - _rightEyeOpenIndex(9), - _browDownLeftIndex(14), - _browDownRightIndex(15), - _browUpCenterIndex(16), - _browUpLeftIndex(17), - _browUpRightIndex(18), - _mouthSmileLeftIndex(28), - _mouthSmileRightIndex(29), - _jawOpenIndex(21), - _longTermAverageEyePitch(0.0f), - _longTermAverageEyeYaw(0.0f), - _longTermAverageInitialized(false), _eyeDeflection("faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION), _hostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME) { @@ -71,31 +45,15 @@ Faceshift::Faceshift() : #endif } +#ifdef HAVE_FACESHIFT void Faceshift::init() { -#ifdef HAVE_FACESHIFT setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift)); -#endif } -bool Faceshift::isConnectedOrConnecting() const { - return _tcpSocket.state() == QAbstractSocket::ConnectedState || - (_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState); -} - -bool Faceshift::isActive() const { -#ifdef HAVE_FACESHIFT - const quint64 ACTIVE_TIMEOUT_USECS = 1000000; - return (usecTimestampNow() - _lastTrackingStateReceived) < ACTIVE_TIMEOUT_USECS; -#else - return false; -#endif -} - -void Faceshift::update() { +void Faceshift::update(float deltaTime) { if (!isActive()) { return; } - PerformanceTimer perfTimer("faceshift"); // get the euler angles relative to the window glm::vec3 eulers = glm::degrees(safeEulerAngles(_headRotation * glm::quat(glm::radians(glm::vec3( (_eyeGazeLeftPitch + _eyeGazeRightPitch) / 2.0f, (_eyeGazeLeftYaw + _eyeGazeRightYaw) / 2.0f, 0.0f))))); @@ -116,14 +74,28 @@ void Faceshift::update() { } void Faceshift::reset() { -#ifdef HAVE_FACESHIFT if (_tcpSocket.state() == QAbstractSocket::ConnectedState) { string message; fsBinaryStream::encode_message(message, fsMsgCalibrateNeutral()); send(message); } _longTermAverageInitialized = false; +} + +bool Faceshift::isActive() const { + const quint64 ACTIVE_TIMEOUT_USECS = 1000000; + return (usecTimestampNow() - _lastTrackingStateReceived) < ACTIVE_TIMEOUT_USECS; +} + +bool Faceshift::isTracking() const { + return isActive() && _tracking; +} #endif + + +bool Faceshift::isConnectedOrConnecting() const { + return _tcpSocket.state() == QAbstractSocket::ConnectedState || + (_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState); } void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp, @@ -148,12 +120,13 @@ void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float } void Faceshift::setTCPEnabled(bool enabled) { +#ifdef HAVE_FACESHIFT if ((_tcpEnabled = enabled)) { connectSocket(); - } else { _tcpSocket.disconnectFromHost(); } +#endif } void Faceshift::connectSocket() { @@ -202,10 +175,6 @@ void Faceshift::readFromSocket() { receive(_tcpSocket.readAll()); } -float Faceshift::getBlendshapeCoefficient(int index) const { - return (index >= 0 && index < (int)_blendshapeCoefficients.size()) ? _blendshapeCoefficients[index] : 0.0f; -} - void Faceshift::send(const std::string& message) { _tcpSocket.write(message.data(), message.size()); } diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index 0cef3d3e13..f224448b8e 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -24,8 +24,7 @@ #include "FaceTracker.h" -const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; -const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost"; +const float STARTING_FACESHIFT_FRAME_TIME = 0.033f; /// Handles interaction with the Faceshift software, which provides head position/orientation and facial features. class Faceshift : public FaceTracker, public Dependency { @@ -33,11 +32,17 @@ class Faceshift : public FaceTracker, public Dependency { SINGLETON_DEPENDENCY public: - void init(); +#ifdef HAVE_FACESHIFT + // If we don't have faceshift, use the base class' methods + virtual void init(); + virtual void update(float deltaTime); + virtual void reset(); - bool isConnectedOrConnecting() const; + virtual bool isActive() const; + virtual bool isTracking() const; +#endif - bool isActive() const; + bool isConnectedOrConnecting() const; const glm::vec3& getHeadAngularVelocity() const { return _headAngularVelocity; } @@ -68,9 +73,6 @@ public: QString getHostname() { return _hostname.get(); } void setHostname(const QString& hostname); - - void update(); - void reset(); void updateFakeCoefficients(float leftBlink, float rightBlink, @@ -82,15 +84,12 @@ public: QVector& coefficients) const; signals: - void connectionStateChanged(); public slots: - void setTCPEnabled(bool enabled); private slots: - void connectSocket(); void noteConnected(); void noteError(QAbstractSocket::SocketError error); @@ -101,8 +100,6 @@ private: Faceshift(); virtual ~Faceshift() {} - float getBlendshapeCoefficient(int index) const; - void send(const std::string& message); void receive(const QByteArray& buffer); @@ -113,48 +110,48 @@ private: fs::fsBinaryStream _stream; #endif - bool _tcpEnabled; - int _tcpRetryCount; - bool _tracking; - quint64 _lastTrackingStateReceived; - float _averageFrameTime; + bool _tcpEnabled = true; + int _tcpRetryCount = 0; + bool _tracking = false; + quint64 _lastTrackingStateReceived = 0; + float _averageFrameTime = STARTING_FACESHIFT_FRAME_TIME; - glm::vec3 _headAngularVelocity; - glm::vec3 _headLinearVelocity; - glm::vec3 _lastHeadTranslation; - glm::vec3 _filteredHeadTranslation; + glm::vec3 _headAngularVelocity = glm::vec3(0.0f); + glm::vec3 _headLinearVelocity = glm::vec3(0.0f); + glm::vec3 _lastHeadTranslation = glm::vec3(0.0f); + glm::vec3 _filteredHeadTranslation = glm::vec3(0.0f); // degrees - float _eyeGazeLeftPitch; - float _eyeGazeLeftYaw; - float _eyeGazeRightPitch; - float _eyeGazeRightYaw; - - int _leftBlinkIndex; - int _rightBlinkIndex; - int _leftEyeOpenIndex; - int _rightEyeOpenIndex; - - // Brows - int _browDownLeftIndex; - int _browDownRightIndex; - int _browUpCenterIndex; - int _browUpLeftIndex; - int _browUpRightIndex; - - int _mouthSmileLeftIndex; - int _mouthSmileRightIndex; - - int _jawOpenIndex; + float _eyeGazeLeftPitch = 0.0f; + float _eyeGazeLeftYaw = 0.0f; + float _eyeGazeRightPitch = 0.0f; + float _eyeGazeRightYaw = 0.0f; // degrees - float _longTermAverageEyePitch; - float _longTermAverageEyeYaw; - bool _longTermAverageInitialized; + float _longTermAverageEyePitch = 0.0f; + float _longTermAverageEyeYaw = 0.0f; + bool _longTermAverageInitialized = false; Setting::Handle _eyeDeflection; Setting::Handle _hostname; + // see http://support.faceshift.com/support/articles/35129-export-of-blendshapes + int _leftBlinkIndex = 0; + int _rightBlinkIndex = 1; + int _leftEyeOpenIndex = 8; + int _rightEyeOpenIndex = 9; + + // Brows + int _browDownLeftIndex = 14; + int _browDownRightIndex = 15; + int _browUpCenterIndex = 16; + int _browUpLeftIndex = 17; + int _browUpRightIndex = 18; + + int _mouthSmileLeftIndex = 28; + int _mouthSmileRightIndex = 29; + + int _jawOpenIndex = 21; }; #endif // hifi_Faceshift_h diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 39bda83e61..45c19a6ab3 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -126,13 +126,12 @@ void Visage::init() { updateEnabled(); } -void Visage::update() { +void Visage::update(float deltaTime) { #ifdef HAVE_VISAGE _active = (_tracker->getTrackingData(_data) == TRACK_STAT_OK); if (!_active) { return; } - PerformanceTimer perfTimer("visage"); _headRotation = glm::quat(glm::vec3(-_data->faceRotation[0], -_data->faceRotation[1], _data->faceRotation[2])); _headTranslation = (glm::vec3(_data->faceTranslation[0], _data->faceTranslation[1], _data->faceTranslation[2]) - _headOrigin) * TRANSLATION_SCALE; diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 690a9f3066..cd2ec3ecad 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -31,12 +31,12 @@ class Visage : public FaceTracker, public Dependency { SINGLETON_DEPENDENCY public: - void init(); + virtual void init(); + virtual void update(float deltaTime); + virtual void reset(); - bool isActive() const { return _active; } - - void update(); - void reset(); + virtual bool isActive() const { return _active; } + virtual bool isTracking() const { return isActive(); } public slots: From f560f97c6b5c1ed0b3381a8be5439843caaeec51 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 26 Feb 2015 19:18:05 +0100 Subject: [PATCH 18/31] Only update active FaceTracker --- interface/src/Application.cpp | 36 ++++------------------------------- interface/src/Application.h | 3 --- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0bdd8f8f53..e1b4aa40ea 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1859,35 +1859,6 @@ void Application::updateMouseRay() { } } -void Application::updateFaceshift() { - bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); - PerformanceWarning warn(showWarnings, "Application::updateFaceshift()"); - auto faceshift = DependencyManager::get(); - // Update faceshift - faceshift->update(); - - // Copy angular velocity if measured by faceshift, to the head - if (faceshift->isActive()) { - _myAvatar->getHead()->setAngularVelocity(faceshift->getHeadAngularVelocity()); - } -} - -void Application::updateVisage() { - bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); - PerformanceWarning warn(showWarnings, "Application::updateVisage()"); - - // Update Visage - DependencyManager::get()->update(); -} - -void Application::updateDDE() { - bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); - PerformanceWarning warn(showWarnings, "Application::updateDDE()"); - - // Update Cara - DependencyManager::get()->update(); -} - void Application::updateMyAvatarLookAtPosition() { PerformanceTimer perfTimer("lookAt"); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); @@ -2067,12 +2038,13 @@ void Application::update(float deltaTime) { { PerformanceTimer perfTimer("devices"); DeviceTracker::updateAll(); - updateFaceshift(); - updateVisage(); + FaceTracker* tracker = getActiveFaceTracker(); + if (tracker) { + tracker->update(deltaTime); + } SixenseManager::getInstance().update(deltaTime); JoystickScriptingInterface::getInstance().update(); _prioVR.update(deltaTime); - } // Dispatch input events diff --git a/interface/src/Application.h b/interface/src/Application.h index 9cd19c8259..4a8e712d30 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -421,9 +421,6 @@ private: // Various helper functions called during update() void updateLOD(); void updateMouseRay(); - void updateFaceshift(); - void updateVisage(); - void updateDDE(); void updateMyAvatarLookAtPosition(); void updateThreads(float deltaTime); void updateMetavoxels(float deltaTime); From 682b3f5e61c109a659e8f2ea11a2926b92dc6049 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 26 Feb 2015 19:18:52 +0100 Subject: [PATCH 19/31] Remove unused angular velocity --- interface/src/avatar/Head.cpp | 1 - interface/src/avatar/Head.h | 4 ---- 2 files changed, 5 deletions(-) diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 52f1b3ee86..a6458c7a22 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -42,7 +42,6 @@ Head::Head(Avatar* owningAvatar) : _mouth2(0.0f), _mouth3(0.0f), _mouth4(0.0f), - _angularVelocity(0,0,0), _renderLookatVectors(false), _saccade(0.0f, 0.0f, 0.0f), _saccadeTarget(0.0f, 0.0f, 0.0f), diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 89eea35903..6c53c2d7aa 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -55,9 +55,6 @@ public: /// \return orientationBody * orientationBasePitch glm::quat getCameraOrientation () const; - - const glm::vec3& getAngularVelocity() const { return _angularVelocity; } - void setAngularVelocity(glm::vec3 angularVelocity) { _angularVelocity = angularVelocity; } void setCorrectedLookAtPosition(glm::vec3 correctedLookAtPosition); glm::vec3 getCorrectedLookAtPosition(); @@ -130,7 +127,6 @@ private: float _mouth2; float _mouth3; float _mouth4; - glm::vec3 _angularVelocity; bool _renderLookatVectors; glm::vec3 _saccade; glm::vec3 _saccadeTarget; From e37ef226fc6b04378d2d8ce48960dc49d5cd4312 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 26 Feb 2015 19:21:14 +0100 Subject: [PATCH 20/31] Simplify lookForward compute --- interface/src/avatar/MyAvatar.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index ba628ea0d4..9cdd38dbc8 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -892,13 +892,7 @@ void MyAvatar::updateLookAtTargetAvatar() { _lookAtTargetAvatar.clear(); _targetAvatarPosition = glm::vec3(0.0f); - glm::quat faceRotation = Application::getInstance()->getViewFrustum()->getOrientation(); - FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); - if (tracker) { - // If faceshift or other face tracker in use, add on the actual angle of the head - faceRotation *= tracker->getHeadRotation(); - } - glm::vec3 lookForward = faceRotation * IDENTITY_FRONT; + glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FRONT; glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition(); float smallestAngleTo = glm::radians(Application::getInstance()->getCamera()->getFieldOfView()) / 2.0f; From 36c3131524a2005cdc11e76ffaf8434751b8f4fd Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Fri, 27 Feb 2015 00:14:46 +0530 Subject: [PATCH 21/31] Rectifying bad merge in BUILD.md and BUILD_WIN.md --- BUILD.md | 37 ++++++--- BUILD_WIN.md | 153 +++++-------------------------------- tools/vhacd/CMakeLists.txt | 4 +- tools/vhacd/src/main.cpp | 5 +- 4 files changed, 50 insertions(+), 149 deletions(-) diff --git a/BUILD.md b/BUILD.md index 82cbf6628c..98b8cffab1 100644 --- a/BUILD.md +++ b/BUILD.md @@ -2,15 +2,31 @@ * [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2 * [Qt](http://qt-project.org/downloads) ~> 5.3.2 -* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4 * [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g * IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability. -* [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3 -* [Soxr](http://sourceforge.net/projects/soxr/) ~> 0.1.1 -* [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82 -* [Gverb](https://github.com/highfidelity/gverb/archive/master.zip) (direct download to latest version) -### OS Specific Build Guides +####CMake External Project Dependencies + +* [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82 +* [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3 +* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4 +* [gverb](https://github.com/highfidelity/gverb) +* [Soxr](http://sourceforge.net/projects/soxr/) ~> 0.1.1 + +The following external projects are optional dependencies. You can indicate to CMake that you would like to include them by passing -DGET_$NAME=1 when running a clean CMake build. For example, to get CMake to download and compile QXmpp you would pass -DGET_QXMPP=1. + +* [SDL2](https://www.libsdl.org/download-2.0.php) ~> 2.0.3 + * Enables game controller support in Interface +* [QXmpp](https://github.com/qxmpp-project/qxmpp) ~> 0.7.6 + * Enables text chat support in Interface + +The above dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build-ext` directory in each of the subfolders for each external project. + +These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. Should you want to force a re-download and re-compile of a specific external, you can simply remove that directory from the appropriate subfolder in `build-ext`. Should you want to force a re-download and re-compile of all externals, just remove the `build-ext` folder. + +If you would like to use a specific install of a dependency instead of the version that would be grabbed as a CMake ExternalProject, you can pass -DGET_$NAME=0 (where $NAME is the name of the subfolder in [cmake/externals](cmake/externals)) when you run CMake to tell it not to get that dependency as an external project. + +###OS Specific Build Guides * [BUILD_OSX.md](BUILD_OSX.md) - additional instructions for OS X. * [BUILD_LINUX.md](BUILD_LINUX.md) - additional instructions for Linux. * [BUILD_WIN.md](BUILD_WIN.md) - additional instructions for Windows. @@ -45,6 +61,9 @@ For example, to pass the QT_CMAKE_PREFIX_PATH variable during build file generat cmake .. -DQT_CMAKE_PREFIX_PATH=/usr/local/qt/5.3.2/lib/cmake ####Finding Dependencies + +The following applies for dependencies we do not grab via CMake ExternalProject (OpenSSL is an example), or for dependencies you have opted not to grab as a CMake ExternalProject (via -DGET_$NAME=0). The list of dependencies we grab by default as external projects can be found in [the CMake External Project Dependencies section](#cmake-external-project-dependencies). + You can point our [Cmake find modules](cmake/modules/) to the correct version of dependencies by setting one of the three following variables to the location of the correct version of the dependency. In the examples below the variable $NAME would be replaced by the name of the dependency in uppercase, and $name would be replaced by the name of the dependency in lowercase (ex: OPENSSL_ROOT_DIR, openssl). @@ -55,12 +74,6 @@ In the examples below the variable $NAME would be replaced by the name of the de ###Optional Components -####QXmpp - -You can [find QXmpp here](https://github.com/qxmpp-project/qxmpp), 0.7.6 is the version you want. The inclusion of the QXmpp enables text chat in the Interface client. - -OS X users who tap our [homebrew formulas repository](https://github.com/highfidelity/homebrew-formulas) can install QXmpp via homebrew - `brew install highfidelity/formulas/qxmpp`. - ####Devices You can support external input/output devices such as Oculus Rift, Leap Motion, Faceshift, PrioVR, MIDI, Razr Hydra and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device. diff --git a/BUILD_WIN.md b/BUILD_WIN.md index 8022fae5b8..28d26d9eb4 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -1,12 +1,6 @@ Please read the [general build guide](BUILD.md) for information on dependencies required for all platforms. Only Windows specific instructions are found in this file. -###Windows Specific Dependencies -* [GLEW](http://glew.sourceforge.net/) ~> 1.10.0 -* [freeglut MSVC](http://www.transmissionzero.co.uk/software/freeglut-devel/) ~> 2.8.1 -* [zLib](http://www.zlib.net/) ~> 1.2.8 -* (remember that you need all other dependencies listed in [BUILD.md](BUILD.md)) - -####Visual Studio 2013 +###Visual Studio 2013 You can use the Community or Professional editions of Visual Studio 2013. @@ -16,10 +10,22 @@ Or you can start a regular command prompt and then run: "%VS120COMNTOOLS%\vsvars32.bat" -#####Windows SDK 8.1 +####Windows SDK 8.1 If using Visual Studio 2013 and building as a Visual Studio 2013 project you need the Windows 8 SDK which you should already have as part of installing Visual Studio 2013. You should be able to see it at `C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86`. +####nmake & msbuild + +Some of the external projects may require nmake and msbuild to compile and install. If they are not installed at the locations listed below, please ensure that both are in your PATH so CMake can find them when required. + +We expect nmake.exe to be located at the following path. + + C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin + +We expect msbuild.exe to be located at the following path. + + C:\Program Files (x86)\MSBUILD\12.0\Bin + ###Qt You can use the online installer or the offline installer. If you use the offline installer, be sure to select the "OpenGL" version. @@ -32,9 +38,8 @@ NOTE: Qt does not support 64-bit builds on Windows 7, so you must use the 32-bit * [Download the offline installer](http://download.qt-project.org/official_releases/qt/5.3/5.3.2/qt-opensource-windows-x86-msvc2013_opengl-5.3.2.exe) Once Qt is installed, you need to manually configure the following: -* Make sure the Qt runtime DLLs are loadable. You must do this before you attempt to build because some tools for the build depend on Qt. E.g., add to the PATH: `Qt\5.3.2\msvc2013_opengl\bin\`. -* Go to Control Panel > System > Advanced System Settings > Environment Variables > New ... -* Set the QT_CMAKE_PREFIX_PATH environment variable to your `Qt\5.3.2\msvc2013_opengl` directory. +* Set the QT_CMAKE_PREFIX_PATH environment variable to your `Qt\5.3.2\msvc2013_opengl\lib\cmake` directory. + * You can set an environment variable from Control Panel > System > Advanced System Settings > Environment Variables > New ###External Libraries @@ -42,40 +47,19 @@ As it stands, Hifi/Interface is a 32-bit application, so all libraries should al CMake will need to know where the headers and libraries for required external dependencies are. +We use CMake's `fixup_bundle` to find the DLLs all of our exectuable targets require, and then copy them beside the executable in a post-build step. If `fixup_bundle` is having problems finding a DLL, you can fix it manually on your end by adding the folder containing that DLL to your path. Let us know which DLL CMake had trouble finding, as it is possible a tweak to our CMake files is required. + The recommended route for CMake to find the external dependencies is to place all of the dependencies in one folder and set one ENV variable - HIFI_LIB_DIR. That ENV variable should point to a directory with the following structure: root_lib_dir - -> bullet - -> include - -> lib - -> freeglut - -> bin - -> include - -> lib - -> glew - -> bin - -> include - -> lib - -> glm - -> glm - -> glm.hpp -> openssl -> bin -> include -> lib - -> tbb - -> include - -> lib - -> zlib - -> include - -> lib - -> test For many of the external libraries where precompiled binaries are readily available you should be able to simply copy the extracted folder that you get from the download links provided at the top of the guide. Otherwise you may need to build from source and install the built product to this directory. The `root_lib_dir` in the above example can be wherever you choose on your system - as long as the environment variable HIFI_LIB_DIR is set to it. From here on, whenever you see %HIFI_LIB_DIR% you should substitute the directory that you chose. -As with the Qt libraries, you will need to make sure that directories containing DLL'S are in your path. Where possible, you can use static builds of the external dependencies to avoid this requirement. - -###OpenSSL +####OpenSSL Qt will use OpenSSL if it's available, but it doesn't install it, so you must install it separately. @@ -95,107 +79,10 @@ To prevent these problems, install OpenSSL yourself. Download the following bina Install OpenSSL into the Windows system directory, to make sure that Qt uses the version that you've just installed, and not some other version. -###Intel Threading Building Blocks (TBB) - -Download the zip from the [TBB website](https://www.threadingbuildingblocks.org/). - -We recommend you extract it to %HIFI_LIB_DIR%\tbb. This will help our FindTBB cmake module find what it needs. You can place it wherever you like on your machine if you specify TBB_ROOT_DIR as an environment variable or a variable passed when cmake is run. - -###Zlib - -Download the compiled DLL from the [zlib website](http://www.zlib.net/). Extract to %HIFI_LIB_DIR%\zlib. - -Add the following environment variables (remember to substitute your own directory for %HIFI_LIB_DIR%): - - ZLIB_LIBRARY=%HIFI_LIB_DIR%\zlib\lib\zdll.lib - ZLIB_INCLUDE_DIR=%HIFI_LIB_DIR%\zlib\include - -Add to the PATH: `%HIFI_LIB_DIR%\zlib` - -(The PATH environment variable is where Windows looks for its DLL's and executables. There's a great tool for editing these variables with ease, [Rapid Environment Editor](http://www.rapidee.com/en/download)) - -Important! This should be added at the beginning of the path, not the end (your -system likely has many copies of zlib1.dll, and you want High Fidelity to use the correct version). If High Fidelity picks up the wrong zlib1.dll then it might be unable to use it, and that would cause it to fail to start, showing only the cryptic error "The application was unable to start correctly: 0xc0000022". - -###freeglut - -Download the binary package: `freeglut-MSVC-2.8.1-1.mp.zip`. Extract to %HIFI_LIB_DIR%\freeglut. - -Add to the PATH: `%HIFI_LIB_DIR%\freeglut\bin` - -###GLEW - -Download the binary package: `glew-1.10.0-win32.zip`. Extract to %HIFI_LIB_DIR%\glew (you'll need to rename the default directory name). - -Add to the PATH: `%HIFI_LIB_DIR%\glew\bin\Release\Win32` - -###GLM - -This package contains only headers, so there's nothing to add to the PATH. - -Be careful with glm. For the folder other libraries would normally call 'include', the folder containing the headers, glm opts to use 'glm'. You will have a glm folder nested inside the top-level glm folder. - -###Gverb - -1. Go to https://github.com/highfidelity/gverb - Or download the sources directly via this link: - https://github.com/highfidelity/gverb/archive/master.zip - -2. Extract the archive - -3. Place the directories “include” and “src” in interface/external/gverb - (Normally next to this readme) - -4. Clear your build directory, run cmake, build and you should be all set. - - -###Bullet - -Bullet 2.82 source can be [downloaded here](https://code.google.com/p/bullet/downloads/detail?name=bullet-2.82-r2704.zip). Bullet does not come with prebuilt libraries, you need to make those yourself. - -* Download the zip file and extract into a temporary folder -* Create a directory named cmakebuild. Bullet comes with a build\ directory by default, however, that directory is intended for use with premake, and considering premake doesn't support VS2013, we prefer to run the cmake build on its own directory. -* Make the following modifications to Bullet's source: - 1. In file: Extras\HACD\hacdICHull.cpp --- in line: 17 --- insert: #include <algorithm> - 2. In file: src\MiniCL\cl_MiniCL_Defs.h --- comment lines 364 to 372 - 3. In file: CMakeLists.txt set to ON the option USE_MSVC_RUNTIME_LIBRARY_DLL in line 27 - -Then create the Visual Studio solution and build the libraries - run the following commands from a Visual Studio 2013 command prompt, from within the cmakebuild directory created before: - -```shell -cmake .. -G "Visual Studio 12" -msbuild BULLET_PHYSICS.sln /p:Configuration=Debug -``` - -This will create Debug libraries in cmakebuild\lib\Debug. You can replace Debug with Release in the msbuild command and that will generate Release libraries in cmakebuild\lib\Release. - -You now have Bullet libraries compiled, now you need to put them in the right place for hifi to find them: - -* Create a directory named bullet\ inside your %HIFI_LIB_DIR% -* Create two directores named lib\ and include\ inside bullet\ -* Copy all the contents inside src\ from the bullet unzip path into %HIFI_LIB_DIR%\bullet\include\ -* Copy all the contents inside cmakebuild\lib\ into %HIFI_LIB_DIR\bullet\lib - -_Note that the INSTALL target should handle the copying of files into an install directory automatically, however, without modifications to Cmake, the install target didn't work right for me, please update this instructions if you get that working right - Leo <leo@highfidelity.io>_ - -###Soxr - -Download the zip from the [soxr sourceforge page](http://sourceforge.net/projects/soxr/). - -We recommend you install it to %HIFI_LIB_DIR%\soxr. This will help our FindSoxr cmake module find what it needs. You can place it wherever you like on your machine if you specify SOXR_ROOT_DIR as an environment variable or a variable passed when cmake is run. - -Extract the soxr archive wherever you like. Then, inside the extracted folder, create a directory called `build`. From that build directory, the following commands will build and then install soxr to `%HIFI_LIB_DIR%`. - -``` -cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%HIFI_LIB_DIR%/soxr -nmake -nmake install -``` - ###Build High Fidelity using Visual Studio Follow the same build steps from the CMake section of [BUILD.md](BUILD.md), but pass a different generator to CMake. - cmake .. -DZLIB_LIBRARY=%ZLIB_LIBRARY% -DZLIB_INCLUDE_DIR=%ZLIB_INCLUDE_DIR% -G "Visual Studio 12" + cmake .. -G "Visual Studio 12" Open %HIFI_DIR%\build\hifi.sln and compile. diff --git a/tools/vhacd/CMakeLists.txt b/tools/vhacd/CMakeLists.txt index db0cc13e67..31a7f7c8e2 100644 --- a/tools/vhacd/CMakeLists.txt +++ b/tools/vhacd/CMakeLists.txt @@ -18,8 +18,6 @@ if(NOT WIN32) endif() endif() -add_dependency_external_project(glm) +add_dependency_external_projects(glm) find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - -include_dependency_includes() diff --git a/tools/vhacd/src/main.cpp b/tools/vhacd/src/main.cpp index 31866a7cfc..3d7f2d7504 100644 --- a/tools/vhacd/src/main.cpp +++ b/tools/vhacd/src/main.cpp @@ -27,7 +27,10 @@ int main(int argc, char * argv[]){ vhacd::ComputeResults results; // results after computing vhacd VHACD::IVHACD::Parameters params; vhacd::ProgressCallback pCallBack; - + if (argc < 2){ + cout << "please provide a FBX file as argument\n "; + return 1; + } string filename(argv[1]); if (filename.empty()){ cout << "please provide a FBX file as argument\n "; From 95839dd64e9caec0138efb7f6a308b23bd0da0f3 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Fri, 27 Feb 2015 00:27:18 +0530 Subject: [PATCH 22/31] untabify the source files --- tools/vhacd/src/VHACDUtil.cpp | 155 ++++++++++++++++----------------- tools/vhacd/src/VHACDUtil.h | 47 +++++----- tools/vhacd/src/main.cpp | 157 +++++++++++++++++----------------- 3 files changed, 180 insertions(+), 179 deletions(-) diff --git a/tools/vhacd/src/VHACDUtil.cpp b/tools/vhacd/src/VHACDUtil.cpp index 95e78b212d..d4ab9d7c8a 100644 --- a/tools/vhacd/src/VHACDUtil.cpp +++ b/tools/vhacd/src/VHACDUtil.cpp @@ -16,104 +16,105 @@ //Read all the meshes from provided FBX file bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *results){ - // open the fbx file - QFile fbx(filename); - if (!fbx.open(QIODevice::ReadOnly)) { - return false; - } - std::cout << "Reading FBX.....\n"; + // open the fbx file + QFile fbx(filename); + if (!fbx.open(QIODevice::ReadOnly)) { + return false; + } + std::cout << "Reading FBX.....\n"; - QByteArray fbxContents = fbx.readAll(); - FBXGeometry geometry = readFBX(fbxContents, QVariantHash()); - //results->meshCount = geometry.meshes.count(); - - int count = 0; - foreach(FBXMesh mesh, geometry.meshes) { - //get vertices for each mesh - QVector vertices = mesh.vertices; + QByteArray fbxContents = fbx.readAll(); + FBXGeometry geometry = readFBX(fbxContents, QVariantHash()); + //results->meshCount = geometry.meshes.count(); + + int count = 0; + foreach(FBXMesh mesh, geometry.meshes) { + //get vertices for each mesh + QVector vertices = mesh.vertices; - //get the triangle indices for each mesh - QVector triangles; - foreach(FBXMeshPart part, mesh.parts) { - QVector indices = part.triangleIndices; - triangles += indices; - } + //get the triangle indices for each mesh + QVector triangles; + foreach(FBXMeshPart part, mesh.parts) { + QVector indices = part.triangleIndices; + triangles += indices; + } - //only read meshes with triangles - if (triangles.count() <= 0) - continue; - results->perMeshVertices.append(vertices); - results->perMeshTriangleIndices.append(triangles); - count++; - } + //only read meshes with triangles + if (triangles.count() <= 0) + continue; + results->perMeshVertices.append(vertices); + results->perMeshTriangleIndices.append(triangles); + count++; + } - results->meshCount = count; - return true; + results->meshCount = count; + return true; } bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const{ - VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD(); - int meshCount = meshes->meshCount; - int count = 0; - std::cout << "Performing V-HACD computation on " << meshCount <<" meshes ..... " << std::endl; + VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD(); + int meshCount = meshes->meshCount; + int count = 0; + std::cout << "Performing V-HACD computation on " << meshCount <<" meshes ..... " << std::endl; - for (int i = 0; i < meshCount; i++){ - - std::vector vertices = meshes->perMeshVertices.at(i).toStdVector(); - std::vector triangles = meshes->perMeshTriangleIndices.at(i).toStdVector(); - int nPoints = (unsigned int)vertices.size(); - int nTriangles = (unsigned int)triangles.size() / 3; - std::cout << "Mesh " << i + 1 << " : "; - // compute approximate convex decomposition - bool res = interfaceVHACD->Compute(&vertices[0].x, 3, nPoints, &triangles[0], 3, nTriangles, params); - if (!res){ - std::cout << "V-HACD computation failed for Mesh : " << i + 1 << std::endl; - continue; - } - count++; //For counting number of successfull computations + for (int i = 0; i < meshCount; i++){ + + std::vector vertices = meshes->perMeshVertices.at(i).toStdVector(); + std::vector triangles = meshes->perMeshTriangleIndices.at(i).toStdVector(); + int nPoints = (unsigned int)vertices.size(); + int nTriangles = (unsigned int)triangles.size() / 3; + std::cout << "Mesh " << i + 1 << " : "; + // compute approximate convex decomposition + bool res = interfaceVHACD->Compute(&vertices[0].x, 3, nPoints, &triangles[0], 3, nTriangles, params); + if (!res){ + std::cout << "V-HACD computation failed for Mesh : " << i + 1 << std::endl; + continue; + } + count++; //For counting number of successfull computations - //Number of hulls for the mesh - unsigned int nConvexHulls = interfaceVHACD->GetNConvexHulls(); - results->convexHullsCountList.append(nConvexHulls); + //Number of hulls for the mesh + unsigned int nConvexHulls = interfaceVHACD->GetNConvexHulls(); + results->convexHullsCountList.append(nConvexHulls); - //get all the convex hulls for this mesh - QVector convexHulls; - for (unsigned int j = 0; j < nConvexHulls; j++){ - VHACD::IVHACD::ConvexHull hull; - interfaceVHACD->GetConvexHull(j, hull); - convexHulls.append(hull); - } - results->convexHullList.append(convexHulls); - } //end of for loop + //get all the convex hulls for this mesh + QVector convexHulls; + for (unsigned int j = 0; j < nConvexHulls; j++){ + VHACD::IVHACD::ConvexHull hull; + interfaceVHACD->GetConvexHull(j, hull); + convexHulls.append(hull); + } + results->convexHullList.append(convexHulls); + } //end of for loop - results->meshCount = count; + results->meshCount = count; - //release memory - interfaceVHACD->Clean(); - interfaceVHACD->Release(); + //release memory + interfaceVHACD->Clean(); + interfaceVHACD->Release(); - if (count > 0) - return true; - else - return false; + if (count > 0) + return true; + else + return false; } vhacd::VHACDUtil:: ~VHACDUtil(){ - //nothing to be cleaned + //nothing to be cleaned } //ProgressClaback implementation -void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation){ - int progress = (int)(overallProgress + 0.5); +void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, + const char * const stage, const char * const operation){ + int progress = (int)(overallProgress + 0.5); - if (progress < 10) - std::cout << "\b\b"; - else - std::cout << "\b\b\b"; - std::cout << progress << "%"; + if (progress < 10) + std::cout << "\b\b"; + else + std::cout << "\b\b\b"; + std::cout << progress << "%"; - if (progress >= 100) - std::cout << std::endl; + if (progress >= 100) + std::cout << std::endl; } diff --git a/tools/vhacd/src/VHACDUtil.h b/tools/vhacd/src/VHACDUtil.h index 036d4ce526..b87ba07ff0 100644 --- a/tools/vhacd/src/VHACDUtil.h +++ b/tools/vhacd/src/VHACDUtil.h @@ -23,32 +23,33 @@ namespace vhacd{ - typedef struct{ - int meshCount; - QVector convexHullsCountList; - QVector> convexHullList; - }ComputeResults; + typedef struct{ + int meshCount; + QVector convexHullsCountList; + QVector> convexHullList; + }ComputeResults; - typedef struct{ - int meshCount; - QVector> perMeshVertices; - QVector> perMeshTriangleIndices; - }LoadFBXResults; + typedef struct{ + int meshCount; + QVector> perMeshVertices; + QVector> perMeshTriangleIndices; + }LoadFBXResults; - class VHACDUtil{ - public: - bool loadFBX(const QString filename, vhacd::LoadFBXResults *results); - bool computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const; - ~VHACDUtil(); - }; + class VHACDUtil{ + public: + bool loadFBX(const QString filename, vhacd::LoadFBXResults *results); + bool computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const; + ~VHACDUtil(); + }; - class ProgressCallback : public VHACD::IVHACD::IUserCallback{ - public: - ProgressCallback(void); - ~ProgressCallback(); + class ProgressCallback : public VHACD::IVHACD::IUserCallback{ + public: + ProgressCallback(void); + ~ProgressCallback(); - //Couldn't follow coding guideline here due to virtual function declared in IUserCallback - void Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation); - }; + //Couldn't follow coding guideline here due to virtual function declared in IUserCallback + void Update(const double overallProgress, const double stageProgress, const double operationProgress, + const char * const stage, const char * const operation); + }; } #endif //hifi_VHACDUtil_h \ No newline at end of file diff --git a/tools/vhacd/src/main.cpp b/tools/vhacd/src/main.cpp index 3d7f2d7504..e43f712fa0 100644 --- a/tools/vhacd/src/main.cpp +++ b/tools/vhacd/src/main.cpp @@ -20,93 +20,92 @@ using namespace std; using namespace VHACD; int main(int argc, char * argv[]){ - vector triangles; // array of indexes - vector points; // array of coordinates - vhacd::VHACDUtil vUtil; - vhacd::LoadFBXResults fbx; //mesh data from loaded fbx file - vhacd::ComputeResults results; // results after computing vhacd - VHACD::IVHACD::Parameters params; - vhacd::ProgressCallback pCallBack; - if (argc < 2){ - cout << "please provide a FBX file as argument\n "; - return 1; - } - string filename(argv[1]); - if (filename.empty()){ - cout << "please provide a FBX file as argument\n "; - return 1; - } + vector triangles; // array of indexes + vector points; // array of coordinates + vhacd::VHACDUtil vUtil; + vhacd::LoadFBXResults fbx; //mesh data from loaded fbx file + vhacd::ComputeResults results; // results after computing vhacd + VHACD::IVHACD::Parameters params; + vhacd::ProgressCallback pCallBack; + if (argc < 2){ + cout << "please provide a FBX file as argument\n "; + return 1; + } + string filename(argv[1]); + if (filename.empty()){ + cout << "please provide a FBX file as argument\n "; + return 1; + } - QString fname = QString::fromStdString(filename); + QString fname = QString::fromStdString(filename); - //set parameters for V-HACD - params.m_callback = &pCallBack; //progress callback - params.m_resolution = 50000; - params.m_depth = 10; - params.m_concavity = 0.003; - params.m_alpha = 0.05; // controls the bias toward clipping along symmetry planes - params.m_pca = 1; // enable/disable normalizing the mesh before applying the convex decomposition - params.m_mode = 1; // 0: voxel - based approximate convex decomposition, 1 : tetrahedron - based approximate convex decomposition - params.m_maxNumVerticesPerCH = 128; - params.m_minVolumePerCH = 0.0001; // controls the adaptive sampling of the generated convex - hulls + //set parameters for V-HACD + params.m_callback = &pCallBack; //progress callback + params.m_resolution = 50000; + params.m_depth = 10; + params.m_concavity = 0.003; + params.m_alpha = 0.05; // controls the bias toward clipping along symmetry planes + params.m_pca = 1; // enable/disable normalizing the mesh before applying the convex decomposition + params.m_mode = 1; // 0: voxel - based approximate convex decomposition, 1 : tetrahedron - based approximate convex decomposition + params.m_maxNumVerticesPerCH = 128; + params.m_minVolumePerCH = 0.0001; // controls the adaptive sampling of the generated convex - hulls - // load the mesh + // load the mesh - auto begin = std::chrono::high_resolution_clock::now(); - if (!vUtil.loadFBX(fname, &fbx)){ - cout << "Error in opening FBX file...."; - return 1; - } - auto end = std::chrono::high_resolution_clock::now(); - auto loadDuration = std::chrono::duration_cast(end - begin).count(); + auto begin = std::chrono::high_resolution_clock::now(); + if (!vUtil.loadFBX(fname, &fbx)){ + cout << "Error in opening FBX file...."; + return 1; + } + auto end = std::chrono::high_resolution_clock::now(); + auto loadDuration = std::chrono::duration_cast(end - begin).count(); - //perform vhacd computation - begin = std::chrono::high_resolution_clock::now(); - if (!vUtil.computeVHACD(&fbx, params, &results)){ - cout << "Compute Failed..."; - return 1; - } - end = std::chrono::high_resolution_clock::now(); - auto computeDuration = std::chrono::duration_cast(end - begin).count(); + //perform vhacd computation + begin = std::chrono::high_resolution_clock::now(); + if (!vUtil.computeVHACD(&fbx, params, &results)){ + cout << "Compute Failed..."; + return 1; + } + end = std::chrono::high_resolution_clock::now(); + auto computeDuration = std::chrono::duration_cast(end - begin).count(); - int totalVertices = 0; - for (int i = 0; i < fbx.meshCount; i++){ - totalVertices += fbx.perMeshVertices.at(i).count(); - } + int totalVertices = 0; + for (int i = 0; i < fbx.meshCount; i++){ + totalVertices += fbx.perMeshVertices.at(i).count(); + } - int totalTriangles = 0; - for (int i = 0; i < fbx.meshCount; i++){ - totalTriangles += fbx.perMeshTriangleIndices.at(i).count(); - } + int totalTriangles = 0; + for (int i = 0; i < fbx.meshCount; i++){ + totalTriangles += fbx.perMeshTriangleIndices.at(i).count(); + } - int totalHulls = 0; - QVector hullCounts = results.convexHullsCountList; - for (int i = 0; i < results.meshCount; i++){ - totalHulls += hullCounts.at(i); - } - cout << endl << "Summary of V-HACD Computation..................." << endl; - cout << "File Path : " << fname.toStdString() << endl; - cout << "Number Of Meshes : " << fbx.meshCount << endl; - cout << "Processed Meshes : " << results.meshCount << endl; - cout << "Total vertices : " << totalVertices << endl; - cout << "Total Triangles : " << totalTriangles << endl; - cout << "Total Convex Hulls : " << totalHulls << endl; - cout << "Total FBX load time: " << (double)loadDuration / 1000000000.00 << " seconds" << endl; - cout << "V-HACD Compute time: " << (double)computeDuration / 1000000000.00 << " seconds" << endl; - cout << endl << "Summary per convex hull ........................" << endl < chList = results.convexHullList.at(i); - cout << "\t" << "Number Of Hulls : " << chList.count() << endl; + int totalHulls = 0; + QVector hullCounts = results.convexHullsCountList; + for (int i = 0; i < results.meshCount; i++){ + totalHulls += hullCounts.at(i); + } + cout << endl << "Summary of V-HACD Computation..................." << endl; + cout << "File Path : " << fname.toStdString() << endl; + cout << "Number Of Meshes : " << fbx.meshCount << endl; + cout << "Processed Meshes : " << results.meshCount << endl; + cout << "Total vertices : " << totalVertices << endl; + cout << "Total Triangles : " << totalTriangles << endl; + cout << "Total Convex Hulls : " << totalHulls << endl; + cout << "Total FBX load time: " << (double)loadDuration / 1000000000.00 << " seconds" << endl; + cout << "V-HACD Compute time: " << (double)computeDuration / 1000000000.00 << " seconds" << endl; + cout << endl << "Summary per convex hull ........................" << endl < chList = results.convexHullList.at(i); + cout << "\t" << "Number Of Hulls : " << chList.count() << endl; - for (int j = 0; j < results.convexHullList.at(i).count(); j++){ + for (int j = 0; j < results.convexHullList.at(i).count(); j++){ + cout << "\tHUll : " << j + 1 << endl; + cout << "\t\tNumber Of Points : " << chList.at(j).m_nPoints << endl; + cout << "\t\tNumber Of Triangles : " << chList.at(j).m_nTriangles << endl; + } + } - cout << "\tHUll : " << j + 1 << endl; - cout << "\t\tNumber Of Points : " << chList.at(j).m_nPoints << endl; - cout << "\t\tNumber Of Triangles : " << chList.at(j).m_nTriangles << endl; - } - } - - getchar(); - return 0; + getchar(); + return 0; } \ No newline at end of file From fdf9fdd8778d38263c4c3c17d1228ddeb9e32e9c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 26 Feb 2015 20:05:47 +0100 Subject: [PATCH 23/31] Relax head/lean when not tracking --- interface/src/avatar/MyAvatar.cpp | 9 +------- interface/src/devices/FaceTracker.cpp | 30 +++++++++++++++++++++++++++ interface/src/devices/FaceTracker.h | 12 +++++------ interface/src/devices/Faceshift.cpp | 2 ++ interface/src/devices/Visage.cpp | 12 +++++------ interface/src/devices/Visage.h | 6 +++--- 6 files changed, 48 insertions(+), 23 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 9cdd38dbc8..8c4ea73775 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1158,15 +1158,8 @@ void MyAvatar::updateOrientation(float deltaTime) { pitch *= DEGREES_PER_RADIAN; roll *= DEGREES_PER_RADIAN; - // Record the angular velocity - Head* head = getHead(); - if (deltaTime > 0.0f) { - glm::vec3 angularVelocity(pitch - head->getBasePitch(), yaw - head->getBaseYaw(), roll - head->getBaseRoll()); - angularVelocity *= 1.0f / deltaTime; - head->setAngularVelocity(angularVelocity); - } - //Invert yaw and roll when in mirror mode + Head* head = getHead(); if (Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) { head->setBaseYaw(-yaw); head->setBasePitch(pitch); diff --git a/interface/src/devices/FaceTracker.cpp b/interface/src/devices/FaceTracker.cpp index 8d61789715..e570e39345 100644 --- a/interface/src/devices/FaceTracker.cpp +++ b/interface/src/devices/FaceTracker.cpp @@ -14,3 +14,33 @@ inline float FaceTracker::getBlendshapeCoefficient(int index) const { return isValidBlendshapeIndex(index) ? _blendshapeCoefficients[index] : 0.0f; } + +float FaceTracker::getFadeCoefficient() const { + // TODO: apply exponential relaxation + return _relaxationStatus; +} + +const glm::vec3 FaceTracker::getHeadTranslation() const { + return glm::mix(glm::vec3(0.0f), _headTranslation, getFadeCoefficient()); +} + +const glm::quat FaceTracker::getHeadRotation() const { + return glm::mix(glm::quat(), _headRotation, getFadeCoefficient()); +} + +void FaceTracker::update(float deltaTime) { + static const float RELAXATION_TIME = 0.4; // sec + + if (isTracking()) { + if (_relaxationStatus == 1.0f) { + return; + } + _relaxationStatus += deltaTime / RELAXATION_TIME; + } else { + if (_relaxationStatus == 0.0f) { + return; + } + _relaxationStatus -= deltaTime / RELAXATION_TIME; + } + _relaxationStatus = glm::clamp(_relaxationStatus, 0.0f, 1.0f); +} \ No newline at end of file diff --git a/interface/src/devices/FaceTracker.h b/interface/src/devices/FaceTracker.h index 07c479e3e3..89ba1f22f6 100644 --- a/interface/src/devices/FaceTracker.h +++ b/interface/src/devices/FaceTracker.h @@ -27,11 +27,13 @@ public: virtual bool isTracking() const { return false; } virtual void init() {} - virtual void update(float deltaTime) {} + virtual void update(float deltaTime); virtual void reset() {} - const glm::vec3& getHeadTranslation() const { return _headTranslation; } - const glm::quat& getHeadRotation() const { return _headRotation; } + float getFadeCoefficient() const; + + const glm::vec3 getHeadTranslation() const; + const glm::quat getHeadRotation() const; float getEstimatedEyePitch() const { return _estimatedEyePitch; } float getEstimatedEyeYaw() const { return _estimatedEyeYaw; } @@ -42,15 +44,13 @@ public: float getBlendshapeCoefficient(int index) const; protected: - - glm::vec3 _headTranslation = glm::vec3(0.0f); glm::quat _headRotation = glm::quat(); float _estimatedEyePitch = 0.0f; float _estimatedEyeYaw = 0.0f; QVector _blendshapeCoefficients; - float _fadeCoefficient = 0.0f; + float _relaxationStatus = 0.0f; // Between 0.0f and 1.0f }; #endif // hifi_FaceTracker_h diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 87ee0ef31c..a2bb4e74a9 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -54,6 +54,8 @@ void Faceshift::update(float deltaTime) { if (!isActive()) { return; } + FaceTracker::update(deltaTime); + // get the euler angles relative to the window glm::vec3 eulers = glm::degrees(safeEulerAngles(_headRotation * glm::quat(glm::radians(glm::vec3( (_eyeGazeLeftPitch + _eyeGazeRightPitch) / 2.0f, (_eyeGazeLeftYaw + _eyeGazeRightYaw) / 2.0f, 0.0f))))); diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 45c19a6ab3..010b872bc6 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -41,7 +41,6 @@ const glm::vec3 DEFAULT_HEAD_ORIGIN(0.0f, 0.0f, 0.7f); Visage::Visage() : _enabled(false), - _active(false), _headOrigin(DEFAULT_HEAD_ORIGIN) { #ifdef HAVE_VISAGE @@ -119,19 +118,20 @@ static const QMultiHash >& getActionUnitNameMap() } #endif -const float TRANSLATION_SCALE = 20.0f; +#ifdef HAVE_VISAGE +const float TRANSLATION_SCALE = 20.0f; void Visage::init() { connect(DependencyManager::get().data(), SIGNAL(connectionStateChanged()), SLOT(updateEnabled())); updateEnabled(); } void Visage::update(float deltaTime) { -#ifdef HAVE_VISAGE - _active = (_tracker->getTrackingData(_data) == TRACK_STAT_OK); - if (!_active) { + if (!isActive()) { return; } + FaceTracker::update(deltaTime); + _headRotation = glm::quat(glm::vec3(-_data->faceRotation[0], -_data->faceRotation[1], _data->faceRotation[2])); _headTranslation = (glm::vec3(_data->faceTranslation[0], _data->faceTranslation[1], _data->faceTranslation[2]) - _headOrigin) * TRANSLATION_SCALE; @@ -163,12 +163,12 @@ void Visage::update(float deltaTime) { } _blendshapeCoefficients[leftEyeBlinkIndex] = 1.0f - _data->eyeClosure[1]; _blendshapeCoefficients[rightEyeBlinkIndex] = 1.0f - _data->eyeClosure[0]; -#endif } void Visage::reset() { _headOrigin += _headTranslation / TRANSLATION_SCALE; } +#endif void Visage::updateEnabled() { setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Visage) && diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index cd2ec3ecad..3ff1ea8c27 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -31,15 +31,16 @@ class Visage : public FaceTracker, public Dependency { SINGLETON_DEPENDENCY public: +#ifdef HAVE_VISAGE virtual void init(); virtual void update(float deltaTime); virtual void reset(); - virtual bool isActive() const { return _active; } + virtual bool isActive() const { return _tracker->getTrackingData(_data) == TRACK_STAT_OK; } virtual bool isTracking() const { return isActive(); } +#endif public slots: - void updateEnabled(); private: @@ -55,7 +56,6 @@ private: void setEnabled(bool enabled); bool _enabled; - bool _active; glm::vec3 _headOrigin; }; From 93106be46663ed09ec3f125adc9bc6f7533476d5 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Fri, 27 Feb 2015 00:58:55 +0530 Subject: [PATCH 24/31] VHACD dependency build instructions --- BUILD.md | 2 +- BUILD_WIN.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/BUILD.md b/BUILD.md index 98b8cffab1..6968d9bde8 100644 --- a/BUILD.md +++ b/BUILD.md @@ -4,7 +4,7 @@ * [Qt](http://qt-project.org/downloads) ~> 5.3.2 * [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g * IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability. - +* [VHACD](https://github.com/virneo/v-hacd)(clone this repository)(Optional) ####CMake External Project Dependencies * [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82 diff --git a/BUILD_WIN.md b/BUILD_WIN.md index 28d26d9eb4..df50fd82c8 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -79,6 +79,21 @@ To prevent these problems, install OpenSSL yourself. Download the following bina Install OpenSSL into the Windows system directory, to make sure that Qt uses the version that you've just installed, and not some other version. +###vhacd +Download it directly from https://github.com/virneo/v-hacd + +To build it run the following commands + 1. cd src\ + 2. mkdir build + 3. cd build + 4. cmake .. + +Build using visual studio 2013. Build ALL_BUILD and INSTALL targets both in Release and Debug. + +This will create an output folder with include and lib directory inside it. + +Either copy the contents of output folder to ENV %HIFI_LIB_DIR%/vhacd or create an environment variable VHACD_ROOT_DIR to this output directory. + ###Build High Fidelity using Visual Studio Follow the same build steps from the CMake section of [BUILD.md](BUILD.md), but pass a different generator to CMake. From d4367924ad5b0646f3cf682e3b0dbf836f8cc995 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Fri, 27 Feb 2015 00:59:59 +0530 Subject: [PATCH 25/31] Clean up coding standard violations --- tools/vhacd/src/VHACDUtil.cpp | 41 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/tools/vhacd/src/VHACDUtil.cpp b/tools/vhacd/src/VHACDUtil.cpp index d4ab9d7c8a..63b3bba459 100644 --- a/tools/vhacd/src/VHACDUtil.cpp +++ b/tools/vhacd/src/VHACDUtil.cpp @@ -26,25 +26,26 @@ bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *re QByteArray fbxContents = fbx.readAll(); FBXGeometry geometry = readFBX(fbxContents, QVariantHash()); //results->meshCount = geometry.meshes.count(); - + int count = 0; - foreach(FBXMesh mesh, geometry.meshes) { + foreach(FBXMesh mesh, geometry.meshes){ //get vertices for each mesh - QVector vertices = mesh.vertices; + QVector vertices = mesh.vertices; //get the triangle indices for each mesh QVector triangles; - foreach(FBXMeshPart part, mesh.parts) { + foreach(FBXMeshPart part, mesh.parts){ QVector indices = part.triangleIndices; triangles += indices; } //only read meshes with triangles - if (triangles.count() <= 0) - continue; + if (triangles.count() <= 0){ + continue; + } results->perMeshVertices.append(vertices); results->perMeshTriangleIndices.append(triangles); - count++; + count++; } results->meshCount = count; @@ -55,10 +56,10 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD(); int meshCount = meshes->meshCount; int count = 0; - std::cout << "Performing V-HACD computation on " << meshCount <<" meshes ..... " << std::endl; + std::cout << "Performing V-HACD computation on " << meshCount << " meshes ..... " << std::endl; for (int i = 0; i < meshCount; i++){ - + std::vector vertices = meshes->perMeshVertices.at(i).toStdVector(); std::vector triangles = meshes->perMeshTriangleIndices.at(i).toStdVector(); int nPoints = (unsigned int)vertices.size(); @@ -92,10 +93,13 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD interfaceVHACD->Clean(); interfaceVHACD->Release(); - if (count > 0) + if (count > 0){ return true; - else + } + else{ return false; + } + } vhacd::VHACDUtil:: ~VHACDUtil(){ @@ -103,19 +107,22 @@ vhacd::VHACDUtil:: ~VHACDUtil(){ } //ProgressClaback implementation -void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, +void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation){ int progress = (int)(overallProgress + 0.5); - if (progress < 10) + if (progress < 10){ std::cout << "\b\b"; - else + } + else{ std::cout << "\b\b\b"; + } + std::cout << progress << "%"; - if (progress >= 100) - std::cout << std::endl; - + if (progress >= 100){ + std::cout << std::endl; + } } vhacd::ProgressCallback::ProgressCallback(void){} From 695cfb3397485b028bfefac9b4311e3340f5e2ba Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Fri, 27 Feb 2015 01:04:23 +0530 Subject: [PATCH 26/31] VHACD dependency build instructions --- BUILD.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILD.md b/BUILD.md index 6968d9bde8..f2efe05289 100644 --- a/BUILD.md +++ b/BUILD.md @@ -5,6 +5,7 @@ * [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g * IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability. * [VHACD](https://github.com/virneo/v-hacd)(clone this repository)(Optional) + ####CMake External Project Dependencies * [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82 From c80995170af3a813a8f0885c9c6f825348c9e7c7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 26 Feb 2015 17:17:19 -0800 Subject: [PATCH 27/31] -n and -t are okay together --- assignment-client/src/AssignmentClientApp.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/assignment-client/src/AssignmentClientApp.cpp b/assignment-client/src/AssignmentClientApp.cpp index 7c6fb50db2..cea952a806 100644 --- a/assignment-client/src/AssignmentClientApp.cpp +++ b/assignment-client/src/AssignmentClientApp.cpp @@ -120,11 +120,6 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : requestAssignmentType = (Assignment::Type) argumentVariantMap.value(ASSIGNMENT_TYPE_OVERRIDE_OPTION).toInt(); } if (parser.isSet(clientTypeOption)) { - if (numForks || minForks || maxForks) { - qCritical() << "don't use -t with forking mode."; - parser.showHelp(); - Q_UNREACHABLE(); - } requestAssignmentType = (Assignment::Type) parser.value(clientTypeOption).toInt(); } From b8322556a65a1c3cb2d15eb0de8354191f2d1b17 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 26 Feb 2015 17:34:24 -0800 Subject: [PATCH 28/31] address code-review comments --- assignment-client/src/AssignmentClientApp.cpp | 7 +------ assignment-client/src/AssignmentClientMonitor.cpp | 6 +++--- libraries/networking/src/LimitedNodeList.h | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/assignment-client/src/AssignmentClientApp.cpp b/assignment-client/src/AssignmentClientApp.cpp index cea952a806..cfb77c8542 100644 --- a/assignment-client/src/AssignmentClientApp.cpp +++ b/assignment-client/src/AssignmentClientApp.cpp @@ -29,14 +29,13 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : setvbuf(stdout, NULL, _IOLBF, 0); # endif - + // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us # ifdef _WIN32 installNativeEventFilter(&ShutdownEventListener::getInstance()); # else ShutdownEventListener::getInstance(); # endif - setOrganizationName("High Fidelity"); setOrganizationDomain("highfidelity.io"); setApplicationName("assignment-client"); @@ -141,7 +140,6 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : walletUUID = parser.value(walletDestinationOption); } - QString assignmentServerHostname; if (argumentVariantMap.contains(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) { assignmentServerHostname = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION).toString(); @@ -150,7 +148,6 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : assignmentServerHostname = parser.value(assignmentServerHostnameOption); } - // check for an overriden assignment server port quint16 assignmentServerPort = DEFAULT_DOMAIN_SERVER_PORT; if (argumentVariantMap.contains(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) { @@ -177,12 +174,10 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : if (numForks || minForks || maxForks) { - // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us AssignmentClientMonitor monitor(numForks, minForks, maxForks, assignmentPool, walletUUID, assignmentServerHostname, assignmentServerPort); exec(); } else { - // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us AssignmentClient client(requestAssignmentType, assignmentPool, walletUUID, assignmentServerHostname, assignmentServerPort); exec(); diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index ffc402c04d..7517669d0b 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -43,8 +43,7 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen // create a NodeList so we can receive stats from children DependencyManager::registerInheritance(); auto addressManager = DependencyManager::set(); - auto nodeList = DependencyManager::set(DEFAULT_ASSIGNMENT_CLIENT_MONITOR_PORT, - DEFAULT_ASSIGNMENT_CLIENT_MONITOR_DTLS_PORT); + auto nodeList = DependencyManager::set(DEFAULT_ASSIGNMENT_CLIENT_MONITOR_PORT); connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &AssignmentClientMonitor::readPendingDatagrams); @@ -55,7 +54,8 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen spawnChildClient(); } - connect(&_checkSparesTimer, SIGNAL(timeout()), SLOT(checkSpares())); + connect(&_checkSparesTimer, &QTimer::timeout, this, &AssignmentClientMonitor::checkSpares); + _checkSparesTimer.start(NODE_SILENCE_THRESHOLD_MSECS * 3); } diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 02234ee4f7..afc98de169 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -54,7 +54,6 @@ const QString ASSIGNMENT_CLIENT_MONITOR_LOCAL_PORT_SMEM_KEY = "assignment-client const char DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME[] = "localhost"; const unsigned short DEFAULT_ASSIGNMENT_CLIENT_MONITOR_PORT = 40104; -const unsigned short DEFAULT_ASSIGNMENT_CLIENT_MONITOR_DTLS_PORT = 40105; class HifiSockAddr; From 9849efe0130082673622349ffc45559e68beafb4 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 27 Feb 2015 15:33:24 +0100 Subject: [PATCH 29/31] Exponential relaxation --- interface/src/devices/FaceTracker.cpp | 13 +++++++------ interface/src/devices/FaceTracker.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/interface/src/devices/FaceTracker.cpp b/interface/src/devices/FaceTracker.cpp index e570e39345..f1ab35859b 100644 --- a/interface/src/devices/FaceTracker.cpp +++ b/interface/src/devices/FaceTracker.cpp @@ -16,8 +16,7 @@ inline float FaceTracker::getBlendshapeCoefficient(int index) const { } float FaceTracker::getFadeCoefficient() const { - // TODO: apply exponential relaxation - return _relaxationStatus; + return _fadeCoefficient; } const glm::vec3 FaceTracker::getHeadTranslation() const { @@ -29,18 +28,20 @@ const glm::quat FaceTracker::getHeadRotation() const { } void FaceTracker::update(float deltaTime) { - static const float RELAXATION_TIME = 0.4; // sec + static const float RELAXATION_TIME = 1.0f; // sec + static const float LAMBDA = 1.5; if (isTracking()) { if (_relaxationStatus == 1.0f) { return; } - _relaxationStatus += deltaTime / RELAXATION_TIME; + _relaxationStatus = glm::clamp(_relaxationStatus + deltaTime / RELAXATION_TIME, 0.0f, 1.0f); + _fadeCoefficient = std::exp(-LAMBDA * _relaxationStatus); } else { if (_relaxationStatus == 0.0f) { return; } - _relaxationStatus -= deltaTime / RELAXATION_TIME; + _relaxationStatus = glm::clamp(_relaxationStatus - deltaTime / RELAXATION_TIME, 0.0f, 1.0f); + _fadeCoefficient = 1.0f - std::exp(-LAMBDA * (1.0f - _relaxationStatus)); } - _relaxationStatus = glm::clamp(_relaxationStatus, 0.0f, 1.0f); } \ No newline at end of file diff --git a/interface/src/devices/FaceTracker.h b/interface/src/devices/FaceTracker.h index 89ba1f22f6..1ec0468dec 100644 --- a/interface/src/devices/FaceTracker.h +++ b/interface/src/devices/FaceTracker.h @@ -51,6 +51,7 @@ protected: QVector _blendshapeCoefficients; float _relaxationStatus = 0.0f; // Between 0.0f and 1.0f + float _fadeCoefficient = 0.0f; // Between 0.0f and 1.0f }; #endif // hifi_FaceTracker_h From 8615bb7cff3a39a37cd50301977e35c58b4bd6d0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 27 Feb 2015 15:58:28 +0100 Subject: [PATCH 30/31] Make relaxation go to EPSILON within TIME --- interface/src/devices/FaceTracker.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/interface/src/devices/FaceTracker.cpp b/interface/src/devices/FaceTracker.cpp index f1ab35859b..d6ccc38a45 100644 --- a/interface/src/devices/FaceTracker.cpp +++ b/interface/src/devices/FaceTracker.cpp @@ -28,20 +28,25 @@ const glm::quat FaceTracker::getHeadRotation() const { } void FaceTracker::update(float deltaTime) { - static const float RELAXATION_TIME = 1.0f; // sec + // Based on exponential distributions: http://en.wikipedia.org/wiki/Exponential_distribution + static const float EPSILON = 0.02f; static const float LAMBDA = 1.5; + static const float INVERSE_AT_EPSILON = -std::log(EPSILON) / LAMBDA; // So that f(1) = EPSILON ~ 0 + static const float RELAXATION_TIME = 0.8f; // sec if (isTracking()) { if (_relaxationStatus == 1.0f) { + _fadeCoefficient = 1.0f; return; } _relaxationStatus = glm::clamp(_relaxationStatus + deltaTime / RELAXATION_TIME, 0.0f, 1.0f); - _fadeCoefficient = std::exp(-LAMBDA * _relaxationStatus); + _fadeCoefficient = 1.0f - std::exp(-LAMBDA * _relaxationStatus * INVERSE_AT_EPSILON); } else { if (_relaxationStatus == 0.0f) { + _fadeCoefficient = 0.0f; return; } _relaxationStatus = glm::clamp(_relaxationStatus - deltaTime / RELAXATION_TIME, 0.0f, 1.0f); - _fadeCoefficient = 1.0f - std::exp(-LAMBDA * (1.0f - _relaxationStatus)); + _fadeCoefficient = std::exp(-LAMBDA * (1.0f - _relaxationStatus) * INVERSE_AT_EPSILON); } } \ No newline at end of file From db90fcdb6220a7a377cd816d765631230dcbc0a5 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 27 Feb 2015 16:09:15 +0100 Subject: [PATCH 31/31] Simplify expression --- interface/src/devices/FaceTracker.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/interface/src/devices/FaceTracker.cpp b/interface/src/devices/FaceTracker.cpp index d6ccc38a45..d3e0600057 100644 --- a/interface/src/devices/FaceTracker.cpp +++ b/interface/src/devices/FaceTracker.cpp @@ -29,9 +29,8 @@ const glm::quat FaceTracker::getHeadRotation() const { void FaceTracker::update(float deltaTime) { // Based on exponential distributions: http://en.wikipedia.org/wiki/Exponential_distribution - static const float EPSILON = 0.02f; - static const float LAMBDA = 1.5; - static const float INVERSE_AT_EPSILON = -std::log(EPSILON) / LAMBDA; // So that f(1) = EPSILON ~ 0 + static const float EPSILON = 0.02f; // MUST BE < 1.0f + static const float INVERSE_AT_EPSILON = -std::log(EPSILON); // So that f(1.0f) = EPSILON ~ 0.0f static const float RELAXATION_TIME = 0.8f; // sec if (isTracking()) { @@ -40,13 +39,13 @@ void FaceTracker::update(float deltaTime) { return; } _relaxationStatus = glm::clamp(_relaxationStatus + deltaTime / RELAXATION_TIME, 0.0f, 1.0f); - _fadeCoefficient = 1.0f - std::exp(-LAMBDA * _relaxationStatus * INVERSE_AT_EPSILON); + _fadeCoefficient = 1.0f - std::exp(-_relaxationStatus * INVERSE_AT_EPSILON); } else { if (_relaxationStatus == 0.0f) { _fadeCoefficient = 0.0f; return; } _relaxationStatus = glm::clamp(_relaxationStatus - deltaTime / RELAXATION_TIME, 0.0f, 1.0f); - _fadeCoefficient = std::exp(-LAMBDA * (1.0f - _relaxationStatus) * INVERSE_AT_EPSILON); + _fadeCoefficient = std::exp(-(1.0f - _relaxationStatus) * INVERSE_AT_EPSILON); } } \ No newline at end of file