def nearest_point(self, pos=(0,0,0), # query position, in panda3d coordinates radius=5): # query radius """ Find the nearest point on a navigable polygon in the navmesh. Returns a tuple of (polyref,point). """ radius = pyrecast.dtPoint3(radius,radius,radius) tmp_polyref = pyrecast.new_uintp(1) tmp_point = pyrecast.dtPoint3(0,0,0) self.query.findNearestPoly(panda2detour(pos),radius,self.filter,tmp_polyref,tmp_point) #.disown() return [tmp_polyref,tmp_point]
def nearest_point( self, pos=(0, 0, 0), # query position, in panda3d coordinates radius=5): # query radius """ Find the nearest point on a navigable polygon in the navmesh. Returns a tuple of (polyref,point). """ radius = pyrecast.dtPoint3(radius, radius, radius) tmp_polyref = pyrecast.new_uintp(1) tmp_point = pyrecast.dtPoint3(0, 0, 0) self.query.findNearestPoly(panda2detour(pos), radius, self.filter, tmp_polyref, tmp_point) #.disown() return [tmp_polyref, tmp_point]
def is_reachable(self, a, # in panda3d coordinates b, # in panda3d coordinates tolerance=0.5, max_path=1000 ): """ Check if two points are reachable from each other. """ a = self.nearest_point(a,radius=tolerance) b = self.nearest_point(b,radius=tolerance) tmp_path = pyrecast.new_uintp(max_path) tmp_pathcount = pyrecast.new_intp(1) status = self.query.findPath(pyrecast.uintp_getitem(a[0],0),pyrecast.uintp_getitem(b[0],0),a[1],b[1],self.filter, tmp_path, tmp_pathcount, int(max_path)) #result = not ((pyrecast.uintp_getitem(status,0) & (1<<30)) == 0) result = pyrecast.dtStatusSucceed(status) #status.disown() return result
def is_reachable( self, a, # in panda3d coordinates b, # in panda3d coordinates tolerance=0.5, max_path=1000): """ Check if two points are reachable from each other. """ a = self.nearest_point(a, radius=tolerance) b = self.nearest_point(b, radius=tolerance) tmp_path = pyrecast.new_uintp(max_path) tmp_pathcount = pyrecast.new_intp(1) status = self.query.findPath(pyrecast.uintp_getitem(a[0], 0), pyrecast.uintp_getitem(b[0], 0), a[1], b[1], self.filter, tmp_path, tmp_pathcount, int(max_path)) #result = not ((pyrecast.uintp_getitem(status,0) & (1<<30)) == 0) result = pyrecast.dtStatusSucceed(status) #status.disown() return result