Merge branch 'cuckoo' of https://github.com/birarda/hifi into applications_diet_cpp11

This commit is contained in:
Atlante45 2014-12-18 14:18:21 -08:00
commit 990362b8ff
56 changed files with 350 additions and 411 deletions

View file

@ -12,7 +12,7 @@ link_hifi_libraries(
)
if (UNIX)
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${CMAKE_DL_LIBS})
target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS})
endif (UNIX)
link_shared_dependencies()

View file

@ -25,18 +25,9 @@ macro(LINK_HIFI_LIBRARIES)
# 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})
# ask the library what its include dependencies are and link them
get_target_property(LINKED_TARGET_DEPENDENCY_INCLUDES ${HIFI_LIBRARY} DEPENDENCY_INCLUDES)
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES ${LINKED_TARGET_DEPENDENCY_INCLUDES})
# ask the library what its qt module dependencies are and link them
get_target_property(LINKED_TARGET_DEPENDENCY_QT_MODULES ${HIFI_LIBRARY} DEPENDENCY_QT_MODULES)
list(APPEND ${TARGET_NAME}_DEPENDENCY_QT_MODULES ${LINKED_TARGET_DEPENDENCY_QT_MODULES})
endforeach()
endmacro(LINK_HIFI_LIBRARIES)

View file

@ -9,14 +9,7 @@
# 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 ()
macro(LINK_SHARED_DEPENDENCIES)
if (${TARGET_NAME}_DEPENDENCY_INCLUDES)
list(REMOVE_DUPLICATES ${TARGET_NAME}_DEPENDENCY_INCLUDES)
@ -24,22 +17,6 @@ macro(LINK_SHARED_DEPENDENCIES)
include_directories(SYSTEM ${${TARGET_NAME}_DEPENDENCY_INCLUDES})
endif ()
if (${TARGET_NAME}_DEPENDENCY_QT_MODULES)
list(REMOVE_DUPLICATES ${TARGET_NAME}_DEPENDENCY_QT_MODULES)
# find these Qt modules and link them to our own target
find_package(Qt5 COMPONENTS ${${TARGET_NAME}_DEPENDENCY_QT_MODULES} REQUIRED)
foreach(QT_MODULE ${${TARGET_NAME}_DEPENDENCY_QT_MODULES})
target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE})
endforeach()
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_NAME}_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_NAME}_LIBRARIES_TO_LINK}")
set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_INCLUDES "${${TARGET_NAME}_DEPENDENCY_INCLUDES}")
set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_QT_MODULES "${${TARGET_NAME}_DEPENDENCY_QT_MODULES}")
endmacro(LINK_SHARED_DEPENDENCIES)

View file

@ -21,4 +21,11 @@ macro(SETUP_HIFI_LIBRARY)
set(${TARGET_NAME}_DEPENDENCY_QT_MODULES ${ARGN})
list(APPEND ${TARGET_NAME}_DEPENDENCY_QT_MODULES Core)
# find these Qt modules and link them to our own target
find_package(Qt5 COMPONENTS ${${TARGET_NAME}_DEPENDENCY_QT_MODULES} REQUIRED)
foreach(QT_MODULE ${${TARGET_NAME}_DEPENDENCY_QT_MODULES})
target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE})
endforeach()
endmacro(SETUP_HIFI_LIBRARY)

View file

@ -27,4 +27,11 @@ macro(SETUP_HIFI_PROJECT)
set(${TARGET_NAME}_DEPENDENCY_QT_MODULES ${ARGN})
list(APPEND ${TARGET_NAME}_DEPENDENCY_QT_MODULES Core)
# find these Qt modules and link them to our own target
find_package(Qt5 COMPONENTS ${${TARGET_NAME}_DEPENDENCY_QT_MODULES} REQUIRED)
foreach(QT_MODULE ${${TARGET_NAME}_DEPENDENCY_QT_MODULES})
target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE})
endforeach()
endmacro()

View file

@ -32,9 +32,10 @@ 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(CoreVideo CoreVideo)
find_library(QTKit QTKit)
find_library(IOKit IOKit)
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})
@ -49,19 +50,19 @@ include(FindPackageHandleStandardArgs)
list(APPEND VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR
VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR
VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY)
VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY)
if (APPLE)
list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit QTKit)
list(APPEND VISAGE_ARGS_LIST CoreVideo QTKit IOKit)
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}")
set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}")
if (APPLE)
list(APPEND VISAGE_LIBRARIES ${QuartzCore} ${AppKit} ${QTKit})
list(APPEND VISAGE_LIBRARIES "${CoreVideo}" "${QTKit}" "${IOKit}")
endif ()
mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES)

View file

@ -50,6 +50,6 @@ endif ()
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
# append OpenSSL to our list of libraries to link
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}")
target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES})
link_shared_dependencies()

View file

@ -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" "Visage" "LeapMotion" "RtMidi" "Qxmpp" "SDL2" "Gverb")
set(OPTIONAL_EXTERNALS "Faceshift" "LibOVR" "PrioVR" "Sixense" "LeapMotion" "RtMidi" "Qxmpp" "SDL2" "Gverb")
foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE)
if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR)
@ -107,7 +107,8 @@ endif()
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
# link required hifi libraries
link_hifi_libraries(shared octree voxels gpu fbx metavoxels networking entities avatars audio animation script-engine physics render-utils)
link_hifi_libraries(shared octree voxels gpu fbx metavoxels networking entities avatars audio animation script-engine physics
render-utils entities-renderer)
# find any optional and required libraries
find_package(ZLIB REQUIRED)
@ -156,7 +157,6 @@ if (VISAGE_FOUND AND NOT DISABLE_VISAGE AND APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment")
find_library(AVFoundation AVFoundation)
find_library(CoreMedia CoreMedia)
find_library(NEW_STD_LIBRARY libc++.dylib /usr/lib/)
target_link_libraries(${TARGET_NAME} ${AVFoundation} ${CoreMedia} ${NEW_STD_LIBRARY})
endif ()

View file

@ -74,6 +74,7 @@
#include <ProgramObject.h>
#include <ResourceCache.h>
#include <SoundCache.h>
#include <TextRenderer.h>
#include <UserActivityLogger.h>
#include <UUID.h>
@ -110,7 +111,6 @@
#include "ui/InfoView.h"
#include "ui/Snapshot.h"
#include "ui/Stats.h"
#include "ui/TextRenderer.h"
@ -155,9 +155,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_voxelImporter(),
_importSucceded(false),
_sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard),
_entities(true),
_entities(true, this, this),
_entityCollisionSystem(),
_entityClipboardRenderer(false),
_entityClipboardRenderer(false, this, this),
_entityClipboard(),
_wantToKillLocalVoxels(false),
_viewFrustum(),
@ -192,7 +192,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_aboutToQuit(false)
{
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
// read the ApplicationInfo.ini file for Name/Version/Domain information
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
@ -2953,6 +2953,18 @@ bool Application::shouldRenderMesh(float largestDimension, float distanceToCamer
return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
}
float Application::getSizeScale() const {
return Menu::getInstance()->getVoxelSizeScale();
}
int Application::getBoundaryLevelAdjust() const {
return Menu::getInstance()->getBoundaryLevelAdjust();
}
PickRay Application::computePickRay(float x, float y) {
return getCamera()->computePickRay(x, y);
}
QImage Application::renderAvatarBillboard() {
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();

View file

@ -23,8 +23,11 @@
#include <QStringList>
#include <QUndoStack>
#include <AbstractScriptingServicesInterface.h>
#include <AbstractViewStateInterface.h>
#include <EntityCollisionSystem.h>
#include <EntityEditPacketSender.h>
#include <EntityTreeRenderer.h>
#include <GeometryCache.h>
#include <NetworkPacket.h>
#include <NodeList.h>
@ -33,7 +36,6 @@
#include <ScriptEngine.h>
#include <TextureCache.h>
#include <ViewFrustum.h>
#include <ViewStateInterface.h>
#include <VoxelEditPacketSender.h>
#include "Audio.h"
@ -51,7 +53,6 @@
#include "avatar/MyAvatar.h"
#include "devices/PrioVR.h"
#include "devices/SixenseManager.h"
#include "entities/EntityTreeRenderer.h"
#include "scripting/ControllerScriptingInterface.h"
#include "ui/BandwidthDialog.h"
#include "ui/BandwidthMeter.h"
@ -119,7 +120,7 @@ static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS
static const QString INFO_HELP_PATH = "html/interface-welcome-allsvg.html";
static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html";
class Application : public QApplication, public ViewStateInterface {
class Application : public QApplication, public AbstractViewStateInterface, AbstractScriptingServicesInterface {
Q_OBJECT
friend class OctreePacketProcessor;
@ -177,6 +178,7 @@ public:
bool isThrottleRendering() const { return DependencyManager::get<GLCanvas>()->isThrottleRendering(); }
MyAvatar* getAvatar() { return _myAvatar; }
const MyAvatar* getAvatar() const { return _myAvatar; }
Audio* getAudio() { return &_audio; }
Camera* getCamera() { return &_myCamera; }
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
@ -242,7 +244,9 @@ public:
ToolWindow* getToolWindow() { return _toolWindow ; }
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
virtual AbstractControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
virtual void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
AvatarManager& getAvatarManager() { return _avatarManager; }
void resetProfile(const QString& username);
@ -279,6 +283,10 @@ public:
virtual bool getShadowsEnabled();
virtual bool getCascadeShadowsEnabled();
virtual QThread* getMainThread() { return thread(); }
virtual float getSizeScale() const;
virtual int getBoundaryLevelAdjust() const;
virtual PickRay computePickRay(float x, float y);
virtual const glm::vec3& getAvatarPosition() const { return getAvatar()->getPosition(); }
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
@ -304,9 +312,6 @@ public:
bool isVSyncEditable() const;
bool isAboutToQuit() const { return _aboutToQuit; }
void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
// the isHMDmode is true whenever we use the interface from an HMD and not a standard flat display
// rendering of several elements depend on that
// TODO: carry that information on the Camera as a setting

View file

@ -19,12 +19,12 @@
#include <glm/gtx/quaternion.hpp>
#include <glm/detail/func_common.hpp>
#include <SharedUtil.h>
#include <QThread>
#include <SharedUtil.h>
#include <TextRenderer.h>
#include "InterfaceConfig.h"
#include "ui/TextRenderer.h"
#include "VoxelConstants.h"
#include "world.h"
#include "Application.h"

View file

@ -30,6 +30,7 @@
#include <PathUtils.h>
#include <PerfStat.h>
#include <SharedUtil.h>
#include <TextRenderer.h>
#include <TextureCache.h>
#include "Application.h"
@ -42,7 +43,6 @@
#include "Recorder.h"
#include "world.h"
#include "devices/OculusManager.h"
#include "ui/TextRenderer.h"
using namespace std;

View file

@ -30,6 +30,7 @@
#include <PerfStat.h>
#include <ShapeCollider.h>
#include <SharedUtil.h>
#include <TextRenderer.h>
#include "Application.h"
#include "Audio.h"
@ -41,7 +42,6 @@
#include "Recorder.h"
#include "devices/Faceshift.h"
#include "devices/OculusManager.h"
#include "ui/TextRenderer.h"
using namespace std;

View file

@ -14,11 +14,11 @@
#include <FBXReader.h>
#include <PerfStat.h>
#include <TextRenderer.h>
#include "Application.h"
#include "PrioVR.h"
#include "scripting/JoystickScriptingInterface.h"
#include "ui/TextRenderer.h"
#ifdef HAVE_PRIOVR
const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A,

View file

@ -16,7 +16,7 @@
#include <glm/glm.hpp>
#include "ui/TextRenderer.h"
#include <TextRenderer.h>
class BandwidthMeter {

View file

@ -12,10 +12,10 @@
#ifndef hifi_LocalModelsOverlay_h
#define hifi_LocalModelsOverlay_h
#include "entities/EntityTreeRenderer.h"
#include "Volume3DOverlay.h"
class EntityTreeRenderer;
class LocalModelsOverlay : public Volume3DOverlay {
Q_OBJECT
public:

View file

@ -11,9 +11,10 @@
// include this before QGLWidget, which includes an earlier version of OpenGL
#include "InterfaceConfig.h"
#include <TextRenderer.h>
#include "Application.h"
#include "Text3DOverlay.h"
#include "ui/TextRenderer.h"
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
const float DEFAULT_BACKGROUND_ALPHA = 0.7f;

View file

@ -13,9 +13,9 @@
#include <QGLWidget>
#include <SharedUtil.h>
#include <TextRenderer.h>
#include "TextOverlay.h"
#include "ui/TextRenderer.h"
TextOverlay::TextOverlay() :
_backgroundColor(DEFAULT_BACKGROUND_COLOR),

View file

@ -0,0 +1,11 @@
set(TARGET_NAME entities-renderer)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
setup_hifi_library(Widgets OpenGL Network Script)
include_glm()
link_hifi_libraries(shared gpu script-engine)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()

View file

@ -9,28 +9,24 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <gpu/GPUConfig.h>
#include <glm/gtx/quaternion.hpp>
#include <QEventLoop>
#include <QScriptSyntaxCheckResult>
#include <FBXReader.h>
#include "InterfaceConfig.h"
#include <BoxEntityItem.h>
#include <AbstractScriptingServicesInterface.h>
#include <AbstractViewStateInterface.h>
#include <DeferredLightingEffect.h>
#include <GlowEffect.h>
#include <ModelEntityItem.h>
#include <MouseEvent.h>
#include <Model.h>
#include <NetworkAccessManager.h>
#include <PerfStat.h>
#include <RenderArgs.h>
#include <ScriptEngine.h>
#include "Menu.h"
#include "NetworkAccessManager.h"
#include "EntityTreeRenderer.h"
#include "devices/OculusManager.h"
#include "RenderableBoxEntityItem.h"
#include "RenderableLightEntityItem.h"
#include "RenderableModelEntityItem.h"
@ -38,15 +34,18 @@
#include "RenderableTextEntityItem.h"
QThread* EntityTreeRenderer::getMainThread() {
return Application::getInstance()->getEntities()->thread();
}
EntityTreeRenderer::EntityTreeRenderer(bool wantScripts) :
EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState,
AbstractScriptingServicesInterface* scriptingServices) :
OctreeRenderer(),
_wantScripts(wantScripts),
_entitiesScriptEngine(NULL),
_lastMouseEventValid(false)
_lastMouseEventValid(false),
_viewState(viewState),
_scriptingServices(scriptingServices),
_displayElementChildProxies(false),
_displayModelBounds(false),
_displayModelElementProxy(false),
_dontDoPrecisionPicking(false)
{
REGISTER_ENTITY_TYPE_WITH_FACTORY(Model, RenderableModelEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Box, RenderableBoxEntityItem::factory)
@ -76,14 +75,14 @@ void EntityTreeRenderer::init() {
entityTree->setFBXService(this);
if (_wantScripts) {
_entitiesScriptEngine = new ScriptEngine(NO_SCRIPT, "Entities",
Application::getInstance()->getControllerScriptingInterface());
Application::getInstance()->registerScriptEngineWithApplicationServices(_entitiesScriptEngine);
_entitiesScriptEngine = new ScriptEngine(NO_SCRIPT, "Entities",
_scriptingServices->getControllerScriptingInterface());
_scriptingServices->registerScriptEngineWithApplicationServices(_entitiesScriptEngine);
}
// make sure our "last avatar position" is something other than our current position, so that on our
// first chance, we'll check for enter/leave entity events.
glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition();
glm::vec3 avatarPosition = _viewState->getAvatarPosition();
_lastAvatarPosition = avatarPosition + glm::vec3(1.0f, 1.0f, 1.0f);
connect(entityTree, &EntityTree::deletingEntity, this, &EntityTreeRenderer::deletingEntity);
@ -240,7 +239,7 @@ void EntityTreeRenderer::update() {
void EntityTreeRenderer::checkEnterLeaveEntities() {
if (_tree) {
_tree->lockForWrite(); // so that our scripts can do edits if they want
glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition() / (float) TREE_SCALE;
glm::vec3 avatarPosition = _viewState->getAvatarPosition() / (float) TREE_SCALE;
if (avatarPosition != _lastAvatarPosition) {
float radius = 1.0f / (float) TREE_SCALE; // for now, assume 1 meter radius
@ -289,44 +288,38 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
}
void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
bool dontRenderAsScene = Menu::getInstance()->isOptionChecked(MenuOption::DontRenderEntitiesAsScene);
if (_tree) {
Model::startScene(renderSide);
RenderArgs args = { this, _viewFrustum, getSizeScale(), getBoundaryLevelAdjust(), renderMode, renderSide,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
_tree->lockForRead();
_tree->recurseTreeWithOperation(renderOperation, &args);
Model::RenderMode modelRenderMode = renderMode == RenderArgs::SHADOW_RENDER_MODE
? Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE;
// we must call endScene while we still have the tree locked so that no one deletes a model
// on us while rendering the scene
Model::endScene(modelRenderMode, &args);
_tree->unlock();
if (dontRenderAsScene) {
OctreeRenderer::render(renderMode, renderSide);
} else {
if (_tree) {
Model::startScene(renderSide);
RenderArgs args = { this, _viewFrustum, getSizeScale(), getBoundaryLevelAdjust(), renderMode, renderSide,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
_tree->lockForRead();
_tree->recurseTreeWithOperation(renderOperation, &args);
// stats...
_meshesConsidered = args._meshesConsidered;
_meshesRendered = args._meshesRendered;
_meshesOutOfView = args._meshesOutOfView;
_meshesTooSmall = args._meshesTooSmall;
Model::RenderMode modelRenderMode = renderMode == RenderArgs::SHADOW_RENDER_MODE
? Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE;
_elementsTouched = args._elementsTouched;
_itemsRendered = args._itemsRendered;
_itemsOutOfView = args._itemsOutOfView;
_itemsTooSmall = args._itemsTooSmall;
// we must call endScene while we still have the tree locked so that no one deletes a model
// on us while rendering the scene
Model::endScene(modelRenderMode, &args);
_tree->unlock();
// stats...
_meshesConsidered = args._meshesConsidered;
_meshesRendered = args._meshesRendered;
_meshesOutOfView = args._meshesOutOfView;
_meshesTooSmall = args._meshesTooSmall;
_materialSwitches = args._materialSwitches;
_trianglesRendered = args._trianglesRendered;
_quadsRendered = args._quadsRendered;
_elementsTouched = args._elementsTouched;
_itemsRendered = args._itemsRendered;
_itemsOutOfView = args._itemsOutOfView;
_itemsTooSmall = args._itemsTooSmall;
_materialSwitches = args._materialSwitches;
_trianglesRendered = args._trianglesRendered;
_quadsRendered = args._quadsRendered;
_translucentMeshPartsRendered = args._translucentMeshPartsRendered;
_opaqueMeshPartsRendered = args._opaqueMeshPartsRendered;
}
_translucentMeshPartsRendered = args._translucentMeshPartsRendered;
_opaqueMeshPartsRendered = args._opaqueMeshPartsRendered;
}
deleteReleasedModels(); // seems like as good as any other place to do some memory cleanup
}
@ -358,75 +351,72 @@ const Model* EntityTreeRenderer::getModelForEntityItem(const EntityItem* entityI
return result;
}
void renderElementProxy(EntityTreeElement* entityTreeElement) {
void EntityTreeRenderer::renderElementProxy(EntityTreeElement* entityTreeElement) {
glm::vec3 elementCenter = entityTreeElement->getAACube().calcCenter() * (float) TREE_SCALE;
float elementSize = entityTreeElement->getScale() * (float) TREE_SCALE;
glColor3f(1.0f, 0.0f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x, elementCenter.y, elementCenter.z);
glutWireCube(elementSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(elementSize);
glPopMatrix();
bool displayElementChildProxies = Menu::getInstance()->isOptionChecked(MenuOption::DisplayModelElementChildProxies);
if (displayElementChildProxies) {
if (_displayElementChildProxies) {
// draw the children
float halfSize = elementSize / 2.0f;
float quarterSize = elementSize / 4.0f;
glColor3f(1.0f, 1.0f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x - quarterSize, elementCenter.y - quarterSize, elementCenter.z - quarterSize);
glutWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
glPopMatrix();
glColor3f(1.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(elementCenter.x + quarterSize, elementCenter.y - quarterSize, elementCenter.z - quarterSize);
glutWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
glPopMatrix();
glColor3f(0.0f, 1.0f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x - quarterSize, elementCenter.y + quarterSize, elementCenter.z - quarterSize);
glutWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
glPopMatrix();
glColor3f(0.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(elementCenter.x - quarterSize, elementCenter.y - quarterSize, elementCenter.z + quarterSize);
glutWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
glPopMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
glPushMatrix();
glTranslatef(elementCenter.x + quarterSize, elementCenter.y + quarterSize, elementCenter.z + quarterSize);
glutWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
glPopMatrix();
glColor3f(0.0f, 0.5f, 0.5f);
glPushMatrix();
glTranslatef(elementCenter.x - quarterSize, elementCenter.y + quarterSize, elementCenter.z + quarterSize);
glutWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
glPopMatrix();
glColor3f(0.5f, 0.0f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x + quarterSize, elementCenter.y - quarterSize, elementCenter.z + quarterSize);
glutWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
glPopMatrix();
glColor3f(0.0f, 0.5f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x + quarterSize, elementCenter.y + quarterSize, elementCenter.z - quarterSize);
glutWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
glPopMatrix();
}
}
void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* args) {
bool isShadowMode = args->_renderMode == RenderArgs::SHADOW_RENDER_MODE;
bool displayModelBounds = Menu::getInstance()->isOptionChecked(MenuOption::DisplayModelBounds);
if (!isShadowMode && displayModelBounds) {
if (!isShadowMode && _displayModelBounds) {
PerformanceTimer perfTimer("renderProxies");
AACube maxCube = entity->getMaximumAACube();
@ -446,14 +436,14 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(maxCenter.x, maxCenter.y, maxCenter.z);
glutWireCube(maxCube.getScale());
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(maxCube.getScale());
glPopMatrix();
// draw the min bounding cube
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(minCenter.x, minCenter.y, minCenter.z);
glutWireCube(minCube.getScale());
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(minCube.getScale());
glPopMatrix();
// draw the entityBox bounding box
@ -461,7 +451,7 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
glPushMatrix();
glTranslatef(entityBoxCenter.x, entityBoxCenter.y, entityBoxCenter.z);
glScalef(entityBoxScale.x, entityBoxScale.y, entityBoxScale.z);
glutWireCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
glPopMatrix();
@ -479,15 +469,13 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
glutWireCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
glPopMatrix();
glPopMatrix();
}
}
void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args) {
bool wantDebug = false;
args->_elementsTouched++;
// actually render it here...
// we need to iterate the actual entityItems of the element
@ -499,11 +487,8 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
uint16_t numberOfEntities = entityItems.size();
bool isShadowMode = args->_renderMode == RenderArgs::SHADOW_RENDER_MODE;
bool displayElementProxy = Menu::getInstance()->isOptionChecked(MenuOption::DisplayModelElementProxy);
if (!isShadowMode && displayElementProxy && numberOfEntities > 0) {
if (!isShadowMode && _displayModelElementProxy && numberOfEntities > 0) {
renderElementProxy(entityTreeElement);
}
@ -520,23 +505,9 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
// when they are outside of the view frustum...
float distance = args->_viewFrustum->distanceToCamera(entityBox.calcCenter());
if (wantDebug) {
qDebug() << "------- renderElement() ----------";
qDebug() << " type:" << EntityTypes::getEntityTypeName(entityItem->getType());
if (entityItem->getType() == EntityTypes::Model) {
ModelEntityItem* modelEntity = static_cast<ModelEntityItem*>(entityItem);
qDebug() << " url:" << modelEntity->getModelURL();
}
qDebug() << " entityBox:" << entityItem->getAABox();
qDebug() << " dimensions:" << entityItem->getDimensionsInMeters() << "in meters";
qDebug() << " largestDimension:" << entityBox.getLargestDimension() << "in meters";
qDebug() << " shouldRender:" << Menu::getInstance()->shouldRenderMesh(entityBox.getLargestDimension(), distance);
qDebug() << " in frustum:" << (args->_viewFrustum->boxInFrustum(entityBox) != ViewFrustum::OUTSIDE);
}
bool outOfView = args->_viewFrustum->boxInFrustum(entityBox) == ViewFrustum::OUTSIDE;
if (!outOfView) {
bool bigEnoughToRender = Menu::getInstance()->shouldRenderMesh(entityBox.getLargestDimension(), distance);
bool bigEnoughToRender = _viewState->shouldRenderMesh(entityBox.getLargestDimension(), distance);
if (bigEnoughToRender) {
renderProxies(entityItem, args);
@ -561,11 +532,11 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
}
float EntityTreeRenderer::getSizeScale() const {
return Menu::getInstance()->getVoxelSizeScale();
return _viewState->getSizeScale();
}
int EntityTreeRenderer::getBoundaryLevelAdjust() const {
return Menu::getInstance()->getBoundaryLevelAdjust();
return _viewState->getBoundaryLevelAdjust();
}
@ -640,11 +611,6 @@ void EntityTreeRenderer::deleteReleasedModels() {
}
}
PickRay EntityTreeRenderer::computePickRay(float x, float y) {
return Application::getInstance()->getCamera()->computePickRay(x, y);
}
RayToEntityIntersectionResult EntityTreeRenderer::findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType,
bool precisionPicking) {
RayToEntityIntersectionResult result;
@ -706,9 +672,9 @@ QScriptValueList EntityTreeRenderer::createEntityArgs(const EntityItemID& entity
void EntityTreeRenderer::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
PerformanceTimer perfTimer("EntityTreeRenderer::mousePressEvent");
PickRay ray = computePickRay(event->x(), event->y());
PickRay ray = _viewState->computePickRay(event->x(), event->y());
bool precisionPicking = !Menu::getInstance()->isOptionChecked(MenuOption::DontDoPrecisionPicking);
bool precisionPicking = !_dontDoPrecisionPicking;
RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::Lock, precisionPicking);
if (rayPickResult.intersects) {
//qDebug() << "mousePressEvent over entity:" << rayPickResult.entityID;
@ -732,8 +698,8 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event, unsigned int device
void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
PerformanceTimer perfTimer("EntityTreeRenderer::mouseReleaseEvent");
PickRay ray = computePickRay(event->x(), event->y());
bool precisionPicking = !Menu::getInstance()->isOptionChecked(MenuOption::DontDoPrecisionPicking);
PickRay ray = _viewState->computePickRay(event->x(), event->y());
bool precisionPicking = !_dontDoPrecisionPicking;
RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::Lock, precisionPicking);
if (rayPickResult.intersects) {
//qDebug() << "mouseReleaseEvent over entity:" << rayPickResult.entityID;
@ -767,7 +733,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event, unsigned int devi
void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
PerformanceTimer perfTimer("EntityTreeRenderer::mouseMoveEvent");
PickRay ray = computePickRay(event->x(), event->y());
PickRay ray = _viewState->computePickRay(event->x(), event->y());
bool precisionPicking = false; // for mouse moves we do not do precision picking
RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::TryLock, precisionPicking);

View file

@ -12,21 +12,15 @@
#ifndef hifi_EntityTreeRenderer_h
#define hifi_EntityTreeRenderer_h
#include <glm/glm.hpp>
#include <stdint.h>
#include <EntityTree.h>
#include <EntityScriptingInterface.h> // for RayToEntityIntersectionResult
#include <MouseEvent.h>
#include <Model.h>
#include <Octree.h>
#include <OctreePacketData.h>
#include <OctreeRenderer.h>
#include <PacketHeaders.h>
#include <RenderArgs.h>
#include <SharedUtil.h>
#include <ViewFrustum.h>
class Model;
class ScriptEngine;
class AbstractViewStateInterface;
class AbstractScriptingServicesInterface;
class ScriptEngine;
@ -40,7 +34,8 @@ public:
class EntityTreeRenderer : public OctreeRenderer, public EntityItemFBXService {
Q_OBJECT
public:
EntityTreeRenderer(bool wantScripts);
EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState,
AbstractScriptingServicesInterface* scriptingServices);
virtual ~EntityTreeRenderer();
virtual char getMyNodeType() const { return NodeType::EntityServer; }
@ -67,8 +62,6 @@ public:
/// clears the tree
virtual void clear();
static QThread* getMainThread();
/// if a renderable entity item needs a model, we will allocate it for them
Q_INVOKABLE Model* allocateModel(const QString& url);
@ -112,17 +105,22 @@ public slots:
void entityCollisionWithVoxel(const EntityItemID& entityID, const VoxelDetail& voxel, const Collision& collision);
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
// optional slots that can be wired to menu items
void setDisplayElementChildProxies(bool value) { _displayElementChildProxies = value; }
void setDisplayModelBounds(bool value) { _displayModelBounds = value; }
void setDisplayModelElementProxy(bool value) { _displayModelElementProxy = value; }
void setDontDoPrecisionPicking(bool value) { _dontDoPrecisionPicking = value; }
protected:
virtual Octree* createTree() { return new EntityTree(true); }
private:
void renderElementProxy(EntityTreeElement* entityTreeElement);
void checkAndCallPreload(const EntityItemID& entityID);
void checkAndCallUnload(const EntityItemID& entityID);
QList<Model*> _releasedModels;
void renderProxies(const EntityItem* entity, RenderArgs* args);
PickRay computePickRay(float x, float y);
RayToEntityIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType,
bool precisionPicking);
@ -148,6 +146,13 @@ private:
bool _lastMouseEventValid;
MouseEvent _lastMouseEvent;
AbstractViewStateInterface* _viewState;
AbstractScriptingServicesInterface* _scriptingServices;
bool _displayElementChildProxies;
bool _displayModelBounds;
bool _displayModelElementProxy;
bool _dontDoPrecisionPicking;
};
#endif // hifi_EntityTreeRenderer_h

View file

@ -11,21 +11,13 @@
#include <glm/gtx/quaternion.hpp>
#include <FBXReader.h>
#include <gpu/GPUConfig.h>
#include "InterfaceConfig.h"
#include <BoxEntityItem.h>
#include <DeferredLightingEffect.h>
#include <ModelEntityItem.h>
#include <PerfStat.h>
#include "Menu.h"
#include "EntityTreeRenderer.h"
#include "RenderableBoxEntityItem.h"
EntityItem* RenderableBoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new RenderableBoxEntityItem(entityID, properties);
}

View file

@ -12,17 +12,6 @@
#ifndef hifi_RenderableBoxEntityItem_h
#define hifi_RenderableBoxEntityItem_h
#include <glm/glm.hpp>
#include <stdint.h>
#include <EntityTree.h>
#include <Octree.h>
#include <OctreePacketData.h>
#include <OctreeRenderer.h>
#include <PacketHeaders.h>
#include <SharedUtil.h>
#include <ViewFrustum.h>
#include <BoxEntityItem.h>
class RenderableBoxEntityItem : public BoxEntityItem {

View file

@ -11,21 +11,13 @@
#include <glm/gtx/quaternion.hpp>
#include <FBXReader.h>
#include "InterfaceConfig.h"
#include <gpu/GPUConfig.h>
#include <DeferredLightingEffect.h>
#include <PerfStat.h>
#include <LightEntityItem.h>
#include "Application.h"
#include "Menu.h"
#include "EntityTreeRenderer.h"
#include "RenderableLightEntityItem.h"
EntityItem* RenderableLightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new RenderableLightEntityItem(entityID, properties);
}
@ -61,17 +53,13 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
float exponent = getExponent();
float cutoff = glm::radians(getCutoff());
bool disableLights = Menu::getInstance()->isOptionChecked(MenuOption::DisableLightEntities);
if (!disableLights) {
if (_isSpotlight) {
DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation,
direction, exponent, cutoff);
} else {
DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation);
}
if (_isSpotlight) {
DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation,
direction, exponent, cutoff);
} else {
DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation);
}
#ifdef WANT_DEBUG
@ -94,10 +82,11 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,
void** intersectedObject, bool precisionPicking) const {
// TODO: this isn't really correct because we don't know if we actually live in the main tree of the applications's
// EntityTreeRenderer. But we probably do. Technically we could be on the clipboard and someone might be trying to
// use the ray intersection API there. Anyway... if you ever try to do ray intersection testing off of trees other
// than the main tree of the main entity renderer, then you'll need to fix this mechanism.
return Application::getInstance()->getEntities()->getTree()->getLightsArePickable();
// TODO: consider if this is really what we want to do. We've made it so that "lights are pickable" is a global state
// this is probably reasonable since there's typically only one tree you'd be picking on at a time. Technically we could
// be on the clipboard and someone might be trying to use the ray intersection API there. Anyway... if you ever try to
// do ray intersection testing off of trees other than the main tree of the main entity renderer, then we'll need to
// fix this mechanism.
return _lightsArePickable;
}

View file

@ -12,17 +12,6 @@
#ifndef hifi_RenderableLightEntityItem_h
#define hifi_RenderableLightEntityItem_h
#include <glm/glm.hpp>
#include <stdint.h>
#include <EntityTree.h>
#include <Octree.h>
#include <OctreePacketData.h>
#include <OctreeRenderer.h>
#include <PacketHeaders.h>
#include <SharedUtil.h>
#include <ViewFrustum.h>
#include <LightEntityItem.h>
class RenderableLightEntityItem : public LightEntityItem {

View file

@ -11,17 +11,14 @@
#include <glm/gtx/quaternion.hpp>
#include <FBXReader.h>
#include <gpu/GPUConfig.h>
#include "InterfaceConfig.h"
#include <QJsonDocument>
#include <BoxEntityItem.h>
#include <DeferredLightingEffect.h>
#include <ModelEntityItem.h>
#include <Model.h>
#include <PerfStat.h>
#include "Menu.h"
#include "EntityTreeRenderer.h"
#include "RenderableModelEntityItem.h"
@ -165,28 +162,11 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
_needsInitialSimulation = false;
}
// TODO: should we allow entityItems to have alpha on their models?
Model::RenderMode modelRenderMode = args->_renderMode == RenderArgs::SHADOW_RENDER_MODE
? Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE;
if (_model->isActive()) {
// TODO: this is the majority of model render time. And rendering of a cube model vs the basic Box render
// is significantly more expensive. Is there a way to call this that doesn't cost us as much?
PerformanceTimer perfTimer("model->render");
bool dontRenderAsScene = Menu::getInstance()->isOptionChecked(MenuOption::DontRenderEntitiesAsScene);
bool displayModelTriangles = Menu::getInstance()->isOptionChecked(MenuOption::DisplayModelTriangles);
bool rendered = false;
if (displayModelTriangles) {
rendered = _model->renderTriangleProxies();
}
if (!rendered) {
if (dontRenderAsScene) {
_model->render(alpha, modelRenderMode, args);
} else {
_model->renderInScene(alpha, args);
}
}
_model->renderInScene(alpha, args);
} else {
// if we couldn't get a model, then just draw a cube
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);

View file

@ -12,18 +12,13 @@
#ifndef hifi_RenderableModelEntityItem_h
#define hifi_RenderableModelEntityItem_h
#include <glm/glm.hpp>
#include <stdint.h>
#include <QString>
#include <QStringList>
#include <EntityTree.h>
#include <Model.h>
#include <ModelEntityItem.h>
#include <Octree.h>
#include <OctreePacketData.h>
#include <OctreeRenderer.h>
#include <PacketHeaders.h>
#include <SharedUtil.h>
#include <ViewFrustum.h>
class Model;
class EntityTreeRenderer;
class RenderableModelEntityItem : public ModelEntityItem {
public:

View file

@ -11,18 +11,12 @@
#include <glm/gtx/quaternion.hpp>
#include <FBXReader.h>
#include "InterfaceConfig.h"
#include <gpu/GPUConfig.h>
#include <DependencyManager.h>
#include <DeferredLightingEffect.h>
#include <PerfStat.h>
#include <SphereEntityItem.h>
#include "Menu.h"
#include "EntityTreeRenderer.h"
#include "RenderableSphereEntityItem.h"
EntityItem* RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {

View file

@ -12,17 +12,6 @@
#ifndef hifi_RenderableSphereEntityItem_h
#define hifi_RenderableSphereEntityItem_h
#include <glm/glm.hpp>
#include <stdint.h>
#include <EntityTree.h>
#include <Octree.h>
#include <OctreePacketData.h>
#include <OctreeRenderer.h>
#include <PacketHeaders.h>
#include <SharedUtil.h>
#include <ViewFrustum.h>
#include <SphereEntityItem.h>
class RenderableSphereEntityItem : public SphereEntityItem {

View file

@ -11,13 +11,10 @@
#include <glm/gtx/quaternion.hpp>
#include "InterfaceConfig.h"
#include <TextEntityItem.h>
#include <gpu/GPUConfig.h>
#include <PerfStat.h>
#include <TextRenderer.h>
#include "Menu.h"
#include "EntityTreeRenderer.h"
#include "RenderableTextEntityItem.h"
const int FIXED_FONT_POINT_SIZE = 40;

View file

@ -12,17 +12,6 @@
#ifndef hifi_RenderableTextEntityItem_h
#define hifi_RenderableTextEntityItem_h
#include <glm/glm.hpp>
#include <stdint.h>
#include <EntityTree.h>
#include <Octree.h>
#include <OctreePacketData.h>
#include <OctreeRenderer.h>
#include <PacketHeaders.h>
#include <SharedUtil.h>
#include <ViewFrustum.h>
#include <TextEntityItem.h>
class RenderableTextEntityItem : public TextEntityItem {

View file

@ -11,6 +11,7 @@
#include "EntityScriptingInterface.h"
#include "EntityTree.h"
#include "LightEntityItem.h"
#include "ModelEntityItem.h"
EntityScriptingInterface::EntityScriptingInterface() :
@ -226,16 +227,11 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke
}
void EntityScriptingInterface::setLightsArePickable(bool value) {
if (_entityTree) {
_entityTree->setLightsArePickable(value);
}
LightEntityItem::setLightsArePickable(value);
}
bool EntityScriptingInterface::getLightsArePickable() const {
if (_entityTree) {
return _entityTree->getLightsArePickable();
}
return false;
return LightEntityItem::getLightsArePickable();
}

View file

@ -22,7 +22,6 @@
EntityTree::EntityTree(bool shouldReaverage) :
Octree(shouldReaverage),
_fbxService(NULL),
_lightsArePickable(true),
_simulation(NULL)
{
_rootElement = createNewElement();

View file

@ -150,8 +150,6 @@ public:
void emitEntityScriptChanging(const EntityItemID& entityItemID);
bool getLightsArePickable() const { return _lightsArePickable; }
void setLightsArePickable(bool value) { _lightsArePickable = value; }
void setSimulation(EntitySimulation* simulation);
signals:
@ -180,7 +178,6 @@ private:
QHash<EntityItemID, EntityTreeElement*> _entityToElementMap;
bool _lightsArePickable;
EntitySimulation* _simulation;
};

View file

@ -18,6 +18,7 @@
#include "EntityTreeElement.h"
#include "LightEntityItem.h"
bool LightEntityItem::_lightsArePickable = false;
EntityItem* LightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new LightEntityItem(entityID, properties);

View file

@ -99,6 +99,9 @@ public:
void setCutoff(float value) { _cutoff = value; }
virtual const Shape& getCollisionShapeInMeters() const { return _emptyShape; }
static bool getLightsArePickable() { return _lightsArePickable; }
static void setLightsArePickable(bool value) { _lightsArePickable = value; }
protected:
virtual void recalculateCollisionShape() { /* nothing to do */ }
@ -116,6 +119,8 @@ protected:
// used for collision detection
SphereShape _emptyShape;
static bool _lightsArePickable;
};
#endif // hifi_LightEntityItem_h

View file

@ -9,7 +9,7 @@ link_hifi_libraries(shared networking octree voxels)
find_package(ZLIB REQUIRED)
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}")
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()

View file

@ -6,13 +6,32 @@ setup_hifi_library()
include_glm()
link_hifi_libraries(shared)
if (APPLE)
# link in required OS X frameworks and include the right GL headers
find_library(OpenGL OpenGL)
target_link_libraries(${TARGET_NAME} ${OpenGL})
else (APPLE)
elseif (WIN32)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
# we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" opengl32.lib)
# need to bubble up the GLEW_INCLUDE_DIRS
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${GLEW_INCLUDE_DIRS}")
# try to find the Nsight package and add it to the build if we find it
find_package(NSIGHT)
if (NSIGHT_FOUND)
include_directories(${NSIGHT_INCLUDE_DIRS})
add_definitions(-DNSIGHT_FOUND)
target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}")
endif ()
else ()
find_package(OpenGL REQUIRED)
if (${OPENGL_INCLUDE_DIR})
@ -21,25 +40,8 @@ else (APPLE)
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}")
# link target to external libraries
if (WIN32)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
# we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${NSIGHT_LIBRARIES}" opengl32.lib)
# try to find the Nsight package and add it to the build if we find it
find_package(NSIGHT)
if (NSIGHT_FOUND)
include_directories(${NSIGHT_INCLUDE_DIRS})
add_definitions(-DNSIGHT_FOUND)
target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}")
endif ()
endif()
# need to bubble up the OPENGL_INCLUDE_DIR
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${OPENGL_INCLUDE_DIR}")
endif (APPLE)
# call macro to link our dependencies and bubble them up via a property on our target

View file

@ -0,0 +1,25 @@
//
// GPUConfig.h
// libraries/gpu/src/gpu
//
// Created by Brad Hefta-Gaub on 12/17/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 gpu__GLUTConfig__
#define gpu__GLUTConfig__
// TODO: remove these once we migrate away from GLUT calls
#if defined(__APPLE__)
#include <GLUT/glut.h>
#elif defined(WIN32)
#include <GL/glut.h>
#else
#include <GL/glut.h>
#endif
#endif // gpu__GLUTConfig__

View file

@ -52,7 +52,8 @@ SharedObjectPointer MetavoxelClientManager::findFirstRaySpannerIntersection(cons
if (client) {
float clientDistance;
SharedObjectPointer clientSpanner = client->getDataCopy().findFirstRaySpannerIntersection(
origin, direction, attribute, clientDistance);
origin, direction, attribute, clientDistance
);
if (clientSpanner && clientDistance < closestDistance) {
closestSpanner = clientSpanner;
closestDistance = clientDistance;

View file

@ -23,7 +23,7 @@ endif ()
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
# append OpenSSL to our list of libraries to link
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}" "${TBB_LIBRARIES}")
target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES} ${TBB_LIBRARIES})
# append libcuckoo includes to our list of includes to bubble
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${TBB_INCLUDE_DIRS}")

View file

@ -332,6 +332,8 @@ int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packe
}
SharedNodePointer LimitedNodeList::nodeWithUUID(const QUuid& nodeUUID) {
QReadLocker readLocker(&_nodeMutex);
NodeHash::const_iterator it = _nodeHash.find(nodeUUID);
return it == _nodeHash.cend() ? SharedNodePointer() : it->second;
}
@ -366,14 +368,20 @@ void LimitedNodeList::reset() {
}
void LimitedNodeList::killNodeWithUUID(const QUuid& nodeUUID) {
_nodeMutex.lockForRead();
NodeHash::iterator it = _nodeHash.find(nodeUUID);
if (it != _nodeHash.end()) {
SharedNodePointer matchingNode = it->second;
_nodeMutex.unlock();
QWriteLocker writeLocker(&_nodeMutex);
_nodeHash.unsafe_erase(it);
handleNodeKill(matchingNode);
} else {
_nodeMutex.unlock();
}
}
@ -484,7 +492,7 @@ void LimitedNodeList::removeSilentNodes() {
SharedNodePointer node = it->second;
node->getMutex().lock();
if ((usecTimestampNow() - node->getLastHeardMicrostamp()) > (NODE_SILENCE_THRESHOLD_MSECS * 1000)) {
if ((usecTimestampNow() - node->getLastHeardMicrostamp()) > (NODE_SILENCE_THRESHOLD_MSECS * USECS_PER_MSEC)) {
// call the NodeHash erase to get rid of this node
it = _nodeHash.unsafe_erase(it);

View file

@ -14,6 +14,9 @@
#include "UUID.h"
// uses the same hashing performed by Qt
// https://qt.gitorious.org/qt/qtbase/source/73ef64fb5fabb60101a3cac6e43f0c5bb2298000:src/corelib/plugin/quuid.cpp
class UUIDHasher {
public:
size_t operator()(const QUuid& uuid) const {

View file

@ -13,7 +13,7 @@ find_package(ZLIB REQUIRED)
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
# append ZLIB and OpenSSL to our list of libraries to link
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}")
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()

View file

@ -6,32 +6,11 @@ setup_hifi_library(Widgets OpenGL Network Script)
include_glm()
link_hifi_libraries(shared gpu)
if (APPLE)
# link in required OS X frameworks and include the right GL headers
find_library(OpenGL OpenGL)
#target_link_libraries(${TARGET_NAME} ${OpenGL})
else (APPLE)
find_package(OpenGL REQUIRED)
if (${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
endif ()
# link target to external libraries
if (WIN32)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
find_package(GLUT REQUIRED)
include_directories(SYSTEM "${GLUT_INCLUDE_DIRS}")
# we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}")
endif()
endif (APPLE)
if (WIN32)
find_package(GLUT REQUIRED)
include_directories(SYSTEM "${GLUT_INCLUDE_DIRS}")
endif ()
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()

View file

@ -1,5 +1,5 @@
//
// ViewStateInterface.h
// AbstractViewStateInterface.h
// interface/src/renderer
//
// Created by Brad Hefta-Gaub on 12/16/14.
@ -9,16 +9,18 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_ViewStateInterface_h
#define hifi_ViewStateInterface_h
#ifndef hifi_AbstractViewStateInterface_h
#define hifi_AbstractViewStateInterface_h
#include <ViewFrustum.h>
#include <glm/glm.hpp>
class Transform;
class QThread;
class ViewFrustum;
class PickRay;
/// Interface provided by Application to other objects that need access to the current view state details
class ViewStateInterface {
class AbstractViewStateInterface {
public:
/// Returns the shadow distances for the current view state
@ -38,7 +40,12 @@ public:
virtual const Transform& getViewTransform() const = 0;
virtual void setupWorldLight() = 0;
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0;
virtual float getSizeScale() const = 0;
virtual int getBoundaryLevelAdjust() const = 0;
virtual PickRay computePickRay(float x, float y) = 0;
virtual const glm::vec3& getAvatarPosition() const = 0;
};
#endif // hifi_ViewStateInterface_h
#endif // hifi_AbstractViewStateInterface_h

View file

@ -19,6 +19,7 @@
#include <PathUtils.h>
#include <SharedUtil.h>
#include "AbstractViewStateInterface.h"
#include "AmbientOcclusionEffect.h"
#include "GlowEffect.h"
#include "ProgramObject.h"
@ -28,7 +29,7 @@
const int ROTATION_WIDTH = 4;
const int ROTATION_HEIGHT = 4;
void AmbientOcclusionEffect::init(ViewStateInterface* viewState) {
void AmbientOcclusionEffect::init(AbstractViewStateInterface* viewState) {
_viewState = viewState; // we will use this for view state services
_occlusionProgram = new ProgramObject();

View file

@ -14,8 +14,7 @@
#include <DependencyManager.h>
#include "ViewStateInterface.h"
class AbstractViewStateInterface;
class ProgramObject;
/// A screen space ambient occlusion effect. See John Chapman's tutorial at
@ -25,7 +24,7 @@ class AmbientOcclusionEffect {
public:
void init(ViewStateInterface* viewState);
void init(AbstractViewStateInterface* viewState);
void render();
private:
@ -45,7 +44,7 @@ private:
int _blurScaleLocation;
GLuint _rotationTextureID;
ViewStateInterface* _viewState;
AbstractViewStateInterface* _viewState;
};
#endif // hifi_AmbientOcclusionEffect_h

View file

@ -12,22 +12,15 @@
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
#include <gpu/GPUConfig.h>
// TODO: remove these once we migrate away from GLUT calls
#if defined(__APPLE__)
#include <GLUT/glut.h>
#elif defined(WIN32)
#include <GL/glut.h>
#else
#include <GL/glut.h>
#endif
#include <gpu/GLUTConfig.h> // TODO - we need to get rid of this ASAP
#include <QOpenGLFramebufferObject>
#include <GLMHelpers.h>
#include <PathUtils.h>
#include <ViewFrustum.h>
#include "AbstractViewStateInterface.h"
#include "DeferredLightingEffect.h"
#include "GeometryCache.h"
#include "GlowEffect.h"
@ -35,7 +28,7 @@
#include "TextureCache.h"
void DeferredLightingEffect::init(ViewStateInterface* viewState) {
void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
_viewState = viewState;
_simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/simple.vert");
_simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/simple.frag");

View file

@ -18,8 +18,8 @@
#include <SharedUtil.h>
#include "ProgramObject.h"
#include "ViewStateInterface.h"
class AbstractViewStateInterface;
class PostLightingRenderable;
/// Handles deferred lighting for the bits that require it (voxels, metavoxels...)
@ -28,7 +28,7 @@ class DeferredLightingEffect {
public:
void init(ViewStateInterface* viewState);
void init(AbstractViewStateInterface* viewState);
/// Returns a reference to a simple program suitable for rendering static
/// untextured geometry (such as that generated by glutSolidSphere, etc.)
@ -126,7 +126,7 @@ private:
QVector<SpotLight> _spotLights;
QVector<PostLightingRenderable*> _postLightingRenderables;
ViewStateInterface* _viewState;
AbstractViewStateInterface* _viewState;
};
/// Simple interface for objects that require something to be rendered after deferred lighting.

View file

@ -27,7 +27,9 @@
#include <PhysicsEntity.h>
#include <ShapeCollider.h>
#include <SphereShape.h>
#include <ViewFrustum.h>
#include "AbstractViewStateInterface.h"
#include "AnimationHandle.h"
#include "DeferredLightingEffect.h"
#include "GlowEffect.h"
@ -111,7 +113,7 @@ Model::SkinLocations Model::_skinNormalSpecularMapLocations;
Model::SkinLocations Model::_skinShadowLocations;
Model::SkinLocations Model::_skinTranslucentLocations;
ViewStateInterface* Model::_viewState = NULL;
AbstractViewStateInterface* Model::_viewState = NULL;
void Model::setScale(const glm::vec3& scale) {
setScaleInternal(scale);

View file

@ -32,8 +32,8 @@
#include "JointState.h"
#include "ProgramObject.h"
#include "TextureCache.h"
#include "ViewStateInterface.h"
class AbstractViewStateInterface;
class QScriptEngine;
class Shape;
@ -47,7 +47,7 @@ class Model : public QObject, public PhysicsEntity {
public:
static void setViewStateInterface(ViewStateInterface* viewState) { _viewState = viewState; }
static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
Model(QObject* parent = NULL);
virtual ~Model();
@ -459,7 +459,7 @@ private:
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args);
static ViewStateInterface* _viewState;
static AbstractViewStateInterface* _viewState;
};

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <gpu/GPUConfig.h>
#include <QApplication>
#include <QDesktopWidget>
#include <QFont>
@ -18,7 +20,6 @@
#include <QStringList>
#include <QWindow>
#include "InterfaceConfig.h"
#include "TextRenderer.h"
#include "glm/glm.hpp"

View file

@ -12,6 +12,8 @@
#ifndef hifi_TextRenderer_h
#define hifi_TextRenderer_h
#include <gpu/GPUConfig.h>
#include <QColor>
#include <QFont>
#include <QFontMetrics>
@ -19,11 +21,10 @@
#include <QImage>
#include <QVector>
#include "gpu/Resource.h"
#include "gpu/Stream.h"
#include <gpu/Resource.h>
#include <gpu/Stream.h>
#include "InterfaceConfig.h"
// a special "character" that renders as a solid block
const char SOLID_BLOCK_CHAR = 127;

View file

@ -0,0 +1,33 @@
//
// AbstractScriptingServicesInterface.h
// interface/src/script-engine
//
// Created by Brad Hefta-Gaub on 12/16/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_AbstractScriptingServicesInterface_h
#define hifi_AbstractScriptingServicesInterface_h
class AbstractControllerScriptingInterface;
class Transform;
class ScriptEngine;
class QThread;
/// Interface provided by Application to other objects that need access to scripting services of the application
class AbstractScriptingServicesInterface {
public:
/// Returns the controller interface for the application
virtual AbstractControllerScriptingInterface* getControllerScriptingInterface() = 0;
/// Registers application specific services with a script engine.
virtual void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine) = 0;
};
#endif // hifi_AbstractScriptingServicesInterface_h

View file

@ -12,7 +12,7 @@ find_package(ZLIB REQUIRED)
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
# add it to our list of libraries to link
list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}")
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()