def isect(bbox, shader, linear): #origin = Vector3(0.0, 0.0, 0.0) origin = random_in_bbox(bbox) direction = random_in_bbox(bbox) direction.normalize() ray = Ray(origin, direction) hit = HitPoint() props = {'hit': hit, 'ret': 5, 'ray': ray} shader.props = props shader.update() shader.execute() h = linear.isect(ray) compare(h, shader, ray) if h is False: return 0 return 1
def visible(bbox, shader, linear): p1 = random_in_bbox(bbox) p2 = random_in_bbox(bbox) props = {'p1': p1, 'ret': 5, 'p2': p2} shader.props = props shader.update() shader.execute() h = linear.visibility(p1, p2) ret = shader.shader.get_value('ret') if h is True and ret != 1: print (p1) print (p2) raise ValueError("Something is wrong") if h is False and ret != 0: print (p1) print (p2) raise ValueError("Something is wrong")
def generate_ray(bbox): dir = random_in_bbox(bbox) dir.normalize() origin = Vector3(0.0, 0.0, 0.0) return Ray(origin, dir)