Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust SDK: raw 3D meshes and example #1010

Merged
merged 21 commits into from
Feb 1, 2023
Merged

rust SDK: raw 3D meshes and example #1010

merged 21 commits into from
Feb 1, 2023

Conversation

teh-cmc
Copy link
Member

@teh-cmc teh-cmc commented Jan 31, 2023

This implements triangle soups, but most importantly it identifies a lot of the pain points in our current Rust SDK, which I'll address in a PR that'll follow shortly.

Fixes #749 and fixes #809.

Test it with cargo r -p raw_mesh

@teh-cmc teh-cmc marked this pull request as ready for review January 31, 2023 15:24
Comment on lines 144 to 148
// TODO(cmc): This should probably just be a compile flag of the SDK; if it's enabled, then the
// global allocator is properly set by the SDK directly.
#[global_allocator]
static GLOBAL: AccountingAllocator<mimalloc::MiMalloc> =
AccountingAllocator::new(mimalloc::MiMalloc);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eeeeh then again in python it works nicely because it really only affects the SDK and not the user code (by virtue of the user code not being Rust to begin with), but in Rust it will affect everything, user code included, which seems too magical for Rust...

Scratch it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Though we will of course reexports all the needed libraries and types to make it easier for the user)

Comment on lines 228 to 233
fn node_name(node: &gltf::Node<'_>) -> String {
node.name()
// TODO(cmc): now that index-paths and instance-keys are decorrelated, maybe we can use
// those here.
.map_or_else(|| format!("node_#{}", node.index()), ToOwned::to_owned)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: for e.g. Buggy.glb I'm able to find names for the nodes when going through trimesh, contrary to the current rust version which finds nothing... there's probably some missing logic here.

Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lot of TODO:s 😅

crates/re_log_types/src/component_types/mesh3d.rs Outdated Show resolved Hide resolved
@@ -71,6 +70,7 @@ impl LoadedMesh {

let mut slf = Self::load_raw(name, *format, bytes, render_ctx)?;

// TODO(cmc): Why are we creating the matrix twice here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like some attempt to avoid shearing? But I really don't see the point.

crates/re_viewer/src/misc/mesh_loader.rs Outdated Show resolved Hide resolved
crates/re_viewer/src/ui/data_ui/component_ui_registry.rs Outdated Show resolved Hide resolved
examples/raw_mesh/src/main.rs Outdated Show resolved Hide resolved
@emilk
Copy link
Member

emilk commented Feb 1, 2023

For another PR:

I think we should split Python examples from Rust examples, and not have them in the same folder.

examples/python + examples/rust for instance.

@emilk
Copy link
Member

emilk commented Feb 1, 2023

A lot of nodes seemingly have no data - how come?

Screen Shot 2023-02-01 at 10 57 33

let mesh_in = vec![Mesh3D::Encoded(EncodedMesh3D {
mesh_id: MeshId::random(),
format: MeshFormat::Glb,
bytes: std::sync::Arc::new([5, 9, 13, 95, 38, 42, 98, 17]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe leave a note about the source of this data? Or is it random junk?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all junk

@teh-cmc teh-cmc changed the title Raw 3D meshes and their very own Rust example rust SDK: raw 3D meshes and example Feb 1, 2023
@teh-cmc
Copy link
Member Author

teh-cmc commented Feb 1, 2023

A lot of nodes seemingly have no data - how come?

Screen Shot 2023-02-01 at 10 57 33

Mmm, not sure what's going on in this screenshot; this is what I see for the same node:
image

@teh-cmc teh-cmc merged commit 5d86a00 into main Feb 1, 2023
@teh-cmc teh-cmc deleted the cmc/triangle_soups branch February 1, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log triangle soups, boxes, cylinders Either fix support for RawMesh3D or Remove it
3 participants