Avoid division by zero in the fix surface compatibility routine

This commit is contained in:
Yuri Sizov 2023-11-20 16:22:58 +01:00
parent 80de898d72
commit 98011e032d
1 changed files with 37 additions and 35 deletions

View File

@ -2148,6 +2148,7 @@ void RenderingServer::fix_surface_compatibility(SurfaceData &p_surface, const St
// The only difference for now is that Version 1 uses interleaved vertex positions while version 2 does not.
// I.e. PNTPNTPNT -> PPPNTNTNT.
if (p_surface.vertex_data.size() > 0 && p_surface.vertex_count > 0) {
int vertex_size = 0;
int normal_size = 0;
int tangent_size = 0;
@ -2189,6 +2190,7 @@ void RenderingServer::fix_surface_compatibility(SurfaceData &p_surface, const St
p_surface.blend_shape_data = new_blend_shape_data;
}
}
}
p_surface.format &= ~(ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);
p_surface.format |= ARRAY_FLAG_FORMAT_CURRENT_VERSION & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);
}