/**************************************************************************/ /* voxelizer.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "voxelizer.h" #include "core/config/project_settings.h" static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3 *p_vtx, const Vector2 *p_uv, const Vector3 *p_normal, Vector2 &r_uv, Vector3 &r_normal) { … } void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector3 *p_normal, const Vector2 *p_uv, const MaterialCache &p_material, const AABB &p_aabb) { … } Vector<Color> Voxelizer::_get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add) { … } Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material) { … } void Voxelizer::plot_mesh(const Transform3D &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material>> &p_materials, const Ref<Material> &p_override_material) { … } void Voxelizer::_sort() { … } void Voxelizer::_fixup_plot(int p_idx, int p_level) { … } void Voxelizer::begin_bake(int p_subdiv, const AABB &p_bounds, float p_exposure_normalization) { … } void Voxelizer::end_bake() { … } //create the data for rendering server int Voxelizer::get_voxel_gi_octree_depth() const { … } Vector3i Voxelizer::get_voxel_gi_octree_size() const { … } int Voxelizer::get_voxel_gi_cell_count() const { … } Vector<uint8_t> Voxelizer::get_voxel_gi_octree_cells() const { … } Vector<uint8_t> Voxelizer::get_voxel_gi_data_cells() const { … } Vector<int> Voxelizer::get_voxel_gi_level_cell_count() const { … } // euclidean distance computation based on: // https://prideout.net/blog/distance_fields/ #define square … #define INF … /* dt of 1d function using squared distance */ static void edt(float *f, int stride, int n) { … } #undef square Vector<uint8_t> Voxelizer::get_sdf_3d_image() const { … } #undef INF void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx) { … } Ref<MultiMesh> Voxelizer::create_debug_multimesh() { … } Transform3D Voxelizer::get_to_cell_space_xform() const { … } Voxelizer::Voxelizer() { … }