Skip to content

Commit

Permalink
Temp fix for bvh select issue
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentFarris committed Mar 21, 2024
1 parent fe10325 commit ca69e00
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/editor/selection/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,17 @@ func (s *Selection) clickSelect(host *engine.Host) {
volume := all[i].EditorBindings.Data("bvh")
hit := false
if volume != nil {
_, hit = volume.(*collision.BVH).RayHit(ray, rayCastLength)
m := all[i].Transform.WorldMatrix()
m.Inverse()
newRay := collision.Ray{
Origin: m.TransformPoint(ray.Origin),
Direction: m.TransformPoint(ray.Direction),
}
_, hit = volume.(*collision.BVH).RayHit(newRay, rayCastLength)
// TODO: This should work, but something's wrong with the inverse
// of the ray. It's not hitting the BVH correctly, so do fallback
hit = hit || ray.SphereHit(pos, 0.5, rayCastLength)
} else {
// TODO: Use BVH or other acceleration structure. The sphere check
// here is just to get testing quickly
hit = ray.SphereHit(pos, 0.5, rayCastLength)
}
if hit {
Expand Down

0 comments on commit ca69e00

Please sign in to comment.