Fixed terrain light priorities (fix for #139)
* lights illuminating the terrain specified in scene file are now always moved to front of light orderingdev-ui
parent
4c33172e17
commit
28b4e9a634
|
@ -236,6 +236,15 @@ bool CLightManager::SetLightEnabled(int lightRank, bool enabled)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CLightManager::SetLightPriority(int lightRank, LightPriority priority)
|
||||||
|
{
|
||||||
|
if ( (lightRank < 0) || (lightRank >= static_cast<int>( m_dynLights.size() )) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_dynLights[lightRank].priority = priority;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CLightManager::SetLightIncludeType(int lightRank, EngineObjectType type)
|
bool CLightManager::SetLightIncludeType(int lightRank, EngineObjectType type)
|
||||||
{
|
{
|
||||||
if ( (lightRank < 0) || (lightRank >= static_cast<int>( m_dynLights.size() )) )
|
if ( (lightRank < 0) || (lightRank >= static_cast<int>( m_dynLights.size() )) )
|
||||||
|
@ -503,6 +512,9 @@ CLightManager::LightsComparator::LightsComparator(Math::Vector eyePos, EngineObj
|
||||||
|
|
||||||
float CLightManager::LightsComparator::GetLightWeight(const DynamicLight& dynLight)
|
float CLightManager::LightsComparator::GetLightWeight(const DynamicLight& dynLight)
|
||||||
{
|
{
|
||||||
|
if (dynLight.priority == LIGHT_PRI_HIGHEST)
|
||||||
|
return -1.0f;
|
||||||
|
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
if (!dynLight.used || !dynLight.enabled || dynLight.intensity.current == 0.0f)
|
if (!dynLight.used || !dynLight.enabled || dynLight.intensity.current == 0.0f)
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
|
|
@ -71,8 +71,9 @@ struct LightProgression
|
||||||
*/
|
*/
|
||||||
enum LightPriority
|
enum LightPriority
|
||||||
{
|
{
|
||||||
LIGHT_PRI_HIGH = 1,
|
LIGHT_PRI_HIGHEST = 1, //!< always highest weight (always picked)
|
||||||
LIGHT_PRI_LOW = 2
|
LIGHT_PRI_HIGH = 2, //!< high weight
|
||||||
|
LIGHT_PRI_LOW = 3 //!< low weight
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,6 +155,8 @@ public:
|
||||||
bool GetLight(int lightRank, Light &light);
|
bool GetLight(int lightRank, Light &light);
|
||||||
//! Enables/disables the given dynamic light
|
//! Enables/disables the given dynamic light
|
||||||
bool SetLightEnabled(int lightRank, bool enable);
|
bool SetLightEnabled(int lightRank, bool enable);
|
||||||
|
//! Changes the light priority
|
||||||
|
bool SetLightPriority(int lightRank, LightPriority priority);
|
||||||
|
|
||||||
//! Sets what objects are included in given dynamic light
|
//! Sets what objects are included in given dynamic light
|
||||||
bool SetLightIncludeType(int lightRank, EngineObjectType type);
|
bool SetLightIncludeType(int lightRank, EngineObjectType type);
|
||||||
|
|
|
@ -92,7 +92,7 @@ void CGLDevice::DebugLights()
|
||||||
m_worldMat.LoadIdentity();
|
m_worldMat.LoadIdentity();
|
||||||
UpdateModelviewMatrix();
|
UpdateModelviewMatrix();
|
||||||
|
|
||||||
for (int i = 0; i < m_lights.size(); ++i)
|
for (int i = 0; i < static_cast<int>( m_lights.size() ); ++i)
|
||||||
{
|
{
|
||||||
color.h = static_cast<float>(i) / static_cast<float>(m_lights.size());
|
color.h = static_cast<float>(i) / static_cast<float>(m_lights.size());
|
||||||
if (m_lightsEnabled[i])
|
if (m_lightsEnabled[i])
|
||||||
|
|
|
@ -4784,7 +4784,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
|
|
||||||
type = OpTypeTerrain(line, "type", Gfx::ENG_OBJTYPE_NULL);
|
type = OpTypeTerrain(line, "type", Gfx::ENG_OBJTYPE_NULL);
|
||||||
if (type == Gfx::ENG_OBJTYPE_TERRAIN)
|
if (type == Gfx::ENG_OBJTYPE_TERRAIN)
|
||||||
|
{
|
||||||
|
m_lightMan->SetLightPriority(lightRank, Gfx::LIGHT_PRI_HIGHEST);
|
||||||
m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_TERRAIN);
|
m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_TERRAIN);
|
||||||
|
}
|
||||||
|
|
||||||
if (type == Gfx::ENG_OBJTYPE_QUARTZ)
|
if (type == Gfx::ENG_OBJTYPE_QUARTZ)
|
||||||
m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_QUARTZ);
|
m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_QUARTZ);
|
||||||
|
|
Loading…
Reference in New Issue