Path: blob/master/scene/resources/3d/navigation_mesh_source_geometry_data_3d.h
9898 views
/**************************************************************************/1/* navigation_mesh_source_geometry_data_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 "core/os/rw_lock.h"33#include "scene/resources/mesh.h"3435class NavigationMeshSourceGeometryData3D : public Resource {36GDCLASS(NavigationMeshSourceGeometryData3D, Resource);37RWLock geometry_rwlock;3839Vector<float> vertices;40Vector<int> indices;4142AABB bounds;43bool bounds_dirty = true;4445public:46struct ProjectedObstruction;4748private:49Vector<ProjectedObstruction> _projected_obstructions;5051protected:52bool _set(const StringName &p_name, const Variant &p_value);53bool _get(const StringName &p_name, Variant &r_ret) const;54static void _bind_methods();5556private:57void _add_vertex(const Vector3 &p_vec3);58void _add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform);59void _add_mesh_array(const Array &p_array, const Transform3D &p_xform);60void _add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform);6162public:63struct ProjectedObstruction {64static inline uint32_t VERSION = 1; // Increase when format changes so we can detect outdated formats and provide compatibility.6566Vector<float> vertices;67float elevation = 0.0;68float height = 0.0;69bool carve = false;70};7172// kept root node transform here on the geometry data73// if we add this transform to all exposed functions we need to break comp on all functions later74// when navmesh changes from global transform to relative to navregion75// but if it stays here we can just remove it and change the internal functions only76Transform3D root_node_transform;7778void set_vertices(const Vector<float> &p_vertices);79const Vector<float> &get_vertices() const;8081void set_indices(const Vector<int> &p_indices);82const Vector<int> &get_indices() const;8384void append_arrays(const Vector<float> &p_vertices, const Vector<int> &p_indices);8586bool has_data();87void clear();88void clear_projected_obstructions();8990void add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform);91void add_mesh_array(const Array &p_mesh_array, const Transform3D &p_xform);92void add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform);9394void merge(const Ref<NavigationMeshSourceGeometryData3D> &p_other_geometry);9596void add_projected_obstruction(const Vector<Vector3> &p_vertices, float p_elevation, float p_height, bool p_carve);97Vector<ProjectedObstruction> _get_projected_obstructions() const;9899void set_projected_obstructions(const Array &p_array);100Array get_projected_obstructions() const;101102void set_data(const Vector<float> &p_vertices, const Vector<int> &p_indices, Vector<ProjectedObstruction> &p_projected_obstructions);103void get_data(Vector<float> &r_vertices, Vector<int> &r_indices, Vector<ProjectedObstruction> &r_projected_obstructions);104105AABB get_bounds();106107~NavigationMeshSourceGeometryData3D() { clear(); }108};109110111