mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 05:46:48 +08:00
Compare commits
2 Commits
9c62125a1f
...
fd0f142517
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fd0f142517 | ||
![]() |
d6bcd62d1a |
@ -10,10 +10,10 @@ void CVirtualContainer::add (const std::filesystem::path& filename, const std::s
|
||||
}
|
||||
|
||||
void CVirtualContainer::add (const std::filesystem::path& filename, const std::string& contents) {
|
||||
size_t length = contents.length () + 1;
|
||||
// do not copy the null terminator
|
||||
size_t length = contents.length ();
|
||||
std::shared_ptr<uint8_t[]> copy = std::shared_ptr<uint8_t[]> (new uint8_t [length]);
|
||||
|
||||
// copy the text AND the \0
|
||||
memcpy (copy.get(), contents.c_str (), length);
|
||||
|
||||
// finally add to the container
|
||||
|
@ -63,7 +63,12 @@ std::map <int, std::string> MaterialParser::parseTextures (const JSON& it) {
|
||||
|
||||
for (const auto& cur : it) {
|
||||
if (!cur.is_null ()) {
|
||||
result.emplace (index, cur);
|
||||
if (!cur.is_string ()) {
|
||||
sLog.error ("Detected a non-string texture, most likely a special value: ", cur.dump ());
|
||||
result.emplace (index, "");
|
||||
} else {
|
||||
result.emplace (index, cur);
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
|
@ -234,11 +234,7 @@ void CImage::setup () {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: SETUP RECALCULATION OF THINGS WHEN A VISIBILITY VALUE CHANGES!!
|
||||
if (!this->m_image.visible->value->getBool ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: CHECK ORDER OF THINGS, 2419444134'S ID 27 DEPENDS ON 104'S COMPOSITE_A WHEN OUR LAST RENDER IS ON COMPOSITE_B
|
||||
// TODO: SUPPORT PASSTHROUGH (IT'S A SHADER)
|
||||
// passthrough images without effects are bad, do not draw them
|
||||
if (this->m_image.model->passthrough && this->m_image.effects.empty ()) {
|
||||
@ -317,19 +313,18 @@ void CImage::setup () {
|
||||
new CPass (*this, fboProvider, config, std::nullopt, std::nullopt, (*curEffect)->target.value ())
|
||||
);
|
||||
} else {
|
||||
auto curPass = (*curEffect)->material.value ()->passes.begin ();
|
||||
auto endPass = (*curEffect)->material.value ()->passes.end ();
|
||||
for (auto& pass : (*curEffect)->material.value ()->passes) {
|
||||
const auto override =
|
||||
curOverride != endOverride
|
||||
? **curOverride
|
||||
: std::optional<std::reference_wrapper<const ImageEffectPassOverride>> (std::nullopt);
|
||||
const auto target = (*curEffect)->target.has_value ()
|
||||
? *(*curEffect)->target
|
||||
: std::optional<std::reference_wrapper<std::string>> (std::nullopt);
|
||||
|
||||
const auto override =
|
||||
curOverride != endOverride
|
||||
? **curOverride
|
||||
: std::optional<std::reference_wrapper<const ImageEffectPassOverride>> (std::nullopt);
|
||||
const auto target = (*curEffect)->target.has_value ()
|
||||
? *(*curEffect)->target
|
||||
: std::optional<std::reference_wrapper<std::string>> (std::nullopt);
|
||||
|
||||
this->m_passes.push_back (
|
||||
new CPass (*this, fboProvider, **curPass, override, (*curEffect)->binds, target));
|
||||
this->m_passes.push_back (
|
||||
new CPass (*this, fboProvider, *pass, override, (*curEffect)->binds, target));
|
||||
}
|
||||
|
||||
if (curOverride != endOverride) {
|
||||
curOverride++;
|
||||
|
@ -64,14 +64,8 @@ CScene::CScene (
|
||||
this->createObject (*object);
|
||||
|
||||
// copy over objects by render order
|
||||
for (const auto& cur : scene->objects) {
|
||||
auto obj = this->m_objects.find (cur->id);
|
||||
|
||||
// ignores not created objects like particle systems
|
||||
if (obj == this->m_objects.end ())
|
||||
continue;
|
||||
|
||||
this->m_objectsByRenderOrder.emplace_back (obj->second);
|
||||
for (const auto& object : scene->objects) {
|
||||
this->addObjectToRenderOrder (*object);
|
||||
}
|
||||
|
||||
// create extra framebuffers for the bloom effect
|
||||
@ -203,6 +197,50 @@ Render::CObject* CScene::createObject (const Object& object) {
|
||||
return renderObject;
|
||||
}
|
||||
|
||||
void CScene::addObjectToRenderOrder (const Object& object) {
|
||||
auto obj = this->m_objects.find (object.id);
|
||||
|
||||
// ignores not created objects like particle systems
|
||||
if (obj == this->m_objects.end ())
|
||||
return;
|
||||
|
||||
// take into account any dependency first
|
||||
for (const auto& dep : object.dependencies) {
|
||||
// self-dependency is possible
|
||||
if (dep == object.id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// add the dependency to the list if it's created
|
||||
auto depIt = std::find_if (
|
||||
this->getScene ().objects.begin (),
|
||||
this->getScene ().objects.end (),
|
||||
[&dep] (const auto& o) {
|
||||
return o->id == dep;
|
||||
}
|
||||
);
|
||||
|
||||
if (depIt != this->getScene ().objects.end ()) {
|
||||
this->addObjectToRenderOrder (**depIt);
|
||||
} else {
|
||||
sLog.error ("Cannot find dependency ", dep, " for object ", object.id);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure we're added only once to the render list
|
||||
const auto renderIt = std::find_if (
|
||||
this->m_objectsByRenderOrder.begin (),
|
||||
this->m_objectsByRenderOrder.end (),
|
||||
[&object] (const auto& o) {
|
||||
return o->getId () == object.id;
|
||||
}
|
||||
);
|
||||
|
||||
if (renderIt == this->m_objectsByRenderOrder.end ()) {
|
||||
this->m_objectsByRenderOrder.emplace_back (obj->second);
|
||||
}
|
||||
}
|
||||
|
||||
CCamera& CScene::getCamera () const {
|
||||
return *this->m_camera;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class CScene final : public CWallpaper {
|
||||
|
||||
private:
|
||||
Render::CObject* createObject (const Object& object);
|
||||
void addObjectToRenderOrder (const Object& object);
|
||||
|
||||
std::unique_ptr<CCamera> m_camera;
|
||||
ObjectUniquePtr m_bloomObjectData;
|
||||
|
Loading…
Reference in New Issue
Block a user