Skip to content

Implement 'Shape "loopsubdiv"' #67

@wahn

Description

@wahn

The one and only test scene distributed with the C++ code contains a subdivision surface:

Shape "loopsubdiv"  "integer nlevels" [1 ] "integer indices" ...

killeroo-simple

Beside the problem that we can't handle Include statements yet (see issue #41), we need to implement CreateLoopSubdiv(...) on the Rust side and a bunch of helper functions/structs:

std::vector<std::shared_ptr<Shape>> CreateLoopSubdiv(const Transform *o2w,
                                                     const Transform *w2o,
                                                     bool reverseOrientation,
                                                     const ParamSet &params) {
    int nLevels = params.FindOneInt("levels",
                                    params.FindOneInt("nlevels", 3));
    int nps, nIndices;
    const int *vertexIndices = params.FindInt("indices", &nIndices);
    const Point3f *P = params.FindPoint3f("P", &nps);
    if (!vertexIndices) {
        Error("Vertex indices \"indices\" not provided for LoopSubdiv shape.");
        return std::vector<std::shared_ptr<Shape>>();
    }
    if (!P) {
        Error("Vertex positions \"P\" not provided for LoopSubdiv shape.");
        return std::vector<std::shared_ptr<Shape>>();
    }

    // don't actually use this for now...
    std::string scheme = params.FindOneString("scheme", "loop");
    return LoopSubdivide(o2w, w2o, reverseOrientation, nLevels, nIndices,
                         vertexIndices, nps, P);
}
> pwd
/.../github/pbrt-v3/src/shapes
> rg "struct SD"
loopsubdiv.cpp
43:struct SDFace;
44:struct SDVertex;
51:struct SDVertex {
64:struct SDFace {
96:struct SDEdge {

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions