Jump to content

[PLUGIN+PARTS][0.23] SCANsat terrain mapping


damny

Recommended Posts

Likewise, but I think it'd be a bit unfair on people without it to make a hard dependency on it. I know plenty of other mods do but I feel the same way about them.

Also, I feel I must disagree with some of the various reasons technogeeky posted as justification. Argumentum ad populum and appeal to authority are both fallacies so they should not be used*. Regarding user confusion, I think it's fair to say that people voting to put SCANsat in all pods are not likely to be confused about the appearance of a satellite button on their screen. They know the reason they put SCANsat in all pods was to eliminate the need for the scanner part so I'm pretty sure they'd know why there is a scanning button but no part. As for roleplay/IVA useage, the current non-Toolbar button could be configured to provide a GIU menu on right click that shows the various options (small/big map, instruments, settings).

Like I said, I already use the toolbar, so forced integration has no impact on me, but I realise other people are in a different situation and might not appreciate it. I would suggest a poll or vote of sorts, but I don't think this thread is active enough to show correctly represented results. Maybe in the General Add-On Affairs board, I don't know. But saying you're coding it so any decision you make is the right one doesn't take the users opinions into account.

*Just because something is popular, doesn't mean it's right or the correct thing to do and "authorities are not necessarily correct about judgements related to their field of expertise". In this case, the field of expertise in question is coding a hard dependency on the Toolbar.

hehe. Obviously I knew they were logical fallacies. I had to look up their names. That's why I put "over varying correctness." Those reasons were essentially jokes.

Link to comment
Share on other sites

I have toolbar because i like the idea of it.

However i would vote AGAINST mandatory and only vote for optional use.

Reason: The game is still only alpha. Already some really nice addons cant be used anymore as the developers decided to not play anymore/wait till final/ whatever. If the game would be final that wouldnt be much a problem, as nothing big will be changed and its unlikely that a addon breaks.

But if you make Toolbar mandatory and the dev decides to drop it, not only toolbar cant be used but all the addons that depend on it.

Sure, someone could overtake it (dont know which licence he uses) but will someone?

And updating is also pain. Your addon now need version X but the newest is already Y which is not compatible to X ... so, cant use your addon or cant use other addon that already need Y .

Link to comment
Share on other sites

But if you make Toolbar mandatory and the dev decides to drop it, not only toolbar cant be used but all the addons that depend on it.

Sure, someone could overtake it (dont know which licence he uses) but will someone?

And updating is also pain. Your addon now need version X but the newest is already Y which is not compatible to X ... so, cant use your addon or cant use other addon that already need Y.

I don't think this will be a problem, for two reasons. The first is that Toolbar is so popular, and so widely adopted by many of the bigshot modders (including ones with an existing track record for adopting others' mods) that it's inevitable that it will remain supported even if blizzy78 leaves.

The second is that blizzy78 has been *extremely* professional about proper versioning and backwards compatibility. They know what would happen if they got sloppy.

Link to comment
Share on other sites

I do look forward to a 'official' version that contains support for Toolbar, but I do think that optional support is best. There is also nothing saying that you have to be as feature-complete with buttons in the non-Toolbar UI. I think mechjeb is a good example of how things should be done in terms of optional Toolbar integration.

Link to comment
Share on other sites

I forked damny's SCAN repository and made two dev branches. One has the code of my currently released toolbar version. The other has the code for the toolbar optional version (and a few other changes), the master branch is unchanged.

I haven't really tested it much, but it works, as in, the game doesn't crash and the SCANsat code gets loaded, but there is no way to open the maps (I guess this could be good for a really die-hard RPM user:cool:). The changes necessary to allow the right-click buttons/action groups to open the map are not too major, so I don't think it would difficult to incorporate this version instead of my other one.

Link to comment
Share on other sites

I forked damny's SCAN repository and made two dev branches. One has the code of my currently released toolbar version. The other has the code for the toolbar optional version (and a few other changes), the master branch is unchanged.

I haven't really tested it much, but it works, as in, the game doesn't crash and the SCANsat code gets loaded, but there is no way to open the maps (I guess this could be good for a really die-hard RPM user:cool:). The changes necessary to allow the right-click buttons/action groups to open the map are not too major, so I don't think it would difficult to incorporate this version instead of my other one.

I'll take a look today. If everything is easy to understand to me (and it should be, I have spent a lot of time reading and commenting SCANsat code) then I'll incorporate it and release both toolbar and no-toolbar versions.

At least with the toolbar version out there it will be easy, at a later date, to stop supporting the non-toolbar version IFF we add features that really need toolbar.

I overestimated the ability for me to use the Toolbar functions from their DLL. All of the code in there is stuck in the Toolbar namespace, so I suppose it doesn't make sense for me to make use of it in SCANsat. I mainly wanted some of the window resizing / window clamping / window edge detection / version checking features. But I will just copy the relevant functions and include them in SCANsat instead.

Link to comment
Share on other sites

I'll take a look today. If everything is easy to understand to me (and it should be, I have spent a lot of time reading and commenting SCANsat code) then I'll incorporate it and release both toolbar and no-toolbar versions.

I made a one line fix to allow the "Open Map"/"Start Scan" button to open the small map. This is the only way to open the map without the toolbar, and you have to close it manually. With toolbar installed it doesn't do this, it might be nice for the MapTraq, but I think it would be annoying for the other scanners to constantly be opening the small map. There is also a fix to prevent non-animated parts from showing the "Extend" option in the editor, but that has nothing to do with the toolbar stuff.

Also, someone earlier said something about allowing for the other windows to be opened from IVA controls with RPM. That would have to be done on RPM's side, but I changed some of the access modifiers in SCANui to allow for that kind of control if you want to include that too.

I wouldn't recommend releasing two versions. If the toolbar-optional version works ok (and it should, the changes are relatively minor compared to the toolbar dependent version) then I think it would be best to only incorporate that version into the final release. With toolbar installed it works exactly the same as the other version.

Link to comment
Share on other sites

I made a one line fix to allow the "Open Map"/"Start Scan" button to open the small map. This is the only way to open the map without the toolbar, and you have to close it manually. With toolbar installed it doesn't do this, it might be nice for the MapTraq, but I think it would be annoying for the other scanners to constantly be opening the small map. There is also a fix to prevent non-animated parts from showing the "Extend" option in the editor, but that has nothing to do with the toolbar stuff.

Also, someone earlier said something about allowing for the other windows to be opened from IVA controls with RPM. That would have to be done on RPM's side, but I changed some of the access modifiers in SCANui to allow for that kind of control if you want to include that too.

I wouldn't recommend releasing two versions. If the toolbar-optional version works ok (and it should, the changes are relatively minor compared to the toolbar dependent version) then I think it would be best to only incorporate that version into the final release. With toolbar installed it works exactly the same as the other version.

OK.

I'm happy to report also, that I have Mono profiling working, and was able to capture some initial data on the (relative) performance of SCANsat. One of my goals is to try to speed up the redrawing of the Big Map, and the FPS loss associated with it (and especially with showing the Orbits).

Is it easy/possible/trivial to get profiling going in Windows? I think you develop on windows...

Link to comment
Share on other sites

Here are some examples from the profiling output. I am using one of the ideal scanning altitudes, allowing it to run in 1000x until (roughly) the time of completion stated by the orbit. Along the way, I have the small map and the big map up, orbit enabled, and I press the Altimtery (since I'm scanning with SAR) button once in a while (not very scientific, I know) to update the big map. The resulting profile is 12MB.

This is the orbit I ran (on the Mun, SAR, ideal 750k, max 800k):


79 41/74 (1.07) [B]519.466[/B] km 1.61 km [B]83.79[/B] [B]154h 09.0m +31.1m[/B] 5.2 0.03 90.74 m

So ~ 25 days later, I ended up with 83.3 % coverage. Tons of gaps. I am taking a hit because I'm below the ideal altitude, which really kills the SAR. I'm thinking about exempting the SAR from this effect just to please the ideal orbit calculator (or at least to verify its correctness).

Here is the first reasonable statistical profile sample I got (just a few functions listed, in order of highest overall percentage of time).


3.95% (7202) SCANsat.SCANdata.updateCoverage ()
7202 calls from SCANsat.SCANcontroller.scanFromAllVessels ()


0.81% (1476) SCANsat.SCANui.drawOrbit (UnityEngine.Rect,SCANsat.SCANmap,Vessel)
20938 calls from SCANsat.SCANui.gui_bigmap_build (int)
1 calls from UnityEngine.GUILayout/LayoutedWindow.DoWindow (int)
6596 calls to Orbit.getPositionAtUT (double)
4710 calls to SCANsat.SCANui.drawOrbitIcon (int,int,SCANsat.SCANui/OrbitIcon,UnityEngine.Color,int,bool)
2211 calls to UnityEngine.Color.op_Inequality (UnityEngine.Color,UnityEngine.Color)
1169 calls to CelestialBody.GetLongitude (Vector3d)
1025 calls to UnityEngine.Color.get_clear ()
952 calls to CelestialBody.GetLatitude (Vector3d)
440 calls to UnityEngine.Texture2D.SetPixels (int,int,int,int,UnityEngine.Color[])
424 calls to SCANsat.SCANui.drawLabel (UnityEngine.Rect,UnityEngine.Color,string,bool,bool)
336 calls to UnityEngine.Texture2D.GetPixels (int,int,int,int)
318 calls to CelestialBody.GetAltitude (Vector3d)
206 calls to UnityEngine.Color.op_Equality (UnityEngine.Color,UnityEngine.Color)
137 calls to SCANsat.SCANmap.projectLongitude (double,double)
102 calls to UnityEngine.Color..ctor (single,single,single,single)
84 calls to SCANsat.SCANmap.projectLatitude (double,double)
84 calls to SCANsat.SCANui.mapPosAtT (UnityEngine.Rect,SCANsat.SCANmap,UnityEngine.Rect&,Vessel,Orbit,double)
82 calls to UnityEngine.Color.op_Implicit (UnityEngine.Color)
73 calls to UnityEngine.Color.get_black ()
61 calls to UnityEngine.Color.Lerp (UnityEngine.Color,UnityEngine.Color,single)
58 calls to SCANsat.SCANmap.scaleLongitude (double)
55 calls to double.ToString (string)
45 calls to Orbit.getObtAtUT (double)
41 calls to UnityEngine.Color.get_white ()
34 calls to SCANsat.SCANmap.scaleLatitude (double)
33 calls to string.memcpy (byte*,byte*,int)
28 calls to System.Math.Atan2 (double,double)


0.43% (784) UnityEngine.Color.get_clear ()
1025 calls from SCANsat.SCANui.drawOrbit (UnityEngine.Rect,SCANsat.SCANmap,Vessel)
78 calls from SCANsat.SCANui.gui_bigmap_build (int)
319 calls to UnityEngine.Color..ctor (single,single,single,single)


0.26% (470) SCANsat.SCANdata.drawHeightScanline (SCANsat.SCANdata/SCANtype)
4918 calls from SCANsat.SCANdata.updateImages (SCANsat.SCANdata/SCANtype)
3384 calls to SCANsat.SCANmap.heightToColor (single,int)
306 calls to PQS.GetSurfaceHeight (Vector3d)
175 calls to SCANsat.SCANdata.isCovered (double,double,SCANsat.SCANdata/SCANtype)
156 calls to UnityEngine.Texture2D.GetPixels (int,int,int,int)
115 calls to SCANsat.SCANdata.isCoveredByAll (double,double,SCANsat.SCANdata/SCANtype)
96 calls to UnityEngine.Color.get_black ()
82 calls to UnityEngine.Color.Lerp (UnityEngine.Color,UnityEngine.Color,single)
67 calls to UnityEngine.Texture2D.SetPixels (int,int,int,int,UnityEngine.Color[])
39 calls to UnityEngine.Color.get_grey ()
12 calls to UnityEngine.Color..ctor (single,single,single,single)
4 calls to SCANsat.SCANcontroller.get_controller ()
3 calls to UnityEngine.Mathf.Clamp (single,single,single)
3 calls to System.Math.Round (double,int)
1 calls to UnityEngine.Mathf.Clamp01 (single)
1 calls to Vector3d.get_normalized ()
1 calls to string.memset (byte*,int,int)
1 calls to UnityEngine.Color.get_white ()
1 calls to PQS.Mod_OnVertexBuildHeight (PQS/VertexBuildData)
1 calls to string.memcpy (byte*,byte*,int)


0.15% (277) SCANsat.SCANcontroller.get_controller ()
4546 calls from SCANsat.SCANmap.heightToColor (single,int)
306 calls from SCANsat.SCANui.gui_bigmap_build (int)
300 calls from SCANsat.SCANui.get_c_good ()
188 calls from SCANsat.SCANui.gui_infobox_build (int)
131 calls from SCANsat.SCANui.gui_show ()
126 calls from SCANsat.SCANsat.OnUpdate ()
68 calls from SCANsat.SCANui.drawLegend ()

This isn't actually about SCANsat at all, it's about MechJeb. But I'm saving it here for the moment.


1.42% (2579) GameDatabase.GetTexture (string,bool)
9711 calls from MuMech.MechJebModuleMenu.SetupToolbarButton (MuMech.DisplayModule,bool)
7 calls from MuMech.MechJebModuleMenu.SetupToolBarButtons ()
5975 calls to string.op_Equality (string,string)
711 calls to System.Collections.Generic.List`1.get_Item (int)
454 calls to string.Equals (string,string)


0.26% (470) SCANsat.SCANdata.drawHeightScanline (SCANsat.SCANdata/SCANtype)
4918 calls from SCANsat.SCANdata.updateImages (SCANsat.SCANdata/SCANtype)
3384 calls to SCANsat.SCANmap.heightToColor (single,int)
306 calls to PQS.GetSurfaceHeight (Vector3d)
175 calls to SCANsat.SCANdata.isCovered (double,double,SCANsat.SCANdata/SCANtype)
156 calls to UnityEngine.Texture2D.GetPixels (int,int,int,int)
115 calls to SCANsat.SCANdata.isCoveredByAll (double,double,SCANsat.SCANdata/SCANtype)
96 calls to UnityEngine.Color.get_black ()
82 calls to UnityEngine.Color.Lerp (UnityEngine.Color,UnityEngine.Color,single)
67 calls to UnityEngine.Texture2D.SetPixels (int,int,int,int,UnityEngine.Color[])
39 calls to UnityEngine.Color.get_grey ()
12 calls to UnityEngine.Color..ctor (single,single,single,single)
4 calls to SCANsat.SCANcontroller.get_controller ()
3 calls to UnityEngine.Mathf.Clamp (single,single,single)
3 calls to System.Math.Round (double,int)
1 calls to UnityEngine.Mathf.Clamp01 (single)
1 calls to Vector3d.get_normalized ()
1 calls to string.memset (byte*,int,int)
1 calls to UnityEngine.Color.get_white ()
1 calls to PQS.Mod_OnVertexBuildHeight (PQS/VertexBuildData)
1 calls to string.memcpy (byte*,byte*,int)

Edited by technogeeky
Link to comment
Share on other sites

Ugh. I give up for tonight. I'm tired of fighting the forums. Anyway, after looking at some of this data. I think there are *several* pretty significant performance enhancements that are low hanging fruit. I think for sure that the bigmap can be improved easily. Especially all of the (probably unnecessary) color function calls.

Link to comment
Share on other sites

technogeeky, those sound like good improvements. When do you think you will have a working compile we can try out?

Unfortunately I doubt it will be until the end of next week. I have spent most of this weekend understanding the toolchains (debugger, profiler) and getting tests and measurements in place.

But I will get it out as soon as I can.

Link to comment
Share on other sites

How would I go about compiling v6 from the github files?

From my repository? You can't, it only has the changes I've made which are already available from this thread, and no one else has an updated fork of the original code available yet.

Link to comment
Share on other sites

OK. I believe I now have a working versions with the known bugfixes, with (fully optional and confirmed working) toolbar support, with debugging and profiling support.

I haven't implemented any performance enhancements yet. Because I have chosen not to, I can release a new version tomorrow.

In the meantime, how about some examples of sea level adjustment. Someone said something about a pink Mun?

"SEA LEVEL": 0 m (what you would see now)

JGBwTcP.png

"SEA LEVEL": -1000 m

yEmprx5.png

"SEA LEVEL": 1500 m

UFfijvJ.png

"SEA LEVEL": 2500 m

Pp0gyLy.png

"SEA LEVEL: 4000 m

2zpFW53.png

Sea Level adjustment will not be a feature in tomorrow's probable release. It is, however, a precursor feature to fully adjustable (and selectable) palettes.

Edited by technogeeky
Link to comment
Share on other sites

What would be best is if you could configure the minimum and maximum values the color-coding would scale to. For example, say you want to get a detailed a picture of some midlands as possible... set "sea level" to 1000m and peak to 2000m, so the entire color is compressed into that range. Small-elevation-change features become much more visible.

Link to comment
Share on other sites

What would be best is if you could configure the minimum and maximum values the color-coding would scale to. For example, say you want to get a detailed a picture of some midlands as possible... set "sea level" to 1000m and peak to 2000m, so the entire color is compressed into that range. Small-elevation-change features become much more visible.

Actually, what would be better is to allow options other than the rainbow color map -- luminosity or saturation-based color schemes will let you see fine detail without sacrificing range. See http://www.research.ibm.com/people/l/lloydt/color/color.HTM for more info on why the current color scheme hides more than it reveals.

Link to comment
Share on other sites

Actually, what would be better is to allow options other than the rainbow color map -- luminosity or saturation-based color schemes will let you see fine detail without sacrificing range. See http://www.research.ibm.com/people/l/lloydt/color/color.HTM for more info on why the current color scheme hides more than it reveals.
That is a really great post, and I totally agree. This is something I learned firsthand when making maps for KSP back in v0.18. The rainbow-shaded maps are some of the hardest to read. On the other hand, selecting a color scheme, using non-linear ranges, and especially adding topo lines and hillshading helps tons.
Link to comment
Share on other sites

Well, I said I would try and release it this weekend, and I find myself publishing the release at 11:59 PM EST.

NOTE: This may not work yet. This is a RELEASE CANDIDATE. I want one or two (hopefully DMagic) people to test it out and tell me things work as expected.

SCANsat v6rc for KSP [0.23.5]

SCANsat v6rc for KSP [0.23.5] SOURCE

If you use RPM, please stick wtih v5 until further notice!


Build 6 - 2014-04-28
--------------------


+ [REQUIRED] Update for KSP version 0.23.5. This version of SCANsat now requires KSP 0.23.5.


+ [OPTIONAL] Toolbar support. Built against 1.7.1. TOTALLY OPTIONAL. Though the experience
is better and more consistent with the Toolbar. [thanks DMagic!]


- [REMOVED] Removed the old expanding/contracting floating SCANsat button. Replaced instead with
either a Toolbar toolbar or with nothing, but maps become visible upon starting a scan. [thanks Dmagic!]


- [REMOVED] Non-animated parts no longer show an 'Extend' option in EDITOR. [... Dmagic is doing all the work!]


+ [COMPATABILITY] "Change access modifiers to allow for more control from RPM".
Yes, it's in quotes because I trust Dmagic THAT much.
[thanks Dmagic!]


- [BUGFIX] Scanning high inclinations with wide-enough FOV scanners
(ie, Multi, RADAR, but not SAR) will no longer reveal the opposite polar region. [thanks DMagic!]
[example orbit]: Minmus 250.000x250.000km @ 91.0 degrees


+ [HUMOR] This file is different, and so is TODO.txt.


+ [dev] Support for changing what you define as 'sea level'. Compiled to be default (ie, 0).
- [dev] Removed all unused declerations
+ [dev] switched to unix line endings.
+ [dev] switched to custom, but uniform formatting (for now done by MonoDevelop).
- [dev] removed windows commands in .csproj and .sln.
+ [dev] added unix commands. I will be happy to have both if I can be shown how.
+ [dev] added debugging and profiling support. Includes dummy executable.
+ [dev] [requires] that the SCANsat.dll be put directly in place (ie, GameData\SCANsat\.)
for debugging to work

Please tell me if you encounter problems, and go easy on me :)

Eventually, after I know it works and I have gotten up-to-date screen shots of features, I will make a new thread and we'll all stumble in there.

Edited by technogeeky
Link to comment
Share on other sites

Well, I said I would try and release it this weekend, and I find myself publishing the release at 11:59 PM EST.

NOTE: This may not work yet. This is a RELEASE CANDIDATE. I want one or two (hopefully DMagic) people to test it out and tell me things work as expected.

SCANsat v6rc for KSP [0.23.5]

SCANsat v6rc for KSP [0.23.5] SOURCE

Please tell me if you encounter problems, and go easy on me :)

Eventually, after I know it works and I have gotten up-to-date screen shots of features, I will make a new thread and we'll all stumble in there.

I have a clean copy I use to tweak parts. I can test with that. Unfortunately this week coming up is one of the busiest weeks at work I have all year. It will probably be next Sunday before I can get a chance. =(

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...