mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
Simplified pick item jobs by using inherited enabled flag in render::Job::Config
This commit is contained in:
parent
7de6079df8
commit
27227d6bd2
2 changed files with 11 additions and 17 deletions
|
@ -10,14 +10,15 @@
|
||||||
//
|
//
|
||||||
#include "PickItemsJob.h"
|
#include "PickItemsJob.h"
|
||||||
|
|
||||||
|
PickItemsJob::PickItemsJob() {
|
||||||
|
}
|
||||||
|
|
||||||
void PickItemsJob::configure(const Config& config) {
|
void PickItemsJob::configure(const Config& config) {
|
||||||
_isEnabled = config.isEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PickItemsJob::run(const render::RenderContextPointer& renderContext, const PickItemsJob::Input& input, PickItemsJob::Output& output) {
|
void PickItemsJob::run(const render::RenderContextPointer& renderContext, const PickItemsJob::Input& input, PickItemsJob::Output& output) {
|
||||||
output.clear();
|
output.clear();
|
||||||
|
|
||||||
if (_isEnabled) {
|
|
||||||
float minIsectDistance = std::numeric_limits<float>::max();
|
float minIsectDistance = std::numeric_limits<float>::max();
|
||||||
auto& itemBounds = input;
|
auto& itemBounds = input;
|
||||||
auto itemID = findNearestItem(renderContext, itemBounds, minIsectDistance);
|
auto itemID = findNearestItem(renderContext, itemBounds, minIsectDistance);
|
||||||
|
@ -25,7 +26,6 @@ void PickItemsJob::run(const render::RenderContextPointer& renderContext, const
|
||||||
if (render::Item::isValidID(itemID)) {
|
if (render::Item::isValidID(itemID)) {
|
||||||
output.emplace_back(itemID);
|
output.emplace_back(itemID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render::ItemID PickItemsJob::findNearestItem(const render::RenderContextPointer& renderContext, const render::ItemBounds& inputs, float& minIsectDistance) const {
|
render::ItemID PickItemsJob::findNearestItem(const render::RenderContextPointer& renderContext, const render::ItemBounds& inputs, float& minIsectDistance) const {
|
||||||
|
|
|
@ -15,16 +15,10 @@
|
||||||
#include <render/Engine.h>
|
#include <render/Engine.h>
|
||||||
|
|
||||||
class PickItemsConfig : public render::Job::Config {
|
class PickItemsConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(bool isEnabled MEMBER isEnabled NOTIFY dirty)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool isEnabled{ false };
|
PickItemsConfig() : render::Job::Config(false) {}
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
void dirty();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PickItemsJob {
|
class PickItemsJob {
|
||||||
|
@ -36,7 +30,7 @@ public:
|
||||||
using Output = render::ItemBounds;
|
using Output = render::ItemBounds;
|
||||||
using JobModel = render::Job::ModelIO<PickItemsJob, Input, Output, Config>;
|
using JobModel = render::Job::ModelIO<PickItemsJob, Input, Output, Config>;
|
||||||
|
|
||||||
PickItemsJob() {}
|
PickItemsJob();
|
||||||
|
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void run(const render::RenderContextPointer& renderContext, const PickItemsJob::Input& input, PickItemsJob::Output& output);
|
void run(const render::RenderContextPointer& renderContext, const PickItemsJob::Input& input, PickItemsJob::Output& output);
|
||||||
|
|
Loading…
Reference in a new issue