Spodii / netgore

Cross platform online rpg engine using C# and SFML
http://www.netgore.com/
40 stars 16 forks source link

Mini-map performance + improvements #338

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Optimize the mini-map's performance. There are two approaches that I can think 
of:

1. Render the mini-map when saving the map in the map editor, and add to 
GrhDatas. This map will not be updated in the client, but can still draw on it. 
This should be fine for 99% of the cases, but will not show stuff like an 
altered background terrain / etc. I recommend this approach, at least 
initially, due to the simplicity.

2. Render real-time. This will allow the map to be rendered based off of what 
the map looks like at the time, making it possible to handle stuff like an 
altered background. But it also comes at a huge performance cost since you have 
to render everything in view. This will require:
a. Render only a partial view of the mini-map - the area you want to display on 
the mini-map, plus some additional buffered area (like an extra 50% in each 
direction, so if your mini-map shows 1000x1000 pixels, the rendered area will 
actually be 2000x2000).
b. Cache the mini-map rendering to a texture, and only update this texture 
every few seconds instead of every frame.
c. Add logic to ensure that the mini-map cache is invalidated when the user 
exceeds the visible area (e.g. teleports on the map).

#2 will be much harder, and only come at benefit if there people are altering 
their game world real-time at relative frequency, AND they want to display 
those alterations in the mini-map. You can still have #1 happen real-time as an 
event if needed, but we won't worry about that for now, since almost every game 
has a mini-map with a fixed background.

If you want to implement using #2, please ask first, as it will add a lot of 
time and complication.

To be included in NetGore mainline, mini-map generation needs to be 
transparent. So again, assuming #1, auto-generate on map save. I would also 
prefer if the map was scaled by a percentage, not a fixed size. E.g. 10% 
original map size. Be sure to also cap the minimap size at 2048x2048, OR have 
it save multiple segments and add support for displaying multiple segments. 
This has to work with large maps.

Since the mini-map will be scaled by percent, the area shown on the mini-map 
should be scrolling if it doesn't all fit in the form.

I would like this resolved before next release. DarkSummon will probably take 
it (didn't let me assign it to him for some reason though), but I can take it 
if needed.

Original issue reported on code.google.com by Spodiii on 5 Feb 2013 at 4:59

GoogleCodeExporter commented 9 years ago

Original comment by Spodiii on 5 Feb 2013 at 4:59

GoogleCodeExporter commented 9 years ago
Are you going to be able to resolve this by the next release, Darksummon? Let 
me know so I know whether or not to tack it onto my TODO.

Original comment by hilts.va...@gmail.com on 8 Feb 2013 at 5:51

GoogleCodeExporter commented 9 years ago

Original comment by hilts.va...@gmail.com on 8 Feb 2013 at 5:52

GoogleCodeExporter commented 9 years ago
I'll take a look later on tonight but I think it might be best for you to have 
a go also. I'm not 100% confident with this issue.

Original comment by darksumm...@gmail.com on 8 Feb 2013 at 8:59

GoogleCodeExporter commented 9 years ago
[Update]
Ok, all completed! :D Will commit the code a little bit later on.

Original comment by darksumm...@gmail.com on 8 Feb 2013 at 8:02

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r4739.

Original comment by darksumm...@gmail.com on 9 Feb 2013 at 12:29