From d811660ed6f0da1574aadb2d114f1649ae84eb81 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 9 Dec 2015 11:07:10 -0800 Subject: [PATCH 01/20] DO NOT MERGE - Testing PR environment --- README.md | 2 ++ cmake/modules/FindOpenSSL.cmake | 1 + 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index a2eb058ae6..7741445842 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +### TESTING BUILD - DO NOT MERGE ### + High Fidelity (hifi) is an early-stage technology lab experimenting with Virtual Worlds and VR. In this repository you'll find the source to many of the components in our diff --git a/cmake/modules/FindOpenSSL.cmake b/cmake/modules/FindOpenSSL.cmake index 9d9557ad9e..6893948d01 100644 --- a/cmake/modules/FindOpenSSL.cmake +++ b/cmake/modules/FindOpenSSL.cmake @@ -256,6 +256,7 @@ if (WIN32) # For some reason fixup misses the following DLL and only copies libeay32. There's gotta be a better way to handle this # but for now resorting to the following interm solution if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE) + message(STATUS "*********** Copying SSL DLL from ${OPENSSL_DLL_PATH}/ssleay32.dll") add_custom_command( TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy ${OPENSSL_DLL_PATH}/ssleay32.dll ${CMAKE_BINARY_DIR}/full-stack-deployment/ From 711d02ba2f44d7bef93c36e8079642d35e72e105 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 16 Dec 2015 14:26:24 -0600 Subject: [PATCH 02/20] Consolidating installer checkpoint --- CMakeLists.txt | 42 ++--- cmake/macros/ConsolidateStackComponents.cmake | 37 ++-- cmake/modules/FindOpenSSL.cmake | 1 - tools/nsis/release.nsi | 176 ++++++++++++++++++ 4 files changed, 207 insertions(+), 49 deletions(-) create mode 100644 tools/nsis/release.nsi diff --git a/CMakeLists.txt b/CMakeLists.txt index a8271abd8e..836b808a4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12.2) +cmake_minimum_required(VERSION 3.3.2) if (USE_ANDROID_TOOLCHAIN) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/android/android.toolchain.cmake") @@ -230,32 +230,14 @@ endif () include_application_version() if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE) - message(STATUS "+++++ Package for deployment will be generated on this build +++++") - - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/full-stack-deployment) - - set(ICONPATH_INTERFACE "$INSTDIR/${PATH_INSTALL_DATA}/interface.ico") - set(ICONPATH_STACK_MANAGER "$INSTDIR/${PATH_INSTALL_DATA}/stack-manager.ico") - string(REPLACE "/" "\\\\" ICONPATH_INTERFACE ${ICONPATH_INTERFACE}) - string(REPLACE "/" "\\\\" ICONPATH_STACK_MANAGER ${ICONPATH_STACK_MANAGER}) - - set(CPACK_PACKAGE_NAME "High Fidelity") - set(CPACK_PACKAGE_VENDOR "High Fidelity, Inc") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "High Fidelity Interface and Stack") - set(CPACK_PACKAGE_VERSION "${BUILD_SEQ}") - set(CPACK_PACKAGE_VERSION_MAJOR "${BUILD_SEQ}") - set(CPACK_PACKAGE_VERSION_MINOR "0") - set(CPACK_PACKAGE_VERSION_PATCH "0") - set(CPACK_PACKAGE_INSTALL_DIRECTORY "High Fidelity-${BUILD_SEQ}") - set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") - set(CPACK_PACKAGE_EXECUTABLES - stack-manager "Stack Manager" - interface "Interface" - ) - - if (WIN32) - install(DIRECTORY ${CMAKE_BINARY_DIR}/full-stack-deployment/ DESTINATION "./") - endif (WIN32) - - include(CPack) -endif () + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/full-stack-deployment") + find_program(MAKENSIS_COMMAND makensis PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS]) + if (NOT MAKENSIS_COMMAND) + message(FATAL_ERROR "The Nullsoft Scriptable Install Systems is required for generating packaged installers on Windows (http://nsis.sourceforge.net/)") + endif () + add_custom_target( + build-package ALL + DEPENDS interface assignment-client domain-server stack-manager + COMMAND CMD /C "\"${MAKENSIS_COMMAND}\" ${CMAKE_SOURCE_DIR}/tools/nsis/release.nsi" + ) +endif () \ No newline at end of file diff --git a/cmake/macros/ConsolidateStackComponents.cmake b/cmake/macros/ConsolidateStackComponents.cmake index 4bcc777751..ca272f6485 100644 --- a/cmake/macros/ConsolidateStackComponents.cmake +++ b/cmake/macros/ConsolidateStackComponents.cmake @@ -1,26 +1,27 @@ macro(CONSOLIDATE_STACK_COMPONENTS) - if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE AND WIN32) - - # Copy all the output for this target into the common deployment location - add_custom_command( - TARGET ${TARGET_NAME} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy_directory $ ${CMAKE_BINARY_DIR}/full-stack-deployment - ) - - # Copy icon files for interface and stack manager - if (TARGET_NAME STREQUAL "interface" OR TARGET_NAME STREQUAL "stack-manager") - if (TARGET_NAME STREQUAL "interface") - set (ICON_FILE_PATH "${PROJECT_SOURCE_DIR}/icon/interface.ico") - set (ICON_DESTINATION_NAME "interface.ico") - elseif (TARGET_NAME STREQUAL "stack-manager") - set (ICON_FILE_PATH "${PROJECT_SOURCE_DIR}/assets/icon.ico") - set (ICON_DESTINATION_NAME "stack-manager.ico") - endif () + if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE) + if (WIN32) + # Copy all the output for this target into the common deployment location add_custom_command( TARGET ${TARGET_NAME} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy ${ICON_FILE_PATH} ${CMAKE_BINARY_DIR}/full-stack-deployment/${ICON_DESTINATION_NAME} + COMMAND "${CMAKE_COMMAND}" -E copy_directory $ ${CMAKE_BINARY_DIR}/full-stack-deployment ) + + # Copy icon files for interface and stack manager + if (TARGET_NAME STREQUAL "interface" OR TARGET_NAME STREQUAL "stack-manager") + if (TARGET_NAME STREQUAL "interface") + set (ICON_FILE_PATH "${PROJECT_SOURCE_DIR}/icon/interface.ico") + set (ICON_DESTINATION_NAME "interface.ico") + elseif (TARGET_NAME STREQUAL "stack-manager") + set (ICON_FILE_PATH "${PROJECT_SOURCE_DIR}/assets/icon.ico") + set (ICON_DESTINATION_NAME "stack-manager.ico") + endif () + add_custom_command( + TARGET ${TARGET_NAME} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy ${ICON_FILE_PATH} ${CMAKE_BINARY_DIR}/full-stack-deployment/${ICON_DESTINATION_NAME} + ) + endif () endif () endif () diff --git a/cmake/modules/FindOpenSSL.cmake b/cmake/modules/FindOpenSSL.cmake index 6893948d01..9d9557ad9e 100644 --- a/cmake/modules/FindOpenSSL.cmake +++ b/cmake/modules/FindOpenSSL.cmake @@ -256,7 +256,6 @@ if (WIN32) # For some reason fixup misses the following DLL and only copies libeay32. There's gotta be a better way to handle this # but for now resorting to the following interm solution if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE) - message(STATUS "*********** Copying SSL DLL from ${OPENSSL_DLL_PATH}/ssleay32.dll") add_custom_command( TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy ${OPENSSL_DLL_PATH}/ssleay32.dll ${CMAKE_BINARY_DIR}/full-stack-deployment/ diff --git a/tools/nsis/release.nsi b/tools/nsis/release.nsi new file mode 100644 index 0000000000..5b2cce5c61 --- /dev/null +++ b/tools/nsis/release.nsi @@ -0,0 +1,176 @@ +!include LogicLib.nsh +!include x64.nsh + +!define srcdir "E:\development\md-hifi\build\full-stack-deployment" ;$%INSTALLER_SOURCE_DIR% +!define setup "E:\development\md-hifi\build\installer-test.exe" ;$%INSTALLER_NAME% +!define scriptsdir "E:\development\md-hifi\examples" ;$%INSTALLER_SCRIPTS_DIR% +!define company "High Fidelity" +!define prodname "Interface" +!define exec "interface.exe" +!define icon "${srcdir}\interface.ico" +!define regkey "Software\${company}\${prodname}" +!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${prodname}" +!define install_dir_company "$PROGRAMFILES64\${company}" +!define install_dir_product "${install_dir_company}\${prodname}" +!define startmenu_company "$SMPROGRAMS\${company}" +!define startmenu_product "${startmenu_company}\${prodname}" +!define uninstaller "uninstall.exe" + +;-------------------------------- + +XPStyle on +ShowInstDetails hide +ShowUninstDetails hide + +Name "${prodname}" +Caption "${prodname}" + +!ifdef icon + Icon "${icon}" +!endif + +OutFile "${setup}" + +SetDateSave on +SetDatablockOptimize on +CRCCheck on +SilentInstall normal + +InstallDir "${install_dir_product}" +InstallDirRegKey HKLM "${regkey}" "" + +; Page components +Page directory +Page components +Page instfiles + +UninstPage uninstConfirm +UninstPage instfiles + +;-------------------------------- + +AutoCloseWindow true +ShowInstDetails show + + +!ifdef screenimage + + ; set up background image + ; uses BgImage plugin + + Function .onGUIInit + ; extract background BMP into temp plugin directory + InitPluginsDir + File /oname=$PLUGINSDIR\1.bmp "${screenimage}" + + BgImage::SetBg /NOUNLOAD /FILLSCREEN $PLUGINSDIR\1.bmp + BgImage::Redraw /NOUNLOAD + FunctionEnd + + Function .onGUIEnd + ; Destroy must not have /NOUNLOAD so NSIS will be able to unload and delete BgImage before it exits + BgImage::Destroy + FunctionEnd + +!endif + +; Optional Component Selection +Section /o "DDE Face Recognition" SEC01 + SetOutPath "$INSTDIR" + CreateDirectory $INSTDIR\dde + NSISdl::download "https://s3-us-west-1.amazonaws.com/hifi-production/optionals/dde-installer.exe" "$INSTDIR\dde-installer.exe" + ExecWait '"$INSTDIR\dde-installer.exe" /q:a /t:"$INSTDIR\dde"' +SectionEnd + +; beginning (invisible) section +Section "Registry Entries and Procotol Handler" SEC02 + + SectionIn RO + + WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR" + WriteRegStr HKLM "${uninstkey}" "DisplayName" "${prodname} (remove only)" + WriteRegStr HKLM "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"' + WriteRegStr HKCR "${prodname}\Shell\open\command\" "" '"$INSTDIR\${exec} "%1"' + + !ifdef icon + WriteRegStr HKCR "${prodname}\DefaultIcon" "" "$INSTDIR\${icon}" + !endif + + ; hifi:// protocol handler registry entries + WriteRegStr HKCR 'hifi' '' 'URL:Alert Protocol' + WriteRegStr HKCR 'hifi' 'URL Protocol' '' + WriteRegStr HKCR 'hifi\DefaultIcon' '' '$INSTDIR\${icon},1' + WriteRegStr HKCR 'hifi\shell\open\command' '' '$INSTDIR\${exec} --url "%1"' + + SetOutPath $INSTDIR + + ; package all files, recursively, preserving attributes + ; assume files are in the correct places + File /r "${srcdir}\" + !ifdef icon + File /a "${icon}" + !endif + ; any application-specific files + !ifdef files + !include "${files}" + !endif + SetOutPath "$DOCUMENTS\${company}\Scripts" + File /r "${scriptsdir}\" + SetOutPath $INSTDIR + WriteUninstaller "${uninstaller}" + Exec '"$INSTDIR\2013_vcredist_x64.exe" /q /norestart' + Exec '"$INSTDIR\2010_vcredist_x86.exe" /q /norestart' +SectionEnd + +; create shortcuts +Section "Start Menu Shortcuts" SEC03 + + SectionIn RO + + ; This should install the shortcuts for "All Users" + SetShellVarContext all + CreateDirectory "${startmenu_product}" + SetOutPath $INSTDIR ; for working directory + !ifdef icon + CreateShortCut "${startmenu_product}\${prodname}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\${icon}" + !else + CreateShortCut "${startmenu_product}\${prodname}.lnk" "$INSTDIR\${exec}" + !endif + + CreateShortCut "${startmenu_product}\Uninstall ${prodname}.lnk" "$INSTDIR\${uninstaller}" +SectionEnd + +; Uninstaller +; All section names prefixed by "Un" will be in the uninstaller + +UninstallText "This will uninstall ${prodname}." + +!ifdef icon + UninstallIcon "${icon}" +!endif + +Section "Uninstall" SEC04 + + SectionIn RO + + ; Explicitly remove all added shortcuts + SetShellVarContext all + DELETE "${startmenu_product}\${prodname}.lnk" + DELETE "${startmenu_product}\Uninstall ${prodname}.lnk" + + RMDIR "${startmenu_product}" + ; This should remove the High Fidelity folder in Start Menu if it's empty + RMDIR "${startmenu_company}" + + RMDIR /r "$INSTDIR" + ; This should remove the High Fidelity folder in Program Files if it's empty + RMDIR "${install_dir_company}" + + !ifdef unfiles + !include "${unfiles}" + !endif + ; It's good practice to put the registry key removal at the very end + DeleteRegKey HKLM "${uninstkey}" + DeleteRegKey HKLM "${regkey}" + DeleteRegKey HKCR 'hifi' +SectionEnd \ No newline at end of file From 56ef52022dd17d9defc3fe25c144337b0826eb33 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 16 Dec 2015 14:28:05 -0600 Subject: [PATCH 03/20] Removing unwanted changes --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 7741445842..a2eb058ae6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -### TESTING BUILD - DO NOT MERGE ### - High Fidelity (hifi) is an early-stage technology lab experimenting with Virtual Worlds and VR. In this repository you'll find the source to many of the components in our From 5ed422e3a19687a941fb5476212a30d854ccaaec Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 16 Dec 2015 14:28:49 -0600 Subject: [PATCH 04/20] Removing unwanted changes --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 836b808a4c..b2ed36a8c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,9 +67,9 @@ if ((NOT MSVC12) AND (NOT MSVC14)) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if (COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") elseif(COMPILER_SUPPORTS_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() @@ -235,9 +235,9 @@ if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE) if (NOT MAKENSIS_COMMAND) message(FATAL_ERROR "The Nullsoft Scriptable Install Systems is required for generating packaged installers on Windows (http://nsis.sourceforge.net/)") endif () - add_custom_target( - build-package ALL - DEPENDS interface assignment-client domain-server stack-manager + add_custom_target( + build-package ALL + DEPENDS interface assignment-client domain-server stack-manager COMMAND CMD /C "\"${MAKENSIS_COMMAND}\" ${CMAKE_SOURCE_DIR}/tools/nsis/release.nsi" - ) + ) endif () \ No newline at end of file From cbed8bf35a8001c309b8a136fbd5c04650e96251 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 16 Dec 2015 15:12:14 -0600 Subject: [PATCH 05/20] NSIS Changes --- CMakeLists.txt | 3 ++ tools/nsis/release.nsi | 71 +++++++++++++++++------------------------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2ed36a8c5..69e6365c8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,6 +238,9 @@ if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE) add_custom_target( build-package ALL DEPENDS interface assignment-client domain-server stack-manager + COMMAND set INSTALLER_SOURCE_DIR=${CMAKE_BINARY_DIR}/full-stack-deployment + COMMAND set INSTALLER_NAME=${CMAKE_BINARY_DIR}/this-is-a-test.exe + COMMANE set INSTALLER_SCRIPTS_DIR=${CMAKE_SOURCE_DIR}/examples COMMAND CMD /C "\"${MAKENSIS_COMMAND}\" ${CMAKE_SOURCE_DIR}/tools/nsis/release.nsi" ) endif () \ No newline at end of file diff --git a/tools/nsis/release.nsi b/tools/nsis/release.nsi index 5b2cce5c61..86ea055e6b 100644 --- a/tools/nsis/release.nsi +++ b/tools/nsis/release.nsi @@ -1,19 +1,18 @@ !include LogicLib.nsh !include x64.nsh -!define srcdir "E:\development\md-hifi\build\full-stack-deployment" ;$%INSTALLER_SOURCE_DIR% -!define setup "E:\development\md-hifi\build\installer-test.exe" ;$%INSTALLER_NAME% -!define scriptsdir "E:\development\md-hifi\examples" ;$%INSTALLER_SCRIPTS_DIR% -!define company "High Fidelity" -!define prodname "Interface" -!define exec "interface.exe" -!define icon "${srcdir}\interface.ico" -!define regkey "Software\${company}\${prodname}" -!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${prodname}" +!define srcdir $%INSTALLER_SOURCE_DIR% +!define setup $%INSTALLER_NAME% +!define scriptsdir $%INSTALLER_SCRIPTS_DIR% +!define company $%INSTALLER_COMPANY% +!define interface_exec "interface.exe" +!define stack_manager_exec "stack-manager.exe" +!define interface_icon "interface.ico" +!define stack_manager_icon "stack-manager.ico" +!define regkey "Software\${company}" +!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${company}" !define install_dir_company "$PROGRAMFILES64\${company}" -!define install_dir_product "${install_dir_company}\${prodname}" !define startmenu_company "$SMPROGRAMS\${company}" -!define startmenu_product "${startmenu_company}\${prodname}" !define uninstaller "uninstall.exe" ;-------------------------------- @@ -22,8 +21,8 @@ XPStyle on ShowInstDetails hide ShowUninstDetails hide -Name "${prodname}" -Caption "${prodname}" +Name "${company}" +Caption "${company}" !ifdef icon Icon "${icon}" @@ -36,7 +35,7 @@ SetDatablockOptimize on CRCCheck on SilentInstall normal -InstallDir "${install_dir_product}" +InstallDir "${install_dir_company}" InstallDirRegKey HKLM "${regkey}" "" ; Page components @@ -88,35 +87,28 @@ Section "Registry Entries and Procotol Handler" SEC02 SectionIn RO WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR" - WriteRegStr HKLM "${uninstkey}" "DisplayName" "${prodname} (remove only)" + WriteRegStr HKLM "${uninstkey}" "DisplayName" "${company} (remove only)" WriteRegStr HKLM "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"' - WriteRegStr HKCR "${prodname}\Shell\open\command\" "" '"$INSTDIR\${exec} "%1"' - - !ifdef icon - WriteRegStr HKCR "${prodname}\DefaultIcon" "" "$INSTDIR\${icon}" - !endif + WriteRegStr HKCR "${company}\Shell\open\command\" "" '"$INSTDIR\${interface_exec} "%1"' + WriteRegStr HKCR "${company}\DefaultIcon" "" "$INSTDIR\${interface_icon}" ; hifi:// protocol handler registry entries WriteRegStr HKCR 'hifi' '' 'URL:Alert Protocol' WriteRegStr HKCR 'hifi' 'URL Protocol' '' - WriteRegStr HKCR 'hifi\DefaultIcon' '' '$INSTDIR\${icon},1' - WriteRegStr HKCR 'hifi\shell\open\command' '' '$INSTDIR\${exec} --url "%1"' + WriteRegStr HKCR 'hifi\DefaultIcon' '' '$INSTDIR\${interface_icon},1' + WriteRegStr HKCR 'hifi\shell\open\command' '' '$INSTDIR\${interface_exec} --url "%1"' SetOutPath $INSTDIR ; package all files, recursively, preserving attributes ; assume files are in the correct places File /r "${srcdir}\" - !ifdef icon - File /a "${icon}" - !endif + File /a "${srcdir}\${interface_icon}" + File /a "${srcdir}\${stack_manager_icon}" ; any application-specific files !ifdef files !include "${files}" !endif - SetOutPath "$DOCUMENTS\${company}\Scripts" - File /r "${scriptsdir}\" - SetOutPath $INSTDIR WriteUninstaller "${uninstaller}" Exec '"$INSTDIR\2013_vcredist_x64.exe" /q /norestart' Exec '"$INSTDIR\2010_vcredist_x86.exe" /q /norestart' @@ -129,24 +121,20 @@ Section "Start Menu Shortcuts" SEC03 ; This should install the shortcuts for "All Users" SetShellVarContext all - CreateDirectory "${startmenu_product}" + CreateDirectory "${startmenu_company}" SetOutPath $INSTDIR ; for working directory - !ifdef icon - CreateShortCut "${startmenu_product}\${prodname}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\${icon}" - !else - CreateShortCut "${startmenu_product}\${prodname}.lnk" "$INSTDIR\${exec}" - !endif - - CreateShortCut "${startmenu_product}\Uninstall ${prodname}.lnk" "$INSTDIR\${uninstaller}" + CreateShortCut "${startmenu_company}\Interface.lnk" "$INSTDIR\${interface_exec}" "" "$INSTDIR\${interface_icon}" + CreateShortCut "${startmenu_company}\Stack Manager.lnk" "$INSTDIR\${stack_manager_exec}" "" "$INSTDIR\${stack_manager_icon}" + CreateShortCut "${startmenu_company}\Uninstall ${company}.lnk" "$INSTDIR\${uninstaller}" SectionEnd ; Uninstaller ; All section names prefixed by "Un" will be in the uninstaller -UninstallText "This will uninstall ${prodname}." +UninstallText "This will uninstall ${company}." !ifdef icon - UninstallIcon "${icon}" + UninstallIcon "${interface_icon}" !endif Section "Uninstall" SEC04 @@ -155,11 +143,10 @@ Section "Uninstall" SEC04 ; Explicitly remove all added shortcuts SetShellVarContext all - DELETE "${startmenu_product}\${prodname}.lnk" - DELETE "${startmenu_product}\Uninstall ${prodname}.lnk" + DELETE "${startmenu_company}\Interface.lnk" + DELETE "${startmenu_company}\Stack Manager.lnk" + DELETE "${startmenu_company}\Uninstall ${company}.lnk" - RMDIR "${startmenu_product}" - ; This should remove the High Fidelity folder in Start Menu if it's empty RMDIR "${startmenu_company}" RMDIR /r "$INSTDIR" From d3c57821c0338b70e068b01f2b5f6c9721609773 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 16 Dec 2015 14:00:04 -0800 Subject: [PATCH 06/20] call a method on actions before each physics simulation step. use this to attempt to dejitter held objects --- interface/src/Application.cpp | 3 + interface/src/avatar/AvatarActionHold.cpp | 70 ++++++++++++++++++- interface/src/avatar/AvatarActionHold.h | 14 ++-- .../entities/src/EntityActionInterface.h | 2 + libraries/physics/src/CharacterController.cpp | 13 ++++ libraries/physics/src/CharacterController.h | 2 + libraries/physics/src/ObjectAction.h | 34 ++++----- libraries/physics/src/ObjectActionOffset.h | 10 +-- libraries/physics/src/ObjectActionSpring.h | 10 +-- libraries/physics/src/PhysicsEngine.cpp | 8 +++ libraries/physics/src/PhysicsEngine.h | 1 + 11 files changed, 134 insertions(+), 33 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f3291469cb..e28d1b2eac 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2989,6 +2989,9 @@ void Application::update(float deltaTime) { _physicsEngine->changeObjects(motionStates); myAvatar->prepareForPhysicsSimulation(); + _physicsEngine->forEachAction([&](EntityActionPointer action) { + action->prepareForPhysicsSimulation(); + }); getEntities()->getTree()->withWriteLock([&] { _physicsEngine->stepSimulation(); diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index fab838aa68..87cf53143c 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -14,6 +14,7 @@ #include #include "avatar/AvatarManager.h" +#include "CharacterController.h" const uint16_t AvatarActionHold::holdVersion = 1; @@ -32,6 +33,57 @@ AvatarActionHold::~AvatarActionHold() { #endif } +void AvatarActionHold::prepareForPhysicsSimulation() { + auto avatarManager = DependencyManager::get(); + auto holdingAvatar = std::static_pointer_cast(avatarManager->getAvatarBySessionID(_holderID)); + + if (!holdingAvatar) { + return; + } + + withTryReadLock([&]{ + bool isRightHand = (_hand == "right"); + + if (_ignoreIK && holdingAvatar->isMyAvatar()) { + return; + } + + if (holdingAvatar->isMyAvatar()) { + glm::vec3 palmPosition { Vectors::ZERO }; + glm::quat palmRotation { Quaternions::IDENTITY }; + if (isRightHand) { + palmPosition = holdingAvatar->getHand()->getCopyOfPalmData(HandData::RightHand).getPosition(); + palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::RightHand).getRotation(); + } else { + palmPosition = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getPosition(); + palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getRotation(); + } + + // XXX dup code + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); + MyCharacterController* controller = myAvatar ? myAvatar->getCharacterController() : nullptr; + if (!controller) { + qDebug() << "AvatarActionHold::prepareForPhysicsSimulation failed to get character controller"; + return; + } + glm::vec3 avatarRigidBodyPosition; + glm::quat avatarRigidBodyRotation; + controller->getRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); + + + if (isRightHand) { + palmPosition = holdingAvatar->getRightPalmPosition(); + palmRotation = holdingAvatar->getRightPalmRotation(); + } else { + palmPosition = holdingAvatar->getLeftPalmPosition(); + palmRotation = holdingAvatar->getLeftPalmRotation(); + } + + _palmOffsetFromRigidBody = palmPosition - avatarRigidBodyPosition; + } + }); +} + std::shared_ptr AvatarActionHold::getTarget(glm::quat& rotation, glm::vec3& position) { auto avatarManager = DependencyManager::get(); auto holdingAvatar = std::static_pointer_cast(avatarManager->getAvatarBySessionID(_holderID)); @@ -44,7 +96,7 @@ std::shared_ptr AvatarActionHold::getTarget(glm::quat& rotation, glm::ve bool isRightHand = (_hand == "right"); glm::vec3 palmPosition { Vectors::ZERO }; glm::quat palmRotation { Quaternions::IDENTITY }; - + if (_ignoreIK && holdingAvatar->isMyAvatar()) { // We cannot ignore other avatars IK and this is not the point of this option // This is meant to make the grabbing behavior more reactive. @@ -55,6 +107,22 @@ std::shared_ptr AvatarActionHold::getTarget(glm::quat& rotation, glm::ve palmPosition = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getPosition(); palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getRotation(); } + } else if (holdingAvatar->isMyAvatar()) { + // XXX dup code + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); + MyCharacterController* controller = myAvatar ? myAvatar->getCharacterController() : nullptr; + if (!controller) { + qDebug() << "AvatarActionHold::prepareForPhysicsSimulation failed to get character controller"; + return; + } + glm::vec3 avatarRigidBodyPosition; + glm::quat avatarRigidBodyRotation; + controller->getRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); + + + + palmPosition = avatarRigidBodyPosition + _palmOffsetFromRigidBody; + palmRotation = holdingAvatar->getRightPalmRotation(); // XXX } else { if (isRightHand) { palmPosition = holdingAvatar->getRightPalmPosition(); diff --git a/interface/src/avatar/AvatarActionHold.h b/interface/src/avatar/AvatarActionHold.h index 63f30a75d9..2746c817ca 100644 --- a/interface/src/avatar/AvatarActionHold.h +++ b/interface/src/avatar/AvatarActionHold.h @@ -25,18 +25,20 @@ public: AvatarActionHold(const QUuid& id, EntityItemPointer ownerEntity); virtual ~AvatarActionHold(); - virtual bool updateArguments(QVariantMap arguments); - virtual QVariantMap getArguments(); + virtual bool updateArguments(QVariantMap arguments) override; + virtual QVariantMap getArguments() override; - virtual void updateActionWorker(float deltaTimeStep); + virtual void updateActionWorker(float deltaTimeStep) override; QByteArray serialize() const; - virtual void deserialize(QByteArray serializedArguments); + virtual void deserialize(QByteArray serializedArguments) override; - virtual bool shouldSuppressLocationEdits() { return _active && !_ownerEntity.expired(); } + virtual bool shouldSuppressLocationEdits() override { return _active && !_ownerEntity.expired(); } std::shared_ptr getTarget(glm::quat& rotation, glm::vec3& position); + virtual void prepareForPhysicsSimulation() override; + private: void doKinematicUpdate(float deltaTimeStep); @@ -56,6 +58,8 @@ private: float _previousDeltaTimeStep = 0.0f; glm::vec3 _previousPositionalDelta; + + glm::vec3 _palmOffsetFromRigidBody; }; #endif // hifi_AvatarActionHold_h diff --git a/libraries/entities/src/EntityActionInterface.h b/libraries/entities/src/EntityActionInterface.h index a192661e52..ba59d66cf4 100644 --- a/libraries/entities/src/EntityActionInterface.h +++ b/libraries/entities/src/EntityActionInterface.h @@ -58,6 +58,8 @@ public: virtual bool shouldSuppressLocationEdits() { return false; } + virtual void prepareForPhysicsSimulation() { } + // these look in the arguments map for a named argument. if it's not found or isn't well formed, // ok will be set to false (note that it's never set to true -- set it to true before calling these). // if required is true, failure to extract an argument will cause a warning to be printed. diff --git a/libraries/physics/src/CharacterController.cpp b/libraries/physics/src/CharacterController.cpp index 44d4269e0e..86d57b7ee9 100644 --- a/libraries/physics/src/CharacterController.cpp +++ b/libraries/physics/src/CharacterController.cpp @@ -15,6 +15,7 @@ #include "BulletUtil.h" #include "PhysicsCollisionGroups.h" +#include "ObjectMotionState.h" const btVector3 LOCAL_UP_AXIS(0.0f, 1.0f, 0.0f); const float JUMP_SPEED = 3.5f; @@ -379,3 +380,15 @@ void CharacterController::preSimulation() { void CharacterController::postSimulation() { // postSimulation() exists for symmetry and just in case we need to do something here later } + + +bool CharacterController::getRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation) { + if (!_rigidBody) { + return false; + } + + const btTransform& worldTrans = _rigidBody->getCenterOfMassTransform(); + avatarRigidBodyPosition = bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(); + avatarRigidBodyRotation = bulletToGLM(worldTrans.getRotation()); + return true; +} diff --git a/libraries/physics/src/CharacterController.h b/libraries/physics/src/CharacterController.h index 88c02d0940..7bdc35fc0b 100644 --- a/libraries/physics/src/CharacterController.h +++ b/libraries/physics/src/CharacterController.h @@ -79,6 +79,8 @@ public: void setEnabled(bool enabled); bool isEnabled() const { return _enabled && _dynamicsWorld; } + bool getRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation); + protected: void updateUpAxis(const glm::quat& rotation); diff --git a/libraries/physics/src/ObjectAction.h b/libraries/physics/src/ObjectAction.h index e44036eadc..4ca13f2fbf 100644 --- a/libraries/physics/src/ObjectAction.h +++ b/libraries/physics/src/ObjectAction.h @@ -29,12 +29,12 @@ public: ObjectAction(EntityActionType type, const QUuid& id, EntityItemPointer ownerEntity); virtual ~ObjectAction(); - virtual void removeFromSimulation(EntitySimulation* simulation) const; - virtual EntityItemWeakPointer getOwnerEntity() const { return _ownerEntity; } - virtual void setOwnerEntity(const EntityItemPointer ownerEntity) { _ownerEntity = ownerEntity; } + virtual void removeFromSimulation(EntitySimulation* simulation) const override; + virtual EntityItemWeakPointer getOwnerEntity() const override { return _ownerEntity; } + virtual void setOwnerEntity(const EntityItemPointer ownerEntity) override { _ownerEntity = ownerEntity; } - virtual bool updateArguments(QVariantMap arguments); - virtual QVariantMap getArguments(); + virtual bool updateArguments(QVariantMap arguments) override; + virtual QVariantMap getArguments() override; // this is called from updateAction and should be overridden by subclasses virtual void updateActionWorker(float deltaTimeStep) = 0; @@ -43,25 +43,25 @@ public: virtual void updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep); virtual void debugDraw(btIDebugDraw* debugDrawer); - virtual QByteArray serialize() const = 0; - virtual void deserialize(QByteArray serializedArguments) = 0; + virtual QByteArray serialize() const override = 0; + virtual void deserialize(QByteArray serializedArguments) override = 0; - virtual bool lifetimeIsOver(); - virtual quint64 getExpires() { return _expires; } + virtual bool lifetimeIsOver() override; + virtual quint64 getExpires() override { return _expires; } protected: quint64 localTimeToServerTime(quint64 timeValue) const; quint64 serverTimeToLocalTime(quint64 timeValue) const; virtual btRigidBody* getRigidBody(); - virtual glm::vec3 getPosition(); - virtual void setPosition(glm::vec3 position); - virtual glm::quat getRotation(); - virtual void setRotation(glm::quat rotation); - virtual glm::vec3 getLinearVelocity(); - virtual void setLinearVelocity(glm::vec3 linearVelocity); - virtual glm::vec3 getAngularVelocity(); - virtual void setAngularVelocity(glm::vec3 angularVelocity); + virtual glm::vec3 getPosition() override; + virtual void setPosition(glm::vec3 position) override; + virtual glm::quat getRotation() override; + virtual void setRotation(glm::quat rotation) override; + virtual glm::vec3 getLinearVelocity() override; + virtual void setLinearVelocity(glm::vec3 linearVelocity) override; + virtual glm::vec3 getAngularVelocity() override; + virtual void setAngularVelocity(glm::vec3 angularVelocity) override; virtual void activateBody(); virtual void forceBodyNonStatic(); diff --git a/libraries/physics/src/ObjectActionOffset.h b/libraries/physics/src/ObjectActionOffset.h index 1918da6996..ea01b10d33 100644 --- a/libraries/physics/src/ObjectActionOffset.h +++ b/libraries/physics/src/ObjectActionOffset.h @@ -22,13 +22,13 @@ public: ObjectActionOffset(const QUuid& id, EntityItemPointer ownerEntity); virtual ~ObjectActionOffset(); - virtual bool updateArguments(QVariantMap arguments); - virtual QVariantMap getArguments(); + virtual bool updateArguments(QVariantMap arguments) override; + virtual QVariantMap getArguments() override; - virtual void updateActionWorker(float deltaTimeStep); + virtual void updateActionWorker(float deltaTimeStep) override; - virtual QByteArray serialize() const; - virtual void deserialize(QByteArray serializedArguments); + virtual QByteArray serialize() const override; + virtual void deserialize(QByteArray serializedArguments) override; private: static const uint16_t offsetVersion; diff --git a/libraries/physics/src/ObjectActionSpring.h b/libraries/physics/src/ObjectActionSpring.h index caa64c3d3a..96bb900bf6 100644 --- a/libraries/physics/src/ObjectActionSpring.h +++ b/libraries/physics/src/ObjectActionSpring.h @@ -19,13 +19,13 @@ public: ObjectActionSpring(const QUuid& id, EntityItemPointer ownerEntity); virtual ~ObjectActionSpring(); - virtual bool updateArguments(QVariantMap arguments); - virtual QVariantMap getArguments(); + virtual bool updateArguments(QVariantMap arguments) override; + virtual QVariantMap getArguments() override; - virtual void updateActionWorker(float deltaTimeStep); + virtual void updateActionWorker(float deltaTimeStep) override; - virtual QByteArray serialize() const; - virtual void deserialize(QByteArray serializedArguments); + virtual QByteArray serialize() const override; + virtual void deserialize(QByteArray serializedArguments) override; protected: static const uint16_t springVersion; diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 10e285186c..22695a1b66 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -497,3 +497,11 @@ void PhysicsEngine::removeAction(const QUuid actionID) { _objectActions.remove(actionID); } } + +void PhysicsEngine::forEachAction(std::function actor) { + QHashIterator iter(_objectActions); + while (iter.hasNext()) { + iter.next(); + actor(iter.value()); + } +} diff --git a/libraries/physics/src/PhysicsEngine.h b/libraries/physics/src/PhysicsEngine.h index e7b5fd79d4..05032ccae2 100644 --- a/libraries/physics/src/PhysicsEngine.h +++ b/libraries/physics/src/PhysicsEngine.h @@ -97,6 +97,7 @@ public: EntityActionPointer getActionByID(const QUuid& actionID) const; void addAction(EntityActionPointer action); void removeAction(const QUuid actionID); + void forEachAction(std::function actor); private: void removeContacts(ObjectMotionState* motionState); From 66770cc907c654d03b01dd6dc3b5a294467955b8 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 16 Dec 2015 16:11:35 -0600 Subject: [PATCH 07/20] Finishing touches --- CMakeLists.txt | 6 ++++-- cmake/macros/IncludeApplicationVersion.cmake | 17 +++++++++++++---- tools/nsis/release.nsi | 13 +++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69e6365c8c..ca3e381405 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,8 +239,10 @@ if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE) build-package ALL DEPENDS interface assignment-client domain-server stack-manager COMMAND set INSTALLER_SOURCE_DIR=${CMAKE_BINARY_DIR}/full-stack-deployment - COMMAND set INSTALLER_NAME=${CMAKE_BINARY_DIR}/this-is-a-test.exe - COMMANE set INSTALLER_SCRIPTS_DIR=${CMAKE_SOURCE_DIR}/examples + COMMAND set INSTALLER_NAME=${CMAKE_BINARY_DIR}/${INSTALLER_NAME} + COMMAND set INSTALLER_SCRIPTS_DIR=${CMAKE_SOURCE_DIR}/examples + COMMAND set INSTALLER_COMPANY=${INSTALLER_COMPANY} + COMMAND set INSTALLER_DIRECTORY=${INSTALLER_DIRECTORY} COMMAND CMD /C "\"${MAKENSIS_COMMAND}\" ${CMAKE_SOURCE_DIR}/tools/nsis/release.nsi" ) endif () \ No newline at end of file diff --git a/cmake/macros/IncludeApplicationVersion.cmake b/cmake/macros/IncludeApplicationVersion.cmake index a91aad6acc..753a12a01c 100644 --- a/cmake/macros/IncludeApplicationVersion.cmake +++ b/cmake/macros/IncludeApplicationVersion.cmake @@ -14,13 +14,22 @@ macro(INCLUDE_APPLICATION_VERSION) # We are relying on Jenkins defined environment variables to determine the origin of this build # and will only package if this is a PR or Release build if (DEFINED ENV{JOB_ID}) - set (DEPLOY_PACKAGE 1) - set (BUILD_SEQ $ENV{JOB_ID}) + set(DEPLOY_PACKAGE 1) + set(BUILD_SEQ $ENV{JOB_ID}) + set(INSTALLER_COMPANY "High Fidelity") + set(INSTALLER_DIRECTORY "${INSTALLER_COMPANY}") + set(INSTALLER_NAME "interface-win64-${BUILD_SEQ}.exe") elseif (DEFINED ENV{ghprbPullId}) - set (DEPLOY_PACKAGE 1) - set (BUILD_SEQ "PR-$ENV{ghprbPullId}") + set(DEPLOY_PACKAGE 1) + set(BUILD_SEQ "PR-$ENV{ghprbPullId}") + set(INSTALLER_COMPANY "High Fidelity - PR") + set(INSTALLER_DIRECTORY "${INSTALLER_COMPANY}\\${BUILD_SEQ}") + set(INSTALLER_NAME "pr-interface-win64-${BUILD_SEQ}.exe") else () set(BUILD_SEQ "dev") + set(INSTALLER_COMPANY "High Fidelity - Dev") + set(INSTALLER_DIRECTORY "${INSTALLER_COMPANY}") + set(INSTALLER_NAME "dev-interface-win64.exe") endif () configure_file("${MACRO_DIR}/ApplicationVersion.h.in" "${PROJECT_BINARY_DIR}/includes/ApplicationVersion.h") include_directories("${PROJECT_BINARY_DIR}/includes") diff --git a/tools/nsis/release.nsi b/tools/nsis/release.nsi index 86ea055e6b..9bc75e5274 100644 --- a/tools/nsis/release.nsi +++ b/tools/nsis/release.nsi @@ -1,18 +1,19 @@ !include LogicLib.nsh !include x64.nsh -!define srcdir $%INSTALLER_SOURCE_DIR% -!define setup $%INSTALLER_NAME% -!define scriptsdir $%INSTALLER_SCRIPTS_DIR% -!define company $%INSTALLER_COMPANY% +!define srcdir "$%INSTALLER_SOURCE_DIR%" +!define setup "$%INSTALLER_NAME%" +!define scriptsdir "$%INSTALLER_SCRIPTS_DIR%" +!define company "$%INSTALLER_COMPANY%" +!define install_directory "$%INSTALLER_DIRECTORY%" !define interface_exec "interface.exe" !define stack_manager_exec "stack-manager.exe" !define interface_icon "interface.ico" !define stack_manager_icon "stack-manager.ico" !define regkey "Software\${company}" !define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${company}" -!define install_dir_company "$PROGRAMFILES64\${company}" -!define startmenu_company "$SMPROGRAMS\${company}" +!define install_dir_company "$PROGRAMFILES64\${install_directory}" +!define startmenu_company "$SMPROGRAMS\${install_directory}" !define uninstaller "uninstall.exe" ;-------------------------------- From 8bfbb69316712d5573aa435dc089c816de7f7c27 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 16 Dec 2015 14:21:56 -0800 Subject: [PATCH 08/20] clean up code, change try-locks to locks --- interface/src/avatar/AvatarActionHold.cpp | 89 ++++++++--------------- interface/src/avatar/AvatarActionHold.h | 1 + 2 files changed, 31 insertions(+), 59 deletions(-) diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index 87cf53143c..32d35e3f8f 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -33,6 +33,19 @@ AvatarActionHold::~AvatarActionHold() { #endif } +glm::vec3 AvatarActionHold::getAvatarRigidBodyPosition() { + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); + MyCharacterController* controller = myAvatar ? myAvatar->getCharacterController() : nullptr; + if (!controller) { + qDebug() << "AvatarActionHold::getAvatarRigidBodyPosition failed to get character controller"; + return glm::vec3(0.0f); + } + glm::vec3 avatarRigidBodyPosition; + glm::quat avatarRigidBodyRotation; + controller->getRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); + return avatarRigidBodyPosition; +} + void AvatarActionHold::prepareForPhysicsSimulation() { auto avatarManager = DependencyManager::get(); auto holdingAvatar = std::static_pointer_cast(avatarManager->getAvatarBySessionID(_holderID)); @@ -41,45 +54,14 @@ void AvatarActionHold::prepareForPhysicsSimulation() { return; } - withTryReadLock([&]{ - bool isRightHand = (_hand == "right"); - + withReadLock([&]{ if (_ignoreIK && holdingAvatar->isMyAvatar()) { return; } - if (holdingAvatar->isMyAvatar()) { - glm::vec3 palmPosition { Vectors::ZERO }; - glm::quat palmRotation { Quaternions::IDENTITY }; - if (isRightHand) { - palmPosition = holdingAvatar->getHand()->getCopyOfPalmData(HandData::RightHand).getPosition(); - palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::RightHand).getRotation(); - } else { - palmPosition = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getPosition(); - palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getRotation(); - } - - // XXX dup code - MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); - MyCharacterController* controller = myAvatar ? myAvatar->getCharacterController() : nullptr; - if (!controller) { - qDebug() << "AvatarActionHold::prepareForPhysicsSimulation failed to get character controller"; - return; - } - glm::vec3 avatarRigidBodyPosition; - glm::quat avatarRigidBodyRotation; - controller->getRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); - - - if (isRightHand) { - palmPosition = holdingAvatar->getRightPalmPosition(); - palmRotation = holdingAvatar->getRightPalmRotation(); - } else { - palmPosition = holdingAvatar->getLeftPalmPosition(); - palmRotation = holdingAvatar->getLeftPalmRotation(); - } - - _palmOffsetFromRigidBody = palmPosition - avatarRigidBodyPosition; + glm::vec3 palmPosition = (_hand == "right") ? + holdingAvatar->getRightPalmPosition() : holdingAvatar->getLeftPalmPosition(); + _palmOffsetFromRigidBody = palmPosition - getAvatarRigidBodyPosition(); } }); } @@ -92,7 +74,7 @@ std::shared_ptr AvatarActionHold::getTarget(glm::quat& rotation, glm::ve return holdingAvatar; } - withTryReadLock([&]{ + withReadLock([&]{ bool isRightHand = (_hand == "right"); glm::vec3 palmPosition { Vectors::ZERO }; glm::quat palmRotation { Quaternions::IDENTITY }; @@ -108,21 +90,12 @@ std::shared_ptr AvatarActionHold::getTarget(glm::quat& rotation, glm::ve palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getRotation(); } } else if (holdingAvatar->isMyAvatar()) { - // XXX dup code - MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); - MyCharacterController* controller = myAvatar ? myAvatar->getCharacterController() : nullptr; - if (!controller) { - qDebug() << "AvatarActionHold::prepareForPhysicsSimulation failed to get character controller"; - return; + palmPosition = getAvatarRigidBodyPosition() + _palmOffsetFromRigidBody; + if (isRightHand) { + palmRotation = holdingAvatar->getRightPalmRotation(); + } else { + palmRotation = holdingAvatar->getLeftPalmRotation(); } - glm::vec3 avatarRigidBodyPosition; - glm::quat avatarRigidBodyRotation; - controller->getRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); - - - - palmPosition = avatarRigidBodyPosition + _palmOffsetFromRigidBody; - palmRotation = holdingAvatar->getRightPalmRotation(); // XXX } else { if (isRightHand) { palmPosition = holdingAvatar->getRightPalmPosition(); @@ -171,21 +144,19 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) { if (valid && holdCount > 0) { position /= holdCount; - bool gotLock = withTryWriteLock([&]{ + withWriteLock([&]{ _positionalTarget = position; _rotationalTarget = rotation; _positionalTargetSet = true; _rotationalTargetSet = true; _active = true; }); - if (gotLock) { - if (_kinematic) { - doKinematicUpdate(deltaTimeStep); - } else { - activateBody(); - forceBodyNonStatic(); - ObjectActionSpring::updateActionWorker(deltaTimeStep); - } + if (_kinematic) { + doKinematicUpdate(deltaTimeStep); + } else { + activateBody(); + forceBodyNonStatic(); + ObjectActionSpring::updateActionWorker(deltaTimeStep); } } } diff --git a/interface/src/avatar/AvatarActionHold.h b/interface/src/avatar/AvatarActionHold.h index 2746c817ca..36a9aa3049 100644 --- a/interface/src/avatar/AvatarActionHold.h +++ b/interface/src/avatar/AvatarActionHold.h @@ -35,6 +35,7 @@ public: virtual bool shouldSuppressLocationEdits() override { return _active && !_ownerEntity.expired(); } + glm::vec3 getAvatarRigidBodyPosition(); std::shared_ptr getTarget(glm::quat& rotation, glm::vec3& position); virtual void prepareForPhysicsSimulation() override; From a7b61cf791387695126b9da9a56233ab06ab170a Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 16 Dec 2015 16:39:09 -0600 Subject: [PATCH 09/20] Couple of fixes --- CMakeLists.txt | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca3e381405..13d5b2bc79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.3.2) +cmake_minimum_required(VERSION 3.2) if (USE_ANDROID_TOOLCHAIN) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/android/android.toolchain.cmake") @@ -228,21 +228,4 @@ if (HIFI_MEMORY_DEBUGGING) endif () include_application_version() - -if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE) - file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/full-stack-deployment") - find_program(MAKENSIS_COMMAND makensis PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS]) - if (NOT MAKENSIS_COMMAND) - message(FATAL_ERROR "The Nullsoft Scriptable Install Systems is required for generating packaged installers on Windows (http://nsis.sourceforge.net/)") - endif () - add_custom_target( - build-package ALL - DEPENDS interface assignment-client domain-server stack-manager - COMMAND set INSTALLER_SOURCE_DIR=${CMAKE_BINARY_DIR}/full-stack-deployment - COMMAND set INSTALLER_NAME=${CMAKE_BINARY_DIR}/${INSTALLER_NAME} - COMMAND set INSTALLER_SCRIPTS_DIR=${CMAKE_SOURCE_DIR}/examples - COMMAND set INSTALLER_COMPANY=${INSTALLER_COMPANY} - COMMAND set INSTALLER_DIRECTORY=${INSTALLER_DIRECTORY} - COMMAND CMD /C "\"${MAKENSIS_COMMAND}\" ${CMAKE_SOURCE_DIR}/tools/nsis/release.nsi" - ) -endif () \ No newline at end of file +generate_installers() \ No newline at end of file From bbe444ffc1a4833f7b4bab49d81d02a02494782c Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 16 Dec 2015 16:40:51 -0600 Subject: [PATCH 10/20] Forgot to add file --- cmake/macros/GenerateInstallers.cmake | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cmake/macros/GenerateInstallers.cmake diff --git a/cmake/macros/GenerateInstallers.cmake b/cmake/macros/GenerateInstallers.cmake new file mode 100644 index 0000000000..570e24332b --- /dev/null +++ b/cmake/macros/GenerateInstallers.cmake @@ -0,0 +1,30 @@ +# +# GenerateInstallers.cmake +# cmake/macros +# +# Created by Leonardo Murillo on 12/16/2015. +# 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 +# + +macro(GENERATE_INSTALLERS) + if (DEFINED DEPLOY_PACKAGE AND DEPLOY_PACKAGE AND WIN32) + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/full-stack-deployment") + find_program(MAKENSIS_COMMAND makensis PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS]) + if (NOT MAKENSIS_COMMAND) + message(FATAL_ERROR "The Nullsoft Scriptable Install Systems is required for generating packaged installers on Windows (http://nsis.sourceforge.net/)") + endif () + add_custom_target( + build-package ALL + DEPENDS interface assignment-client domain-server stack-manager + COMMAND set INSTALLER_SOURCE_DIR=${CMAKE_BINARY_DIR}/full-stack-deployment + COMMAND set INSTALLER_NAME=${CMAKE_BINARY_DIR}/${INSTALLER_NAME} + COMMAND set INSTALLER_SCRIPTS_DIR=${CMAKE_SOURCE_DIR}/examples + COMMAND set INSTALLER_COMPANY=${INSTALLER_COMPANY} + COMMAND set INSTALLER_DIRECTORY=${INSTALLER_DIRECTORY} + COMMAND CMD /C "\"${MAKENSIS_COMMAND}\" ${CMAKE_SOURCE_DIR}/tools/nsis/release.nsi" + ) + endif () +endmacro() \ No newline at end of file From 489d4099a7dbd76f59fa2d7b62092de402ba5748 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 16 Dec 2015 15:21:20 -0800 Subject: [PATCH 11/20] add locationChanged to model entities --- interface/src/avatar/AvatarActionHold.cpp | 2 ++ .../entities-renderer/src/RenderableModelEntityItem.cpp | 8 ++++++++ .../entities-renderer/src/RenderableModelEntityItem.h | 1 + 3 files changed, 11 insertions(+) diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index 32d35e3f8f..160a437f44 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -199,6 +199,8 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) { motionState->dirtyInternalKinematicChanges(); + ownerEntity->setPosition(_positionalTarget); + _previousPositionalTarget = _positionalTarget; _previousRotationalTarget = _rotationalTarget; _previousSet = true; diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index b5203ea460..14e89b59fd 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -625,3 +625,11 @@ glm::vec3 RenderableModelEntityItem::getAbsoluteJointTranslationInObjectFrame(in } return glm::vec3(0.0f); } + +void RenderableModelEntityItem::locationChanged() { + EntityItem::locationChanged(); + if (_model && _model->isActive()) { + _model->setRotation(getRotation()); + _model->setTranslation(getPosition()); + } +} diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.h b/libraries/entities-renderer/src/RenderableModelEntityItem.h index 143113146e..cf948bd7a0 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.h +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.h @@ -73,6 +73,7 @@ public: virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override; virtual void loader() override; + virtual void locationChanged() override; private: void remapTextures(); From d7affcf811a8e5a46d5f201336effbeeec1584e3 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 16 Dec 2015 15:41:27 -0800 Subject: [PATCH 12/20] keep track of palm rotation vs avatar as well as palm translation --- interface/src/avatar/AvatarActionHold.cpp | 49 +++++++++++++++++------ interface/src/avatar/AvatarActionHold.h | 3 +- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index 160a437f44..5a4dbfa4d1 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -33,17 +33,15 @@ AvatarActionHold::~AvatarActionHold() { #endif } -glm::vec3 AvatarActionHold::getAvatarRigidBodyPosition() { +bool AvatarActionHold::getAvatarRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation) { MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); MyCharacterController* controller = myAvatar ? myAvatar->getCharacterController() : nullptr; if (!controller) { - qDebug() << "AvatarActionHold::getAvatarRigidBodyPosition failed to get character controller"; - return glm::vec3(0.0f); + qDebug() << "AvatarActionHold::getAvatarRigidBodyLocation failed to get character controller"; + return false; } - glm::vec3 avatarRigidBodyPosition; - glm::quat avatarRigidBodyRotation; controller->getRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); - return avatarRigidBodyPosition; + return true; } void AvatarActionHold::prepareForPhysicsSimulation() { @@ -59,9 +57,28 @@ void AvatarActionHold::prepareForPhysicsSimulation() { return; } if (holdingAvatar->isMyAvatar()) { - glm::vec3 palmPosition = (_hand == "right") ? - holdingAvatar->getRightPalmPosition() : holdingAvatar->getLeftPalmPosition(); - _palmOffsetFromRigidBody = palmPosition - getAvatarRigidBodyPosition(); + glm::vec3 palmPosition; + glm::quat palmRotation; + if (_hand == "right") { + palmPosition = holdingAvatar->getRightPalmPosition(); + palmRotation = holdingAvatar->getRightPalmRotation(); + } else { + palmPosition = holdingAvatar->getLeftPalmPosition(); + palmRotation = holdingAvatar->getLeftPalmRotation(); + } + + glm::vec3 avatarRigidBodyPosition; + glm::quat avatarRigidBodyRotation; + getAvatarRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); + + // determine the difference in translation and rotation between the avatar's + // rigid body and the palm position. The avatar's rigid body will be moved by bullet + // between this call and the call to getTarget, below. A call to get*PalmPosition in + // getTarget would get the palm position of the previous location of the avatar (because + // bullet has moved the av's rigid body but the rigid body's location has not yet been + // copied out into the Avatar class. + _palmOffsetFromRigidBody = palmPosition - avatarRigidBodyPosition; + _palmRotationFromRigidBody = glm::inverse(avatarRigidBodyRotation) * palmRotation; } }); } @@ -90,7 +107,17 @@ std::shared_ptr AvatarActionHold::getTarget(glm::quat& rotation, glm::ve palmRotation = holdingAvatar->getHand()->getCopyOfPalmData(HandData::LeftHand).getRotation(); } } else if (holdingAvatar->isMyAvatar()) { - palmPosition = getAvatarRigidBodyPosition() + _palmOffsetFromRigidBody; + glm::vec3 avatarRigidBodyPosition; + glm::quat avatarRigidBodyRotation; + getAvatarRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); + + // the offset and rotation between the avatar's rigid body and the palm were determined earlier + // in prepareForPhysicsSimulation. At this point, the avatar's rigid body has been moved by bullet + // and the data in the Avatar class is stale. This means that the result of get*PalmPosition will + // be stale. Instead, determine the current palm position with the current avatar's rigid body + // location and the saved offsets. + palmPosition = avatarRigidBodyPosition + _palmOffsetFromRigidBody; + palmRotation = avatarRigidBodyRotation * _palmRotationFromRigidBody; if (isRightHand) { palmRotation = holdingAvatar->getRightPalmRotation(); } else { @@ -199,8 +226,6 @@ void AvatarActionHold::doKinematicUpdate(float deltaTimeStep) { motionState->dirtyInternalKinematicChanges(); - ownerEntity->setPosition(_positionalTarget); - _previousPositionalTarget = _positionalTarget; _previousRotationalTarget = _rotationalTarget; _previousSet = true; diff --git a/interface/src/avatar/AvatarActionHold.h b/interface/src/avatar/AvatarActionHold.h index 36a9aa3049..fc8baf6dcc 100644 --- a/interface/src/avatar/AvatarActionHold.h +++ b/interface/src/avatar/AvatarActionHold.h @@ -35,7 +35,7 @@ public: virtual bool shouldSuppressLocationEdits() override { return _active && !_ownerEntity.expired(); } - glm::vec3 getAvatarRigidBodyPosition(); + bool getAvatarRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation); std::shared_ptr getTarget(glm::quat& rotation, glm::vec3& position); virtual void prepareForPhysicsSimulation() override; @@ -61,6 +61,7 @@ private: glm::vec3 _previousPositionalDelta; glm::vec3 _palmOffsetFromRigidBody; + glm::quat _palmRotationFromRigidBody; }; #endif // hifi_AvatarActionHold_h From 5f9bdcb2aa6ba705ac3173cdebf9fbb171e03b90 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 16 Dec 2015 15:52:20 -0800 Subject: [PATCH 13/20] fix lock type --- interface/src/avatar/AvatarActionHold.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index 5a4dbfa4d1..34b959575d 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -52,7 +52,7 @@ void AvatarActionHold::prepareForPhysicsSimulation() { return; } - withReadLock([&]{ + withWriteLock([&]{ if (_ignoreIK && holdingAvatar->isMyAvatar()) { return; } From 1b0856307976ab348027491b795997b0368551f9 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 16 Dec 2015 16:56:49 -0800 Subject: [PATCH 14/20] ParticleEffectEntityItem: fix for invalid iterator increment Was causing an assert in debug, due to calling ++ on an invalid iterator. In release this might lead to memory corruption. --- libraries/entities/src/ParticleEffectEntityItem.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 5600c85650..533b077a9c 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -595,19 +595,24 @@ void ParticleEffectEntityItem::integrateParticle(Particle& particle, float delta void ParticleEffectEntityItem::stepSimulation(float deltaTime) { // update particles between head and tail + int popCount = 0; for (Particle& particle : _particles) { particle.lifetime += deltaTime; // if particle has died. if (particle.lifetime >= _lifespan) { // move head forward - _particles.pop_front(); + popCount++; } else { // Otherwise update it integrateParticle(particle, deltaTime); } } + for (int i = 0; i < popCount; i++) { + _particles.pop_front(); + } + // emit new particles, but only if we are emmitting if (getIsEmitting() && _emitRate > 0.0f && _lifespan > 0.0f && _polarStart <= _polarFinish) { From 2eecb61da5a5c9f130522e0cf3cd6907fc5ef95b Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 16 Dec 2015 19:08:31 -0800 Subject: [PATCH 15/20] Prefer erase over repeated pop_front calls --- libraries/entities/src/ParticleEffectEntityItem.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 533b077a9c..165afd1536 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -608,10 +608,7 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) { integrateParticle(particle, deltaTime); } } - - for (int i = 0; i < popCount; i++) { - _particles.pop_front(); - } + _particles.erase(_particles.begin(), _particles.begin() + popCount); // emit new particles, but only if we are emmitting if (getIsEmitting() && _emitRate > 0.0f && _lifespan > 0.0f && _polarStart <= _polarFinish) { From 286b984d6fd0cb693b8465123ede179476c84893 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 17 Dec 2015 10:48:33 -0800 Subject: [PATCH 16/20] serve SHTML files with HTML MIME type --- libraries/embedded-webserver/src/HTTPManager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/embedded-webserver/src/HTTPManager.cpp b/libraries/embedded-webserver/src/HTTPManager.cpp index 1f1dfa1735..0b98d52cb1 100644 --- a/libraries/embedded-webserver/src/HTTPManager.cpp +++ b/libraries/embedded-webserver/src/HTTPManager.cpp @@ -145,9 +145,14 @@ bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, localFileData = localFileString.toLocal8Bit(); } - - connection->respond(HTTPConnection::StatusCode200, localFileData, - qPrintable(mimeDatabase.mimeTypeForFile(filePath).name())); + + // if this is an shtml file just make the MIME type match HTML so browsers aren't confused + auto mimeType = QString { "text/html" }; + if (localFileInfo.suffix() != "shtml") { + mimeType = mimeDatabase.mimeTypeForFile(filePath).name(); + } + + connection->respond(HTTPConnection::StatusCode200, localFileData, qPrintable(mimeType)); return true; } From 08f42c08d9e5286ee4483b3f40654c3adf4258c7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 17 Dec 2015 10:54:32 -0800 Subject: [PATCH 17/20] use a ternary for single assignment --- libraries/embedded-webserver/src/HTTPManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/embedded-webserver/src/HTTPManager.cpp b/libraries/embedded-webserver/src/HTTPManager.cpp index 0b98d52cb1..4c804f2e7b 100644 --- a/libraries/embedded-webserver/src/HTTPManager.cpp +++ b/libraries/embedded-webserver/src/HTTPManager.cpp @@ -147,10 +147,10 @@ bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, } // if this is an shtml file just make the MIME type match HTML so browsers aren't confused - auto mimeType = QString { "text/html" }; - if (localFileInfo.suffix() != "shtml") { - mimeType = mimeDatabase.mimeTypeForFile(filePath).name(); - } + // otherwise use the mimeDatabase to look it up + auto mimeType = localFileInfo.suffix() == "shtml" + ? QString { "text/html" } + : mimeDatabase.mimeTypeForFile(filePath).name(); connection->respond(HTTPConnection::StatusCode200, localFileData, qPrintable(mimeType)); From 06e9731fe4f626366f1120b2a85a727b79200ff1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 17 Dec 2015 11:07:36 -0800 Subject: [PATCH 18/20] don't attempt to read an empty or malformed packet --- libraries/networking/src/udt/Socket.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 11f1b043c8..8fb5db3853 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -236,8 +236,14 @@ void Socket::readPendingDatagrams() { auto buffer = std::unique_ptr(new char[packetSizeWithHeader]); // pull the datagram - _udpSocket.readDatagram(buffer.get(), packetSizeWithHeader, - senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer()); + auto sizeRead = _udpSocket.readDatagram(buffer.get(), packetSizeWithHeader, + senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer()); + + if (sizeRead <= 0) { + // we either didn't pull anything for this packet or there was an error reading (this seems to trigger + // on windows even if there's not a packet available) + continue; + } auto it = _unfilteredHandlers.find(senderSockAddr); @@ -248,7 +254,7 @@ void Socket::readPendingDatagrams() { it->second(std::move(basePacket)); } - return; + continue; } // check if this was a control packet or a data packet @@ -276,7 +282,7 @@ void Socket::readPendingDatagrams() { packet->getDataSize(), packet->getPayloadSize())) { // the connection indicated that we should not continue processing this packet - return; + continue; } } From f3adb8a2f70264af4eb50b93b314065ce88d059b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 17 Dec 2015 11:16:59 -0800 Subject: [PATCH 19/20] fix offset math in hold action --- interface/src/avatar/AvatarActionHold.cpp | 55 +++++++++++------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index 34b959575d..b2343c8bce 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -48,38 +48,38 @@ void AvatarActionHold::prepareForPhysicsSimulation() { auto avatarManager = DependencyManager::get(); auto holdingAvatar = std::static_pointer_cast(avatarManager->getAvatarBySessionID(_holderID)); - if (!holdingAvatar) { + if (!holdingAvatar || !holdingAvatar->isMyAvatar()) { return; } withWriteLock([&]{ - if (_ignoreIK && holdingAvatar->isMyAvatar()) { + if (_ignoreIK) { return; } - if (holdingAvatar->isMyAvatar()) { - glm::vec3 palmPosition; - glm::quat palmRotation; - if (_hand == "right") { - palmPosition = holdingAvatar->getRightPalmPosition(); - palmRotation = holdingAvatar->getRightPalmRotation(); - } else { - palmPosition = holdingAvatar->getLeftPalmPosition(); - palmRotation = holdingAvatar->getLeftPalmRotation(); - } - glm::vec3 avatarRigidBodyPosition; - glm::quat avatarRigidBodyRotation; - getAvatarRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); - - // determine the difference in translation and rotation between the avatar's - // rigid body and the palm position. The avatar's rigid body will be moved by bullet - // between this call and the call to getTarget, below. A call to get*PalmPosition in - // getTarget would get the palm position of the previous location of the avatar (because - // bullet has moved the av's rigid body but the rigid body's location has not yet been - // copied out into the Avatar class. - _palmOffsetFromRigidBody = palmPosition - avatarRigidBodyPosition; - _palmRotationFromRigidBody = glm::inverse(avatarRigidBodyRotation) * palmRotation; + glm::vec3 palmPosition; + glm::quat palmRotation; + if (_hand == "right") { + palmPosition = holdingAvatar->getRightPalmPosition(); + palmRotation = holdingAvatar->getRightPalmRotation(); + } else { + palmPosition = holdingAvatar->getLeftPalmPosition(); + palmRotation = holdingAvatar->getLeftPalmRotation(); } + + glm::vec3 avatarRigidBodyPosition; + glm::quat avatarRigidBodyRotation; + getAvatarRigidBodyLocation(avatarRigidBodyPosition, avatarRigidBodyRotation); + + // determine the difference in translation and rotation between the avatar's + // rigid body and the palm position. The avatar's rigid body will be moved by bullet + // between this call and the call to getTarget, below. A call to get*PalmPosition in + // getTarget would get the palm position of the previous location of the avatar (because + // bullet has moved the av's rigid body but the rigid body's location has not yet been + // copied out into the Avatar class. + glm::quat avatarRotationInverse = glm::inverse(avatarRigidBodyRotation); + _palmOffsetFromRigidBody = avatarRotationInverse * (palmPosition - avatarRigidBodyPosition); + _palmRotationFromRigidBody = avatarRotationInverse * palmRotation; }); } @@ -116,13 +116,8 @@ std::shared_ptr AvatarActionHold::getTarget(glm::quat& rotation, glm::ve // and the data in the Avatar class is stale. This means that the result of get*PalmPosition will // be stale. Instead, determine the current palm position with the current avatar's rigid body // location and the saved offsets. - palmPosition = avatarRigidBodyPosition + _palmOffsetFromRigidBody; + palmPosition = avatarRigidBodyPosition + avatarRigidBodyRotation * _palmOffsetFromRigidBody; palmRotation = avatarRigidBodyRotation * _palmRotationFromRigidBody; - if (isRightHand) { - palmRotation = holdingAvatar->getRightPalmRotation(); - } else { - palmRotation = holdingAvatar->getLeftPalmRotation(); - } } else { if (isRightHand) { palmPosition = holdingAvatar->getRightPalmPosition(); From b80fa1c8064c23bb3709593dafcef968cb7e1aa3 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 17 Dec 2015 11:46:41 -0800 Subject: [PATCH 20/20] code review --- interface/src/avatar/AvatarActionHold.cpp | 29 +++++++++++++++++++---- interface/src/avatar/AvatarActionHold.h | 3 ++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index b2343c8bce..be562e2773 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -78,8 +78,16 @@ void AvatarActionHold::prepareForPhysicsSimulation() { // bullet has moved the av's rigid body but the rigid body's location has not yet been // copied out into the Avatar class. glm::quat avatarRotationInverse = glm::inverse(avatarRigidBodyRotation); - _palmOffsetFromRigidBody = avatarRotationInverse * (palmPosition - avatarRigidBodyPosition); - _palmRotationFromRigidBody = avatarRotationInverse * palmRotation; + + // the offset should be in the frame of the avatar, but something about the order + // things are updated makes this wrong: + // _palmOffsetFromRigidBody = avatarRotationInverse * (palmPosition - avatarRigidBodyPosition); + // I'll leave it here as a comment in case avatar handling changes. + _palmOffsetFromRigidBody = palmPosition - avatarRigidBodyPosition; + + // rotation should also be needed, but again, the order of updates makes this unneeded. leaving + // code here for future reference. + // _palmRotationFromRigidBody = avatarRotationInverse * palmRotation; }); } @@ -116,8 +124,21 @@ std::shared_ptr AvatarActionHold::getTarget(glm::quat& rotation, glm::ve // and the data in the Avatar class is stale. This means that the result of get*PalmPosition will // be stale. Instead, determine the current palm position with the current avatar's rigid body // location and the saved offsets. - palmPosition = avatarRigidBodyPosition + avatarRigidBodyRotation * _palmOffsetFromRigidBody; - palmRotation = avatarRigidBodyRotation * _palmRotationFromRigidBody; + + // this line is more correct but breaks for the current way avatar data is updated. + // palmPosition = avatarRigidBodyPosition + avatarRigidBodyRotation * _palmOffsetFromRigidBody; + // instead, use this for now: + palmPosition = avatarRigidBodyPosition + _palmOffsetFromRigidBody; + + // the item jitters the least by getting the rotation based on the opinion of Avatar.h rather + // than that of the rigid body. leaving this next line here for future reference: + // palmRotation = avatarRigidBodyRotation * _palmRotationFromRigidBody; + + if (isRightHand) { + palmRotation = holdingAvatar->getRightPalmRotation(); + } else { + palmRotation = holdingAvatar->getLeftPalmRotation(); + } } else { if (isRightHand) { palmPosition = holdingAvatar->getRightPalmPosition(); diff --git a/interface/src/avatar/AvatarActionHold.h b/interface/src/avatar/AvatarActionHold.h index fc8baf6dcc..b97ec59780 100644 --- a/interface/src/avatar/AvatarActionHold.h +++ b/interface/src/avatar/AvatarActionHold.h @@ -61,7 +61,8 @@ private: glm::vec3 _previousPositionalDelta; glm::vec3 _palmOffsetFromRigidBody; - glm::quat _palmRotationFromRigidBody; + // leaving this here for future refernece. + // glm::quat _palmRotationFromRigidBody; }; #endif // hifi_AvatarActionHold_h