direction.normalize() ray = Ray(origin, direction) return ray if __name__ == "__main__": sph1 = mdl.create_random_sphere() #sph2 = mdl.create_random_sphere() #sph3 = mdl.create_random_sphere() for x in range(10000): sph3 = mdl.create_random_sphere() grid = Grid() t = timeit.Timer(lambda :grid.setup()) print ("time", t.timeit(1)) grid.setup() for n in range(100): ray = generate_ray() hp2 = isect_ray_scene(ray) hp = grid.intersect(ray) #print ("prvi grid", hp, hp2) if hp2 is not None: if hp is not None: if abs(hp.t - hp2.t) > 0.001:
direction = Vector3(dir_x, dir_y, dir_z) direction.normalize() ray = Ray(origin, direction) return ray if __name__ == "__main__": sph1 = mdl.create_random_sphere() #sph2 = mdl.create_random_sphere() #sph3 = mdl.create_random_sphere() for x in range(10000): sph3 = mdl.create_random_sphere() grid = Grid() t = timeit.Timer(lambda: grid.setup()) print("time", t.timeit(1)) grid.setup() for n in range(100): ray = generate_ray() hp2 = isect_ray_scene(ray) hp = grid.intersect(ray) #print ("prvi grid", hp, hp2) if hp2 is not None: if hp is not None: if abs(hp.t - hp2.t) > 0.001: print(hp.t, hp2.t)
sphere = mdl.create_shape(sh_props) sh_props = {"type":"sphere", "position":(0,1,0), "radius":3, "material":"m1"} sphere2 = mdl.create_shape(sh_props) for x in range(1000): sh_props = {"type":"sphere", "position":(random.random(),random.random(),random.random()), "radius":random.random()*0.25, "material":"m1"} sphere3 = mdl.create_shape(sh_props) ray = generate_ray() #sphere = random_sphere() hp = sphere.isect(ray) hp = renmas.shapes.isect(ray, mdl.lst_shapes()) #print(hp.t) grid = Grid() grid.setup(mdl.lst_shapes()) hp3 = grid.isect(ray) #print(hp3.t) runtime = Runtime() grid.isect_asm(runtime, "grid_intersect") asm_structs = util.structs("ray", "grid", "hitpoint") ASM = """ #DATA """ ASM += asm_structs + """ ray ray1
sh_props = { "type": "sphere", "position": (random.random(), random.random(), random.random()), "radius": random.random() * 0.25, "material": "m1" } sphere3 = mdl.create_shape(sh_props) ray = generate_ray() #sphere = random_sphere() hp = sphere.isect(ray) hp = renmas.shapes.isect(ray, mdl.lst_shapes()) #print(hp.t) grid = Grid() grid.setup(mdl.lst_shapes()) hp3 = grid.isect(ray) #print(hp3.t) runtime = Runtime() grid.isect_asm(runtime, "grid_intersect") asm_structs = util.structs("ray", "grid", "hitpoint") ASM = """ #DATA """ ASM += asm_structs + """ ray ray1