Skip to content

Commit

Permalink
Improve picking precision (#530)
Browse files Browse the repository at this point in the history
* improve picking precision

* smaller pick point in example

* Revert "improve picking precision"

This reverts commit 1ff0049.

* Improve picking precision without division

* Improve pick geometry

---------

Co-authored-by: Asger Nyman Christiansen <asgernyman@gmail.com>
  • Loading branch information
paul2t and asny authored Jan 20, 2025
1 parent 4aa5dea commit 10e340d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions examples/picking/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub async fn run() {
PhysicalMaterial::new_opaque(
&context,
&CpuMaterial {
albedo: Srgba::new(100, 100, 100, 0),
albedo: Srgba::new(255, 255, 0, 255),
..Default::default()
},
),
Expand Down Expand Up @@ -114,7 +114,9 @@ pub async fn run() {
position,
monkey.into_iter().chain(&cone).chain(&instanced_mesh),
) {
pick_mesh.set_transformation(Mat4::from_translation(pick.position));
pick_mesh.set_transformation(
Mat4::from_translation(pick.position) * Mat4::from_scale(0.3),
);
match pick.geometry_id {
0 => {
monkey.material.albedo = Srgba::RED;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ pub fn ray_intersect(
let camera = Camera::new_orthographic(
viewport,
position,
position + direction * max_depth,
position + direction,
up,
0.01,
0.0,
Expand Down

0 comments on commit 10e340d

Please sign in to comment.