mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:56:43 +00:00 
			
		
		
		
	add settings for viewing distance and fog
This commit is contained in:
		
							parent
							
								
									e5cc9adbb0
								
							
						
					
					
						commit
						fd662f937a
					
				
					 3 changed files with 19 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -94,7 +94,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
 | 
			
		|||
    extents *= insert->getScale();
 | 
			
		||||
    float size = std::max(std::max(extents.x, extents.y), extents.z);
 | 
			
		||||
 | 
			
		||||
    bool small = (size < Settings::Manager::getInt("small object size", "Objects")) && Settings::Manager::getBool("limit small object distance", "Objects");
 | 
			
		||||
    bool small = (size < Settings::Manager::getInt("small object size", "View distance")) && Settings::Manager::getBool("limit small object distance", "Objects");
 | 
			
		||||
 | 
			
		||||
    // do not fade out doors. that will cause holes and look stupid
 | 
			
		||||
    if (ptr.getTypeName().find("Door") != std::string::npos)
 | 
			
		||||
| 
						 | 
				
			
			@ -116,7 +116,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
 | 
			
		|||
    {
 | 
			
		||||
        insert->attachObject(ent);
 | 
			
		||||
 | 
			
		||||
        ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Objects") : 0); /// \todo config value
 | 
			
		||||
        ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "View distance") : 0); /// \todo config value
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -130,7 +130,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
 | 
			
		|||
                sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
 | 
			
		||||
                mStaticGeometrySmall[ptr.getCell()] = sg;
 | 
			
		||||
 | 
			
		||||
                sg->setRenderingDistance(Settings::Manager::getInt("small object distance", "Objects")); /// \todo config value
 | 
			
		||||
                sg->setRenderingDistance(Settings::Manager::getInt("small object distance", "View distance")); /// \todo config value
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                sg = mStaticGeometrySmall[ptr.getCell()];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@
 | 
			
		|||
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
 | 
			
		||||
#include "../mwworld/ptr.hpp"
 | 
			
		||||
#include <components/esm/loadstat.hpp>
 | 
			
		||||
#include <components/settings/settings.hpp>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
using namespace MWRender;
 | 
			
		||||
| 
						 | 
				
			
			@ -273,18 +274,14 @@ void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell)
 | 
			
		|||
 | 
			
		||||
void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour)
 | 
			
		||||
{
 | 
			
		||||
  /// \todo make the viewing distance and fog start/end configurable
 | 
			
		||||
  float max = Settings::Manager::getFloat("max viewing distance", "Viewing distance");
 | 
			
		||||
 | 
			
		||||
  // right now we load 3x3 cells, so the maximum viewing distance we
 | 
			
		||||
  // can allow (to prevent objects suddenly popping up) equals:
 | 
			
		||||
  // 8192            * 0.69
 | 
			
		||||
  //   ^ cell size    ^ minimum density value used (clear weather)
 | 
			
		||||
  float low = 5652.48 / density / 2.f;
 | 
			
		||||
  float high = 5652.48 / density;
 | 
			
		||||
  float low = max / (density) * Settings::Manager::getFloat("fog start factor", "Viewing distance");
 | 
			
		||||
  float high = max / (density) * Settings::Manager::getFloat("fog end factor", "Viewing distance");
 | 
			
		||||
 | 
			
		||||
  mRendering.getScene()->setFog (FOG_LINEAR, colour, 0, low, high);
 | 
			
		||||
 | 
			
		||||
  mRendering.getCamera()->setFarClipDistance ( high );
 | 
			
		||||
  mRendering.getCamera()->setFarClipDistance ( max / density );
 | 
			
		||||
  mRendering.getViewport()->setBackgroundColour (colour);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,8 @@ num lights = 8
 | 
			
		|||
# Use static geometry for static objects. Improves rendering speed.
 | 
			
		||||
use static geometry = true
 | 
			
		||||
 | 
			
		||||
[Viewing distance]
 | 
			
		||||
 | 
			
		||||
# Limit the rendering distance of small objects
 | 
			
		||||
limit small object distance = false
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +20,15 @@ small object size = 250
 | 
			
		|||
# Rendering distance for small objects
 | 
			
		||||
small object distance = 3500
 | 
			
		||||
 | 
			
		||||
# Max viewing distance at clear weather conditions
 | 
			
		||||
max viewing distance = 5600
 | 
			
		||||
 | 
			
		||||
# Distance at which fog starts (proportional to viewing distance)
 | 
			
		||||
fog start factor = 0.5
 | 
			
		||||
 | 
			
		||||
# Distance at which fog ends (proportional to viewing distance)
 | 
			
		||||
fog end factor = 1.0
 | 
			
		||||
 | 
			
		||||
[Terrain]
 | 
			
		||||
 | 
			
		||||
# Max. number of lights that affect the terrain. Setting to 1 will only reflect sunlight
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue