Path: blob/master/modules/navigation_2d/2d/nav_region_iteration_2d.h
10278 views
/**************************************************************************/1/* nav_region_iteration_2d.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "../nav_utils_2d.h"33#include "nav_base_iteration_2d.h"34#include "scene/resources/2d/navigation_polygon.h"3536#include "core/math/rect2.h"3738class NavRegion2D;39class NavRegionIteration2D;4041struct NavRegionIterationBuild2D {42Nav2D::PerformanceData performance_data;4344NavRegion2D *region = nullptr;4546Vector2 map_cell_size;47Transform2D region_transform;4849struct NavMeshData {50Vector<Vector2> vertices;51Vector<Vector<int>> polygons;5253void clear() {54vertices.clear();55polygons.clear();56}57} navmesh_data;5859Ref<NavRegionIteration2D> region_iteration;6061HashMap<Nav2D::EdgeKey, Nav2D::EdgeConnectionPair, Nav2D::EdgeKey> iter_connection_pairs_map;6263void reset() {64performance_data.reset();6566navmesh_data.clear();67region_iteration = Ref<NavRegionIteration2D>();68iter_connection_pairs_map.clear();69}70};7172class NavRegionIteration2D : public NavBaseIteration2D {73GDCLASS(NavRegionIteration2D, NavBaseIteration2D);7475public:76Transform2D transform;77real_t surface_area = 0.0;78Rect2 bounds;79LocalVector<Nav2D::ConnectableEdge> external_edges;8081const Transform2D &get_transform() const { return transform; }82real_t get_surface_area() const { return surface_area; }83Rect2 get_bounds() const { return bounds; }84const LocalVector<Nav2D::ConnectableEdge> &get_external_edges() const { return external_edges; }8586virtual ~NavRegionIteration2D() override {87external_edges.clear();88navmesh_polygons.clear();89internal_connections.clear();90}91};929394