Skip to content

Commit

Permalink
UVector3D -> TriangleIndices
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 30, 2024
1 parent bf605d8 commit 22b73b6
Show file tree
Hide file tree
Showing 33 changed files with 222 additions and 221 deletions.
6 changes: 3 additions & 3 deletions crates/re_query/src/latest_at/to_archetype/mesh3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/re_space_view_spatial/src/visualizers/meshes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use re_renderer::renderer::MeshInstance;
use re_types::{
archetypes::Mesh3D,
components::{
ClassId, Color, Material, Position3D, TensorData, Texcoord2D, UVector3D, Vector3D,
ClassId, Color, Material, Position3D, TensorData, Texcoord2D, TriangleIndices, Vector3D,
},
};
use re_viewer_context::{
Expand Down Expand Up @@ -44,7 +44,7 @@ struct Mesh3DComponentData<'a> {
vertex_colors: &'a [Color],
vertex_texcoords: &'a [Texcoord2D],

triangle_indices: Option<&'a [UVector3D]>,
triangle_indices: Option<&'a [TriangleIndices]>,
mesh_material: Option<&'a Material>,
albedo_texture: Option<&'a TensorData>,

Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/definitions/rerun/archetypes/mesh3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ table Mesh3D (
// --- Recommended ---

/// Optional indices for the triangles that make up the mesh.
triangle_indices: [rerun.components.UVector3D] ("attr.rerun.component_recommended", nullable, order: 2000);
triangle_indices: [rerun.components.TriangleIndices] ("attr.rerun.component_recommended", nullable, order: 2000);

/// An optional normal for each vertex.
vertex_normals: [rerun.components.Vector3D] ("attr.rerun.component_recommended", nullable, order: 2100);
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/definitions/rerun/components.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ include "./components/texcoord2d.fbs";
include "./components/text.fbs";
include "./components/text_log_level.fbs";
include "./components/transform3d.fbs";
include "./components/uvector3d.fbs";
include "./components/triangle_indices.fbs";
include "./components/vector2d.fbs";
include "./components/vector3d.fbs";
include "./components/view_coordinates.fbs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ namespace rerun.components;

// ---

/// A uint32 vector in 3D space.
struct UVector3D (
/// The three indices of a triangle mesh.
struct TriangleIndices (
"attr.rust.derive": "Copy, PartialEq, Eq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
vector: rerun.datatypes.UVec3D (order: 100);
indices: rerun.datatypes.UVec3D (order: 100);
}
36 changes: 18 additions & 18 deletions crates/re_types/src/archetypes/mesh3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/re_types/src/archetypes/mesh3d_ext.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{components::UVector3D, datatypes::UVec3D};
use crate::{components::TriangleIndices, datatypes::UVec3D};

use super::Mesh3D;

Expand All @@ -24,7 +24,7 @@ impl Mesh3D {
let num_vertices = self.num_vertices();

if let Some(indices) = self.triangle_indices.as_ref() {
for &UVector3D(UVec3D([x, y, z])) in indices {
for &TriangleIndices(UVec3D([x, y, z])) in indices {
if num_vertices <= x as usize {
return Err(Mesh3DError::IndexOutOfBounds {
index: x,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/src/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/re_types/src/components/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::UVector3D;
use super::TriangleIndices;

impl UVector3D {
impl TriangleIndices {
/// The zero vector, i.e. the additive identity.
pub const ZERO: Self = Self(crate::datatypes::UVec3D::ZERO);

Expand All @@ -9,17 +9,17 @@ impl UVector3D {
}

#[cfg(feature = "glam")]
impl From<UVector3D> for glam::UVec3 {
impl From<TriangleIndices> for glam::UVec3 {
#[inline]
fn from(v: UVector3D) -> Self {
fn from(v: TriangleIndices) -> Self {
Self::new(v.x(), v.y(), v.z())
}
}

#[cfg(feature = "mint")]
impl From<UVector3D> for mint::Vector3<u32> {
impl From<TriangleIndices> for mint::Vector3<u32> {
#[inline]
fn from(v: UVector3D) -> Self {
fn from(v: TriangleIndices) -> Self {
Self {
x: v.x(),
y: v.y(),
Expand Down
6 changes: 3 additions & 3 deletions crates/re_types/tests/mesh3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use re_types::{
archetypes::Mesh3D,
components::{ClassId, Position3D, Texcoord2D, UVector3D, Vector3D},
components::{ClassId, Position3D, Texcoord2D, TriangleIndices, Vector3D},
datatypes::{
Material, Rgba32, TensorBuffer, TensorData, TensorDimension, UVec3D, Vec2D, Vec3D,
},
Expand Down Expand Up @@ -32,8 +32,8 @@ fn roundtrip() {
Position3D(Vec3D([10.0, 20.0, 30.0])),
],
triangle_indices: Some(vec![
UVector3D(UVec3D([1, 2, 3])), //
UVector3D(UVec3D([4, 5, 6])), //
TriangleIndices(UVec3D([1, 2, 3])), //
TriangleIndices(UVec3D([4, 5, 6])), //
]),
vertex_normals: Some(vec![
Vector3D(Vec3D([4.0, 5.0, 6.0])), //
Expand Down
2 changes: 1 addition & 1 deletion crates/rerun/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod prelude {
// Also import any component or datatype that has a unique name:
pub use re_types::components::{
Color, HalfSizes2D, HalfSizes3D, LineStrip2D, LineStrip3D, Material, MediaType,
OutOfTreeTransform3D, Position2D, Position3D, Radius, Text, TextLogLevel, UVector3D,
OutOfTreeTransform3D, Position2D, Position3D, Radius, Text, TextLogLevel, TriangleIndices,
Vector2D, Vector3D,
};
pub use re_types::datatypes::{
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/types/archetypes/mesh3d.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/content/reference/types/components.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/content/reference/types/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 22b73b6

Please sign in to comment.