Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions source/MaterialXRenderGlsl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.c*")
file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")

message(STATUS "The value of MY_VARIABLE is: ${materialx_source}")

if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
Expand Down
12 changes: 11 additions & 1 deletion source/PyMaterialX/PyMaterialXRender/PyTinyObjLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
#include <PyMaterialX/PyMaterialX.h>

#include <MaterialXRender/TinyObjLoader.h>
#include <utility>

namespace py = pybind11;
namespace mx = MaterialX;

std::pair<bool, mx::MeshList> load_meshes_wrapper_tuple(mx::TinyObjLoader& self,
const mx::FilePath& filePath,
bool texcoordVerticalFlip)
{
mx::MeshList meshList;
bool success = self.load(filePath, meshList, texcoordVerticalFlip);
return {success, meshList};
}

void bindPyTinyObjLoader(py::module& mod)
{
py::class_<mx::TinyObjLoader, mx::TinyObjLoaderPtr, mx::GeometryLoader>(mod, "TinyObjLoader")
.def_static("create", &mx::TinyObjLoader::create)
.def(py::init<>())
.def("load", &mx::TinyObjLoader::load);
.def("load", &load_meshes_wrapper_tuple);
Copy link
Contributor

@kwokcb kwokcb Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is an attempt to fix that the meshlist is not being updated since it's a referenced shared point list ? We should not change an existing signature to handle this.

I think the easiest fix in this case is to expose Python wrapper for MeshList in PyMesh.cpp. e.g:
py::bind_vector<mx::MeshList>(mod, "MeshList");
I think this was just a oversight.

As "load" in in the base class Python wrapper I think these derived class "load"s can be removed as well. There is one for CgltfLoader as well as TinyObjLoader.

Any new / user defined Python derived loaders will would also work properly.

To test this, the workflow of adding loaders to a handler should also be tested. There load and get are separated into two different methods. (BTW, Working via a handler is the desired pattern to follow to allow per loader extension handling.)

It would be good to have a unit test for this as well. e.g. of handler workflow:

import MaterialX as mx
import MaterialX.PyMaterialXRender as mxr

# Test obj, gltf should also be tested
location = "./resources/Geometry/plane.obj"
meshlist = [] # This would create a Python wrapper MeshList instead.
flipUVs = False

cgltf = mxr.CgltfLoader.create()
objl = mxr.TinyObjLoader.create()
# Individua loader test
loaded = objl.load(location, meshlist, flipUVs)

handler = mxr.GeometryHandler.create()
handler.addLoader(cgltf)
handler.addLoader(objl)

loaded = handler.loadGeometry(location, flipUVs)
handler.getGeoemetry(meshlist, location)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give that a try. I'm much more flexible in changing signature when it is necessary but you have figured out what I could not on MeshList. Thanks for your help in looking at this issue that was blocking rendering in python (which is now working I might add, with a few more changes which will be coming soon). I like the idea of a unit test for this behavior.

}