Commit 8625339a authored by Rick Gruber-Riemer's avatar Rick Gruber-Riemer

Re-introducing deleted code, which prepvents non-repeated textures to be...

Re-introducing deleted code, which prepvents non-repeated textures to be written to texture atlas and thereby leading to "black" untextured buildings.
parent 12f1b877
...@@ -46,7 +46,7 @@ def _make_texture_atlas(texture_list: List[Texture], atlas_filename: str, ext: s ...@@ -46,7 +46,7 @@ def _make_texture_atlas(texture_list: List[Texture], atlas_filename: str, ext: s
""" """
Create texture atlas from all textures. Update all our item coordinates. Create texture atlas from all textures. Update all our item coordinates.
""" """
logging.debug("Making texture atlas") logging.info("Making texture atlas")
if len(texture_list) < 1: if len(texture_list) < 1:
logging.error('Got an empty texture list. Check installation of tex.src/ folder!') logging.error('Got an empty texture list. Check installation of tex.src/ folder!')
...@@ -87,10 +87,16 @@ def _make_texture_atlas(texture_list: List[Texture], atlas_filename: str, ext: s ...@@ -87,10 +87,16 @@ def _make_texture_atlas(texture_list: List[Texture], atlas_filename: str, ext: s
# FIXME: maybe auto-calc x-size here # FIXME: maybe auto-calc x-size here
# -- pack non_repeatables
# Sort textures by perimeter size in non-increasing order
the_atlas = atlas.Atlas(0, 0, atlas_sx, 1e10, 'Facades') the_atlas = atlas.Atlas(0, 0, atlas_sx, 1e10, 'Facades')
# Work on not repeatable textures
# Sort textures by perimeter size in non-increasing order
non_repeat_list = sorted(non_repeat_list, key=lambda i: i.sy, reverse=True)
for the_texture in non_repeat_list:
the_texture.width_px, the_texture.height_px = the_texture.im.size
if not the_atlas.pack(the_texture):
logging.info("Failed to pack" + str(the_texture))
atlas_sy = the_atlas.cur_height() atlas_sy = the_atlas.cur_height()
# Work on repeatable textures. # Work on repeatable textures.
......
"""Atlas of textures, where a couple of textures are put into one file including thier attributes""" """Atlas of textures, where a couple of textures are put into one file including their attributes"""
import logging
import PIL.Image as Image import PIL.Image as Image
import logging
class Region(object): class Region(object):
...@@ -18,7 +18,7 @@ class Region(object): ...@@ -18,7 +18,7 @@ class Region(object):
class Atlas(Region): class Atlas(Region):
def __init__(self, x, y, width, height, name): def __init__(self, x, y, width, height, name: str) -> None:
super().__init__(x, y, width, height) super().__init__(x, y, width, height)
self.regions = [Region(x, y, width, height)] self.regions = [Region(x, y, width, height)]
self._textures = [] # Type atlas.Texture self._textures = [] # Type atlas.Texture
...@@ -48,7 +48,7 @@ class Atlas(Region): ...@@ -48,7 +48,7 @@ class Atlas(Region):
logging.debug("%s : %s: Skipping an empty texture" % (self.name, the_texture.filename)) logging.debug("%s : %s: Skipping an empty texture" % (self.name, the_texture.filename))
atlas.save(filename, optimize=True) atlas.save(filename, optimize=True)
def pack(self, the_texture): def pack(self, the_texture) -> bool:
logging.debug("packing %s (%i %i)" % logging.debug("packing %s (%i %i)" %
(the_texture.filename, the_texture.width_px, the_texture.height_px)) (the_texture.filename, the_texture.width_px, the_texture.height_px))
for the_region in self.regions: for the_region in self.regions:
......
...@@ -69,6 +69,7 @@ class Texture(object): ...@@ -69,6 +69,7 @@ class Texture(object):
self.ay = 0 self.ay = 0
self.validation_message = None self.validation_message = None
self.registered_in = None # filename of the .py file, where this texture has been referenced self.registered_in = None # filename of the .py file, where this texture has been referenced
self.cls = '' # The class of the texture depends on the manager: 'roof' or 'facade'
try: try:
self.im = Image.open(self.filename) self.im = Image.open(self.filename)
...@@ -185,7 +186,7 @@ Please set either h_can_repeat or v_can_repeat to False.' % self.filename ...@@ -185,7 +186,7 @@ Please set either h_can_repeat or v_can_repeat to False.' % self.filename
class RoofManager(object): class RoofManager(object):
def __init__(self, cls, stats: Stats): def __init__(self, cls: str, stats: Stats):
self.__l = [] self.__l = []
self.__cls = cls # -- class (roof, facade, ...) self.__cls = cls # -- class (roof, facade, ...)
self.stats = stats self.stats = stats
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment