Merge pull request #10718 from jherico/frame_thread

Cleanup and refactoring
This commit is contained in:
Brad Davis 2017-06-19 13:31:44 -07:00 committed by GitHub
commit ed6620fc51
113 changed files with 553 additions and 616 deletions

View file

@ -23,7 +23,6 @@
#include <EntityEditPacketSender.h> #include <EntityEditPacketSender.h>
#include <EntityTree.h> #include <EntityTree.h>
#include <EntityTreeHeadlessViewer.h>
#include <ScriptEngine.h> #include <ScriptEngine.h>
#include <ThreadedAssignment.h> #include <ThreadedAssignment.h>
@ -31,6 +30,7 @@
#include "AudioGate.h" #include "AudioGate.h"
#include "MixedAudioStream.h" #include "MixedAudioStream.h"
#include "entities/EntityTreeHeadlessViewer.h"
#include "avatars/ScriptableAvatar.h" #include "avatars/ScriptableAvatar.h"
class Agent : public ThreadedAssignment { class Agent : public ThreadedAssignment {

View file

@ -16,9 +16,9 @@
#include <SharedUtil.h> #include <SharedUtil.h>
#include <Octree.h> #include <Octree.h>
#include <OctreePacketData.h> #include <OctreePacketData.h>
#include <OctreeHeadlessViewer.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include "../octree/OctreeHeadlessViewer.h"
#include "EntityTree.h" #include "EntityTree.h"
class EntitySimulation; class EntitySimulation;

View file

@ -9,17 +9,14 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <NodeList.h>
#include "OctreeLogging.h"
#include "OctreeHeadlessViewer.h" #include "OctreeHeadlessViewer.h"
OctreeHeadlessViewer::OctreeHeadlessViewer() : OctreeRenderer() { #include <NodeList.h>
_viewFrustum.setProjection(glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), DEFAULT_ASPECT_RATIO, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); #include <OctreeLogging.h>
}
void OctreeHeadlessViewer::init() {
OctreeRenderer::init(); OctreeHeadlessViewer::OctreeHeadlessViewer() {
_viewFrustum.setProjection(glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), DEFAULT_ASPECT_RATIO, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
} }
void OctreeHeadlessViewer::queryOctree() { void OctreeHeadlessViewer::queryOctree() {

View file

@ -12,28 +12,17 @@
#ifndef hifi_OctreeHeadlessViewer_h #ifndef hifi_OctreeHeadlessViewer_h
#define hifi_OctreeHeadlessViewer_h #define hifi_OctreeHeadlessViewer_h
#include <udt/PacketHeaders.h> #include <OctreeProcessor.h>
#include <SharedUtil.h> #include <JurisdictionListener.h>
#include <ViewFrustum.h> #include <OctreeQuery.h>
#include "JurisdictionListener.h"
#include "Octree.h"
#include "OctreeConstants.h"
#include "OctreeQuery.h"
#include "OctreeRenderer.h"
#include "OctreeSceneStats.h"
#include "Octree.h"
// Generic client side Octree renderer class. // Generic client side Octree renderer class.
class OctreeHeadlessViewer : public OctreeRenderer { class OctreeHeadlessViewer : public OctreeProcessor {
Q_OBJECT Q_OBJECT
public: public:
OctreeHeadlessViewer(); OctreeHeadlessViewer();
virtual ~OctreeHeadlessViewer() {}; virtual ~OctreeHeadlessViewer() {};
virtual void renderElement(OctreeElementPointer element, RenderArgs* args) override { /* swallow these */ }
virtual void init() override ;
virtual void render(RenderArgs* renderArgs) override { /* swallow these */ }
void setJurisdictionListener(JurisdictionListener* jurisdictionListener) { _jurisdictionListener = jurisdictionListener; } void setJurisdictionListener(JurisdictionListener* jurisdictionListener) { _jurisdictionListener = jurisdictionListener; }
@ -71,6 +60,7 @@ private:
JurisdictionListener* _jurisdictionListener = nullptr; JurisdictionListener* _jurisdictionListener = nullptr;
OctreeQuery _octreeQuery; OctreeQuery _octreeQuery;
ViewFrustum _viewFrustum;
float _voxelSizeScale { DEFAULT_OCTREE_SIZE_SCALE }; float _voxelSizeScale { DEFAULT_OCTREE_SIZE_SCALE };
int _boundaryLevelAdjust { 0 }; int _boundaryLevelAdjust { 0 };
int _maxPacketsPerSecond { DEFAULT_MAX_OCTREE_PPS }; int _maxPacketsPerSecond { DEFAULT_MAX_OCTREE_PPS };

View file

@ -19,10 +19,10 @@
#include <QtCore/QUuid> #include <QtCore/QUuid>
#include <EntityEditPacketSender.h> #include <EntityEditPacketSender.h>
#include <EntityTreeHeadlessViewer.h>
#include <plugins/CodecPlugin.h> #include <plugins/CodecPlugin.h>
#include <ScriptEngine.h> #include <ScriptEngine.h>
#include <ThreadedAssignment.h> #include <ThreadedAssignment.h>
#include "../entities/EntityTreeHeadlessViewer.h"
class EntityScriptServer : public ThreadedAssignment { class EntityScriptServer : public ThreadedAssignment {
Q_OBJECT Q_OBJECT

View file

@ -7,16 +7,18 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
# #
macro(LINK_HIFI_LIBRARIES) function(LINK_HIFI_LIBRARIES)
file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}") file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}")
set(LIBRARIES_TO_LINK ${ARGN}) set(LIBRARIES_TO_LINK ${ARGN})
foreach(HIFI_LIBRARY ${LIBRARIES_TO_LINK})
foreach(HIFI_LIBRARY ${LIBRARIES_TO_LINK})
if (NOT TARGET ${HIFI_LIBRARY}) if (NOT TARGET ${HIFI_LIBRARY})
add_subdirectory("${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}" "${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}") add_subdirectory("${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}" "${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}")
endif () endif ()
endforeach()
foreach(HIFI_LIBRARY ${LIBRARIES_TO_LINK})
include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src") include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src")
include_directories("${CMAKE_BINARY_DIR}/libraries/${HIFI_LIBRARY}/shaders") include_directories("${CMAKE_BINARY_DIR}/libraries/${HIFI_LIBRARY}/shaders")
@ -29,4 +31,4 @@ macro(LINK_HIFI_LIBRARIES)
setup_memory_debugger() setup_memory_debugger()
endmacro(LINK_HIFI_LIBRARIES) endfunction()

View file

@ -580,7 +580,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
_undoStackScriptingInterface(&_undoStack), _undoStackScriptingInterface(&_undoStack),
_entitySimulation(new PhysicalEntitySimulation()), _entitySimulation(new PhysicalEntitySimulation()),
_physicsEngine(new PhysicsEngine(Vectors::ZERO)), _physicsEngine(new PhysicsEngine(Vectors::ZERO)),
_entityClipboardRenderer(false, this, this),
_entityClipboard(new EntityTree()), _entityClipboard(new EntityTree()),
_lastQueriedTime(usecTimestampNow()), _lastQueriedTime(usecTimestampNow()),
_previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION),
@ -3987,11 +3986,6 @@ void Application::init() {
DependencyManager::get<NodeList>()->sendDomainServerCheckIn(); DependencyManager::get<NodeList>()->sendDomainServerCheckIn();
getEntities()->init(); getEntities()->init();
{
QMutexLocker viewLocker(&_viewMutex);
getEntities()->setViewFrustum(_viewFrustum);
}
getEntities()->setEntityLoadingPriorityFunction([this](const EntityItem& item) { getEntities()->setEntityLoadingPriorityFunction([this](const EntityItem& item) {
auto dims = item.getDimensions(); auto dims = item.getDimensions();
auto maxSize = glm::compMax(dims); auto maxSize = glm::compMax(dims);
@ -4021,13 +4015,6 @@ void Application::init() {
// of events related clicking, hovering over, and entering entities // of events related clicking, hovering over, and entering entities
getEntities()->connectSignalsToSlots(entityScriptingInterface.data()); getEntities()->connectSignalsToSlots(entityScriptingInterface.data());
_entityClipboardRenderer.init();
{
QMutexLocker viewLocker(&_viewMutex);
_entityClipboardRenderer.setViewFrustum(_viewFrustum);
}
_entityClipboardRenderer.setTree(_entityClipboard);
// Make sure any new sounds are loaded as soon as know about them. // Make sure any new sounds are loaded as soon as know about them.
connect(tree.get(), &EntityTree::newCollisionSoundURL, this, [this](QUrl newURL, EntityItemID id) { connect(tree.get(), &EntityTree::newCollisionSoundURL, this, [this](QUrl newURL, EntityItemID id) {
EntityTreePointer tree = getEntities()->getTree(); EntityTreePointer tree = getEntities()->getTree();
@ -5020,9 +5007,6 @@ QRect Application::getDesirableApplicationGeometry() const {
return applicationGeometry; return applicationGeometry;
} }
// FIXME, preprocessor guard this check to occur only in DEBUG builds
static QThread * activeRenderingThread = nullptr;
PickRay Application::computePickRay(float x, float y) const { PickRay Application::computePickRay(float x, float y) const {
vec2 pickPoint { x, y }; vec2 pickPoint { x, y };
PickRay result; PickRay result;
@ -5093,7 +5077,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
auto myAvatar = getMyAvatar(); auto myAvatar = getMyAvatar();
myAvatar->preDisplaySide(renderArgs); myAvatar->preDisplaySide(renderArgs);
activeRenderingThread = QThread::currentThread();
PROFILE_RANGE(render, __FUNCTION__); PROFILE_RANGE(render, __FUNCTION__);
PerformanceTimer perfTimer("display"); PerformanceTimer perfTimer("display");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
@ -5166,8 +5149,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
// Before the deferred pass, let's try to use the render engine // Before the deferred pass, let's try to use the render engine
_renderEngine->run(); _renderEngine->run();
} }
activeRenderingThread = nullptr;
} }
void Application::resetSensors(bool andReload) { void Application::resetSensors(bool andReload) {

View file

@ -181,7 +181,6 @@ public:
QUndoStack* getUndoStack() { return &_undoStack; } QUndoStack* getUndoStack() { return &_undoStack; }
MainWindow* getWindow() const { return _window; } MainWindow* getWindow() const { return _window; }
EntityTreePointer getEntityClipboard() const { return _entityClipboard; } EntityTreePointer getEntityClipboard() const { return _entityClipboard; }
EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; }
EntityEditPacketSender* getEntityEditPacketSender() { return &_entityEditSender; } EntityEditPacketSender* getEntityEditPacketSender() { return &_entityEditSender; }
ivec2 getMouse() const; ivec2 getMouse() const;
@ -532,7 +531,6 @@ private:
PhysicalEntitySimulationPointer _entitySimulation; PhysicalEntitySimulationPointer _entitySimulation;
PhysicsEnginePointer _physicsEngine; PhysicsEnginePointer _physicsEngine;
EntityTreeRenderer _entityClipboardRenderer;
EntityTreePointer _entityClipboard; EntityTreePointer _entityClipboard;
mutable QMutex _viewMutex { QMutex::Recursive }; mutable QMutex _viewMutex { QMutex::Recursive };

View file

@ -17,6 +17,7 @@
#include <OctreeConstants.h> #include <OctreeConstants.h>
#include <PIDController.h> #include <PIDController.h>
#include <SimpleMovingAverage.h> #include <SimpleMovingAverage.h>
#include <render/Args.h>
const float DEFAULT_DESKTOP_LOD_DOWN_FPS = 20.0; const float DEFAULT_DESKTOP_LOD_DOWN_FPS = 20.0;
const float DEFAULT_HMD_LOD_DOWN_FPS = 20.0; const float DEFAULT_HMD_LOD_DOWN_FPS = 20.0;
@ -45,7 +46,6 @@ const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE;
// This controls how low the auto-adjust LOD will go. We want a minimum vision of ~20:500 or 0.04 of default // This controls how low the auto-adjust LOD will go. We want a minimum vision of ~20:500 or 0.04 of default
const float ADJUST_LOD_MIN_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE * 0.04f; const float ADJUST_LOD_MIN_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE * 0.04f;
class RenderArgs;
class AABox; class AABox;
class LODManager : public QObject, public Dependency { class LODManager : public QObject, public Dependency {

View file

@ -19,7 +19,6 @@
#include <DependencyManager.h> #include <DependencyManager.h>
#include <gpu/Batch.h> #include <gpu/Batch.h>
#include <RenderArgs.h>
class AudioScope : public QObject, public Dependency { class AudioScope : public QObject, public Dependency {

View file

@ -152,9 +152,13 @@ void MenuScriptingInterface::closeInfoView(const QString& path) {
} }
bool MenuScriptingInterface::isInfoViewVisible(const QString& path) { bool MenuScriptingInterface::isInfoViewVisible(const QString& path) {
if (QThread::currentThread() == qApp->thread()) {
return Menu::getInstance()->isInfoViewVisible(path);
}
bool result; bool result;
QMetaObject::invokeMethod(Menu::getInstance(), "isInfoViewVisible", Qt::BlockingQueuedConnection, QMetaObject::invokeMethod(Menu::getInstance(), "isInfoViewVisible", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, result), Q_ARG(const QString&, path)); Q_RETURN_ARG(bool, result), Q_ARG(const QString&, path));
return result; return result;
} }

View file

@ -16,6 +16,7 @@
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <glm/gtx/vector_angle.hpp> #include <glm/gtx/vector_angle.hpp>
#include <render/Args.h>
#include <avatar/AvatarManager.h> #include <avatar/AvatarManager.h>
#include <Application.h> #include <Application.h>
#include <AudioClient.h> #include <AudioClient.h>
@ -33,6 +34,7 @@
#include "SequenceNumberStats.h" #include "SequenceNumberStats.h"
#include "StatTracker.h" #include "StatTracker.h"
HIFI_QML_DEF(Stats) HIFI_QML_DEF(Stats)
using namespace std; using namespace std;
@ -454,7 +456,7 @@ void Stats::updateStats(bool force) {
} }
} }
void Stats::setRenderDetails(const RenderDetails& details) { void Stats::setRenderDetails(const render::RenderDetails& details) {
STAT_UPDATE(triangles, details._trianglesRendered); STAT_UPDATE(triangles, details._trianglesRendered);
STAT_UPDATE(materialSwitches, details._materialSwitches); STAT_UPDATE(materialSwitches, details._materialSwitches);
if (_expanded) { if (_expanded) {

View file

@ -9,10 +9,11 @@
#ifndef hifi_Stats_h #ifndef hifi_Stats_h
#define hifi_Stats_h #define hifi_Stats_h
#include <QtGui/QVector3D>
#include <OffscreenQmlElement.h> #include <OffscreenQmlElement.h>
#include <RenderArgs.h>
#include <QVector3D>
#include <AudioIOStats.h> #include <AudioIOStats.h>
#include <render/Args.h>
#define STATS_PROPERTY(type, name, initialValue) \ #define STATS_PROPERTY(type, name, initialValue) \
Q_PROPERTY(type name READ name NOTIFY name##Changed) \ Q_PROPERTY(type name READ name NOTIFY name##Changed) \
@ -138,7 +139,7 @@ public:
Stats(QQuickItem* parent = nullptr); Stats(QQuickItem* parent = nullptr);
bool includeTimingRecord(const QString& name); bool includeTimingRecord(const QString& name);
void setRenderDetails(const RenderDetails& details); void setRenderDetails(const render::RenderDetails& details);
const QString& monospaceFont() { const QString& monospaceFont() {
return _monospaceFont; return _monospaceFont;
} }

View file

@ -112,7 +112,7 @@ void Image3DOverlay::render(RenderArgs* args) {
_geometryId _geometryId
); );
batch->setResourceTexture(0, args->_whiteTexture); // restore default white color after me batch->setResourceTexture(0, nullptr); // restore default white color after me
} }
const render::ShapeKey Image3DOverlay::getShapeKey() { const render::ShapeKey Image3DOverlay::getShapeKey() {

View file

@ -1,50 +0,0 @@
//
// LocalModelsOverlay.cpp
// interface/src/ui/overlays
//
// Created by Ryan Huffman on 07/08/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 "LocalModelsOverlay.h"
#include <EntityTreeRenderer.h>
#include <gpu/Batch.h>
QString const LocalModelsOverlay::TYPE = "localmodels";
LocalModelsOverlay::LocalModelsOverlay(EntityTreeRenderer* entityTreeRenderer) :
Volume3DOverlay(),
_entityTreeRenderer(entityTreeRenderer) {
}
LocalModelsOverlay::LocalModelsOverlay(const LocalModelsOverlay* localModelsOverlay) :
Volume3DOverlay(localModelsOverlay),
_entityTreeRenderer(localModelsOverlay->_entityTreeRenderer)
{
}
void LocalModelsOverlay::update(float deltatime) {
_entityTreeRenderer->update();
}
void LocalModelsOverlay::render(RenderArgs* args) {
if (_visible) {
auto batch = args ->_batch;
Transform transform = Transform();
transform.setTranslation(args->getViewFrustum().getPosition() + getPosition());
batch->setViewTransform(transform);
_entityTreeRenderer->render(args);
transform.setTranslation(args->getViewFrustum().getPosition());
batch->setViewTransform(transform);
}
}
LocalModelsOverlay* LocalModelsOverlay::createClone() const {
return new LocalModelsOverlay(this);
}

View file

@ -1,37 +0,0 @@
//
// LocalModelsOverlay.h
// interface/src/ui/overlays
//
// Created by Ryan Huffman on 07/08/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_LocalModelsOverlay_h
#define hifi_LocalModelsOverlay_h
#include "Volume3DOverlay.h"
class EntityTreeRenderer;
class LocalModelsOverlay : public Volume3DOverlay {
Q_OBJECT
public:
static QString const TYPE;
virtual QString getType() const override { return TYPE; }
LocalModelsOverlay(EntityTreeRenderer* entityTreeRenderer);
LocalModelsOverlay(const LocalModelsOverlay* localModelsOverlay);
virtual void update(float deltatime) override;
virtual void render(RenderArgs* args) override;
virtual LocalModelsOverlay* createClone() const override;
private:
EntityTreeRenderer* _entityTreeRenderer;
};
#endif // hifi_LocalModelsOverlay_h

View file

@ -26,7 +26,6 @@
#include "Shape3DOverlay.h" #include "Shape3DOverlay.h"
#include "ImageOverlay.h" #include "ImageOverlay.h"
#include "Line3DOverlay.h" #include "Line3DOverlay.h"
#include "LocalModelsOverlay.h"
#include "ModelOverlay.h" #include "ModelOverlay.h"
#include "Rectangle3DOverlay.h" #include "Rectangle3DOverlay.h"
#include "Sphere3DOverlay.h" #include "Sphere3DOverlay.h"
@ -171,8 +170,6 @@ OverlayID Overlays::addOverlay(const QString& type, const QVariant& properties)
thisOverlay = std::make_shared<Line3DOverlay>(); thisOverlay = std::make_shared<Line3DOverlay>();
} else if (type == Grid3DOverlay::TYPE) { } else if (type == Grid3DOverlay::TYPE) {
thisOverlay = std::make_shared<Grid3DOverlay>(); thisOverlay = std::make_shared<Grid3DOverlay>();
} else if (type == LocalModelsOverlay::TYPE) {
thisOverlay = std::make_shared<LocalModelsOverlay>(qApp->getEntityClipboardRenderer());
} else if (type == ModelOverlay::TYPE) { } else if (type == ModelOverlay::TYPE) {
thisOverlay = std::make_shared<ModelOverlay>(); thisOverlay = std::make_shared<ModelOverlay>();
} else if (type == Web3DOverlay::TYPE) { } else if (type == Web3DOverlay::TYPE) {

View file

@ -21,7 +21,6 @@
#include "Cube3DOverlay.h" #include "Cube3DOverlay.h"
#include "ImageOverlay.h" #include "ImageOverlay.h"
#include "Line3DOverlay.h" #include "Line3DOverlay.h"
#include "LocalModelsOverlay.h"
#include "ModelOverlay.h" #include "ModelOverlay.h"
#include "Overlays.h" #include "Overlays.h"
#include "Rectangle3DOverlay.h" #include "Rectangle3DOverlay.h"

View file

@ -318,7 +318,7 @@ void Web3DOverlay::render(RenderArgs* args) {
geometryCache->bindOpaqueWebBrowserProgram(batch, _isAA); geometryCache->bindOpaqueWebBrowserProgram(batch, _isAA);
} }
geometryCache->renderQuad(batch, halfSize * -1.0f, halfSize, vec2(0), vec2(1), color, _geometryId); geometryCache->renderQuad(batch, halfSize * -1.0f, halfSize, vec2(0), vec2(1), color, _geometryId);
batch.setResourceTexture(0, args->_whiteTexture); // restore default white color after me batch.setResourceTexture(0, nullptr); // restore default white color after me
} }
const render::ShapeKey Web3DOverlay::getShapeKey() { const render::ShapeKey Web3DOverlay::getShapeKey() {

View file

@ -1,5 +1,7 @@
set(TARGET_NAME animation) set(TARGET_NAME animation)
setup_hifi_library(Network Script) setup_hifi_library(Network Script)
link_hifi_libraries(shared model fbx) link_hifi_libraries(shared model fbx)
include_hifi_library_headers(networking)
include_hifi_library_headers(gpu)
target_nsight() target_nsight()

View file

@ -1,6 +1,8 @@
set(TARGET_NAME audio-client) set(TARGET_NAME audio-client)
setup_hifi_library(Network Multimedia) setup_hifi_library(Network Multimedia)
link_hifi_libraries(audio plugins) link_hifi_libraries(audio plugins)
include_hifi_library_headers(shared)
include_hifi_library_headers(networking)
# append audio includes to our list of includes to bubble # append audio includes to our list of includes to bubble
target_include_directories(${TARGET_NAME} PUBLIC "${HIFI_LIBRARY_DIR}/audio/src") target_include_directories(${TARGET_NAME} PUBLIC "${HIFI_LIBRARY_DIR}/audio/src")

View file

@ -2,5 +2,17 @@ set(TARGET_NAME avatars-renderer)
AUTOSCRIBE_SHADER_LIB(gpu model render render-utils) AUTOSCRIBE_SHADER_LIB(gpu model render render-utils)
setup_hifi_library(Widgets Network Script) setup_hifi_library(Widgets Network Script)
link_hifi_libraries(shared gpu model animation model-networking script-engine render image render-utils) link_hifi_libraries(shared gpu model animation model-networking script-engine render image render-utils)
include_hifi_library_headers(avatars)
include_hifi_library_headers(networking)
include_hifi_library_headers(fbx)
include_hifi_library_headers(recording)
include_hifi_library_headers(trackers)
include_hifi_library_headers(ktx)
include_hifi_library_headers(procedural)
include_hifi_library_headers(physics)
include_hifi_library_headers(entities-renderer)
include_hifi_library_headers(audio)
include_hifi_library_headers(entities)
include_hifi_library_headers(octree)
target_bullet() target_bullet()

View file

@ -5,6 +5,7 @@ setup_hifi_library(Script Qml)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules # use setup_hifi_library macro to setup our project and link appropriate Qt modules
link_hifi_libraries(shared) link_hifi_libraries(shared)
include_hifi_library_headers(networking)
GroupSources("src/controllers") GroupSources("src/controllers")

View file

@ -2,6 +2,14 @@ set(TARGET_NAME display-plugins)
AUTOSCRIBE_SHADER_LIB(gpu display-plugins) AUTOSCRIBE_SHADER_LIB(gpu display-plugins)
setup_hifi_library(OpenGL) setup_hifi_library(OpenGL)
link_hifi_libraries(shared plugins ui-plugins gl gpu-gl ui render-utils) link_hifi_libraries(shared plugins ui-plugins gl gpu-gl ui render-utils)
include_hifi_library_headers(gpu)
include_hifi_library_headers(model-networking)
include_hifi_library_headers(networking)
include_hifi_library_headers(model)
include_hifi_library_headers(fbx)
include_hifi_library_headers(image)
include_hifi_library_headers(ktx)
include_hifi_library_headers(render)
target_opengl() target_opengl()

View file

@ -10,7 +10,6 @@
#include <QtCore/QProcessEnvironment> #include <QtCore/QProcessEnvironment>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <controllers/Pose.h>
#include <gpu/Frame.h> #include <gpu/Frame.h>
const QString DebugHmdDisplayPlugin::NAME("HMD Simulator"); const QString DebugHmdDisplayPlugin::NAME("HMD Simulator");

View file

@ -2,6 +2,16 @@ set(TARGET_NAME entities-renderer)
AUTOSCRIBE_SHADER_LIB(gpu model procedural render render-utils) AUTOSCRIBE_SHADER_LIB(gpu model procedural render render-utils)
setup_hifi_library(Widgets Network Script) setup_hifi_library(Widgets Network Script)
link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils image) link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils image)
include_hifi_library_headers(networking)
include_hifi_library_headers(gl)
include_hifi_library_headers(ktx)
include_hifi_library_headers(octree)
include_hifi_library_headers(audio)
include_hifi_library_headers(physics)
include_hifi_library_headers(animation)
include_hifi_library_headers(fbx)
include_hifi_library_headers(entities)
include_hifi_library_headers(avatars)
target_bullet() target_bullet()

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "EntityTreeRenderer.h"
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <QEventLoop> #include <QEventLoop>
@ -24,7 +26,6 @@
#include <SceneScriptingInterface.h> #include <SceneScriptingInterface.h>
#include <ScriptEngine.h> #include <ScriptEngine.h>
#include "EntityTreeRenderer.h"
#include "RenderableEntityItem.h" #include "RenderableEntityItem.h"
@ -130,7 +131,12 @@ void EntityTreeRenderer::clear() {
if (scene) { if (scene) {
render::Transaction transaction; render::Transaction transaction;
foreach(auto entity, _entitiesInScene) { foreach(auto entity, _entitiesInScene) {
entity->removeFromScene(entity, scene, transaction); auto renderable = entity->getRenderableInterface();
if (!renderable) {
qCWarning(entitiesrenderer) << "EntityTreeRenderer::deletingEntity(), trying to remove non-renderable entity";
continue;
}
renderable->removeFromScene(entity, scene, transaction);
} }
scene->enqueueTransaction(transaction); scene->enqueueTransaction(transaction);
} else { } else {
@ -141,7 +147,7 @@ void EntityTreeRenderer::clear() {
// reset the zone to the default (while we load the next scene) // reset the zone to the default (while we load the next scene)
_layeredZones.clear(); _layeredZones.clear();
OctreeRenderer::clear(); OctreeProcessor::clear();
} }
void EntityTreeRenderer::reloadEntityScripts() { void EntityTreeRenderer::reloadEntityScripts() {
@ -155,7 +161,7 @@ void EntityTreeRenderer::reloadEntityScripts() {
} }
void EntityTreeRenderer::init() { void EntityTreeRenderer::init() {
OctreeRenderer::init(); OctreeProcessor::init();
EntityTreePointer entityTree = std::static_pointer_cast<EntityTree>(_tree); EntityTreePointer entityTree = std::static_pointer_cast<EntityTree>(_tree);
entityTree->setFBXService(this); entityTree->setFBXService(this);
@ -181,7 +187,7 @@ void EntityTreeRenderer::shutdown() {
} }
void EntityTreeRenderer::setTree(OctreePointer newTree) { void EntityTreeRenderer::setTree(OctreePointer newTree) {
OctreeRenderer::setTree(newTree); OctreeProcessor::setTree(newTree);
std::static_pointer_cast<EntityTree>(_tree)->setFBXService(this); std::static_pointer_cast<EntityTree>(_tree)->setFBXService(this);
} }
@ -791,24 +797,33 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) {
} }
void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) { void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) {
if (!_entitiesInScene.contains(entityID)) {
return;
}
if (_tree && !_shuttingDown && _entitiesScriptEngine) { if (_tree && !_shuttingDown && _entitiesScriptEngine) {
_entitiesScriptEngine->unloadEntityScript(entityID, true); _entitiesScriptEngine->unloadEntityScript(entityID, true);
} }
auto scene = _viewState->getMain3DScene();
if (!scene) {
qCWarning(entitiesrenderer) << "EntityTreeRenderer::deletingEntity(), Unexpected null scene, possibly during application shutdown";
return;
}
auto entity = _entitiesInScene.take(entityID);
auto renderable = entity->getRenderableInterface();
if (!renderable) {
qCWarning(entitiesrenderer) << "EntityTreeRenderer::deletingEntity(), trying to remove non-renderable entity";
return;
}
forceRecheckEntities(); // reset our state to force checking our inside/outsideness of entities forceRecheckEntities(); // reset our state to force checking our inside/outsideness of entities
// here's where we remove the entity payload from the scene // here's where we remove the entity payload from the scene
if (_entitiesInScene.contains(entityID)) { render::Transaction transaction;
auto entity = _entitiesInScene.take(entityID); renderable->removeFromScene(entity, scene, transaction);
render::Transaction transaction; scene->enqueueTransaction(transaction);
auto scene = _viewState->getMain3DScene();
if (scene) {
entity->removeFromScene(entity, scene, transaction);
scene->enqueueTransaction(transaction);
} else {
qCWarning(entitiesrenderer) << "EntityTreeRenderer::deletingEntity(), Unexpected null scene, possibly during application shutdown";
}
}
} }
void EntityTreeRenderer::addingEntity(const EntityItemID& entityID) { void EntityTreeRenderer::addingEntity(const EntityItemID& entityID) {
@ -820,18 +835,25 @@ void EntityTreeRenderer::addingEntity(const EntityItemID& entityID) {
} }
} }
void EntityTreeRenderer::addEntityToScene(EntityItemPointer entity) { void EntityTreeRenderer::addEntityToScene(const EntityItemPointer& entity) {
// here's where we add the entity payload to the scene // here's where we add the entity payload to the scene
render::Transaction transaction;
auto scene = _viewState->getMain3DScene(); auto scene = _viewState->getMain3DScene();
if (scene) { if (!scene) {
if (entity->addToScene(entity, scene, transaction)) {
_entitiesInScene.insert(entity->getEntityItemID(), entity);
}
scene->enqueueTransaction(transaction);
} else {
qCWarning(entitiesrenderer) << "EntityTreeRenderer::addEntityToScene(), Unexpected null scene, possibly during application shutdown"; qCWarning(entitiesrenderer) << "EntityTreeRenderer::addEntityToScene(), Unexpected null scene, possibly during application shutdown";
return;
} }
auto renderable = entity->getRenderableInterface();
if (!renderable) {
qCWarning(entitiesrenderer) << "EntityTreeRenderer::addEntityToScene(), Unexpected non-renderable entity";
return;
}
render::Transaction transaction;
if (renderable->addToScene(entity, scene, transaction)) {
_entitiesInScene.insert(entity->getEntityItemID(), entity);
}
scene->enqueueTransaction(transaction);
} }
@ -1050,3 +1072,4 @@ bool EntityTreeRenderer::LayeredZones::contains(const LayeredZones& other) {
} }
return result; return result;
} }

View file

@ -20,9 +20,10 @@
#include <EntityTree.h> #include <EntityTree.h>
#include <QMouseEvent> #include <QMouseEvent>
#include <PointerEvent.h> #include <PointerEvent.h>
#include <OctreeRenderer.h>
#include <ScriptCache.h> #include <ScriptCache.h>
#include <TextureCache.h> #include <TextureCache.h>
#include <OctreeProcessor.h>
#include <render/Forward.h>
class AbstractScriptingServicesInterface; class AbstractScriptingServicesInterface;
class AbstractViewStateInterface; class AbstractViewStateInterface;
@ -38,7 +39,7 @@ using ModelWeakPointer = std::weak_ptr<Model>;
using CalculateEntityLoadingPriority = std::function<float(const EntityItem& item)>; using CalculateEntityLoadingPriority = std::function<float(const EntityItem& item)>;
// Generic client side Octree renderer class. // Generic client side Octree renderer class.
class EntityTreeRenderer : public OctreeRenderer, public EntityItemFBXService, public Dependency { class EntityTreeRenderer : public OctreeProcessor, public EntityItemFBXService, public Dependency {
Q_OBJECT Q_OBJECT
public: public:
EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState, EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState,
@ -144,7 +145,7 @@ protected:
private: private:
void resetEntitiesScriptEngine(); void resetEntitiesScriptEngine();
void addEntityToScene(EntityItemPointer entity); void addEntityToScene(const EntityItemPointer& entity);
bool findBestZoneAndMaybeContainingEntities(QVector<EntityItemID>* entitiesContainingAvatar = nullptr); bool findBestZoneAndMaybeContainingEntities(QVector<EntityItemID>* entitiesContainingAvatar = nullptr);
bool applyLayeredZones(); bool applyLayeredZones();

View file

@ -40,7 +40,7 @@ namespace render {
template <> void payloadRender(const RenderableEntityItemProxy::Pointer& payload, RenderArgs* args) { template <> void payloadRender(const RenderableEntityItemProxy::Pointer& payload, RenderArgs* args) {
if (args) { if (args) {
if (payload && payload->_entity && payload->_entity->getVisible()) { if (payload && payload->_entity && payload->_entity->getVisible()) {
payload->_entity->render(args); payload->_entity->getRenderableInterface()->render(args);
} }
} }
} }

View file

@ -34,13 +34,23 @@ enum class RenderItemStatusIcon {
void makeEntityItemStatusGetters(EntityItemPointer entity, render::Item::Status::Getters& statusGetters); void makeEntityItemStatusGetters(EntityItemPointer entity, render::Item::Status::Getters& statusGetters);
// Renderable entity item interface
class RenderableEntityInterface {
public:
virtual void render(RenderArgs* args) {};
virtual bool addToScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) = 0;
virtual void removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) = 0;
virtual RenderableEntityInterface* getRenderableInterface() { return nullptr; }
};
class RenderableEntityItemProxy { class RenderableEntityItemProxy {
public: public:
RenderableEntityItemProxy(EntityItemPointer entity, render::ItemID metaID) : _entity(entity), _metaID(metaID) { } RenderableEntityItemProxy(const EntityItemPointer& entity, render::ItemID metaID)
: _entity(entity), _metaID(metaID) {}
typedef render::Payload<RenderableEntityItemProxy> Payload; typedef render::Payload<RenderableEntityItemProxy> Payload;
typedef Payload::DataPointer Pointer; typedef Payload::DataPointer Pointer;
EntityItemPointer _entity; const EntityItemPointer _entity;
render::ItemID _metaID; render::ItemID _metaID;
}; };
@ -51,10 +61,11 @@ namespace render {
template <> uint32_t metaFetchMetaSubItems(const RenderableEntityItemProxy::Pointer& payload, ItemIDs& subItems); template <> uint32_t metaFetchMetaSubItems(const RenderableEntityItemProxy::Pointer& payload, ItemIDs& subItems);
} }
// Mixin class for implementing basic single item rendering // Mixin class for implementing basic single item rendering
class SimpleRenderableEntityItem { class SimplerRenderableEntitySupport : public RenderableEntityInterface {
public: public:
bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) { bool addToScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override {
_myItem = scene->allocateID(); _myItem = scene->allocateID();
auto renderData = std::make_shared<RenderableEntityItemProxy>(self, _myItem); auto renderData = std::make_shared<RenderableEntityItemProxy>(self, _myItem);
@ -69,7 +80,7 @@ public:
return true; return true;
} }
void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) { void removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override {
transaction.removeItem(_myItem); transaction.removeItem(_myItem);
render::Item::clearID(_myItem); render::Item::clearID(_myItem);
} }
@ -91,7 +102,6 @@ public:
qCWarning(entitiesrenderer) << "SimpleRenderableEntityItem::notifyChanged(), Unexpected null scene, possibly during application shutdown"; qCWarning(entitiesrenderer) << "SimpleRenderableEntityItem::notifyChanged(), Unexpected null scene, possibly during application shutdown";
} }
} }
private: private:
render::ItemID _myItem { render::Item::INVALID_ITEM_ID }; render::ItemID _myItem { render::Item::INVALID_ITEM_ID };
}; };
@ -99,20 +109,18 @@ private:
#define SIMPLE_RENDERABLE() \ #define SIMPLE_RENDERABLE() \
public: \ public: \
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override { return _renderHelper.addToScene(self, scene, transaction); } \ virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyChanged(); } \
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override { _renderHelper.removeFromScene(self, scene, transaction); } \ virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); notifyChanged(); } \
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); _renderHelper.notifyChanged(); } \ virtual RenderableEntityInterface* getRenderableInterface() override { return this; } \
virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); _renderHelper.notifyChanged(); } \
void checkFading() { \ void checkFading() { \
bool transparent = isTransparent(); \ bool transparent = isTransparent(); \
if (transparent != _prevIsTransparent) { \ if (transparent != _prevIsTransparent) { \
_renderHelper.notifyChanged(); \ notifyChanged(); \
_isFading = false; \ _isFading = false; \
_prevIsTransparent = transparent; \ _prevIsTransparent = transparent; \
} \ } \
} \ } \
private: \ private: \
SimpleRenderableEntityItem _renderHelper; \
bool _prevIsTransparent { isTransparent() }; bool _prevIsTransparent { isTransparent() };

View file

@ -27,7 +27,7 @@ RenderableLightEntityItem::RenderableLightEntityItem(const EntityItemID& entityI
{ {
} }
bool RenderableLightEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) { bool RenderableLightEntityItem::addToScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) {
_myItem = scene->allocateID(); _myItem = scene->allocateID();
auto renderItem = std::make_shared<LightPayload>(); auto renderItem = std::make_shared<LightPayload>();
@ -51,7 +51,7 @@ void RenderableLightEntityItem::somethingChangedNotification() {
LightEntityItem::somethingChangedNotification(); LightEntityItem::somethingChangedNotification();
} }
void RenderableLightEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) { void RenderableLightEntityItem::removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) {
transaction.removeItem(_myItem); transaction.removeItem(_myItem);
render::Item::clearID(_myItem); render::Item::clearID(_myItem);
} }

View file

@ -17,11 +17,13 @@
#include "RenderableEntityItem.h" #include "RenderableEntityItem.h"
class RenderableLightEntityItem : public LightEntityItem { class RenderableLightEntityItem : public LightEntityItem, public RenderableEntityInterface {
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
RenderableLightEntityItem(const EntityItemID& entityItemID); RenderableLightEntityItem(const EntityItemID& entityItemID);
RenderableEntityInterface* getRenderableInterface() override { return this; }
virtual bool supportsDetailedRayIntersection() const override { return true; } virtual bool supportsDetailedRayIntersection() const override { return true; }
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
bool& keepSearching, OctreeElementPointer& element, float& distance, bool& keepSearching, OctreeElementPointer& element, float& distance,
@ -30,10 +32,10 @@ public:
void updateLightFromEntity(render::Transaction& transaction); void updateLightFromEntity(render::Transaction& transaction);
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override; virtual bool addToScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
virtual void somethingChangedNotification() override; virtual void somethingChangedNotification() override;
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override; virtual void removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
virtual void locationChanged(bool tellPhysics = true) override; virtual void locationChanged(bool tellPhysics = true) override;

View file

@ -16,7 +16,7 @@
#include "RenderableEntityItem.h" #include "RenderableEntityItem.h"
#include <GeometryCache.h> #include <GeometryCache.h>
class RenderableLineEntityItem : public LineEntityItem { class RenderableLineEntityItem : public LineEntityItem, public SimplerRenderableEntitySupport {
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
RenderableLineEntityItem(const EntityItemID& entityItemID) : RenderableLineEntityItem(const EntityItemID& entityItemID) :

View file

@ -213,7 +213,7 @@ namespace render {
if (args) { if (args) {
if (payload && payload->entity) { if (payload && payload->entity) {
PROFILE_RANGE(render_detail, "MetaModelRender"); PROFILE_RANGE(render_detail, "MetaModelRender");
payload->entity->render(args); payload->entity->getRenderableInterface()->render(args);
} }
} }
} }
@ -228,7 +228,7 @@ namespace render {
} }
} }
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene, bool RenderableModelEntityItem::addToScene(const EntityItemPointer& self, const render::ScenePointer& scene,
render::Transaction& transaction) { render::Transaction& transaction) {
_myMetaItem = scene->allocateID(); _myMetaItem = scene->allocateID();
@ -249,7 +249,7 @@ bool RenderableModelEntityItem::addToScene(EntityItemPointer self, const render:
return true; return true;
} }
void RenderableModelEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, void RenderableModelEntityItem::removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene,
render::Transaction& transaction) { render::Transaction& transaction) {
transaction.removeItem(_myMetaItem); transaction.removeItem(_myMetaItem);
render::Item::clearID(_myMetaItem); render::Item::clearID(_myMetaItem);
@ -390,7 +390,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
if (!_model || _needsModelReload) { if (!_model || _needsModelReload) {
// TODO: this getModel() appears to be about 3% of model render time. We should optimize // TODO: this getModel() appears to be about 3% of model render time. We should optimize
PerformanceTimer perfTimer("getModel"); PerformanceTimer perfTimer("getModel");
auto renderer = qSharedPointerCast<EntityTreeRenderer>(args->_renderer); auto renderer = qSharedPointerCast<EntityTreeRenderer>(args->_renderData);
getModel(renderer); getModel(renderer);
// Remap textures immediately after loading to avoid flicker // Remap textures immediately after loading to avoid flicker

View file

@ -20,7 +20,7 @@
class Model; class Model;
class EntityTreeRenderer; class EntityTreeRenderer;
class RenderableModelEntityItem : public ModelEntityItem { class RenderableModelEntityItem : public ModelEntityItem, RenderableEntityInterface {
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
@ -28,6 +28,8 @@ public:
virtual ~RenderableModelEntityItem(); virtual ~RenderableModelEntityItem();
RenderableEntityInterface* getRenderableInterface() override { return this; }
virtual void setDimensions(const glm::vec3& value) override; virtual void setDimensions(const glm::vec3& value) override;
virtual void setModelURL(const QString& url) override; virtual void setModelURL(const QString& url) override;
@ -40,8 +42,8 @@ public:
void doInitialModelSimulation(); void doInitialModelSimulation();
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override; virtual bool addToScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override; virtual void removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
void updateModelBounds(); void updateModelBounds();

View file

@ -161,7 +161,7 @@ RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const Ent
} }
} }
bool RenderableParticleEffectEntityItem::addToScene(EntityItemPointer self, bool RenderableParticleEffectEntityItem::addToScene(const EntityItemPointer& self,
const render::ScenePointer& scene, const render::ScenePointer& scene,
render::Transaction& transaction) { render::Transaction& transaction) {
_scene = scene; _scene = scene;
@ -176,7 +176,7 @@ bool RenderableParticleEffectEntityItem::addToScene(EntityItemPointer self,
return true; return true;
} }
void RenderableParticleEffectEntityItem::removeFromScene(EntityItemPointer self, void RenderableParticleEffectEntityItem::removeFromScene(const EntityItemPointer& self,
const render::ScenePointer& scene, const render::ScenePointer& scene,
render::Transaction& transaction) { render::Transaction& transaction) {
transaction.removeItem(_renderItemId); transaction.removeItem(_renderItemId);

View file

@ -15,18 +15,20 @@
#include <TextureCache.h> #include <TextureCache.h>
#include "RenderableEntityItem.h" #include "RenderableEntityItem.h"
class RenderableParticleEffectEntityItem : public ParticleEffectEntityItem { class RenderableParticleEffectEntityItem : public ParticleEffectEntityItem, public RenderableEntityInterface {
friend class ParticlePayloadData; friend class ParticlePayloadData;
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
RenderableParticleEffectEntityItem(const EntityItemID& entityItemID); RenderableParticleEffectEntityItem(const EntityItemID& entityItemID);
RenderableEntityInterface* getRenderableInterface() override { return this; }
virtual void update(const quint64& now) override; virtual void update(const quint64& now) override;
void updateRenderItem(); void updateRenderItem();
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override; virtual bool addToScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override; virtual void removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
protected: protected:
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyBoundChanged(); } virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyBoundChanged(); }

View file

@ -206,7 +206,7 @@ void RenderablePolyLineEntityItem::render(RenderArgs* args) {
if (_texture->isLoaded()) { if (_texture->isLoaded()) {
batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, _texture->getGPUTexture()); batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, _texture->getGPUTexture());
} else { } else {
batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, args->_whiteTexture); batch.setResourceTexture(PAINTSTROKE_TEXTURE_SLOT, nullptr);
} }
batch.setInputFormat(_format); batch.setInputFormat(_format);

View file

@ -22,7 +22,7 @@
#include <QReadWriteLock> #include <QReadWriteLock>
class RenderablePolyLineEntityItem : public PolyLineEntityItem { class RenderablePolyLineEntityItem : public PolyLineEntityItem, public SimplerRenderableEntitySupport {
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
static void createPipeline(); static void createPipeline();

View file

@ -820,7 +820,7 @@ void RenderablePolyVoxEntityItem::render(RenderArgs* args) {
batch.drawIndexed(gpu::TRIANGLES, (gpu::uint32)mesh->getNumIndices(), 0); batch.drawIndexed(gpu::TRIANGLES, (gpu::uint32)mesh->getNumIndices(), 0);
} }
bool RenderablePolyVoxEntityItem::addToScene(EntityItemPointer self, bool RenderablePolyVoxEntityItem::addToScene(const EntityItemPointer& self,
const render::ScenePointer& scene, const render::ScenePointer& scene,
render::Transaction& transaction) { render::Transaction& transaction) {
_myItem = scene->allocateID(); _myItem = scene->allocateID();
@ -838,7 +838,7 @@ bool RenderablePolyVoxEntityItem::addToScene(EntityItemPointer self,
return true; return true;
} }
void RenderablePolyVoxEntityItem::removeFromScene(EntityItemPointer self, void RenderablePolyVoxEntityItem::removeFromScene(const EntityItemPointer& self,
const render::ScenePointer& scene, const render::ScenePointer& scene,
render::Transaction& transaction) { render::Transaction& transaction) {
transaction.removeItem(_myItem); transaction.removeItem(_myItem);
@ -865,7 +865,7 @@ namespace render {
template <> void payloadRender(const PolyVoxPayload::Pointer& payload, RenderArgs* args) { template <> void payloadRender(const PolyVoxPayload::Pointer& payload, RenderArgs* args) {
if (args && payload && payload->_owner) { if (args && payload && payload->_owner) {
payload->_owner->render(args); payload->_owner->getRenderableInterface()->render(args);
} }
} }
} }

View file

@ -41,13 +41,15 @@ namespace render {
} }
class RenderablePolyVoxEntityItem : public PolyVoxEntityItem { class RenderablePolyVoxEntityItem : public PolyVoxEntityItem, public RenderableEntityInterface {
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
RenderablePolyVoxEntityItem(const EntityItemID& entityItemID); RenderablePolyVoxEntityItem(const EntityItemID& entityItemID);
virtual ~RenderablePolyVoxEntityItem(); virtual ~RenderablePolyVoxEntityItem();
RenderableEntityInterface* getRenderableInterface() override { return this; }
void initializePolyVox(); void initializePolyVox();
virtual void somethingChangedNotification() override { virtual void somethingChangedNotification() override {
@ -105,10 +107,10 @@ public:
virtual void setYTextureURL(const QString& yTextureURL) override; virtual void setYTextureURL(const QString& yTextureURL) override;
virtual void setZTextureURL(const QString& zTextureURL) override; virtual void setZTextureURL(const QString& zTextureURL) override;
virtual bool addToScene(EntityItemPointer self, virtual bool addToScene(const EntityItemPointer& self,
const render::ScenePointer& scene, const render::ScenePointer& scene,
render::Transaction& transaction) override; render::Transaction& transaction) override;
virtual void removeFromScene(EntityItemPointer self, virtual void removeFromScene(const EntityItemPointer& self,
const render::ScenePointer& scene, const render::ScenePointer& scene,
render::Transaction& transaction) override; render::Transaction& transaction) override;

View file

@ -14,7 +14,7 @@
#include "RenderableEntityItem.h" #include "RenderableEntityItem.h"
class RenderableShapeEntityItem : public ShapeEntityItem { class RenderableShapeEntityItem : public ShapeEntityItem, private SimplerRenderableEntitySupport {
using Pointer = std::shared_ptr<RenderableShapeEntityItem>; using Pointer = std::shared_ptr<RenderableShapeEntityItem>;
static Pointer baseFactory(const EntityItemID& entityID, const EntityItemProperties& properties); static Pointer baseFactory(const EntityItemID& entityID, const EntityItemProperties& properties);
public: public:

View file

@ -19,7 +19,7 @@
const int FIXED_FONT_POINT_SIZE = 40; const int FIXED_FONT_POINT_SIZE = 40;
class RenderableTextEntityItem : public TextEntityItem { class RenderableTextEntityItem : public TextEntityItem, public SimplerRenderableEntitySupport {
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
RenderableTextEntityItem(const EntityItemID& entityItemID) : TextEntityItem(entityItemID) { } RenderableTextEntityItem(const EntityItemID& entityItemID) : TextEntityItem(entityItemID) { }

View file

@ -198,7 +198,7 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
#endif #endif
if (!_webSurface) { if (!_webSurface) {
auto renderer = qSharedPointerCast<EntityTreeRenderer>(args->_renderer); auto renderer = qSharedPointerCast<EntityTreeRenderer>(args->_renderData);
if (!buildWebSurface(renderer)) { if (!buildWebSurface(renderer)) {
return; return;
} }

View file

@ -27,7 +27,7 @@ class EntityTreeRenderer;
class RenderableWebEntityItem; class RenderableWebEntityItem;
class RenderableWebEntityItem : public WebEntityItem { class RenderableWebEntityItem : public WebEntityItem, SimplerRenderableEntitySupport {
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
RenderableWebEntityItem(const EntityItemID& entityItemID); RenderableWebEntityItem(const EntityItemID& entityItemID);

View file

@ -257,7 +257,7 @@ bool RenderableZoneEntityItem::contains(const glm::vec3& point) const {
return false; return false;
} }
bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene, bool RenderableZoneEntityItem::addToScene(const EntityItemPointer& self, const render::ScenePointer& scene,
render::Transaction& transaction) { render::Transaction& transaction) {
_myMetaItem = scene->allocateID(); _myMetaItem = scene->allocateID();
@ -277,7 +277,7 @@ bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, const render::
return true; return true;
} }
void RenderableZoneEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, void RenderableZoneEntityItem::removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene,
render::Transaction& transaction) { render::Transaction& transaction) {
transaction.removeItem(_myMetaItem); transaction.removeItem(_myMetaItem);
render::Item::clearID(_myMetaItem); render::Item::clearID(_myMetaItem);

View file

@ -14,13 +14,14 @@
#include <Model.h> #include <Model.h>
#include <ZoneEntityItem.h> #include <ZoneEntityItem.h>
#include "RenderableEntityItem.h"
class NetworkGeometry; class NetworkGeometry;
class KeyLightPayload; class KeyLightPayload;
class RenderableZoneEntityItemMeta; class RenderableZoneEntityItemMeta;
class RenderableZoneEntityItem : public ZoneEntityItem { class RenderableZoneEntityItem : public ZoneEntityItem, public RenderableEntityInterface {
public: public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
@ -30,6 +31,8 @@ public:
_needsInitialSimulation(true) _needsInitialSimulation(true)
{ } { }
RenderableEntityInterface* getRenderableInterface() override { return this; }
virtual bool setProperties(const EntityItemProperties& properties) override; virtual bool setProperties(const EntityItemProperties& properties) override;
virtual void somethingChangedNotification() override; virtual void somethingChangedNotification() override;
@ -41,8 +44,8 @@ public:
virtual void render(RenderArgs* args) override; virtual void render(RenderArgs* args) override;
virtual bool contains(const glm::vec3& point) const override; virtual bool contains(const glm::vec3& point) const override;
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override; virtual bool addToScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override; virtual void removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
render::ItemID getRenderItemID() const { return _myMetaItem; } render::ItemID getRenderItemID() const { return _myMetaItem; }

View file

@ -1,6 +1,8 @@
set(TARGET_NAME entities) set(TARGET_NAME entities)
setup_hifi_library(Network Script) setup_hifi_library(Network Script)
link_hifi_libraries(avatars shared audio octree model model-networking fbx networking animation) link_hifi_libraries(avatars shared audio octree model model-networking fbx networking animation)
include_hifi_library_headers(networking)
include_hifi_library_headers(gpu)
target_bullet() target_bullet()

View file

@ -30,7 +30,7 @@ AddEntityOperator::AddEntityOperator(EntityTreePointer tree, EntityItemPointer n
_newEntityBox = queryCube.clamp((float)(-HALF_TREE_SCALE), (float)HALF_TREE_SCALE); _newEntityBox = queryCube.clamp((float)(-HALF_TREE_SCALE), (float)HALF_TREE_SCALE);
} }
bool AddEntityOperator::preRecursion(OctreeElementPointer element) { bool AddEntityOperator::preRecursion(const OctreeElementPointer& element) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
// In Pre-recursion, we're generally deciding whether or not we want to recurse this // In Pre-recursion, we're generally deciding whether or not we want to recurse this
@ -60,7 +60,7 @@ bool AddEntityOperator::preRecursion(OctreeElementPointer element) {
return keepSearching; // if we haven't yet found it, keep looking return keepSearching; // if we haven't yet found it, keep looking
} }
bool AddEntityOperator::postRecursion(OctreeElementPointer element) { bool AddEntityOperator::postRecursion(const OctreeElementPointer& element) {
// Post-recursion is the unwinding process. For this operation, while we // Post-recursion is the unwinding process. For this operation, while we
// unwind we want to mark the path as being dirty if we changed it below. // unwind we want to mark the path as being dirty if we changed it below.
// We might have two paths, one for the old entity and one for the new entity. // We might have two paths, one for the old entity and one for the new entity.
@ -74,7 +74,7 @@ bool AddEntityOperator::postRecursion(OctreeElementPointer element) {
return keepSearching; // if we haven't yet found it, keep looking return keepSearching; // if we haven't yet found it, keep looking
} }
OctreeElementPointer AddEntityOperator::possiblyCreateChildAt(OctreeElementPointer element, int childIndex) { OctreeElementPointer AddEntityOperator::possiblyCreateChildAt(const OctreeElementPointer& element, int childIndex) {
// If we're getting called, it's because there was no child element at this index while recursing. // If we're getting called, it's because there was no child element at this index while recursing.
// We only care if this happens while still searching for the new entity location. // We only care if this happens while still searching for the new entity location.
// Check to see if // Check to see if

View file

@ -16,9 +16,9 @@ class AddEntityOperator : public RecurseOctreeOperator {
public: public:
AddEntityOperator(EntityTreePointer tree, EntityItemPointer newEntity); AddEntityOperator(EntityTreePointer tree, EntityItemPointer newEntity);
virtual bool preRecursion(OctreeElementPointer element) override; virtual bool preRecursion(const OctreeElementPointer& element) override;
virtual bool postRecursion(OctreeElementPointer element) override; virtual bool postRecursion(const OctreeElementPointer& element) override;
virtual OctreeElementPointer possiblyCreateChildAt(OctreeElementPointer element, int childIndex) override; virtual OctreeElementPointer possiblyCreateChildAt(const OctreeElementPointer& element, int childIndex) override;
private: private:
EntityTreePointer _tree; EntityTreePointer _tree;
EntityItemPointer _newEntity; EntityItemPointer _newEntity;

View file

@ -55,7 +55,7 @@ void DeleteEntityOperator::addEntityIDToDeleteList(const EntityItemID& searchEnt
// does this entity tree element contain the old entity // does this entity tree element contain the old entity
bool DeleteEntityOperator::subTreeContainsSomeEntitiesToDelete(OctreeElementPointer element) { bool DeleteEntityOperator::subTreeContainsSomeEntitiesToDelete(const OctreeElementPointer& element) {
bool containsEntity = false; bool containsEntity = false;
// If we don't have an old entity, then we don't contain the entity, otherwise // If we don't have an old entity, then we don't contain the entity, otherwise
@ -72,7 +72,7 @@ bool DeleteEntityOperator::subTreeContainsSomeEntitiesToDelete(OctreeElementPoin
return containsEntity; return containsEntity;
} }
bool DeleteEntityOperator::preRecursion(OctreeElementPointer element) { bool DeleteEntityOperator::preRecursion(const OctreeElementPointer& element) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
// In Pre-recursion, we're generally deciding whether or not we want to recurse this // In Pre-recursion, we're generally deciding whether or not we want to recurse this
@ -108,7 +108,7 @@ bool DeleteEntityOperator::preRecursion(OctreeElementPointer element) {
return keepSearching; // if we haven't yet found it, keep looking return keepSearching; // if we haven't yet found it, keep looking
} }
bool DeleteEntityOperator::postRecursion(OctreeElementPointer element) { bool DeleteEntityOperator::postRecursion(const OctreeElementPointer& element) {
// Post-recursion is the unwinding process. For this operation, while we // Post-recursion is the unwinding process. For this operation, while we
// unwind we want to mark the path as being dirty if we changed it below. // unwind we want to mark the path as being dirty if we changed it below.
// We might have two paths, one for the old entity and one for the new entity. // We might have two paths, one for the old entity and one for the new entity.

View file

@ -36,8 +36,8 @@ public:
~DeleteEntityOperator(); ~DeleteEntityOperator();
void addEntityIDToDeleteList(const EntityItemID& searchEntityID); void addEntityIDToDeleteList(const EntityItemID& searchEntityID);
virtual bool preRecursion(OctreeElementPointer element) override; virtual bool preRecursion(const OctreeElementPointer& element) override;
virtual bool postRecursion(OctreeElementPointer element) override; virtual bool postRecursion(const OctreeElementPointer& element) override;
const RemovedEntities& getEntities() const { return _entitiesToDelete; } const RemovedEntities& getEntities() const { return _entitiesToDelete; }
private: private:
@ -46,7 +46,7 @@ private:
quint64 _changeTime; quint64 _changeTime;
int _foundCount; int _foundCount;
int _lookingCount; int _lookingCount;
bool subTreeContainsSomeEntitiesToDelete(OctreeElementPointer element); bool subTreeContainsSomeEntitiesToDelete(const OctreeElementPointer& element);
}; };
#endif // hifi_DeleteEntityOperator_h #endif // hifi_DeleteEntityOperator_h

View file

@ -51,10 +51,6 @@ typedef std::shared_ptr<EntityTreeElement> EntityTreeElementPointer;
using EntityTreeElementExtraEncodeDataPointer = std::shared_ptr<EntityTreeElementExtraEncodeData>; using EntityTreeElementExtraEncodeDataPointer = std::shared_ptr<EntityTreeElementExtraEncodeData>;
namespace render {
class Scene;
class Transaction;
}
#define DONT_ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() = 0; #define DONT_ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() = 0;
#define ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() override { }; #define ALLOW_INSTANTIATION virtual void pureVirtualFunctionPlaceHolder() override { };
@ -65,6 +61,8 @@ namespace render {
class MeshProxyList; class MeshProxyList;
class RenderableEntityInterface;
/// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available /// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available
/// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate /// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate
@ -83,6 +81,8 @@ public:
EntityItem(const EntityItemID& entityItemID); EntityItem(const EntityItemID& entityItemID);
virtual ~EntityItem(); virtual ~EntityItem();
virtual RenderableEntityInterface* getRenderableInterface() { return nullptr; }
inline EntityItemPointer getThisPointer() const { inline EntityItemPointer getThisPointer() const {
return std::static_pointer_cast<EntityItem>(std::const_pointer_cast<SpatiallyNestable>(shared_from_this())); return std::static_pointer_cast<EntityItem>(std::const_pointer_cast<SpatiallyNestable>(shared_from_this()));
} }
@ -150,13 +150,6 @@ public:
EntityPropertyFlags& propertyFlags, bool overwriteLocalData, EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
bool& somethingChanged) bool& somethingChanged)
{ somethingChanged = false; return 0; } { somethingChanged = false; return 0; }
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene,
render::Transaction& transaction) { return false; } // by default entity items don't add to scene
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene,
render::Transaction& transaction) { } // by default entity items don't add to scene
virtual void render(RenderArgs* args) { } // by default entity items don't know how to render
static int expectedBytes(); static int expectedBytes();
static void adjustEditPacketForClockSkew(QByteArray& buffer, qint64 clockSkew); static void adjustEditPacketForClockSkew(QByteArray& buffer, qint64 clockSkew);

View file

@ -554,7 +554,7 @@ public:
}; };
bool EntityTree::findNearPointOperation(OctreeElementPointer element, void* extraData) { bool EntityTree::findNearPointOperation(const OctreeElementPointer& element, void* extraData) {
FindNearPointArgs* args = static_cast<FindNearPointArgs*>(extraData); FindNearPointArgs* args = static_cast<FindNearPointArgs*>(extraData);
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
@ -589,7 +589,7 @@ bool EntityTree::findNearPointOperation(OctreeElementPointer element, void* extr
return false; return false;
} }
bool findRayIntersectionOp(OctreeElementPointer element, void* extraData) { bool findRayIntersectionOp(const OctreeElementPointer& element, void* extraData) {
RayArgs* args = static_cast<RayArgs*>(extraData); RayArgs* args = static_cast<RayArgs*>(extraData);
bool keepSearching = true; bool keepSearching = true;
EntityTreeElementPointer entityTreeElementPointer = std::dynamic_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElementPointer = std::dynamic_pointer_cast<EntityTreeElement>(element);
@ -625,7 +625,7 @@ bool EntityTree::findRayIntersection(const glm::vec3& origin, const glm::vec3& d
} }
EntityItemPointer EntityTree::findClosestEntity(glm::vec3 position, float targetRadius) { EntityItemPointer EntityTree::findClosestEntity(const glm::vec3& position, float targetRadius) {
FindNearPointArgs args = { position, targetRadius, false, NULL, FLT_MAX }; FindNearPointArgs args = { position, targetRadius, false, NULL, FLT_MAX };
withReadLock([&] { withReadLock([&] {
// NOTE: This should use recursion, since this is a spatial operation // NOTE: This should use recursion, since this is a spatial operation
@ -642,7 +642,7 @@ public:
}; };
bool EntityTree::findInSphereOperation(OctreeElementPointer element, void* extraData) { bool EntityTree::findInSphereOperation(const OctreeElementPointer& element, void* extraData) {
FindAllNearPointArgs* args = static_cast<FindAllNearPointArgs*>(extraData); FindAllNearPointArgs* args = static_cast<FindAllNearPointArgs*>(extraData);
glm::vec3 penetration; glm::vec3 penetration;
bool sphereIntersection = element->getAACube().findSpherePenetration(args->position, args->targetRadius, penetration); bool sphereIntersection = element->getAACube().findSpherePenetration(args->position, args->targetRadius, penetration);
@ -678,7 +678,7 @@ public:
QVector<EntityItemPointer> _foundEntities; QVector<EntityItemPointer> _foundEntities;
}; };
bool EntityTree::findInCubeOperation(OctreeElementPointer element, void* extraData) { bool EntityTree::findInCubeOperation(const OctreeElementPointer& element, void* extraData) {
FindEntitiesInCubeArgs* args = static_cast<FindEntitiesInCubeArgs*>(extraData); FindEntitiesInCubeArgs* args = static_cast<FindEntitiesInCubeArgs*>(extraData);
if (element->getAACube().touches(args->_cube)) { if (element->getAACube().touches(args->_cube)) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
@ -707,7 +707,7 @@ public:
QVector<EntityItemPointer> _foundEntities; QVector<EntityItemPointer> _foundEntities;
}; };
bool EntityTree::findInBoxOperation(OctreeElementPointer element, void* extraData) { bool EntityTree::findInBoxOperation(const OctreeElementPointer& element, void* extraData) {
FindEntitiesInBoxArgs* args = static_cast<FindEntitiesInBoxArgs*>(extraData); FindEntitiesInBoxArgs* args = static_cast<FindEntitiesInBoxArgs*>(extraData);
if (element->getAACube().touches(args->_box)) { if (element->getAACube().touches(args->_box)) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
@ -732,7 +732,7 @@ public:
QVector<EntityItemPointer> entities; QVector<EntityItemPointer> entities;
}; };
bool EntityTree::findInFrustumOperation(OctreeElementPointer element, void* extraData) { bool EntityTree::findInFrustumOperation(const OctreeElementPointer& element, void* extraData) {
FindInFrustumArgs* args = static_cast<FindInFrustumArgs*>(extraData); FindInFrustumArgs* args = static_cast<FindInFrustumArgs*>(extraData);
if (element->isInView(args->frustum)) { if (element->isInView(args->frustum)) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
@ -1527,15 +1527,15 @@ void EntityTree::debugDumpMap() {
class ContentsDimensionOperator : public RecurseOctreeOperator { class ContentsDimensionOperator : public RecurseOctreeOperator {
public: public:
virtual bool preRecursion(OctreeElementPointer element) override; virtual bool preRecursion(const OctreeElementPointer& element) override;
virtual bool postRecursion(OctreeElementPointer element) override { return true; } virtual bool postRecursion(const OctreeElementPointer& element) override { return true; }
glm::vec3 getDimensions() const { return _contentExtents.size(); } glm::vec3 getDimensions() const { return _contentExtents.size(); }
float getLargestDimension() const { return _contentExtents.largestDimension(); } float getLargestDimension() const { return _contentExtents.largestDimension(); }
private: private:
Extents _contentExtents; Extents _contentExtents;
}; };
bool ContentsDimensionOperator::preRecursion(OctreeElementPointer element) { bool ContentsDimensionOperator::preRecursion(const OctreeElementPointer& element) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
entityTreeElement->expandExtentsToContents(_contentExtents); entityTreeElement->expandExtentsToContents(_contentExtents);
return true; return true;
@ -1555,11 +1555,11 @@ float EntityTree::getContentsLargestDimension() {
class DebugOperator : public RecurseOctreeOperator { class DebugOperator : public RecurseOctreeOperator {
public: public:
virtual bool preRecursion(OctreeElementPointer element) override; virtual bool preRecursion(const OctreeElementPointer& element) override;
virtual bool postRecursion(OctreeElementPointer element) override { return true; } virtual bool postRecursion(const OctreeElementPointer& element) override { return true; }
}; };
bool DebugOperator::preRecursion(OctreeElementPointer element) { bool DebugOperator::preRecursion(const OctreeElementPointer& element) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
qCDebug(entities) << "EntityTreeElement [" << entityTreeElement.get() << "]"; qCDebug(entities) << "EntityTreeElement [" << entityTreeElement.get() << "]";
entityTreeElement->debugDump(); entityTreeElement->debugDump();
@ -1573,11 +1573,11 @@ void EntityTree::dumpTree() {
class PruneOperator : public RecurseOctreeOperator { class PruneOperator : public RecurseOctreeOperator {
public: public:
virtual bool preRecursion(OctreeElementPointer element) override { return true; } virtual bool preRecursion(const OctreeElementPointer& element) override { return true; }
virtual bool postRecursion(OctreeElementPointer element) override; virtual bool postRecursion(const OctreeElementPointer& element) override;
}; };
bool PruneOperator::postRecursion(OctreeElementPointer element) { bool PruneOperator::postRecursion(const OctreeElementPointer& element) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
entityTreeElement->pruneChildren(); entityTreeElement->pruneChildren();
return true; return true;
@ -1639,6 +1639,7 @@ QVector<EntityItemID> EntityTree::sendEntities(EntityEditPacketSender* packetSen
// If this is called repeatedly (e.g., multiple pastes with the same data), the new elements will clash unless we // If this is called repeatedly (e.g., multiple pastes with the same data), the new elements will clash unless we
// use new identifiers. We need to keep a map so that we can map parent identifiers correctly. // use new identifiers. We need to keep a map so that we can map parent identifiers correctly.
QHash<EntityItemID, EntityItemID> map; QHash<EntityItemID, EntityItemID> map;
args.map = &map; args.map = &map;
withReadLock([&] { withReadLock([&] {
recurseTreeWithOperation(sendEntitiesOperation, &args); recurseTreeWithOperation(sendEntitiesOperation, &args);
@ -1692,7 +1693,7 @@ QVector<EntityItemID> EntityTree::sendEntities(EntityEditPacketSender* packetSen
return map.values().toVector(); return map.values().toVector();
} }
bool EntityTree::sendEntitiesOperation(OctreeElementPointer element, void* extraData) { bool EntityTree::sendEntitiesOperation(const OctreeElementPointer& element, void* extraData) {
SendEntitiesOperationArgs* args = static_cast<SendEntitiesOperationArgs*>(extraData); SendEntitiesOperationArgs* args = static_cast<SendEntitiesOperationArgs*>(extraData);
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);

View file

@ -136,7 +136,7 @@ public:
/// \param position point of query in world-frame (meters) /// \param position point of query in world-frame (meters)
/// \param targetRadius radius of query (meters) /// \param targetRadius radius of query (meters)
EntityItemPointer findClosestEntity(glm::vec3 position, float targetRadius); EntityItemPointer findClosestEntity(const glm::vec3& position, float targetRadius);
EntityItemPointer findEntityByID(const QUuid& id); EntityItemPointer findEntityByID(const QUuid& id);
EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID); EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID);
virtual SpatiallyNestablePointer findByID(const QUuid& id) override { return findEntityByID(id); } virtual SpatiallyNestablePointer findByID(const QUuid& id) override { return findEntityByID(id); }
@ -294,12 +294,12 @@ protected:
bool updateEntityWithElement(EntityItemPointer entity, const EntityItemProperties& properties, bool updateEntityWithElement(EntityItemPointer entity, const EntityItemProperties& properties,
EntityTreeElementPointer containingElement, EntityTreeElementPointer containingElement,
const SharedNodePointer& senderNode = SharedNodePointer(nullptr)); const SharedNodePointer& senderNode = SharedNodePointer(nullptr));
static bool findNearPointOperation(OctreeElementPointer element, void* extraData); static bool findNearPointOperation(const OctreeElementPointer& element, void* extraData);
static bool findInSphereOperation(OctreeElementPointer element, void* extraData); static bool findInSphereOperation(const OctreeElementPointer& element, void* extraData);
static bool findInCubeOperation(OctreeElementPointer element, void* extraData); static bool findInCubeOperation(const OctreeElementPointer& element, void* extraData);
static bool findInBoxOperation(OctreeElementPointer element, void* extraData); static bool findInBoxOperation(const OctreeElementPointer& element, void* extraData);
static bool findInFrustumOperation(OctreeElementPointer element, void* extraData); static bool findInFrustumOperation(const OctreeElementPointer& element, void* extraData);
static bool sendEntitiesOperation(OctreeElementPointer element, void* extraData); static bool sendEntitiesOperation(const OctreeElementPointer& element, void* extraData);
static void bumpTimestamp(EntityItemProperties& properties); static void bumpTimestamp(EntityItemProperties& properties);
void notifyNewlyCreatedEntity(const EntityItem& newEntity, const SharedNodePointer& senderNode); void notifyNewlyCreatedEntity(const EntityItem& newEntity, const SharedNodePointer& senderNode);

View file

@ -17,8 +17,6 @@
#include <QHash> #include <QHash>
#include <QString> #include <QString>
#include <OctreeRenderer.h> // for RenderArgs
#include "EntitiesLogging.h" #include "EntitiesLogging.h"
class EntityItem; class EntityItem;

View file

@ -109,7 +109,7 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItemPointer entity, const
} }
// does this entity tree element contain the old entity // does this entity tree element contain the old entity
bool MovingEntitiesOperator::shouldRecurseSubTree(OctreeElementPointer element) { bool MovingEntitiesOperator::shouldRecurseSubTree(const OctreeElementPointer& element) {
bool containsEntity = false; bool containsEntity = false;
// If we don't have an old entity, then we don't contain the entity, otherwise // If we don't have an old entity, then we don't contain the entity, otherwise
@ -141,7 +141,7 @@ bool MovingEntitiesOperator::shouldRecurseSubTree(OctreeElementPointer element)
return containsEntity; return containsEntity;
} }
bool MovingEntitiesOperator::preRecursion(OctreeElementPointer element) { bool MovingEntitiesOperator::preRecursion(const OctreeElementPointer& element) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
// In Pre-recursion, we're generally deciding whether or not we want to recurse this // In Pre-recursion, we're generally deciding whether or not we want to recurse this
@ -221,7 +221,7 @@ bool MovingEntitiesOperator::preRecursion(OctreeElementPointer element) {
return keepSearching; // if we haven't yet found it, keep looking return keepSearching; // if we haven't yet found it, keep looking
} }
bool MovingEntitiesOperator::postRecursion(OctreeElementPointer element) { bool MovingEntitiesOperator::postRecursion(const OctreeElementPointer& element) {
// Post-recursion is the unwinding process. For this operation, while we // Post-recursion is the unwinding process. For this operation, while we
// unwind we want to mark the path as being dirty if we changed it below. // unwind we want to mark the path as being dirty if we changed it below.
// We might have two paths, one for the old entity and one for the new entity. // We might have two paths, one for the old entity and one for the new entity.
@ -261,7 +261,7 @@ bool MovingEntitiesOperator::postRecursion(OctreeElementPointer element) {
return keepSearching; // if we haven't yet found it, keep looking return keepSearching; // if we haven't yet found it, keep looking
} }
OctreeElementPointer MovingEntitiesOperator::possiblyCreateChildAt(OctreeElementPointer element, int childIndex) { OctreeElementPointer MovingEntitiesOperator::possiblyCreateChildAt(const OctreeElementPointer& element, int childIndex) {
// If we're getting called, it's because there was no child element at this index while recursing. // If we're getting called, it's because there was no child element at this index while recursing.
// We only care if this happens while still searching for the new entity locations. // We only care if this happens while still searching for the new entity locations.
if (_foundNewCount < _lookingCount) { if (_foundNewCount < _lookingCount) {

View file

@ -38,9 +38,9 @@ public:
~MovingEntitiesOperator(); ~MovingEntitiesOperator();
void addEntityToMoveList(EntityItemPointer entity, const AACube& newCube); void addEntityToMoveList(EntityItemPointer entity, const AACube& newCube);
virtual bool preRecursion(OctreeElementPointer element) override; virtual bool preRecursion(const OctreeElementPointer& element) override;
virtual bool postRecursion(OctreeElementPointer element) override; virtual bool postRecursion(const OctreeElementPointer& element) override;
virtual OctreeElementPointer possiblyCreateChildAt(OctreeElementPointer element, int childIndex) override; virtual OctreeElementPointer possiblyCreateChildAt(const OctreeElementPointer& element, int childIndex) override;
bool hasMovingEntities() const { return _entitiesToMove.size() > 0; } bool hasMovingEntities() const { return _entitiesToMove.size() > 0; }
private: private:
EntityTreePointer _tree; EntityTreePointer _tree;
@ -49,7 +49,7 @@ private:
int _foundOldCount; int _foundOldCount;
int _foundNewCount; int _foundNewCount;
int _lookingCount; int _lookingCount;
bool shouldRecurseSubTree(OctreeElementPointer element); bool shouldRecurseSubTree(const OctreeElementPointer& element);
bool _wantDebug; bool _wantDebug;
}; };

View file

@ -14,7 +14,7 @@
#include "EntityItemProperties.h" #include "EntityItemProperties.h"
RecurseOctreeToMapOperator::RecurseOctreeToMapOperator(QVariantMap& map, RecurseOctreeToMapOperator::RecurseOctreeToMapOperator(QVariantMap& map,
OctreeElementPointer top, const OctreeElementPointer& top,
QScriptEngine* engine, QScriptEngine* engine,
bool skipDefaultValues, bool skipDefaultValues,
bool skipThoseWithBadParents) : bool skipThoseWithBadParents) :
@ -34,14 +34,14 @@ RecurseOctreeToMapOperator::RecurseOctreeToMapOperator(QVariantMap& map,
} }
}; };
bool RecurseOctreeToMapOperator::preRecursion(OctreeElementPointer element) { bool RecurseOctreeToMapOperator::preRecursion(const OctreeElementPointer& element) {
if (element == _top) { if (element == _top) {
_withinTop = true; _withinTop = true;
} }
return true; return true;
} }
bool RecurseOctreeToMapOperator::postRecursion(OctreeElementPointer element) { bool RecurseOctreeToMapOperator::postRecursion(const OctreeElementPointer& element) {
EntityItemProperties defaultProperties; EntityItemProperties defaultProperties;

View file

@ -13,10 +13,10 @@
class RecurseOctreeToMapOperator : public RecurseOctreeOperator { class RecurseOctreeToMapOperator : public RecurseOctreeOperator {
public: public:
RecurseOctreeToMapOperator(QVariantMap& map, OctreeElementPointer top, QScriptEngine* engine, bool skipDefaultValues, RecurseOctreeToMapOperator(QVariantMap& map, const OctreeElementPointer& top, QScriptEngine* engine, bool skipDefaultValues,
bool skipThoseWithBadParents); bool skipThoseWithBadParents);
bool preRecursion(OctreeElementPointer element) override; bool preRecursion(const OctreeElementPointer& element) override;
bool postRecursion(OctreeElementPointer element) override; bool postRecursion(const OctreeElementPointer& element) override;
private: private:
QVariantMap& _map; QVariantMap& _map;
OctreeElementPointer _top; OctreeElementPointer _top;

View file

@ -77,7 +77,7 @@ UpdateEntityOperator::~UpdateEntityOperator() {
// does this entity tree element contain the old entity // does this entity tree element contain the old entity
bool UpdateEntityOperator::subTreeContainsOldEntity(OctreeElementPointer element) { bool UpdateEntityOperator::subTreeContainsOldEntity(const OctreeElementPointer& element) {
// We've found cases where the old entity might be placed in an element that is not actually the best fit // We've found cases where the old entity might be placed in an element that is not actually the best fit
// so when we're searching the tree for the old element, we use the known cube for the known containing element // so when we're searching the tree for the old element, we use the known cube for the known containing element
@ -95,7 +95,7 @@ bool UpdateEntityOperator::subTreeContainsOldEntity(OctreeElementPointer element
return elementContainsOldBox; return elementContainsOldBox;
} }
bool UpdateEntityOperator::subTreeContainsNewEntity(OctreeElementPointer element) { bool UpdateEntityOperator::subTreeContainsNewEntity(const OctreeElementPointer& element) {
bool elementContainsNewBox = element->getAACube().contains(_newEntityBox); bool elementContainsNewBox = element->getAACube().contains(_newEntityBox);
if (_wantDebug) { if (_wantDebug) {
@ -112,7 +112,7 @@ bool UpdateEntityOperator::subTreeContainsNewEntity(OctreeElementPointer element
} }
bool UpdateEntityOperator::preRecursion(OctreeElementPointer element) { bool UpdateEntityOperator::preRecursion(const OctreeElementPointer& element) {
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element); EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
// In Pre-recursion, we're generally deciding whether or not we want to recurse this // In Pre-recursion, we're generally deciding whether or not we want to recurse this
@ -238,7 +238,7 @@ bool UpdateEntityOperator::preRecursion(OctreeElementPointer element) {
return keepSearching; // if we haven't yet found it, keep looking return keepSearching; // if we haven't yet found it, keep looking
} }
bool UpdateEntityOperator::postRecursion(OctreeElementPointer element) { bool UpdateEntityOperator::postRecursion(const OctreeElementPointer& element) {
// Post-recursion is the unwinding process. For this operation, while we // Post-recursion is the unwinding process. For this operation, while we
// unwind we want to mark the path as being dirty if we changed it below. // unwind we want to mark the path as being dirty if we changed it below.
// We might have two paths, one for the old entity and one for the new entity. // We might have two paths, one for the old entity and one for the new entity.
@ -270,7 +270,7 @@ bool UpdateEntityOperator::postRecursion(OctreeElementPointer element) {
return keepSearching; // if we haven't yet found it, keep looking return keepSearching; // if we haven't yet found it, keep looking
} }
OctreeElementPointer UpdateEntityOperator::possiblyCreateChildAt(OctreeElementPointer element, int childIndex) { OctreeElementPointer UpdateEntityOperator::possiblyCreateChildAt(const OctreeElementPointer& element, int childIndex) {
// If we're getting called, it's because there was no child element at this index while recursing. // If we're getting called, it's because there was no child element at this index while recursing.
// We only care if this happens while still searching for the new entity location. // We only care if this happens while still searching for the new entity location.
// Check to see if // Check to see if

View file

@ -25,9 +25,9 @@ public:
~UpdateEntityOperator(); ~UpdateEntityOperator();
virtual bool preRecursion(OctreeElementPointer element) override; virtual bool preRecursion(const OctreeElementPointer& element) override;
virtual bool postRecursion(OctreeElementPointer element) override; virtual bool postRecursion(const OctreeElementPointer& element) override;
virtual OctreeElementPointer possiblyCreateChildAt(OctreeElementPointer element, int childIndex) override; virtual OctreeElementPointer possiblyCreateChildAt(const OctreeElementPointer& element, int childIndex) override;
private: private:
EntityTreePointer _tree; EntityTreePointer _tree;
EntityItemPointer _existingEntity; EntityItemPointer _existingEntity;
@ -45,8 +45,8 @@ private:
AABox _oldEntityBox; // clamped to domain AABox _oldEntityBox; // clamped to domain
AABox _newEntityBox; // clamped to domain AABox _newEntityBox; // clamped to domain
bool subTreeContainsOldEntity(OctreeElementPointer element); bool subTreeContainsOldEntity(const OctreeElementPointer& element);
bool subTreeContainsNewEntity(OctreeElementPointer element); bool subTreeContainsNewEntity(const OctreeElementPointer& element);
bool _wantDebug; bool _wantDebug;
}; };

View file

@ -1,3 +1,4 @@
set(TARGET_NAME fbx) set(TARGET_NAME fbx)
setup_hifi_library() setup_hifi_library()
link_hifi_libraries(shared model networking) link_hifi_libraries(shared model networking)
include_hifi_library_headers(gpu)

View file

@ -123,7 +123,7 @@ GLuint GL45Texture::allocate(const Texture& texture) {
glCreateTextures(getGLTextureType(texture), 1, &result); glCreateTextures(getGLTextureType(texture), 1, &result);
#ifdef DEBUG #ifdef DEBUG
auto source = texture.source(); auto source = texture.source();
glObjectLabel(GL_TEXTURE, result, source.length(), source.data()); glObjectLabel(GL_TEXTURE, result, (GLsizei)source.length(), source.data());
#endif #endif
return result; return result;
} }

View file

@ -1,3 +1,3 @@
set(TARGET_NAME ktx) set(TARGET_NAME ktx)
setup_hifi_library() setup_hifi_library()
link_hifi_libraries() include_hifi_library_headers(shared)

View file

@ -1,4 +1,4 @@
set(TARGET_NAME model-networking) set(TARGET_NAME model-networking)
setup_hifi_library() setup_hifi_library()
link_hifi_libraries(shared networking model fbx ktx image) link_hifi_libraries(shared networking model fbx ktx image)
include_hifi_library_headers(gpu)

View file

@ -13,10 +13,10 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include "AABox.h" #include <AABox.h>
#include "gpu/Resource.h" #include <gpu/Resource.h>
#include "gpu/Stream.h" #include <gpu/Stream.h>
namespace model { namespace model {
typedef gpu::BufferView::Index Index; typedef gpu::BufferView::Index Index;

View file

@ -11,20 +11,20 @@
#include "DirtyOctreeElementOperator.h" #include "DirtyOctreeElementOperator.h"
DirtyOctreeElementOperator::DirtyOctreeElementOperator(OctreeElementPointer element) DirtyOctreeElementOperator::DirtyOctreeElementOperator(const OctreeElementPointer& element)
: _element(element) { : _element(element) {
assert(_element.get()); assert(_element.get());
_point = _element->getAACube().calcCenter(); _point = _element->getAACube().calcCenter();
} }
bool DirtyOctreeElementOperator::preRecursion(OctreeElementPointer element) { bool DirtyOctreeElementOperator::preRecursion(const OctreeElementPointer& element) {
if (element == _element) { if (element == _element) {
return false; return false;
} }
return element->getAACube().contains(_point); return element->getAACube().contains(_point);
} }
bool DirtyOctreeElementOperator::postRecursion(OctreeElementPointer element) { bool DirtyOctreeElementOperator::postRecursion(const OctreeElementPointer& element) {
element->markWithChangedTime(); element->markWithChangedTime();
return true; return true;
} }

View file

@ -16,12 +16,12 @@
class DirtyOctreeElementOperator : public RecurseOctreeOperator { class DirtyOctreeElementOperator : public RecurseOctreeOperator {
public: public:
DirtyOctreeElementOperator(OctreeElementPointer element); DirtyOctreeElementOperator(const OctreeElementPointer& element);
~DirtyOctreeElementOperator() {} ~DirtyOctreeElementOperator() {}
virtual bool preRecursion(OctreeElementPointer element) override; virtual bool preRecursion(const OctreeElementPointer& element) override;
virtual bool postRecursion(OctreeElementPointer element) override; virtual bool postRecursion(const OctreeElementPointer& element) override;
private: private:
glm::vec3 _point; glm::vec3 _point;
OctreeElementPointer _element; OctreeElementPointer _element;

View file

@ -74,7 +74,7 @@ Octree::~Octree() {
// non-sorted array // non-sorted array
// returns -1 if size exceeded // returns -1 if size exceeded
// originalIndexArray is optional // originalIndexArray is optional
int insertOctreeElementIntoSortedArrays(OctreeElementPointer value, float key, int originalIndex, int insertOctreeElementIntoSortedArrays(const OctreeElementPointer& value, float key, int originalIndex,
OctreeElementPointer* valueArray, float* keyArray, int* originalIndexArray, OctreeElementPointer* valueArray, float* keyArray, int* originalIndexArray,
int currentCount, int maxCount) { int currentCount, int maxCount) {
@ -108,17 +108,17 @@ int insertOctreeElementIntoSortedArrays(OctreeElementPointer value, float key, i
// Recurses voxel tree calling the RecurseOctreeOperation function for each element. // Recurses voxel tree calling the RecurseOctreeOperation function for each element.
// stops recursion if operation function returns false. // stops recursion if operation function returns false.
void Octree::recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData) { void Octree::recurseTreeWithOperation(const RecurseOctreeOperation& operation, void* extraData) {
recurseElementWithOperation(_rootElement, operation, extraData); recurseElementWithOperation(_rootElement, operation, extraData);
} }
// Recurses voxel tree calling the RecurseOctreePostFixOperation function for each element in post-fix order. // Recurses voxel tree calling the RecurseOctreePostFixOperation function for each element in post-fix order.
void Octree::recurseTreeWithPostOperation(RecurseOctreeOperation operation, void* extraData) { void Octree::recurseTreeWithPostOperation(const RecurseOctreeOperation& operation, void* extraData) {
recurseElementWithPostOperation(_rootElement, operation, extraData); recurseElementWithPostOperation(_rootElement, operation, extraData);
} }
// Recurses voxel element with an operation function // Recurses voxel element with an operation function
void Octree::recurseElementWithOperation(OctreeElementPointer element, RecurseOctreeOperation operation, void* extraData, void Octree::recurseElementWithOperation(const OctreeElementPointer& element, const RecurseOctreeOperation& operation, void* extraData,
int recursionCount) { int recursionCount) {
if (recursionCount > DANGEROUSLY_DEEP_RECURSION) { if (recursionCount > DANGEROUSLY_DEEP_RECURSION) {
static QString repeatedMessage static QString repeatedMessage
@ -140,7 +140,7 @@ void Octree::recurseElementWithOperation(OctreeElementPointer element, RecurseOc
} }
// Recurses voxel element with an operation function // Recurses voxel element with an operation function
void Octree::recurseElementWithPostOperation(OctreeElementPointer element, RecurseOctreeOperation operation, void Octree::recurseElementWithPostOperation(const OctreeElementPointer& element, const RecurseOctreeOperation& operation,
void* extraData, int recursionCount) { void* extraData, int recursionCount) {
if (recursionCount > DANGEROUSLY_DEEP_RECURSION) { if (recursionCount > DANGEROUSLY_DEEP_RECURSION) {
static QString repeatedMessage static QString repeatedMessage
@ -162,14 +162,14 @@ void Octree::recurseElementWithPostOperation(OctreeElementPointer element, Recur
// Recurses voxel tree calling the RecurseOctreeOperation function for each element. // Recurses voxel tree calling the RecurseOctreeOperation function for each element.
// stops recursion if operation function returns false. // stops recursion if operation function returns false.
void Octree::recurseTreeWithOperationDistanceSorted(RecurseOctreeOperation operation, void Octree::recurseTreeWithOperationDistanceSorted(const RecurseOctreeOperation& operation,
const glm::vec3& point, void* extraData) { const glm::vec3& point, void* extraData) {
recurseElementWithOperationDistanceSorted(_rootElement, operation, point, extraData); recurseElementWithOperationDistanceSorted(_rootElement, operation, point, extraData);
} }
// Recurses voxel element with an operation function // Recurses voxel element with an operation function
void Octree::recurseElementWithOperationDistanceSorted(OctreeElementPointer element, RecurseOctreeOperation operation, void Octree::recurseElementWithOperationDistanceSorted(const OctreeElementPointer& element, const RecurseOctreeOperation& operation,
const glm::vec3& point, void* extraData, int recursionCount) { const glm::vec3& point, void* extraData, int recursionCount) {
if (recursionCount > DANGEROUSLY_DEEP_RECURSION) { if (recursionCount > DANGEROUSLY_DEEP_RECURSION) {
@ -212,7 +212,7 @@ void Octree::recurseTreeWithOperator(RecurseOctreeOperator* operatorObject) {
recurseElementWithOperator(_rootElement, operatorObject); recurseElementWithOperator(_rootElement, operatorObject);
} }
bool Octree::recurseElementWithOperator(OctreeElementPointer element, bool Octree::recurseElementWithOperator(const OctreeElementPointer& element,
RecurseOctreeOperator* operatorObject, int recursionCount) { RecurseOctreeOperator* operatorObject, int recursionCount) {
if (recursionCount > DANGEROUSLY_DEEP_RECURSION) { if (recursionCount > DANGEROUSLY_DEEP_RECURSION) {
static QString repeatedMessage static QString repeatedMessage
@ -245,7 +245,7 @@ bool Octree::recurseElementWithOperator(OctreeElementPointer element,
} }
OctreeElementPointer Octree::nodeForOctalCode(OctreeElementPointer ancestorElement, const unsigned char* needleCode, OctreeElementPointer Octree::nodeForOctalCode(const OctreeElementPointer& ancestorElement, const unsigned char* needleCode,
OctreeElementPointer* parentOfFoundElement) const { OctreeElementPointer* parentOfFoundElement) const {
// special case for NULL octcode // special case for NULL octcode
if (!needleCode) { if (!needleCode) {
@ -281,7 +281,7 @@ OctreeElementPointer Octree::nodeForOctalCode(OctreeElementPointer ancestorEleme
} }
// returns the element created! // returns the element created!
OctreeElementPointer Octree::createMissingElement(OctreeElementPointer lastParentElement, OctreeElementPointer Octree::createMissingElement(const OctreeElementPointer& lastParentElement,
const unsigned char* codeToReach, int recursionCount) { const unsigned char* codeToReach, int recursionCount) {
if (recursionCount > DANGEROUSLY_DEEP_RECURSION) { if (recursionCount > DANGEROUSLY_DEEP_RECURSION) {
@ -311,7 +311,7 @@ OctreeElementPointer Octree::createMissingElement(OctreeElementPointer lastParen
} }
} }
int Octree::readElementData(OctreeElementPointer destinationElement, const unsigned char* nodeData, int bytesAvailable, int Octree::readElementData(const OctreeElementPointer& destinationElement, const unsigned char* nodeData, int bytesAvailable,
ReadBitstreamToTreeParams& args) { ReadBitstreamToTreeParams& args) {
int bytesLeftToRead = bytesAvailable; int bytesLeftToRead = bytesAvailable;
@ -529,7 +529,7 @@ void Octree::deleteOctalCodeFromTree(const unsigned char* codeBuffer, bool colla
}); });
} }
void Octree::deleteOctalCodeFromTreeRecursion(OctreeElementPointer element, void* extraData) { void Octree::deleteOctalCodeFromTreeRecursion(const OctreeElementPointer& element, void* extraData) {
DeleteOctalCodeFromTreeArgs* args = (DeleteOctalCodeFromTreeArgs*)extraData; DeleteOctalCodeFromTreeArgs* args = (DeleteOctalCodeFromTreeArgs*)extraData;
int lengthOfElementCode = numberOfThreeBitSectionsInCode(element->getOctalCode()); int lengthOfElementCode = numberOfThreeBitSectionsInCode(element->getOctalCode());
@ -703,7 +703,7 @@ public:
void* penetratedObject; /// the type is defined by the type of Octree, the caller is assumed to know the type void* penetratedObject; /// the type is defined by the type of Octree, the caller is assumed to know the type
}; };
bool findSpherePenetrationOp(OctreeElementPointer element, void* extraData) { bool findSpherePenetrationOp(const OctreeElementPointer& element, void* extraData) {
SphereArgs* args = static_cast<SphereArgs*>(extraData); SphereArgs* args = static_cast<SphereArgs*>(extraData);
// coarse check against bounds // coarse check against bounds
@ -765,7 +765,7 @@ public:
CubeList* cubes; CubeList* cubes;
}; };
bool findCapsulePenetrationOp(OctreeElementPointer element, void* extraData) { bool findCapsulePenetrationOp(const OctreeElementPointer& element, void* extraData) {
CapsuleArgs* args = static_cast<CapsuleArgs*>(extraData); CapsuleArgs* args = static_cast<CapsuleArgs*>(extraData);
// coarse check against bounds // coarse check against bounds
@ -798,7 +798,7 @@ uint qHash(const glm::vec3& point) {
(((quint64)(point.z * RESOLUTION_PER_METER)) % MAX_SCALED_COMPONENT << 2 * BITS_PER_COMPONENT)); (((quint64)(point.z * RESOLUTION_PER_METER)) % MAX_SCALED_COMPONENT << 2 * BITS_PER_COMPONENT));
} }
bool findContentInCubeOp(OctreeElementPointer element, void* extraData) { bool findContentInCubeOp(const OctreeElementPointer& element, void* extraData) {
ContentArgs* args = static_cast<ContentArgs*>(extraData); ContentArgs* args = static_cast<ContentArgs*>(extraData);
// coarse check against bounds // coarse check against bounds
@ -851,7 +851,7 @@ public:
}; };
// Find the smallest colored voxel enclosing a point (if there is one) // Find the smallest colored voxel enclosing a point (if there is one)
bool getElementEnclosingOperation(OctreeElementPointer element, void* extraData) { bool getElementEnclosingOperation(const OctreeElementPointer& element, void* extraData) {
GetElementEnclosingArgs* args = static_cast<GetElementEnclosingArgs*>(extraData); GetElementEnclosingArgs* args = static_cast<GetElementEnclosingArgs*>(extraData);
if (element->getAACube().contains(args->point)) { if (element->getAACube().contains(args->point)) {
if (element->hasContent() && element->isLeaf()) { if (element->hasContent() && element->isLeaf()) {
@ -885,7 +885,7 @@ OctreeElementPointer Octree::getElementEnclosingPoint(const glm::vec3& point, Oc
int Octree::encodeTreeBitstream(OctreeElementPointer element, int Octree::encodeTreeBitstream(const OctreeElementPointer& element,
OctreePacketData* packetData, OctreeElementBag& bag, OctreePacketData* packetData, OctreeElementBag& bag,
EncodeBitstreamParams& params) { EncodeBitstreamParams& params) {
@ -979,7 +979,7 @@ int Octree::encodeTreeBitstream(OctreeElementPointer element,
return bytesWritten; return bytesWritten;
} }
int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, int Octree::encodeTreeBitstreamRecursion(const OctreeElementPointer& element,
OctreePacketData* packetData, OctreeElementBag& bag, OctreePacketData* packetData, OctreeElementBag& bag,
EncodeBitstreamParams& params, int& currentEncodeLevel, EncodeBitstreamParams& params, int& currentEncodeLevel,
const ViewFrustum::intersection& parentLocationThisView) const { const ViewFrustum::intersection& parentLocationThisView) const {
@ -1866,7 +1866,7 @@ bool Octree::readJSONFromStream(unsigned long streamLength, QDataStream& inputSt
return success; return success;
} }
bool Octree::writeToFile(const char* fileName, OctreeElementPointer element, QString persistAsFileType) { bool Octree::writeToFile(const char* fileName, const OctreeElementPointer& element, QString persistAsFileType) {
// make the sure file extension makes sense // make the sure file extension makes sense
QString qFileName = fileNameWithoutExtension(QString(fileName), PERSIST_EXTENSIONS) + "." + persistAsFileType; QString qFileName = fileNameWithoutExtension(QString(fileName), PERSIST_EXTENSIONS) + "." + persistAsFileType;
QByteArray byteArray = qFileName.toUtf8(); QByteArray byteArray = qFileName.toUtf8();
@ -1883,7 +1883,7 @@ bool Octree::writeToFile(const char* fileName, OctreeElementPointer element, QSt
return success; return success;
} }
bool Octree::writeToJSONFile(const char* fileName, OctreeElementPointer element, bool doGzip) { bool Octree::writeToJSONFile(const char* fileName, const OctreeElementPointer& element, bool doGzip) {
QVariantMap entityDescription; QVariantMap entityDescription;
qCDebug(octree, "Saving JSON SVO to file %s...", fileName); qCDebug(octree, "Saving JSON SVO to file %s...", fileName);
@ -1937,7 +1937,7 @@ unsigned long Octree::getOctreeElementsCount() {
return nodeCount; return nodeCount;
} }
bool Octree::countOctreeElementsOperation(OctreeElementPointer element, void* extraData) { bool Octree::countOctreeElementsOperation(const OctreeElementPointer& element, void* extraData) {
(*(unsigned long*)extraData)++; (*(unsigned long*)extraData)++;
return true; // keep going return true; // keep going
} }

View file

@ -41,13 +41,13 @@ extern QVector<QString> PERSIST_EXTENSIONS;
/// derive from this class to use the Octree::recurseTreeWithOperator() method /// derive from this class to use the Octree::recurseTreeWithOperator() method
class RecurseOctreeOperator { class RecurseOctreeOperator {
public: public:
virtual bool preRecursion(OctreeElementPointer element) = 0; virtual bool preRecursion(const OctreeElementPointer& element) = 0;
virtual bool postRecursion(OctreeElementPointer element) = 0; virtual bool postRecursion(const OctreeElementPointer& element) = 0;
virtual OctreeElementPointer possiblyCreateChildAt(OctreeElementPointer element, int childIndex) { return NULL; } virtual OctreeElementPointer possiblyCreateChildAt(const OctreeElementPointer& element, int childIndex) { return NULL; }
}; };
// Callback function, for recuseTreeWithOperation // Callback function, for recuseTreeWithOperation
typedef bool (*RecurseOctreeOperation)(OctreeElementPointer element, void* extraData); using RecurseOctreeOperation = std::function<bool(const OctreeElementPointer&, void*)>;
typedef enum {GRADIENT, RANDOM, NATURAL} creationMode; typedef enum {GRADIENT, RANDOM, NATURAL} creationMode;
typedef QHash<uint, AACube> CubeList; typedef QHash<uint, AACube> CubeList;
@ -233,7 +233,7 @@ public:
void readBitstreamToTree(const unsigned char* bitstream, unsigned long int bufferSizeBytes, ReadBitstreamToTreeParams& args); void readBitstreamToTree(const unsigned char* bitstream, unsigned long int bufferSizeBytes, ReadBitstreamToTreeParams& args);
void deleteOctalCodeFromTree(const unsigned char* codeBuffer, bool collapseEmptyTrees = DONT_COLLAPSE); void deleteOctalCodeFromTree(const unsigned char* codeBuffer, bool collapseEmptyTrees = DONT_COLLAPSE);
void reaverageOctreeElements(OctreeElementPointer startElement = NULL); void reaverageOctreeElements(OctreeElementPointer startElement = OctreeElementPointer());
void deleteOctreeElementAt(float x, float y, float z, float s); void deleteOctreeElementAt(float x, float y, float z, float s);
@ -248,18 +248,18 @@ public:
OctreeElementPointer getOrCreateChildElementAt(float x, float y, float z, float s); OctreeElementPointer getOrCreateChildElementAt(float x, float y, float z, float s);
OctreeElementPointer getOrCreateChildElementContaining(const AACube& box); OctreeElementPointer getOrCreateChildElementContaining(const AACube& box);
void recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData = NULL); void recurseTreeWithOperation(const RecurseOctreeOperation& operation, void* extraData = NULL);
void recurseTreeWithPostOperation(RecurseOctreeOperation operation, void* extraData = NULL); void recurseTreeWithPostOperation(const RecurseOctreeOperation& operation, void* extraData = NULL);
/// \param operation type of operation /// \param operation type of operation
/// \param point point in world-frame (meters) /// \param point point in world-frame (meters)
/// \param extraData hook for user data to be interpreted by special context /// \param extraData hook for user data to be interpreted by special context
void recurseTreeWithOperationDistanceSorted(RecurseOctreeOperation operation, void recurseTreeWithOperationDistanceSorted(const RecurseOctreeOperation& operation,
const glm::vec3& point, void* extraData = NULL); const glm::vec3& point, void* extraData = NULL);
void recurseTreeWithOperator(RecurseOctreeOperator* operatorObject); void recurseTreeWithOperator(RecurseOctreeOperator* operatorObject);
int encodeTreeBitstream(OctreeElementPointer element, OctreePacketData* packetData, OctreeElementBag& bag, int encodeTreeBitstream(const OctreeElementPointer& element, OctreePacketData* packetData, OctreeElementBag& bag,
EncodeBitstreamParams& params) ; EncodeBitstreamParams& params) ;
bool isDirty() const { return _isDirty; } bool isDirty() const { return _isDirty; }
@ -293,8 +293,8 @@ public:
void loadOctreeFile(const char* fileName); void loadOctreeFile(const char* fileName);
// Octree exporters // Octree exporters
bool writeToFile(const char* filename, OctreeElementPointer element = NULL, QString persistAsFileType = "json.gz"); bool writeToFile(const char* filename, const OctreeElementPointer& element = NULL, QString persistAsFileType = "json.gz");
bool writeToJSONFile(const char* filename, OctreeElementPointer element = NULL, bool doGzip = false); bool writeToJSONFile(const char* filename, const OctreeElementPointer& element = NULL, bool doGzip = false);
virtual bool writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues, virtual bool writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues,
bool skipThoseWithBadParents) = 0; bool skipThoseWithBadParents) = 0;
@ -311,18 +311,18 @@ public:
bool getShouldReaverage() const { return _shouldReaverage; } bool getShouldReaverage() const { return _shouldReaverage; }
void recurseElementWithOperation(OctreeElementPointer element, RecurseOctreeOperation operation, void recurseElementWithOperation(const OctreeElementPointer& element, const RecurseOctreeOperation& operation,
void* extraData, int recursionCount = 0); void* extraData, int recursionCount = 0);
/// Traverse child nodes of node applying operation in post-fix order /// Traverse child nodes of node applying operation in post-fix order
/// ///
void recurseElementWithPostOperation(OctreeElementPointer element, RecurseOctreeOperation operation, void recurseElementWithPostOperation(const OctreeElementPointer& element, const RecurseOctreeOperation& operation,
void* extraData, int recursionCount = 0); void* extraData, int recursionCount = 0);
void recurseElementWithOperationDistanceSorted(OctreeElementPointer element, RecurseOctreeOperation operation, void recurseElementWithOperationDistanceSorted(const OctreeElementPointer& element, const RecurseOctreeOperation& operation,
const glm::vec3& point, void* extraData, int recursionCount = 0); const glm::vec3& point, void* extraData, int recursionCount = 0);
bool recurseElementWithOperator(OctreeElementPointer element, RecurseOctreeOperator* operatorObject, int recursionCount = 0); bool recurseElementWithOperator(const OctreeElementPointer& element, RecurseOctreeOperator* operatorObject, int recursionCount = 0);
bool getIsViewing() const { return _isViewing; } /// This tree is receiving inbound viewer datagrams. bool getIsViewing() const { return _isViewing; } /// This tree is receiving inbound viewer datagrams.
void setIsViewing(bool isViewing) { _isViewing = isViewing; } void setIsViewing(bool isViewing) { _isViewing = isViewing; }
@ -353,18 +353,18 @@ public slots:
protected: protected:
void deleteOctalCodeFromTreeRecursion(OctreeElementPointer element, void* extraData); void deleteOctalCodeFromTreeRecursion(const OctreeElementPointer& element, void* extraData);
int encodeTreeBitstreamRecursion(OctreeElementPointer element, int encodeTreeBitstreamRecursion(const OctreeElementPointer& element,
OctreePacketData* packetData, OctreeElementBag& bag, OctreePacketData* packetData, OctreeElementBag& bag,
EncodeBitstreamParams& params, int& currentEncodeLevel, EncodeBitstreamParams& params, int& currentEncodeLevel,
const ViewFrustum::intersection& parentLocationThisView) const; const ViewFrustum::intersection& parentLocationThisView) const;
static bool countOctreeElementsOperation(OctreeElementPointer element, void* extraData); static bool countOctreeElementsOperation(const OctreeElementPointer& element, void* extraData);
OctreeElementPointer nodeForOctalCode(OctreeElementPointer ancestorElement, const unsigned char* needleCode, OctreeElementPointer* parentOfFoundElement) const; OctreeElementPointer nodeForOctalCode(const OctreeElementPointer& ancestorElement, const unsigned char* needleCode, OctreeElementPointer* parentOfFoundElement) const;
OctreeElementPointer createMissingElement(OctreeElementPointer lastParentElement, const unsigned char* codeToReach, int recursionCount = 0); OctreeElementPointer createMissingElement(const OctreeElementPointer& lastParentElement, const unsigned char* codeToReach, int recursionCount = 0);
int readElementData(OctreeElementPointer destinationElement, const unsigned char* nodeData, int readElementData(const OctreeElementPointer& destinationElement, const unsigned char* nodeData,
int bufferSizeBytes, ReadBitstreamToTreeParams& args); int bufferSizeBytes, ReadBitstreamToTreeParams& args);
OctreeElementPointer _rootElement = nullptr; OctreeElementPointer _rootElement = nullptr;

View file

@ -233,7 +233,7 @@ OctreeElementPointer OctreeElement::removeChildAtIndex(int childIndex) {
return returnedChild; return returnedChild;
} }
bool OctreeElement::isParentOf(OctreeElementPointer possibleChild) const { bool OctreeElement::isParentOf(const OctreeElementPointer& possibleChild) const {
if (possibleChild) { if (possibleChild) {
for (int childIndex = 0; childIndex < NUMBER_OF_CHILDREN; childIndex++) { for (int childIndex = 0; childIndex < NUMBER_OF_CHILDREN; childIndex++) {
OctreeElementPointer childAt = getChildAtIndex(childIndex); OctreeElementPointer childAt = getChildAtIndex(childIndex);
@ -300,7 +300,7 @@ void OctreeElement::deleteAllChildren() {
} }
} }
void OctreeElement::setChildAtIndex(int childIndex, OctreeElementPointer child) { void OctreeElement::setChildAtIndex(int childIndex, const OctreeElementPointer& child) {
#ifdef SIMPLE_CHILD_ARRAY #ifdef SIMPLE_CHILD_ARRAY
int previousChildCount = getChildCount(); int previousChildCount = getChildCount();
if (child) { if (child) {

View file

@ -122,7 +122,7 @@ public:
OctreeElementPointer getChildAtIndex(int childIndex) const; OctreeElementPointer getChildAtIndex(int childIndex) const;
void deleteChildAtIndex(int childIndex); void deleteChildAtIndex(int childIndex);
OctreeElementPointer removeChildAtIndex(int childIndex); OctreeElementPointer removeChildAtIndex(int childIndex);
bool isParentOf(OctreeElementPointer possibleChild) const; bool isParentOf(const OctreeElementPointer& possibleChild) const;
/// handles deletion of all descendants, returns false if delete not approved /// handles deletion of all descendants, returns false if delete not approved
bool safeDeepDeleteChildAtIndex(int childIndex, int recursionCount = 0); bool safeDeepDeleteChildAtIndex(int childIndex, int recursionCount = 0);
@ -222,7 +222,7 @@ public:
protected: protected:
void deleteAllChildren(); void deleteAllChildren();
void setChildAtIndex(int childIndex, OctreeElementPointer child); void setChildAtIndex(int childIndex, const OctreeElementPointer& child);
void calculateAACube(); void calculateAACube();

View file

@ -23,7 +23,7 @@ bool OctreeElementBag::isEmpty() {
return _bagElements.empty(); return _bagElements.empty();
} }
void OctreeElementBag::insert(OctreeElementPointer element) { void OctreeElementBag::insert(const OctreeElementPointer& element) {
_bagElements[element.get()] = element; _bagElements[element.get()] = element;
} }

View file

@ -24,7 +24,7 @@ class OctreeElementBag {
using Bag = std::unordered_map<OctreeElement*, OctreeElementWeakPointer>; using Bag = std::unordered_map<OctreeElement*, OctreeElementWeakPointer>;
public: public:
void insert(OctreeElementPointer element); // put a element into the bag void insert(const OctreeElementPointer& element); // put a element into the bag
OctreeElementPointer extract(); /// pull a element out of the bag (could come in any order) and if all of the OctreeElementPointer extract(); /// pull a element out of the bag (could come in any order) and if all of the
/// elements have expired, a single null pointer will be returned /// elements have expired, a single null pointer will be returned

View file

@ -1,5 +1,5 @@
// //
// OctreeRenderer.cpp // OctreeProcessor.cpp
// libraries/octree/src // libraries/octree/src
// //
// Created by Brad Hefta-Gaub on 12/6/13. // Created by Brad Hefta-Gaub on 12/6/13.
@ -14,49 +14,48 @@
#include <NumericalConstants.h> #include <NumericalConstants.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <RenderArgs.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "OctreeLogging.h" #include "OctreeLogging.h"
#include "OctreeRenderer.h" #include "OctreeProcessor.h"
OctreeRenderer::OctreeRenderer() : OctreeProcessor::OctreeProcessor() :
_tree(NULL), _tree(NULL),
_managedTree(false) _managedTree(false)
{ {
} }
void OctreeRenderer::init() { void OctreeProcessor::init() {
if (!_tree) { if (!_tree) {
_tree = createTree(); _tree = createTree();
_managedTree = true; _managedTree = true;
} }
} }
OctreeRenderer::~OctreeRenderer() { OctreeProcessor::~OctreeProcessor() {
} }
void OctreeRenderer::setTree(OctreePointer newTree) { void OctreeProcessor::setTree(OctreePointer newTree) {
_tree = newTree; _tree = newTree;
} }
void OctreeRenderer::processDatagram(ReceivedMessage& message, SharedNodePointer sourceNode) { void OctreeProcessor::processDatagram(ReceivedMessage& message, SharedNodePointer sourceNode) {
bool extraDebugging = false; bool extraDebugging = false;
if (extraDebugging) { if (extraDebugging) {
qCDebug(octree) << "OctreeRenderer::processDatagram()"; qCDebug(octree) << "OctreeProcessor::processDatagram()";
} }
if (!_tree) { if (!_tree) {
qCDebug(octree) << "OctreeRenderer::processDatagram() called before init, calling init()..."; qCDebug(octree) << "OctreeProcessor::processDatagram() called before init, calling init()...";
this->init(); this->init();
} }
bool showTimingDetails = false; // Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showTimingDetails = false; // Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram()", showTimingDetails); PerformanceWarning warn(showTimingDetails, "OctreeProcessor::processDatagram()", showTimingDetails);
if (message.getType() == getExpectedPacketType()) { if (message.getType() == getExpectedPacketType()) {
PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram expected PacketType", showTimingDetails); PerformanceWarning warn(showTimingDetails, "OctreeProcessor::processDatagram expected PacketType", showTimingDetails);
// if we are getting inbound packets, then our tree is also viewing, and we should remember that fact. // if we are getting inbound packets, then our tree is also viewing, and we should remember that fact.
_tree->setIsViewing(true); _tree->setIsViewing(true);
@ -79,7 +78,7 @@ void OctreeRenderer::processDatagram(ReceivedMessage& message, SharedNodePointer
OCTREE_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0; OCTREE_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;
if (extraDebugging) { if (extraDebugging) {
qCDebug(octree) << "OctreeRenderer::processDatagram() ... " qCDebug(octree) << "OctreeProcessor::processDatagram() ... "
"Got Packet Section color:" << packetIsColored << "Got Packet Section color:" << packetIsColored <<
"compressed:" << packetIsCompressed << "compressed:" << packetIsCompressed <<
"sequence: " << sequence << "sequence: " << sequence <<
@ -130,7 +129,7 @@ void OctreeRenderer::processDatagram(ReceivedMessage& message, SharedNodePointer
packetData.loadFinalizedContent(reinterpret_cast<const unsigned char*>(message.getRawMessage() + message.getPosition()), packetData.loadFinalizedContent(reinterpret_cast<const unsigned char*>(message.getRawMessage() + message.getPosition()),
sectionLength); sectionLength);
if (extraDebugging) { if (extraDebugging) {
qCDebug(octree) << "OctreeRenderer::processDatagram() ... " qCDebug(octree) << "OctreeProcessor::processDatagram() ... "
"Got Packet Section color:" << packetIsColored << "Got Packet Section color:" << packetIsColored <<
"compressed:" << packetIsCompressed << "compressed:" << packetIsCompressed <<
"sequence: " << sequence << "sequence: " << sequence <<
@ -143,13 +142,13 @@ void OctreeRenderer::processDatagram(ReceivedMessage& message, SharedNodePointer
} }
if (extraDebugging) { if (extraDebugging) {
qCDebug(octree) << "OctreeRenderer::processDatagram() ******* START _tree->readBitstreamToTree()..."; qCDebug(octree) << "OctreeProcessor::processDatagram() ******* START _tree->readBitstreamToTree()...";
} }
startReadBitsteam = usecTimestampNow(); startReadBitsteam = usecTimestampNow();
_tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args); _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
endReadBitsteam = usecTimestampNow(); endReadBitsteam = usecTimestampNow();
if (extraDebugging) { if (extraDebugging) {
qCDebug(octree) << "OctreeRenderer::processDatagram() ******* END _tree->readBitstreamToTree()..."; qCDebug(octree) << "OctreeProcessor::processDatagram() ******* END _tree->readBitstreamToTree()...";
} }
}); });
@ -198,32 +197,7 @@ void OctreeRenderer::processDatagram(ReceivedMessage& message, SharedNodePointer
} }
} }
bool OctreeRenderer::renderOperation(OctreeElementPointer element, void* extraData) { void OctreeProcessor::clear() {
RenderArgs* args = static_cast<RenderArgs*>(extraData);
if (element->isInView(args->getViewFrustum())) {
if (element->hasContent()) {
if (element->calculateShouldRender(args->getViewFrustum(), args->_sizeScale, args->_boundaryLevelAdjust)) {
args->_renderer->renderElement(element, args);
} else {
return false; // if we shouldn't render, then we also should stop recursing.
}
}
return true; // continue recursing
}
// if not in view stop recursing
return false;
}
void OctreeRenderer::render(RenderArgs* renderArgs) {
if (_tree) {
renderArgs->_renderer = sharedFromThis();
_tree->withReadLock([&] {
_tree->recurseTreeWithOperation(renderOperation, renderArgs);
});
}
}
void OctreeRenderer::clear() {
if (_tree) { if (_tree) {
_tree->withWriteLock([&] { _tree->withWriteLock([&] {
_tree->eraseAllOctreeElements(); _tree->eraseAllOctreeElements();

View file

@ -1,5 +1,5 @@
// //
// OctreeRenderer.h // OctreeProcessor.h
// libraries/octree/src // libraries/octree/src
// //
// Created by Brad Hefta-Gaub on 12/6/13. // Created by Brad Hefta-Gaub on 12/6/13.
@ -9,8 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#ifndef hifi_OctreeRenderer_h #ifndef hifi_OctreeProcessor_h
#define hifi_OctreeRenderer_h #define hifi_OctreeProcessor_h
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <stdint.h> #include <stdint.h>
@ -18,27 +18,22 @@
#include <QObject> #include <QObject>
#include <udt/PacketHeaders.h> #include <udt/PacketHeaders.h>
#include <RenderArgs.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <ViewFrustum.h>
#include "Octree.h" #include "Octree.h"
#include "OctreePacketData.h" #include "OctreePacketData.h"
class OctreeRenderer;
// Generic client side Octree renderer class. // Generic client side Octree renderer class.
class OctreeRenderer : public QObject, public QEnableSharedFromThis<OctreeRenderer> { class OctreeProcessor : public QObject, public QEnableSharedFromThis<OctreeProcessor> {
Q_OBJECT Q_OBJECT
public: public:
OctreeRenderer(); OctreeProcessor();
virtual ~OctreeRenderer(); virtual ~OctreeProcessor();
virtual char getMyNodeType() const = 0; virtual char getMyNodeType() const = 0;
virtual PacketType getMyQueryMessageType() const = 0; virtual PacketType getMyQueryMessageType() const = 0;
virtual PacketType getExpectedPacketType() const = 0; virtual PacketType getExpectedPacketType() const = 0;
virtual void renderElement(OctreeElementPointer element, RenderArgs* args) { }
virtual void setTree(OctreePointer newTree); virtual void setTree(OctreePointer newTree);
@ -48,14 +43,6 @@ public:
/// initialize and GPU/rendering related resources /// initialize and GPU/rendering related resources
virtual void init(); virtual void init();
/// render the content of the octree
virtual void render(RenderArgs* renderArgs);
const ViewFrustum& getViewFrustum() const { return _viewFrustum; }
void setViewFrustum(const ViewFrustum& viewFrustum) { _viewFrustum = viewFrustum; }
static bool renderOperation(OctreeElementPointer element, void* extraData);
/// clears the tree /// clears the tree
virtual void clear(); virtual void clear();
@ -75,7 +62,6 @@ protected:
OctreePointer _tree; OctreePointer _tree;
bool _managedTree; bool _managedTree;
ViewFrustum _viewFrustum;
SimpleMovingAverage _elementsPerPacket; SimpleMovingAverage _elementsPerPacket;
SimpleMovingAverage _entitiesPerPacket; SimpleMovingAverage _entitiesPerPacket;
@ -95,4 +81,4 @@ protected:
}; };
#endif // hifi_OctreeRenderer_h #endif // hifi_OctreeProcessor_h

View file

@ -141,7 +141,7 @@ OctreeSceneStats::~OctreeSceneStats() {
reset(); reset();
} }
void OctreeSceneStats::sceneStarted(bool isFullScene, bool isMoving, OctreeElementPointer root, void OctreeSceneStats::sceneStarted(bool isFullScene, bool isMoving, const OctreeElementPointer& root,
JurisdictionMap* jurisdictionMap) { JurisdictionMap* jurisdictionMap) {
reset(); // resets packet and octree stats reset(); // resets packet and octree stats
_isStarted = true; _isStarted = true;
@ -246,7 +246,7 @@ void OctreeSceneStats::packetSent(int bytes) {
_bytes += bytes; _bytes += bytes;
} }
void OctreeSceneStats::traversed(const OctreeElementPointer element) { void OctreeSceneStats::traversed(const OctreeElementPointer& element) {
_traversed++; _traversed++;
if (element->isLeaf()) { if (element->isLeaf()) {
_leaves++; _leaves++;
@ -255,7 +255,7 @@ void OctreeSceneStats::traversed(const OctreeElementPointer element) {
} }
} }
void OctreeSceneStats::skippedDistance(const OctreeElementPointer element) { void OctreeSceneStats::skippedDistance(const OctreeElementPointer& element) {
_skippedDistance++; _skippedDistance++;
if (element->isLeaf()) { if (element->isLeaf()) {
_leavesSkippedDistance++; _leavesSkippedDistance++;
@ -264,7 +264,7 @@ void OctreeSceneStats::skippedDistance(const OctreeElementPointer element) {
} }
} }
void OctreeSceneStats::skippedOutOfView(const OctreeElementPointer element) { void OctreeSceneStats::skippedOutOfView(const OctreeElementPointer& element) {
_skippedOutOfView++; _skippedOutOfView++;
if (element->isLeaf()) { if (element->isLeaf()) {
_leavesSkippedOutOfView++; _leavesSkippedOutOfView++;
@ -273,7 +273,7 @@ void OctreeSceneStats::skippedOutOfView(const OctreeElementPointer element) {
} }
} }
void OctreeSceneStats::skippedWasInView(const OctreeElementPointer element) { void OctreeSceneStats::skippedWasInView(const OctreeElementPointer& element) {
_skippedWasInView++; _skippedWasInView++;
if (element->isLeaf()) { if (element->isLeaf()) {
_leavesSkippedWasInView++; _leavesSkippedWasInView++;
@ -282,7 +282,7 @@ void OctreeSceneStats::skippedWasInView(const OctreeElementPointer element) {
} }
} }
void OctreeSceneStats::skippedNoChange(const OctreeElementPointer element) { void OctreeSceneStats::skippedNoChange(const OctreeElementPointer& element) {
_skippedNoChange++; _skippedNoChange++;
if (element->isLeaf()) { if (element->isLeaf()) {
_leavesSkippedNoChange++; _leavesSkippedNoChange++;
@ -291,7 +291,7 @@ void OctreeSceneStats::skippedNoChange(const OctreeElementPointer element) {
} }
} }
void OctreeSceneStats::skippedOccluded(const OctreeElementPointer element) { void OctreeSceneStats::skippedOccluded(const OctreeElementPointer& element) {
_skippedOccluded++; _skippedOccluded++;
if (element->isLeaf()) { if (element->isLeaf()) {
_leavesSkippedOccluded++; _leavesSkippedOccluded++;
@ -300,7 +300,7 @@ void OctreeSceneStats::skippedOccluded(const OctreeElementPointer element) {
} }
} }
void OctreeSceneStats::colorSent(const OctreeElementPointer element) { void OctreeSceneStats::colorSent(const OctreeElementPointer& element) {
_colorSent++; _colorSent++;
if (element->isLeaf()) { if (element->isLeaf()) {
_leavesColorSent++; _leavesColorSent++;
@ -309,7 +309,7 @@ void OctreeSceneStats::colorSent(const OctreeElementPointer element) {
} }
} }
void OctreeSceneStats::didntFit(const OctreeElementPointer element) { void OctreeSceneStats::didntFit(const OctreeElementPointer& element) {
_didntFit++; _didntFit++;
if (element->isLeaf()) { if (element->isLeaf()) {
_leavesDidntFit++; _leavesDidntFit++;

View file

@ -39,7 +39,7 @@ public:
OctreeSceneStats& operator= (const OctreeSceneStats& other); // copy assignment OctreeSceneStats& operator= (const OctreeSceneStats& other); // copy assignment
/// Call when beginning the computation of a scene. Initializes internal structures /// Call when beginning the computation of a scene. Initializes internal structures
void sceneStarted(bool fullScene, bool moving, OctreeElementPointer root, JurisdictionMap* jurisdictionMap); void sceneStarted(bool fullScene, bool moving, const OctreeElementPointer& root, JurisdictionMap* jurisdictionMap);
bool getIsSceneStarted() const { return _isStarted; } bool getIsSceneStarted() const { return _isStarted; }
/// Call when the computation of a scene is completed. Finalizes internal structures /// Call when the computation of a scene is completed. Finalizes internal structures
@ -57,28 +57,28 @@ public:
void encodeStopped(); void encodeStopped();
/// Track that a element was traversed as part of computation of a scene. /// Track that a element was traversed as part of computation of a scene.
void traversed(const OctreeElementPointer element); void traversed(const OctreeElementPointer& element);
/// Track that a element was skipped as part of computation of a scene due to being beyond the LOD distance. /// Track that a element was skipped as part of computation of a scene due to being beyond the LOD distance.
void skippedDistance(const OctreeElementPointer element); void skippedDistance(const OctreeElementPointer& element);
/// Track that a element was skipped as part of computation of a scene due to being out of view. /// Track that a element was skipped as part of computation of a scene due to being out of view.
void skippedOutOfView(const OctreeElementPointer element); void skippedOutOfView(const OctreeElementPointer& element);
/// Track that a element was skipped as part of computation of a scene due to previously being in view while in delta sending /// Track that a element was skipped as part of computation of a scene due to previously being in view while in delta sending
void skippedWasInView(const OctreeElementPointer element); void skippedWasInView(const OctreeElementPointer& element);
/// Track that a element was skipped as part of computation of a scene due to not having changed since last full scene sent /// Track that a element was skipped as part of computation of a scene due to not having changed since last full scene sent
void skippedNoChange(const OctreeElementPointer element); void skippedNoChange(const OctreeElementPointer& element);
/// Track that a element was skipped as part of computation of a scene due to being occluded /// Track that a element was skipped as part of computation of a scene due to being occluded
void skippedOccluded(const OctreeElementPointer element); void skippedOccluded(const OctreeElementPointer& element);
/// Track that a element's color was was sent as part of computation of a scene /// Track that a element's color was was sent as part of computation of a scene
void colorSent(const OctreeElementPointer element); void colorSent(const OctreeElementPointer& element);
/// Track that a element was due to be sent, but didn't fit in the packet and was moved to next packet /// Track that a element was due to be sent, but didn't fit in the packet and was moved to next packet
void didntFit(const OctreeElementPointer element); void didntFit(const OctreeElementPointer& element);
/// Track that the color bitmask was was sent as part of computation of a scene /// Track that the color bitmask was was sent as part of computation of a scene
void colorBitsWritten(); void colorBitsWritten();

View file

@ -1,5 +1,11 @@
set(TARGET_NAME physics) set(TARGET_NAME physics)
setup_hifi_library() setup_hifi_library()
link_hifi_libraries(shared fbx entities model) link_hifi_libraries(shared fbx entities model)
include_hifi_library_headers(networking)
include_hifi_library_headers(gpu)
include_hifi_library_headers(avatars)
include_hifi_library_headers(audio)
include_hifi_library_headers(octree)
include_hifi_library_headers(animation)
target_bullet() target_bullet()

View file

@ -4,6 +4,9 @@ AUTOSCRIBE_SHADER_LIB(gpu model render)
qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc") qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc")
setup_hifi_library(Widgets OpenGL Network Qml Quick Script) setup_hifi_library(Widgets OpenGL Network Qml Quick Script)
link_hifi_libraries(shared ktx gpu model model-networking render animation fbx entities image procedural) link_hifi_libraries(shared ktx gpu model model-networking render animation fbx entities image procedural)
include_hifi_library_headers(networking)
include_hifi_library_headers(octree)
include_hifi_library_headers(audio)
if (NOT ANDROID) if (NOT ANDROID)
target_nsight() target_nsight()

View file

@ -12,10 +12,10 @@
#ifndef hifi_DeferredFrameTransform_h #ifndef hifi_DeferredFrameTransform_h
#define hifi_DeferredFrameTransform_h #define hifi_DeferredFrameTransform_h
#include "gpu/Resource.h" #include <gpu/Resource.h>
#include "render/DrawTask.h"
class RenderArgs; #include <render/Forward.h>
#include <render/DrawTask.h>
// DeferredFrameTransform is a helper class gathering in one place the needed camera transform // DeferredFrameTransform is a helper class gathering in one place the needed camera transform
// and frame resolution needed for all the deferred rendering passes taking advantage of the Deferred buffers // and frame resolution needed for all the deferred rendering passes taking advantage of the Deferred buffers

View file

@ -15,7 +15,6 @@
#include "gpu/Resource.h" #include "gpu/Resource.h"
#include "gpu/Framebuffer.h" #include "gpu/Framebuffer.h"
class RenderArgs;
// DeferredFramebuffer is a helper class gathering in one place the GBuffer (Framebuffer) and lighting framebuffer // DeferredFramebuffer is a helper class gathering in one place the GBuffer (Framebuffer) and lighting framebuffer
class DeferredFramebuffer { class DeferredFramebuffer {

View file

@ -37,7 +37,6 @@
#include "AmbientOcclusionEffect.h" #include "AmbientOcclusionEffect.h"
class RenderArgs;
struct LightLocations; struct LightLocations;
using LightLocationsPtr = std::shared_ptr<LightLocations>; using LightLocationsPtr = std::shared_ptr<LightLocations>;

View file

@ -12,10 +12,10 @@
#ifndef hifi_LightingModel_h #ifndef hifi_LightingModel_h
#define hifi_LightingModel_h #define hifi_LightingModel_h
#include "gpu/Resource.h" #include <gpu/Resource.h>
#include "render/DrawTask.h"
class RenderArgs; #include <render/Forward.h>
#include <render/DrawTask.h>
// LightingModel is a helper class gathering in one place the flags to enable the lighting contributions // LightingModel is a helper class gathering in one place the flags to enable the lighting contributions
class LightingModel { class LightingModel {

View file

@ -557,6 +557,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
if (_fadeState == FADE_WAITING_TO_START) { if (_fadeState == FADE_WAITING_TO_START) {
if (model->isLoaded()) { if (model->isLoaded()) {
// FIXME as far as I can tell this is the ONLY reason render-util depends on entities.
if (EntityItem::getEntitiesShouldFadeFunction()()) { if (EntityItem::getEntitiesShouldFadeFunction()()) {
_fadeStartTime = usecTimestampNow(); _fadeStartTime = usecTimestampNow();
_fadeState = FADE_IN_PROGRESS; _fadeState = FADE_IN_PROGRESS;

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "Model.h"
#include <QMetaType> #include <QMetaType>
#include <QRunnable> #include <QRunnable>
#include <QThreadPool> #include <QThreadPool>
@ -24,7 +26,6 @@
#include "AbstractViewStateInterface.h" #include "AbstractViewStateInterface.h"
#include "MeshPartPayload.h" #include "MeshPartPayload.h"
#include "Model.h"
#include "RenderUtilsLogging.h" #include "RenderUtilsLogging.h"
#include <Trace.h> #include <Trace.h>

View file

@ -25,6 +25,7 @@
#include <DependencyManager.h> #include <DependencyManager.h>
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <gpu/Batch.h> #include <gpu/Batch.h>
#include <render/Forward.h>
#include <render/Scene.h> #include <render/Scene.h>
#include <Transform.h> #include <Transform.h>
#include <SpatiallyNestable.h> #include <SpatiallyNestable.h>
@ -34,10 +35,10 @@
#include "TextureCache.h" #include "TextureCache.h"
#include "Rig.h" #include "Rig.h"
class AbstractViewStateInterface; class AbstractViewStateInterface;
class QScriptEngine; class QScriptEngine;
#include "RenderArgs.h"
class ViewFrustum; class ViewFrustum;
namespace render { namespace render {

View file

@ -14,7 +14,6 @@
#include <PerfStat.h> #include <PerfStat.h>
#include <PathUtils.h> #include <PathUtils.h>
#include <RenderArgs.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <gpu/Context.h> #include <gpu/Context.h>

View file

@ -15,7 +15,6 @@
#include <PerfStat.h> #include <PerfStat.h>
#include <PathUtils.h> #include <PathUtils.h>
#include <RenderArgs.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <gpu/Context.h> #include <gpu/Context.h>

View file

@ -11,7 +11,6 @@
#include "StencilMaskPass.h" #include "StencilMaskPass.h"
#include <RenderArgs.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <gpu/Context.h> #include <gpu/Context.h>

View file

@ -14,7 +14,6 @@
#include <gpu/Context.h> #include <gpu/Context.h>
#include <gpu/StandardShaderLib.h> #include <gpu/StandardShaderLib.h>
#include <RenderArgs.h>
#include "StencilMaskPass.h" #include "StencilMaskPass.h"
#include "FramebufferCache.h" #include "FramebufferCache.h"

View file

@ -17,11 +17,10 @@
#include <gpu/Resource.h> #include <gpu/Resource.h>
#include <gpu/Pipeline.h> #include <gpu/Pipeline.h>
#include <render/Forward.h>
#include <render/DrawTask.h> #include <render/DrawTask.h>
class RenderArgs;
class ToneMappingEffect { class ToneMappingEffect {
public: public:
ToneMappingEffect(); ToneMappingEffect();

View file

@ -2,7 +2,8 @@ set(TARGET_NAME render)
AUTOSCRIBE_SHADER_LIB(gpu model) AUTOSCRIBE_SHADER_LIB(gpu model)
setup_hifi_library() setup_hifi_library()
link_hifi_libraries(shared ktx gpu model)
# render needs octree only for getAccuracyAngle(float, int) # render needs octree only for getAccuracyAngle(float, int)
link_hifi_libraries(shared ktx gpu model octree) include_hifi_library_headers(octree)
target_nsight() target_nsight()

View file

@ -0,0 +1,128 @@
//
// Created by Brad Hefta-Gaub on 10/29/14.
// Copyright 2013-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
//
#pragma once
#ifndef hifi_render_Args_h
#define hifi_render_Args_h
#include <functional>
#include <memory>
#include <stack>
#include <GLMHelpers.h>
#include <ViewFrustum.h>
#include <gpu/Forward.h>
#include "Forward.h"
class AABox;
namespace render {
class RenderDetails {
public:
enum Type {
ITEM,
SHADOW,
OTHER
};
struct Item {
int _considered = 0;
int _outOfView = 0;
int _tooSmall = 0;
int _rendered = 0;
};
int _materialSwitches = 0;
int _trianglesRendered = 0;
Item _item;
Item _shadow;
Item _other;
Item& edit(Type type) {
switch (type) {
case SHADOW:
return _shadow;
case ITEM:
return _item;
default:
return _other;
}
}
};
class Args {
public:
enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE, MIRROR_RENDER_MODE };
enum DisplayMode { MONO, STEREO_MONITOR, STEREO_HMD };
enum DebugFlags {
RENDER_DEBUG_NONE = 0,
RENDER_DEBUG_HULLS = 1
};
Args() {}
Args(const gpu::ContextPointer& context,
QSharedPointer<QObject> renderData = QSharedPointer<QObject>(nullptr),
float sizeScale = 1.0f,
int boundaryLevelAdjust = 0,
RenderMode renderMode = DEFAULT_RENDER_MODE,
DisplayMode displayMode = MONO,
DebugFlags debugFlags = RENDER_DEBUG_NONE,
gpu::Batch* batch = nullptr) :
_context(context),
_renderData(renderData),
_sizeScale(sizeScale),
_boundaryLevelAdjust(boundaryLevelAdjust),
_renderMode(renderMode),
_displayMode(displayMode),
_debugFlags(debugFlags),
_batch(batch) {
}
bool hasViewFrustum() const { return _viewFrustums.size() > 0; }
void setViewFrustum(const ViewFrustum& viewFrustum) {
while (_viewFrustums.size() > 0) {
_viewFrustums.pop();
}
_viewFrustums.push(viewFrustum);
}
const ViewFrustum& getViewFrustum() const { assert(_viewFrustums.size() > 0); return _viewFrustums.top(); }
void pushViewFrustum(const ViewFrustum& viewFrustum) { _viewFrustums.push(viewFrustum); }
void popViewFrustum() { _viewFrustums.pop(); }
std::shared_ptr<gpu::Context> _context;
std::shared_ptr<gpu::Framebuffer> _blitFramebuffer;
std::shared_ptr<render::ShapePipeline> _pipeline;
QSharedPointer<QObject> _renderData;
std::stack<ViewFrustum> _viewFrustums;
glm::ivec4 _viewport { 0.0f, 0.0f, 1.0f, 1.0f };
glm::vec3 _boomOffset { 0.0f, 0.0f, 1.0f };
float _sizeScale { 1.0f };
int _boundaryLevelAdjust { 0 };
RenderMode _renderMode { DEFAULT_RENDER_MODE };
DisplayMode _displayMode { MONO };
DebugFlags _debugFlags { RENDER_DEBUG_NONE };
gpu::Batch* _batch = nullptr;
uint32_t _globalShapeKey { 0 };
bool _enableTexturing { true };
RenderDetails _details;
render::ScenePointer _scene;
int8_t _cameraMode { -1 };
};
}
using RenderArgs = render::Args;
#endif // hifi_render_Args_h

View file

@ -16,11 +16,11 @@
#include <OctreeUtils.h> #include <OctreeUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <RenderArgs.h>
#include <gpu/Context.h> #include <gpu/Context.h>
#include <gpu/StandardShaderLib.h> #include <gpu/StandardShaderLib.h>
#include "Args.h"
#include "drawCellBounds_vert.h" #include "drawCellBounds_vert.h"
#include "drawCellBounds_frag.h" #include "drawCellBounds_frag.h"

View file

@ -12,9 +12,10 @@
#ifndef hifi_render_DrawSceneOctree_h #ifndef hifi_render_DrawSceneOctree_h
#define hifi_render_DrawSceneOctree_h #define hifi_render_DrawSceneOctree_h
#include "DrawTask.h"
#include "gpu/Batch.h"
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <gpu/Batch.h>
#include "DrawTask.h"
namespace render { namespace render {
class DrawSceneOctreeConfig : public Job::Config { class DrawSceneOctreeConfig : public Job::Config {

View file

@ -16,10 +16,11 @@
#include <PerfStat.h> #include <PerfStat.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <RenderArgs.h>
#include <gpu/Context.h> #include <gpu/Context.h>
#include "Args.h"
#include "drawItemBounds_vert.h" #include "drawItemBounds_vert.h"
#include "drawItemBounds_frag.h" #include "drawItemBounds_frag.h"
#include "drawItemStatus_vert.h" #include "drawItemStatus_vert.h"

View file

@ -0,0 +1,25 @@
//
// Created by Bradley Austin Davis on 2017/06/15
// Copyright 2013-2017 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
//
#pragma once
#ifndef hifi_render_Forward_h
#define hifi_render_Forward_h
#include <memory>
namespace render {
class Scene;
using ScenePointer = std::shared_ptr<Scene>;
class ShapePipeline;
class Args;
}
using RenderArgs = render::Args;
#endif // hifi_render_Forward_h

Some files were not shown because too many files have changed in this diff Show more