Merge branch 'master' of gitorious.org:fg/fgdata
This commit is contained in:
commit
fb48ba3384
4 changed files with 46 additions and 28 deletions
|
@ -186,7 +186,7 @@ Symbol.Controller.getpos = func(obj) {
|
|||
die("bad ghost of type '"~ghosttype(obj)~"'");
|
||||
if (typeof(obj) == 'hash')
|
||||
if (isa(obj, geo.Coord))
|
||||
return obj.latlon();
|
||||
return subvec(obj.latlon(), 0, 2);
|
||||
if (isa(obj, props.Node))
|
||||
return [
|
||||
obj.getValue("position/latitude-deg") or obj.getValue("latitude-deg"),
|
||||
|
@ -380,8 +380,13 @@ var SymbolLayer = {
|
|||
onAdded: func(model)
|
||||
append(me.list, Symbol.new(me.type, me.group, model)),
|
||||
# Removes a symbol.
|
||||
onRemoved: func(model)
|
||||
me.findsym(model, 1).del(),
|
||||
onRemoved: func(model) {
|
||||
if (me.findsym(model, 1)) die("model not found");
|
||||
call(func model.del, nil, var err = []);
|
||||
# ignore errors
|
||||
# TODO: ignore only missing member del() errors? and only from the above line?
|
||||
# Note: die(err[0]) rethrows it; die(err[0]~"") does not.
|
||||
},
|
||||
}; # of SymbolLayer
|
||||
|
||||
# Class to manage controlling a #SymbolLayer.
|
||||
|
|
|
@ -422,7 +422,7 @@ var Map = {
|
|||
df_controller: nil,
|
||||
new: func(ghost)
|
||||
{
|
||||
return { parents: [Map, Group.new(ghost)] }.setController();
|
||||
return { parents: [Map, Group.new(ghost)], layers:{} }.setController();
|
||||
},
|
||||
del: func()
|
||||
{
|
||||
|
@ -451,9 +451,6 @@ var Map = {
|
|||
},
|
||||
addLayer: func(factory, type_arg=nil, priority=nil)
|
||||
{
|
||||
if (!contains(me, "layers"))
|
||||
me.layers = {};
|
||||
|
||||
if(contains(me.layers, type_arg))
|
||||
print("addLayer() warning: overwriting existing layer:", type_arg);
|
||||
|
||||
|
|
|
@ -21,17 +21,21 @@ var new = func(layer) {
|
|||
# Listen to ai model events
|
||||
append(m.listeners, setlistener(
|
||||
model_root.getNode("model-added"), func(n) {
|
||||
#printlog(_MP_dbg_lvl, "Dynamically adding model at "~n.getValue());
|
||||
var node = props.globals.getNode(n.getValue());
|
||||
var name = node.getName();
|
||||
if (name == "aircraft" or name == "multiplayer")
|
||||
if (m.in_range(node.getValue("position/latitude-deg"), node.getValue("position/longitude-deg")))
|
||||
layer.onAdded(TrafficModel.new(node));
|
||||
}
|
||||
));
|
||||
append(m.listeners, setlistener(
|
||||
model_root.getNode("model-removed"), func(n) {
|
||||
#printlog(_MP_dbg_lvl, "Dynamically deleting model at "~n.getValue());
|
||||
var node = props.globals.getNode(n.getValue());
|
||||
var name = node.getName();
|
||||
if (name == "aircraft" or name == "multiplayer")
|
||||
if (m.in_range(node.getValue("position/latitude-deg"), node.getValue("position/longitude-deg")))
|
||||
layer.onRemoved(TrafficModel.new(node));
|
||||
}
|
||||
));
|
||||
|
@ -43,6 +47,19 @@ var del = func() {
|
|||
foreach (var l; me.listeners)
|
||||
removelistener(l);
|
||||
};
|
||||
var in_range = func(lat,lon,myPositionVec=nil,max_dist_m=nil) {
|
||||
if (lat == nil or lon == nil) return 0;
|
||||
var pos = geo.Coord.new();
|
||||
pos.set_latlon(lat,lon);
|
||||
var myPosition = geo.Coord.new();
|
||||
# FIXME: need a Map Controller for this, and all query_range's/get_position's
|
||||
if (myPositionVec == nil)
|
||||
var myPositionVec = me.get_position();
|
||||
myPosition.set_latlon( myPositionVec[0], myPositionVec[1]);
|
||||
if (max_dist_m == nil)
|
||||
var max_dist_m = me.query_range()*NM2M;
|
||||
return (pos.distance_to( myPosition ) <= max_dist_m )
|
||||
};
|
||||
|
||||
var TrafficModel = {
|
||||
new: func(node, id=nil, layer=nil) {
|
||||
|
@ -50,13 +67,14 @@ var TrafficModel = {
|
|||
var m = {
|
||||
# Note: because this inherits from props.Node, Symbol.Controller.equals
|
||||
# will call l.equals(r) -- the one defined below
|
||||
parents: [TrafficModel, geo.Coord, node],
|
||||
parents: [TrafficModel, geo.Coord, node], # note we don't implement a full geo.Coord API
|
||||
id: id,
|
||||
node: node,
|
||||
pos: node.getNode("position"),
|
||||
pos: node.getNode("position",1),
|
||||
};
|
||||
if (m.pos == nil)
|
||||
m.latlon = func [nil,nil,nil];
|
||||
#debug.dump(m); # why doesn't this print?
|
||||
return m;
|
||||
},
|
||||
equals: func(other) other.id == me.id,
|
||||
|
@ -74,22 +92,20 @@ var searchCmd = func {
|
|||
#print("Doing query: "~name);
|
||||
|
||||
var result = [];
|
||||
var pos = geo.Coord.new(); # FIXME: all of these should be instance variables
|
||||
var myPosition = geo.Coord.new();
|
||||
# FIXME: need a Map Controller for this, and all query_range's/get_position's
|
||||
var myPositionVec = me.get_position();
|
||||
myPosition.set_latlon( myPositionVec[0], myPositionVec[1]);
|
||||
var max_dist_m = me.query_range()*NM2M;
|
||||
|
||||
# AI and Multiplayer traffic
|
||||
foreach (var traffic; [model_root.getChildren("aircraft"), model_root.getChildren("multiplayer")])
|
||||
foreach (var traffic; [model_root.getChildren("aircraft"), model_root.getChildren("multiplayer")]) {
|
||||
foreach(var t; traffic) {
|
||||
pos.set_latlon(t.getValue("position/latitude-deg"),
|
||||
t.getValue("position/longitude-deg"));
|
||||
|
||||
if (pos.distance_to( myPosition ) <= max_dist_m )
|
||||
if (me.in_range(t.getValue("position/latitude-deg"),
|
||||
t.getValue("position/longitude-deg"),
|
||||
myPositionVec,
|
||||
max_dist_m))
|
||||
append(result, TrafficModel.new(t, nil, me.layer));
|
||||
}
|
||||
}
|
||||
|
||||
#debug.dump(result);
|
||||
#return [];
|
||||
|
|
|
@ -66,10 +66,10 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<renderer>default-pipeline</renderer>
|
||||
<show-buffers type="bool" userarchive="y">false</show-buffers>
|
||||
<ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion>
|
||||
<ambient-occlusion-strength type="float" userarchive="y">1.0</ambient-occlusion-strength>
|
||||
<ambient-occlusion-strength type="float" userarchive="y">0.6</ambient-occlusion-strength>
|
||||
<ambient-occlusion-buffers type="bool">true</ambient-occlusion-buffers>
|
||||
<bloom type="bool" userarchive="y">true</bloom>
|
||||
<bloom-strength type="float" userarchive="y">1.0</bloom-strength>
|
||||
<bloom-strength type="float" userarchive="y">0.6</bloom-strength>
|
||||
<bloom-buffers type="bool">true</bloom-buffers>
|
||||
<night-vision type="bool">false</night-vision>
|
||||
<cinema>
|
||||
|
@ -104,7 +104,7 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
</cinema>
|
||||
<exposure type="float" userarchive="y">1.0</exposure>
|
||||
<use-color-for-depth type="bool">false</use-color-for-depth>
|
||||
<no-16bit-buffer type="bool">true</no-16bit-buffer>
|
||||
<no-16bit-buffer type="bool">false</no-16bit-buffer>
|
||||
<debug-buffer n="0">
|
||||
<enabled type="bool" userarchive="y">false</enabled>
|
||||
<name userarchive="y"></name>
|
||||
|
@ -229,13 +229,13 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<shadows>
|
||||
<enabled type="bool" userarchive="y">true</enabled>
|
||||
<debug type="bool" userarchive="y">false</debug>
|
||||
<map-size type="int">4096</map-size>
|
||||
<map-size type="int" userarchive="y">2048</map-size>
|
||||
<num-cascades type="int" userarchive="y">4</num-cascades>
|
||||
<cascade-far-m index="0" type="float" userarchive="y">5.0</cascade-far-m>
|
||||
<cascade-far-m index="1" type="float" userarchive="y">50.0</cascade-far-m>
|
||||
<cascade-far-m index="2" type="float" userarchive="y">500.0</cascade-far-m>
|
||||
<cascade-far-m index="3" type="float" userarchive="y">5000.0</cascade-far-m>
|
||||
<filtering type="int" userarchive="y">2</filtering>
|
||||
<cascade-far-m index="0" type="float" userarchive="y">2.0</cascade-far-m>
|
||||
<cascade-far-m index="1" type="float" userarchive="y">8.0</cascade-far-m>
|
||||
<cascade-far-m index="2" type="float" userarchive="y">32.0</cascade-far-m>
|
||||
<cascade-far-m index="3" type="float" userarchive="y">128.0</cascade-far-m>
|
||||
<filtering type="int" userarchive="y">1</filtering>
|
||||
</shadows>
|
||||
<shader-experimental type="bool" userarchive="y">false</shader-experimental>
|
||||
<shader-effects type="bool" userarchive="y">true</shader-effects>
|
||||
|
|
Loading…
Reference in a new issue