| 718 | } |
| 719 | |
| 720 | Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing, uint64_t p_compress_flags) { |
| 721 | Ref<ArrayMesh> mesh; |
| 722 | if (p_existing.is_valid()) { |
| 723 | mesh = p_existing; |
| 724 | } else { |
| 725 | mesh.instantiate(); |
| 726 | } |
| 727 | |
| 728 | int varr_len = vertex_array.size(); |
| 729 | |
| 730 | if (varr_len == 0) { |
| 731 | return mesh; |
| 732 | } |
| 733 | |
| 734 | int surface = mesh->get_surface_count(); |
| 735 | |
| 736 | Array a = commit_to_arrays(); |
| 737 | |
| 738 | uint64_t compress_flags = (p_compress_flags >> RS::ARRAY_COMPRESS_FLAGS_BASE) << RS::ARRAY_COMPRESS_FLAGS_BASE; |
| 739 | static const uint64_t shift[RS::ARRAY_CUSTOM_COUNT] = { Mesh::ARRAY_FORMAT_CUSTOM0_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM1_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM2_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM3_SHIFT }; |
| 740 | for (int i = 0; i < RS::ARRAY_CUSTOM_COUNT; i++) { |
| 741 | if (last_custom_format[i] != CUSTOM_MAX) { |
| 742 | compress_flags |= uint64_t(last_custom_format[i]) << shift[i]; |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | mesh->add_surface_from_arrays(primitive, a, Array(), Dictionary(), compress_flags); |
| 747 | |
| 748 | if (material.is_valid()) { |
| 749 | mesh->surface_set_material(surface, material); |
| 750 | } |
| 751 | |
| 752 | return mesh; |
| 753 | } |
| 754 | |
| 755 | void SurfaceTool::index() { |
| 756 | if (index_array.size()) { |
no test coverage detected