Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[panic] in BVHAccel::recursive_build() #96

Closed
wahn opened this issue May 21, 2019 · 2 comments
Closed

[panic] in BVHAccel::recursive_build() #96

wahn opened this issue May 21, 2019 · 2 comments
Assignees
Labels

Comments

@wahn
Copy link
Owner

wahn commented May 21, 2019

> pwd
/mill3d/users/jan/Graphics/Rendering/PBRT/pbrt-v3-scenes/coffee-splash
> ~/git/github/rs_pbrt/target/release/examples/rs_pbrt -i f15-5.pbrt
pbrt version 0.5.3 [Detected 8 cores]
Copyright (c) 2016-2019 Jan Douglas Bert Walter.
Rust code based on C++ code by Matt Pharr, Greg Humphreys, and Wenzel Jakob.
Sampler "sobol"
  "integer pixelsamples" [8]
Integrator "volpath"
  "integer maxdepth" [25]
Film "image"
  "string filename" ["f15-5.exr"]
  "integer xresolution" [1000]
  "integer yresolution" [800]
  "float scale" [2]
Include "/mill3d/users/jan/Graphics/Rendering/PBRT/pbrt-v3-scenes/coffee-splash/materials.pbrt"
reading "bsdfs/ceramic.bsdf" returns true
Include "/mill3d/users/jan/Graphics/Rendering/PBRT/pbrt-v3-scenes/coffee-splash/geometry.pbrt"
reading "bsdfs/ceramic.bsdf" returns true
BVHAccel::recursive_build(..., 0, ...)
thread 'main' panicked at 'assertion failed: `(left != right)`
  left: `0`,
 right: `0`', src/accelerators/bvh.rs:210:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
@wahn wahn added the bug label May 21, 2019
@wahn wahn self-assigned this May 21, 2019
@wahn
Copy link
Owner Author

wahn commented May 23, 2019

On the C++ side we can set a breakpoint here (in src/shapes/plymesh.cpp):

B+ │285         return CreateTriangleMesh(o2w, w2o, reverseOrientation,
   │286                                   context.indexCtr / 3, context.indices,
   │287                                   vertexCount, context.p, nullptr, context.n,
   │288                                   context.uv, alphaTex, shadowAlphaTex,
  >│289                                   context.faceIndices);

At that point we have read 3970 vertices and 23808 indices (divided by 3, means 7936 triangles):

(gdb) p	context.indexCtr
$3 = 23808
(gdb) p	vertexCount 
$7 = 3970

Debugging the Rust side (in shapes/plymesh.rs):

    let mesh = Arc::new(TriangleMesh::new(                                                              
        *o2w,                                                                                           
        *w2o,                                                                                           
        reverse_orientation,                                                                            
        tm_vertex_indices.len() / 3, // n_triangles                                                     
        tm_vertex_indices,                                                                              
        n_vertices,                                                                                     
        p_ws, // in world space                                                                         
        s_ws, // in world space                                                                         
        n_ws, // in world space                                                                         
        uvs,                                                                                            
    ));                                                                                                 

We find the same amount of read vertices:

(gdb) p n_vertices
$15 = 3970

But the vertex indices are missing!!!

(gdb) p tm_vertex_indices
$16 = Vec<usize>(len: 0, cap: 0)

@wahn
Copy link
Owner Author

wahn commented May 23, 2019

Commit 056f2e4 fixes the issue and also fixes a bug in create_ply_mesh(...) regarding quads.

@wahn wahn closed this as completed May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant