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.
This commit is contained in:
parent
7b279f1fd7
commit
c0713db911
1 changed files with 10 additions and 6 deletions
|
@ -662,9 +662,13 @@ var screenWidthCompens = {
|
||||||
statusNode: nil, # = /sim/current-view/field-of-view-compensation
|
statusNode: nil, # = /sim/current-view/field-of-view-compensation
|
||||||
getStatus: func me.statusNode.getValue(),
|
getStatus: func me.statusNode.getValue(),
|
||||||
setStatus: func(state) me.statusNode.setValue(state),
|
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) {
|
calcNewFov: func(fov=55, oldW=nil, oldH=nil, w=nil, h=nil) {
|
||||||
if (w == nil) w = getprop("/sim/rendering/camera-group/camera/viewport/width");
|
var dim = me.getDimensions();
|
||||||
if (h == nil) h = getprop("/sim/rendering/camera-group/camera/viewport/height");
|
if (w == nil) w = dim[0];
|
||||||
|
if (h == nil) h = dim[1];
|
||||||
if (oldW == nil) oldW = me.assumedW;
|
if (oldW == nil) oldW = me.assumedW;
|
||||||
if (oldH == nil) oldH = me.assumedH;
|
if (oldH == nil) oldH = me.assumedH;
|
||||||
if (w/h == oldW/oldH or h > w) return fov;
|
if (w/h == oldW/oldH or h > w) return fov;
|
||||||
|
@ -673,8 +677,9 @@ var screenWidthCompens = {
|
||||||
init: func() {
|
init: func() {
|
||||||
me.defaultFov = getprop("/sim/current-view/config/default-field-of-view-deg");
|
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.statusNode = props.globals.getNode("/sim/current-view/field-of-view-compensation", 1);
|
||||||
me.oldW = getprop("/sim/rendering/camera-group/camera/viewport/width");
|
me.wNode = props.globals.getNode("/sim/startup/xsize", 1);
|
||||||
me.oldH = getprop("/sim/rendering/camera-group/camera/viewport/height");
|
me.hNode = props.globals.getNode("/sim/startup/ysize", 1);
|
||||||
|
(me.oldW, me.oldH) = me.getDimensions();
|
||||||
|
|
||||||
setsize(me.fovStore, size(views));
|
setsize(me.fovStore, size(views));
|
||||||
forindex (var i; views) {
|
forindex (var i; views) {
|
||||||
|
@ -688,8 +693,7 @@ var screenWidthCompens = {
|
||||||
if (opt == nil)
|
if (opt == nil)
|
||||||
opt = me.getStatus();
|
opt = me.getStatus();
|
||||||
else me.setStatus(opt);
|
else me.setStatus(opt);
|
||||||
var w = getprop("/sim/rendering/camera-group/camera/viewport/width");
|
var (w, h) = me.getDimensions();
|
||||||
var h = getprop("/sim/rendering/camera-group/camera/viewport/height");
|
|
||||||
# Update config/default-field-of-view-deg nodes if state changed:
|
# Update config/default-field-of-view-deg nodes if state changed:
|
||||||
if (force or me.oldOpt != opt or me.oldW/me.oldH != w/h) {
|
if (force or me.oldOpt != opt or me.oldW/me.oldH != w/h) {
|
||||||
me.oldW = w;
|
me.oldW = w;
|
||||||
|
|
Loading…
Reference in a new issue