diff --git a/simgear/scene/model/SGLight.cxx b/simgear/scene/model/SGLight.cxx index b29f5797..47a48ef1 100644 --- a/simgear/scene/model/SGLight.cxx +++ b/simgear/scene/model/SGLight.cxx @@ -51,15 +51,23 @@ SGLight::appendLight(const SGPropertyNode *configNode, if((p = configNode->getNode("type")) != NULL) { std::string type = p->getStringValue(); if (type == "point") - light->setType(SGLight::Type::POINT); + light->setType(SGLight::POINT); else if (type == "spot") - light->setType(SGLight::Type::SPOT); + light->setType(SGLight::SPOT); else SG_LOG(SG_GENERAL, SG_ALERT, "ignoring unknown light type '" << type << "'"); } light->setRange(configNode->getFloatValue("range-m")); + std::string priority = configNode->getStringValue("priority", "low"); + if (priority == "high") + light->setPriority(SGLight::HIGH); + else if (priority == "medium") + light->setPriority(SGLight::MEDIUM); + else + light->setPriority(SGLight::LOW); + #define SGLIGHT_GET_COLOR_VALUE(n) \ osg::Vec4(configNode->getFloatValue(n "/r"), \ configNode->getFloatValue(n "/g"), \ @@ -166,7 +174,8 @@ SGLight::appendLight(const SGPropertyNode *configNode, SGLight::SGLight() : _type(Type::POINT), - _range(0.0f) + _range(0.0f), + _priority(Priority::LOW) { // Default values taken from osg::Light // They don't matter anyway as they are overwritten by the XML config values diff --git a/simgear/scene/model/SGLight.hxx b/simgear/scene/model/SGLight.hxx index a9b07cf2..407fe57e 100644 --- a/simgear/scene/model/SGLight.hxx +++ b/simgear/scene/model/SGLight.hxx @@ -30,6 +30,12 @@ public: SPOT }; + enum Priority { + LOW, + MEDIUM, + HIGH + }; + class UpdateCallback : public osg::NodeCallback { public: UpdateCallback(const SGExpressiond *expression, @@ -106,6 +112,9 @@ public: void setSpotCutoff(float spot_cutoff) { _spot_cutoff = spot_cutoff; } float getSpotCutoff() const { return _spot_cutoff; } + void setPriority(Priority priority) { _priority = priority; } + Priority getPriority() const { return _priority; } + protected: virtual ~SGLight(); @@ -122,6 +131,8 @@ protected: float _quadratic_attenuation; float _spot_exponent; float _spot_cutoff; + + Priority _priority; }; typedef std::vector> SGLightList; diff --git a/simgear/scene/viewer/ClusteredShading.cxx b/simgear/scene/viewer/ClusteredShading.cxx index 976e6559..4061efc5 100644 --- a/simgear/scene/viewer/ClusteredShading.cxx +++ b/simgear/scene/viewer/ClusteredShading.cxx @@ -191,8 +191,7 @@ ClusteredShading::update(const SGLightList &light_list) // The parenthesis are very important: if the vector is // multiplied by the local to world matrix first we'll have // precision issues - (osg::computeLocalToWorld(light->getParentalNodePaths()[0]) * - _camera->getViewMatrix()); + (light->getWorldMatrices()[0] * _camera->getViewMatrix()); point.range = light->getRange(); _point_bounds.push_back(point); @@ -200,11 +199,9 @@ ClusteredShading::update(const SGLightList &light_list) SpotlightBound spot; spot.light = light; spot.position = osg::Vec4f(0.0f, 0.0f, 0.0f, 1.0f) * - (osg::computeLocalToWorld(light->getParentalNodePaths()[0]) * - _camera->getViewMatrix()); + (light->getWorldMatrices()[0] * _camera->getViewMatrix()); spot.direction = osg::Vec4f(0.0f, 0.0f, -1.0f, 0.0f) * - (osg::computeLocalToWorld(light->getParentalNodePaths()[0]) * - _camera->getViewMatrix()); + (light->getWorldMatrices()[0] * _camera->getViewMatrix()); spot.direction.normalize(); float range = light->getRange();