Function push_open_ring_indices

Source
pub fn push_open_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, leaving the ring open.

This is similar to push_ring_indices, but doesn’t close the ring. The connection between the last point and the first point is not made, leaving a gap. This is useful for creating open cylinders or partial tubes.

§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

§Panics

Panics if nsubdiv is 0.

§Example

use parry3d::transformation::utils::{push_circle, push_open_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
push_circle(2.0, nsubdiv, dtheta, 0.0, &mut vertices);
push_circle(2.0, nsubdiv, dtheta, 5.0, &mut vertices);

// Connect them without closing the ring
push_open_ring_indices(0, nsubdiv, nsubdiv, &mut indices);

// Open ring has 2 fewer triangles than closed ring
assert_eq!(indices.len(), 2 * (nsubdiv - 1) as usize);