From 9af931b4a3d91364f7afa6161cae8cab6da04366 Mon Sep 17 00:00:00 2001 From: Ryan Rector Date: Wed, 3 Aug 2011 22:47:25 -0600 Subject: [PATCH] Super performance fixer! Rotations no longer have any significant performance hit. Allocate rotated array once during rotation instead of during every chunk render. --- README.rst | 5 ----- overviewer_core/world.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index 1535941..bf3e700 100644 --- a/README.rst +++ b/README.rst @@ -43,11 +43,6 @@ existing bug that will not let you click on a sign in some cases. This is a bang-head-on-desk sort of thing, I should be able to find it but I just haven't yet. It does seem to work fine on my actual SMP map, for what that's worth. -It's slow! One of the rotation methods is very, very inefficient. It needs to be -rewritten, but I don't seem to be smart enough to do it right now. I must -investigate! On my SMP map the initial render took 30% longer vs the official -Minecraft Overviewer. Totally worth it, though. - So far only blocks where direction is important (minecart tracks, doors, signs, etc) rotate. Blocks like grass, stone, gravel, etc do not, however for the most part it isn't noticeable because they look very similar no matter which diff --git a/overviewer_core/world.py b/overviewer_core/world.py index 6ca3d86..2bba9dd 100644 --- a/overviewer_core/world.py +++ b/overviewer_core/world.py @@ -153,18 +153,18 @@ class World(object): data = nbt.read_all() level = data[1]['Level'] chunk_data = level - chunk_data['Blocks'] = numpy.rot90(numpy.frombuffer( + chunk_data['Blocks'] = numpy.array(numpy.rot90(numpy.frombuffer( level['Blocks'], dtype=numpy.uint8).reshape((16,16,128)), - self._get_north_rotations()) - chunk_data['Data'] = numpy.rot90(numpy.frombuffer( + self._get_north_rotations())) + chunk_data['Data'] = numpy.array(numpy.rot90(numpy.frombuffer( level['Data'], dtype=numpy.uint8).reshape((16,16,64)), - self._get_north_rotations()) - chunk_data['SkyLight'] = numpy.rot90(numpy.frombuffer( + self._get_north_rotations())) + chunk_data['SkyLight'] = numpy.array(numpy.rot90(numpy.frombuffer( level['SkyLight'], dtype=numpy.uint8).reshape((16,16,64)), - self._get_north_rotations()) - chunk_data['BlockLight'] = numpy.rot90(numpy.frombuffer( + self._get_north_rotations())) + chunk_data['BlockLight'] = numpy.array(numpy.rot90(numpy.frombuffer( level['BlockLight'], dtype=numpy.uint8).reshape((16,16,64)), - self._get_north_rotations()) + self._get_north_rotations())) #chunk_data = {} #chunk_data['skylight'] = chunk.get_skylight_array(level) #chunk_data['blocklight'] = chunk.get_blocklight_array(level)