Skip to content

Commit

Permalink
#5585: Deform type getters
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Apr 11, 2021
1 parent 6a58ea2 commit 689b577
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions install/scripts/materialtest.py
Expand Up @@ -41,6 +41,9 @@
print('Clamp type: {0}'.format(newMaterial.getClampType()))
print('Flags: {0}'.format(newMaterial.getMaterialFlags()))
print('Surface Flags: {0}'.format(newMaterial.getSurfaceFlags()))
print('Deform Type: {0}'.format(newMaterial.getDeformType()))
print('Deform Expression #1: {0}'.format(newMaterial.getDeformExpressionString(0)))
print('Deform Decl Name: {0}'.format(newMaterial.getDeformDeclName()))

# There are a couple of pre-defined sort requests, corresponding to the engine code
newMaterial.setSortRequest(dr.Material.SortRequest.NEAREST)
Expand Down
16 changes: 16 additions & 0 deletions plugins/script/interfaces/ShaderSystemInterface.cpp
Expand Up @@ -181,6 +181,19 @@ void ShaderSystemInterface::registerInterface(py::module& scope, py::dict& globa
.value("SURFTYPE15", Material::SURFTYPE_15)
.export_values();

py::enum_<Material::DeformType>(material, "DeformType")
.value("NONE", Material::DEFORM_NONE)
.value("SPRITE", Material::DEFORM_SPRITE)
.value("TUBE", Material::DEFORM_TUBE)
.value("FLARE", Material::DEFORM_FLARE)
.value("EXPAND", Material::DEFORM_EXPAND)
.value("MOVE", Material::DEFORM_MOVE)
.value("TURBULENT", Material::DEFORM_TURBULENT)
.value("EYEBALL", Material::DEFORM_EYEBALL)
.value("PARTICLE", Material::DEFORM_PARTICLE)
.value("PARTICLE2", Material::DEFORM_PARTICLE2)
.export_values();

material.def(py::init<const MaterialPtr&>());
material.def("getName", &ScriptMaterial::getName);
material.def("getShaderFileName", &ScriptMaterial::getShaderFileName);
Expand Down Expand Up @@ -213,6 +226,9 @@ void ShaderSystemInterface::registerInterface(py::module& scope, py::dict& globa
material.def("clearSurfaceFlag", &ScriptMaterial::clearSurfaceFlag);
material.def("getSurfaceType", &ScriptMaterial::getSurfaceType);
material.def("setSurfaceType", &ScriptMaterial::setSurfaceType);
material.def("getDeformType", &ScriptMaterial::getDeformType);
material.def("getDeformExpressionString", &ScriptMaterial::getDeformExpressionString);
material.def("getDeformDeclName", &ScriptMaterial::getDeformDeclName);

// Expose the MaterialVisitor interface

Expand Down
19 changes: 19 additions & 0 deletions plugins/script/interfaces/ShaderSystemInterface.h
Expand Up @@ -186,6 +186,25 @@ class ScriptMaterial
if (_material) _material->setSurfaceType(type);
}

/// Get the deform type of this material
Material::DeformType getDeformType()
{
return _material ? _material->getDeformType() : Material::DEFORM_NONE;
}

// Returns the shader expression used to define the deform parameters (valid indices in [0..2])
std::string getDeformExpressionString(std::size_t index)
{
return _material && _material->getDeformExpression(index) ?
_material->getDeformExpression(index)->getExpressionString() : std::string();
}

// Used for Deform_Particle/Particle2 defines the name of the particle def
std::string getDeformDeclName()
{
return _material ? _material->getDeformDeclName() : std::string();
}

private:
void throwIfMaterialCannotBeModified()
{
Expand Down

0 comments on commit 689b577

Please sign in to comment.