Skip to content

Commit d914c06

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 d9464d4 commit d914c06

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/common/m_model.fpp

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

229-
integer :: i, j, k, l, iunit, iostat, nVertices
229+
integer :: i, j, k, l, iv3, iunit, iostat, nVertices
230230

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

@@ -275,10 +275,10 @@ contains
275275
read (line(3:), *) vertices(i, :)
276276
i = i + 1
277277
case ("f ")
278-
read (line(3:), *) k, l, j
278+
read (line(3:), *) k, l, iv3
279279
model%trs(j)%v(1, :) = vertices(k, :)
280280
model%trs(j)%v(2, :) = vertices(l, :)
281-
model%trs(j)%v(3, :) = vertices(j, :)
281+
model%trs(j)%v(3, :) = vertices(iv3, :)
282282
j = j + 1
283283
case default
284284
print *, "Error: unknown line type in OBJ file ", filepath

0 commit comments

Comments
 (0)