Forráskód Böngészése

Undid some assumptions on how visible works as they were not entirely right
Effect's visible behaves a little weirdly :/ need to properly understand it

Signed-off-by: Alexis Maiquez <almamu@almamu.com>

Alexis Maiquez 3 éve
szülő
commit
e1fe215398

+ 2 - 8
src/WallpaperEngine/Core/CObject.cpp

@@ -125,14 +125,8 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer* containe
 
         for (; cur != end; cur ++)
         {
-            auto effectVisible_it = data.find ("visible");
-            CUserSettingBoolean* effectVisible;
-
-            if (effectVisible_it == data.end ())
-                effectVisible = CUserSettingBoolean::fromScalar (true);
-            else
-                effectVisible = CUserSettingBoolean::fromJSON (*effectVisible_it);
-
+            auto effectVisible = jsonFindUserConfig <CUserSettingBoolean, bool> (data, "visible", true);
+            
             object->insertEffect (
                 Objects::CEffect::fromJSON (*cur, effectVisible, object, container)
             );

+ 5 - 46
src/WallpaperEngine/Render/Objects/CImage.cpp

@@ -335,11 +335,6 @@ void CImage::setupPasses ()
     for (; cur != end; cur ++)
     {
         Effects::CPass* pass = *cur;
-
-        // do not do anything if the passes' effect is not visible
-        if (pass->getMaterial ()->getEffect ()->isVisible () == false)
-            continue;
-
         const CFBO* prevDrawTo = drawTo;
         GLuint spacePosition = (first) ? this->getCopySpacePosition () : this->getPassSpacePosition ();
         glm::mat4* projection = (first) ? &this->m_modelViewProjectionCopy : &this->m_modelViewProjectionPass;
@@ -359,29 +354,11 @@ void CImage::setupPasses ()
                 drawTo = this->getScene ()->findFBO (target);
         }
         // determine if it's the last element in the list as this is a screen-copy-like process
-        else
+        else if (std::next (cur) == end && this->getImage ()->isVisible () == true)
         {
-            bool isLastPass = std::next (cur) == end && this->getImage ()->isVisible () == true;
-            auto lastIt = std::next (cur);
-
-            // determine if this is the real last pass
-            for (; lastIt != end && isLastPass == false; lastIt ++)
-            {
-                Effects::CPass* lastPass = *lastIt;
-
-                if (lastPass->getMaterial ()->getEffect ()->isVisible () == true)
-                {
-                    isLastPass = false;
-                    break;
-                }
-            }
-
-            if (isLastPass == true)
-            {
-                spacePosition = this->getSceneSpacePosition ();
-                drawTo = this->getScene ()->getFBO ();
-                projection = &this->m_modelViewProjectionScreen;
-            }
+            spacePosition = this->getSceneSpacePosition ();
+            drawTo = this->getScene ()->getFBO ();
+            projection = &this->m_modelViewProjectionScreen;
         }
 
         pass->setDestination (drawTo);
@@ -446,25 +423,7 @@ void CImage::render ()
 
     for (; cur != end; cur ++)
     {
-        if ((*cur)->getMaterial ()->getEffect ()->isVisible () == false)
-            continue;
-
-        bool isLastPass = std::next (cur) == end && this->getImage ()->isVisible () == true;
-        auto lastIt = std::next (cur);
-
-        // determine if this is the real last pass
-        for (; lastIt != end && isLastPass == false; lastIt ++)
-        {
-            Effects::CPass* lastPass = *lastIt;
-
-            if (lastPass->getMaterial ()->getEffect ()->isVisible () == true)
-            {
-                isLastPass = false;
-                break;
-            }
-        }
-
-        if (isLastPass == true)
+        if (std::next (cur) == end)
             glColorMask (true, true, true, false);
 
         (*cur)->render ();