Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 26, 2011, 5:00:17 PM (13 years ago)
Author:
landauf
Message:

some changes related to camera switching:

  • added ViewportEventListener (currently only listens to camera changes in a viewport)
  • Shader now correctly updates its visibility if the camera changes the scene
  • (the same lines of code also fix the weird Ogre behavior which was originally fixed in CameraManager)
  • GraphicsManager also updates the GUIManager's camera
  • if all cameras are destroyed, CameraManager now officially switches to NULL camera
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/usability/src/libraries/tools/Shader.cc

    r6417 r7966  
    5656        this->bVisible_ = true;
    5757        this->bLoadCompositor_ = GameMode::showsGraphics();
    58         this->bViewportInitialized_ = false;
     58        this->bViewportInitialized_ = true;
    5959
    6060        if (this->bLoadCompositor_ && Ogre::Root::getSingletonPtr())
     
    8989    {
    9090        this->scenemanager_ = scenemanager;
    91         this->bViewportInitialized_ = false;
    92     }
    93 
     91//        this->bViewportInitialized_ = false;
     92    }
     93
     94    void Shader::cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera)
     95    {
     96        if (!this->scenemanager_ || (viewport != this->scenemanager_->getCurrentViewport() && this->scenemanager_->getCurrentViewport() != NULL))
     97            return;
     98
     99        // update compositor in viewport (shader should only be active if the current camera is in the same scene as the shader)
     100
     101        // Note:
     102        // The shader needs also to be switched off and on after changing the camera in the
     103        // same scene to avoid weird behaviour with active compositors while switching the
     104        // camera (like freezing the image)
     105        //
     106        // Last known Ogre version needing this workaround:
     107        // 1.4.8
     108        // 1.7.2
     109
     110
     111        if (oldCamera && this->scenemanager_ == oldCamera->getSceneManager())
     112            Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositor_, false);
     113
     114        if (viewport->getCamera() && this->scenemanager_ == viewport->getCamera()->getSceneManager())
     115            Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositor_, this->isVisible());
     116    }
     117/*
    94118    void Shader::tick(float dt)
    95119    {
     
    102126        }
    103127    }
    104 
     128*/
    105129    void Shader::changedCompositor()
    106130    {
     
    119143                if (!this->compositorInstance_)
    120144                    COUT(2) << "Warning: Couldn't load compositor with name \"" << this->compositor_ << "\"." << std::endl;
    121                 Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositor_, this->bViewportInitialized_ && this->isVisible());
     145                //Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositor_, this->bViewportInitialized_ && this->isVisible());
    122146            }
    123147            this->oldcompositor_ = this->compositor_;
Note: See TracChangeset for help on using the changeset viewer.