AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb

[BUG] math::Ray ill defined if a component of its direction is zero.

Open
#2,094 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
3.4k
Forks
774
Avg merge
3d 9h
Merged PRs (30d)
34

Description

### Environment
Debian Trixie

### Describe the bug
When a Ray is created with direction component that is zero, then mInvDir will be ill defined.

### To Reproduce
Run unit tests, a ray with direction 1,0,0 will divide by zero.

### Expected behavior
No FP exception.

### Additional context

```
[ RUN ] TestLevelSetRayIntersector.tests

Thread 1 "vdb_test" received signal SIGFPE, Arithmetic exception.
```

```
(gdb) up
#1 0x0000555557ec7a60 in openvdb::v12_1::math::Ray::Ray (
this=0x7fffffffd8f0, eye=..., direction=..., t0=1.0000000000000001e-09,
t1=1.7976931348623157e+308)
at /home/bram/src/openvdb/openvdb/openvdb/../openvdb/math/Ray.h:61
61 : mEye(eye), mDir(direction), mInvDir(1/mDir), mTimeSpan(t0, t1)
(gdb) print mDir
$1 = {> = {static size = 3, mm = {1, 0,
0}}, }
```

Contributor guide

Open the contributing guide

Research direction

Start at openvdb/math/Ray.h line 61 and reproduce the issue through the TestLevelSetRayIntersector.tests unit test with a direction component of zero. Trace how mInvDir is used and add regression coverage showing that constructing such a ray completes without an FP exception; the relevant test should pass afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.