Add in support for generated structures

try this one
I thought about that, but I usually prefer code readability over code
speed, unless there is actually a proven detriment to the code. I assumed
that comparing the string (comparing 6 bytes vs comparing 1) would not
cause that much of an issue in the code. Just to verify, I ran gprof:

[1]     70.4    0.00    1.63      61             MapView::redraw() [1]
                0.03    1.44  191301/196460      MapView::drawChunk(int,
int) [2]
                0.02    0.12   80284/80284       MapView::getY(int, int)
[22]
                0.02    0.00   47903/47903
MapView::SpecialBlock::draw(double, double, double, QPainter&) const [72]
                0.00    0.00   90887/616273      QString::operator==(char
const*) const [94]
                0.00    0.00   90968/614397
 MapView::SpecialBlock::intersects(double, double, double, double, double,
double) const [100]

What it shows is that the redraw routine is very much the most expensive
call in the program. it is composed of an expensive call to drawChunk
(.03), getY (.02), and SpecialBlock::draw (.02). the string comparison
operator and the intersects routine do not show up on the same order of
magnitude.

The getY call is meant to determine the y coordinate of a given block on
the screen. its code gets called multiple times during the rendering
process, and could probably be cached. I will look into doing this in the
near future.

the SpecialBlock::draw call draws the alpha blended rounded rects on the
screen. Looking at it, it appears to spend most of its time in the QColor
constructor. I replaced it with the Qt::transparent constant, and it now
shows up near the bottom of the list of redraw subcalls.

So... I don't know much about drawChunk, but getY and SpecialBlock::draw
can very easily be improved. I will look into these, but reordering the
loop to reduce a string compare is not worth the reduction in readability.

All of these numbers, of course, will be heavily influenced by the size of
the map and the number of entities. I would love to see some profiling
results from a larger map, especially one that has been browsed for a
while.


On Thu, Oct 23, 2014 at 1:20 AM, Mattes D <notifications@github.com> wrote:

> In mapview.cpp:
>
> > +	//TODO: handle height?
> > +	QPainter canvas(&image);
> > +	double halfviewwidth = image.width()/2/zoom;
> > +	double halvviewheight = image.height()/2/zoom;
> > +	double x1 = x - halfviewwidth;
> > +	double z1 = z - halvviewheight;
> > +	double x2 = x + halfviewwidth;
> > +	double z2 = z + halvviewheight;
> > +
> > +	foreach(const QString& type, specialBlockTypes)
> > +	{
> > +		foreach(const SpecialBlock& block, specialBlocks[type])
> > +		{
> > +			//for Entitites, restrict the depth we see them
> > +			int mindepth = 0;
> > +			if (type == "Entity")
>
> You might want to pull this condition out of the inner loop and store its
> result into a bool variable, to avoid string comparison in a tight loop.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/mrkite/minutor/pull/49/files#r19261060>.
>



-- 
rian