mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-04 23:10:15 +02:00
Merge branch 'team-teaching' of https://github.com/highfidelity/hifi into punk
This commit is contained in:
commit
c10384f91b
7 changed files with 140 additions and 20 deletions
|
@ -119,6 +119,8 @@
|
||||||
#include "gpu/Context.h"
|
#include "gpu/Context.h"
|
||||||
#include "gpu/GLBackend.h"
|
#include "gpu/GLBackend.h"
|
||||||
|
|
||||||
|
#include "RenderDeferredTask.h"
|
||||||
|
|
||||||
#include "scripting/AccountScriptingInterface.h"
|
#include "scripting/AccountScriptingInterface.h"
|
||||||
#include "scripting/AudioDeviceScriptingInterface.h"
|
#include "scripting/AudioDeviceScriptingInterface.h"
|
||||||
#include "scripting/ClipboardScriptingInterface.h"
|
#include "scripting/ClipboardScriptingInterface.h"
|
||||||
|
@ -372,7 +374,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_runningScriptsWidget = new RunningScriptsWidget(_window);
|
_runningScriptsWidget = new RunningScriptsWidget(_window);
|
||||||
|
|
||||||
|
|
||||||
_renderEngine->buildStandardTaskPipeline();
|
_renderEngine->addTask(render::TaskPointer(new RenderDeferredTask()));
|
||||||
_renderEngine->registerScene(_main3DScene);
|
_renderEngine->registerScene(_main3DScene);
|
||||||
|
|
||||||
// start the nodeThread so its event loop is running
|
// start the nodeThread so its event loop is running
|
||||||
|
@ -3168,6 +3170,7 @@ public:
|
||||||
typedef render::Payload<WorldBoxRenderData> Payload;
|
typedef render::Payload<WorldBoxRenderData> Payload;
|
||||||
typedef Payload::DataPointer Pointer;
|
typedef Payload::DataPointer Pointer;
|
||||||
|
|
||||||
|
int _val = 0;
|
||||||
static render::ItemID _item; // unique WorldBoxRenderData
|
static render::ItemID _item; // unique WorldBoxRenderData
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3402,6 +3405,14 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
WorldBoxRenderData::_item = _main3DScene->allocateID();
|
WorldBoxRenderData::_item = _main3DScene->allocateID();
|
||||||
|
|
||||||
pendingChanges.resetItem(WorldBoxRenderData::_item, worldBoxRenderPayload);
|
pendingChanges.resetItem(WorldBoxRenderData::_item, worldBoxRenderPayload);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
pendingChanges.updateItem<WorldBoxRenderData>(WorldBoxRenderData::_item,
|
||||||
|
[](WorldBoxRenderData& payload) {
|
||||||
|
payload._val++;
|
||||||
|
// A test Update to proof the concept is woking
|
||||||
|
// qCDebug(interfaceapp, "MyFirst update message!!!!! %u", payload._val);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <EntityScriptingInterface.h> // for RayToEntityIntersectionResult
|
#include <EntityScriptingInterface.h> // for RayToEntityIntersectionResult
|
||||||
#include <MouseEvent.h>
|
#include <MouseEvent.h>
|
||||||
#include <OctreeRenderer.h>
|
#include <OctreeRenderer.h>
|
||||||
#include <render/Scene.h>
|
|
||||||
#include <ScriptCache.h>
|
#include <ScriptCache.h>
|
||||||
#include <AbstractAudioInterface.h>
|
#include <AbstractAudioInterface.h>
|
||||||
|
|
||||||
|
|
|
@ -41,3 +41,4 @@ namespace render {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
40
libraries/render-utils/src/RenderDeferredTask.cpp
Executable file
40
libraries/render-utils/src/RenderDeferredTask.cpp
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// RenderDeferredTask.cpp
|
||||||
|
// render-utils/src/
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 5/29/15.
|
||||||
|
// Copyright 20154 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 "RenderDeferredTask.h"
|
||||||
|
|
||||||
|
using namespace render;
|
||||||
|
|
||||||
|
RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
|
_jobs.push_back(Job(DrawOpaque()));
|
||||||
|
_jobs.push_back(Job(DrawLight()));
|
||||||
|
_jobs.push_back(Job(DrawTransparent()));
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderDeferredTask::~RenderDeferredTask() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||||
|
// sanity checks
|
||||||
|
assert(sceneContext);
|
||||||
|
if (!sceneContext->_scene) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Is it possible that we render without a viewFrustum ?
|
||||||
|
if (!(renderContext->args && renderContext->args->_viewFrustum)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto job : _jobs) {
|
||||||
|
job.run(sceneContext, renderContext);
|
||||||
|
}
|
||||||
|
};
|
31
libraries/render-utils/src/RenderDeferredTask.h
Executable file
31
libraries/render-utils/src/RenderDeferredTask.h
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
//
|
||||||
|
// RenderDeferredTask.h
|
||||||
|
// render-utils/src/
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 5/29/15.
|
||||||
|
// Copyright 20154 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_RenderDeferredTask_h
|
||||||
|
#define hifi_RenderDeferredTask_h
|
||||||
|
|
||||||
|
#include "render/DrawTask.h"
|
||||||
|
|
||||||
|
|
||||||
|
class RenderDeferredTask : public render::Task {
|
||||||
|
public:
|
||||||
|
|
||||||
|
RenderDeferredTask();
|
||||||
|
~RenderDeferredTask();
|
||||||
|
|
||||||
|
render::Jobs _jobs;
|
||||||
|
|
||||||
|
virtual void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // hifi_RenderDeferredTask_h
|
|
@ -66,10 +66,6 @@ void Item::kill() {
|
||||||
_key._flags.reset();
|
_key._flags.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::move() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void PendingChanges::resetItem(ItemID id, const PayloadPointer& payload) {
|
void PendingChanges::resetItem(ItemID id, const PayloadPointer& payload) {
|
||||||
_resetItems.push_back(id);
|
_resetItems.push_back(id);
|
||||||
_resetPayloads.push_back(payload);
|
_resetPayloads.push_back(payload);
|
||||||
|
@ -79,8 +75,9 @@ void PendingChanges::removeItem(ItemID id) {
|
||||||
_removedItems.push_back(id);
|
_removedItems.push_back(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingChanges::moveItem(ItemID id) {
|
void PendingChanges::updateItem(ItemID id, const UpdateFunctorPointer& functor) {
|
||||||
_movedItems.push_back(id);
|
_updatedItems.push_back(id);
|
||||||
|
_updateFunctors.push_back(functor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +85,8 @@ void PendingChanges::merge(PendingChanges& changes) {
|
||||||
_resetItems.insert(_resetItems.end(), changes._resetItems.begin(), changes._resetItems.end());
|
_resetItems.insert(_resetItems.end(), changes._resetItems.begin(), changes._resetItems.end());
|
||||||
_resetPayloads.insert(_resetPayloads.end(), changes._resetPayloads.begin(), changes._resetPayloads.end());
|
_resetPayloads.insert(_resetPayloads.end(), changes._resetPayloads.begin(), changes._resetPayloads.end());
|
||||||
_removedItems.insert(_removedItems.end(), changes._removedItems.begin(), changes._removedItems.end());
|
_removedItems.insert(_removedItems.end(), changes._removedItems.begin(), changes._removedItems.end());
|
||||||
_movedItems.insert(_movedItems.end(), changes._movedItems.begin(), changes._movedItems.end());
|
_updatedItems.insert(_updatedItems.end(), changes._updatedItems.begin(), changes._updatedItems.end());
|
||||||
|
_updateFunctors.insert(_updateFunctors.end(), changes._updateFunctors.begin(), changes._updateFunctors.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene::Scene() {
|
Scene::Scene() {
|
||||||
|
@ -133,7 +131,7 @@ void Scene::processPendingChangesQueue() {
|
||||||
// capture anything coming from the pendingChanges
|
// capture anything coming from the pendingChanges
|
||||||
resetItems(consolidatedPendingChanges._resetItems, consolidatedPendingChanges._resetPayloads);
|
resetItems(consolidatedPendingChanges._resetItems, consolidatedPendingChanges._resetPayloads);
|
||||||
removeItems(consolidatedPendingChanges._removedItems);
|
removeItems(consolidatedPendingChanges._removedItems);
|
||||||
moveItems(consolidatedPendingChanges._movedItems);
|
updateItems(consolidatedPendingChanges._updatedItems, consolidatedPendingChanges._updateFunctors);
|
||||||
|
|
||||||
// ready to go back to rendering activities
|
// ready to go back to rendering activities
|
||||||
_itemsMutex.unlock();
|
_itemsMutex.unlock();
|
||||||
|
@ -159,9 +157,11 @@ void Scene::removeItems(const ItemIDs& ids) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::moveItems(const ItemIDs& ids) {
|
void Scene::updateItems(const ItemIDs& ids, UpdateFunctors& functors) {
|
||||||
for (auto movedID :ids) {
|
auto updateID = ids.begin();
|
||||||
_items[movedID].move();
|
auto updateFunctor = functors.begin();
|
||||||
|
for (;updateID != ids.end(); updateID++, updateFunctor++) {
|
||||||
|
_items[(*updateID)].update((*updateFunctor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,7 @@ inline QDebug operator<<(QDebug debug, const ItemFilter& me) {
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Item {
|
class Item {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<Item> Vector;
|
typedef std::vector<Item> Vector;
|
||||||
|
@ -194,6 +195,13 @@ public:
|
||||||
int _firstFrame;
|
int _firstFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Update Functor
|
||||||
|
class UpdateFunctorInterface {
|
||||||
|
public:
|
||||||
|
virtual ~UpdateFunctorInterface() {}
|
||||||
|
};
|
||||||
|
typedef std::shared_ptr<UpdateFunctorInterface> UpdateFunctorPointer;
|
||||||
|
|
||||||
// Payload is whatever is in this Item and implement the Payload Interface
|
// Payload is whatever is in this Item and implement the Payload Interface
|
||||||
class PayloadInterface {
|
class PayloadInterface {
|
||||||
public:
|
public:
|
||||||
|
@ -201,18 +209,23 @@ public:
|
||||||
virtual const Bound getBound() const = 0;
|
virtual const Bound getBound() const = 0;
|
||||||
virtual void render(RenderArgs* args) = 0;
|
virtual void render(RenderArgs* args) = 0;
|
||||||
|
|
||||||
|
virtual void update(const UpdateFunctorPointer& functor) = 0;
|
||||||
|
|
||||||
~PayloadInterface() {}
|
~PayloadInterface() {}
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef std::shared_ptr<PayloadInterface> PayloadPointer;
|
typedef std::shared_ptr<PayloadInterface> PayloadPointer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Item() {}
|
Item() {}
|
||||||
~Item() {}
|
~Item() {}
|
||||||
|
|
||||||
void resetPayload(const PayloadPointer& payload);
|
void resetPayload(const PayloadPointer& payload);
|
||||||
void kill();
|
void kill();
|
||||||
void move();
|
|
||||||
|
|
||||||
// Check heuristic key
|
// Check heuristic key
|
||||||
const ItemKey& getKey() const { return _key; }
|
const ItemKey& getKey() const { return _key; }
|
||||||
|
@ -220,6 +233,7 @@ public:
|
||||||
// Payload Interface
|
// Payload Interface
|
||||||
const Bound getBound() const { return _payload->getBound(); }
|
const Bound getBound() const { return _payload->getBound(); }
|
||||||
void render(RenderArgs* args) { _payload->render(args); }
|
void render(RenderArgs* args) { _payload->render(args); }
|
||||||
|
void update(const UpdateFunctorPointer& updateFunctor) { _payload->update(updateFunctor); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PayloadPointer _payload;
|
PayloadPointer _payload;
|
||||||
|
@ -228,12 +242,26 @@ protected:
|
||||||
friend class Scene;
|
friend class Scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef Item::UpdateFunctorInterface UpdateFunctorInterface;
|
||||||
|
typedef Item::UpdateFunctorPointer UpdateFunctorPointer;
|
||||||
|
typedef std::vector<UpdateFunctorPointer> UpdateFunctors;
|
||||||
|
|
||||||
|
template <class T> class UpdateFunctor : public Item::UpdateFunctorInterface {
|
||||||
|
public:
|
||||||
|
typedef std::function<void(T&)> Func;
|
||||||
|
Func _func;
|
||||||
|
|
||||||
|
UpdateFunctor(Func func): _func(func) {}
|
||||||
|
~UpdateFunctor() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
inline QDebug operator<<(QDebug debug, const Item& item) {
|
inline QDebug operator<<(QDebug debug, const Item& item) {
|
||||||
debug << "[Item: _key:" << item.getKey() << ", bounds:" << item.getBound() << "]";
|
debug << "[Item: _key:" << item.getKey() << ", bounds:" << item.getBound() << "]";
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// THe Payload class is the real Payload to be used
|
// THe Payload class is the real Payload to be used
|
||||||
// THis allow anything to be turned into a Payload as long as the required interface functions are available
|
// THis allow anything to be turned into a Payload as long as the required interface functions are available
|
||||||
// When creating a new kind of payload from a new "stuff" class then you need to create specialized version for "stuff"
|
// When creating a new kind of payload from a new "stuff" class then you need to create specialized version for "stuff"
|
||||||
|
@ -245,11 +273,14 @@ template <class T> void payloadRender(const std::shared_ptr<T>& payloadData, Ren
|
||||||
template <class T> class Payload : public Item::PayloadInterface {
|
template <class T> class Payload : public Item::PayloadInterface {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<T> DataPointer;
|
typedef std::shared_ptr<T> DataPointer;
|
||||||
|
typedef UpdateFunctor<T> Updater;
|
||||||
|
|
||||||
virtual const ItemKey getKey() const { return payloadGetKey<T>(_data); }
|
virtual const ItemKey getKey() const { return payloadGetKey<T>(_data); }
|
||||||
virtual const Item::Bound getBound() const { return payloadGetBound<T>(_data); }
|
virtual const Item::Bound getBound() const { return payloadGetBound<T>(_data); }
|
||||||
virtual void render(RenderArgs* args) { payloadRender<T>(_data, args); }
|
virtual void render(RenderArgs* args) { payloadRender<T>(_data, args); }
|
||||||
|
|
||||||
|
virtual void update(const UpdateFunctorPointer& functor) { static_cast<Updater*>(functor.get())->_func((*_data)); }
|
||||||
|
|
||||||
Payload(const DataPointer& data) : _data(data) {}
|
Payload(const DataPointer& data) : _data(data) {}
|
||||||
protected:
|
protected:
|
||||||
DataPointer _data;
|
DataPointer _data;
|
||||||
|
@ -315,6 +346,7 @@ public:
|
||||||
class Engine;
|
class Engine;
|
||||||
class Observer;
|
class Observer;
|
||||||
|
|
||||||
|
|
||||||
class PendingChanges {
|
class PendingChanges {
|
||||||
public:
|
public:
|
||||||
PendingChanges() {}
|
PendingChanges() {}
|
||||||
|
@ -322,14 +354,20 @@ public:
|
||||||
|
|
||||||
void resetItem(ItemID id, const PayloadPointer& payload);
|
void resetItem(ItemID id, const PayloadPointer& payload);
|
||||||
void removeItem(ItemID id);
|
void removeItem(ItemID id);
|
||||||
void moveItem(ItemID id);
|
|
||||||
|
template <class T> void updateItem(ItemID id, std::function<void(T&)> func) {
|
||||||
|
updateItem(id, UpdateFunctorPointer(new UpdateFunctor<T>(func)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateItem(ItemID id, const UpdateFunctorPointer& functor);
|
||||||
|
|
||||||
void merge(PendingChanges& changes);
|
void merge(PendingChanges& changes);
|
||||||
|
|
||||||
Payloads _resetPayloads;
|
Payloads _resetPayloads;
|
||||||
ItemIDs _resetItems;
|
ItemIDs _resetItems;
|
||||||
ItemIDs _removedItems;
|
ItemIDs _removedItems;
|
||||||
ItemIDs _movedItems;
|
ItemIDs _updatedItems;
|
||||||
|
UpdateFunctors _updateFunctors;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
@ -413,7 +451,7 @@ protected:
|
||||||
|
|
||||||
void resetItems(const ItemIDs& ids, Payloads& payloads);
|
void resetItems(const ItemIDs& ids, Payloads& payloads);
|
||||||
void removeItems(const ItemIDs& ids);
|
void removeItems(const ItemIDs& ids);
|
||||||
void moveItems(const ItemIDs& ids);
|
void updateItems(const ItemIDs& ids, UpdateFunctors& functors);
|
||||||
|
|
||||||
|
|
||||||
// The scene context listening for any change to the database
|
// The scene context listening for any change to the database
|
||||||
|
|
Loading…
Reference in a new issue