mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-12 08:31:19 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into record_feature
This commit is contained in:
commit
33d646d92d
107 changed files with 1203 additions and 3028 deletions
|
@ -44,6 +44,18 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
|
||||
|
||||
set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros")
|
||||
|
||||
file(GLOB HIFI_CUSTOM_MACROS "cmake/macros/*.cmake")
|
||||
foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS})
|
||||
include(${CUSTOM_MACRO})
|
||||
endforeach()
|
||||
|
||||
# targets on all platforms
|
||||
add_subdirectory(assignment-client)
|
||||
add_subdirectory(domain-server)
|
||||
|
|
|
@ -1,47 +1,17 @@
|
|||
set(TARGET_NAME assignment-client)
|
||||
|
||||
set(ROOT_DIR ..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
setup_hifi_project(Core Gui Network Script Widgets)
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/")
|
||||
|
||||
find_package(Qt5 COMPONENTS Network Script Widgets)
|
||||
|
||||
include("${MACRO_DIR}/SetupHifiProject.cmake")
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
|
||||
# include glm
|
||||
include("${MACRO_DIR}/IncludeGLM.cmake")
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
include_glm()
|
||||
|
||||
# link in the shared libraries
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(audio ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(avatars ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_libraries(
|
||||
audio avatars octree voxels fbx particles models metavoxels
|
||||
networking animation shared script-engine embedded-webserver
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS})
|
||||
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${CMAKE_DL_LIBS})
|
||||
endif (UNIX)
|
||||
|
||||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
link_shared_dependencies()
|
|
@ -115,7 +115,7 @@ void Agent::readPendingDatagrams() {
|
|||
sourceNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||
|
||||
QByteArray mutablePacket = receivedPacket;
|
||||
ssize_t messageLength = mutablePacket.size();
|
||||
int messageLength = mutablePacket.size();
|
||||
|
||||
if (datagramPacketType == PacketTypeOctreeStats) {
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include <QThread>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include "ScriptableAvatar.h"
|
||||
|
||||
ScriptableAvatar::ScriptableAvatar(ScriptEngine* scriptEngine) : _scriptEngine(scriptEngine), _animation(NULL) {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(AUTO_MTC TARGET ROOT_DIR)
|
||||
set(AUTOMTC_SRC ${TARGET}_automtc.cpp)
|
||||
macro(AUTO_MTC)
|
||||
set(AUTOMTC_SRC ${TARGET_NAME}_automtc.cpp)
|
||||
|
||||
file(GLOB INCLUDE_FILES src/*.h)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(INCLUDE_GLM TARGET ROOT_DIR)
|
||||
macro(INCLUDE_GLM)
|
||||
|
||||
find_package(GLM REQUIRED)
|
||||
include_directories("${GLM_INCLUDE_DIRS}")
|
||||
|
@ -16,4 +16,4 @@ macro(INCLUDE_GLM TARGET ROOT_DIR)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GLM_INCLUDE_DIRS}")
|
||||
endif ()
|
||||
|
||||
endmacro(INCLUDE_GLM _target _root_dir)
|
||||
endmacro(INCLUDE_GLM)
|
14
cmake/macros/IncludeHifiLibraryHeaders.cmake
Normal file
14
cmake/macros/IncludeHifiLibraryHeaders.cmake
Normal file
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# IncludeHifiLibraryHeaders.cmake
|
||||
# cmake/macros
|
||||
#
|
||||
# Copyright 2014 High Fidelity, Inc.
|
||||
# Created by Stephen Birarda on August 8, 2014
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(include_hifi_library_headers LIBRARY)
|
||||
include_directories("${HIFI_LIBRARY_DIR}/${LIBRARY}/src")
|
||||
endmacro(include_hifi_library_headers _library _root_dir)
|
34
cmake/macros/LinkHifiLibraries.cmake
Normal file
34
cmake/macros/LinkHifiLibraries.cmake
Normal file
|
@ -0,0 +1,34 @@
|
|||
#
|
||||
# LinkHifiLibrary.cmake
|
||||
#
|
||||
# Copyright 2013 High Fidelity, Inc.
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(LINK_HIFI_LIBRARIES)
|
||||
|
||||
file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}")
|
||||
|
||||
set(LIBRARIES_TO_LINK ${ARGN})
|
||||
|
||||
foreach(HIFI_LIBRARY ${LIBRARIES_TO_LINK})
|
||||
if (NOT TARGET ${HIFI_LIBRARY})
|
||||
add_subdirectory("${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}" "${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}")
|
||||
endif ()
|
||||
|
||||
include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src")
|
||||
|
||||
add_dependencies(${TARGET_NAME} ${HIFI_LIBRARY})
|
||||
|
||||
# link the actual library - it is static so don't bubble it up
|
||||
target_link_libraries(${TARGET_NAME} ${HIFI_LIBRARY})
|
||||
|
||||
# ask the library what its dynamic dependencies are and link them
|
||||
get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES)
|
||||
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${LINKED_TARGET_DEPENDENCY_LIBRARIES})
|
||||
|
||||
endforeach()
|
||||
|
||||
endmacro(LINK_HIFI_LIBRARIES)
|
|
@ -1,27 +0,0 @@
|
|||
#
|
||||
# LinkHifiLibrary.cmake
|
||||
#
|
||||
# Copyright 2013 High Fidelity, Inc.
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR)
|
||||
|
||||
if (NOT TARGET ${LIBRARY})
|
||||
add_subdirectory("${ROOT_DIR}/libraries/${LIBRARY}" "${ROOT_DIR}/libraries/${LIBRARY}")
|
||||
endif ()
|
||||
|
||||
include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src")
|
||||
|
||||
add_dependencies(${TARGET} ${LIBRARY})
|
||||
target_link_libraries(${TARGET} ${LIBRARY})
|
||||
|
||||
if (APPLE)
|
||||
# currently the "shared" library requires CoreServices
|
||||
# link in required OS X framework
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreServices")
|
||||
endif ()
|
||||
|
||||
endmacro(LINK_HIFI_LIBRARY _library _target _root_dir)
|
25
cmake/macros/LinkSharedDependencies.cmake
Normal file
25
cmake/macros/LinkSharedDependencies.cmake
Normal file
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# LinkSharedDependencies.cmake
|
||||
# cmake/macros
|
||||
#
|
||||
# Copyright 2014 High Fidelity, Inc.
|
||||
# Created by Stephen Birarda on August 8, 2014
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(LINK_SHARED_DEPENDENCIES)
|
||||
if (${TARGET_NAME}_LIBRARIES_TO_LINK)
|
||||
list(REMOVE_DUPLICATES ${TARGET_NAME}_LIBRARIES_TO_LINK)
|
||||
|
||||
# link these libraries to our target
|
||||
target_link_libraries(${TARGET_NAME} ${${TARGET_NAME}_LIBRARIES_TO_LINK})
|
||||
endif ()
|
||||
|
||||
# we've already linked our Qt modules, but we need to bubble them up to parents
|
||||
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${${TARGET}_QT_MODULES_TO_LINK}")
|
||||
|
||||
# set the property on this target so it can be retreived by targets linking to us
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${${TARGET}_LIBRARIES_TO_LINK}")
|
||||
endmacro(LINK_SHARED_DEPENDENCIES)
|
|
@ -7,20 +7,27 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(SETUP_HIFI_LIBRARY TARGET)
|
||||
macro(SETUP_HIFI_LIBRARY)
|
||||
|
||||
project(${TARGET})
|
||||
project(${TARGET_NAME})
|
||||
|
||||
# grab the implemenation and header files
|
||||
file(GLOB LIB_SRCS src/*.h src/*.cpp)
|
||||
set(LIB_SRCS ${LIB_SRCS} ${WRAPPED_SRCS})
|
||||
set(LIB_SRCS ${LIB_SRCS})
|
||||
|
||||
# create a library and set the property so it can be referenced later
|
||||
add_library(${TARGET} ${LIB_SRCS} ${ARGN})
|
||||
add_library(${TARGET_NAME} ${LIB_SRCS} ${AUTOMTC_SRC})
|
||||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
qt5_use_modules(${TARGET} Core)
|
||||
|
||||
target_link_libraries(${TARGET} ${QT_LIBRARIES})
|
||||
|
||||
endmacro(SETUP_HIFI_LIBRARY _target)
|
||||
set(QT_MODULES_TO_LINK ${ARGN})
|
||||
list(APPEND QT_MODULES_TO_LINK Core)
|
||||
|
||||
find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK} REQUIRED)
|
||||
|
||||
foreach(QT_MODULE ${QT_MODULES_TO_LINK})
|
||||
get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION)
|
||||
|
||||
# add the actual path to the Qt module to our LIBRARIES_TO_LINK variable
|
||||
target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE})
|
||||
list(APPEND ${TARGET_NAME}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION})
|
||||
endforeach()
|
||||
endmacro(SETUP_HIFI_LIBRARY)
|
|
@ -7,8 +7,8 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT)
|
||||
project(${TARGET})
|
||||
macro(SETUP_HIFI_PROJECT)
|
||||
project(${TARGET_NAME})
|
||||
|
||||
# grab the implemenation and header files
|
||||
file(GLOB TARGET_SRCS src/*)
|
||||
|
@ -23,12 +23,19 @@ macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT)
|
|||
endforeach()
|
||||
|
||||
# add the executable, include additional optional sources
|
||||
add_executable(${TARGET} ${TARGET_SRCS} ${ARGN})
|
||||
add_executable(${TARGET_NAME} ${TARGET_SRCS} "${AUTOMTC_SRC}")
|
||||
|
||||
if (${INCLUDE_QT})
|
||||
find_package(Qt5Core REQUIRED)
|
||||
qt5_use_modules(${TARGET} Core)
|
||||
endif ()
|
||||
set(QT_MODULES_TO_LINK ${ARGN})
|
||||
list(APPEND QT_MODULES_TO_LINK Core)
|
||||
|
||||
find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK} REQUIRED)
|
||||
|
||||
foreach(QT_MODULE ${QT_MODULES_TO_LINK})
|
||||
target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE})
|
||||
|
||||
# add the actual path to the Qt module to our LIBRARIES_TO_LINK variable
|
||||
get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION)
|
||||
list(APPEND ${TARGET_NAME}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION})
|
||||
endforeach()
|
||||
|
||||
target_link_libraries(${TARGET} ${QT_LIBRARIES})
|
||||
endmacro()
|
|
@ -29,6 +29,8 @@ include(SelectLibraryConfigurations)
|
|||
if (APPLE)
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/MacOS/Debug HINTS ${OCULUS_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/MacOS/Release HINTS ${OCULUS_SEARCH_DIRS})
|
||||
find_library(ApplicationServices ApplicationServices)
|
||||
find_library(IOKit IOKit)
|
||||
elseif (UNIX)
|
||||
find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/)
|
||||
find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/)
|
||||
|
@ -53,12 +55,16 @@ endif ()
|
|||
select_library_configurations(LIBOVR)
|
||||
set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARY}")
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
if (APPLE)
|
||||
set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" ${IOKit} ${ApplicationServices})
|
||||
elseif (UNIX)
|
||||
set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}")
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
if (UNIX AND NOT APPLE)
|
||||
if (APPLE)
|
||||
find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES IOKit ApplicationServices)
|
||||
elseif (UNIX)
|
||||
find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY)
|
||||
else ()
|
||||
find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES)
|
||||
|
|
|
@ -26,10 +26,12 @@ find_path(QXMPP_INCLUDE_DIRS QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${Q
|
|||
find_library(QXMPP_LIBRARY_RELEASE NAMES qxmpp PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS})
|
||||
find_library(QXMPP_LIBRARY_DEBUG NAMES qxmpp_d PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS})
|
||||
|
||||
find_package(Qt5 COMPONENTS Xml REQUIRED)
|
||||
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(QXMPP)
|
||||
|
||||
set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}")
|
||||
set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}" Qt5::Xml)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES)
|
||||
|
|
|
@ -32,6 +32,9 @@ if (APPLE)
|
|||
find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS})
|
||||
find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib HINTS ${VISAGE_SEARCH_DIRS})
|
||||
|
||||
find_library(AppKit AppKit)
|
||||
find_library(QuartzCore QuartzCore)
|
||||
find_library(QTKit QTKit)
|
||||
elseif (WIN32)
|
||||
find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS})
|
||||
find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h PATH_SUFFIXES dependencies/OpenCV/include HINTS ${VISAGE_SEARCH_DIRS})
|
||||
|
@ -43,16 +46,22 @@ elseif (WIN32)
|
|||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(VISAGE DEFAULT_MSG
|
||||
VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR
|
||||
VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY
|
||||
)
|
||||
|
||||
list(APPEND VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR
|
||||
VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR
|
||||
VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY)
|
||||
|
||||
if (APPLE)
|
||||
list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit QTKit)
|
||||
endif ()
|
||||
|
||||
find_package_handle_standard_args(VISAGE DEFAULT_MSG ${VISAGE_ARGS_LIST})
|
||||
|
||||
set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR}" "${VISAGE_OPENCV2_INCLUDE_DIR}" "${VISAGE_BASE_INCLUDE_DIR}")
|
||||
set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}")
|
||||
|
||||
mark_as_advanced(
|
||||
VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES
|
||||
VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR
|
||||
VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY VISAGE_SEARCH_DIRS
|
||||
)
|
||||
if (APPLE)
|
||||
list(APPEND VISAGE_LIBRARIES ${QuartzCore} ${AppKit} ${QTKit})
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES)
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
if (WIN32)
|
||||
cmake_policy (SET CMP0020 NEW)
|
||||
endif (WIN32)
|
||||
|
||||
set(TARGET_NAME domain-server)
|
||||
|
||||
set(ROOT_DIR ..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/")
|
||||
|
||||
# set up the external glm library
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
find_package(Qt5Network REQUIRED)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
# setup the project and link required Qt modules
|
||||
setup_hifi_project(Network)
|
||||
|
||||
# remove and then copy the files for the webserver
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
|
@ -29,20 +12,7 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
|||
"${PROJECT_SOURCE_DIR}/resources/web"
|
||||
$<TARGET_FILE_DIR:${TARGET_NAME}>/resources/web)
|
||||
|
||||
# link the shared hifi library
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}")
|
||||
# link the shared hifi libraries
|
||||
link_hifi_libraries(embedded-webserver networking shared)
|
||||
|
||||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# link QtNetwork
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
link_shared_dependencies()
|
|
@ -1,12 +1,6 @@
|
|||
set(ROOT_DIR ..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
set(TARGET_NAME interface)
|
||||
project(${TARGET_NAME})
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/")
|
||||
|
||||
# set a default root dir for each of our optional externals if it was not passed
|
||||
set(OPTIONAL_EXTERNALS "faceplus" "faceshift" "oculus" "priovr" "sixense" "visage" "leapmotion" "rtmidi" "qxmpp")
|
||||
foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
|
||||
|
@ -38,8 +32,7 @@ elseif (WIN32)
|
|||
endif ()
|
||||
|
||||
# set up the external glm library
|
||||
include("${MACRO_DIR}/IncludeGLM.cmake")
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
include_glm()
|
||||
|
||||
# create the InterfaceConfig.h file based on GL_HEADERS above
|
||||
configure_file(InterfaceConfig.h.in "${PROJECT_BINARY_DIR}/includes/InterfaceConfig.h")
|
||||
|
@ -52,7 +45,7 @@ foreach(SUBDIR avatar devices renderer ui starfield location scripting voxels pa
|
|||
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}")
|
||||
endforeach(SUBDIR)
|
||||
|
||||
find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools)
|
||||
find_package(Qt5 COMPONENTS Gui Multimedia Network OpenGL Script Svg WebKitWidgets)
|
||||
|
||||
# grab the ui files in resources/ui
|
||||
file (GLOB_RECURSE QT_UI_FILES ui/*.ui)
|
||||
|
@ -97,22 +90,8 @@ endif()
|
|||
# create the executable, make it a bundle on OS X
|
||||
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
|
||||
|
||||
# link in the hifi shared library
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
|
||||
# link required hifi libraries
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(avatars ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(audio ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_libraries(shared octree voxels fbx metavoxels networking particles models avatars audio animation script-engine)
|
||||
|
||||
# find any optional and required libraries
|
||||
find_package(Faceplus)
|
||||
|
@ -123,9 +102,10 @@ find_package(SDL)
|
|||
find_package(Sixense)
|
||||
find_package(Visage)
|
||||
find_package(LeapMotion)
|
||||
find_package(ZLIB)
|
||||
find_package(Qxmpp)
|
||||
find_package(RtMidi)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
# perform standard include and linking for found externals
|
||||
|
@ -179,17 +159,11 @@ endif ()
|
|||
|
||||
# include headers for interface and InterfaceConfig.
|
||||
include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes")
|
||||
|
||||
# include external library headers
|
||||
# use system flag so warnings are supressed
|
||||
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
||||
include_directories("${OPENSSL_INCLUDE_DIR}")
|
||||
|
||||
target_link_libraries(
|
||||
${TARGET_NAME}
|
||||
"${ZLIB_LIBRARIES}"
|
||||
${OPENSSL_LIBRARIES}
|
||||
Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL
|
||||
Qt5::Script Qt5::Svg Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml Qt5::UiTools
|
||||
${TARGET_NAME} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}
|
||||
Qt5::Gui Qt5::Network Qt5::Multimedia Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKitWidgets
|
||||
)
|
||||
|
||||
# assume we are using a Qt build without bearer management
|
||||
|
@ -197,30 +171,12 @@ add_definitions(-DQT_NO_BEARERMANAGEMENT)
|
|||
|
||||
if (APPLE)
|
||||
# link in required OS X frameworks and include the right GL headers
|
||||
find_library(AppKit AppKit)
|
||||
find_library(CoreAudio CoreAudio)
|
||||
find_library(CoreServices CoreServices)
|
||||
find_library(Carbon Carbon)
|
||||
find_library(Foundation Foundation)
|
||||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(GLUT GLUT)
|
||||
find_library(OpenGL OpenGL)
|
||||
find_library(IOKit IOKit)
|
||||
find_library(QTKit QTKit)
|
||||
find_library(QuartzCore QuartzCore)
|
||||
|
||||
target_link_libraries(
|
||||
${TARGET_NAME}
|
||||
${AppKit}
|
||||
${CoreAudio}
|
||||
${CoreServices}
|
||||
${Carbon}
|
||||
${Foundation}
|
||||
${GLUT}
|
||||
${OpenGL}
|
||||
${IOKit}
|
||||
${QTKit}
|
||||
${QuartzCore}
|
||||
)
|
||||
target_link_libraries(${TARGET_NAME} ${CoreAudio} ${CoreFoundation} ${GLUT} ${OpenGL})
|
||||
|
||||
# install command for OS X bundle
|
||||
INSTALL(TARGETS ${TARGET_NAME}
|
||||
|
@ -254,9 +210,9 @@ else (APPLE)
|
|||
# we're using static GLEW, so define GLEW_STATIC
|
||||
add_definitions(-DGLEW_STATIC)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
add_definitions(-Dssize_t=long)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib)
|
||||
endif()
|
||||
endif (APPLE)
|
||||
|
||||
# link any dependencies bubbled up from our linked dependencies
|
||||
link_shared_dependencies()
|
||||
|
|
|
@ -261,8 +261,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||
connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer)));
|
||||
connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));
|
||||
connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle);
|
||||
connect(nodeList, SIGNAL(uuidChanged(const QUuid&)), _myAvatar, SLOT(setSessionUUID(const QUuid&)));
|
||||
connect(nodeList, &NodeList::uuidChanged, _myAvatar, &MyAvatar::setSessionUUID);
|
||||
connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset);
|
||||
|
||||
// connect to appropriate slots on AccountManager
|
||||
|
|
|
@ -85,13 +85,13 @@ MyAvatar::MyAvatar() :
|
|||
}
|
||||
_skeletonModel.setEnableShapes(true);
|
||||
// The skeleton is both a PhysicsEntity and Ragdoll, so we add it to the simulation once for each type.
|
||||
_physicsSimulation.addEntity(&_skeletonModel);
|
||||
_physicsSimulation.addRagdoll(&_skeletonModel);
|
||||
_physicsSimulation.setEntity(&_skeletonModel);
|
||||
_physicsSimulation.setRagdoll(&_skeletonModel);
|
||||
}
|
||||
|
||||
MyAvatar::~MyAvatar() {
|
||||
_physicsSimulation.removeEntity(&_skeletonModel);
|
||||
_physicsSimulation.removeRagdoll(&_skeletonModel);
|
||||
_physicsSimulation.setRagdoll(NULL);
|
||||
_physicsSimulation.setEntity(NULL);
|
||||
_lookAtTargetAvatar.clear();
|
||||
}
|
||||
|
||||
|
@ -206,9 +206,10 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
{
|
||||
PerformanceTimer perfTimer("ragdoll");
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll)) {
|
||||
const int minError = 0.01f;
|
||||
const float minError = 0.01f;
|
||||
const float maxIterations = 10;
|
||||
const quint64 maxUsec = 2000;
|
||||
_physicsSimulation.setTranslation(_position);
|
||||
_physicsSimulation.stepForward(deltaTime, minError, maxIterations, maxUsec);
|
||||
} else {
|
||||
_skeletonModel.moveShapesTowardJoints(1.0f);
|
||||
|
@ -235,12 +236,10 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
} else {
|
||||
_trapDuration = 0.0f;
|
||||
}
|
||||
/* TODO: Andrew to make this work
|
||||
if (_collisionGroups & COLLISION_GROUP_AVATARS) {
|
||||
PerformanceTimer perfTimer("avatars");
|
||||
updateCollisionWithAvatars(deltaTime);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// consider updating our billboard
|
||||
|
@ -1551,8 +1550,6 @@ bool findAvatarAvatarPenetration(const glm::vec3 positionA, float radiusA, float
|
|||
return false;
|
||||
}
|
||||
|
||||
const float BODY_COLLISION_RESOLUTION_TIMESCALE = 0.5f; // seconds
|
||||
|
||||
void MyAvatar::updateCollisionWithAvatars(float deltaTime) {
|
||||
// Reset detector for nearest avatar
|
||||
_distanceToNearestAvatar = std::numeric_limits<float>::max();
|
||||
|
@ -1563,41 +1560,51 @@ void MyAvatar::updateCollisionWithAvatars(float deltaTime) {
|
|||
}
|
||||
float myBoundingRadius = getBoundingRadius();
|
||||
|
||||
const float BODY_COLLISION_RESOLUTION_FACTOR = glm::max(1.0f, deltaTime / BODY_COLLISION_RESOLUTION_TIMESCALE);
|
||||
|
||||
// find nearest avatar
|
||||
float nearestDistance2 = std::numeric_limits<float>::max();
|
||||
Avatar* nearestAvatar = NULL;
|
||||
foreach (const AvatarSharedPointer& avatarPointer, avatars) {
|
||||
Avatar* avatar = static_cast<Avatar*>(avatarPointer.data());
|
||||
if (static_cast<Avatar*>(this) == avatar) {
|
||||
// don't collide with ourselves
|
||||
continue;
|
||||
}
|
||||
float distance = glm::length(_position - avatar->getPosition());
|
||||
if (_distanceToNearestAvatar > distance) {
|
||||
_distanceToNearestAvatar = distance;
|
||||
float distance2 = glm::distance2(_position, avatar->getPosition());
|
||||
if (nearestDistance2 > distance2) {
|
||||
nearestDistance2 = distance2;
|
||||
nearestAvatar = avatar;
|
||||
}
|
||||
float theirBoundingRadius = avatar->getBoundingRadius();
|
||||
if (distance < myBoundingRadius + theirBoundingRadius) {
|
||||
// collide our body against theirs
|
||||
QVector<const Shape*> myShapes;
|
||||
_skeletonModel.getBodyShapes(myShapes);
|
||||
QVector<const Shape*> theirShapes;
|
||||
avatar->getSkeletonModel().getBodyShapes(theirShapes);
|
||||
}
|
||||
_distanceToNearestAvatar = glm::sqrt(nearestDistance2);
|
||||
|
||||
CollisionInfo collision;
|
||||
if (ShapeCollider::collideShapesCoarse(myShapes, theirShapes, collision)) {
|
||||
float penetrationDepth = glm::length(collision._penetration);
|
||||
if (penetrationDepth > myBoundingRadius) {
|
||||
qDebug() << "WARNING: ignoring avatar-avatar penetration depth " << penetrationDepth;
|
||||
}
|
||||
else if (penetrationDepth > EPSILON) {
|
||||
setPosition(getPosition() - BODY_COLLISION_RESOLUTION_FACTOR * collision._penetration);
|
||||
_lastBodyPenetration += collision._penetration;
|
||||
emit collisionWithAvatar(getSessionUUID(), avatar->getSessionUUID(), collision);
|
||||
}
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll)) {
|
||||
if (nearestAvatar != NULL) {
|
||||
if (_distanceToNearestAvatar > myBoundingRadius + nearestAvatar->getBoundingRadius()) {
|
||||
// they aren't close enough to put into the _physicsSimulation
|
||||
// so we clear the pointer
|
||||
nearestAvatar = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const AvatarSharedPointer& avatarPointer, avatars) {
|
||||
Avatar* avatar = static_cast<Avatar*>(avatarPointer.data());
|
||||
if (static_cast<Avatar*>(this) == avatar) {
|
||||
// don't collide with ourselves
|
||||
continue;
|
||||
}
|
||||
SkeletonModel* skeleton = &(avatar->getSkeletonModel());
|
||||
PhysicsSimulation* simulation = skeleton->getSimulation();
|
||||
if (avatar == nearestAvatar) {
|
||||
if (simulation != &(_physicsSimulation)) {
|
||||
skeleton->setEnableShapes(true);
|
||||
_physicsSimulation.addEntity(skeleton);
|
||||
_physicsSimulation.addRagdoll(skeleton);
|
||||
}
|
||||
} else if (simulation == &(_physicsSimulation)) {
|
||||
_physicsSimulation.removeRagdoll(skeleton);
|
||||
_physicsSimulation.removeEntity(skeleton);
|
||||
skeleton->setEnableShapes(false);
|
||||
}
|
||||
|
||||
// collide their hands against us
|
||||
avatar->getHand()->collideAgainstAvatar(this, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -490,11 +490,13 @@ void SkeletonModel::renderRagdoll() {
|
|||
float alpha = 0.3f;
|
||||
float radius1 = 0.008f;
|
||||
float radius2 = 0.01f;
|
||||
glm::vec3 simulationTranslation = getTranslationInSimulationFrame();
|
||||
for (int i = 0; i < numPoints; ++i) {
|
||||
glPushMatrix();
|
||||
// draw each point as a yellow hexagon with black border
|
||||
glm::vec3 position = _rotation * _ragdollPoints[i]._position;
|
||||
// NOTE: ragdollPoints are in simulation-frame but we want them to be model-relative
|
||||
glm::vec3 position = _ragdollPoints[i]._position - simulationTranslation;
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
// draw each point as a yellow hexagon with black border
|
||||
glColor4f(0.0f, 0.0f, 0.0f, alpha);
|
||||
glutSolidSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
glColor4f(1.0f, 1.0f, 0.0f, alpha);
|
||||
|
@ -511,13 +513,14 @@ void SkeletonModel::initRagdollPoints() {
|
|||
clearRagdollConstraintsAndPoints();
|
||||
_muscleConstraints.clear();
|
||||
|
||||
initRagdollTransform();
|
||||
// one point for each joint
|
||||
int numJoints = _jointStates.size();
|
||||
_ragdollPoints.fill(VerletPoint(), numJoints);
|
||||
for (int i = 0; i < numJoints; ++i) {
|
||||
int numStates = _jointStates.size();
|
||||
_ragdollPoints.fill(VerletPoint(), numStates);
|
||||
for (int i = 0; i < numStates; ++i) {
|
||||
const JointState& state = _jointStates.at(i);
|
||||
glm::vec3 position = state.getPosition();
|
||||
_ragdollPoints[i].initPosition(position);
|
||||
// _ragdollPoints start in model-frame
|
||||
_ragdollPoints[i].initPosition(state.getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -534,12 +537,12 @@ void SkeletonModel::buildRagdollConstraints() {
|
|||
const JointState& state = _jointStates.at(i);
|
||||
int parentIndex = state.getParentIndex();
|
||||
if (parentIndex == -1) {
|
||||
FixedConstraint* anchor = new FixedConstraint(&(_ragdollPoints[i]), glm::vec3(0.0f));
|
||||
_ragdollConstraints.push_back(anchor);
|
||||
FixedConstraint* anchor = new FixedConstraint(&_translationInSimulationFrame, &(_ragdollPoints[i]));
|
||||
_fixedConstraints.push_back(anchor);
|
||||
} else {
|
||||
DistanceConstraint* bone = new DistanceConstraint(&(_ragdollPoints[i]), &(_ragdollPoints[parentIndex]));
|
||||
bone->setDistance(state.getDistanceToParent());
|
||||
_ragdollConstraints.push_back(bone);
|
||||
_boneConstraints.push_back(bone);
|
||||
families.insert(parentIndex, i);
|
||||
}
|
||||
float boneLength = glm::length(state.getPositionInParentFrame());
|
||||
|
@ -558,11 +561,11 @@ void SkeletonModel::buildRagdollConstraints() {
|
|||
if (numChildren > 1) {
|
||||
for (int i = 1; i < numChildren; ++i) {
|
||||
DistanceConstraint* bone = new DistanceConstraint(&(_ragdollPoints[children[i-1]]), &(_ragdollPoints[children[i]]));
|
||||
_ragdollConstraints.push_back(bone);
|
||||
_boneConstraints.push_back(bone);
|
||||
}
|
||||
if (numChildren > 2) {
|
||||
DistanceConstraint* bone = new DistanceConstraint(&(_ragdollPoints[children[numChildren-1]]), &(_ragdollPoints[children[0]]));
|
||||
_ragdollConstraints.push_back(bone);
|
||||
_boneConstraints.push_back(bone);
|
||||
}
|
||||
}
|
||||
++itr;
|
||||
|
@ -604,6 +607,7 @@ void SkeletonModel::updateVisibleJointStates() {
|
|||
}
|
||||
QVector<glm::vec3> points;
|
||||
points.reserve(_jointStates.size());
|
||||
glm::quat invRotation = glm::inverse(_rotation);
|
||||
for (int i = 0; i < _jointStates.size(); i++) {
|
||||
JointState& state = _jointStates[i];
|
||||
points.push_back(_ragdollPoints[i]._position);
|
||||
|
@ -628,8 +632,9 @@ void SkeletonModel::updateVisibleJointStates() {
|
|||
|
||||
// we're looking for the rotation that moves visible bone parallel to ragdoll bone
|
||||
// rotationBetween(jointTip - jointPivot, shapeTip - shapePivot)
|
||||
// NOTE: points are in simulation-frame so rotate line segment into model-frame
|
||||
glm::quat delta = rotationBetween(state.getVisiblePosition() - extractTranslation(parentTransform),
|
||||
points[i] - points[parentIndex]);
|
||||
invRotation * (points[i] - points[parentIndex]));
|
||||
|
||||
// apply
|
||||
parentState.mixVisibleRotationDelta(delta, 0.01f);
|
||||
|
@ -641,6 +646,7 @@ void SkeletonModel::updateVisibleJointStates() {
|
|||
|
||||
// virtual
|
||||
void SkeletonModel::stepRagdollForward(float deltaTime) {
|
||||
setRagdollTransform(_translation, _rotation);
|
||||
Ragdoll::stepRagdollForward(deltaTime);
|
||||
updateMuscles();
|
||||
int numConstraints = _muscleConstraints.size();
|
||||
|
@ -665,6 +671,7 @@ void SkeletonModel::buildShapes() {
|
|||
}
|
||||
|
||||
initRagdollPoints();
|
||||
float massScale = getMassScale();
|
||||
|
||||
float uniformScale = extractUniformScale(_scale);
|
||||
const int numStates = _jointStates.size();
|
||||
|
@ -678,25 +685,30 @@ void SkeletonModel::buildShapes() {
|
|||
// this shape is forced to be a sphere
|
||||
type = Shape::SPHERE_SHAPE;
|
||||
}
|
||||
if (radius < EPSILON) {
|
||||
type = Shape::UNKNOWN_SHAPE;
|
||||
}
|
||||
Shape* shape = NULL;
|
||||
int parentIndex = joint.parentIndex;
|
||||
if (type == Shape::SPHERE_SHAPE) {
|
||||
shape = new VerletSphereShape(radius, &(_ragdollPoints[i]));
|
||||
shape->setEntity(this);
|
||||
_ragdollPoints[i]._mass = glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume());
|
||||
_ragdollPoints[i].setMass(massScale * glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume()));
|
||||
} else if (type == Shape::CAPSULE_SHAPE) {
|
||||
assert(parentIndex != -1);
|
||||
shape = new VerletCapsuleShape(radius, &(_ragdollPoints[parentIndex]), &(_ragdollPoints[i]));
|
||||
shape->setEntity(this);
|
||||
_ragdollPoints[i]._mass = glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume());
|
||||
_ragdollPoints[i].setMass(massScale * glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume()));
|
||||
}
|
||||
if (parentIndex != -1) {
|
||||
// always disable collisions between joint and its parent
|
||||
disableCollisions(i, parentIndex);
|
||||
if (shape) {
|
||||
disableCollisions(i, parentIndex);
|
||||
}
|
||||
} else {
|
||||
// give the base joint a very large mass since it doesn't actually move
|
||||
// in the local-frame simulation (it defines the origin)
|
||||
_ragdollPoints[i]._mass = VERY_BIG_MASS;
|
||||
_ragdollPoints[i].setMass(VERY_BIG_MASS);
|
||||
}
|
||||
_shapes.push_back(shape);
|
||||
}
|
||||
|
@ -712,8 +724,9 @@ void SkeletonModel::buildShapes() {
|
|||
|
||||
// ... then move shapes back to current joint positions
|
||||
if (_ragdollPoints.size() == numStates) {
|
||||
int numJoints = _jointStates.size();
|
||||
for (int i = 0; i < numJoints; ++i) {
|
||||
int numStates = _jointStates.size();
|
||||
for (int i = 0; i < numStates; ++i) {
|
||||
// ragdollPoints start in model-frame
|
||||
_ragdollPoints[i].initPosition(_jointStates.at(i).getPosition());
|
||||
}
|
||||
}
|
||||
|
@ -735,9 +748,11 @@ void SkeletonModel::moveShapesTowardJoints(float deltaTime) {
|
|||
float fraction = glm::clamp(deltaTime / RAGDOLL_FOLLOWS_JOINTS_TIMESCALE, 0.0f, 1.0f);
|
||||
|
||||
float oneMinusFraction = 1.0f - fraction;
|
||||
glm::vec3 simulationTranslation = getTranslationInSimulationFrame();
|
||||
for (int i = 0; i < numStates; ++i) {
|
||||
// ragdollPoints are in simulation-frame but jointStates are in model-frame
|
||||
_ragdollPoints[i].initPosition(oneMinusFraction * _ragdollPoints[i]._position +
|
||||
fraction * _jointStates.at(i).getPosition());
|
||||
fraction * (simulationTranslation + _rotation * (_jointStates.at(i).getPosition())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -748,23 +763,22 @@ void SkeletonModel::updateMuscles() {
|
|||
int j = constraint->getParentIndex();
|
||||
int k = constraint->getChildIndex();
|
||||
assert(j != -1 && k != -1);
|
||||
constraint->setChildOffset(_jointStates.at(k).getPosition() - _jointStates.at(j).getPosition());
|
||||
// ragdollPoints are in simulation-frame but jointStates are in model-frame
|
||||
constraint->setChildOffset(_rotation * (_jointStates.at(k).getPosition() - _jointStates.at(j).getPosition()));
|
||||
}
|
||||
}
|
||||
|
||||
void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) {
|
||||
// compute default joint transforms
|
||||
int numJoints = geometry.joints.size();
|
||||
if (numJoints != _ragdollPoints.size()) {
|
||||
return;
|
||||
}
|
||||
int numStates = _jointStates.size();
|
||||
QVector<glm::mat4> transforms;
|
||||
transforms.fill(glm::mat4(), numJoints);
|
||||
transforms.fill(glm::mat4(), numStates);
|
||||
|
||||
// compute the default transforms and slam the ragdoll positions accordingly
|
||||
// (which puts the shapes where we want them)
|
||||
for (int i = 0; i < numJoints; i++) {
|
||||
const FBXJoint& joint = geometry.joints.at(i);
|
||||
for (int i = 0; i < numStates; i++) {
|
||||
JointState& state = _jointStates[i];
|
||||
const FBXJoint& joint = state.getFBXJoint();
|
||||
int parentIndex = joint.parentIndex;
|
||||
if (parentIndex == -1) {
|
||||
transforms[i] = _jointStates[i].getTransform();
|
||||
|
@ -836,7 +850,7 @@ void SkeletonModel::resetShapePositionsToDefaultPose() {
|
|||
}
|
||||
|
||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||
if (geometry.joints.isEmpty() || _shapes.size() != geometry.joints.size()) {
|
||||
if (geometry.joints.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -891,3 +905,54 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
const int BALL_SUBDIVISIONS = 10;
|
||||
|
||||
// virtual
|
||||
void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
||||
glPushMatrix();
|
||||
Application::getInstance()->loadTranslatedViewMatrix(_translation);
|
||||
glm::vec3 simulationTranslation = getTranslationInSimulationFrame();
|
||||
for (int i = 0; i < _shapes.size(); i++) {
|
||||
Shape* shape = _shapes[i];
|
||||
if (!shape) {
|
||||
continue;
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
// shapes are stored in simulation-frame but we want position to be model-relative
|
||||
if (shape->getType() == Shape::SPHERE_SHAPE) {
|
||||
glm::vec3 position = shape->getTranslation() - simulationTranslation;
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
// draw a grey sphere at shape position
|
||||
glColor4f(0.75f, 0.75f, 0.75f, alpha);
|
||||
glutSolidSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
} else if (shape->getType() == Shape::CAPSULE_SHAPE) {
|
||||
CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
|
||||
|
||||
// draw a blue sphere at the capsule endpoint
|
||||
glm::vec3 endPoint;
|
||||
capsule->getEndPoint(endPoint);
|
||||
endPoint = endPoint - simulationTranslation;
|
||||
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
||||
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
||||
glutSolidSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
|
||||
// draw a yellow sphere at the capsule startpoint
|
||||
glm::vec3 startPoint;
|
||||
capsule->getStartPoint(startPoint);
|
||||
startPoint = startPoint - simulationTranslation;
|
||||
glm::vec3 axis = endPoint - startPoint;
|
||||
glTranslatef(-axis.x, -axis.y, -axis.z);
|
||||
glColor4f(0.8f, 0.8f, 0.6f, alpha);
|
||||
glutSolidSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
|
||||
// draw a green cylinder between the two points
|
||||
glm::vec3 origin(0.0f);
|
||||
glColor4f(0.6f, 0.8f, 0.6f, alpha);
|
||||
Avatar::renderJointConnectingCone( origin, axis, capsule->getRadius(), capsule->getRadius());
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
|
||||
void computeBoundingShape(const FBXGeometry& geometry);
|
||||
void renderBoundingCollisionShapes(float alpha);
|
||||
void renderJointCollisionShapes(float alpha);
|
||||
float getBoundingShapeRadius() const { return _boundingShape.getRadius(); }
|
||||
const CapsuleShape& getBoundingShape() const { return _boundingShape; }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
|
||||
#include "CaraFaceTracker.h"
|
||||
#include <SharedUtil.h>
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
//qt
|
||||
#include <QJsonDocument>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <FBXReader.h>
|
||||
|
||||
class AngularConstraint;
|
||||
|
|
|
@ -188,10 +188,12 @@ void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locati
|
|||
|
||||
QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) {
|
||||
QVector<JointState> jointStates;
|
||||
foreach (const FBXJoint& joint, geometry.joints) {
|
||||
// NOTE: the state keeps a pointer to an FBXJoint
|
||||
for (int i = 0; i < geometry.joints.size(); ++i) {
|
||||
const FBXJoint& joint = geometry.joints[i];
|
||||
// store a pointer to the FBXJoint in the JointState
|
||||
JointState state;
|
||||
state.setFBXJoint(&joint);
|
||||
|
||||
jointStates.append(state);
|
||||
}
|
||||
return jointStates;
|
||||
|
@ -199,8 +201,8 @@ QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) {
|
|||
|
||||
void Model::initJointTransforms() {
|
||||
// compute model transforms
|
||||
int numJoints = _jointStates.size();
|
||||
for (int i = 0; i < numJoints; ++i) {
|
||||
int numStates = _jointStates.size();
|
||||
for (int i = 0; i < numStates; ++i) {
|
||||
JointState& state = _jointStates[i];
|
||||
const FBXJoint& joint = state.getFBXJoint();
|
||||
int parentIndex = joint.parentIndex;
|
||||
|
@ -538,9 +540,9 @@ void Model::setJointStates(QVector<JointState> states) {
|
|||
_jointStates = states;
|
||||
initJointTransforms();
|
||||
|
||||
int numJoints = _jointStates.size();
|
||||
int numStates = _jointStates.size();
|
||||
float radius = 0.0f;
|
||||
for (int i = 0; i < numJoints; ++i) {
|
||||
for (int i = 0; i < numStates; ++i) {
|
||||
float distance = glm::length(_jointStates[i].getPosition());
|
||||
if (distance > radius) {
|
||||
radius = distance;
|
||||
|
@ -1243,55 +1245,7 @@ float Model::getLimbLength(int jointIndex) const {
|
|||
const int BALL_SUBDIVISIONS = 10;
|
||||
|
||||
void Model::renderJointCollisionShapes(float alpha) {
|
||||
glPushMatrix();
|
||||
Application::getInstance()->loadTranslatedViewMatrix(_translation);
|
||||
for (int i = 0; i < _shapes.size(); i++) {
|
||||
Shape* shape = _shapes[i];
|
||||
if (!shape) {
|
||||
continue;
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
// NOTE: the shapes are in the avatar local-frame
|
||||
if (shape->getType() == Shape::SPHERE_SHAPE) {
|
||||
// shapes are stored in world-frame, so we have to transform into model frame
|
||||
glm::vec3 position = _rotation * shape->getTranslation();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
const glm::quat& rotation = shape->getRotation();
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
|
||||
// draw a grey sphere at shape position
|
||||
glColor4f(0.75f, 0.75f, 0.75f, alpha);
|
||||
glutSolidSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
} else if (shape->getType() == Shape::CAPSULE_SHAPE) {
|
||||
CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
|
||||
|
||||
// draw a blue sphere at the capsule endpoint
|
||||
glm::vec3 endPoint;
|
||||
capsule->getEndPoint(endPoint);
|
||||
endPoint = _rotation * endPoint;
|
||||
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
||||
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
||||
glutSolidSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
|
||||
// draw a yellow sphere at the capsule startpoint
|
||||
glm::vec3 startPoint;
|
||||
capsule->getStartPoint(startPoint);
|
||||
startPoint = _rotation * startPoint;
|
||||
glm::vec3 axis = endPoint - startPoint;
|
||||
glTranslatef(-axis.x, -axis.y, -axis.z);
|
||||
glColor4f(0.8f, 0.8f, 0.6f, alpha);
|
||||
glutSolidSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||
|
||||
// draw a green cylinder between the two points
|
||||
glm::vec3 origin(0.0f);
|
||||
glColor4f(0.6f, 0.8f, 0.6f, alpha);
|
||||
Avatar::renderJointConnectingCone( origin, axis, capsule->getRadius(), capsule->getRadius());
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
// implement this when we have shapes for regular models
|
||||
}
|
||||
|
||||
void Model::setBlendedVertices(const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals) {
|
||||
|
|
|
@ -149,7 +149,7 @@ public:
|
|||
virtual void buildShapes();
|
||||
virtual void updateShapePositions();
|
||||
|
||||
void renderJointCollisionShapes(float alpha);
|
||||
virtual void renderJointCollisionShapes(float alpha);
|
||||
|
||||
/// Sets blended vertices computed in a separate thread.
|
||||
void setBlendedVertices(const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#ifndef hifi_Base3DOverlay_h
|
||||
#define hifi_Base3DOverlay_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "Overlay.h"
|
||||
|
||||
class Base3DOverlay : public Overlay {
|
||||
|
|
|
@ -26,7 +26,7 @@ void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode,
|
|||
if (packetsToProcessCount() > WAY_BEHIND && Application::getInstance()->getLogger()->extraDebugging()) {
|
||||
qDebug("OctreePacketProcessor::processPacket() packets to process=%d", packetsToProcessCount());
|
||||
}
|
||||
ssize_t messageLength = mutablePacket.size();
|
||||
int messageLength = mutablePacket.size();
|
||||
|
||||
Application* app = Application::getInstance();
|
||||
bool wasStatsPacket = false;
|
||||
|
|
|
@ -1,29 +1,9 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME animation)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network Script)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
link_hifi_libraries(shared fbx)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -1,26 +1,11 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME audio)
|
||||
|
||||
find_package(Qt5 COMPONENTS Script)
|
||||
include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}")
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network)
|
||||
|
||||
# set up the external glm library
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
include_glm()
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_libraries(networking shared)
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include "PacketHeaders.h"
|
||||
#include "AudioRingBuffer.h"
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "AudioRingBuffer.h"
|
||||
|
||||
AudioRingBuffer::AudioRingBuffer(int numFrameSamples, bool randomAccessMode, int numFramesCapacity) :
|
||||
_frameCapacity(numFramesCapacity),
|
||||
|
|
|
@ -15,12 +15,10 @@
|
|||
#include <limits>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <QtCore/QIODevice>
|
||||
|
||||
#include "NodeData.h"
|
||||
#include "SharedUtil.h"
|
||||
#include <SharedUtil.h>
|
||||
#include <NodeData.h>
|
||||
|
||||
const int SAMPLE_RATE = 24000;
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "InboundAudioStream.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
||||
|
|
|
@ -1,30 +1,12 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME avatars)
|
||||
|
||||
find_package(Qt5Script REQUIRED)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network Script)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
include_glm()
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_libraries(shared octree voxels networking)
|
||||
include_hifi_library_headers(fbx)
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link in the hifi voxels library
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Script)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -22,7 +22,7 @@
|
|||
#include <NetworkAccessManager.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <StreamUtils.h>
|
||||
#include <UUID.h>
|
||||
#include <VoxelConstants.h>
|
||||
|
|
|
@ -290,7 +290,7 @@ public slots:
|
|||
void sendBillboardPacket();
|
||||
void setBillboardFromNetworkReply();
|
||||
void setJointMappingsFromNetworkReply();
|
||||
void setSessionUUID(const QUuid& id) { _sessionUUID = id; }
|
||||
void setSessionUUID(const QUuid& sessionUUID) { _sessionUUID = sessionUUID; }
|
||||
bool hasReferential();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -9,19 +9,21 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "AvatarHashMap.h"
|
||||
|
||||
AvatarHashMap::AvatarHashMap() :
|
||||
_avatarHash()
|
||||
_avatarHash(),
|
||||
_lastOwnerSessionUUID()
|
||||
{
|
||||
|
||||
connect(NodeList::getInstance(), &NodeList::uuidChanged, this, &AvatarHashMap::sessionUUIDChanged);
|
||||
}
|
||||
|
||||
void AvatarHashMap::insert(const QUuid& id, AvatarSharedPointer avatar) {
|
||||
_avatarHash.insert(id, avatar);
|
||||
avatar->setSessionUUID(id);
|
||||
void AvatarHashMap::insert(const QUuid& sessionUUID, AvatarSharedPointer avatar) {
|
||||
_avatarHash.insert(sessionUUID, avatar);
|
||||
avatar->setSessionUUID(sessionUUID);
|
||||
}
|
||||
|
||||
AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator) {
|
||||
|
@ -110,10 +112,16 @@ void AvatarHashMap::processAvatarDataPacket(const QByteArray &datagram, const QW
|
|||
QUuid sessionUUID = QUuid::fromRfc4122(datagram.mid(bytesRead, NUM_BYTES_RFC4122_UUID));
|
||||
bytesRead += NUM_BYTES_RFC4122_UUID;
|
||||
|
||||
AvatarSharedPointer matchingAvatarData = matchingOrNewAvatar(sessionUUID, mixerWeakPointer);
|
||||
|
||||
// have the matching (or new) avatar parse the data from the packet
|
||||
bytesRead += matchingAvatarData->parseDataAtOffset(datagram, bytesRead);
|
||||
if (sessionUUID != _lastOwnerSessionUUID) {
|
||||
AvatarSharedPointer matchingAvatarData = matchingOrNewAvatar(sessionUUID, mixerWeakPointer);
|
||||
|
||||
// have the matching (or new) avatar parse the data from the packet
|
||||
bytesRead += matchingAvatarData->parseDataAtOffset(datagram, bytesRead);
|
||||
} else {
|
||||
// create a dummy AvatarData class to throw this data on the ground
|
||||
AvatarData dummyData;
|
||||
bytesRead += dummyData.parseDataAtOffset(datagram, bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,3 +185,7 @@ void AvatarHashMap::processKillAvatar(const QByteArray& datagram) {
|
|||
erase(matchedAvatar);
|
||||
}
|
||||
}
|
||||
|
||||
void AvatarHashMap::sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID) {
|
||||
_lastOwnerSessionUUID = oldUUID;
|
||||
}
|
|
@ -31,12 +31,15 @@ public:
|
|||
const AvatarHash& getAvatarHash() { return _avatarHash; }
|
||||
int size() const { return _avatarHash.size(); }
|
||||
|
||||
virtual void insert(const QUuid& id, AvatarSharedPointer avatar);
|
||||
virtual void insert(const QUuid& sessionUUID, AvatarSharedPointer avatar);
|
||||
|
||||
public slots:
|
||||
void processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer<Node>& mixerWeakPointer);
|
||||
bool containsAvatarWithDisplayName(const QString& displayName);
|
||||
|
||||
|
||||
private slots:
|
||||
void sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID);
|
||||
|
||||
protected:
|
||||
virtual AvatarHash::iterator erase(const AvatarHash::iterator& iterator);
|
||||
|
||||
|
@ -51,6 +54,7 @@ protected:
|
|||
void processKillAvatar(const QByteArray& datagram);
|
||||
|
||||
AvatarHash _avatarHash;
|
||||
QUuid _lastOwnerSessionUUID;
|
||||
};
|
||||
|
||||
#endif // hifi_AvatarHashMap_h
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <FBXReader.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <OctreeConstants.h>
|
||||
|
||||
#include "AvatarData.h"
|
||||
#include "HeadData.h"
|
||||
|
||||
#include "../fbx/src/FBXReader.h"
|
||||
|
||||
HeadData::HeadData(AvatarData* owningAvatar) :
|
||||
_baseYaw(0.0f),
|
||||
_basePitch(0.0f),
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include "AvatarData.h"
|
||||
#include "Referential.h"
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME embedded-webserver)
|
||||
|
||||
find_package(Qt5Network REQUIRED)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network)
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -1,30 +1,15 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME fbx)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
include_glm()
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
link_hifi_libraries(shared networking octree voxels)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}")
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
#include <GeometryUtil.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <OctalCode.h>
|
||||
#include <Shape.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include <VoxelTree.h>
|
||||
|
||||
|
|
|
@ -1,29 +1,14 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME metavoxels)
|
||||
|
||||
find_package(Qt5 COMPONENTS Network Script Widgets)
|
||||
auto_mtc()
|
||||
|
||||
include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
auto_mtc(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}")
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network Script Widgets)
|
||||
|
||||
# link in the networking library
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_libraries(shared networking)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
include_glm()
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -24,6 +24,8 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include "MetavoxelUtil.h"
|
||||
#include "ScriptCache.h"
|
||||
#include "StreamUtils.h"
|
||||
|
|
|
@ -1,39 +1,11 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME models)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network Script)
|
||||
|
||||
include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
auto_mtc(${TARGET_NAME} "${ROOT_DIR}")
|
||||
include_glm()
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}")
|
||||
link_hifi_libraries(shared octree fbx networking animation)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# for streamable
|
||||
link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
|
||||
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -38,7 +38,7 @@ void ModelEditPacketSender::sendEditModelMessage(PacketType type, ModelItemID mo
|
|||
}
|
||||
}
|
||||
|
||||
void ModelEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) {
|
||||
void ModelEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) {
|
||||
ModelItem::adjustEditPacketForClockSkew(codeColorBuffer, length, clockSkew);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,6 @@ public:
|
|||
|
||||
// My server type is the model server
|
||||
virtual char getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew);
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew);
|
||||
};
|
||||
#endif // hifi_ModelEditPacketSender_h
|
||||
|
|
|
@ -11,19 +11,12 @@
|
|||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <Octree.h>
|
||||
#include <RegisteredMetaTypes.h>
|
||||
#include <SharedUtil.h> // usecTimestampNow()
|
||||
#include <VoxelsScriptingInterface.h>
|
||||
#include <VoxelDetail.h>
|
||||
|
||||
|
||||
// This is not ideal, but adding script-engine as a linked library, will cause a circular reference
|
||||
// I'm open to other potential solutions. Could we change cmake to allow libraries to reference each others
|
||||
// headers, but not link to each other, this is essentially what this construct is doing, but would be
|
||||
// better to add includes to the include path, but not link
|
||||
#include "../../script-engine/src/ScriptEngine.h"
|
||||
|
||||
#include "ModelsScriptingInterface.h"
|
||||
#include "ModelItem.h"
|
||||
#include "ModelTree.h"
|
||||
|
@ -641,7 +634,7 @@ bool ModelItem::encodeModelEditMessageDetails(PacketType command, ModelItemID id
|
|||
}
|
||||
|
||||
// adjust any internal timestamps to fix clock skew for this server
|
||||
void ModelItem::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) {
|
||||
void ModelItem::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) {
|
||||
unsigned char* dataAt = codeColorBuffer;
|
||||
int octets = numberOfThreeBitSectionsInCode(dataAt);
|
||||
int lengthOfOctcode = bytesRequiredForCodeLength(octets);
|
||||
|
|
|
@ -270,7 +270,7 @@ public:
|
|||
static bool encodeModelEditMessageDetails(PacketType command, ModelItemID id, const ModelItemProperties& details,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut);
|
||||
|
||||
static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew);
|
||||
static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew);
|
||||
|
||||
void update(const quint64& now);
|
||||
|
||||
|
|
|
@ -1,21 +1,14 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
set(TARGET_NAME networking)
|
||||
project(${TARGET_NAME})
|
||||
|
||||
find_package(Qt5 COMPONENTS Network)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
link_hifi_libraries(shared)
|
||||
|
||||
# include GLM
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# we need ws2_32.lib on windows, but it's static so we don't bubble it up
|
||||
target_link_libraries(${TARGET_NAME} ws2_32.lib)
|
||||
endif ()
|
||||
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -95,7 +95,7 @@ void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) {
|
|||
if (sessionUUID != oldUUID) {
|
||||
qDebug() << "NodeList UUID changed from" << uuidStringWithoutCurlyBraces(oldUUID)
|
||||
<< "to" << uuidStringWithoutCurlyBraces(_sessionUUID);
|
||||
emit uuidChanged(sessionUUID);
|
||||
emit uuidChanged(sessionUUID, oldUUID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public slots:
|
|||
|
||||
void killNodeWithUUID(const QUuid& nodeUUID);
|
||||
signals:
|
||||
void uuidChanged(const QUuid& ownerUUID);
|
||||
void uuidChanged(const QUuid& ownerUUID, const QUuid& oldUUID);
|
||||
void nodeAdded(SharedNodePointer);
|
||||
void nodeKilled(SharedNodePointer);
|
||||
protected:
|
||||
|
|
|
@ -39,10 +39,6 @@ public:
|
|||
~PacketSender();
|
||||
|
||||
/// Add packet to outbound queue.
|
||||
/// \param HifiSockAddr& address the destination address
|
||||
/// \param packetData pointer to data
|
||||
/// \param ssize_t packetLength size of data
|
||||
/// \thread any thread, typically the application thread
|
||||
void queuePacketForSending(const SharedNodePointer& destinationNode, const QByteArray& packet);
|
||||
|
||||
void setPacketsPerSecond(int packetsPerSecond);
|
||||
|
|
|
@ -24,10 +24,6 @@ public:
|
|||
ReceivedPacketProcessor() { }
|
||||
|
||||
/// Add packet from network receive thread to the processing queue.
|
||||
/// \param sockaddr& senderAddress the address of the sender
|
||||
/// \param packetData pointer to received data
|
||||
/// \param ssize_t packetLength size of received data
|
||||
/// \thread network receive thread
|
||||
void queueReceivedPacket(const SharedNodePointer& sendingNode, const QByteArray& packet);
|
||||
|
||||
/// Are there received packets waiting to be processed
|
||||
|
|
|
@ -1,30 +1,19 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME octree)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
include_glm()
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_libraries(shared networking)
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
# find ZLIB
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# append ZLIB and OpenSSL to our list of libraries to link
|
||||
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}")
|
||||
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -20,7 +20,7 @@ EditPacketBuffer::EditPacketBuffer() :
|
|||
|
||||
}
|
||||
|
||||
EditPacketBuffer::EditPacketBuffer(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost, QUuid nodeUUID) :
|
||||
EditPacketBuffer::EditPacketBuffer(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost, QUuid nodeUUID) :
|
||||
_nodeUUID(nodeUUID),
|
||||
_currentType(type),
|
||||
_currentSize(length),
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
class EditPacketBuffer {
|
||||
public:
|
||||
EditPacketBuffer();
|
||||
EditPacketBuffer(PacketType type, unsigned char* codeColorBuffer, ssize_t length,
|
||||
EditPacketBuffer(PacketType type, unsigned char* codeColorBuffer, size_t length,
|
||||
qint64 satoshiCost = 0, const QUuid nodeUUID = QUuid());
|
||||
|
||||
QUuid _nodeUUID;
|
||||
PacketType _currentType;
|
||||
unsigned char _currentBuffer[MAX_PACKET_SIZE];
|
||||
ssize_t _currentSize;
|
||||
size_t _currentSize;
|
||||
qint64 _satoshiCost;
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void JurisdictionListener::nodeKilled(SharedNodePointer node) {
|
|||
bool JurisdictionListener::queueJurisdictionRequest() {
|
||||
static unsigned char buffer[MAX_PACKET_SIZE];
|
||||
unsigned char* bufferOut = &buffer[0];
|
||||
ssize_t sizeOut = populatePacketHeader(reinterpret_cast<char*>(bufferOut), PacketTypeJurisdictionRequest);
|
||||
int sizeOut = populatePacketHeader(reinterpret_cast<char*>(bufferOut), PacketTypeJurisdictionRequest);
|
||||
int nodeCount = 0;
|
||||
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
|
|
@ -47,10 +47,6 @@ public slots:
|
|||
protected:
|
||||
/// Callback for processing of received packets. Will process any queued PacketType_JURISDICTION and update the
|
||||
/// jurisdiction map member variable
|
||||
/// \param sockaddr& senderAddress the address of the sender
|
||||
/// \param packetData pointer to received data
|
||||
/// \param ssize_t packetLength size of received data
|
||||
/// \thread "this" individual processing thread
|
||||
virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet);
|
||||
|
||||
private:
|
||||
|
|
|
@ -47,7 +47,7 @@ bool JurisdictionSender::process() {
|
|||
// add our packet to our own queue, then let the PacketSender class do the rest of the work.
|
||||
static unsigned char buffer[MAX_PACKET_SIZE];
|
||||
unsigned char* bufferOut = &buffer[0];
|
||||
ssize_t sizeOut = 0;
|
||||
int sizeOut = 0;
|
||||
|
||||
if (_jurisdictionMap) {
|
||||
sizeOut = _jurisdictionMap->packIntoMessage(bufferOut, MAX_PACKET_SIZE);
|
||||
|
|
|
@ -83,7 +83,7 @@ bool OctreeEditPacketSender::serversExist() const {
|
|||
// This method is called when the edit packet layer has determined that it has a fully formed packet destined for
|
||||
// a known nodeID.
|
||||
void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned char* buffer,
|
||||
ssize_t length, qint64 satoshiCost) {
|
||||
size_t length, qint64 satoshiCost) {
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||
|
@ -161,7 +161,7 @@ void OctreeEditPacketSender::processPreServerExistsPackets() {
|
|||
}
|
||||
|
||||
void OctreeEditPacketSender::queuePendingPacketToNodes(PacketType type, unsigned char* buffer,
|
||||
ssize_t length, qint64 satoshiCost) {
|
||||
size_t length, qint64 satoshiCost) {
|
||||
// If we're asked to save messages while waiting for voxel servers to arrive, then do so...
|
||||
|
||||
if (_maxPendingMessages > 0) {
|
||||
|
@ -179,7 +179,7 @@ void OctreeEditPacketSender::queuePendingPacketToNodes(PacketType type, unsigned
|
|||
}
|
||||
}
|
||||
|
||||
void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t length, qint64 satoshiCost) {
|
||||
void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, size_t length, qint64 satoshiCost) {
|
||||
if (!_shouldSend) {
|
||||
return; // bail early
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t l
|
|||
|
||||
// NOTE: codeColorBuffer - is JUST the octcode/color and does not contain the packet header!
|
||||
void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, unsigned char* codeColorBuffer,
|
||||
ssize_t length, qint64 satoshiCost) {
|
||||
size_t length, qint64 satoshiCost) {
|
||||
|
||||
if (!_shouldSend) {
|
||||
return; // bail early
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
/// Queues a single edit message. Will potentially send a pending multi-command packet. Determines which server
|
||||
/// node or nodes the packet should be sent to. Can be called even before servers are known, in which case up to
|
||||
/// MaxPendingMessages will be buffered and processed when servers are known.
|
||||
void queueOctreeEditMessage(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0);
|
||||
void queueOctreeEditMessage(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
|
||||
/// Releases all queued messages even if those messages haven't filled an MTU packet. This will move the packed message
|
||||
/// packets onto the send queue. If running in threaded mode, the caller does not need to do any further processing to
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
|
||||
// you must override these...
|
||||
virtual char getMyNodeType() const = 0;
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { };
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { };
|
||||
|
||||
bool hasDestinationWalletUUID() const { return !_destinationWalletUUID.isNull(); }
|
||||
void setDestinationWalletUUID(const QUuid& destinationWalletUUID) { _destinationWalletUUID = destinationWalletUUID; }
|
||||
|
@ -97,9 +97,9 @@ signals:
|
|||
|
||||
protected:
|
||||
bool _shouldSend;
|
||||
void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0);
|
||||
void queuePendingPacketToNodes(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0);
|
||||
void queuePacketToNodes(unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0);
|
||||
void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void queuePendingPacketToNodes(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void queuePacketToNodes(unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void initializePacket(EditPacketBuffer& packetBuffer, PacketType type);
|
||||
void releaseQueuedPacket(EditPacketBuffer& packetBuffer); // releases specific queued packet
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
#include "OctreePacketData.h"
|
||||
|
||||
bool OctreePacketData::_debug = false;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#ifndef hifi_OctreePacketData_h
|
||||
#define hifi_OctreePacketData_h
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include "OctreeConstants.h"
|
||||
#include "OctreeElement.h"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include "OctreeConstants.h"
|
||||
#include "OctreeQuery.h"
|
||||
|
|
|
@ -1,33 +1,12 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME particles)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Gui Network Script)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
include_glm()
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_libraries(shared octree fbx networking animation)
|
||||
include_hifi_library_headers(script-engine)
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
|
||||
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <Octree.h>
|
||||
#include <RegisteredMetaTypes.h>
|
||||
#include <SharedUtil.h> // usecTimestampNow()
|
||||
#include <GLMHelpers.h>
|
||||
#include <VoxelsScriptingInterface.h>
|
||||
#include <VoxelDetail.h>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
// I'm open to other potential solutions. Could we change cmake to allow libraries to reference each others
|
||||
// headers, but not link to each other, this is essentially what this construct is doing, but would be
|
||||
// better to add includes to the include path, but not link
|
||||
#include "../../script-engine/src/ScriptEngine.h"
|
||||
#include <ScriptEngine.h>
|
||||
|
||||
#include "ParticlesScriptingInterface.h"
|
||||
#include "Particle.h"
|
||||
|
@ -856,7 +856,7 @@ bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID i
|
|||
}
|
||||
|
||||
// adjust any internal timestamps to fix clock skew for this server
|
||||
void Particle::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) {
|
||||
void Particle::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) {
|
||||
unsigned char* dataAt = codeColorBuffer;
|
||||
int octets = numberOfThreeBitSectionsInCode(dataAt);
|
||||
int lengthOfOctcode = bytesRequiredForCodeLength(octets);
|
||||
|
|
|
@ -292,7 +292,7 @@ public:
|
|||
static bool encodeParticleEditMessageDetails(PacketType command, ParticleID id, const ParticleProperties& details,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut);
|
||||
|
||||
static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew);
|
||||
static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew);
|
||||
|
||||
void applyHardCollision(const CollisionInfo& collisionInfo);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void ParticleEditPacketSender::sendEditParticleMessage(PacketType type, Particle
|
|||
}
|
||||
}
|
||||
|
||||
void ParticleEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) {
|
||||
void ParticleEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) {
|
||||
Particle::adjustEditPacketForClockSkew(codeColorBuffer, length, clockSkew);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,6 @@ public:
|
|||
|
||||
// My server type is the particle server
|
||||
virtual char getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew);
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew);
|
||||
};
|
||||
#endif // hifi_ParticleEditPacketSender_h
|
||||
|
|
|
@ -1,35 +1,11 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME script-engine)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Gui Network Script Widgets)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
include_glm()
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_libraries(shared octree voxels fbx particles models animation)
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
|
||||
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -14,7 +14,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include <OctreeConstants.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include "Quat.h"
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,7 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
set(TARGET_NAME shared)
|
||||
project(${TARGET_NAME})
|
||||
|
||||
find_package(Qt5 COMPONENTS Network Widgets Xml Script)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network Widgets)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
# include GLM
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
set(EXTERNAL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external")
|
||||
|
||||
if (WIN32)
|
||||
# include headers for external libraries and InterfaceConfig.
|
||||
include_directories("${EXTERNAL_ROOT_DIR}")
|
||||
endif (WIN32)
|
||||
|
||||
# link required libraries on UNIX
|
||||
if (UNIX AND NOT APPLE)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}")
|
||||
endif (UNIX AND NOT APPLE)
|
||||
|
||||
# There is something special (bug) about Qt5Scripts, that we have to explicitly add its include
|
||||
# directory when Qt5 (5.2.1) is compiled from source and is not in a standard place.
|
||||
include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets)
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
1403
libraries/shared/external/pthread.h
vendored
1403
libraries/shared/external/pthread.h
vendored
File diff suppressed because it is too large
Load diff
189
libraries/shared/external/sched.h
vendored
189
libraries/shared/external/sched.h
vendored
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
* Module: sched.h
|
||||
*
|
||||
* Purpose:
|
||||
* Provides an implementation of POSIX realtime extensions
|
||||
* as defined in
|
||||
*
|
||||
* POSIX 1003.1b-1993 (POSIX.1b)
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(_SCHED_H)
|
||||
#define _SCHED_H
|
||||
|
||||
#undef PTW32_SCHED_LEVEL
|
||||
|
||||
#if defined(_POSIX_SOURCE)
|
||||
#define PTW32_SCHED_LEVEL 0
|
||||
/* Early POSIX */
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
|
||||
#undef PTW32_SCHED_LEVEL
|
||||
#define PTW32_SCHED_LEVEL 1
|
||||
/* Include 1b, 1c and 1d */
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_NP)
|
||||
#undef PTW32_SCHED_LEVEL
|
||||
#define PTW32_SCHED_LEVEL 2
|
||||
/* Include Non-Portable extensions */
|
||||
#endif
|
||||
|
||||
#define PTW32_SCHED_LEVEL_MAX 3
|
||||
|
||||
#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL)
|
||||
#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX
|
||||
/* Include everything */
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__GNUC__) && !defined(__declspec)
|
||||
# error Please upgrade your GNU compiler to one that supports __declspec.
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When building the library, you should define PTW32_BUILD so that
|
||||
* the variables/functions are exported correctly. When using the library,
|
||||
* do NOT define PTW32_BUILD, and then the variables/functions will
|
||||
* be imported correctly.
|
||||
*/
|
||||
#if !defined(PTW32_STATIC_LIB)
|
||||
# if defined(PTW32_BUILD)
|
||||
# define PTW32_DLLPORT __declspec (dllexport)
|
||||
# else
|
||||
# define PTW32_DLLPORT __declspec (dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define PTW32_DLLPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is a duplicate of what is in the autoconf config.h,
|
||||
* which is only used when building the pthread-win32 libraries.
|
||||
*/
|
||||
|
||||
#if !defined(PTW32_CONFIG_H)
|
||||
# if defined(WINCE)
|
||||
# define NEED_ERRNO
|
||||
# define NEED_SEM
|
||||
# endif
|
||||
# if defined(__MINGW64__)
|
||||
# define HAVE_STRUCT_TIMESPEC
|
||||
# define HAVE_MODE_T
|
||||
# elif defined(_UWIN) || defined(__MINGW32__)
|
||||
# define HAVE_MODE_T
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
|
||||
#if defined(NEED_ERRNO)
|
||||
#include "need_errno.h"
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */
|
||||
|
||||
#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN)
|
||||
# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
|
||||
/* For pid_t */
|
||||
# include <sys/types.h>
|
||||
/* Required by Unix 98 */
|
||||
# include <time.h>
|
||||
# else
|
||||
typedef int pid_t;
|
||||
# endif
|
||||
#else
|
||||
/* [i_a] fix for using pthread_win32 with mongoose code, which #define's its own pid_t akin to typedef HANDLE pid_t; */
|
||||
#undef pid_t
|
||||
# if defined(_MSC_VER)
|
||||
typedef void *pid_t;
|
||||
# else
|
||||
typedef int pid_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Thread scheduling policies */
|
||||
|
||||
enum {
|
||||
SCHED_OTHER = 0,
|
||||
SCHED_FIFO,
|
||||
SCHED_RR,
|
||||
SCHED_MIN = SCHED_OTHER,
|
||||
SCHED_MAX = SCHED_RR
|
||||
};
|
||||
|
||||
struct sched_param {
|
||||
int sched_priority;
|
||||
};
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_yield (void);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
|
||||
|
||||
/*
|
||||
* Note that this macro returns ENOTSUP rather than
|
||||
* ENOSYS as might be expected. However, returning ENOSYS
|
||||
* should mean that sched_get_priority_{min,max} are
|
||||
* not implemented as well as sched_rr_get_interval.
|
||||
* This is not the case, since we just don't support
|
||||
* round-robin scheduling. Therefore I have chosen to
|
||||
* return the same value as sched_setscheduler when
|
||||
* SCHED_RR is passed to it.
|
||||
*/
|
||||
#define sched_rr_get_interval(_pid, _interval) \
|
||||
( errno = ENOTSUP, (int) -1 )
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* End of extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#undef PTW32_SCHED_LEVEL
|
||||
#undef PTW32_SCHED_LEVEL_MAX
|
||||
|
||||
#endif /* !_SCHED_H */
|
||||
|
|
@ -11,8 +11,9 @@
|
|||
|
||||
#include <glm/gtx/norm.hpp>
|
||||
|
||||
#include "GLMHelpers.h"
|
||||
|
||||
#include "AngularConstraint.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
// helper function
|
||||
/// \param angle radian angle to be clamped within angleMin and angleMax
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
|
||||
class AngularConstraint {
|
||||
public:
|
||||
/// \param minAngles minumum euler angles for the constraint
|
||||
|
|
|
@ -10,26 +10,26 @@
|
|||
//
|
||||
|
||||
#include "FixedConstraint.h"
|
||||
#include "Shape.h" // for MAX_SHAPE_MASS
|
||||
#include "VerletPoint.h"
|
||||
|
||||
FixedConstraint::FixedConstraint(VerletPoint* point, const glm::vec3& anchor) : _point(point), _anchor(anchor) {
|
||||
FixedConstraint::FixedConstraint(glm::vec3* anchor, VerletPoint* point) : _anchor(anchor), _point(point) {
|
||||
assert(anchor);
|
||||
assert(point);
|
||||
}
|
||||
|
||||
float FixedConstraint::enforce() {
|
||||
assert(_point != NULL);
|
||||
// TODO: use fast approximate sqrt here
|
||||
float distance = glm::distance(_anchor, _point->_position);
|
||||
_point->_position = _anchor;
|
||||
return distance;
|
||||
_point->_position = *_anchor;
|
||||
_point->_lastPosition = *_anchor;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void FixedConstraint::setAnchor(glm::vec3* anchor) {
|
||||
assert(anchor);
|
||||
_anchor = anchor;
|
||||
}
|
||||
|
||||
void FixedConstraint::setPoint(VerletPoint* point) {
|
||||
assert(point);
|
||||
_point = point;
|
||||
_point->_mass = MAX_SHAPE_MASS;
|
||||
}
|
||||
|
||||
void FixedConstraint::setAnchor(const glm::vec3& anchor) {
|
||||
_anchor = anchor;
|
||||
}
|
||||
|
|
|
@ -18,15 +18,19 @@
|
|||
|
||||
class VerletPoint;
|
||||
|
||||
// FixedConstraint takes pointers to a glm::vec3 and a VerletPoint.
|
||||
// The enforcement will copy the value of the vec3 into the VerletPoint.
|
||||
|
||||
class FixedConstraint : public Constraint {
|
||||
public:
|
||||
FixedConstraint(VerletPoint* point, const glm::vec3& anchor);
|
||||
FixedConstraint(glm::vec3* anchor, VerletPoint* point);
|
||||
~FixedConstraint() {}
|
||||
float enforce();
|
||||
void setAnchor(glm::vec3* anchor);
|
||||
void setPoint(VerletPoint* point);
|
||||
void setAnchor(const glm::vec3& anchor);
|
||||
private:
|
||||
glm::vec3* _anchor;
|
||||
VerletPoint* _point;
|
||||
glm::vec3 _anchor;
|
||||
};
|
||||
|
||||
#endif // hifi_FixedConstraint_h
|
||||
|
|
299
libraries/shared/src/GLMHelpers.cpp
Normal file
299
libraries/shared/src/GLMHelpers.cpp
Normal file
|
@ -0,0 +1,299 @@
|
|||
//
|
||||
// GLMHelpers.cpp
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-08-07.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "GLMHelpers.h"
|
||||
|
||||
// Safe version of glm::mix; based on the code in Nick Bobick's article,
|
||||
// http://www.gamasutra.com/features/19980703/quaternions_01.htm (via Clyde,
|
||||
// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java)
|
||||
glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float proportion) {
|
||||
float cosa = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
|
||||
float ox = q2.x, oy = q2.y, oz = q2.z, ow = q2.w, s0, s1;
|
||||
|
||||
// adjust signs if necessary
|
||||
if (cosa < 0.0f) {
|
||||
cosa = -cosa;
|
||||
ox = -ox;
|
||||
oy = -oy;
|
||||
oz = -oz;
|
||||
ow = -ow;
|
||||
}
|
||||
|
||||
// calculate coefficients; if the angle is too close to zero, we must fall back
|
||||
// to linear interpolation
|
||||
if ((1.0f - cosa) > EPSILON) {
|
||||
float angle = acosf(cosa), sina = sinf(angle);
|
||||
s0 = sinf((1.0f - proportion) * angle) / sina;
|
||||
s1 = sinf(proportion * angle) / sina;
|
||||
|
||||
} else {
|
||||
s0 = 1.0f - proportion;
|
||||
s1 = proportion;
|
||||
}
|
||||
|
||||
return glm::normalize(glm::quat(s0 * q1.w + s1 * ow, s0 * q1.x + s1 * ox, s0 * q1.y + s1 * oy, s0 * q1.z + s1 * oz));
|
||||
}
|
||||
|
||||
// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc
|
||||
int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix) {
|
||||
int16_t outVal = (int16_t)(scalar * (float)(1 << radix));
|
||||
memcpy(buffer, &outVal, sizeof(uint16_t));
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix) {
|
||||
*destinationPointer = *byteFixedPointer / (float)(1 << radix);
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix) {
|
||||
const unsigned char* startPosition = destBuffer;
|
||||
destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.x, radix);
|
||||
destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.y, radix);
|
||||
destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.z, radix);
|
||||
return destBuffer - startPosition;
|
||||
}
|
||||
|
||||
int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix) {
|
||||
const unsigned char* startPosition = sourceBuffer;
|
||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.x), radix);
|
||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.y), radix);
|
||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.z), radix);
|
||||
return sourceBuffer - startPosition;
|
||||
}
|
||||
|
||||
|
||||
int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) {
|
||||
const float ANGLE_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 360.f);
|
||||
|
||||
uint16_t angleHolder = floorf((degrees + 180.f) * ANGLE_CONVERSION_RATIO);
|
||||
memcpy(buffer, &angleHolder, sizeof(uint16_t));
|
||||
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) {
|
||||
*destinationPointer = (*byteAnglePointer / (float) std::numeric_limits<uint16_t>::max()) * 360.f - 180.f;
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) {
|
||||
const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 2.f);
|
||||
uint16_t quatParts[4];
|
||||
quatParts[0] = floorf((quatInput.x + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
||||
quatParts[1] = floorf((quatInput.y + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
||||
quatParts[2] = floorf((quatInput.z + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
||||
quatParts[3] = floorf((quatInput.w + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
||||
|
||||
memcpy(buffer, &quatParts, sizeof(quatParts));
|
||||
return sizeof(quatParts);
|
||||
}
|
||||
|
||||
int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput) {
|
||||
uint16_t quatParts[4];
|
||||
memcpy(&quatParts, buffer, sizeof(quatParts));
|
||||
|
||||
quatOutput.x = ((quatParts[0] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
||||
quatOutput.y = ((quatParts[1] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
||||
quatOutput.z = ((quatParts[2] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
||||
quatOutput.w = ((quatParts[3] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
||||
|
||||
return sizeof(quatParts);
|
||||
}
|
||||
|
||||
// Safe version of glm::eulerAngles; uses the factorization method described in David Eberly's
|
||||
// http://www.geometrictools.com/Documentation/EulerAngles.pdf (via Clyde,
|
||||
// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java)
|
||||
glm::vec3 safeEulerAngles(const glm::quat& q) {
|
||||
float sy = 2.0f * (q.y * q.w - q.x * q.z);
|
||||
glm::vec3 eulers;
|
||||
if (sy < 1.0f - EPSILON) {
|
||||
if (sy > -1.0f + EPSILON) {
|
||||
eulers = glm::vec3(
|
||||
atan2f(q.y * q.z + q.x * q.w, 0.5f - (q.x * q.x + q.y * q.y)),
|
||||
asinf(sy),
|
||||
atan2f(q.x * q.y + q.z * q.w, 0.5f - (q.y * q.y + q.z * q.z)));
|
||||
|
||||
} else {
|
||||
// not a unique solution; x + z = atan2(-m21, m11)
|
||||
eulers = glm::vec3(
|
||||
0.0f,
|
||||
- PI_OVER_TWO,
|
||||
atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z)));
|
||||
}
|
||||
} else {
|
||||
// not a unique solution; x - z = atan2(-m21, m11)
|
||||
eulers = glm::vec3(
|
||||
0.0f,
|
||||
PI_OVER_TWO,
|
||||
-atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z)));
|
||||
}
|
||||
|
||||
// adjust so that z, rather than y, is in [-pi/2, pi/2]
|
||||
if (eulers.z < -PI_OVER_TWO) {
|
||||
if (eulers.x < 0.0f) {
|
||||
eulers.x += PI;
|
||||
} else {
|
||||
eulers.x -= PI;
|
||||
}
|
||||
eulers.y = -eulers.y;
|
||||
if (eulers.y < 0.0f) {
|
||||
eulers.y += PI;
|
||||
} else {
|
||||
eulers.y -= PI;
|
||||
}
|
||||
eulers.z += PI;
|
||||
|
||||
} else if (eulers.z > PI_OVER_TWO) {
|
||||
if (eulers.x < 0.0f) {
|
||||
eulers.x += PI;
|
||||
} else {
|
||||
eulers.x -= PI;
|
||||
}
|
||||
eulers.y = -eulers.y;
|
||||
if (eulers.y < 0.0f) {
|
||||
eulers.y += PI;
|
||||
} else {
|
||||
eulers.y -= PI;
|
||||
}
|
||||
eulers.z -= PI;
|
||||
}
|
||||
return eulers;
|
||||
}
|
||||
|
||||
// Helper function returns the positive angle (in radians) between two 3D vectors
|
||||
float angleBetween(const glm::vec3& v1, const glm::vec3& v2) {
|
||||
return acosf((glm::dot(v1, v2)) / (glm::length(v1) * glm::length(v2)));
|
||||
}
|
||||
|
||||
// Helper function return the rotation from the first vector onto the second
|
||||
glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2) {
|
||||
float angle = angleBetween(v1, v2);
|
||||
if (glm::isnan(angle) || angle < EPSILON) {
|
||||
return glm::quat();
|
||||
}
|
||||
glm::vec3 axis;
|
||||
if (angle > 179.99f * RADIANS_PER_DEGREE) { // 180 degree rotation; must use another axis
|
||||
axis = glm::cross(v1, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
float axisLength = glm::length(axis);
|
||||
if (axisLength < EPSILON) { // parallel to x; y will work
|
||||
axis = glm::normalize(glm::cross(v1, glm::vec3(0.0f, 1.0f, 0.0f)));
|
||||
} else {
|
||||
axis /= axisLength;
|
||||
}
|
||||
} else {
|
||||
axis = glm::normalize(glm::cross(v1, v2));
|
||||
// It is possible for axis to be nan even when angle is not less than EPSILON.
|
||||
// For example when angle is small but not tiny but v1 and v2 and have very short lengths.
|
||||
if (glm::isnan(glm::dot(axis, axis))) {
|
||||
// set angle and axis to values that will generate an identity rotation
|
||||
angle = 0.0f;
|
||||
axis = glm::vec3(1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
return glm::angleAxis(angle, axis);
|
||||
}
|
||||
|
||||
glm::vec3 extractTranslation(const glm::mat4& matrix) {
|
||||
return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]);
|
||||
}
|
||||
|
||||
void setTranslation(glm::mat4& matrix, const glm::vec3& translation) {
|
||||
matrix[3][0] = translation.x;
|
||||
matrix[3][1] = translation.y;
|
||||
matrix[3][2] = translation.z;
|
||||
}
|
||||
|
||||
glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal) {
|
||||
// uses the iterative polar decomposition algorithm described by Ken Shoemake at
|
||||
// http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf
|
||||
// code adapted from Clyde, https://github.com/threerings/clyde/blob/master/core/src/main/java/com/threerings/math/Matrix4f.java
|
||||
// start with the contents of the upper 3x3 portion of the matrix
|
||||
glm::mat3 upper = glm::mat3(matrix);
|
||||
if (!assumeOrthogonal) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// store the results of the previous iteration
|
||||
glm::mat3 previous = upper;
|
||||
|
||||
// compute average of the matrix with its inverse transpose
|
||||
float sd00 = previous[1][1] * previous[2][2] - previous[2][1] * previous[1][2];
|
||||
float sd10 = previous[0][1] * previous[2][2] - previous[2][1] * previous[0][2];
|
||||
float sd20 = previous[0][1] * previous[1][2] - previous[1][1] * previous[0][2];
|
||||
float det = previous[0][0] * sd00 + previous[2][0] * sd20 - previous[1][0] * sd10;
|
||||
if (fabs(det) == 0.0f) {
|
||||
// determinant is zero; matrix is not invertible
|
||||
break;
|
||||
}
|
||||
float hrdet = 0.5f / det;
|
||||
upper[0][0] = +sd00 * hrdet + previous[0][0] * 0.5f;
|
||||
upper[1][0] = -sd10 * hrdet + previous[1][0] * 0.5f;
|
||||
upper[2][0] = +sd20 * hrdet + previous[2][0] * 0.5f;
|
||||
|
||||
upper[0][1] = -(previous[1][0] * previous[2][2] - previous[2][0] * previous[1][2]) * hrdet + previous[0][1] * 0.5f;
|
||||
upper[1][1] = +(previous[0][0] * previous[2][2] - previous[2][0] * previous[0][2]) * hrdet + previous[1][1] * 0.5f;
|
||||
upper[2][1] = -(previous[0][0] * previous[1][2] - previous[1][0] * previous[0][2]) * hrdet + previous[2][1] * 0.5f;
|
||||
|
||||
upper[0][2] = +(previous[1][0] * previous[2][1] - previous[2][0] * previous[1][1]) * hrdet + previous[0][2] * 0.5f;
|
||||
upper[1][2] = -(previous[0][0] * previous[2][1] - previous[2][0] * previous[0][1]) * hrdet + previous[1][2] * 0.5f;
|
||||
upper[2][2] = +(previous[0][0] * previous[1][1] - previous[1][0] * previous[0][1]) * hrdet + previous[2][2] * 0.5f;
|
||||
|
||||
// compute the difference; if it's small enough, we're done
|
||||
glm::mat3 diff = upper - previous;
|
||||
if (diff[0][0] * diff[0][0] + diff[1][0] * diff[1][0] + diff[2][0] * diff[2][0] + diff[0][1] * diff[0][1] +
|
||||
diff[1][1] * diff[1][1] + diff[2][1] * diff[2][1] + diff[0][2] * diff[0][2] + diff[1][2] * diff[1][2] +
|
||||
diff[2][2] * diff[2][2] < EPSILON) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now that we have a nice orthogonal matrix, we can extract the rotation quaternion
|
||||
// using the method described in http://en.wikipedia.org/wiki/Rotation_matrix#Conversions
|
||||
float x2 = fabs(1.0f + upper[0][0] - upper[1][1] - upper[2][2]);
|
||||
float y2 = fabs(1.0f - upper[0][0] + upper[1][1] - upper[2][2]);
|
||||
float z2 = fabs(1.0f - upper[0][0] - upper[1][1] + upper[2][2]);
|
||||
float w2 = fabs(1.0f + upper[0][0] + upper[1][1] + upper[2][2]);
|
||||
return glm::normalize(glm::quat(0.5f * sqrtf(w2),
|
||||
0.5f * sqrtf(x2) * (upper[1][2] >= upper[2][1] ? 1.0f : -1.0f),
|
||||
0.5f * sqrtf(y2) * (upper[2][0] >= upper[0][2] ? 1.0f : -1.0f),
|
||||
0.5f * sqrtf(z2) * (upper[0][1] >= upper[1][0] ? 1.0f : -1.0f)));
|
||||
}
|
||||
|
||||
glm::vec3 extractScale(const glm::mat4& matrix) {
|
||||
return glm::vec3(glm::length(matrix[0]), glm::length(matrix[1]), glm::length(matrix[2]));
|
||||
}
|
||||
|
||||
float extractUniformScale(const glm::mat4& matrix) {
|
||||
return extractUniformScale(extractScale(matrix));
|
||||
}
|
||||
|
||||
float extractUniformScale(const glm::vec3& scale) {
|
||||
return (scale.x + scale.y + scale.z) / 3.0f;
|
||||
}
|
||||
|
||||
QByteArray createByteArray(const glm::vec3& vector) {
|
||||
return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z);
|
||||
}
|
||||
|
||||
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) {
|
||||
// Compute the angular distance between the two orientations
|
||||
float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB)));
|
||||
if (isNaN(angleOrientation)) {
|
||||
angleOrientation = 0.0f;
|
||||
}
|
||||
return (angleOrientation <= similarEnough);
|
||||
}
|
||||
|
||||
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough) {
|
||||
// Compute the distance between the two points
|
||||
float positionDistance = glm::distance(positionA, positionB);
|
||||
return (positionDistance <= similarEnough);
|
||||
}
|
89
libraries/shared/src/GLMHelpers.h
Normal file
89
libraries/shared/src/GLMHelpers.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
//
|
||||
// GLMHelpers.h
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-08-07.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_GLMHelpers_h
|
||||
#define hifi_GLMHelpers_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
|
||||
#include "SharedUtil.h"
|
||||
|
||||
glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float alpha);
|
||||
|
||||
// These pack/unpack functions are designed to start specific known types in as efficient a manner
|
||||
// as possible. Taking advantage of the known characteristics of the semantic types.
|
||||
|
||||
// Angles are known to be between 0 and 360 degrees, this allows us to encode in 16bits with great accuracy
|
||||
int packFloatAngleToTwoByte(unsigned char* buffer, float degrees);
|
||||
int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer);
|
||||
|
||||
// Orientation Quats are known to have 4 normalized components be between -1.0 and 1.0
|
||||
// this allows us to encode each component in 16bits with great accuracy
|
||||
int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput);
|
||||
int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput);
|
||||
|
||||
// Ratios need the be highly accurate when less than 10, but not very accurate above 10, and they
|
||||
// are never greater than 1000 to 1, this allows us to encode each component in 16bits
|
||||
int packFloatRatioToTwoByte(unsigned char* buffer, float ratio);
|
||||
int unpackFloatRatioFromTwoByte(const unsigned char* buffer, float& ratio);
|
||||
|
||||
// Near/Far Clip values need the be highly accurate when less than 10, but only integer accuracy above 10 and
|
||||
// they are never greater than 16,000, this allows us to encode each component in 16bits
|
||||
int packClipValueToTwoByte(unsigned char* buffer, float clipValue);
|
||||
int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue);
|
||||
|
||||
// Positive floats that don't need to be very precise
|
||||
int packFloatToByte(unsigned char* buffer, float value, float scaleBy);
|
||||
int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy);
|
||||
|
||||
// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc
|
||||
int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix);
|
||||
int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix);
|
||||
|
||||
// A convenience for sending vec3's as fixed-point floats
|
||||
int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix);
|
||||
int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix);
|
||||
|
||||
/// \return vec3 with euler angles in radians
|
||||
glm::vec3 safeEulerAngles(const glm::quat& q);
|
||||
|
||||
float angleBetween(const glm::vec3& v1, const glm::vec3& v2);
|
||||
|
||||
glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2);
|
||||
|
||||
glm::vec3 extractTranslation(const glm::mat4& matrix);
|
||||
|
||||
void setTranslation(glm::mat4& matrix, const glm::vec3& translation);
|
||||
|
||||
glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal = false);
|
||||
|
||||
glm::vec3 extractScale(const glm::mat4& matrix);
|
||||
|
||||
float extractUniformScale(const glm::mat4& matrix);
|
||||
|
||||
float extractUniformScale(const glm::vec3& scale);
|
||||
|
||||
QByteArray createByteArray(const glm::vec3& vector);
|
||||
|
||||
/// \return bool are two orientations similar to each other
|
||||
const float ORIENTATION_SIMILAR_ENOUGH = 5.0f; // 10 degrees in any direction
|
||||
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB,
|
||||
float similarEnough = ORIENTATION_SIMILAR_ENOUGH);
|
||||
const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter
|
||||
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH);
|
||||
|
||||
|
||||
#endif // hifi_GLMHelpers_h
|
|
@ -12,6 +12,7 @@
|
|||
#ifndef hifi_MovingMinMaxAvg_h
|
||||
#define hifi_MovingMinMaxAvg_h
|
||||
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
|
||||
#include "RingBufferHistory.h"
|
||||
|
|
|
@ -24,19 +24,51 @@ int MAX_ENTITIES_PER_SIMULATION = 64;
|
|||
int MAX_COLLISIONS_PER_SIMULATION = 256;
|
||||
|
||||
|
||||
PhysicsSimulation::PhysicsSimulation() : _frame(0), _collisions(MAX_COLLISIONS_PER_SIMULATION) {
|
||||
PhysicsSimulation::PhysicsSimulation() : _translation(0.0f), _frameCount(0), _entity(NULL), _ragdoll(NULL),
|
||||
_collisions(MAX_COLLISIONS_PER_SIMULATION) {
|
||||
}
|
||||
|
||||
PhysicsSimulation::~PhysicsSimulation() {
|
||||
// entities have a backpointer to this simulator that must be cleaned up
|
||||
int numEntities = _entities.size();
|
||||
int numEntities = _otherEntities.size();
|
||||
for (int i = 0; i < numEntities; ++i) {
|
||||
_entities[i]->_simulation = NULL;
|
||||
_otherEntities[i]->_simulation = NULL;
|
||||
}
|
||||
_otherEntities.clear();
|
||||
if (_entity) {
|
||||
_entity->_simulation = NULL;
|
||||
}
|
||||
_entities.clear();
|
||||
|
||||
// but Ragdolls do not
|
||||
_dolls.clear();
|
||||
_ragdoll = NULL;
|
||||
_otherRagdolls.clear();
|
||||
}
|
||||
|
||||
void PhysicsSimulation::setRagdoll(Ragdoll* ragdoll) {
|
||||
if (_ragdoll != ragdoll) {
|
||||
if (_ragdoll) {
|
||||
_ragdoll->_ragdollSimulation = NULL;
|
||||
}
|
||||
_ragdoll = ragdoll;
|
||||
if (_ragdoll) {
|
||||
assert(!(_ragdoll->_ragdollSimulation));
|
||||
_ragdoll->_ragdollSimulation = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsSimulation::setEntity(PhysicsEntity* entity) {
|
||||
if (_entity != entity) {
|
||||
if (_entity) {
|
||||
assert(_entity->_simulation == this);
|
||||
_entity->_simulation = NULL;
|
||||
}
|
||||
_entity = entity;
|
||||
if (_entity) {
|
||||
assert(!(_entity->_simulation));
|
||||
_entity->_simulation = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PhysicsSimulation::addEntity(PhysicsEntity* entity) {
|
||||
|
@ -44,25 +76,25 @@ bool PhysicsSimulation::addEntity(PhysicsEntity* entity) {
|
|||
return false;
|
||||
}
|
||||
if (entity->_simulation == this) {
|
||||
int numEntities = _entities.size();
|
||||
int numEntities = _otherEntities.size();
|
||||
for (int i = 0; i < numEntities; ++i) {
|
||||
if (entity == _entities.at(i)) {
|
||||
if (entity == _otherEntities.at(i)) {
|
||||
// already in list
|
||||
assert(entity->_simulation == this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// belongs to some other simulation
|
||||
return false;
|
||||
}
|
||||
int numEntities = _entities.size();
|
||||
int numEntities = _otherEntities.size();
|
||||
if (numEntities > MAX_ENTITIES_PER_SIMULATION) {
|
||||
// list is full
|
||||
return false;
|
||||
}
|
||||
// add to list
|
||||
assert(!(entity->_simulation));
|
||||
entity->_simulation = this;
|
||||
_entities.push_back(entity);
|
||||
_otherEntities.push_back(entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -71,17 +103,17 @@ void PhysicsSimulation::removeEntity(PhysicsEntity* entity) {
|
|||
return;
|
||||
}
|
||||
removeShapes(entity);
|
||||
int numEntities = _entities.size();
|
||||
int numEntities = _otherEntities.size();
|
||||
for (int i = 0; i < numEntities; ++i) {
|
||||
if (entity == _entities.at(i)) {
|
||||
if (entity == _otherEntities.at(i)) {
|
||||
if (i == numEntities - 1) {
|
||||
// remove it
|
||||
_entities.pop_back();
|
||||
_otherEntities.pop_back();
|
||||
} else {
|
||||
// swap the last for this one
|
||||
PhysicsEntity* lastEntity = _entities[numEntities - 1];
|
||||
_entities.pop_back();
|
||||
_entities[i] = lastEntity;
|
||||
PhysicsEntity* lastEntity = _otherEntities[numEntities - 1];
|
||||
_otherEntities.pop_back();
|
||||
_otherEntities[i] = lastEntity;
|
||||
}
|
||||
entity->_simulation = NULL;
|
||||
break;
|
||||
|
@ -101,57 +133,75 @@ void PhysicsSimulation::removeShapes(const PhysicsEntity* entity) {
|
|||
}
|
||||
}
|
||||
|
||||
const float OTHER_RAGDOLL_MASS_SCALE = 10.0f;
|
||||
|
||||
bool PhysicsSimulation::addRagdoll(Ragdoll* doll) {
|
||||
if (!doll) {
|
||||
return false;
|
||||
}
|
||||
int numDolls = _dolls.size();
|
||||
int numDolls = _otherRagdolls.size();
|
||||
if (numDolls > MAX_DOLLS_PER_SIMULATION) {
|
||||
// list is full
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < numDolls; ++i) {
|
||||
if (doll == _dolls[i]) {
|
||||
// already in list
|
||||
return true;
|
||||
if (doll->_ragdollSimulation == this) {
|
||||
for (int i = 0; i < numDolls; ++i) {
|
||||
if (doll == _otherRagdolls[i]) {
|
||||
// already in list
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// add to list
|
||||
_dolls.push_back(doll);
|
||||
assert(!(doll->_ragdollSimulation));
|
||||
doll->_ragdollSimulation = this;
|
||||
_otherRagdolls.push_back(doll);
|
||||
|
||||
// set the massScale of otherRagdolls artificially high
|
||||
doll->setMassScale(OTHER_RAGDOLL_MASS_SCALE);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PhysicsSimulation::removeRagdoll(Ragdoll* doll) {
|
||||
int numDolls = _dolls.size();
|
||||
int numDolls = _otherRagdolls.size();
|
||||
if (doll->_ragdollSimulation != this) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < numDolls; ++i) {
|
||||
if (doll == _dolls[i]) {
|
||||
if (doll == _otherRagdolls[i]) {
|
||||
if (i == numDolls - 1) {
|
||||
// remove it
|
||||
_dolls.pop_back();
|
||||
_otherRagdolls.pop_back();
|
||||
} else {
|
||||
// swap the last for this one
|
||||
Ragdoll* lastDoll = _dolls[numDolls - 1];
|
||||
_dolls.pop_back();
|
||||
_dolls[i] = lastDoll;
|
||||
Ragdoll* lastDoll = _otherRagdolls[numDolls - 1];
|
||||
_otherRagdolls.pop_back();
|
||||
_otherRagdolls[i] = lastDoll;
|
||||
}
|
||||
doll->_ragdollSimulation = NULL;
|
||||
doll->setMassScale(1.0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) {
|
||||
++_frame;
|
||||
++_frameCount;
|
||||
if (!_ragdoll) {
|
||||
return;
|
||||
}
|
||||
quint64 now = usecTimestampNow();
|
||||
quint64 startTime = now;
|
||||
quint64 expiry = startTime + maxUsec;
|
||||
|
||||
moveRagdolls(deltaTime);
|
||||
buildContactConstraints();
|
||||
int numDolls = _dolls.size();
|
||||
int numDolls = _otherRagdolls.size();
|
||||
{
|
||||
PerformanceTimer perfTimer("enforce");
|
||||
_ragdoll->enforceRagdollConstraints();
|
||||
for (int i = 0; i < numDolls; ++i) {
|
||||
_dolls[i]->enforceRagdollConstraints();
|
||||
_otherRagdolls[i]->enforceRagdollConstraints();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,9 +214,9 @@ void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIter
|
|||
|
||||
{ // enforce constraints
|
||||
PerformanceTimer perfTimer("enforce");
|
||||
error = 0.0f;
|
||||
error = _ragdoll->enforceRagdollConstraints();
|
||||
for (int i = 0; i < numDolls; ++i) {
|
||||
error = glm::max(error, _dolls[i]->enforceRagdollConstraints());
|
||||
error = glm::max(error, _otherRagdolls[i]->enforceRagdollConstraints());
|
||||
}
|
||||
}
|
||||
enforceContactConstraints();
|
||||
|
@ -180,40 +230,38 @@ void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIter
|
|||
|
||||
void PhysicsSimulation::moveRagdolls(float deltaTime) {
|
||||
PerformanceTimer perfTimer("integrate");
|
||||
int numDolls = _dolls.size();
|
||||
_ragdoll->stepRagdollForward(deltaTime);
|
||||
int numDolls = _otherRagdolls.size();
|
||||
for (int i = 0; i < numDolls; ++i) {
|
||||
_dolls.at(i)->stepRagdollForward(deltaTime);
|
||||
_otherRagdolls[i]->stepRagdollForward(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsSimulation::computeCollisions() {
|
||||
PerformanceTimer perfTimer("collide");
|
||||
_collisions.clear();
|
||||
// TODO: keep track of QSet<PhysicsEntity*> collidedEntities;
|
||||
int numEntities = _entities.size();
|
||||
for (int i = 0; i < numEntities; ++i) {
|
||||
PhysicsEntity* entity = _entities.at(i);
|
||||
const QVector<Shape*> shapes = entity->getShapes();
|
||||
int numShapes = shapes.size();
|
||||
// collide with self
|
||||
for (int j = 0; j < numShapes; ++j) {
|
||||
const Shape* shape = shapes.at(j);
|
||||
if (!shape) {
|
||||
continue;
|
||||
}
|
||||
for (int k = j+1; k < numShapes; ++k) {
|
||||
const Shape* otherShape = shapes.at(k);
|
||||
if (otherShape && entity->collisionsAreEnabled(j, k)) {
|
||||
ShapeCollider::collideShapes(shape, otherShape, _collisions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// collide with others
|
||||
for (int j = i+1; j < numEntities; ++j) {
|
||||
const QVector<Shape*> otherShapes = _entities.at(j)->getShapes();
|
||||
ShapeCollider::collideShapesWithShapes(shapes, otherShapes, _collisions);
|
||||
const QVector<Shape*> shapes = _entity->getShapes();
|
||||
int numShapes = shapes.size();
|
||||
// collide main ragdoll with self
|
||||
for (int i = 0; i < numShapes; ++i) {
|
||||
const Shape* shape = shapes.at(i);
|
||||
if (!shape) {
|
||||
continue;
|
||||
}
|
||||
for (int j = i+1; j < numShapes; ++j) {
|
||||
const Shape* otherShape = shapes.at(j);
|
||||
if (otherShape && _entity->collisionsAreEnabled(i, j)) {
|
||||
ShapeCollider::collideShapes(shape, otherShape, _collisions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// collide main ragdoll with others
|
||||
int numEntities = _otherEntities.size();
|
||||
for (int i = 0; i < numEntities; ++i) {
|
||||
const QVector<Shape*> otherShapes = _otherEntities.at(i)->getShapes();
|
||||
ShapeCollider::collideShapesWithShapes(shapes, otherShapes, _collisions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,9 +317,9 @@ void PhysicsSimulation::updateContacts() {
|
|||
}
|
||||
QMap<quint64, ContactPoint>::iterator itr = _contacts.find(key);
|
||||
if (itr == _contacts.end()) {
|
||||
_contacts.insert(key, ContactPoint(*collision, _frame));
|
||||
_contacts.insert(key, ContactPoint(*collision, _frameCount));
|
||||
} else {
|
||||
itr.value().updateContact(*collision, _frame);
|
||||
itr.value().updateContact(*collision, _frameCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +329,7 @@ const quint32 MAX_CONTACT_FRAME_LIFETIME = 2;
|
|||
void PhysicsSimulation::pruneContacts() {
|
||||
QMap<quint64, ContactPoint>::iterator itr = _contacts.begin();
|
||||
while (itr != _contacts.end()) {
|
||||
if (_frame - itr.value().getLastFrame() > MAX_CONTACT_FRAME_LIFETIME) {
|
||||
if (_frameCount - itr.value().getLastFrame() > MAX_CONTACT_FRAME_LIFETIME) {
|
||||
itr = _contacts.erase(itr);
|
||||
} else {
|
||||
++itr;
|
||||
|
|
|
@ -28,6 +28,12 @@ public:
|
|||
PhysicsSimulation();
|
||||
~PhysicsSimulation();
|
||||
|
||||
void setTranslation(const glm::vec3& translation) { _translation = translation; }
|
||||
const glm::vec3& getTranslation() const { return _translation; }
|
||||
|
||||
void setRagdoll(Ragdoll* ragdoll);
|
||||
void setEntity(PhysicsEntity* entity);
|
||||
|
||||
/// \return true if entity was added to or is already in the list
|
||||
bool addEntity(PhysicsEntity* entity);
|
||||
|
||||
|
@ -56,10 +62,15 @@ protected:
|
|||
void pruneContacts();
|
||||
|
||||
private:
|
||||
quint32 _frame;
|
||||
glm::vec3 _translation; // origin of simulation in world-frame
|
||||
|
||||
QVector<Ragdoll*> _dolls;
|
||||
QVector<PhysicsEntity*> _entities;
|
||||
quint32 _frameCount;
|
||||
|
||||
PhysicsEntity* _entity;
|
||||
Ragdoll* _ragdoll;
|
||||
|
||||
QVector<Ragdoll*> _otherRagdolls;
|
||||
QVector<PhysicsEntity*> _otherEntities;
|
||||
CollisionList _collisions;
|
||||
QMap<quint64, ContactPoint> _contacts;
|
||||
};
|
||||
|
|
|
@ -9,13 +9,17 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <glm/gtx/norm.hpp>
|
||||
|
||||
#include "Ragdoll.h"
|
||||
|
||||
#include "Constraint.h"
|
||||
#include "DistanceConstraint.h"
|
||||
#include "FixedConstraint.h"
|
||||
#include "PhysicsSimulation.h"
|
||||
#include "SharedUtil.h" // for EPSILON
|
||||
|
||||
Ragdoll::Ragdoll() {
|
||||
Ragdoll::Ragdoll() : _massScale(1.0f), _ragdollTranslation(0.0f), _translationInSimulationFrame(0.0f), _ragdollSimulation(NULL) {
|
||||
}
|
||||
|
||||
Ragdoll::~Ragdoll() {
|
||||
|
@ -23,6 +27,9 @@ Ragdoll::~Ragdoll() {
|
|||
}
|
||||
|
||||
void Ragdoll::stepRagdollForward(float deltaTime) {
|
||||
if (_ragdollSimulation) {
|
||||
updateSimulationTransforms(_ragdollTranslation - _ragdollSimulation->getTranslation(), _ragdollRotation);
|
||||
}
|
||||
int numPoints = _ragdollPoints.size();
|
||||
for (int i = 0; i < numPoints; ++i) {
|
||||
_ragdollPoints[i].integrateForward();
|
||||
|
@ -30,21 +37,79 @@ void Ragdoll::stepRagdollForward(float deltaTime) {
|
|||
}
|
||||
|
||||
void Ragdoll::clearRagdollConstraintsAndPoints() {
|
||||
int numConstraints = _ragdollConstraints.size();
|
||||
int numConstraints = _boneConstraints.size();
|
||||
for (int i = 0; i < numConstraints; ++i) {
|
||||
delete _ragdollConstraints[i];
|
||||
delete _boneConstraints[i];
|
||||
}
|
||||
_ragdollConstraints.clear();
|
||||
_boneConstraints.clear();
|
||||
numConstraints = _fixedConstraints.size();
|
||||
for (int i = 0; i < numConstraints; ++i) {
|
||||
delete _fixedConstraints[i];
|
||||
}
|
||||
_fixedConstraints.clear();
|
||||
_ragdollPoints.clear();
|
||||
}
|
||||
|
||||
float Ragdoll::enforceRagdollConstraints() {
|
||||
float maxDistance = 0.0f;
|
||||
const int numConstraints = _ragdollConstraints.size();
|
||||
// enforce the bone constraints first
|
||||
int numConstraints = _boneConstraints.size();
|
||||
for (int i = 0; i < numConstraints; ++i) {
|
||||
DistanceConstraint* c = static_cast<DistanceConstraint*>(_ragdollConstraints[i]);
|
||||
//maxDistance = glm::max(maxDistance, _ragdollConstraints[i]->enforce());
|
||||
maxDistance = glm::max(maxDistance, c->enforce());
|
||||
maxDistance = glm::max(maxDistance, _boneConstraints[i]->enforce());
|
||||
}
|
||||
// enforce FixedConstraints second
|
||||
numConstraints = _fixedConstraints.size();
|
||||
for (int i = 0; i < _fixedConstraints.size(); ++i) {
|
||||
maxDistance = glm::max(maxDistance, _fixedConstraints[i]->enforce());
|
||||
}
|
||||
return maxDistance;
|
||||
}
|
||||
|
||||
void Ragdoll::initRagdollTransform() {
|
||||
_ragdollTranslation = glm::vec3(0.0f);
|
||||
_ragdollRotation = glm::quat();
|
||||
_translationInSimulationFrame = glm::vec3(0.0f);
|
||||
_rotationInSimulationFrame = glm::quat();
|
||||
}
|
||||
|
||||
void Ragdoll::setRagdollTransform(const glm::vec3& translation, const glm::quat& rotation) {
|
||||
_ragdollTranslation = translation;
|
||||
_ragdollRotation = rotation;
|
||||
}
|
||||
|
||||
void Ragdoll::updateSimulationTransforms(const glm::vec3& translation, const glm::quat& rotation) {
|
||||
const float EPSILON2 = EPSILON * EPSILON;
|
||||
if (glm::distance2(translation, _translationInSimulationFrame) < EPSILON2 &&
|
||||
glm::abs(1.0f - glm::abs(glm::dot(rotation, _rotationInSimulationFrame))) < EPSILON2) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
// compute linear and angular deltas
|
||||
glm::vec3 deltaPosition = translation - _translationInSimulationFrame;
|
||||
glm::quat deltaRotation = rotation * glm::inverse(_rotationInSimulationFrame);
|
||||
|
||||
// apply the deltas to all ragdollPoints
|
||||
int numPoints = _ragdollPoints.size();
|
||||
for (int i = 0; i < numPoints; ++i) {
|
||||
_ragdollPoints[i].move(deltaPosition, deltaRotation, _translationInSimulationFrame);
|
||||
}
|
||||
|
||||
// remember the current transform
|
||||
_translationInSimulationFrame = translation;
|
||||
_rotationInSimulationFrame = rotation;
|
||||
}
|
||||
|
||||
void Ragdoll::setMassScale(float scale) {
|
||||
const float MIN_SCALE = 1.0e-2f;
|
||||
const float MAX_SCALE = 1.0e6f;
|
||||
scale = glm::clamp(glm::abs(scale), MIN_SCALE, MAX_SCALE);
|
||||
if (scale != _massScale) {
|
||||
float rescale = scale / _massScale;
|
||||
int numPoints = _ragdollPoints.size();
|
||||
for (int i = 0; i < numPoints; ++i) {
|
||||
_ragdollPoints[i].setMass(rescale * _ragdollPoints[i].getMass());
|
||||
}
|
||||
_massScale = scale;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,14 @@
|
|||
|
||||
#include <QVector>
|
||||
|
||||
class Constraint;
|
||||
//#include "PhysicsSimulation.h"
|
||||
|
||||
class DistanceConstraint;
|
||||
class FixedConstraint;
|
||||
class PhysicsSimulation;
|
||||
|
||||
// TODO: don't derive SkeletonModel from Ragdoll so we can clean up the Ragdoll API
|
||||
// (==> won't need to worry about namespace conflicts between Entity and Ragdoll).
|
||||
|
||||
class Ragdoll {
|
||||
public:
|
||||
|
@ -35,13 +42,35 @@ public:
|
|||
const QVector<VerletPoint>& getRagdollPoints() const { return _ragdollPoints; }
|
||||
QVector<VerletPoint>& getRagdollPoints() { return _ragdollPoints; }
|
||||
|
||||
void initRagdollTransform();
|
||||
|
||||
/// set the translation and rotation of the Ragdoll and adjust all VerletPoints.
|
||||
void setRagdollTransform(const glm::vec3& translation, const glm::quat& rotation);
|
||||
|
||||
const glm::vec3& getTranslationInSimulationFrame() const { return _translationInSimulationFrame; }
|
||||
|
||||
void setMassScale(float scale);
|
||||
float getMassScale() const { return _massScale; }
|
||||
|
||||
protected:
|
||||
void clearRagdollConstraintsAndPoints();
|
||||
virtual void initRagdollPoints() = 0;
|
||||
virtual void buildRagdollConstraints() = 0;
|
||||
|
||||
float _massScale;
|
||||
glm::vec3 _ragdollTranslation; // world-frame
|
||||
glm::quat _ragdollRotation; // world-frame
|
||||
glm::vec3 _translationInSimulationFrame;
|
||||
glm::quat _rotationInSimulationFrame;
|
||||
|
||||
QVector<VerletPoint> _ragdollPoints;
|
||||
QVector<Constraint*> _ragdollConstraints;
|
||||
QVector<DistanceConstraint*> _boneConstraints;
|
||||
QVector<FixedConstraint*> _fixedConstraints;
|
||||
private:
|
||||
void updateSimulationTransforms(const glm::vec3& translation, const glm::quat& rotation);
|
||||
|
||||
friend class PhysicsSimulation;
|
||||
PhysicsSimulation* _ragdollSimulation;
|
||||
};
|
||||
|
||||
#endif // hifi_Ragdoll_h
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
@ -79,40 +80,6 @@ bool shouldDo(float desiredInterval, float deltaTime) {
|
|||
return randFloat() < deltaTime / desiredInterval;
|
||||
}
|
||||
|
||||
// Safe version of glm::mix; based on the code in Nick Bobick's article,
|
||||
// http://www.gamasutra.com/features/19980703/quaternions_01.htm (via Clyde,
|
||||
// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java)
|
||||
glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float proportion) {
|
||||
float cosa = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
|
||||
float ox = q2.x, oy = q2.y, oz = q2.z, ow = q2.w, s0, s1;
|
||||
|
||||
// adjust signs if necessary
|
||||
if (cosa < 0.0f) {
|
||||
cosa = -cosa;
|
||||
ox = -ox;
|
||||
oy = -oy;
|
||||
oz = -oz;
|
||||
ow = -ow;
|
||||
}
|
||||
|
||||
// calculate coefficients; if the angle is too close to zero, we must fall back
|
||||
// to linear interpolation
|
||||
if ((1.0f - cosa) > EPSILON) {
|
||||
float angle = acosf(cosa), sina = sinf(angle);
|
||||
s0 = sinf((1.0f - proportion) * angle) / sina;
|
||||
s1 = sinf(proportion * angle) / sina;
|
||||
|
||||
} else {
|
||||
s0 = 1.0f - proportion;
|
||||
s1 = proportion;
|
||||
}
|
||||
|
||||
return glm::normalize(glm::quat(s0 * q1.w + s1 * ow, s0 * q1.x + s1 * ox, s0 * q1.y + s1 * oy, s0 * q1.z + s1 * oz));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void outputBufferBits(const unsigned char* buffer, int length, QDebug* continuedDebug) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
outputBits(buffer[i], continuedDebug);
|
||||
|
@ -489,73 +456,6 @@ int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int*
|
|||
return -1; // error case
|
||||
}
|
||||
|
||||
// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc
|
||||
int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix) {
|
||||
int16_t outVal = (int16_t)(scalar * (float)(1 << radix));
|
||||
memcpy(buffer, &outVal, sizeof(uint16_t));
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix) {
|
||||
*destinationPointer = *byteFixedPointer / (float)(1 << radix);
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix) {
|
||||
const unsigned char* startPosition = destBuffer;
|
||||
destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.x, radix);
|
||||
destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.y, radix);
|
||||
destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.z, radix);
|
||||
return destBuffer - startPosition;
|
||||
}
|
||||
|
||||
int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix) {
|
||||
const unsigned char* startPosition = sourceBuffer;
|
||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.x), radix);
|
||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.y), radix);
|
||||
sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.z), radix);
|
||||
return sourceBuffer - startPosition;
|
||||
}
|
||||
|
||||
|
||||
int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) {
|
||||
const float ANGLE_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 360.f);
|
||||
|
||||
uint16_t angleHolder = floorf((degrees + 180.f) * ANGLE_CONVERSION_RATIO);
|
||||
memcpy(buffer, &angleHolder, sizeof(uint16_t));
|
||||
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) {
|
||||
*destinationPointer = (*byteAnglePointer / (float) std::numeric_limits<uint16_t>::max()) * 360.f - 180.f;
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) {
|
||||
const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 2.f);
|
||||
uint16_t quatParts[4];
|
||||
quatParts[0] = floorf((quatInput.x + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
||||
quatParts[1] = floorf((quatInput.y + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
||||
quatParts[2] = floorf((quatInput.z + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
||||
quatParts[3] = floorf((quatInput.w + 1.f) * QUAT_PART_CONVERSION_RATIO);
|
||||
|
||||
memcpy(buffer, &quatParts, sizeof(quatParts));
|
||||
return sizeof(quatParts);
|
||||
}
|
||||
|
||||
int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput) {
|
||||
uint16_t quatParts[4];
|
||||
memcpy(&quatParts, buffer, sizeof(quatParts));
|
||||
|
||||
quatOutput.x = ((quatParts[0] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
||||
quatOutput.y = ((quatParts[1] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
||||
quatOutput.z = ((quatParts[2] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
||||
quatOutput.w = ((quatParts[3] / (float) std::numeric_limits<uint16_t>::max()) * 2.f) - 1.f;
|
||||
|
||||
return sizeof(quatParts);
|
||||
}
|
||||
|
||||
float SMALL_LIMIT = 10.f;
|
||||
float LARGE_LIMIT = 1000.f;
|
||||
|
||||
|
@ -651,199 +551,10 @@ void debug::checkDeadBeef(void* memoryVoid, int size) {
|
|||
assert(memcmp((unsigned char*)memoryVoid, DEADBEEF, std::min(size, DEADBEEF_SIZE)) != 0);
|
||||
}
|
||||
|
||||
// Safe version of glm::eulerAngles; uses the factorization method described in David Eberly's
|
||||
// http://www.geometrictools.com/Documentation/EulerAngles.pdf (via Clyde,
|
||||
// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java)
|
||||
glm::vec3 safeEulerAngles(const glm::quat& q) {
|
||||
float sy = 2.0f * (q.y * q.w - q.x * q.z);
|
||||
glm::vec3 eulers;
|
||||
if (sy < 1.0f - EPSILON) {
|
||||
if (sy > -1.0f + EPSILON) {
|
||||
eulers = glm::vec3(
|
||||
atan2f(q.y * q.z + q.x * q.w, 0.5f - (q.x * q.x + q.y * q.y)),
|
||||
asinf(sy),
|
||||
atan2f(q.x * q.y + q.z * q.w, 0.5f - (q.y * q.y + q.z * q.z)));
|
||||
|
||||
} else {
|
||||
// not a unique solution; x + z = atan2(-m21, m11)
|
||||
eulers = glm::vec3(
|
||||
0.0f,
|
||||
- PI_OVER_TWO,
|
||||
atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z)));
|
||||
}
|
||||
} else {
|
||||
// not a unique solution; x - z = atan2(-m21, m11)
|
||||
eulers = glm::vec3(
|
||||
0.0f,
|
||||
PI_OVER_TWO,
|
||||
-atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z)));
|
||||
}
|
||||
|
||||
// adjust so that z, rather than y, is in [-pi/2, pi/2]
|
||||
if (eulers.z < -PI_OVER_TWO) {
|
||||
if (eulers.x < 0.0f) {
|
||||
eulers.x += PI;
|
||||
} else {
|
||||
eulers.x -= PI;
|
||||
}
|
||||
eulers.y = -eulers.y;
|
||||
if (eulers.y < 0.0f) {
|
||||
eulers.y += PI;
|
||||
} else {
|
||||
eulers.y -= PI;
|
||||
}
|
||||
eulers.z += PI;
|
||||
|
||||
} else if (eulers.z > PI_OVER_TWO) {
|
||||
if (eulers.x < 0.0f) {
|
||||
eulers.x += PI;
|
||||
} else {
|
||||
eulers.x -= PI;
|
||||
}
|
||||
eulers.y = -eulers.y;
|
||||
if (eulers.y < 0.0f) {
|
||||
eulers.y += PI;
|
||||
} else {
|
||||
eulers.y -= PI;
|
||||
}
|
||||
eulers.z -= PI;
|
||||
}
|
||||
return eulers;
|
||||
}
|
||||
|
||||
// Helper function returns the positive angle (in radians) between two 3D vectors
|
||||
float angleBetween(const glm::vec3& v1, const glm::vec3& v2) {
|
||||
return acosf((glm::dot(v1, v2)) / (glm::length(v1) * glm::length(v2)));
|
||||
}
|
||||
|
||||
// Helper function return the rotation from the first vector onto the second
|
||||
glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2) {
|
||||
float angle = angleBetween(v1, v2);
|
||||
if (glm::isnan(angle) || angle < EPSILON) {
|
||||
return glm::quat();
|
||||
}
|
||||
glm::vec3 axis;
|
||||
if (angle > 179.99f * RADIANS_PER_DEGREE) { // 180 degree rotation; must use another axis
|
||||
axis = glm::cross(v1, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
float axisLength = glm::length(axis);
|
||||
if (axisLength < EPSILON) { // parallel to x; y will work
|
||||
axis = glm::normalize(glm::cross(v1, glm::vec3(0.0f, 1.0f, 0.0f)));
|
||||
} else {
|
||||
axis /= axisLength;
|
||||
}
|
||||
} else {
|
||||
axis = glm::normalize(glm::cross(v1, v2));
|
||||
// It is possible for axis to be nan even when angle is not less than EPSILON.
|
||||
// For example when angle is small but not tiny but v1 and v2 and have very short lengths.
|
||||
if (glm::isnan(glm::dot(axis, axis))) {
|
||||
// set angle and axis to values that will generate an identity rotation
|
||||
angle = 0.0f;
|
||||
axis = glm::vec3(1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
return glm::angleAxis(angle, axis);
|
||||
}
|
||||
|
||||
glm::vec3 extractTranslation(const glm::mat4& matrix) {
|
||||
return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]);
|
||||
}
|
||||
|
||||
void setTranslation(glm::mat4& matrix, const glm::vec3& translation) {
|
||||
matrix[3][0] = translation.x;
|
||||
matrix[3][1] = translation.y;
|
||||
matrix[3][2] = translation.z;
|
||||
}
|
||||
|
||||
glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal) {
|
||||
// uses the iterative polar decomposition algorithm described by Ken Shoemake at
|
||||
// http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf
|
||||
// code adapted from Clyde, https://github.com/threerings/clyde/blob/master/core/src/main/java/com/threerings/math/Matrix4f.java
|
||||
// start with the contents of the upper 3x3 portion of the matrix
|
||||
glm::mat3 upper = glm::mat3(matrix);
|
||||
if (!assumeOrthogonal) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// store the results of the previous iteration
|
||||
glm::mat3 previous = upper;
|
||||
|
||||
// compute average of the matrix with its inverse transpose
|
||||
float sd00 = previous[1][1] * previous[2][2] - previous[2][1] * previous[1][2];
|
||||
float sd10 = previous[0][1] * previous[2][2] - previous[2][1] * previous[0][2];
|
||||
float sd20 = previous[0][1] * previous[1][2] - previous[1][1] * previous[0][2];
|
||||
float det = previous[0][0] * sd00 + previous[2][0] * sd20 - previous[1][0] * sd10;
|
||||
if (fabs(det) == 0.0f) {
|
||||
// determinant is zero; matrix is not invertible
|
||||
break;
|
||||
}
|
||||
float hrdet = 0.5f / det;
|
||||
upper[0][0] = +sd00 * hrdet + previous[0][0] * 0.5f;
|
||||
upper[1][0] = -sd10 * hrdet + previous[1][0] * 0.5f;
|
||||
upper[2][0] = +sd20 * hrdet + previous[2][0] * 0.5f;
|
||||
|
||||
upper[0][1] = -(previous[1][0] * previous[2][2] - previous[2][0] * previous[1][2]) * hrdet + previous[0][1] * 0.5f;
|
||||
upper[1][1] = +(previous[0][0] * previous[2][2] - previous[2][0] * previous[0][2]) * hrdet + previous[1][1] * 0.5f;
|
||||
upper[2][1] = -(previous[0][0] * previous[1][2] - previous[1][0] * previous[0][2]) * hrdet + previous[2][1] * 0.5f;
|
||||
|
||||
upper[0][2] = +(previous[1][0] * previous[2][1] - previous[2][0] * previous[1][1]) * hrdet + previous[0][2] * 0.5f;
|
||||
upper[1][2] = -(previous[0][0] * previous[2][1] - previous[2][0] * previous[0][1]) * hrdet + previous[1][2] * 0.5f;
|
||||
upper[2][2] = +(previous[0][0] * previous[1][1] - previous[1][0] * previous[0][1]) * hrdet + previous[2][2] * 0.5f;
|
||||
|
||||
// compute the difference; if it's small enough, we're done
|
||||
glm::mat3 diff = upper - previous;
|
||||
if (diff[0][0] * diff[0][0] + diff[1][0] * diff[1][0] + diff[2][0] * diff[2][0] + diff[0][1] * diff[0][1] +
|
||||
diff[1][1] * diff[1][1] + diff[2][1] * diff[2][1] + diff[0][2] * diff[0][2] + diff[1][2] * diff[1][2] +
|
||||
diff[2][2] * diff[2][2] < EPSILON) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now that we have a nice orthogonal matrix, we can extract the rotation quaternion
|
||||
// using the method described in http://en.wikipedia.org/wiki/Rotation_matrix#Conversions
|
||||
float x2 = fabs(1.0f + upper[0][0] - upper[1][1] - upper[2][2]);
|
||||
float y2 = fabs(1.0f - upper[0][0] + upper[1][1] - upper[2][2]);
|
||||
float z2 = fabs(1.0f - upper[0][0] - upper[1][1] + upper[2][2]);
|
||||
float w2 = fabs(1.0f + upper[0][0] + upper[1][1] + upper[2][2]);
|
||||
return glm::normalize(glm::quat(0.5f * sqrtf(w2),
|
||||
0.5f * sqrtf(x2) * (upper[1][2] >= upper[2][1] ? 1.0f : -1.0f),
|
||||
0.5f * sqrtf(y2) * (upper[2][0] >= upper[0][2] ? 1.0f : -1.0f),
|
||||
0.5f * sqrtf(z2) * (upper[0][1] >= upper[1][0] ? 1.0f : -1.0f)));
|
||||
}
|
||||
|
||||
glm::vec3 extractScale(const glm::mat4& matrix) {
|
||||
return glm::vec3(glm::length(matrix[0]), glm::length(matrix[1]), glm::length(matrix[2]));
|
||||
}
|
||||
|
||||
float extractUniformScale(const glm::mat4& matrix) {
|
||||
return extractUniformScale(extractScale(matrix));
|
||||
}
|
||||
|
||||
float extractUniformScale(const glm::vec3& scale) {
|
||||
return (scale.x + scale.y + scale.z) / 3.0f;
|
||||
}
|
||||
|
||||
bool isNaN(float value) {
|
||||
return value != value;
|
||||
}
|
||||
|
||||
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) {
|
||||
// Compute the angular distance between the two orientations
|
||||
float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB)));
|
||||
if (isNaN(angleOrientation)) {
|
||||
angleOrientation = 0.0f;
|
||||
}
|
||||
return (angleOrientation <= similarEnough);
|
||||
}
|
||||
|
||||
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough) {
|
||||
// Compute the distance between the two points
|
||||
float positionDistance = glm::distance(positionA, positionB);
|
||||
return (positionDistance <= similarEnough);
|
||||
}
|
||||
|
||||
QByteArray createByteArray(const glm::vec3& vector) {
|
||||
return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z);
|
||||
}
|
||||
|
||||
QString formatUsecTime(float usecs, int prec) {
|
||||
static const quint64 SECONDS_PER_MINUTE = 60;
|
||||
static const quint64 USECS_PER_MINUTE = USECS_PER_SECOND * SECONDS_PER_MINUTE;
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
#include <unistd.h> // not on windows, not needed for mac or windows
|
||||
#endif
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
const int BYTES_PER_COLOR = 3;
|
||||
|
@ -71,8 +68,6 @@ float randomSign(); /// \return -1.0 or 1.0
|
|||
unsigned char randomColorValue(int minimum = 0);
|
||||
bool randomBoolean();
|
||||
|
||||
glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float alpha);
|
||||
|
||||
bool shouldDo(float desiredInterval, float deltaTime);
|
||||
|
||||
void outputBufferBits(const unsigned char* buffer, int length, QDebug* continuedDebug = NULL);
|
||||
|
@ -108,8 +103,6 @@ int insertIntoSortedArrays(void* value, float key, int originalIndex,
|
|||
int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int* originalIndexArray,
|
||||
int currentCount, int maxCount);
|
||||
|
||||
|
||||
|
||||
// Helper Class for debugging
|
||||
class debug {
|
||||
public:
|
||||
|
@ -124,71 +117,9 @@ private:
|
|||
bool isBetween(int64_t value, int64_t max, int64_t min);
|
||||
|
||||
|
||||
// These pack/unpack functions are designed to start specific known types in as efficient a manner
|
||||
// as possible. Taking advantage of the known characteristics of the semantic types.
|
||||
|
||||
// Angles are known to be between 0 and 360 degrees, this allows us to encode in 16bits with great accuracy
|
||||
int packFloatAngleToTwoByte(unsigned char* buffer, float degrees);
|
||||
int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer);
|
||||
|
||||
// Orientation Quats are known to have 4 normalized components be between -1.0 and 1.0
|
||||
// this allows us to encode each component in 16bits with great accuracy
|
||||
int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput);
|
||||
int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput);
|
||||
|
||||
// Ratios need the be highly accurate when less than 10, but not very accurate above 10, and they
|
||||
// are never greater than 1000 to 1, this allows us to encode each component in 16bits
|
||||
int packFloatRatioToTwoByte(unsigned char* buffer, float ratio);
|
||||
int unpackFloatRatioFromTwoByte(const unsigned char* buffer, float& ratio);
|
||||
|
||||
// Near/Far Clip values need the be highly accurate when less than 10, but only integer accuracy above 10 and
|
||||
// they are never greater than 16,000, this allows us to encode each component in 16bits
|
||||
int packClipValueToTwoByte(unsigned char* buffer, float clipValue);
|
||||
int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue);
|
||||
|
||||
// Positive floats that don't need to be very precise
|
||||
int packFloatToByte(unsigned char* buffer, float value, float scaleBy);
|
||||
int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy);
|
||||
|
||||
// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc
|
||||
int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix);
|
||||
int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix);
|
||||
|
||||
// A convenience for sending vec3's as fixed-point floats
|
||||
int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix);
|
||||
int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix);
|
||||
|
||||
/// \return vec3 with euler angles in radians
|
||||
glm::vec3 safeEulerAngles(const glm::quat& q);
|
||||
|
||||
float angleBetween(const glm::vec3& v1, const glm::vec3& v2);
|
||||
|
||||
glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2);
|
||||
|
||||
glm::vec3 extractTranslation(const glm::mat4& matrix);
|
||||
|
||||
void setTranslation(glm::mat4& matrix, const glm::vec3& translation);
|
||||
|
||||
glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal = false);
|
||||
|
||||
glm::vec3 extractScale(const glm::mat4& matrix);
|
||||
|
||||
float extractUniformScale(const glm::mat4& matrix);
|
||||
|
||||
float extractUniformScale(const glm::vec3& scale);
|
||||
|
||||
/// \return bool are two orientations similar to each other
|
||||
const float ORIENTATION_SIMILAR_ENOUGH = 5.0f; // 10 degrees in any direction
|
||||
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB,
|
||||
float similarEnough = ORIENTATION_SIMILAR_ENOUGH);
|
||||
const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter
|
||||
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH);
|
||||
|
||||
/// \return bool is the float NaN
|
||||
bool isNaN(float value);
|
||||
|
||||
QByteArray createByteArray(const glm::vec3& vector);
|
||||
|
||||
QString formatUsecTime(float usecs, int prec = 3);
|
||||
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ float VerletCapsuleShape::computeEffectiveMass(const glm::vec3& penetration, con
|
|||
_endLagrangeCoef = 1.0f;
|
||||
}
|
||||
// the effective mass is the weighted sum of the two endpoints
|
||||
return _startLagrangeCoef * _startPoint->_mass + _endLagrangeCoef * _endPoint->_mass;
|
||||
return _startLagrangeCoef * _startPoint->getMass() + _endLagrangeCoef * _endPoint->getMass();
|
||||
}
|
||||
|
||||
void VerletCapsuleShape::accumulateDelta(float relativeMassFactor, const glm::vec3& penetration) {
|
||||
|
|
|
@ -31,3 +31,19 @@ void VerletPoint::applyAccumulatedDelta() {
|
|||
_numDeltas = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void VerletPoint::move(const glm::vec3& deltaPosition, const glm::quat& deltaRotation, const glm::vec3& oldPivot) {
|
||||
glm::vec3 arm = _position - oldPivot;
|
||||
_position += deltaPosition + (deltaRotation * arm - arm);
|
||||
arm = _lastPosition - oldPivot;
|
||||
_lastPosition += deltaPosition + (deltaRotation * arm - arm);
|
||||
}
|
||||
|
||||
void VerletPoint::setMass(float mass) {
|
||||
const float MIN_MASS = 1.0e-6f;
|
||||
const float MAX_MASS = 1.0e18f;
|
||||
if (glm::isnan(mass)) {
|
||||
mass = MIN_MASS;
|
||||
}
|
||||
_mass = glm::clamp(glm::abs(mass), MIN_MASS, MAX_MASS);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#define hifi_VerletPoint_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
|
||||
class VerletPoint {
|
||||
public:
|
||||
|
@ -22,12 +24,16 @@ public:
|
|||
void integrateForward();
|
||||
void accumulateDelta(const glm::vec3& delta);
|
||||
void applyAccumulatedDelta();
|
||||
void move(const glm::vec3& deltaPosition, const glm::quat& deltaRotation, const glm::vec3& oldPivot);
|
||||
|
||||
void setMass(float mass);
|
||||
float getMass() const { return _mass; }
|
||||
|
||||
glm::vec3 _position;
|
||||
glm::vec3 _lastPosition;
|
||||
float _mass;
|
||||
|
||||
private:
|
||||
float _mass;
|
||||
glm::vec3 _accumulatedDelta;
|
||||
int _numDeltas;
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ const glm::vec3& VerletSphereShape::getTranslation() const {
|
|||
|
||||
// virtual
|
||||
float VerletSphereShape::computeEffectiveMass(const glm::vec3& penetration, const glm::vec3& contactPoint) {
|
||||
return _point->_mass;
|
||||
return _point->getMass();
|
||||
}
|
||||
|
||||
// virtual
|
||||
|
|
|
@ -1,31 +1,18 @@
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME voxels)
|
||||
|
||||
find_package(Qt5 COMPONENTS Widgets Script)
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Widgets Script)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
include_glm()
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
link_hifi_libraries(shared octree networking)
|
||||
|
||||
# find ZLIB
|
||||
find_package(ZLIB REQUIRED)
|
||||
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
# add it to our list of libraries to link
|
||||
list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}")
|
||||
|
||||
# call macro to link our dependencies and bubble them up via a property on our target
|
||||
link_shared_dependencies()
|
|
@ -28,7 +28,7 @@ public:
|
|||
/// Queues a single voxel edit message. Will potentially send a pending multi-command packet. Determines which voxel-server
|
||||
/// node or nodes the packet should be sent to. Can be called even before voxel servers are known, in which case up to
|
||||
/// MaxPendingMessages will be buffered and processed when voxel servers are known.
|
||||
void queueVoxelEditMessage(PacketType type, unsigned char* codeColorBuffer, ssize_t length) {
|
||||
void queueVoxelEditMessage(PacketType type, unsigned char* codeColorBuffer, size_t length) {
|
||||
queueOctreeEditMessage(type, codeColorBuffer, length);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +1,10 @@
|
|||
set(TARGET_NAME audio-tests)
|
||||
|
||||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
|
||||
setup_hifi_project()
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
#find_package(Qt5Network REQUIRED)
|
||||
#find_package(Qt5Script REQUIRED)
|
||||
#find_package(Qt5Widgets REQUIRED)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
|
||||
include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
auto_mtc(${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
#qt5_use_modules(${TARGET_NAME} Network Script Widgets)
|
||||
|
||||
#include glm
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} ${ROOT_DIR})
|
||||
include_glm()
|
||||
|
||||
# link in the shared libraries
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
link_hifi_libraries(shared audio networking)
|
||||
|
||||
link_shared_dependencies()
|
|
@ -1,33 +1,8 @@
|
|||
set(TARGET_NAME jitter-tests)
|
||||
|
||||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
#find_package(Qt5Network REQUIRED)
|
||||
#find_package(Qt5Script REQUIRED)
|
||||
#find_package(Qt5Widgets REQUIRED)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
|
||||
#include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
#auto_mtc(${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
#qt5_use_modules(${TARGET_NAME} Network Script Widgets)
|
||||
|
||||
#include glm - because it's a dependency of shared utils...
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} ${ROOT_DIR})
|
||||
setup_hifi_project()
|
||||
|
||||
# link in the shared libraries
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
link_hifi_libraries(shared networking)
|
||||
|
||||
link_shared_dependencies()
|
|
@ -1,32 +1,12 @@
|
|||
set(TARGET_NAME metavoxel-tests)
|
||||
|
||||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
||||
auto_mtc()
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
include_glm()
|
||||
|
||||
find_package(Qt5 COMPONENTS Network Script Widgets)
|
||||
|
||||
include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
auto_mtc(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
setup_hifi_project(${TARGET_NAME} TRUE "${AUTOMTC_SRC}")
|
||||
|
||||
#include glm
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
setup_hifi_project(Network Script Widgets)
|
||||
|
||||
# link in the shared libraries
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script)
|
||||
link_hifi_libraries(metavoxels networking shared)
|
||||
|
||||
link_shared_dependencies()
|
|
@ -1,33 +1,8 @@
|
|||
set(TARGET_NAME networking-tests)
|
||||
|
||||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
#find_package(Qt5Network REQUIRED)
|
||||
#find_package(Qt5Script REQUIRED)
|
||||
#find_package(Qt5Widgets REQUIRED)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
|
||||
include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
auto_mtc(${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
#qt5_use_modules(${TARGET_NAME} Network Script Widgets)
|
||||
|
||||
#include glm
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} ${ROOT_DIR})
|
||||
setup_hifi_project()
|
||||
|
||||
# link in the shared libraries
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
link_hifi_libraries(shared networking)
|
||||
|
||||
link_shared_dependencies()
|
|
@ -9,11 +9,12 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "SequenceNumberStatsTests.h"
|
||||
|
||||
#include "SharedUtil.h"
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "SequenceNumberStatsTests.h"
|
||||
|
||||
void SequenceNumberStatsTests::runAllTests() {
|
||||
rolloverTest();
|
||||
|
|
|
@ -1,43 +1,10 @@
|
|||
set(TARGET_NAME octree-tests)
|
||||
|
||||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
|
||||
setup_hifi_project(Script Network)
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5Script REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
|
||||
include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
auto_mtc(${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Network Script Widgets)
|
||||
|
||||
#include glm
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} ${ROOT_DIR})
|
||||
include_glm()
|
||||
|
||||
# link in the shared libraries
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(models ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(octree ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(animation ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(fbx ${TARGET_NAME} ${ROOT_DIR})
|
||||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
IF (WIN32)
|
||||
# add a definition for ssize_t so that windows doesn't bail
|
||||
add_definitions(-Dssize_t=long)
|
||||
|
||||
#target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
target_link_libraries(${TARGET_NAME} wsock32.lib)
|
||||
ENDIF(WIN32)
|
||||
|
||||
link_hifi_libraries(animation fbx models networking octree shared)
|
||||
|
||||
link_shared_dependencies()
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue