MCPcopy Create free account
hub / github.com/PerroEngine/Perro / push_triangle

Function push_triangle

perro_source/core/perro_builtin_meshes/src/lib.rs:426–462  ·  view source on GitHub ↗
(
    vertices: &mut Vec<BuiltinMeshVertex>,
    indices: &mut Vec<u16>,
    a: [f32; 3],
    b: [f32; 3],
    c: [f32; 3],
)

Source from the content-addressed store, hash-verified

424}
425
426fn push_triangle(
427 vertices: &mut Vec<BuiltinMeshVertex>,
428 indices: &mut Vec<u16>,
429 a: [f32; 3],
430 b: [f32; 3],
431 c: [f32; 3],
432) {
433 let av = a;
434 let mut bv = b;
435 let mut cv = c;
436 let mut normal = normalize3(cross3(sub3(bv, av), sub3(cv, av)));
437 let centroid = scale3(add3(add3(av, bv), cv), 1.0 / 3.0);
438 if dot3(normal, centroid) < 0.0 {
439 std::mem::swap(&mut bv, &mut cv);
440 normal = normalize3(cross3(sub3(bv, av), sub3(cv, av)));
441 }
442 let auv = project_uv(a, normal);
443 let buv = project_uv(bv, normal);
444 let cuv = project_uv(cv, normal);
445 let base = vertices.len() as u16;
446 vertices.push(BuiltinMeshVertex {
447 pos: a,
448 normal,
449 uv: auv,
450 });
451 vertices.push(BuiltinMeshVertex {
452 pos: bv,
453 normal,
454 uv: buv,
455 });
456 vertices.push(BuiltinMeshVertex {
457 pos: cv,
458 normal,
459 uv: cuv,
460 });
461 indices.extend_from_slice(&[base, base + 1, base + 2]);
462}
463
464fn push_quad(
465 vertices: &mut Vec<BuiltinMeshVertex>,

Callers 6

triangular_pyramidFunction · 0.85
square_pyramidFunction · 0.85
triangular_prismFunction · 0.85
cylinderFunction · 0.85
coneFunction · 0.85
push_quadFunction · 0.85

Calls 9

scale3Function · 0.85
add3Function · 0.85
project_uvFunction · 0.85
normalize3Function · 0.70
cross3Function · 0.70
sub3Function · 0.70
dot3Function · 0.70
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected