Skip to content

Implement trimesh builder#866

Merged
Jondolf merged 23 commits into
avianphysics:mainfrom
janhohenheim:trimesh-builder
Oct 15, 2025
Merged

Implement trimesh builder#866
Jondolf merged 23 commits into
avianphysics:mainfrom
janhohenheim:trimesh-builder

Conversation

@janhohenheim

@janhohenheim janhohenheim commented Oct 15, 2025

Copy link
Copy Markdown
Member

Objective

  • I want to have a trimesh plz

Solution

  • Create a builder

Changelog

Colliders could always be converted into a trimesh by manually matching on their type and handling them individually. This involved some fair bit of boilerplate. Now, we have a dedicated TrimeshBuilder for the task:

use avian3d::prelude::*;

let collider = Collider::sphere(1.0);

// Using default settings
let trimesh = collider.trimesh_builder().build().unwrap();

// Using extra subdivions
let trimesh = collider.trimesh_builder().ball_subdivs(20).build().unwrap();

// Setting different subdivions for different shapes
let trimesh = collider
    .trimesh_builder()
    .ball_subdivs(20)
    .capsule_subdivs(10, 5)
    .fallback_subdivs(15)
    .build()
    .unwrap();

// Generating the trimesh with a transformation
let trimesh = collider.trimesh_builder().translated([1.0, 0.0, 0.0]).build().unwrap();

The resulting Trimesh is in the format of a triangle list and can easily be converted into a Bevy Mesh via its From implementation.

This feature is currently only available for 3D.

@Jondolf Jondolf added C-Feature A new feature, making something new possible A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality labels Oct 15, 2025
Comment thread src/collision/collider/trimesh_builder.rs Outdated
Comment thread src/collision/collider/trimesh_builder.rs Outdated
Comment thread src/collision/collider/trimesh_builder.rs Outdated
Comment thread src/collision/collider/trimesh_builder.rs
Comment thread src/collision/collider/trimesh_builder.rs Outdated
Comment thread src/collision/collider/trimesh_builder.rs Outdated
Comment thread src/collision/collider/trimesh_builder.rs Outdated
Comment thread src/collision/collider/trimesh_builder.rs Outdated
@Jondolf Jondolf added this to the 0.4.1 milestone Oct 15, 2025
@Jondolf Jondolf enabled auto-merge (squash) October 15, 2025 20:48
auto-merge was automatically disabled October 15, 2025 21:06

Head branch was pushed to by a user without write access

@Jondolf Jondolf enabled auto-merge (squash) October 15, 2025 21:26
auto-merge was automatically disabled October 15, 2025 21:46

Head branch was pushed to by a user without write access

@Jondolf Jondolf merged commit 6377d65 into avianphysics:main Oct 15, 2025
6 checks passed
@janhohenheim janhohenheim deleted the trimesh-builder branch October 15, 2025 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality C-Feature A new feature, making something new possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants