Open github-actions[bot] opened 7 months ago
https://github.com/mosure/bevy_gaussian_splatting/blob/eb0fcc33900f7ad99357d7251f9b5da4c1cab89b/src/gaussian/f16.rs#L165
} #[derive( Clone, Debug, Default, Copy, PartialEq, Reflect, ShaderType, Pod, Zeroable, Serialize, Deserialize, )] #[repr(C)] pub struct Covariance3dOpacityPacked128 { #[reflect(ignore)] pub cov3d: [u32; 3], pub opacity: u32, } impl Covariance3dOpacityPacked128 { pub fn from_gaussian(gaussian: &Gaussian) -> Self { let cov3d: Covariance3dOpacity = gaussian.into(); let cov3d = cov3d.cov3d; let opacity = gaussian.scale_opacity.opacity; Self { cov3d: [ pack_f32s_to_u32(cov3d[0], cov3d[1]), pack_f32s_to_u32(cov3d[2], cov3d[3]), pack_f32s_to_u32(cov3d[4], cov3d[5]), ], opacity: pack_f32s_to_u32(opacity, opacity), // TODO: benefit from 32-bit opacity } } pub fn covariance_3d_opacity(&self) -> Covariance3dOpacity { let (c0, c1) = unpack_u32_to_f32s(self.cov3d[0]); let (c2, c3) = unpack_u32_to_f32s(self.cov3d[1]); let (c4, c5) = unpack_u32_to_f32s(self.cov3d[2]); let (opacity, _) = unpack_u32_to_f32s(self.opacity); let cov3d: [f32; 6] = [c0, c1, c2, c3, c4, c5]; Covariance3dOpacity { cov3d, opacity, pad: 0.0, } } } impl From<[u32; 4]> for Covariance3dOpacityPacked128 { fn from(cov3d_opacity: [u32; 4]) -> Self { Self { cov3d: [ cov3d_opacity[0], cov3d_opacity[1], cov3d_opacity[2], ], opacity: cov3d_opacity[3], } } } pub fn pack_f32s_to_u32(upper: f32, lower: f32) -> u32 { pack_f16s_to_u32( f16::from_f32(upper),
https://github.com/mosure/bevy_gaussian_splatting/blob/eb0fcc33900f7ad99357d7251f9b5da4c1cab89b/src/gaussian/f16.rs#L165