hit_point = None for s in objs: hit = s.intersect(ray, min_dist) if hit is False: continue if hit.t < min_dist: min_dist = hit.t hit_point = hit return hit_point if __name__ == "__main__": asm = util.get_asm() mc = asm.assemble(ASM) #mc.print_machine_code() runtime = Runtime() Plane.intersect_asm(runtime, "_plane_intersect") intersect_ray_shape_array("plane", runtime, "plane_array", "_plane_intersect") ds = runtime.load("test", mc) planes, dyn_planes = generate_planes(10000) ray = generate_ray() hp = ray_objects(ray, planes) adr = dyn_planes.get_addr() ds["ptr_planes"] = adr ds["nplanes"] = dyn_planes.size ds["r1.origin"] = v4(ray.origin) ds["r1.dir"] = v4(ray.dir)
hp = isect(ray, shape_db.shapes()) hp2 = isect_ray_scene(ray) asm = util.get_asm() dy_spheres = shape_db.asm_shapes[Sphere] dy_planes = shape_db.asm_shapes[Plane] #ds["r1.origin"] = v4(ray.origin) #ds["r1.dir"] = v4(ray.dir) runtime = Runtime() Sphere.intersect_asm(runtime, "_sphere_intersect") intersect_ray_shape_array("sphere", runtime, "sphere_array", "_sphere_intersect") Plane.intersect_asm(runtime, "_plane_intersect") intersect_ray_shape_array("plane", runtime, "plane_array", "_plane_intersect") mc = asm.assemble(ASM) ds = runtime.load("test", mc) ds["r1.origin"] = v4(ray.origin) ds["r1.dir"] = v4(ray.dir) ds["ptr_spheres"] = dy_spheres.get_addr() ds["nspheres"] = dy_spheres.size ds["ptr_planes"] = dy_planes.get_addr() ds["nplanes"] = dy_planes.size #runtime.run("test") t = timeit.Timer(lambda : runtime.run("test"))