Skip to content

Commit

Permalink
TGP: TGP account for radar blep refresh rate. Issue #589.
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiVChr committed Apr 19, 2024
1 parent a7f460c commit 48f9868
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Nasal/radar/radar-system.nas
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,16 @@ var AIContact = {
# This is for inaccurate radar locking of surface targets with TGP.
if (me.virt != nil) return me.virt;
me.virt = {parents: [me, AIContact, Contact]};
me.virtCoord = me.getCoord();
me.virtCoord.set_xyz(me.virtCoord.x()+rand()*spheric_dist_m*2-spheric_dist_m,me.virtCoord.y()+rand()*spheric_dist_m*2-spheric_dist_m,me.virtCoord.z()+rand()*spheric_dist_m*2-spheric_dist_m);
me.virtCoord = me.getLastCoord();
if (me.virtCoord == nil) {
me.virtCoord = me.getCoord();
}
me.virt.rx = rand()*spheric_dist_m*2-spheric_dist_m;
me.virt.ry = rand()*spheric_dist_m*2-spheric_dist_m;
me.virt.rz = rand()*spheric_dist_m*2-spheric_dist_m;
me.virt.r = spheric_dist_m != 0;
me.virt.lastBleep = me.getLastBlep();
me.virtCoord.set_xyz(me.virtCoord.x()+me.virt.rx,me.virtCoord.y()+me.virt.ry,me.virtCoord.z()+me.virt.rz;
me.virt.elevpick = geo.elevation(me.virtCoord.lat(),me.virtCoord.lon());
if (spheric_dist_m != 0 and me.virt.elevpick != nil) me.virtCoord.set_alt(me.virt.elevpick);# TODO: Not convinced this is the place for the 1m offset since both missiles and radar subtract 1m from targetdistance, but for slanted picking with undulations its still good idea to not place it at the base.
me.virt.coord = me.virtCoord;
Expand All @@ -921,6 +929,17 @@ var AIContact = {
return me.virt;
};
me.virt.getCoord = func {
if (me.virt.lastBleep != me.getLastBlep()) {
# we have a new blep, calculate the offset coord for it
me.virtCoord = me.getLastCoord();
if (me.virtCoord != nil) {
me.virtCoord.set_xyz(me.virtCoord.x()+me.virt.rx,me.virtCoord.y()+me.virt.ry,me.virtCoord.z()+me.virt.rz;
me.virt.elevpick = geo.elevation(me.virtCoord.lat(),me.virtCoord.lon());
if (me.virt.r and me.virt.elevpick != nil) me.virtCoord.set_alt(me.virt.elevpick);# TODO
me.virt.coord = me.virtCoord;
}
me.virt.lastBleep = me.getLastBlep();
}
return me.virt.coord;
};
me.virt.isVirtual = func {
Expand Down

0 comments on commit 48f9868

Please sign in to comment.