Move configureLight to a separate file

pull/872/head
scrawl 9 years ago
parent fb849014bd
commit 438b30d6f0

@ -30,8 +30,9 @@
#include <components/sceneutil/statesetupdater.hpp>
#include <components/sceneutil/visitor.hpp>
#include <components/sceneutil/lightmanager.hpp>
#include <components/sceneutil/util.hpp>
#include <components/sceneutil/lightutil.hpp>
#include <components/sceneutil/lightcontroller.hpp>
#include <components/sceneutil/util.hpp>
#include <components/sceneutil/skeleton.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>

@ -45,7 +45,8 @@ add_component_dir (resource
)
add_component_dir (sceneutil
clone attach lightmanager visitor util statesetupdater controller skeleton riggeometry lightcontroller positionattitudetransform
clone attach visitor util statesetupdater controller skeleton riggeometry lightcontroller
lightmanager lightutil positionattitudetransform
# not used yet
#workqueue
)

@ -371,28 +371,4 @@ namespace SceneUtil
traverse(node, nv);
}
void configureLight(osg::Light *light, float radius, bool isExterior, bool outQuadInLin, bool useQuadratic,
float quadraticValue, float quadraticRadiusMult, bool useLinear, float linearRadiusMult, float linearValue)
{
bool quadratic = useQuadratic && (!outQuadInLin || isExterior);
float quadraticAttenuation = 0;
float linearAttenuation = 0;
if (quadratic)
{
float r = radius * quadraticRadiusMult;
quadraticAttenuation = quadraticValue / std::pow(r, 2);
}
if (useLinear)
{
float r = radius * linearRadiusMult;
linearAttenuation = linearValue / r;
}
light->setLinearAttenuation(linearAttenuation);
light->setQuadraticAttenuation(quadraticAttenuation);
light->setConstantAttenuation(0.f);
}
}

@ -168,10 +168,6 @@ namespace SceneUtil
LightManager::LightList mLightList;
};
/// @brief Configures a light's attenuation according to vanilla Morrowind attenuation settings.
void configureLight(osg::Light* light, float radius, bool isExterior, bool outQuadInLin, bool useQuadratic, float quadraticValue,
float quadraticRadiusMult, bool useLinear, float linearRadiusMult, float linearValue);
}
#endif

@ -0,0 +1,32 @@
#include "lightutil.hpp"
#include <osg/Light>
namespace SceneUtil
{
void configureLight(osg::Light *light, float radius, bool isExterior, bool outQuadInLin, bool useQuadratic,
float quadraticValue, float quadraticRadiusMult, bool useLinear, float linearRadiusMult, float linearValue)
{
bool quadratic = useQuadratic && (!outQuadInLin || isExterior);
float quadraticAttenuation = 0;
float linearAttenuation = 0;
if (quadratic)
{
float r = radius * quadraticRadiusMult;
quadraticAttenuation = quadraticValue / std::pow(r, 2);
}
if (useLinear)
{
float r = radius * linearRadiusMult;
linearAttenuation = linearValue / r;
}
light->setLinearAttenuation(linearAttenuation);
light->setQuadraticAttenuation(quadraticAttenuation);
light->setConstantAttenuation(0.f);
}
}

@ -0,0 +1,19 @@
#ifndef OPENMW_COMPONENTS_LIGHTUTIL_H
#define OPENMW_COMPONENTS_LIGHTUTIL_H
namespace osg
{
class Light;
}
namespace SceneUtil
{
/// @brief Configures a light's attenuation according to vanilla Morrowind attenuation settings.
void configureLight(osg::Light* light, float radius, bool isExterior, bool outQuadInLin, bool useQuadratic,
float quadraticValue, float quadraticRadiusMult, bool useLinear, float linearRadiusMult,
float linearValue);
}
#endif
Loading…
Cancel
Save