diff --git a/BUILD.md b/BUILD.md index f2efe05289..a38ed591f6 100644 --- a/BUILD.md +++ b/BUILD.md @@ -77,5 +77,5 @@ In the examples below the variable $NAME would be replaced by the name of the de ####Devices -You can support external input/output devices such as Oculus Rift, Leap Motion, Faceshift, PrioVR, MIDI, Razr Hydra and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device. +You can support external input/output devices such as Oculus Rift, Leap Motion, Faceshift, MIDI, Razr Hydra and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device. diff --git a/BUILD_WIN.md b/BUILD_WIN.md index df50fd82c8..39252ec4f2 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -14,18 +14,14 @@ Or you can start a regular command prompt and then run: If using Visual Studio 2013 and building as a Visual Studio 2013 project you need the Windows 8 SDK which you should already have as part of installing Visual Studio 2013. You should be able to see it at `C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86`. -####nmake & msbuild +####nmake -Some of the external projects may require nmake and msbuild to compile and install. If they are not installed at the locations listed below, please ensure that both are in your PATH so CMake can find them when required. +Some of the external projects may require nmake to compile and install. If it is not installed at the location listed below, please ensure that it is in your PATH so CMake can find it when required. We expect nmake.exe to be located at the following path. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin -We expect msbuild.exe to be located at the following path. - - C:\Program Files (x86)\MSBUILD\12.0\Bin - ###Qt You can use the online installer or the offline installer. If you use the offline installer, be sure to select the "OpenGL" version. diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index c545262967..d56db7aace 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -44,7 +44,7 @@ Agent::Agent(const QByteArray& packet) : // be the parent of the script engine so it gets moved when we do _scriptEngine.setParent(this); - _scriptEngine.getEntityScriptingInterface()->setPacketSender(&_entityEditSender); + DependencyManager::get()->setPacketSender(&_entityEditSender); DependencyManager::set(); DependencyManager::set(); @@ -68,8 +68,8 @@ void Agent::readPendingDatagrams() { // PacketType_JURISDICTION, first byte is the node type... switch (receivedPacket[headerBytes]) { case NodeType::EntityServer: - _scriptEngine.getEntityScriptingInterface()->getJurisdictionListener()-> - queueReceivedPacket(matchedNode, receivedPacket); + DependencyManager::get()->getJurisdictionListener()-> + queueReceivedPacket(matchedNode, receivedPacket); break; } } @@ -211,10 +211,12 @@ void Agent::run() { _scriptEngine.registerGlobalObject("SoundCache", DependencyManager::get().data()); + auto entityScriptingInterface = DependencyManager::get(); + _scriptEngine.registerGlobalObject("EntityViewer", &_entityViewer); - _entityViewer.setJurisdictionListener(_scriptEngine.getEntityScriptingInterface()->getJurisdictionListener()); + _entityViewer.setJurisdictionListener(entityScriptingInterface->getJurisdictionListener()); _entityViewer.init(); - _scriptEngine.getEntityScriptingInterface()->setEntityTree(_entityViewer.getTree()); + entityScriptingInterface->setEntityTree(_entityViewer.getTree()); _scriptEngine.setScriptContents(scriptContents); _scriptEngine.run(); diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index 86680d2f03..fba96c4967 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri DependencyManager::registerInheritance(); auto addressManager = DependencyManager::set(); auto nodeList = DependencyManager::set(NodeType::Unassigned); + auto entityScriptingInterface = DependencyManager::set(); // make up a uuid for this child so the parent can tell us apart. This id will be changed // when the domain server hands over an assignment. diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 7517669d0b..a315fce1a9 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -47,7 +47,8 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &AssignmentClientMonitor::readPendingDatagrams); - nodeList->putLocalPortIntoSharedMemory(ASSIGNMENT_CLIENT_MONITOR_LOCAL_PORT_SMEM_KEY, this); + nodeList->putLocalPortIntoSharedMemory(ASSIGNMENT_CLIENT_MONITOR_LOCAL_PORT_SMEM_KEY, this, + nodeList->getNodeSocket().localPort()); // use QProcess to fork off a process for each of the child assignment clients for (unsigned int i = 0; i < _numAssignmentClientForks; i++) { diff --git a/cmake/externals/bullet/CMakeLists.txt b/cmake/externals/bullet/CMakeLists.txt index d08ceb11b9..e3610997d1 100644 --- a/cmake/externals/bullet/CMakeLists.txt +++ b/cmake/externals/bullet/CMakeLists.txt @@ -14,21 +14,12 @@ endif () include(ExternalProject) -if (WIN32) - if (UPPER_CMAKE_BUILD_TYPE MATCHES DEBUG) - set(MSBUILD_CONFIGURATION Debug) - else () - set(MSBUILD_CONFIGURATION Release) - endif () - - find_program(MSBUILD_COMMAND msbuild PATHS "C:/Program Files (x86)/MSBUILD/12.0/Bin") - +if (WIN32) ExternalProject_Add( ${EXTERNAL_NAME} URL https://bullet.googlecode.com/files/bullet-2.82-r2704.zip URL_MD5 f5e8914fc9064ad32e0d62d19d33d977 - CMAKE_ARGS ${PLATFORM_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_EXTRAS=0 -DINSTALL_LIBS=1 -DBUILD_DEMOS=0 -DUSE_GLUT=0 - BUILD_COMMAND ${MSBUILD_COMMAND} ALL_BUILD.vcxproj /p:Configuration=${MSBUILD_CONFIGURATION} + CMAKE_ARGS ${PLATFORM_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_EXTRAS=0 -DINSTALL_LIBS=1 -DBUILD_DEMOS=0 -DUSE_GLUT=0 LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 @@ -66,28 +57,22 @@ elseif (WIN32) endif () if (DEFINED BULLET_LIB_EXT) - if (NOT WIN32 OR UPPER_CMAKE_BUILD_TYPE MATCHES RELEASE) - set(_PRESENT_LIB_TYPE RELEASE) - set(_MISSING_LIB_TYPE DEBUG) - else () - set(_PRESENT_LIB_TYPE DEBUG) - set(_MISSING_LIB_TYPE RELEASE) - set(_LIB_NAME_SUFFIX _Debug) - endif () + set(_BULLET_LIB_PAIRS "DYNAMICS_LIBRARY\;BulletDynamics" "COLLISION_LIBRARY\;BulletCollision" "MATH_LIBRARY\;LinearMath" "SOFTBODY_LIBRARY\;BulletSoftBody") - set(${EXTERNAL_NAME_UPPER}_DYNAMICS_LIBRARY_${_PRESENT_LIB_TYPE} ${BULLET_LIB_DIR}/${LIB_PREFIX}BulletDynamics${_LIB_NAME_SUFFIX}.${BULLET_LIB_EXT} CACHE FILEPATH "Bullet dynamics ${_PRESENT_LIB_TYPE} library location") - set(${EXTERNAL_NAME_UPPER}_DYNAMICS_LIBRARY_${_MISSING_LIB_TYPE} "" CACHE FILEPATH "Bullet dynamics ${_MISSING_LIB_TYPE} library location") - - set(${EXTERNAL_NAME_UPPER}_COLLISION_LIBRARY_${_PRESENT_LIB_TYPE} ${BULLET_LIB_DIR}/${LIB_PREFIX}BulletCollision${_LIB_NAME_SUFFIX}.${BULLET_LIB_EXT} CACHE FILEPATH "Bullet collision ${_PRESENT_LIB_TYPE} library location") - set(${EXTERNAL_NAME_UPPER}_COLLISION_LIBRARY_${_MISSING_LIB_TYPE} "" CACHE FILEPATH "Bullet collision ${_MISSING_LIB_TYPE} library location") - - set(${EXTERNAL_NAME_UPPER}_MATH_LIBRARY_${_PRESENT_LIB_TYPE} ${BULLET_LIB_DIR}/${LIB_PREFIX}LinearMath${_LIB_NAME_SUFFIX}.${BULLET_LIB_EXT} CACHE FILEPATH "Bullet math ${_PRESENT_LIB_TYPE} library location") - set(${EXTERNAL_NAME_UPPER}_MATH_LIBRARY_${_MISSING_LIB_TYPE} "" CACHE FILEPATH "Bullet math ${_MISSING_LIB_TYPE} library location") - - set(${EXTERNAL_NAME_UPPER}_SOFTBODY_LIBRARY_${_PRESENT_LIB_TYPE} ${BULLET_LIB_DIR}/${LIB_PREFIX}BulletSoftBody${_LIB_NAME_SUFFIX}.${BULLET_LIB_EXT} CACHE FILEPATH "Bullet softbody ${_PRESENT_LIB_TYPE} library location") - set(${EXTERNAL_NAME_UPPER}_SOFTBODY_LIBRARY_${_MISSING_LIB_TYPE} "" CACHE FILEPATH "Bullet softbody ${_MISSING_LIB_TYPE} library location") + foreach(_LIB_PAIR ${_BULLET_LIB_PAIRS}) + list(GET _LIB_PAIR 0 _LIB_VAR_NAME) + list(GET _LIB_PAIR 1 _LIB_NAME) + + set(${EXTERNAL_NAME_UPPER}_${_LIB_VAR_NAME}_RELEASE ${BULLET_LIB_DIR}/${LIB_PREFIX}${_LIB_NAME}.${BULLET_LIB_EXT} CACHE FILEPATH "${_LIB_NAME} release library location") + + if (WIN32) + set(${EXTERNAL_NAME_UPPER}_${_LIB_VAR_NAME}_DEBUG ${BULLET_LIB_DIR}/${LIB_PREFIX}${_LIB_NAME}_Debug.${BULLET_LIB_EXT} CACHE FILEPATH "${_LIB_NAME} debug library location") + else () + set(${EXTERNAL_NAME_UPPER}_${_LIB_VAR_NAME}_DEBUG "" CACHE FILEPATH "${_LIB_NAME} debug library location") + endif () + endforeach() endif () -if (DEFINED ${EXTERNAL_NAME_UPPER}_DYNAMICS_LIBRARY_${_PRESENT_LIB_TYPE}) +if (DEFINED ${EXTERNAL_NAME_UPPER}_DYNAMICS_LIBRARY_RELEASE) set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIR ${INSTALL_DIR}/include/bullet CACHE PATH "Path to bullet include directory") endif () \ No newline at end of file diff --git a/cmake/externals/qxmpp/CMakeLists.txt b/cmake/externals/qxmpp/CMakeLists.txt index c8bbdba6ba..9165da115f 100644 --- a/cmake/externals/qxmpp/CMakeLists.txt +++ b/cmake/externals/qxmpp/CMakeLists.txt @@ -1,7 +1,7 @@ set(EXTERNAL_NAME qxmpp) # we need to find qmake inside QT_DIR -find_program(QMAKE_COMMAND NAME qmake PATHS ${QT_DIR}/bin NO_DEFAULT_PATH) +find_program(QMAKE_COMMAND NAME qmake PATHS ${QT_DIR}/bin $ENV{QTTOOLDIR} NO_DEFAULT_PATH) if (NOT QMAKE_COMMAND) message(FATAL_ERROR "Could not find qmake. Qxmpp cannot be compiled without qmake.") diff --git a/cmake/modules/FindPrioVR.cmake b/cmake/modules/FindPrioVR.cmake deleted file mode 100644 index 691ba85689..0000000000 --- a/cmake/modules/FindPrioVR.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# Try to find the PrioVR library -# -# You must provide a PRIOVR_ROOT_DIR which contains lib and include directories -# -# Once done this will define -# -# PRIOVR_FOUND - system found PrioVR -# PRIOVR_INCLUDE_DIRS - the PrioVR include directory -# PRIOVR_LIBRARIES - Link this to use PrioVR -# -# Created on 5/12/2014 by Andrzej Kapolka -# Copyright (c) 2014 High Fidelity -# - -find_path(PRIOVR_INCLUDE_DIRS yei_skeletal_api.h ${PRIOVR_ROOT_DIR}/include) - -if (WIN32) - find_library(PRIOVR_LIBRARIES Skeletal_API.lib ${PRIOVR_ROOT_DIR}/lib) -endif (WIN32) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(PrioVR DEFAULT_MSG PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) - -mark_as_advanced(PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) \ No newline at end of file diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 9aec456587..fed3d721b3 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -247,7 +247,14 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) { auto nodeList = DependencyManager::set(domainServerPort, domainServerDTLSPort); // no matter the local port, save it to shared mem so that local assignment clients can ask what it is - nodeList->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, this); + nodeList->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, this, nodeList->getNodeSocket().localPort()); + + // store our local http ports in shared memory + quint16 localHttpPort = DOMAIN_SERVER_HTTP_PORT; + nodeList->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_HTTP_PORT_SMEM_KEY, this, localHttpPort); + quint16 localHttpsPort = DOMAIN_SERVER_HTTPS_PORT; + nodeList->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_HTTPS_PORT_SMEM_KEY, this, localHttpsPort); + // set our LimitedNodeList UUID to match the UUID from our config // nodes will currently use this to add resources to data-web that relate to our domain @@ -944,7 +951,7 @@ void DomainServer::readAvailableDatagrams() { if (requestAssignment.getType() != Assignment::AgentType || noisyMessageTimer.elapsed() > NOISY_MESSAGE_INTERVAL_MSECS) { - static QString repeatedMessage = LogHandler::getInstance().addRepeatedMessageRegex + static QString repeatedMessage = LogHandler::getInstance().addOnlyOnceMessageRegex ("Received a request for assignment type [^ ]+ from [^ ]+"); qDebug() << "Received a request for assignment type" << requestAssignment.getType() << "from" << senderSockAddr; @@ -977,7 +984,7 @@ void DomainServer::readAvailableDatagrams() { } else { if (requestAssignment.getType() != Assignment::AgentType || noisyMessageTimer.elapsed() > NOISY_MESSAGE_INTERVAL_MSECS) { - static QString repeatedMessage = LogHandler::getInstance().addRepeatedMessageRegex + static QString repeatedMessage = LogHandler::getInstance().addOnlyOnceMessageRegex ("Unable to fulfill assignment request of type [^ ]+ from [^ ]+"); qDebug() << "Unable to fulfill assignment request of type" << requestAssignment.getType() << "from" << senderSockAddr; diff --git a/examples/editEntities.js b/examples/editEntities.js index ef6472e4b8..a0f3cdc167 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -81,6 +81,8 @@ var SETTING_INSPECT_TOOL_ENABLED = "inspectToolEnabled"; var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect"; var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus"; +var INSUFFICIENT_PERMISSIONS_ERROR_MSG = "You do not have the necessary permissions to edit on this domain." + var modelURLs = [ HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Alder.fbx", HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Bush1.fbx", @@ -177,25 +179,29 @@ var toolBar = (function () { that.setActive = function(active) { if (active != isActive) { - isActive = active; - if (!isActive) { - entityListTool.setVisible(false); - gridTool.setVisible(false); - grid.setEnabled(false); - propertiesTool.setVisible(false); - selectionManager.clearSelections(); - cameraManager.disable(); + if (active && !Entities.canAdjustLocks()) { + Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG); } else { - hasShownPropertiesTool = false; - cameraManager.enable(); - entityListTool.setVisible(true); - gridTool.setVisible(true); - grid.setEnabled(true); - propertiesTool.setVisible(true); - Window.setFocus(); + isActive = active; + if (!isActive) { + entityListTool.setVisible(false); + gridTool.setVisible(false); + grid.setEnabled(false); + propertiesTool.setVisible(false); + selectionManager.clearSelections(); + cameraManager.disable(); + } else { + hasShownPropertiesTool = false; + cameraManager.enable(); + entityListTool.setVisible(true); + gridTool.setVisible(true); + grid.setEnabled(true); + propertiesTool.setVisible(true); + Window.setFocus(); + } } } - toolBar.selectTool(activeButton, active); + toolBar.selectTool(activeButton, isActive); }; var RESIZE_INTERVAL = 50; @@ -400,6 +406,12 @@ var toolBar = (function () { that.setActive(false); }); + Entities.canAdjustLocksChanged.connect(function(canAdjustLocks) { + if (isActive && !canAdjustLocks) { + that.setActive(false); + } + }); + that.cleanup = function () { toolBar.cleanup(); }; diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index f54c2c9ce3..fd1a4e3821 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -128,11 +128,11 @@ var elLightSections = document.querySelectorAll(".light-section"); var elLightSpotLight = document.getElementById("property-light-spot-light"); - var elLightDiffuseRed = document.getElementById("property-light-diffuse-red"); - var elLightDiffuseGreen = document.getElementById("property-light-diffuse-green"); - var elLightDiffuseBlue = document.getElementById("property-light-diffuse-blue"); + var elLightColorRed = document.getElementById("property-light-color-red"); + var elLightColorGreen = document.getElementById("property-light-color-green"); + var elLightColorBlue = document.getElementById("property-light-color-blue"); - var elLightConstantAttenuation = document.getElementById("property-light-constant-attenuation"); + var elLightIntensity = document.getElementById("property-light-intensity"); var elLightExponent = document.getElementById("property-light-exponent"); var elLightCutoff = document.getElementById("property-light-cutoff"); @@ -305,11 +305,11 @@ elLightSections[i].style.display = 'block'; } - elLightDiffuseRed.value = properties.diffuseColor.red; - elLightDiffuseGreen.value = properties.diffuseColor.green; - elLightDiffuseBlue.value = properties.diffuseColor.blue; + elLightColorRed.value = properties.color.red; + elLightColorGreen.value = properties.color.green; + elLightColorBlue.value = properties.color.blue; - elLightConstantAttenuation.value = properties.constantAttenuation; + elLightIntensity.value = properties.intensity; elLightExponent.value = properties.exponent; elLightCutoff.value = properties.cutoff; } @@ -380,13 +380,13 @@ elLightSpotLight.addEventListener('change', createEmitCheckedPropertyUpdateFunction('isSpotlight')); - var lightDiffuseChangeFunction = createEmitColorPropertyUpdateFunction( - 'diffuseColor', elLightDiffuseRed, elLightDiffuseGreen, elLightDiffuseBlue); - elLightDiffuseRed.addEventListener('change', lightDiffuseChangeFunction); - elLightDiffuseGreen.addEventListener('change', lightDiffuseChangeFunction); - elLightDiffuseBlue.addEventListener('change', lightDiffuseChangeFunction); + var lightColorChangeFunction = createEmitColorPropertyUpdateFunction( + 'color', elLightColorRed, elLightColorGreen, elLightColorBlue); + elLightColorRed.addEventListener('change', lightColorChangeFunction); + elLightColorGreen.addEventListener('change', lightColorChangeFunction); + elLightColorBlue.addEventListener('change', lightColorChangeFunction); - elLightConstantAttenuation.addEventListener('change', createEmitNumberPropertyUpdateFunction('constantAttenuation')); + elLightIntensity.addEventListener('change', createEmitNumberPropertyUpdateFunction('intensity')); elLightExponent.addEventListener('change', createEmitNumberPropertyUpdateFunction('exponent')); elLightCutoff.addEventListener('change', createEmitNumberPropertyUpdateFunction('cutoff')); @@ -439,6 +439,13 @@ percentage: parseInt(elRescaleDimensionsPct.value), })); }); + + window.onblur = function() { + // Fake a change event + var ev = document.createEvent("HTMLEvents"); + ev.initEvent("change", true, true); + document.activeElement.dispatchEvent(ev); + } } @@ -708,15 +715,15 @@
Color
-
R
-
G
-
B
+
R
+
G
+
B
Intensity
- +
diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index ee41648758..9bc4b393c5 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -2,7 +2,7 @@ set(TARGET_NAME interface) project(${TARGET_NAME}) # set a default root dir for each of our optional externals if it was not passed -set(OPTIONAL_EXTERNALS "Faceshift" "LibOVR" "PrioVR" "Sixense" "LeapMotion" "RtMidi" "Qxmpp" "SDL2" "RSSDK") +set(OPTIONAL_EXTERNALS "Faceshift" "LibOVR" "Sixense" "LeapMotion" "RtMidi" "Qxmpp" "SDL2" "RSSDK") foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE) if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR) diff --git a/interface/external/priovr/readme.txt b/interface/external/priovr/readme.txt deleted file mode 100644 index 202a90cf12..0000000000 --- a/interface/external/priovr/readme.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Instructions for adding the PrioVR driver to Interface -Andrzej Kapolka, May 12, 2014 - -1. Download and install the YEI drivers from https://www.yeitechnology.com/yei-3-space-sensor-software-suite. If using - Window 8+, follow the workaround instructions at http://forum.yeitechnology.com/viewtopic.php?f=3&t=24. - -2. Get the PrioVR skeleton API, open ts_c_api2_priovr2/visual_studio/ThreeSpace_API_2/ThreeSpace_API_2.sln - in Visual Studio, and build it. - -3. Copy ts_c_api2_priovr2/visual_studio/ThreeSpace_API_2/Skeletal_API/yei_skeletal_api.h to interface/external/priovr/include, - ts_c_api2_priovr2/visual_studio/ThreeSpace_API_2/Debug/Skeletal_API.lib to interface/external/priovr/lib, and - ts_c_api2_priovr2/visual_studio/ThreeSpace_API_2/Debug/*.dll to your path. - -4. Delete your build directory, run cmake and build, and you should be all set. - diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fe41621dc1..49bd680481 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -241,6 +241,7 @@ bool setupEssentials(int& argc, char** argv) { auto dialogsManager = DependencyManager::set(); auto bandwidthRecorder = DependencyManager::set(); auto resouceCacheSharedItems = DependencyManager::set(); + auto entityScriptingInterface = DependencyManager::set(); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) auto speechRecognizer = DependencyManager::set(); #endif @@ -1766,8 +1767,10 @@ void Application::init() { tree->setSimulation(&_physicsEngine); _physicsEngine.init(&_entityEditSender); + auto entityScriptingInterface = DependencyManager::get(); + connect(&_physicsEngine, &EntitySimulation::entityCollisionWithEntity, - ScriptEngine::getEntityScriptingInterface(), &EntityScriptingInterface::entityCollisionWithEntity); + entityScriptingInterface.data(), &EntityScriptingInterface::entityCollisionWithEntity); // connect the _entityCollisionSystem to our EntityTreeRenderer since that's what handles running entity scripts connect(&_physicsEngine, &EntitySimulation::entityCollisionWithEntity, @@ -1775,7 +1778,7 @@ void Application::init() { // connect the _entities (EntityTreeRenderer) to our script engine's EntityScriptingInterface for firing // of events related clicking, hovering over, and entering entities - _entities.connectSignalsToSlots(ScriptEngine::getEntityScriptingInterface()); + _entities.connectSignalsToSlots(entityScriptingInterface.data()); _entityClipboardRenderer.init(); _entityClipboardRenderer.setViewFrustum(getViewFrustum()); @@ -2045,7 +2048,6 @@ void Application::update(float deltaTime) { } SixenseManager::getInstance().update(deltaTime); JoystickScriptingInterface::getInstance().update(); - _prioVR.update(deltaTime); } // Dispatch input events @@ -3107,7 +3109,6 @@ void Application::resetSensors() { OculusManager::reset(); - _prioVR.reset(); //_leapmotion.reset(); QScreen* currentScreen = _window->windowHandle()->screen(); @@ -3441,8 +3442,9 @@ void joystickFromScriptValue(const QScriptValue &object, Joystick* &out) { void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine) { // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so // we can use the same ones from the application. - scriptEngine->getEntityScriptingInterface()->setPacketSender(&_entityEditSender); - scriptEngine->getEntityScriptingInterface()->setEntityTree(_entities.getTree()); + auto entityScriptingInterface = DependencyManager::get(); + entityScriptingInterface->setPacketSender(&_entityEditSender); + entityScriptingInterface->setEntityTree(_entities.getTree()); // AvatarManager has some custom types AvatarManager::registerMetaTypes(scriptEngine); diff --git a/interface/src/Application.h b/interface/src/Application.h index 4a8e712d30..8ea55059fe 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -51,7 +51,6 @@ #include "Stars.h" #include "avatar/Avatar.h" #include "avatar/MyAvatar.h" -#include "devices/PrioVR.h" #include "devices/SixenseManager.h" #include "scripting/ControllerScriptingInterface.h" #include "ui/BandwidthDialog.h" @@ -182,7 +181,6 @@ public: MetavoxelSystem* getMetavoxels() { return &_metavoxels; } EntityTreeRenderer* getEntities() { return &_entities; } Environment* getEnvironment() { return &_environment; } - PrioVR* getPrioVR() { return &_prioVR; } QUndoStack* getUndoStack() { return &_undoStack; } MainWindow* getWindow() { return _window; } OctreeQuery& getOctreeQuery() { return _octreeQuery; } @@ -490,8 +488,6 @@ private: MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be) - PrioVR _prioVR; - Camera _myCamera; // My view onto the world Camera _mirrorCamera; // Cammera for mirror view QRect _mirrorViewRect; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 467f63ccef..16f8192e89 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -77,7 +77,8 @@ Avatar::Avatar() : _moving(false), _collisionGroups(0), _initialized(false), - _shouldRenderBillboard(true) + _shouldRenderBillboard(true), + _voiceSphereID(GeometryCache::UNKNOWN_ID) { // we may have been created in the network thread, but we live in the main thread moveToThread(Application::getInstance()->thread()); @@ -438,8 +439,13 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool glPushMatrix(); glTranslatef(_position.x, _position.y, _position.z); glScalef(height, height, height); + + if (_voiceSphereID == GeometryCache::UNKNOWN_ID) { + _voiceSphereID = DependencyManager::get()->allocateID(); + } DependencyManager::get()->renderSphere(sphereRadius, 15, 15, - glm::vec4(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.0f - angle / MAX_SPHERE_ANGLE)); + glm::vec4(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.0f - angle / MAX_SPHERE_ANGLE), true, + _voiceSphereID); glPopMatrix(); } diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 72b7ecf93a..d6977afce6 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -243,6 +243,8 @@ private: float getBillboardSize() const; static int _jointConesID; + + int _voiceSphereID; }; #endif // hifi_Avatar_h diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 8c4ea73775..29b9e22c16 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -294,12 +294,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { return; } - if (Application::getInstance()->getPrioVR()->hasHeadRotation()) { - estimatedRotation = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getHeadRotation())); - estimatedRotation.x *= -1.0f; - estimatedRotation.z *= -1.0f; - - } else if (OculusManager::isConnected()) { + if (OculusManager::isConnected()) { estimatedPosition = OculusManager::getRelativePosition(); estimatedPosition.x *= -1.0f; _trackedHeadPosition = estimatedPosition; @@ -349,13 +344,6 @@ void MyAvatar::updateFromTrackers(float deltaTime) { } head->setDeltaRoll(estimatedRotation.z); - // the priovr can give us exact lean - if (Application::getInstance()->getPrioVR()->isActive()) { - glm::vec3 eulers = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getTorsoRotation())); - head->setLeanSideways(eulers.z); - head->setLeanForward(eulers.x); - return; - } // Update torso lean distance based on accelerometer data const float TORSO_LENGTH = 0.5f; glm::vec3 relativePosition = estimatedPosition - glm::vec3(0.0f, -TORSO_LENGTH, 0.0f); diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 6e207f9703..fa9846fd7d 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -106,21 +106,6 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { } const FBXGeometry& geometry = _geometry->getFBXGeometry(); - PrioVR* prioVR = Application::getInstance()->getPrioVR(); - if (prioVR->isActive()) { - for (int i = 0; i < prioVR->getJointRotations().size(); i++) { - int humanIKJointIndex = prioVR->getHumanIKJointIndices().at(i); - if (humanIKJointIndex == -1) { - continue; - } - int jointIndex = geometry.humanIKJointIndices.at(humanIKJointIndex); - if (jointIndex != -1) { - JointState& state = _jointStates[jointIndex]; - state.setRotationInBindFrame(prioVR->getJointRotations().at(i), PALM_PRIORITY); - } - } - return; - } // find the left and rightmost active palms int leftPalmIndex, rightPalmIndex; @@ -294,7 +279,7 @@ void SkeletonModel::updateJointState(int index) { } void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, JointState& state) { - if (!_owningAvatar->isMyAvatar() || Application::getInstance()->getPrioVR()->isActive()) { + if (!_owningAvatar->isMyAvatar()) { return; } // get the rotation axes in joint space and use them to adjust the rotation diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp deleted file mode 100644 index 428c223eb7..0000000000 --- a/interface/src/devices/PrioVR.cpp +++ /dev/null @@ -1,224 +0,0 @@ -// -// PrioVR.cpp -// interface/src/devices -// -// Created by Andrzej Kapolka on 5/12/14. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include -#include - -#include -#include -#include -#include - -#include "Application.h" -#include "PrioVR.h" -#include "scripting/JoystickScriptingInterface.h" - -#ifdef HAVE_PRIOVR -const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A, - 0x0000000C, 0x0000000D, 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 }; -const unsigned char AXIS_LIST[] = { 9, 43, 37, 37, 37, 13, 13, 13, 52, 52, 28, 28 }; -const int LIST_LENGTH = sizeof(SERIAL_LIST) / sizeof(SERIAL_LIST[0]); - -const char* JOINT_NAMES[] = { "Neck", "Spine", "LeftArm", "LeftForeArm", "LeftHand", "RightArm", - "RightForeArm", "RightHand", "LeftUpLeg", "LeftLeg", "RightUpLeg", "RightLeg" }; - -static int indexOfHumanIKJoint(const char* jointName) { - for (int i = 0;; i++) { - QByteArray humanIKJoint = HUMANIK_JOINTS[i]; - if (humanIKJoint.isEmpty()) { - return -1; - } - if (humanIKJoint == jointName) { - return i; - } - } -} - -static void setPalm(float deltaTime, int index) { - MyAvatar* avatar = DependencyManager::get()->getMyAvatar(); - Hand* hand = avatar->getHand(); - PalmData* palm; - bool foundHand = false; - for (size_t j = 0; j < hand->getNumPalms(); j++) { - if (hand->getPalms()[j].getSixenseID() == index) { - palm = &(hand->getPalms()[j]); - foundHand = true; - } - } - if (!foundHand) { - PalmData newPalm(hand); - hand->getPalms().push_back(newPalm); - palm = &(hand->getPalms()[hand->getNumPalms() - 1]); - palm->setSixenseID(index); - } - - palm->setActive(true); - - // Read controller buttons and joystick into the hand - const QString PRIO_JOYSTICK_NAME = "PrioVR"; - Joystick* prioJoystick = JoystickScriptingInterface::getInstance().joystickWithName(PRIO_JOYSTICK_NAME); - if (prioJoystick) { - const QVector axes = prioJoystick->getAxes(); - const QVector buttons = prioJoystick->getButtons(); - - if (axes.size() >= 4 && buttons.size() >= 4) { - if (index == LEFT_HAND_INDEX) { - palm->setControllerButtons(buttons[1] ? BUTTON_FWD : 0); - palm->setTrigger(buttons[0] ? 1.0f : 0.0f); - palm->setJoystick(axes[0], -axes[1]); - - } else { - palm->setControllerButtons(buttons[3] ? BUTTON_FWD : 0); - palm->setTrigger(buttons[2] ? 1.0f : 0.0f); - palm->setJoystick(axes[2], -axes[3]); - } - } - } - - // NOTE: this math is done in the worl-frame with unecessary complexity. - // TODO: transfom this to stay in the model-frame. - glm::vec3 position; - glm::quat rotation; - SkeletonModel* skeletonModel = &DependencyManager::get()->getMyAvatar()->getSkeletonModel(); - int jointIndex; - glm::quat inverseRotation = glm::inverse(DependencyManager::get()->getMyAvatar()->getOrientation()); - if (index == LEFT_HAND_INDEX) { - jointIndex = skeletonModel->getLeftHandJointIndex(); - skeletonModel->getJointRotationInWorldFrame(jointIndex, rotation); - rotation = inverseRotation * rotation * glm::quat(glm::vec3(0.0f, PI_OVER_TWO, 0.0f)); - - } else { - jointIndex = skeletonModel->getRightHandJointIndex(); - skeletonModel->getJointRotationInWorldFrame(jointIndex, rotation); - rotation = inverseRotation * rotation * glm::quat(glm::vec3(0.0f, -PI_OVER_TWO, 0.0f)); - } - skeletonModel->getJointPositionInWorldFrame(jointIndex, position); - position = inverseRotation * (position - skeletonModel->getTranslation()); - - palm->setRawRotation(rotation); - - // Compute current velocity from position change - glm::vec3 rawVelocity; - if (deltaTime > 0.0f) { - rawVelocity = (position - palm->getRawPosition()) / deltaTime; - } else { - rawVelocity = glm::vec3(0.0f); - } - palm->setRawVelocity(rawVelocity); - palm->setRawPosition(position); - - // Store the one fingertip in the palm structure so we can track velocity - const float FINGER_LENGTH = 0.3f; // meters - const glm::vec3 FINGER_VECTOR(0.0f, 0.0f, FINGER_LENGTH); - const glm::vec3 newTipPosition = position + rotation * FINGER_VECTOR; - glm::vec3 oldTipPosition = palm->getTipRawPosition(); - if (deltaTime > 0.0f) { - palm->setTipVelocity((newTipPosition - oldTipPosition) / deltaTime); - } else { - palm->setTipVelocity(glm::vec3(0.0f)); - } - palm->setTipPosition(newTipPosition); -} -#endif - -PrioVR::PrioVR() { -#ifdef HAVE_PRIOVR - char jointsDiscovered[LIST_LENGTH]; - _skeletalDevice = yei_setUpPrioVRSensors(0x00000000, const_cast(SERIAL_LIST), - const_cast(AXIS_LIST), jointsDiscovered, LIST_LENGTH, YEI_TIMESTAMP_SYSTEM); - if (!_skeletalDevice) { - return; - } - _jointRotations.resize(LIST_LENGTH); - _lastJointRotations.resize(LIST_LENGTH); - for (int i = 0; i < LIST_LENGTH; i++) { - _humanIKJointIndices.append(jointsDiscovered[i] ? indexOfHumanIKJoint(JOINT_NAMES[i]) : -1); - } -#endif -} - -PrioVR::~PrioVR() { -#ifdef HAVE_PRIOVR - if (_skeletalDevice) { - yei_stopStreaming(_skeletalDevice); - } -#endif -} - -const int HEAD_ROTATION_INDEX = 0; - -bool PrioVR::hasHeadRotation() const { - return _humanIKJointIndices.size() > HEAD_ROTATION_INDEX && _humanIKJointIndices.at(HEAD_ROTATION_INDEX) != -1; -} - -glm::quat PrioVR::getHeadRotation() const { - return _jointRotations.size() > HEAD_ROTATION_INDEX ? _jointRotations.at(HEAD_ROTATION_INDEX) : glm::quat(); -} - -glm::quat PrioVR::getTorsoRotation() const { - const int TORSO_ROTATION_INDEX = 1; - return _jointRotations.size() > TORSO_ROTATION_INDEX ? _jointRotations.at(TORSO_ROTATION_INDEX) : glm::quat(); -} - -void PrioVR::update(float deltaTime) { -#ifdef HAVE_PRIOVR - if (!_skeletalDevice) { - return; - } - PerformanceTimer perfTimer("PrioVR"); - unsigned int timestamp; - yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(), - _jointRotations.size() * sizeof(glm::quat), ×tamp); - - // convert to our expected coordinate system, average with last rotations to smooth - for (int i = 0; i < _jointRotations.size(); i++) { - _jointRotations[i].y *= -1.0f; - _jointRotations[i].z *= -1.0f; - - glm::quat lastRotation = _lastJointRotations.at(i); - _lastJointRotations[i] = _jointRotations.at(i); - _jointRotations[i] = safeMix(lastRotation, _jointRotations.at(i), 0.5f); - } - - // convert the joysticks into palm data - setPalm(deltaTime, LEFT_HAND_INDEX); - setPalm(deltaTime, RIGHT_HAND_INDEX); -#endif -} - -void PrioVR::reset() { -#ifdef HAVE_PRIOVR - if (!_skeletalDevice) { - return; - } - connect(Application::getInstance(), SIGNAL(renderingOverlay()), SLOT(renderCalibrationCountdown())); - _calibrationCountdownStarted = QDateTime::currentDateTime(); -#endif -} - -void PrioVR::renderCalibrationCountdown() { -#ifdef HAVE_PRIOVR - const int COUNTDOWN_SECONDS = 3; - int secondsRemaining = COUNTDOWN_SECONDS - _calibrationCountdownStarted.secsTo(QDateTime::currentDateTime()); - if (secondsRemaining == 0) { - yei_tareSensors(_skeletalDevice); - Application::getInstance()->disconnect(this); - return; - } - static TextRenderer* textRenderer = TextRenderer::getInstance(MONO_FONT_FAMILY, 18, QFont::Bold, - false, TextRenderer::OUTLINE_EFFECT, 2); - QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "..."; - auto glCanvas = Application::getInstance()->getGLWidget(); - textRenderer->draw((glCanvas->width() - textRenderer->computeExtent(text.constData()).x) / 2, - glCanvas->height() / 2, - text, glm::vec4(1,1,1,1)); -#endif -} diff --git a/interface/src/devices/PrioVR.h b/interface/src/devices/PrioVR.h deleted file mode 100644 index bb563bf807..0000000000 --- a/interface/src/devices/PrioVR.h +++ /dev/null @@ -1,65 +0,0 @@ -// -// PrioVR.h -// interface/src/devices -// -// Created by Andrzej Kapolka on 5/12/14. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_PrioVR_h -#define hifi_PrioVR_h - -#include -#include -#include - -#include - -#ifdef HAVE_PRIOVR -extern "C" { -#include -} -#endif - -/// Handles interaction with the PrioVR skeleton tracking suit. -class PrioVR : public QObject { - Q_OBJECT - -public: - - PrioVR(); - virtual ~PrioVR(); - - bool isActive() const { return !_jointRotations.isEmpty(); } - - bool hasHeadRotation() const; - - glm::quat getHeadRotation() const; - glm::quat getTorsoRotation() const; - - const QVector& getHumanIKJointIndices() const { return _humanIKJointIndices; } - const QVector& getJointRotations() const { return _jointRotations; } - - void update(float deltaTime); - void reset(); - -private slots: - - void renderCalibrationCountdown(); - -private: -#ifdef HAVE_PRIOVR - YEI_Device_Id _skeletalDevice; -#endif - - QVector _humanIKJointIndices; - QVector _jointRotations; - QVector _lastJointRotations; - - QDateTime _calibrationCountdownStarted; -}; - -#endif // hifi_PrioVR_h diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp index 7f630f1c8c..b5a2523158 100644 --- a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp @@ -32,13 +32,13 @@ void RenderableLightEntityItem::render(RenderArgs* args) { float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z); const float MAX_COLOR = 255.0f; - float diffuseR = getDiffuseColor()[RED_INDEX] / MAX_COLOR; - float diffuseG = getDiffuseColor()[GREEN_INDEX] / MAX_COLOR; - float diffuseB = getDiffuseColor()[BLUE_INDEX] / MAX_COLOR; + float colorR = getColor()[RED_INDEX] / MAX_COLOR; + float colorG = getColor()[GREEN_INDEX] / MAX_COLOR; + float colorB = getColor()[BLUE_INDEX] / MAX_COLOR; - glm::vec3 color = glm::vec3(diffuseR, diffuseG, diffuseB); + glm::vec3 color = glm::vec3(colorR, colorG, colorB); - float intensity = getConstantAttenuation(); + float intensity = getIntensity(); float exponent = getExponent(); float cutoff = glm::radians(getCutoff()); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index f3f84876ba..e53a6ede3d 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -49,12 +49,7 @@ EntityItemProperties::EntityItemProperties() : CONSTRUCT_PROPERTY(ignoreForCollisions, ENTITY_ITEM_DEFAULT_IGNORE_FOR_COLLISIONS), CONSTRUCT_PROPERTY(collisionsWillMove, ENTITY_ITEM_DEFAULT_COLLISIONS_WILL_MOVE), CONSTRUCT_PROPERTY(isSpotlight, false), - CONSTRUCT_PROPERTY(diffuseColor, ), - CONSTRUCT_PROPERTY(ambientColor, ), - CONSTRUCT_PROPERTY(specularColor, ), - CONSTRUCT_PROPERTY(constantAttenuation, 1.0f), - CONSTRUCT_PROPERTY(linearAttenuation, 0.0f), - CONSTRUCT_PROPERTY(quadraticAttenuation, 0.0f), + CONSTRUCT_PROPERTY(intensity, 1.0f), CONSTRUCT_PROPERTY(exponent, 0.0f), CONSTRUCT_PROPERTY(cutoff, PI), CONSTRUCT_PROPERTY(locked, ENTITY_ITEM_DEFAULT_LOCKED), @@ -222,12 +217,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_IGNORE_FOR_COLLISIONS, ignoreForCollisions); CHECK_PROPERTY_CHANGE(PROP_COLLISIONS_WILL_MOVE, collisionsWillMove); CHECK_PROPERTY_CHANGE(PROP_IS_SPOTLIGHT, isSpotlight); - CHECK_PROPERTY_CHANGE(PROP_DIFFUSE_COLOR, diffuseColor); - CHECK_PROPERTY_CHANGE(PROP_AMBIENT_COLOR, ambientColor); - CHECK_PROPERTY_CHANGE(PROP_SPECULAR_COLOR, specularColor); - CHECK_PROPERTY_CHANGE(PROP_CONSTANT_ATTENUATION, constantAttenuation); - CHECK_PROPERTY_CHANGE(PROP_LINEAR_ATTENUATION, linearAttenuation); - CHECK_PROPERTY_CHANGE(PROP_QUADRATIC_ATTENUATION, quadraticAttenuation); + CHECK_PROPERTY_CHANGE(PROP_INTENSITY, intensity); CHECK_PROPERTY_CHANGE(PROP_EXPONENT, exponent); CHECK_PROPERTY_CHANGE(PROP_CUTOFF, cutoff); CHECK_PROPERTY_CHANGE(PROP_LOCKED, locked); @@ -281,12 +271,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons COPY_PROPERTY_TO_QSCRIPTVALUE(ignoreForCollisions); COPY_PROPERTY_TO_QSCRIPTVALUE(collisionsWillMove); COPY_PROPERTY_TO_QSCRIPTVALUE(isSpotlight); - COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR_GETTER(diffuseColor, getDiffuseColor()); - COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR_GETTER(ambientColor, getAmbientColor()); - COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR_GETTER(specularColor, getSpecularColor()); - COPY_PROPERTY_TO_QSCRIPTVALUE(constantAttenuation); - COPY_PROPERTY_TO_QSCRIPTVALUE(linearAttenuation); - COPY_PROPERTY_TO_QSCRIPTVALUE(quadraticAttenuation); + COPY_PROPERTY_TO_QSCRIPTVALUE(intensity); COPY_PROPERTY_TO_QSCRIPTVALUE(exponent); COPY_PROPERTY_TO_QSCRIPTVALUE(cutoff); COPY_PROPERTY_TO_QSCRIPTVALUE(locked); @@ -359,12 +344,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) { COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(ignoreForCollisions, setIgnoreForCollisions); COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(collisionsWillMove, setCollisionsWillMove); COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(isSpotlight, setIsSpotlight); - COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(diffuseColor, setDiffuseColor); - COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(ambientColor, setAmbientColor); - COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(specularColor, setSpecularColor); - COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(constantAttenuation, setConstantAttenuation); - COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(linearAttenuation, setLinearAttenuation); - COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(quadraticAttenuation, setQuadraticAttenuation); + COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(intensity, setIntensity); COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(exponent, setExponent); COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(cutoff, setCutoff); COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(locked, setLocked); @@ -543,12 +523,8 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem if (properties.getType() == EntityTypes::Light) { APPEND_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, appendValue, properties.getIsSpotlight()); - APPEND_ENTITY_PROPERTY(PROP_DIFFUSE_COLOR, appendColor, properties.getDiffuseColor()); - APPEND_ENTITY_PROPERTY(PROP_AMBIENT_COLOR, appendColor, properties.getAmbientColor()); - APPEND_ENTITY_PROPERTY(PROP_SPECULAR_COLOR, appendColor, properties.getSpecularColor()); - APPEND_ENTITY_PROPERTY(PROP_CONSTANT_ATTENUATION, appendValue, properties.getConstantAttenuation()); - APPEND_ENTITY_PROPERTY(PROP_LINEAR_ATTENUATION, appendValue, properties.getLinearAttenuation()); - APPEND_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION, appendValue, properties.getQuadraticAttenuation()); + APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, properties.getColor()); + APPEND_ENTITY_PROPERTY(PROP_INTENSITY, appendValue, properties.getIntensity()); APPEND_ENTITY_PROPERTY(PROP_EXPONENT, appendValue, properties.getExponent()); APPEND_ENTITY_PROPERTY(PROP_CUTOFF, appendValue, properties.getCutoff()); } @@ -765,12 +741,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int if (properties.getType() == EntityTypes::Light) { READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IS_SPOTLIGHT, bool, setIsSpotlight); - READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(PROP_DIFFUSE_COLOR, setDiffuseColor); - READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(PROP_AMBIENT_COLOR, setAmbientColor); - READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(PROP_SPECULAR_COLOR, setSpecularColor); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_CONSTANT_ATTENUATION, float, setConstantAttenuation); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINEAR_ATTENUATION, float, setLinearAttenuation); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_QUADRATIC_ATTENUATION, float, setQuadraticAttenuation); + READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(PROP_COLOR, setColor); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_INTENSITY, float, setIntensity); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_EXPONENT, float, setExponent); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_CUTOFF, float, setCutoff); } @@ -835,12 +807,7 @@ void EntityItemProperties::markAllChanged() { _ignoreForCollisionsChanged = true; _collisionsWillMoveChanged = true; - _diffuseColorChanged = true; - _ambientColorChanged = true; - _specularColorChanged = true; - _constantAttenuationChanged = true; - _linearAttenuationChanged = true; - _quadraticAttenuationChanged = true; + _intensityChanged = true; _exponentChanged = true; _cutoffChanged = true; _lockedChanged = true; diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 2391bcde84..12cc50b6ea 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -66,12 +66,12 @@ enum EntityPropertyList { // property used by Light entity PROP_IS_SPOTLIGHT, - PROP_DIFFUSE_COLOR, - PROP_AMBIENT_COLOR, - PROP_SPECULAR_COLOR, - PROP_CONSTANT_ATTENUATION, - PROP_LINEAR_ATTENUATION, - PROP_QUADRATIC_ATTENUATION, + PROP_DIFFUSE_COLOR_UNUSED, + PROP_AMBIENT_COLOR_UNUSED, + PROP_SPECULAR_COLOR_UNUSED, + PROP_INTENSITY, // Previously PROP_CONSTANT_ATTENUATION + PROP_LINEAR_ATTENUATION_UNUSED, + PROP_QUADRATIC_ATTENUATION_UNUSED, PROP_EXPONENT, PROP_CUTOFF, @@ -165,12 +165,7 @@ public: DEFINE_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, IgnoreForCollisions, ignoreForCollisions, bool); DEFINE_PROPERTY(PROP_COLLISIONS_WILL_MOVE, CollisionsWillMove, collisionsWillMove, bool); DEFINE_PROPERTY(PROP_IS_SPOTLIGHT, IsSpotlight, isSpotlight, bool); - DEFINE_PROPERTY_REF(PROP_DIFFUSE_COLOR, DiffuseColor, diffuseColor, xColor); - DEFINE_PROPERTY_REF(PROP_AMBIENT_COLOR, AmbientColor, ambientColor, xColor); - DEFINE_PROPERTY_REF(PROP_SPECULAR_COLOR, SpecularColor, specularColor, xColor); - DEFINE_PROPERTY(PROP_CONSTANT_ATTENUATION, ConstantAttenuation, constantAttenuation, float); - DEFINE_PROPERTY(PROP_LINEAR_ATTENUATION, LinearAttenuation, linearAttenuation, float); - DEFINE_PROPERTY(PROP_QUADRATIC_ATTENUATION, QuadraticAttenuation, quadraticAttenuation, float); + DEFINE_PROPERTY(PROP_INTENSITY, Intensity, intensity, float); DEFINE_PROPERTY(PROP_EXPONENT, Exponent, exponent, float); DEFINE_PROPERTY(PROP_CUTOFF, Cutoff, cutoff, float); DEFINE_PROPERTY(PROP_LOCKED, Locked, locked, bool); @@ -288,12 +283,7 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) { DEBUG_PROPERTY_IF_CHANGED(debug, properties, IgnoreForCollisions, ignoreForCollisions, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, CollisionsWillMove, collisionsWillMove, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, IsSpotlight, isSpotlight, ""); - DEBUG_PROPERTY_IF_CHANGED(debug, properties, DiffuseColor, diffuseColor, ""); - DEBUG_PROPERTY_IF_CHANGED(debug, properties, AmbientColor, ambientColor, ""); - DEBUG_PROPERTY_IF_CHANGED(debug, properties, SpecularColor, specularColor, ""); - DEBUG_PROPERTY_IF_CHANGED(debug, properties, ConstantAttenuation, constantAttenuation, ""); - DEBUG_PROPERTY_IF_CHANGED(debug, properties, LinearAttenuation, linearAttenuation, ""); - DEBUG_PROPERTY_IF_CHANGED(debug, properties, QuadraticAttenuation, quadraticAttenuation, ""); + DEBUG_PROPERTY_IF_CHANGED(debug, properties, Intensity, intensity, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, Exponent, exponent, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, Cutoff, cutoff, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, Locked, locked, ""); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 0ee2e243f9..10ed98b0fa 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -19,6 +19,8 @@ EntityScriptingInterface::EntityScriptingInterface() : _nextCreatorTokenID(0), _entityTree(NULL) { + auto nodeList = DependencyManager::get(); + connect(nodeList.data(), &NodeList::canAdjustLocksChanged, this, &EntityScriptingInterface::canAdjustLocksChanged); } void EntityScriptingInterface::queueEntityMessage(PacketType packetType, diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index 6b02d6db0a..bac018f2ae 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -48,7 +49,7 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra /// handles scripting of Entity commands from JS passed to assigned clients -class EntityScriptingInterface : public OctreeScriptingInterface { +class EntityScriptingInterface : public OctreeScriptingInterface, public Dependency { Q_OBJECT public: EntityScriptingInterface(); @@ -111,6 +112,8 @@ public slots: signals: void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision); + void canAdjustLocksChanged(bool canAdjustLocks); + void mousePressOnEntity(const EntityItemID& entityItemID, const MouseEvent& event); void mouseMoveOnEntity(const EntityItemID& entityItemID, const MouseEvent& event); void mouseReleaseOnEntity(const EntityItemID& entityItemID, const MouseEvent& event); diff --git a/libraries/entities/src/LightEntityItem.cpp b/libraries/entities/src/LightEntityItem.cpp index 4a8dc2d582..3265891b18 100644 --- a/libraries/entities/src/LightEntityItem.cpp +++ b/libraries/entities/src/LightEntityItem.cpp @@ -14,6 +14,7 @@ #include +#include "EntityItemID.h" #include "EntityTree.h" #include "EntityTreeElement.h" #include "LightEntityItem.h" @@ -32,12 +33,8 @@ LightEntityItem::LightEntityItem(const EntityItemID& entityItemID, const EntityI // default property values const quint8 MAX_COLOR = 255; - _ambientColor[RED_INDEX] = _ambientColor[GREEN_INDEX] = _ambientColor[BLUE_INDEX] = 0; - _diffuseColor[RED_INDEX] = _diffuseColor[GREEN_INDEX] = _diffuseColor[BLUE_INDEX] = MAX_COLOR; - _specularColor[RED_INDEX] = _specularColor[GREEN_INDEX] = _specularColor[BLUE_INDEX] = MAX_COLOR; - _constantAttenuation = 1.0f; - _linearAttenuation = 0.0f; - _quadraticAttenuation = 0.0f; + _color[RED_INDEX] = _color[GREEN_INDEX] = _color[BLUE_INDEX] = 0; + _intensity = 1.0f; _exponent = 0.0f; _cutoff = PI; @@ -54,12 +51,8 @@ EntityItemProperties LightEntityItem::getProperties() const { EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class COPY_ENTITY_PROPERTY_TO_PROPERTIES(isSpotlight, getIsSpotlight); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(diffuseColor, getDiffuseXColor); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(ambientColor, getAmbientXColor); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(specularColor, getSpecularXColor); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(constantAttenuation, getConstantAttenuation); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(linearAttenuation, getLinearAttenuation); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(quadraticAttenuation, getQuadraticAttenuation); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(intensity, getIntensity); COPY_ENTITY_PROPERTY_TO_PROPERTIES(exponent, getExponent); COPY_ENTITY_PROPERTY_TO_PROPERTIES(cutoff, getCutoff); @@ -70,17 +63,11 @@ bool LightEntityItem::setProperties(const EntityItemProperties& properties) { bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class SET_ENTITY_PROPERTY_FROM_PROPERTIES(isSpotlight, setIsSpotlight); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(diffuseColor, setDiffuseColor); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(ambientColor, setAmbientColor); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(specularColor, setSpecularColor); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(isSpotlight, setIsSpotlight); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(constantAttenuation, setConstantAttenuation); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(linearAttenuation, setLinearAttenuation); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(quadraticAttenuation, setQuadraticAttenuation); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(intensity, setIntensity); SET_ENTITY_PROPERTY_FROM_PROPERTIES(exponent, setExponent); SET_ENTITY_PROPERTY_FROM_PROPERTIES(cutoff, setCutoff); - if (somethingChanged) { bool wantDebug = false; if (wantDebug) { @@ -101,15 +88,37 @@ int LightEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesRead = 0; const unsigned char* dataAt = data; - READ_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, bool, _isSpotlight); - READ_ENTITY_PROPERTY_COLOR(PROP_DIFFUSE_COLOR, _diffuseColor); - READ_ENTITY_PROPERTY_COLOR(PROP_AMBIENT_COLOR, _ambientColor); - READ_ENTITY_PROPERTY_COLOR(PROP_SPECULAR_COLOR, _specularColor); - READ_ENTITY_PROPERTY(PROP_CONSTANT_ATTENUATION, float, _constantAttenuation); - READ_ENTITY_PROPERTY(PROP_LINEAR_ATTENUATION, float, _linearAttenuation); - READ_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION, float, _quadraticAttenuation); - READ_ENTITY_PROPERTY(PROP_EXPONENT, float, _exponent); - READ_ENTITY_PROPERTY(PROP_CUTOFF, float, _cutoff); + if (args.bitstreamVersion < VERSION_ENTITIES_LIGHT_HAS_INTENSITY_AND_COLOR_PROPERTIES) { + rgbColor ignoredColor; + float ignoredAttenuation; + + READ_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, bool, _isSpotlight); + + // _diffuseColor has been renamed to _color + READ_ENTITY_PROPERTY_COLOR(PROP_DIFFUSE_COLOR_UNUSED, _color); + + // Ambient and specular color are from an older format and are no longer supported. + // Their values will be ignored. + READ_ENTITY_PROPERTY_COLOR(PROP_AMBIENT_COLOR_UNUSED, ignoredColor); + READ_ENTITY_PROPERTY_COLOR(PROP_SPECULAR_COLOR_UNUSED, ignoredColor); + + // _constantAttenuation has been renamed to _intensity + READ_ENTITY_PROPERTY(PROP_INTENSITY, float, _intensity); + + // Linear and quadratic attenuation are from an older format and are no longer supported. + // Their values will be ignored. + READ_ENTITY_PROPERTY(PROP_LINEAR_ATTENUATION_UNUSED, float, ignoredAttenuation); + READ_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION_UNUSED, float, ignoredAttenuation); + + READ_ENTITY_PROPERTY(PROP_EXPONENT, float, _exponent); + READ_ENTITY_PROPERTY(PROP_CUTOFF, float, _cutoff); + } else { + READ_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, bool, _isSpotlight); + READ_ENTITY_PROPERTY_COLOR(PROP_COLOR, _color); + READ_ENTITY_PROPERTY(PROP_INTENSITY, float, _intensity); + READ_ENTITY_PROPERTY(PROP_EXPONENT, float, _exponent); + READ_ENTITY_PROPERTY(PROP_CUTOFF, float, _cutoff); + } return bytesRead; } @@ -119,12 +128,8 @@ int LightEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, EntityPropertyFlags LightEntityItem::getEntityProperties(EncodeBitstreamParams& params) const { EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params); requestedProperties += PROP_IS_SPOTLIGHT; - requestedProperties += PROP_DIFFUSE_COLOR; - requestedProperties += PROP_AMBIENT_COLOR; - requestedProperties += PROP_SPECULAR_COLOR; - requestedProperties += PROP_CONSTANT_ATTENUATION; - requestedProperties += PROP_LINEAR_ATTENUATION; - requestedProperties += PROP_QUADRATIC_ATTENUATION; + requestedProperties += PROP_COLOR; + requestedProperties += PROP_INTENSITY; requestedProperties += PROP_EXPONENT; requestedProperties += PROP_CUTOFF; return requestedProperties; @@ -140,12 +145,8 @@ void LightEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit bool successPropertyFits = true; APPEND_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, appendValue, getIsSpotlight()); - APPEND_ENTITY_PROPERTY(PROP_DIFFUSE_COLOR, appendColor, getDiffuseColor()); - APPEND_ENTITY_PROPERTY(PROP_AMBIENT_COLOR, appendColor, getAmbientColor()); - APPEND_ENTITY_PROPERTY(PROP_SPECULAR_COLOR, appendColor, getSpecularColor()); - APPEND_ENTITY_PROPERTY(PROP_CONSTANT_ATTENUATION, appendValue, getConstantAttenuation()); - APPEND_ENTITY_PROPERTY(PROP_LINEAR_ATTENUATION, appendValue, getLinearAttenuation()); - APPEND_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION, appendValue, getQuadraticAttenuation()); + APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor()); + APPEND_ENTITY_PROPERTY(PROP_INTENSITY, appendValue, getIntensity()); APPEND_ENTITY_PROPERTY(PROP_EXPONENT, appendValue, getExponent()); APPEND_ENTITY_PROPERTY(PROP_CUTOFF, appendValue, getCutoff()); } diff --git a/libraries/entities/src/LightEntityItem.h b/libraries/entities/src/LightEntityItem.h index 5e39ba26a2..cdbdb59ece 100644 --- a/libraries/entities/src/LightEntityItem.h +++ b/libraries/entities/src/LightEntityItem.h @@ -43,53 +43,23 @@ public: ReadBitstreamToTreeParams& args, EntityPropertyFlags& propertyFlags, bool overwriteLocalData); - const rgbColor& getAmbientColor() const { return _ambientColor; } - xColor getAmbientXColor() const { - xColor color = { _ambientColor[RED_INDEX], _ambientColor[GREEN_INDEX], _ambientColor[BLUE_INDEX] }; return color; + const rgbColor& getColor() const { return _color; } + xColor getXColor() const { + xColor color = { _color[RED_INDEX], _color[GREEN_INDEX], _color[BLUE_INDEX] }; return color; } - void setAmbientColor(const rgbColor& value) { memcpy(_ambientColor, value, sizeof(_ambientColor)); } - void setAmbientColor(const xColor& value) { - _ambientColor[RED_INDEX] = value.red; - _ambientColor[GREEN_INDEX] = value.green; - _ambientColor[BLUE_INDEX] = value.blue; - } - - const rgbColor& getDiffuseColor() const { return _diffuseColor; } - xColor getDiffuseXColor() const { - xColor color = { _diffuseColor[RED_INDEX], _diffuseColor[GREEN_INDEX], _diffuseColor[BLUE_INDEX] }; return color; - } - - void setDiffuseColor(const rgbColor& value) { memcpy(_diffuseColor, value, sizeof(_diffuseColor)); } - void setDiffuseColor(const xColor& value) { - _diffuseColor[RED_INDEX] = value.red; - _diffuseColor[GREEN_INDEX] = value.green; - _diffuseColor[BLUE_INDEX] = value.blue; - } - - const rgbColor& getSpecularColor() const { return _specularColor; } - xColor getSpecularXColor() const { - xColor color = { _specularColor[RED_INDEX], _specularColor[GREEN_INDEX], _specularColor[BLUE_INDEX] }; return color; - } - - void setSpecularColor(const rgbColor& value) { memcpy(_specularColor, value, sizeof(_specularColor)); } - void setSpecularColor(const xColor& value) { - _specularColor[RED_INDEX] = value.red; - _specularColor[GREEN_INDEX] = value.green; - _specularColor[BLUE_INDEX] = value.blue; + void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); } + void setColor(const xColor& value) { + _color[RED_INDEX] = value.red; + _color[GREEN_INDEX] = value.green; + _color[BLUE_INDEX] = value.blue; } bool getIsSpotlight() const { return _isSpotlight; } void setIsSpotlight(bool value) { _isSpotlight = value; } - float getConstantAttenuation() const { return _constantAttenuation; } - void setConstantAttenuation(float value) { _constantAttenuation = value; } - - float getLinearAttenuation() const { return _linearAttenuation; } - void setLinearAttenuation(float value) { _linearAttenuation = value; } - - float getQuadraticAttenuation() const { return _quadraticAttenuation; } - void setQuadraticAttenuation(float value) { _quadraticAttenuation = value; } + float getIntensity() const { return _intensity; } + void setIntensity(float value) { _intensity = value; } float getExponent() const { return _exponent; } void setExponent(float value) { _exponent = value; } @@ -103,13 +73,9 @@ public: protected: // properties of a light - rgbColor _ambientColor; - rgbColor _diffuseColor; - rgbColor _specularColor; + rgbColor _color; bool _isSpotlight; - float _constantAttenuation; - float _linearAttenuation; - float _quadraticAttenuation; + float _intensity; float _exponent; float _cutoff; diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index f67abdca2b..58399a6075 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -34,7 +34,8 @@ AddressManager::AddressManager() : _rootPlaceName(), _rootPlaceID(), _positionGetter(NULL), - _orientationGetter(NULL) + _orientationGetter(NULL), + _localDSPortSharedMem(NULL) { connect(qApp, &QCoreApplication::aboutToQuit, this, &AddressManager::storeCurrentAddress); } @@ -152,8 +153,15 @@ void AddressManager::handleLookupString(const QString& lookupString) { if (!lookupString.startsWith('/')) { const QRegExp HIFI_SCHEME_REGEX = QRegExp(HIFI_URL_SCHEME + ":\\/{1,2}", Qt::CaseInsensitive); sanitizedString = sanitizedString.remove(HIFI_SCHEME_REGEX); + + quint16 localDomainServerPort = DEFAULT_DOMAIN_SERVER_PORT; + if (sanitizedString == "localhost") { + auto nodeList = DependencyManager::get(); + nodeList->getLocalServerPortFromSharedMemory + (DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, _localDSPortSharedMem, localDomainServerPort); + } - lookupURL = QUrl(HIFI_URL_SCHEME + "://" + sanitizedString); + lookupURL = QUrl(HIFI_URL_SCHEME + "://" + sanitizedString + ":" + QString::number(localDomainServerPort)); } else { lookupURL = QUrl(lookupString); } diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index 0c24c12cc9..bfc3ace657 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -13,6 +13,7 @@ #define hifi_AddressManager_h #include +#include #include #include @@ -94,6 +95,8 @@ private: QUuid _rootPlaceID; PositionGetter _positionGetter; OrientationGetter _orientationGetter; + + QSharedMemory* _localDSPortSharedMem; // memory shared with domain server }; -#endif // hifi_AddressManager_h \ No newline at end of file +#endif // hifi_AddressManager_h diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index b240f0df9e..cf5b2eef27 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -96,6 +96,13 @@ void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) { } } +void LimitedNodeList::setThisNodeCanAdjustLocks(bool canAdjustLocks) { + if (_thisNodeCanAdjustLocks != canAdjustLocks) { + _thisNodeCanAdjustLocks = canAdjustLocks; + emit canAdjustLocksChanged(canAdjustLocks); + } +} + QUdpSocket& LimitedNodeList::getDTLSSocket() { if (!_dtlsSocket) { // DTLS socket getter called but no DTLS socket exists, create it now @@ -670,10 +677,9 @@ void LimitedNodeList::sendHeartbeatToIceServer(const HifiSockAddr& iceServerSock writeUnverifiedDatagram(iceRequestByteArray, iceServerSockAddr); } -void LimitedNodeList::putLocalPortIntoSharedMemory(const QString key, QObject* parent) { +void LimitedNodeList::putLocalPortIntoSharedMemory(const QString key, QObject* parent, quint16 localPort) { // save our local port to shared memory so that assignment client children know how to talk to this parent QSharedMemory* sharedPortMem = new QSharedMemory(key, parent); - quint16 localPort = getNodeSocket().localPort(); // attempt to create the shared memory segment if (sharedPortMem->create(sizeof(localPort)) || sharedPortMem->attach()) { diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index afc98de169..85db739cda 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -50,6 +50,8 @@ const char STUN_SERVER_HOSTNAME[] = "stun.highfidelity.io"; const unsigned short STUN_SERVER_PORT = 3478; const QString DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY = "domain-server.local-port"; +const QString DOMAIN_SERVER_LOCAL_HTTP_PORT_SMEM_KEY = "domain-server.local-http-port"; +const QString DOMAIN_SERVER_LOCAL_HTTPS_PORT_SMEM_KEY = "domain-server.local-https-port"; const QString ASSIGNMENT_CLIENT_MONITOR_LOCAL_PORT_SMEM_KEY = "assignment-client-monitor.local-port"; const char DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME[] = "localhost"; @@ -82,8 +84,8 @@ public: const QUuid& getSessionUUID() const { return _sessionUUID; } void setSessionUUID(const QUuid& sessionUUID); - bool getThisNodeCanAdjustLocks() { return _thisNodeCanAdjustLocks; } - void setThisNodeCanAdjustLocks(bool canAdjustLocks) { _thisNodeCanAdjustLocks = canAdjustLocks; } + bool getThisNodeCanAdjustLocks() const { return _thisNodeCanAdjustLocks; } + void setThisNodeCanAdjustLocks(bool canAdjustLocks); void rebindNodeSocket(); QUdpSocket& getNodeSocket() { return _nodeSocket; } @@ -174,7 +176,7 @@ public: return SharedNodePointer(); } - void putLocalPortIntoSharedMemory(const QString key, QObject* parent); + void putLocalPortIntoSharedMemory(const QString key, QObject* parent, quint16 localPort); bool getLocalServerPortFromSharedMemory(const QString key, QSharedMemory*& sharedMem, quint16& localPort); public slots: @@ -194,6 +196,8 @@ signals: void localSockAddrChanged(const HifiSockAddr& localSockAddr); void publicSockAddrChanged(const HifiSockAddr& publicSockAddr); + void canAdjustLocksChanged(bool canAdjustLocks); + void dataSent(const quint8 channel_type, const int bytes); void dataReceived(const quint8 channel_type, const int bytes); diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index db97e216ee..c8f6b6e25c 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -74,7 +74,7 @@ PacketVersion versionForPacketType(PacketType type) { return 1; case PacketTypeEntityAddOrEdit: case PacketTypeEntityData: - return VERSION_MODEL_ENTITIES_SUPPORT_SHAPE_TYPE; + return VERSION_ENTITIES_LIGHT_HAS_INTENSITY_AND_COLOR_PROPERTIES; case PacketTypeEntityErase: return 2; case PacketTypeAudioStreamStats: diff --git a/libraries/networking/src/PacketHeaders.h b/libraries/networking/src/PacketHeaders.h index 32f33c01d9..44a464201b 100644 --- a/libraries/networking/src/PacketHeaders.h +++ b/libraries/networking/src/PacketHeaders.h @@ -128,6 +128,7 @@ const PacketVersion VERSION_ENTITIES_MODELS_HAVE_ANIMATION_SETTINGS = 5; const PacketVersion VERSION_ENTITIES_HAVE_USER_DATA = 6; const PacketVersion VERSION_ENTITIES_HAS_LAST_SIMULATED_TIME = 7; const PacketVersion VERSION_MODEL_ENTITIES_SUPPORT_SHAPE_TYPE = 8; +const PacketVersion VERSION_ENTITIES_LIGHT_HAS_INTENSITY_AND_COLOR_PROPERTIES = 9; const PacketVersion VERSION_OCTREE_HAS_FILE_BREAKS = 1; #endif // hifi_PacketHeaders_h diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index dffadc730f..317b3bd6b9 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -53,18 +53,33 @@ const int NUM_COORDS_PER_VERTEX = 3; const int NUM_BYTES_PER_VERTEX = NUM_COORDS_PER_VERTEX * sizeof(GLfloat); const int NUM_BYTES_PER_INDEX = sizeof(GLushort); -void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid) { +void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) { + bool registered = (id != UNKNOWN_ID); Vec2Pair radiusKey(glm::vec2(radius, slices), glm::vec2(stacks, 0)); IntPair slicesStacksKey(slices, stacks); - Vec3Pair colorKey(glm::vec3(color.x, color.y, slices), glm::vec3(color.z, color.y, stacks)); + Vec3Pair colorKey(glm::vec3(color.x, color.y, slices), glm::vec3(color.z, color.w, stacks)); int vertices = slices * (stacks - 1) + 2; int indices = slices * (stacks - 1) * NUM_VERTICES_PER_TRIANGULATED_QUAD; - if (!_sphereVertices.contains(radiusKey)) { + if (registered && (!_registeredSphereVertices.contains(id) || _lastRegisteredSphereVertices[id] != radiusKey) + || !registered && !_sphereVertices.contains(radiusKey)) { + + if (registered && _registeredSphereVertices.contains(id)) { + _registeredSphereVertices[id].clear(); + #ifdef WANT_DEBUG + qDebug() << "renderSphere()... RELEASING REGISTERED VERTICES BUFFER"; + #endif + } + gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - _sphereVertices[radiusKey] = verticesBuffer; + if (registered) { + _registeredSphereVertices[id] = verticesBuffer; + _lastRegisteredSphereVertices[id] = radiusKey; + } else { + _sphereVertices[radiusKey] = verticesBuffer; + } GLfloat* vertexData = new GLfloat[vertices * NUM_COORDS_PER_VERTEX]; GLfloat* vertex = vertexData; @@ -106,10 +121,29 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm qDebug() << " _sphereVertices.size():" << _sphereVertices.size(); #endif } + #ifdef WANT_DEBUG + else if (registered) { + qDebug() << "renderSphere()... REUSING PREVIOUSLY REGISTERED VERTICES BUFFER"; + } + #endif - if (!_sphereIndices.contains(slicesStacksKey)) { + if (registered && (!_registeredSphereIndices.contains(id) || _lastRegisteredSphereIndices[id] != slicesStacksKey) + || !registered && !_sphereIndices.contains(slicesStacksKey)) { + + if (registered && _registeredSphereIndices.contains(id)) { + _registeredSphereIndices[id].clear(); + #ifdef WANT_DEBUG + qDebug() << "renderSphere()... RELEASING REGISTERED INDICES BUFFER"; + #endif + } + gpu::BufferPointer indicesBuffer(new gpu::Buffer()); - _sphereIndices[slicesStacksKey] = indicesBuffer; + if (registered) { + _registeredSphereIndices[id] = indicesBuffer; + _lastRegisteredSphereIndices[id] = slicesStacksKey; + } else { + _sphereIndices[slicesStacksKey] = indicesBuffer; + } GLushort* indexData = new GLushort[indices]; GLushort* index = indexData; @@ -164,7 +198,7 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm delete[] indexData; #ifdef WANT_DEBUG - qDebug() << "GeometryCache::renderSphere()... --- CREATING INDEX BUFFER"; + qDebug() << "GeometryCache::renderSphere()... --- CREATING INDICES BUFFER"; qDebug() << " radius:" << radius; qDebug() << " slices:" << slices; qDebug() << " stacks:" << stacks; @@ -173,10 +207,29 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm qDebug() << " _sphereIndices.size():" << _sphereIndices.size(); #endif } + #ifdef WANT_DEBUG + else if (registered) { + qDebug() << "renderSphere()... REUSING PREVIOUSLY REGISTERED INDICES BUFFER"; + } + #endif + + if (registered && (!_registeredSphereColors.contains(id) || _lastRegisteredSphereColors[id] != colorKey) + || !registered && !_sphereColors.contains(colorKey)) { + + if (registered && _registeredSphereColors.contains(id)) { + _registeredSphereColors[id].clear(); + #ifdef WANT_DEBUG + qDebug() << "renderSphere()... RELEASING REGISTERED COLORS BUFFER"; + #endif + } - if (!_sphereColors.contains(colorKey)) { gpu::BufferPointer colorBuffer(new gpu::Buffer()); - _sphereColors[colorKey] = colorBuffer; + if (registered) { + _registeredSphereColors[id] = colorBuffer; + _lastRegisteredSphereColors[id] = colorKey; + } else { + _sphereColors[colorKey] = colorBuffer; + } int compactColor = ((int(color.x * 255.0f) & 0xFF)) | ((int(color.y * 255.0f) & 0xFF) << 8) | @@ -201,11 +254,16 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm qDebug() << " stacks:" << stacks; qDebug() << " _sphereColors.size():" << _sphereColors.size(); #endif - } - gpu::BufferPointer verticesBuffer = _sphereVertices[radiusKey]; - gpu::BufferPointer indicesBuffer = _sphereIndices[slicesStacksKey]; - gpu::BufferPointer colorBuffer = _sphereColors[colorKey]; + #ifdef WANT_DEBUG + else if (registered) { + qDebug() << "renderSphere()... REUSING PREVIOUSLY REGISTERED COLORS BUFFER"; + } + #endif + + gpu::BufferPointer verticesBuffer = registered ? _registeredSphereVertices[id] : _sphereVertices[radiusKey]; + gpu::BufferPointer indicesBuffer = registered ? _registeredSphereIndices[id] : _sphereIndices[slicesStacksKey]; + gpu::BufferPointer colorBuffer = registered ? _registeredSphereColors[id] : _sphereColors[colorKey]; const int VERTICES_SLOT = 0; const int NORMALS_SLOT = 1; diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 864c5ff24c..92b6d44b6c 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -134,10 +134,10 @@ public: void renderCone(float base, float height, int slices, int stacks); - void renderSphere(float radius, int slices, int stacks, const glm::vec3& color, bool solid = true) - { renderSphere(radius, slices, stacks, glm::vec4(color, 1.0f), solid); } + void renderSphere(float radius, int slices, int stacks, const glm::vec3& color, bool solid = true, int id = UNKNOWN_ID) + { renderSphere(radius, slices, stacks, glm::vec4(color, 1.0f), solid, id); } - void renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid = true); + void renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid = true, int id = UNKNOWN_ID); void renderGrid(int xDivisions, int yDivisions, const glm::vec4& color); void renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id = UNKNOWN_ID); void renderSolidCube(float size, const glm::vec4& color); @@ -290,10 +290,15 @@ private: QHash _gridColors; QHash _sphereVertices; + QHash _registeredSphereVertices; + QHash _lastRegisteredSphereVertices; QHash _sphereIndices; + QHash _registeredSphereIndices; + QHash _lastRegisteredSphereIndices; QHash _sphereColors; - - + QHash _registeredSphereColors; + QHash _lastRegisteredSphereColors; + QHash > _networkGeometry; }; diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 3bdf9a9fa9..df327b9c5c 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -44,8 +44,6 @@ #include "MIDIEvent.h" -EntityScriptingInterface ScriptEngine::_entityScriptingInterface; - static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ qDebug() << "script:print()<<" << context->argument(0).toString(); QString message = context->argument(0).toString() @@ -314,7 +312,8 @@ void ScriptEngine::init() { auto sceneScriptingInterface = DependencyManager::set(); - _entityScriptingInterface.init(); + auto entityScriptingInterface = DependencyManager::get(); + entityScriptingInterface->init(); // register various meta-types registerMetaTypes(this); @@ -352,7 +351,7 @@ void ScriptEngine::init() { registerGlobalObject("Script", this); registerGlobalObject("Audio", &AudioScriptingInterface::getInstance()); registerGlobalObject("Controller", _controllerScriptingInterface); - registerGlobalObject("Entities", &_entityScriptingInterface); + registerGlobalObject("Entities", entityScriptingInterface.data()); registerGlobalObject("Quat", &_quatLibrary); registerGlobalObject("Vec3", &_vec3Library); registerGlobalObject("Uuid", &_uuidLibrary); @@ -470,6 +469,7 @@ void ScriptEngine::run() { int thisFrame = 0; auto nodeList = DependencyManager::get(); + auto entityScriptingInterface = DependencyManager::get(); qint64 lastUpdate = usecTimestampNow(); @@ -489,13 +489,13 @@ void ScriptEngine::run() { break; } - if (!_isFinished && _entityScriptingInterface.getEntityPacketSender()->serversExist()) { + if (!_isFinished && entityScriptingInterface->getEntityPacketSender()->serversExist()) { // release the queue of edit entity messages. - _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages(); + entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); // since we're in non-threaded mode, call process so that the packets are sent - if (!_entityScriptingInterface.getEntityPacketSender()->isThreaded()) { - _entityScriptingInterface.getEntityPacketSender()->process(); + if (!entityScriptingInterface->getEntityPacketSender()->isThreaded()) { + entityScriptingInterface->getEntityPacketSender()->process(); } } @@ -622,13 +622,13 @@ void ScriptEngine::run() { // kill the avatar identity timer delete _avatarIdentityTimer; - if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) { + if (entityScriptingInterface->getEntityPacketSender()->serversExist()) { // release the queue of edit entity messages. - _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages(); + entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); // since we're in non-threaded mode, call process so that the packets are sent - if (!_entityScriptingInterface.getEntityPacketSender()->isThreaded()) { - _entityScriptingInterface.getEntityPacketSender()->process(); + if (!entityScriptingInterface->getEntityPacketSender()->isThreaded()) { + entityScriptingInterface->getEntityPacketSender()->process(); } } diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index 154fdb88e3..84d2527bd0 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -31,8 +31,6 @@ #include "ScriptUUID.h" #include "Vec3.h" -class EntityScriptingInterface; - const QString NO_SCRIPT(""); const unsigned int SCRIPT_DATA_CALLBACK_USECS = floor(((1.0 / 60.0f) * 1000 * 1000) + 0.5); @@ -46,9 +44,6 @@ public: ~ScriptEngine(); - /// Access the EntityScriptingInterface in order to initialize it with a custom packet sender and jurisdiction listener - static EntityScriptingInterface* getEntityScriptingInterface() { return &_entityScriptingInterface; } - ArrayBufferClass* getArrayBufferClass() { return _arrayBufferClass; } /// sets the script contents, will return false if failed, will fail if script is already running @@ -153,8 +148,6 @@ private: QObject* setupTimerWithInterval(const QScriptValue& function, int intervalMS, bool isSingleShot); void stopTimer(QTimer* timer); - static EntityScriptingInterface _entityScriptingInterface; - AbstractControllerScriptingInterface* _controllerScriptingInterface; AvatarData* _avatarData; QString _scriptName; diff --git a/libraries/shared/src/LogHandler.cpp b/libraries/shared/src/LogHandler.cpp index 577bf83449..60cddb5cfe 100644 --- a/libraries/shared/src/LogHandler.cpp +++ b/libraries/shared/src/LogHandler.cpp @@ -101,6 +101,22 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont } } } + + // see if this message is one we should only print once + foreach(const QString& regexString, getInstance()._onlyOnceMessageRegexes) { + QRegExp onlyOnceRegex(regexString); + if (onlyOnceRegex.indexIn(message) != -1) { + if (!_onlyOnceMessageCountHash.contains(message)) { + // we have a match and haven't yet printed this message. + _onlyOnceMessageCountHash[message] = 1; + // break the foreach so we output the first match + break; + } else { + // We've already printed this message, don't print it again. + return QString(); + } + } + } } // log prefix is in the following format diff --git a/libraries/shared/src/LogHandler.h b/libraries/shared/src/LogHandler.h index f8f06b0033..914cad212d 100644 --- a/libraries/shared/src/LogHandler.h +++ b/libraries/shared/src/LogHandler.h @@ -48,6 +48,7 @@ public: static void verboseMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message); const QString& addRepeatedMessageRegex(const QString& regexString) { return *_repeatedMessageRegexes.insert(regexString); } + const QString& addOnlyOnceMessageRegex(const QString& regexString) { return *_onlyOnceMessageRegexes.insert(regexString); } private: LogHandler(); @@ -58,6 +59,9 @@ private: QSet _repeatedMessageRegexes; QHash _repeatMessageCountHash; QHash _lastRepeatedMessage; + + QSet _onlyOnceMessageRegexes; + QHash _onlyOnceMessageCountHash; }; -#endif // hifi_LogHandler_h \ No newline at end of file +#endif // hifi_LogHandler_h