Skip to content

Conversation

@quillaja
Copy link
Contributor

While working on #29, I used some OBJs with geometry defined not using object (o) or group (g) lines. Apparently these are also optional in the OBJ format. In the case when a file does not have an o or g specified, a nil-pointer error is encountered at dec.objCurrent in parseFace(), as it assume a group is made previously via the parseObject() method.

To protect against this, basically just made a group unnamed###. I also pulled the creation of obj.Object out into a private func because I thought I'd have to call it from multiple places (I didn't need to, but it may be useful down the road).

quillaja added 10 commits March 6, 2019 09:28
…file can be found and when no materials are specified in the OBJ file.
…de. added default material defined in 1 location.
object (o) and group (g) lines are optional in OBJ. the parser doesn't create a group if
these lines are not present, which breaks parsing of face and usemtl lines. I added checks
to create 'default' groups when first encountering a usemtl or face line if no group or
object was created.
DecodeReader() will try the io.Reader first, then the mtllib file
in the OBJ, if present. If all else fails, a default material is
applied. DecodeReader() produces no error for materials.
Merge branch 'issue-29-obj-default-mat' into issue-29-handle-no-groups
@quillaja quillaja mentioned this pull request Mar 12, 2019
@danaugrs danaugrs merged commit 70eaa04 into g3n:master Mar 14, 2019
@danaugrs
Copy link
Member

Merged! 😄

uzudil pushed a commit to uzudil/engine that referenced this pull request Dec 16, 2020
Issue 29a: errors when no object or group specified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants