Skip to content

Commit

Permalink
#5585: MaterialVisitor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Apr 11, 2021
1 parent ccf6820 commit 111f74e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion install/scripts/test.py
Expand Up @@ -160,7 +160,7 @@ def visit(self, shader):

# Disabled code, takes very long in TDM
# materialVisitor = TestMaterialVisitor()
# GlobalMaterialManager.foreachShader(materialVisitor)
# GlobalMaterialManager.foreachMaterial(materialVisitor)

material = GlobalMaterialManager.getMaterialForName('bc_rat')

Expand Down
9 changes: 5 additions & 4 deletions plugins/script/interfaces/ShaderSystemInterface.cpp
Expand Up @@ -26,7 +26,7 @@ namespace
};
}

void ShaderSystemInterface::foreachShader(MaterialVisitor& visitor)
void ShaderSystemInterface::foreachMaterial(MaterialVisitor& visitor)
{
// Note: foreachShader only traverses the loaded materials, use a small adaptor to traverse all known
ShaderNameToShaderWrapper adaptor(visitor);
Expand Down Expand Up @@ -66,13 +66,14 @@ void ShaderSystemInterface::registerInterface(py::module& scope, py::dict& globa
visitor.def(py::init<>());
visitor.def("visit", &MaterialVisitor::visit);

scope.add_object("ShaderVisitor", visitor); // old compatibility name

// Add the module declaration to the given python namespace
py::class_<ShaderSystemInterface> materialManager(scope, "MaterialManager");

materialManager.def("foreachShader", &ShaderSystemInterface::foreachShader);
materialManager.def("foreachMaterial", &ShaderSystemInterface::foreachMaterial);
materialManager.def("getMaterial", &ShaderSystemInterface::getMaterial);

scope.add_object("ShaderVisitor", visitor); // old compatibility name
materialManager.def("foreachShader", &ShaderSystemInterface::foreachMaterial); // old compatibility name
materialManager.def("getMaterialForName", &ShaderSystemInterface::getMaterial); // old compatibility name

// Now point the Python variable "GlobalMaterialManager" to this instance
Expand Down
2 changes: 1 addition & 1 deletion plugins/script/interfaces/ShaderSystemInterface.h
Expand Up @@ -93,7 +93,7 @@ class ShaderSystemInterface :
public IScriptInterface
{
public:
void foreachShader(MaterialVisitor& visitor);
void foreachMaterial(MaterialVisitor& visitor);
ScriptShader getMaterial(const std::string& name);

// IScriptInterface implementation
Expand Down

0 comments on commit 111f74e

Please sign in to comment.