mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.86k stars 1.18k forks source link

Misplaced "ObjectBegin/ObjectEnd" pair in some scenes #238

Closed plumer closed 4 years ago

plumer commented 5 years ago

Thanks to the author for the great book and great test scenes. To understand the organization of the input file I intend to write a parser on my own as an exercise. My idea is to build this functionality with flex and bison. However some input files in pbrt-v3-scenes confuses me: some ObjectBegin/ObjectEnd pairs are not placed correctly. One such example is in transparent-machines/frame675.pbrt. The object "BOLT.1" is defined in lines 1952-1971. This object begins at line 1953, ends at 1971, but the directive pairs AttributeBegin and AttributeEnd don't match here.

pbrt-v3-scenes/transparent-machines/frame675.pbrt, lines 1952-1971
------------------------------------------------------------------------------
AttributeBegin
    ObjectBegin "BOLT.1"

    AttributeBegin
        # TINYSCREW
        ConcatTransform [ 1 0 0 0 0 1 0 0 0 0 1 0 0 -207.486588 -2.27373675e-13 1  ]
        Shape "plymesh" "string filename" "geometry/675/mesh_00011.ply" 
    AttributeEnd

    AttributeBegin
        # Cylinder
        ConcatTransform [ 1.19400001 0 0 0 0 1.19400001 0 0 0 0 1.19400001 0 0 207.486588 -2.27373675e-13 1  ]

        AttributeBegin
            # Cylinder
            Shape "plymesh" "string filename" "geometry/675/mesh_00012.ply" 
        AttributeEnd
    AttributeEnd
AttributeEnd             # should this line be switched
ObjectEnd                # with this line?

This seemingly incorrect ordering of the directives doesn't baffle the api provided by pbrt (it also works if I switch the last 2 lines), but is this intended? I read the documentation for file format, but the description and example I see indicates "balanced" usage of the directive pairs.

Clarification on this issue can help a lot with a bison-based parser. Thanks!

mmp commented 4 years ago

That is definitely an error in the scene description files (that pbrt isn't complaining about, though it probably should be.) Sorry about that!

We'll add a check in the next version to catch that--thanks!