filter faces to make better/simpler meshes

This commit is contained in:
Laura Klünder 2017-11-14 01:29:17 +01:00
parent 1e8305a281
commit dd8d160a10
2 changed files with 16 additions and 3 deletions

View file

@ -74,6 +74,12 @@ class HybridGeometry:
add_faces={crop_id: tuple((faces*scale+offset) for faces in self.faces)
for crop_id, faces in self.add_faces})
def filter(self, **kwargs):
return HybridGeometry(geom=self.geom, crop_ids=self.crop_ids,
faces=tuple(mesh.filter(**kwargs) for mesh in self.faces),
add_faces={crop_id: tuple(mesh.filter(**kwargs) for mesh in faces)
for crop_id, faces in self.add_faces.items()})
@property
def is_empty(self):
return not self.faces and not any(self.add_faces.values())
@ -333,6 +339,11 @@ class Mesh:
def __add__(self, other):
return Mesh(self.top+other, self.sides+other, self.bottom+other)
def filter(self, top=True, sides=True, bottom=True):
return Mesh(top=self.top if top else None,
sides=self.sides if sides else None,
bottom=self.bottom if bottom else None)
class LevelGeometries:
def __init__(self):

View file

@ -108,14 +108,16 @@ class MapRenderer:
bottom = float(altitudearea.altitude) - 0.7
scale = (bottom - min_altitude) / 0.7
offset = min_altitude - bottom * scale
engine.add_geometry(altitudearea.geometry.fit(scale=scale, offset=offset),
engine.add_geometry(altitudearea.geometry.fit(scale=scale, offset=offset).filter(top=False),
fill=FillAttribs('#aaaaaa'))
# render altitude areas in default ground color and add ground colors to each one afterwards
# shadows are directly calculated and added by the engine
for altitudearea in geoms.altitudeareas:
engine.add_geometry(altitudearea.geometry.difference(crop_areas),
altitude=altitudearea.altitude, fill=FillAttribs('#eeeeee'))
geometry = altitudearea.geometry.difference(crop_areas)
if not self.full_levels and engine.is_3d:
geometry = geometry.filter(bottom=False)
engine.add_geometry(geometry, altitude=altitudearea.altitude, fill=FillAttribs('#eeeeee'))
for color, areas in altitudearea.colors.items():
# only select ground colors if their access restriction is unlocked