Function push_ring_indices

Source
pub fn push_ring_indices(
    base_lower_circle: u32,
    base_upper_circle: u32,
    nsubdiv: u32,
    out: &mut Vec<[u32; 3]>,
)
Expand description

Creates the triangle faces connecting two circles with the same discretization.

This function generates triangle indices to form a closed ring (tube segment) between two parallel circles. The circles must have the same number of points. The ring wraps around completely, connecting the last points back to the first.

§Arguments

  • base_lower_circle - Index of the first point of the lower circle
  • base_upper_circle - Index of the first point of the upper circle
  • nsubdiv - Number of points in each circle
  • out - Output buffer where triangle indices will be pushed

§Example

use parry3d::transformation::utils::{push_circle, push_ring_indices};
use parry3d::math::Point;
use std::f32::consts::PI;

let mut vertices = Vec::new();
let mut indices = Vec::new();

let nsubdiv = 8;
let dtheta = 2.0 * PI / nsubdiv as f32;

// Create two circles at different heights
push_circle(2.0, nsubdiv, dtheta, 0.0, &mut vertices);  // Lower circle
push_circle(2.0, nsubdiv, dtheta, 5.0, &mut vertices);  // Upper circle

// Connect them with triangles
push_ring_indices(0, nsubdiv, nsubdiv, &mut indices);

// A ring with n subdivisions creates 2*n triangles
assert_eq!(indices.len(), 2 * nsubdiv as usize);