smpl_core/common/
outputs.rs

1use burn::{
2    prelude::Backend,
3    tensor::{Float, Int, Tensor},
4};
5use gloss_geometry::geom::{self, PerVertexNormalsWeightingType};
6/// Component for shaped and un-posed mesh. This would be the output of the
7/// ``betas_to_verts`` system. This component is a generic over burn backend
8#[derive(Clone)]
9pub struct SmplOutputPoseTDynamic<B: Backend> {
10    pub verts: Tensor<B, 2, Float>,
11    pub verts_without_expression: Tensor<B, 2, Float>,
12    pub joints: Tensor<B, 2, Float>,
13}
14/// Component for a posed mesh. This would be the output of the ``apply_pose``
15/// system. This component is a generic over burn backend
16#[derive(Clone)]
17pub struct SmplOutputPosedDynamic<B: Backend> {
18    pub joints: Tensor<B, 2, Float>,
19    pub verts: Tensor<B, 2, Float>,
20}
21/// Component for the final shaped and posed mesh. This would be the output of
22/// ``smpl_model.forward()`` This component is a generic over burn backend
23#[derive(Clone)]
24pub struct SmplOutputDynamic<B: Backend> {
25    pub verts: Tensor<B, 2, Float>,
26    pub faces: Tensor<B, 2, Int>,
27    pub normals: Option<Tensor<B, 2, Float>>,
28    pub uvs: Option<Tensor<B, 2, Float>>,
29    pub joints: Tensor<B, 2, Float>,
30}
31impl<B: Backend> SmplOutputDynamic<B> {
32    pub fn compute_normals(&mut self) {
33        let normals = geom::compute_per_vertex_normals_burn(&self.verts, &self.faces, &PerVertexNormalsWeightingType::Area);
34        self.normals = Some(normals);
35    }
36}