Added multiple selections but still only first linked to outline

This commit is contained in:
Olivier Prat 2017-10-16 10:57:06 +02:00
parent 8d79313a9d
commit e42699c0ea
6 changed files with 55 additions and 20 deletions

View file

@ -34,7 +34,12 @@ ContextOverlayInterface::ContextOverlayInterface() {
_tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
_selectionScriptingInterface = DependencyManager::get<SelectionScriptingInterface>();
_selectionToSceneHandler.initialize("contextOverlayHighlightList");
_selectionToSceneHandlers[0].initialize("contextOverlayHighlightList");
connect(_selectionScriptingInterface.data(), &SelectionScriptingInterface::selectedItemsListChanged, &_selectionToSceneHandlers[0], &SelectionToSceneHandler::selectedItemsListChanged);
for (auto i = 1; i < MAX_HIGHLIGHT_COUNT; i++) {
_selectionToSceneHandlers[i].initialize(QString("contextOverlayHighlightList")+QString::number(i));
connect(_selectionScriptingInterface.data(), &SelectionScriptingInterface::selectedItemsListChanged, &_selectionToSceneHandlers[i], &SelectionToSceneHandler::selectedItemsListChanged);
}
_entityPropertyFlags += PROP_POSITION;
_entityPropertyFlags += PROP_ROTATION;
@ -61,8 +66,6 @@ ContextOverlayInterface::ContextOverlayInterface() {
});
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>().data();
connect(entityScriptingInterface, &EntityScriptingInterface::deletingEntity, this, &ContextOverlayInterface::deletingEntity);
connect(_selectionScriptingInterface.data(), &SelectionScriptingInterface::selectedItemsListChanged, &_selectionToSceneHandler, &SelectionToSceneHandler::selectedItemsListChanged);
}
static const uint32_t MOUSE_HW_ID = 0;

View file

@ -47,6 +47,11 @@ class ContextOverlayInterface : public QObject, public Dependency {
OverlayID _contextOverlayID { UNKNOWN_OVERLAY_ID };
std::shared_ptr<Image3DOverlay> _contextOverlay { nullptr };
public:
enum {
MAX_HIGHLIGHT_COUNT = 4
};
ContextOverlayInterface();
Q_INVOKABLE QUuid getCurrentEntityWithContextOverlay() { return _currentEntityWithContextOverlay; }
@ -86,7 +91,7 @@ private:
void deletingEntity(const EntityItemID& entityItemID);
SelectionToSceneHandler _selectionToSceneHandler;
SelectionToSceneHandler _selectionToSceneHandlers[MAX_HIGHLIGHT_COUNT];
};
#endif // hifi_ContextOverlayInterface_h

View file

@ -399,8 +399,8 @@ void DrawOutlineTask::configure(const Config& config) {
}
void DrawOutlineTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs) {
const auto input = inputs.get<Inputs>();
const auto selectedMetas = inputs.getN<Inputs>(0);
const auto groups = inputs.getN<Inputs>(0).get<Groups>();
const auto selectedMetas = groups[0];
const auto sceneFrameBuffer = inputs.getN<Inputs>(1);
const auto primaryFramebuffer = inputs.getN<Inputs>(2);
const auto deferredFrameTransform = inputs.getN<Inputs>(3);

View file

@ -173,7 +173,13 @@ private:
class DrawOutlineTask {
public:
using Inputs = render::VaryingSet4<render::ItemBounds, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer>;
enum {
MAX_GROUP_COUNT = 7
};
using Groups = render::VaryingArray<render::ItemBounds, MAX_GROUP_COUNT>;
using Inputs = render::VaryingSet4<Groups, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer>;
using Config = render::Task::Config;
using JobModel = render::Task::ModelI<DrawOutlineTask, Inputs, Config>;

View file

@ -44,6 +44,7 @@
#include <gpu/StandardShaderLib.h>
#include <sstream>
using namespace render;
extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false);
@ -57,6 +58,18 @@ void RenderDeferredTask::configure(const Config& config)
{
}
const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, const char* selectionName,
const render::Varying& metas,
const render::Varying& opaques,
const render::Varying& transparents) {
const auto selectMetaInput = SelectItems::Inputs(metas, Varying()).asVarying();
const auto selectedMetas = task.addJob<SelectItems>("MetaSelection", selectMetaInput, selectionName);
const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas).asVarying();
const auto selectedMetasAndOpaques = task.addJob<SelectItems>("OpaqueSelection", selectMetaAndOpaqueInput, selectionName);
const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques).asVarying();
return task.addJob<SelectItems>("TransparentSelection", selectItemInput, selectionName);
}
void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
const auto& items = input.get<Input>();
auto fadeEffect = DependencyManager::get<FadeEffect>();
@ -94,15 +107,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
// draw a stencil mask in hidden regions of the framebuffer.
task.addJob<PrepareStencil>("PrepareStencil", primaryFramebuffer);
// Select items that need to be outlined
const auto selectionName = "contextOverlayHighlightList";
const auto selectMetaInput = SelectItems::Inputs(metas, Varying()).asVarying();
const auto selectedMetas = task.addJob<SelectItems>("PassTestMetaSelection", selectMetaInput, selectionName);
const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas).asVarying();
const auto selectedMetasAndOpaques = task.addJob<SelectItems>("PassTestOpaqueSelection", selectMetaAndOpaqueInput, selectionName);
const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques).asVarying();
const auto selectedItems = task.addJob<SelectItems>("PassTestTransparentSelection", selectItemInput, selectionName);
// Render opaque objects in DeferredBuffer
const auto opaqueInputs = DrawStateSortDeferred::Inputs(opaques, lightingModel).asVarying();
task.addJob<DrawStateSortDeferred>("DrawOpaqueDeferred", opaqueInputs, shapePlumber);
@ -172,9 +176,22 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying();
task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);
// Select items that need to be outlined
const auto selectionBaseName = "contextOverlayHighlightList";
const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents);
DrawOutlineTask::Groups outlineGroups;
outlineGroups[0] = selectedItems;
for (auto i = 1; i < DrawOutlineTask::MAX_GROUP_COUNT; i++) {
std::ostringstream selectionName;
selectionName << selectionBaseName;
selectionName << i;
outlineGroups[i] = addSelectItemJobs(task, selectionName.str().c_str(), metas, opaques, transparents);
}
const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginOutlineRangeTimer", "Outline");
const auto outlineInputs = DrawOutlineTask::Inputs(selectedItems, deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying();
const auto outlineInputs = DrawOutlineTask::Inputs(outlineGroups, deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying();
task.addJob<DrawOutlineTask>("DrawOutline", outlineInputs);
task.addJob<EndGPURangeTimer>("EndOutlineRangeTimer", outlineRangeTimer);
{ // DEbug the bounds of the rendered items, still look at the zbuffer
@ -184,6 +201,9 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<DrawBounds>("DrawLightBounds", lights);
task.addJob<DrawBounds>("DrawZones", zones);
// Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true
task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems);
}
// Layered Overlays
@ -230,9 +250,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
}
task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform);
// Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true
task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems);
}
// AA job to be revisited

View file

@ -198,6 +198,10 @@ public:
void configure(const Config& config);
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
private:
static const render::Varying addSelectItemJobs(JobModel& task, const char* selectionName,
const render::Varying& metas, const render::Varying& opaques, const render::Varying& transparents);
};
#endif // hifi_RenderDeferredTask_h