2014-01-05 17:22:29 +00:00
|
|
|
#ifndef GAME_OCCLUSION_QUERY_H
|
|
|
|
#define GAME_OCCLUSION_QUERY_H
|
2012-03-24 12:06:01 +00:00
|
|
|
|
2012-03-24 16:59:26 +00:00
|
|
|
#include <OgreRenderObjectListener.h>
|
2012-03-25 18:52:56 +00:00
|
|
|
#include <OgreRenderQueueListener.h>
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-03-24 19:41:23 +00:00
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
class HardwareOcclusionQuery;
|
|
|
|
class Entity;
|
|
|
|
class SceneNode;
|
|
|
|
}
|
|
|
|
|
2012-03-24 16:59:26 +00:00
|
|
|
#include <openengine/ogre/renderer.hpp>
|
2012-03-24 12:06:01 +00:00
|
|
|
|
|
|
|
namespace MWRender
|
|
|
|
{
|
|
|
|
///
|
|
|
|
/// \brief Implements hardware occlusion queries on the GPU
|
|
|
|
///
|
2012-03-25 18:52:56 +00:00
|
|
|
class OcclusionQuery : public Ogre::RenderObjectListener, public Ogre::RenderQueueListener
|
2012-03-24 12:06:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-03-24 16:59:26 +00:00
|
|
|
OcclusionQuery(OEngine::Render::OgreRenderer*, Ogre::SceneNode* sunNode);
|
|
|
|
~OcclusionQuery();
|
2012-03-24 12:06:01 +00:00
|
|
|
|
2012-03-24 17:38:58 +00:00
|
|
|
/**
|
|
|
|
* @return true if occlusion queries are supported on the user's hardware
|
|
|
|
*/
|
2012-03-24 12:06:01 +00:00
|
|
|
bool supported();
|
|
|
|
|
2013-02-03 14:46:23 +00:00
|
|
|
/**
|
|
|
|
* make sure to disable occlusion queries before updating unrelated render targets
|
|
|
|
* @param active
|
|
|
|
*/
|
|
|
|
void setActive (bool active) { mActive = active; }
|
|
|
|
|
2012-03-24 17:38:58 +00:00
|
|
|
/**
|
|
|
|
* per-frame update
|
|
|
|
*/
|
2012-03-25 22:31:03 +00:00
|
|
|
void update(float duration);
|
2012-03-24 17:38:58 +00:00
|
|
|
|
2012-03-24 16:59:26 +00:00
|
|
|
float getSunVisibility() const {return mSunVisibility;};
|
|
|
|
|
2012-04-01 13:07:41 +00:00
|
|
|
void setSunNode(Ogre::SceneNode* node);
|
|
|
|
|
2012-03-24 12:06:01 +00:00
|
|
|
private:
|
|
|
|
Ogre::HardwareOcclusionQuery* mSunTotalAreaQuery;
|
|
|
|
Ogre::HardwareOcclusionQuery* mSunVisibleAreaQuery;
|
2012-03-24 16:59:26 +00:00
|
|
|
Ogre::HardwareOcclusionQuery* mActiveQuery;
|
|
|
|
|
2013-05-07 15:38:24 +00:00
|
|
|
Ogre::Entity* mBBQueryVisible;
|
|
|
|
Ogre::Entity* mBBQueryTotal;
|
2012-03-24 16:59:26 +00:00
|
|
|
|
|
|
|
Ogre::SceneNode* mSunNode;
|
2012-03-31 17:08:05 +00:00
|
|
|
Ogre::SceneNode* mBBNodeReal;
|
2012-03-24 16:59:26 +00:00
|
|
|
float mSunVisibility;
|
2012-03-24 12:06:01 +00:00
|
|
|
|
2012-03-25 18:52:56 +00:00
|
|
|
bool mWasVisible;
|
2012-03-24 17:38:58 +00:00
|
|
|
|
2013-02-03 14:46:23 +00:00
|
|
|
bool mActive;
|
2013-05-13 18:08:12 +00:00
|
|
|
bool mFirstFrame;
|
2013-02-03 14:46:23 +00:00
|
|
|
|
2012-03-24 12:06:01 +00:00
|
|
|
bool mSupported;
|
2012-03-24 16:59:26 +00:00
|
|
|
bool mDoQuery;
|
|
|
|
|
|
|
|
OEngine::Render::OgreRenderer* mRendering;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void notifyRenderSingleObject(Ogre::Renderable* rend, const Ogre::Pass* pass, const Ogre::AutoParamDataSource* source,
|
|
|
|
const Ogre::LightList* pLightList, bool suppressRenderStateChanges);
|
2012-03-25 18:52:56 +00:00
|
|
|
|
|
|
|
virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation);
|
2012-03-24 12:06:01 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|