mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 03:15:32 +00:00
Move configureLight to a separate file
This commit is contained in:
parent
fb849014bd
commit
438b30d6f0
6 changed files with 55 additions and 30 deletions
|
@ -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
|
||||
|
|
32
components/sceneutil/lightutil.cpp
Normal file
32
components/sceneutil/lightutil.cpp
Normal file
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
19
components/sceneutil/lightutil.hpp
Normal file
19
components/sceneutil/lightutil.hpp
Normal file
|
@ -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…
Reference in a new issue