@ -40,7 +40,6 @@
# include <components/sceneutil/unrefqueue.hpp>
# include <components/sceneutil/writescene.hpp>
# include <components/sceneutil/shadow.hpp>
# include <components/sceneutil/vismask.hpp>
# include <components/terrain/terraingrid.hpp>
# include <components/terrain/quadtreeworld.hpp>
@ -59,6 +58,7 @@
# include "sky.hpp"
# include "effectmanager.hpp"
# include "npcanimation.hpp"
# include "vismask.hpp"
# include "pathgrid.hpp"
# include "camera.hpp"
# include "water.hpp"
@ -216,7 +216,7 @@ namespace MWRender
, mFieldOfViewOverride ( 0.f )
, mBorders ( false )
{
resourceSystem - > getSceneManager ( ) - > setParticleSystemMask ( SceneUtil : : Mask_ParticleSystem ) ;
resourceSystem - > getSceneManager ( ) - > setParticleSystemMask ( MWRender : : Mask_ParticleSystem ) ;
resourceSystem - > getSceneManager ( ) - > setShaderPath ( resourcePath + " /shaders " ) ;
// Shadows and radial fog have problems with fixed-function mode
bool forceShaders = Settings : : Manager : : getBool ( " radial fog " , " Shaders " ) | | Settings : : Manager : : getBool ( " force shaders " , " Shaders " ) | | Settings : : Manager : : getBool ( " enable shadows " , " Shadows " ) ;
@ -230,21 +230,21 @@ namespace MWRender
resourceSystem - > getSceneManager ( ) - > setSpecularMapPattern ( Settings : : Manager : : getString ( " specular map pattern " , " Shaders " ) ) ;
osg : : ref_ptr < SceneUtil : : LightManager > sceneRoot = new SceneUtil : : LightManager ;
sceneRoot - > setLightingMask ( SceneUtil: : Mask_Lighting) ;
sceneRoot - > setLightingMask ( Mask_Lighting) ;
mSceneRoot = sceneRoot ;
sceneRoot - > setStartLight ( 1 ) ;
int shadowCastingTraversalMask = SceneUtil: : Mask_Scene;
int shadowCastingTraversalMask = Mask_Scene;
if ( Settings : : Manager : : getBool ( " actor shadows " , " Shadows " ) )
shadowCastingTraversalMask | = SceneUtil: : Mask_Actor;
shadowCastingTraversalMask | = Mask_Actor;
if ( Settings : : Manager : : getBool ( " player shadows " , " Shadows " ) )
shadowCastingTraversalMask | = SceneUtil: : Mask_Player;
shadowCastingTraversalMask | = Mask_Player;
if ( Settings : : Manager : : getBool ( " terrain shadows " , " Shadows " ) )
shadowCastingTraversalMask | = SceneUtil: : Mask_Terrain;
shadowCastingTraversalMask | = Mask_Terrain;
int indoorShadowCastingTraversalMask = shadowCastingTraversalMask ;
if ( Settings : : Manager : : getBool ( " object shadows " , " Shadows " ) )
shadowCastingTraversalMask | = ( SceneUtil: : Mask_Object| SceneUtil : : Mask_Static ) ;
shadowCastingTraversalMask | = ( Mask_Object| Mask_Static ) ;
mShadowManager . reset ( new SceneUtil : : ShadowManager ( sceneRoot , mRootNode , shadowCastingTraversalMask , indoorShadowCastingTraversalMask , mResourceSystem - > getSceneManager ( ) - > getShaderManager ( ) ) ) ;
@ -311,10 +311,11 @@ namespace MWRender
float maxCompGeometrySize = Settings : : Manager : : getFloat ( " max composite geometry size " , " Terrain " ) ;
maxCompGeometrySize = std : : max ( maxCompGeometrySize , 1.f ) ;
mTerrain . reset ( new Terrain : : QuadTreeWorld (
sceneRoot , mRootNode , mResourceSystem , mTerrainStorage , compMapResolution , compMapLevel , lodFactor , vertexLodMod , maxCompGeometrySize ) ) ;
sceneRoot , mRootNode , mResourceSystem , mTerrainStorage , Mask_Terrain , Mask_PreCompile , Mask_Debug ,
compMapResolution , compMapLevel , lodFactor , vertexLodMod , maxCompGeometrySize ) ) ;
}
else
mTerrain . reset ( new Terrain : : TerrainGrid ( sceneRoot , mRootNode , mResourceSystem , mTerrainStorage )) ;
mTerrain . reset ( new Terrain : : TerrainGrid ( sceneRoot , mRootNode , mResourceSystem , mTerrainStorage , Mask_Terrain , Mask_PreCompile , Mask_Debug )) ;
mTerrain - > setTargetFrameRate ( Settings : : Manager : : getFloat ( " target framerate " , " Cells " ) ) ;
mTerrain - > setWorkQueue ( mWorkQueue . get ( ) ) ;
@ -324,7 +325,7 @@ namespace MWRender
mViewer - > setLightingMode ( osgViewer : : View : : NO_LIGHT ) ;
osg : : ref_ptr < osg : : LightSource > source = new osg : : LightSource ;
source - > setNodeMask ( SceneUtil: : Mask_Lighting) ;
source - > setNodeMask ( Mask_Lighting) ;
mSunLight = new osg : : Light ;
source - > setLight ( mSunLight ) ;
mSunLight - > setDiffuse ( osg : : Vec4f ( 0 , 0 , 0 , 1 ) ) ;
@ -343,7 +344,7 @@ namespace MWRender
defaultMat - > setSpecular ( osg : : Material : : FRONT_AND_BACK , osg : : Vec4f ( 0.f , 0.f , 0.f , 0.f ) ) ;
sceneRoot - > getOrCreateStateSet ( ) - > setAttribute ( defaultMat ) ;
sceneRoot - > setNodeMask ( SceneUtil: : Mask_Scene) ;
sceneRoot - > setNodeMask ( Mask_Scene) ;
sceneRoot - > setName ( " Scene Root " ) ;
mSky . reset ( new SkyManager ( sceneRoot , resourceSystem - > getSceneManager ( ) ) ) ;
@ -371,7 +372,7 @@ namespace MWRender
mViewer - > getCamera ( ) - > setComputeNearFarMode ( osg : : Camera : : DO_NOT_COMPUTE_NEAR_FAR ) ;
mViewer - > getCamera ( ) - > setCullingMode ( cullingMode ) ;
mViewer - > getCamera ( ) - > setCullMask ( ~ ( SceneUtil: : Mask_UpdateVisitor| SceneUtil : : Mask_SimpleWater ) ) ;
mViewer - > getCamera ( ) - > setCullMask ( ~ ( Mask_UpdateVisitor| Mask_SimpleWater ) ) ;
mNearClip = Settings : : Manager : : getFloat ( " near clip " , " Camera " ) ;
mViewDistance = Settings : : Manager : : getFloat ( " viewing distance " , " Camera " ) ;
@ -573,12 +574,12 @@ namespace MWRender
else if ( mode = = Render_Scene )
{
int mask = mViewer - > getCamera ( ) - > getCullMask ( ) ;
bool enabled = mask & SceneUtil : : Mask_Scene ;
bool enabled = mask & Mask_Scene ;
enabled = ! enabled ;
if ( enabled )
mask | = SceneUtil: : Mask_Scene;
mask | = Mask_Scene;
else
mask & = ~ SceneUtil: : Mask_Scene;
mask & = ~ Mask_Scene;
mViewer - > getCamera ( ) - > setCullMask ( mask ) ;
return enabled ;
}
@ -851,7 +852,7 @@ namespace MWRender
int maskBackup = mPlayerAnimation - > getObjectRoot ( ) - > getNodeMask ( ) ;
if ( mCamera - > isFirstPerson ( ) )
mPlayerAnimation - > getObjectRoot ( ) - > setNodeMask ( SceneUtil : : Mask_Disabled ) ;
mPlayerAnimation - > getObjectRoot ( ) - > setNodeMask ( 0 ) ;
for ( int i = 0 ; i < 6 ; + + i ) // for each cubemap side
{
@ -925,7 +926,7 @@ namespace MWRender
void RenderingManager : : renderCameraToImage ( osg : : Camera * camera , osg : : Image * image , int w , int h )
{
camera - > setNodeMask ( SceneUtil: : Mask_RenderToTexture) ;
camera - > setNodeMask ( Mask_RenderToTexture) ;
camera - > attach ( osg : : Camera : : COLOR_BUFFER , image ) ;
camera - > setRenderOrder ( osg : : Camera : : PRE_RENDER ) ;
camera - > setReferenceFrame ( osg : : Camera : : ABSOLUTE_RF ) ;
@ -978,7 +979,7 @@ namespace MWRender
rttCamera - > addChild ( mWater - > getReflectionCamera ( ) ) ;
rttCamera - > addChild ( mWater - > getRefractionCamera ( ) ) ;
rttCamera - > setCullMask ( mViewer - > getCamera ( ) - > getCullMask ( ) & ( ~ SceneUtil: : Mask_GUI) ) ;
rttCamera - > setCullMask ( mViewer - > getCamera ( ) - > getCullMask ( ) & ( ~ Mask_GUI) ) ;
rttCamera - > setClearMask ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
@ -991,7 +992,7 @@ namespace MWRender
return osg : : Vec4f ( ) ;
osg : : ComputeBoundsVisitor computeBoundsVisitor ;
computeBoundsVisitor . setTraversalMask ( ~ ( SceneUtil: : Mask_ParticleSystem| SceneUtil : : Mask_Effect ) ) ;
computeBoundsVisitor . setTraversalMask ( ~ ( Mask_ParticleSystem| Mask_Effect ) ) ;
ptr . getRefData ( ) . getBaseNode ( ) - > accept ( computeBoundsVisitor ) ;
osg : : Matrix viewProj = mViewer - > getCamera ( ) - > getViewMatrix ( ) * mViewer - > getCamera ( ) - > getProjectionMatrix ( ) ;
@ -1063,11 +1064,12 @@ namespace MWRender
mIntersectionVisitor - > setTraversalNumber ( mViewer - > getFrameStamp ( ) - > getFrameNumber ( ) ) ;
mIntersectionVisitor - > setIntersector ( intersector ) ;
int mask = ~ ( SceneUtil : : Mask_RenderToTexture | SceneUtil : : Mask_Sky | SceneUtil : : Mask_Pathgrid | SceneUtil : : Mask_Debug | SceneUtil : : Mask_Effect | SceneUtil : : Mask_Water | SceneUtil : : Mask_SimpleWater ) ;
int mask = ~ 0 ;
mask & = ~ ( Mask_RenderToTexture | Mask_Sky | Mask_Debug | Mask_Effect | Mask_Water | Mask_SimpleWater ) ;
if ( ignorePlayer )
mask & = ~ ( SceneUtil: : Mask_Player) ;
mask & = ~ ( Mask_Player) ;
if ( ignoreActors )
mask & = ~ ( SceneUtil: : Mask_Actor| SceneUtil : : Mask_Player ) ;
mask & = ~ ( Mask_Actor| Mask_Player ) ;
mIntersectionVisitor - > setTraversalMask ( mask ) ;
return mIntersectionVisitor ;
@ -1148,7 +1150,7 @@ namespace MWRender
if ( ! mPlayerNode )
{
mPlayerNode = new SceneUtil : : PositionAttitudeTransform ;
mPlayerNode - > setNodeMask ( SceneUtil: : Mask_Player) ;
mPlayerNode - > setNodeMask ( Mask_Player) ;
mPlayerNode - > setName ( " Player Root " ) ;
mSceneRoot - > addChild ( mPlayerNode ) ;
}
@ -1392,7 +1394,7 @@ namespace MWRender
osg : : ref_ptr < const osg : : Node > node = mResourceSystem - > getSceneManager ( ) - > getTemplate ( modelName ) ;
osg : : ComputeBoundsVisitor computeBoundsVisitor ;
computeBoundsVisitor . setTraversalMask ( ~ ( SceneUtil: : Mask_ParticleSystem | SceneUtil : : Mask_Effect ) ) ;
computeBoundsVisitor . setTraversalMask ( ~ ( MWRender: : Mask_ParticleSystem | MWRender : : Mask_Effect ) ) ;
const_cast < osg : : Node * > ( node . get ( ) ) - > accept ( computeBoundsVisitor ) ;
osg : : BoundingBox bounds = computeBoundsVisitor . getBoundingBox ( ) ;