Path: blob/master/modules/navigation_3d/3d/nav_region_iteration_3d.h
10278 views
/**************************************************************************/1/* nav_region_iteration_3d.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_3d.h"33#include "nav_base_iteration_3d.h"34#include "scene/resources/navigation_mesh.h"3536#include "core/math/aabb.h"3738class NavRegion3D;39class NavRegionIteration3D;4041struct NavRegionIterationBuild3D {42Nav3D::PerformanceData performance_data;4344NavRegion3D *region = nullptr;4546Vector3 map_cell_size;47Transform3D region_transform;4849struct NavMeshData {50Vector<Vector3> vertices;51Vector<Vector<int>> polygons;5253void clear() {54vertices.clear();55polygons.clear();56}57} navmesh_data;5859Ref<NavRegionIteration3D> region_iteration;6061HashMap<Nav3D::EdgeKey, Nav3D::EdgeConnectionPair, Nav3D::EdgeKey> iter_connection_pairs_map;6263void reset() {64performance_data.reset();6566navmesh_data.clear();67region_iteration = Ref<NavRegionIteration3D>();68iter_connection_pairs_map.clear();69}70};7172class NavRegionIteration3D : public NavBaseIteration3D {73GDCLASS(NavRegionIteration3D, NavBaseIteration3D);7475public:76Transform3D transform;77real_t surface_area = 0.0;78AABB bounds;79LocalVector<Nav3D::ConnectableEdge> external_edges;8081const Transform3D &get_transform() const { return transform; }82real_t get_surface_area() const { return surface_area; }83AABB get_bounds() const { return bounds; }84const LocalVector<Nav3D::ConnectableEdge> &get_external_edges() const { return external_edges; }8586virtual ~NavRegionIteration3D() override {87external_edges.clear();88navmesh_polygons.clear();89internal_connections.clear();90}91};929394