From c0713db911b8a1ff25db86632286cb98f81764a3 Mon Sep 17 00:00:00 2001 From: Philosopher Date: Thu, 27 Nov 2014 22:07:25 -0600 Subject: [PATCH] Fix screen width compensation The reason it didn't work for me is that /sim/rendering/camera-group/camera/viewport/ does not seem to contain the actual dimensions of the view window... which is odd. Instead I'll use /sim/startup/[xy]size (and make it into a method so I don't have to change 3 lines next time :). Now that it works (again), it looks so much better. Thanks to Alexis Bory for the original idea. --- Nasal/view.nas | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Nasal/view.nas b/Nasal/view.nas index 41e05e946..6b4aae7f6 100644 --- a/Nasal/view.nas +++ b/Nasal/view.nas @@ -662,9 +662,13 @@ var screenWidthCompens = { statusNode: nil, # = /sim/current-view/field-of-view-compensation getStatus: func me.statusNode.getValue(), setStatus: func(state) me.statusNode.setValue(state), + wNode: nil, # = /sim/startup/xsize + hNode: nil, # = /sim/startup/ysize + getDimensions: func [me.wNode.getValue(),me.hNode.getValue()], calcNewFov: func(fov=55, oldW=nil, oldH=nil, w=nil, h=nil) { - if (w == nil) w = getprop("/sim/rendering/camera-group/camera/viewport/width"); - if (h == nil) h = getprop("/sim/rendering/camera-group/camera/viewport/height"); + var dim = me.getDimensions(); + if (w == nil) w = dim[0]; + if (h == nil) h = dim[1]; if (oldW == nil) oldW = me.assumedW; if (oldH == nil) oldH = me.assumedH; if (w/h == oldW/oldH or h > w) return fov; @@ -673,8 +677,9 @@ var screenWidthCompens = { init: func() { me.defaultFov = getprop("/sim/current-view/config/default-field-of-view-deg"); me.statusNode = props.globals.getNode("/sim/current-view/field-of-view-compensation", 1); - me.oldW = getprop("/sim/rendering/camera-group/camera/viewport/width"); - me.oldH = getprop("/sim/rendering/camera-group/camera/viewport/height"); + me.wNode = props.globals.getNode("/sim/startup/xsize", 1); + me.hNode = props.globals.getNode("/sim/startup/ysize", 1); + (me.oldW, me.oldH) = me.getDimensions(); setsize(me.fovStore, size(views)); forindex (var i; views) { @@ -688,8 +693,7 @@ var screenWidthCompens = { if (opt == nil) opt = me.getStatus(); else me.setStatus(opt); - var w = getprop("/sim/rendering/camera-group/camera/viewport/width"); - var h = getprop("/sim/rendering/camera-group/camera/viewport/height"); + var (w, h) = me.getDimensions(); # Update config/default-field-of-view-deg nodes if state changed: if (force or me.oldOpt != opt or me.oldW/me.oldH != w/h) { me.oldW = w;