mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Merge pull request #8249 from samcake/skin
Fix the web entity rendering
This commit is contained in:
commit
4b9011ff65
4 changed files with 36 additions and 23 deletions
|
@ -70,8 +70,8 @@ void packDeferredFragmentUnlit(vec3 normal, float alpha, vec3 color) {
|
|||
}
|
||||
_fragColor0 = vec4(color, packUnlit());
|
||||
_fragColor1 = vec4(packNormal(normal), 1.0);
|
||||
_fragColor2 = vec4(vec3(0.0), 1.0);
|
||||
_fragColor3 = vec4(color * isUnlitEnabled(), 1.0);
|
||||
// _fragColor2 = vec4(vec3(0.0), 1.0);
|
||||
_fragColor3 = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness) {
|
||||
|
|
|
@ -85,8 +85,7 @@ void RenderShadowMap::run(const render::SceneContextPointer& sceneContext, const
|
|||
});
|
||||
}
|
||||
|
||||
// The shadow task *must* use this base ctor to initialize with its own Config, see Task.h
|
||||
RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) : Task(std::make_shared<Config>()) {
|
||||
RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) {
|
||||
cullFunctor = cullFunctor ? cullFunctor : [](const RenderArgs*, const AABox&){ return true; };
|
||||
|
||||
// Prepare the ShapePipeline
|
||||
|
|
|
@ -40,5 +40,5 @@ void main(void) {
|
|||
packDeferredFragmentUnlit(
|
||||
normalize(_normal),
|
||||
opacity,
|
||||
albedo);
|
||||
albedo * isUnlitEnabled());
|
||||
}
|
||||
|
|
|
@ -368,8 +368,6 @@ public:
|
|||
TaskConfig() = default ;
|
||||
TaskConfig(bool enabled) : JobConfig(enabled) {}
|
||||
|
||||
void init(Task* task) { _task = task; }
|
||||
|
||||
// getter for qml integration, prefer the templated getter
|
||||
Q_INVOKABLE QObject* getConfig(const QString& name) { return QObject::findChild<JobConfig*>(name); }
|
||||
// getter for cpp (strictly typed), prefer this getter
|
||||
|
@ -382,6 +380,7 @@ public slots:
|
|||
void refresh();
|
||||
|
||||
private:
|
||||
friend class Task;
|
||||
Task* _task;
|
||||
};
|
||||
|
||||
|
@ -498,8 +497,6 @@ public:
|
|||
|
||||
// A task is a specialized job to run a collection of other jobs
|
||||
// It is defined with JobModel = Task::Model<T>
|
||||
//
|
||||
// A task with a custom config *must* use the templated constructor
|
||||
class Task {
|
||||
public:
|
||||
using Config = TaskConfig;
|
||||
|
@ -521,9 +518,10 @@ public:
|
|||
|
||||
template <class... A>
|
||||
Model(const Varying& input, A&&... args) :
|
||||
Concept(std::make_shared<Config>()), _data(Data(std::forward<A>(args)...)), _input(input), _output(Output()) {
|
||||
_config = _data._config;
|
||||
std::static_pointer_cast<Config>(_config)->init(&_data);
|
||||
Concept(nullptr), _data(Data(std::forward<A>(args)...)), _input(input), _output(Output()) {
|
||||
// Recreate the Config to use the templated type
|
||||
_data.createConfiguration<C>();
|
||||
_config = _data.getConfiguration();
|
||||
applyConfiguration();
|
||||
}
|
||||
|
||||
|
@ -545,23 +543,19 @@ public:
|
|||
|
||||
using Jobs = std::vector<Job>;
|
||||
|
||||
// A task must use its Config for construction
|
||||
Task() : _config{ std::make_shared<Config>() } {}
|
||||
template <class C> Task(std::shared_ptr<C> config) : _config{ config } {}
|
||||
|
||||
// Create a new job in the container's queue; returns the job's output
|
||||
template <class T, class... A> const Varying addJob(std::string name, const Varying& input, A&&... args) {
|
||||
_jobs.emplace_back(name, std::make_shared<typename T::JobModel>(input, std::forward<A>(args)...));
|
||||
QConfigPointer config = _jobs.back().getConfiguration();
|
||||
config->setParent(_config.get());
|
||||
config->setParent(getConfiguration().get());
|
||||
config->setObjectName(name.c_str());
|
||||
|
||||
// Connect loaded->refresh
|
||||
QObject::connect(config.get(), SIGNAL(loaded()), _config.get(), SLOT(refresh()));
|
||||
QObject::connect(config.get(), SIGNAL(loaded()), getConfiguration().get(), SLOT(refresh()));
|
||||
static const char* DIRTY_SIGNAL = "dirty()";
|
||||
if (config->metaObject()->indexOfSignal(DIRTY_SIGNAL) != -1) {
|
||||
// Connect dirty->refresh if defined
|
||||
QObject::connect(config.get(), SIGNAL(dirty()), _config.get(), SLOT(refresh()));
|
||||
QObject::connect(config.get(), SIGNAL(dirty()), getConfiguration().get(), SLOT(refresh()));
|
||||
}
|
||||
|
||||
return _jobs.back().getOutput();
|
||||
|
@ -571,16 +565,36 @@ public:
|
|||
return addJob<T>(name, input, std::forward<A>(args)...);
|
||||
}
|
||||
|
||||
template <class C> void createConfiguration() {
|
||||
auto config = std::make_shared<C>();
|
||||
if (_config) {
|
||||
// Transfer children to the new configuration
|
||||
auto children = _config->children();
|
||||
for (auto& child : children) {
|
||||
child->setParent(config.get());
|
||||
QObject::connect(child, SIGNAL(loaded()), config.get(), SLOT(refresh()));
|
||||
static const char* DIRTY_SIGNAL = "dirty()";
|
||||
if (child->metaObject()->indexOfSignal(DIRTY_SIGNAL) != -1) {
|
||||
// Connect dirty->refresh if defined
|
||||
QObject::connect(child, SIGNAL(dirty()), config.get(), SLOT(refresh()));
|
||||
}
|
||||
}
|
||||
}
|
||||
_config = config;
|
||||
std::static_pointer_cast<Config>(_config)->_task = this;
|
||||
}
|
||||
|
||||
std::shared_ptr<Config> getConfiguration() {
|
||||
auto config = std::static_pointer_cast<Config>(_config);
|
||||
// If we are here, we were not made by a Model, so we must initialize our own config
|
||||
config->init(this);
|
||||
return config;
|
||||
if (!_config) {
|
||||
createConfiguration<Config>();
|
||||
}
|
||||
return std::static_pointer_cast<Config>(_config);
|
||||
}
|
||||
|
||||
void configure(const QObject& configuration) {
|
||||
for (auto& job : _jobs) {
|
||||
job.applyConfiguration();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue