Skip to content

Commit

Permalink
Merge branch 'write_xml' of https://github.com/bathal1/mitsuba2 into …
Browse files Browse the repository at this point in the history
…write_xml
  • Loading branch information
Baptiste Nicolet committed May 15, 2020
2 parents cebe405 + 418ec6a commit 5b28154
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/libcore/xml.cpp
Expand Up @@ -1174,6 +1174,17 @@ ref<Object> load_string(const std::string &string, const std::string &variant,

ref<Object> load_file(const fs::path &filename_, const std::string &variant,
ParameterList param, bool write_update) {

ref<Thread> thread = Thread::thread();
ref<FileResolver> fr = thread->file_resolver();
ref<FileResolver> fr2 = new FileResolver(*fr);
thread->set_file_resolver(fr2);

// Add the scene file's directory to the search path.
fs::path scene_dir = filename_.parent_path();
if (!fr2->contains(scene_dir))
fr2->append(scene_dir);

ScopedPhase sp(ProfilerPhase::InitScene);
fs::path filename = filename_;
if (!fs::exists(filename))
Expand Down
4 changes: 2 additions & 2 deletions src/librender/mesh.cpp
Expand Up @@ -205,7 +205,7 @@ MTS_VARIANT Mesh<Float, Spectrum>::Mesh(
const InputVector3f e1 = face_points[1] - face_points[0];
const InputVector3f e2 = face_points[2] - face_points[0];
normal = m_to_world.transform_affine(cross(e1, e2));
if(unlikely(all(normal==0.0f)))
if(unlikely(eq(normal, 0.f)))
continue; // Degenerate triangle, ignore it
else
normal = normalize(normal);
Expand All @@ -221,7 +221,7 @@ MTS_VARIANT Mesh<Float, Spectrum>::Mesh(
if (blender::ME_SMOOTH & face.flag) {
// smooth shading, store per vertex normals
normal = m_to_world.transform_affine(InputNormal3f(vert.no[0], vert.no[1], vert.no[2]));
if(unlikely(all(normal==0.0f)))
if(unlikely(eq(normal, 0.f)))
fail("Mesh has invalid normals!");
else
normal = normalize(normal);
Expand Down
8 changes: 0 additions & 8 deletions src/mitsuba/mitsuba.cpp
Expand Up @@ -202,14 +202,6 @@ int main(int argc, char *argv[]) {

while (arg_extra && *arg_extra) {
filesystem::path filename(arg_extra->as_string());
ref<FileResolver> fr2 = new FileResolver(*fr);
thread->set_file_resolver(fr2);

// Add the scene file's directory to the search path.
fs::path scene_dir = filename.parent_path();
if (!fr2->contains(scene_dir))
fr2->append(scene_dir);

if (*arg_output)
filename = arg_output->as_string();

Expand Down

0 comments on commit 5b28154

Please sign in to comment.