From 8aabd3726ada9932ca4209d0770ce420ac8afb09 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Sat, 19 Jul 2014 21:43:51 +0200 Subject: [PATCH 1/6] parsesvg: support for rectangular clip/mask. --- Nasal/canvas/svg.nas | 83 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/Nasal/canvas/svg.nas b/Nasal/canvas/svg.nas index 7593b1eb9..955f2d46d 100644 --- a/Nasal/canvas/svg.nas +++ b/Nasal/canvas/svg.nas @@ -49,12 +49,18 @@ var parsesvg = func(group, path, options = nil) var stack = [group]; var close_stack = []; # helper for check tag closing + var defs_stack = []; + var text = nil; var tspans = nil; # lookup table for element ids (for element) var id_dict = {}; + # lookup table for mask and clipPath element ids + var clip_dict = {}; + var cur_clip = nil; + # ---------------------------------------------------------------------------- # Create a new child an push it onto the stack var pushElement = func(type, id = nil) @@ -64,6 +70,21 @@ var parsesvg = func(group, path, options = nil) if( typeof(id) == 'scalar' and size(id) ) id_dict[ id ] = stack[-1]; + + if( cur_clip != nil ) + { + var rect = sprintf( + "rect(%f, %f, %f, %f)", + cur_clip['y'], + cur_clip['x'] + cur_clip['width'], + cur_clip['y'] + cur_clip['height'], + cur_clip['x'] + ); + + stack[-1].set("clip", rect); + stack[-1].set("clip-frame", canvas.Element.LOCAL); + cur_clip = nil; + } } # ---------------------------------------------------------------------------- @@ -367,11 +388,46 @@ var parsesvg = func(group, path, options = nil) return; } + if( size(defs_stack) > 0 ) + { + if( name == "mask" or name == "clipPath" ) + { + append(defs_stack, {'type': name, 'id': attr['id']}); + } + else if( name == "rect" ) + { + foreach(var p; ["x", "y", "width", "height"]) + defs_stack[-1][p] = evalCSSNum(attr[p]); + skip = level; + } + else + { + printlog( + "info", + "parsesvg: skipping unknown element in : <" ~ name ~ ">" + ); + skip = level; + } + return; + } + var style = parseStyle(attr['style']); + var clip_id = attr['clip-path'] or attr['mask']; + if( clip_id != nil ) + { + if( clip_id.starts_with("url(#") + and clip_id[-1] == `)` ) + clip_id = substr(clip_id, 5, size(clip_id) - 5 - 1); + + cur_clip = clip_dict[clip_id]; + if( cur_clip == nil ) + printlog("warn", "parsesvg: clip not found: " ~ clip_id); + } + if( style['display'] == 'none' ) { - skip = level - 1; + skip = level; return; } else if( name == "g" ) @@ -448,7 +504,10 @@ var parsesvg = func(group, path, options = nil) var el_src = id_dict[ substr(ref, 1) ]; if( el_src == nil ) - return printlog("info", "parsesvg: Reference to unknown element (" ~ ref ~ ")"); + return printlog( + "warn", + "parsesvg: Reference to unknown element (" ~ ref ~ ")" + ); # Create new element and copy sub branch from source node pushElement(el_src._node.getName(), attr['id']); @@ -457,6 +516,11 @@ var parsesvg = func(group, path, options = nil) # copying also overrides the id so we need to set it again stack[-1]._node.getNode("id").setValue(attr['id']); } + else if( name == "defs" ) + { + append(defs_stack, "defs"); + return; + } else { printlog("info", "parsesvg: skipping unknown element '" ~ name ~ "'"); @@ -482,11 +546,24 @@ var parsesvg = func(group, path, options = nil) if( skip ) { - if( level <= skip ) + if( level < skip ) skip = 0; return; } + if( size(defs_stack) > 0 ) + { + if( name != "defs" ) + { + var type = defs_stack[-1]['type']; + if( type == "mask" or type == "clipPath" ) + clip_dict[defs_stack[-1]['id']] = defs_stack[-1]; + } + + pop(defs_stack); + return; + } + if( size(close_stack) and (level + 1) == close_stack[-1] ) popElement(); From 67229cbadc682434c2b01c6269e412bc74de4351 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 21 Jul 2014 00:28:44 +0200 Subject: [PATCH 2/6] canvas.gui: handle visibility changes of widgets. --- Nasal/canvas/gui/Widget.nas | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Nasal/canvas/gui/Widget.nas b/Nasal/canvas/gui/Widget.nas index 652da5c4b..95955bcd2 100644 --- a/Nasal/canvas/gui/Widget.nas +++ b/Nasal/canvas/gui/Widget.nas @@ -127,6 +127,10 @@ gui.Widget = { if( me._view != nil and me._view.update != nil ) me._view.update(me); }, + visibilityChanged: func(visible) + { + me._view._root.setVisible(visible); + }, _setView: func(view) { me._view = view; From db5002ebe0be81d33fcdb35a4f0cf2bc2b2b0754 Mon Sep 17 00:00:00 2001 From: BARANGER Emmanuel Date: Mon, 28 Jul 2014 13:37:23 +0200 Subject: [PATCH 3/6] Merge branch 'master' of gitorious.org:fg/fgdata From 46e2402f2f67508eca1378ec4db5c79ee3f5bbf6 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Wed, 30 Jul 2014 12:21:09 +0300 Subject: [PATCH 4/6] Improved fading for runway lights at night for ALS (work in progress) --- Effects/surface-lights.eff | 4 ++-- Shaders/surface-light-lightfield.frag | 6 ++++-- Shaders/surface-light-lightfield.vert | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Effects/surface-lights.eff b/Effects/surface-lights.eff index f10c0065a..7603f6c2d 100644 --- a/Effects/surface-lights.eff +++ b/Effects/surface-lights.eff @@ -50,10 +50,10 @@ false - + directional point diff --git a/Shaders/surface-light-lightfield.frag b/Shaders/surface-light-lightfield.frag index 717e2b8c2..04e46173b 100644 --- a/Shaders/surface-light-lightfield.frag +++ b/Shaders/surface-light-lightfield.frag @@ -7,6 +7,7 @@ uniform float avisibility; uniform float hazeLayerAltitude; uniform float eye_alt; uniform float terminator; +uniform float size; varying vec3 relPos; varying vec2 rawPos; @@ -140,8 +141,9 @@ void main() transmission = fog_func(transmission_arg); float lightArg = terminator/100000.0; - float attenuationScale = 1.0 + 3.0 * (1.0 -smoothstep(-15.0, 0.0, lightArg)); - float dist_att = exp(-0.3/attenuationScale/pixelSize); + float attenuationScale = 1.0 + 20.0 * (1.0 -smoothstep(-15.0, 0.0, lightArg)); + //float dist_att = exp(-100.0/attenuationScale/size); + float dist_att = exp(-dist/200.0/size/attenuationScale); //vec4 texel = texture2D(texture,gl_TexCoord[0].st); vec4 texel = light_sprite(gl_TexCoord[0].st,transmission, noise); diff --git a/Shaders/surface-light-lightfield.vert b/Shaders/surface-light-lightfield.vert index 43b6c2522..6d90cb8f0 100644 --- a/Shaders/surface-light-lightfield.vert +++ b/Shaders/surface-light-lightfield.vert @@ -20,7 +20,7 @@ void main() relPos = gl_Vertex.xyz - ep.xyz; rawPos = gl_Vertex.xy; float dist = length(relPos); - float lightScale = size * size * size * size * size / 1000.0; + float lightScale = size * size * size * size * size/ 500.0; pixelSize = min(size * size/25.0,lightScale/dist); gl_PointSize = 2.0 * pixelSize; } From bbb501e36af99a658b8d7867d57339078b2f836e Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Thu, 31 Jul 2014 21:34:48 +0100 Subject: [PATCH 5/6] Reload scenery on exit from Rendering dialog. Various updates to the Rendering Dialog - Remove experimental reduced LoD options - Remove Reload Scenery - Automatically Reload Scenery on OK. --- gui/dialogs/rendering.xml | 48 +++++---------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/gui/dialogs/rendering.xml b/gui/dialogs/rendering.xml index 7759c24c7..e46d13685 100644 --- a/gui/dialogs/rendering.xml +++ b/gui/dialogs/rendering.xml @@ -363,47 +363,8 @@ - - 5 - 0 - 3 - left - - simplify-far - /sim/rendering/terrain/simplifier/enabled-far - - dialog-apply - simplify-far - - - - - 6 - 0 - 3 - left - - simplify-near - /sim/rendering/terrain/simplifier/enabled-near - - /sim/rendering/terrain/simplifier/enabled-far - - - dialog-apply - simplify-near - - - - - vbox 1 @@ -781,9 +742,12 @@