def generate_planes(n): dyn_array = util.DynamicArray(Plane.struct()) planes = [] for x in range(n): plane = Plane.generate_plane() dyn_array.add_instance(plane.struct_params()) planes.append(plane) return planes, dyn_array
return ray def v4(v3): return (v3.x, v3.y, v3.z, 0.0) if __name__ == "__main__": asm = util.get_asm() mc = asm.assemble(ASM) #mc.print_machine_code() runtime = Runtime() Plane.intersectbool_asm(runtime, "_plane_intersect") ds = runtime.load("test", mc) for x in range(100000): #pl = generate_plane() pl = Plane.generate_plane() ray = generate_ray() ds["r1.origin"] = v4(ray.origin) ds["r1.dir"] = v4(ray.dir) ds["p1.point"] = v4(pl.point) ds["p1.normal"] = v4(pl.normal) ds["p1.mat_index"] = pl.material h = pl.intersect(ray) runtime.run("test") if h is False and ds["hit"] == 1: print (h, ds["hit"]) if h is not False and ds["hit"] == 0: print (h, ds["hit"])
return ray def v4(v3): return (v3.x, v3.y, v3.z, 0.0) if __name__ == "__main__": asm = util.get_asm() mc = asm.assemble(ASM) #mc.print_machine_code() runtime = Runtime() Plane.intersect_asm(runtime, "_plane_intersect") ds = runtime.load("test", mc) for x in range(100000): #pl = generate_plane() pl = Plane.generate_plane() ray = generate_ray() ds["r1.origin"] = v4(ray.origin) ds["r1.dir"] = v4(ray.dir) ds["p1.point"] = v4(pl.point) ds["p1.normal"] = v4(pl.normal) h = pl.intersect(ray) runtime.run("test") if h is False and ds["hit"] == 1: print (h, ds["hit"]) if h is not False and ds["hit"] == 0: print(h.t, " ", h.material ," ", ds["hp.t"], ds["hp.mat_index"])