Merge pull request #83211 from clayjohn/cleanup-mesh-stuff

Cleanup instances of using uint32_t for mesh formats
This commit is contained in:
Rémi Verschelde 2023-10-13 11:46:20 +02:00
commit cbb95bc8ab
No known key found for this signature in database
GPG key ID: C3336907360768E1
6 changed files with 16 additions and 18 deletions

View file

@ -486,7 +486,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, co
mesh.instantiate();
mesh->set_name(m->get_name());
for (int i = 0; i < m->get_surface_count(); i++) {
mesh->add_surface(m->surface_get_primitive_type(i), m->surface_get_arrays(i), Array(), Dictionary(), m->surface_get_material(i));
mesh->add_surface(m->surface_get_primitive_type(i), m->surface_get_arrays(i), Array(), Dictionary(), m->surface_get_material(i), String(), m->surface_get_format(i));
}
ImporterMeshInstance3D *mi = memnew(ImporterMeshInstance3D);

View file

@ -391,7 +391,7 @@ void _rescale_importer_mesh(Vector3 p_scale, Ref<ImporterMesh> p_mesh, bool is_s
Dictionary lods;
String name;
Ref<Material> mat;
int fmt_compress_flags = 0;
uint64_t fmt_compress_flags = 0;
};
Vector<LocalSurfData> surf_data_by_mesh;
@ -403,7 +403,7 @@ void _rescale_importer_mesh(Vector3 p_scale, Ref<ImporterMesh> p_mesh, bool is_s
for (int surf_idx = 0; surf_idx < surf_count; surf_idx++) {
Mesh::PrimitiveType prim = p_mesh->get_surface_primitive_type(surf_idx);
const int fmt_compress_flags = p_mesh->get_surface_format(surf_idx);
const uint64_t fmt_compress_flags = p_mesh->get_surface_format(surf_idx);
Array arr = p_mesh->get_surface_arrays(surf_idx);
String name = p_mesh->get_surface_name(surf_idx);
Dictionary lods;
@ -450,7 +450,7 @@ void _rescale_importer_mesh(Vector3 p_scale, Ref<ImporterMesh> p_mesh, bool is_s
const Array arr = surf_data_by_mesh[surf_idx].arr;
const Array bsarr = surf_data_by_mesh[surf_idx].bsarr;
const Dictionary lods = surf_data_by_mesh[surf_idx].lods;
const int fmt_compress_flags = surf_data_by_mesh[surf_idx].fmt_compress_flags;
const uint64_t fmt_compress_flags = surf_data_by_mesh[surf_idx].fmt_compress_flags;
const String name = surf_data_by_mesh[surf_idx].name;
const Ref<Material> mat = surf_data_by_mesh[surf_idx].mat;

View file

@ -351,8 +351,6 @@ private:
}
};
size_t sss = sizeof(MaterialKey);
struct ShaderData {
RID shader;
int users = 0;

View file

@ -181,7 +181,7 @@ TypedArray<Array> PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) c
BitField<Mesh::ArrayFormat> PrimitiveMesh::surface_get_format(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, 1, 0);
uint32_t mesh_format = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL | RS::ARRAY_FORMAT_TANGENT | RS::ARRAY_FORMAT_TEX_UV | RS::ARRAY_FORMAT_INDEX;
uint64_t mesh_format = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL | RS::ARRAY_FORMAT_TANGENT | RS::ARRAY_FORMAT_TEX_UV | RS::ARRAY_FORMAT_INDEX;
if (add_uv2) {
mesh_format |= RS::ARRAY_FORMAT_TEX_UV2;
}

View file

@ -729,11 +729,11 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing, uint64_t p_
Array a = commit_to_arrays();
uint32_t compress_flags = (p_compress_flags >> RS::ARRAY_COMPRESS_FLAGS_BASE) << RS::ARRAY_COMPRESS_FLAGS_BASE;
static const uint32_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 };
uint64_t compress_flags = (p_compress_flags >> RS::ARRAY_COMPRESS_FLAGS_BASE) << RS::ARRAY_COMPRESS_FLAGS_BASE;
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 };
for (int i = 0; i < RS::ARRAY_CUSTOM_COUNT; i++) {
if (last_custom_format[i] != CUSTOM_MAX) {
compress_flags |= last_custom_format[i] << shift[i];
compress_flags |= uint64_t(last_custom_format[i]) << shift[i];
}
}
@ -819,7 +819,7 @@ void SurfaceTool::create_vertex_array_from_triangle_arrays(const Array &p_arrays
return;
}
int lformat = 0;
uint64_t lformat = 0;
if (varr.size()) {
lformat |= RS::ARRAY_FORMAT_VERTEX;
}

View file

@ -907,7 +907,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint
uint32_t RenderingServer::mesh_surface_get_format_offset(BitField<ArrayFormat> p_format, int p_vertex_len, int p_array_index) const {
ERR_FAIL_INDEX_V(p_array_index, ARRAY_MAX, 0);
p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
uint32_t offsets[ARRAY_MAX];
uint32_t vstr;
uint32_t ntstr;
@ -918,7 +918,7 @@ uint32_t RenderingServer::mesh_surface_get_format_offset(BitField<ArrayFormat> p
}
uint32_t RenderingServer::mesh_surface_get_format_vertex_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
uint32_t offsets[ARRAY_MAX];
uint32_t vstr;
uint32_t ntstr;
@ -929,18 +929,18 @@ uint32_t RenderingServer::mesh_surface_get_format_vertex_stride(BitField<ArrayFo
}
uint32_t RenderingServer::mesh_surface_get_format_normal_tangent_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
uint32_t offsets[ARRAY_MAX];
uint32_t vstr;
uint32_t ntstr;
uint32_t astr;
uint32_t sstr;
mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);
return vstr;
return ntstr;
}
uint32_t RenderingServer::mesh_surface_get_format_attribute_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
uint32_t offsets[ARRAY_MAX];
uint32_t vstr;
uint32_t ntstr;
@ -950,7 +950,7 @@ uint32_t RenderingServer::mesh_surface_get_format_attribute_stride(BitField<Arra
return astr;
}
uint32_t RenderingServer::mesh_surface_get_format_skin_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
uint32_t offsets[ARRAY_MAX];
uint32_t vstr;
uint32_t ntstr;
@ -1662,7 +1662,7 @@ TypedArray<Array> RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mes
uint32_t normal_elem_size;
uint32_t attrib_elem_size;
uint32_t skin_elem_size;
//CLAY
mesh_surface_make_offsets_from_format(bs_format, sd.vertex_count, 0, bs_offsets, vertex_elem_size, normal_elem_size, attrib_elem_size, skin_elem_size);
int divisor = (vertex_elem_size + normal_elem_size) * sd.vertex_count;