aboutsummaryrefslogtreecommitdiff
path: root/adapters/fparkan-render-vulkan/src/asset_mesh.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-07-18 14:19:07 +0300
committerValentin Popov <valentin@popov.link>2026-07-18 14:19:07 +0300
commit438aaebcbc5c963d378d297bfb13e2af24b12084 (patch)
tree06e53f63862eaf21c64220491cde1606e8a4d9b1 /adapters/fparkan-render-vulkan/src/asset_mesh.rs
parent733bfcf6fa2e17dbc94487fb1b9eb4f896e53845 (diff)
downloadfparkan-438aaebcbc5c963d378d297bfb13e2af24b12084.tar.xz
fparkan-438aaebcbc5c963d378d297bfb13e2af24b12084.zip
feat(render): support full-scene 32-bit indices
Diffstat (limited to 'adapters/fparkan-render-vulkan/src/asset_mesh.rs')
-rw-r--r--adapters/fparkan-render-vulkan/src/asset_mesh.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/adapters/fparkan-render-vulkan/src/asset_mesh.rs b/adapters/fparkan-render-vulkan/src/asset_mesh.rs
index 7a2f8ba..d74e79c 100644
--- a/adapters/fparkan-render-vulkan/src/asset_mesh.rs
+++ b/adapters/fparkan-render-vulkan/src/asset_mesh.rs
@@ -251,7 +251,7 @@ pub fn project_land_msh_to_static_mesh(
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?,
);
for face in &terrain.faces {
- indices.extend(face.vertices);
+ indices.extend(face.vertices.map(u32::from));
}
if indices.is_empty() {
return Err(VulkanAssetMeshError::EmptyGeometry);
@@ -280,7 +280,7 @@ pub fn project_land_msh_to_static_mesh_in_xy_frame(
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?,
);
for face in &terrain.faces {
- indices.extend(face.vertices);
+ indices.extend(face.vertices.map(u32::from));
}
if indices.is_empty() {
return Err(VulkanAssetMeshError::EmptyGeometry);
@@ -357,7 +357,7 @@ pub fn project_land_msh_to_static_mesh_in_world_space(
})
}
-fn static_terrain_indices(terrain: &LandMeshDocument) -> Result<Vec<u16>, VulkanAssetMeshError> {
+fn static_terrain_indices(terrain: &LandMeshDocument) -> Result<Vec<u32>, VulkanAssetMeshError> {
let mut indices = Vec::with_capacity(
terrain
.faces
@@ -366,7 +366,7 @@ fn static_terrain_indices(terrain: &LandMeshDocument) -> Result<Vec<u16>, Vulkan
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?,
);
for face in &terrain.faces {
- indices.extend(face.vertices);
+ indices.extend(face.vertices.map(u32::from));
}
if indices.is_empty() {
return Err(VulkanAssetMeshError::EmptyGeometry);
@@ -391,7 +391,7 @@ fn static_terrain_draw_ranges(
fn static_model_indices_and_ranges(
model: &ModelAsset,
-) -> Result<(Vec<u16>, Vec<VulkanStaticDrawRange>), VulkanAssetMeshError> {
+) -> Result<(Vec<u32>, Vec<VulkanStaticDrawRange>), VulkanAssetMeshError> {
let mut indices = Vec::new();
let mut draw_ranges = Vec::with_capacity(model.batches.len());
for batch in &model.batches {
@@ -411,7 +411,7 @@ fn static_model_indices_and_ranges(
.base_vertex
.checked_add(u32::from(raw_index))
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?;
- indices.push(u16::try_from(index).map_err(|_| VulkanAssetMeshError::IndexOutOfRange)?);
+ indices.push(index);
}
draw_ranges.push(VulkanStaticDrawRange {
first_index,
@@ -429,7 +429,7 @@ fn static_model_indices_and_ranges(
fn static_mesh_xy_bounds(
positions: &[[f32; 3]],
- indices: &[u16],
+ indices: &[u32],
) -> Result<(f32, f32, f32, f32), VulkanAssetMeshError> {
let mut min_x = f32::INFINITY;
let mut max_x = f32::NEG_INFINITY;
@@ -437,7 +437,7 @@ fn static_mesh_xy_bounds(
let mut max_y = f32::NEG_INFINITY;
for &index in indices {
let position = positions
- .get(usize::from(index))
+ .get(usize::try_from(index).map_err(|_| VulkanAssetMeshError::IndexOutOfRange)?)
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?;
if !position.iter().all(|value| value.is_finite()) {
return Err(VulkanAssetMeshError::NonFinitePosition);