Reduce SurfaceImage creation

Issue #31 new
Ian Mayo repo owner created an issue

I believe SurfaceImage is the way to go for us. I don't think we can pre-calculate a global coastline model, or afford to generate the an object that follows the coastline on the fly (though we haven't tried).

I think we can improve the SurfaceImage by cacheing the image object. As the user zooms/pans we can decide if a new surface image needs to be created.

Here's how we'd do it: * store the Sector object for the current image * change how we use computeSector. We only create a new TexturedLayer if the computeSector returns a non-null sector * in computeSector, compare the new dc.getVisibleSector() to the stored one using a ruleset: if stored sector is null, return getVisibleSector plus 10% if we have a sector, see if contains the new getVisibleSector. If it does, return null. If it doesn't return getVis plus 10% ** if we have a sector, see if it is more than double the size of the new getVisibleSector. If it is, return getVis plus 10%

Obviously I welcome an improved ruleset, and we'll want to tune the proportion figures.

Comments (6)

  1. Ian Mayo reporter

    Patrick provided feedback that appears related to this:

    Looking at you code, i think you should rather adapt the TexturedLayer code then create a top TexturedLayer that instanciates new TexturedLayers each time it needs to change the coverage.
    
    What takes some time is not the geometry creation but the image/texture loading which does only need to be done once.
    

    If I have a look at our OceanLayer class I believe he's referring to this. In doPreRender we examine the view to decide whether to re-generate the TexturedLayer. His point is that we should only generate the textured layer once (myLayer), but in this method we should just call myLayer.setSector(computeSector(dc))

    Whilst the image we use is quite small, it may be expensive to parse the image format, and then convert it to an OpenGL texture.

    Hope this helps, Ian

  2. Lance Wellspring

    Ohhhhh ok. I dont know why it was so hard for me to understand, but I just realized what he meant. That makes total sense, and I'm going to try it next. Now I feel silly for doing it the way I was lol.

  3. Ian Mayo reporter

    Great - I'm pleased the penny dropped.

    I look forward to the tidier version. Could you also rename the class from OceanLayer to SurfaceLayer?

    cheers, Ian

  4. Lance Wellspring

    This is currently working, though it has several problems. Note that it still only shows up after zooming in past 200,000 feet.

    1. I'm dumbfounded by this, but sometimes, for no apparent reason, the surface layer disappears. To get it to come back, you have to zoom out and back in.

    2. In some places, particularly near coastlines, the layer is darker in spots. The only explanation I can think of is that the layer has somehow been 'doubled up', so that it is being drawn twice in some places - making it darker.

    3. Moving a single TexturedLayer is still slow - and the resolution isn't even at an incredible amount. It seems that this chance did not really fix our problem.

    4. It doesn't yet use getVisibleSector, or any of the logic you outlined in the initial post.

  5. Log in to comment