Removed cheap texture hacks.

This commit is contained in:
Quantum 2018-08-22 22:35:36 -04:00
parent 50b8d39b71
commit 1b973b0082
2 changed files with 24 additions and 57 deletions

View file

@ -1,6 +1,5 @@
from math import sqrt
from six.moves import range
from pyglet.gl import *
from punyverse.orbit import KeplerOrbit

View file

@ -1,7 +1,7 @@
from __future__ import print_function
from collections import OrderedDict
import os
from collections import OrderedDict
try:
import json
@ -28,37 +28,16 @@ from math import pi, sqrt
G = 6.67384e-11 # Gravitation Constant
def get_best_texture(info, optional=False, loader=load_texture):
cheap = False
skip = False
texture = None
def get_best_texture(info, loader=load_texture):
if isinstance(info, list):
for item in info:
if isinstance(item, list):
if len(item) == 4:
cheap = True
texture = item
break
continue
try:
texture = loader(item)
return loader(item)
except ValueError:
pass
else:
break
else:
cheap = True
texture = [1, 1, 1, 1]
else:
try:
texture = loader(info)
except ValueError:
if optional:
skip = True
else:
cheap = True
texture = [1, 1, 1, 1]
return cheap, skip, texture
return loader(info)
raise ValueError('No texture found')
def load_world(file, callback=lambda message, completion: None):
@ -176,12 +155,7 @@ class World(object):
division = info.get('division', max(min(int(radius / 8), 60), 10))
if 'texture' in info:
cheap, skip, texture = get_best_texture(info['texture'], optional=info.get('optional', False))
if skip:
return
if cheap:
object_id = compile(colourball, radius, division, division, texture)
else:
texture = get_best_texture(info['texture'])
if self.options.get('normal', False) and 'normal' in info:
object_id = compile(normal_sphere, radius, division, texture,
info['normal'], lighting=lighting, inside=background)
@ -229,22 +203,18 @@ class World(object):
cloud_texture = atmosphere_data.get('cloud_texture', None)
corona_texture = atmosphere_data.get('corona_texture', None)
if cloud_texture is not None:
cheap, _, cloud_texture = get_best_texture(cloud_texture, loader=load_clouds)
if not cheap:
cloudmap_id = compile(sphere, radius + 2, division, division, cloud_texture,
lighting=False)
cloud_texture = get_best_texture(cloud_texture, loader=load_clouds)
cloudmap_id = compile(sphere, radius + 2, division, division, cloud_texture, lighting=False)
if corona_texture is not None:
cheap, _, corona = get_best_texture(corona_texture)
if not cheap:
corona = get_best_texture(corona_texture)
corona_size = atmosphere_data.get('corona_size', radius / 2)
corona_division = atmosphere_data.get('corona_division', 100)
corona_ratio = atmosphere_data.get('corona_ratio', 0.5)
corona_id = compile(flare, radius, radius + corona_size, corona_division,
corona_ratio, corona)
corona_id = compile(flare, radius, radius + corona_size, corona_division, corona_ratio, corona)
if atm_texture is not None:
cheap, _, atm_texture = get_best_texture(atm_texture)
if not cheap:
atm_texture = get_best_texture(atm_texture)
atmosphere_id = compile(disk, radius, radius + atm_size, 30, atm_texture)
theta = 360.0 / rotation if rotation else 0
@ -262,10 +232,8 @@ class World(object):
yaw = self._eval(ring_data.get('yaw', yaw))
roll = self._eval(ring_data.get('roll', roll))
cheap, _, texture = get_best_texture(texture)
if not cheap:
self.tracker.append(
type(compile(disk, distance, distance + size, 30, texture), (x, y, z),
texture = get_best_texture(texture)
self.tracker.append(type(compile(disk, distance, distance + size, 30, texture), (x, y, z),
(pitch, yaw, roll), **params))
for satellite, info in six.iteritems(info.get('satellites', {})):