1
0
Fork 0

Directional point light (triangle) changes

Ensure that there are listeners on the properties as the scene features needs to be kept up to date with the properties.
This commit is contained in:
Richard Harrison 2020-08-07 08:36:45 +02:00
parent 75e28368ea
commit ab1ecb0a31
2 changed files with 34 additions and 9 deletions

View file

@ -461,6 +461,30 @@ public:
} }
}; };
class PointSpriteListener : public SGPropertyChangeListener {
public:
virtual void valueChanged(SGPropertyNode* node) {
static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
sceneFeatures->setEnablePointSpriteLights(node->getIntValue());
}
};
class DistanceAttenuationListener : public SGPropertyChangeListener {
public:
virtual void valueChanged(SGPropertyNode* node) {
static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
sceneFeatures->setEnableDistanceAttenuationLights(node->getIntValue());
}
};
class DirectionalLightsListener : public SGPropertyChangeListener {
public:
virtual void valueChanged(SGPropertyNode* node) {
static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance();
sceneFeatures->setEnableTriangleDirectionalLights(node->getIntValue());
}
};
void void
FGRenderer::addChangeListener(SGPropertyChangeListener* l, const char* path) FGRenderer::addChangeListener(SGPropertyChangeListener* l, const char* path)
{ {
@ -514,21 +538,22 @@ FGRenderer::init( void )
_ysize = fgGetNode("/sim/startup/ysize", true); _ysize = fgGetNode("/sim/startup/ysize", true);
_splash_alpha = fgGetNode("/sim/startup/splash-alpha", true); _splash_alpha = fgGetNode("/sim/startup/splash-alpha", true);
_point_sprites = fgGetNode("/sim/rendering/point-sprites", true); _horizon_effect = fgGetNode("/sim/rendering/horizon-effect", true);
_distance_attenuation = fgGetNode("/sim/rendering/distance-attenuation", true);
_triangle_directional_lights = fgGetNode("/sim/rendering/triangle-directional-lights", true);
_horizon_effect = fgGetNode("/sim/rendering/horizon-effect", true);
_altitude_ft = fgGetNode("/position/altitude-ft", true); _altitude_ft = fgGetNode("/position/altitude-ft", true);
_cloud_status = fgGetNode("/environment/clouds/status", true); _cloud_status = fgGetNode("/environment/clouds/status", true);
_visibility_m = fgGetNode("/environment/visibility-m", true); _visibility_m = fgGetNode("/environment/visibility-m", true);
bool use_point_sprites = _point_sprites->getBoolValue(); // configure the lighting related parameters and add change listeners.
bool distance_attenuation = _distance_attenuation->getBoolValue(); bool use_point_sprites = fgGetBool("/sim/rendering/point-sprites", true);
bool triangles = _triangle_directional_lights->getBoolValue(); bool distance_attenuation = fgGetBool("/sim/rendering/distance-attenuation", false);
bool triangles = fgGetBool("/sim/rendering/triangle-directional-lights", true);
SGConfigureDirectionalLights(use_point_sprites, distance_attenuation, triangles);
SGConfigureDirectionalLights( use_point_sprites, distance_attenuation, triangles ); addChangeListener(new PointSpriteListener, "/sim/rendering/point-sprites");
addChangeListener(new DistanceAttenuationListener, "/sim/rendering/distance-attenuation");
addChangeListener(new DirectionalLightsListener, "/sim/rendering/triangle-directional-lights");
if (const char* tc = fgGetString("/sim/rendering/texture-compression", NULL)) { if (const char* tc = fgGetString("/sim/rendering/texture-compression", NULL)) {
if (strcmp(tc, "false") == 0 || strcmp(tc, "off") == 0 || if (strcmp(tc, "false") == 0 || strcmp(tc, "off") == 0 ||

View file

@ -137,7 +137,7 @@ protected:
SGPropertyNode_ptr _splash_alpha; SGPropertyNode_ptr _splash_alpha;
SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation, _triangle_directional_lights; SGPropertyNode_ptr _enhanced_lighting;
SGPropertyNode_ptr _textures; SGPropertyNode_ptr _textures;
SGPropertyNode_ptr _cloud_status, _visibility_m; SGPropertyNode_ptr _cloud_status, _visibility_m;
SGPropertyNode_ptr _xsize, _ysize; SGPropertyNode_ptr _xsize, _ysize;