Skip to content

Commit e417c68

Browse files
sbryngelsonclaude
andcommitted
Fix OBJ reader using j as both triangle counter and vertex index
When reading face lines, j is overwritten by the third vertex index from the file, then used as the triangle index for model%trs(j). Introduces a separate iv3 variable for the third vertex index. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9b1e8b7 commit e417c68

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/common/m_model.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ contains
225225
character(LEN=*), intent(in) :: filepath
226226
type(t_model), intent(out) :: model
227227

228-
integer :: i, j, k, l, iunit, iostat, nVertices
228+
integer :: i, j, k, l, iv3, iunit, iostat, nVertices
229229

230230
real(wp), dimension(1:3), allocatable :: vertices(:, :)
231231

@@ -274,10 +274,10 @@ contains
274274
read (line(3:), *) vertices(i, :)
275275
i = i + 1
276276
case ("f ")
277-
read (line(3:), *) k, l, j
277+
read (line(3:), *) k, l, iv3
278278
model%trs(j)%v(1, :) = vertices(k, :)
279279
model%trs(j)%v(2, :) = vertices(l, :)
280-
model%trs(j)%v(3, :) = vertices(j, :)
280+
model%trs(j)%v(3, :) = vertices(iv3, :)
281281
j = j + 1
282282
case default
283283
print *, "Error: unknown line type in OBJ file ", filepath

0 commit comments

Comments
 (0)