Skip to content

Commit

Permalink
Clang format updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jstone-lucasfilm committed Dec 4, 2023
1 parent eb24c5e commit 4bdfb7f
Show file tree
Hide file tree
Showing 63 changed files with 353 additions and 349 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,13 @@ jobs:

- name: Run Clang Format
if: matrix.clang_format == 'ON'
run: find source \( -name *.h -o -name *.cpp -o -name *.mm \) ! -path "*/External/*" ! -path "*/NanoGUI/*" | xargs clang-format -i --verbose
run: find source \( -name *.h -o -name *.cpp -o -name *.mm -o -name *.inl \) ! -path "*/External/*" ! -path "*/NanoGUI/*" | xargs clang-format -i --verbose

- name: CMake Generate
run: cmake -S . -B build -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON -DMATERIALX_TEST_RENDER=OFF -DMATERIALX_WARNINGS_AS_ERRORS=ON ${{matrix.cmake_config}}

- name: CMake Build
run: cmake --build . --target install --config Release --parallel 2
working-directory: build
run: cmake --build build --target install --config Release --parallel 2

- name: CMake Unit Tests
run: ctest -VV --output-on-failure --build-config Release
Expand Down Expand Up @@ -314,8 +313,7 @@ jobs:

- name: JavaScript CMake Build
if: matrix.build_javascript == 'ON'
run: cmake --build . --target install --config Release --parallel 2
working-directory: javascript/build
run: cmake --build javascript/build --target install --config Release --parallel 2

- name: JavaScript Unit Tests
if: matrix.build_javascript == 'ON'
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXCore/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ InterfaceElementPtr NodeDef::getImplementation(const string& target) const
}
}
}

// Then search for a generic match.
for (InterfaceElementPtr interface : interfaces)
{
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXFormat/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ FileSearchPath getDefaultDataSearchPath()
}
currentPath = currentPath.getParentPath();
}
return FileSearchPath();
return FileSearchPath();
}

MATERIALX_NAMESPACE_END
2 changes: 1 addition & 1 deletion source/MaterialXFormat/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ MX_FORMAT_API FileSearchPath getSourceSearchPath(ConstDocumentPtr doc);

/// Return a file search path to the default data library folder.
/// The module path and all parent paths are examined to until either there is
/// no parent or the library folder is found.
/// no parent or the library folder is found.
MX_FORMAT_API FileSearchPath getDefaultDataSearchPath();

MATERIALX_NAMESPACE_END
Expand Down
20 changes: 10 additions & 10 deletions source/MaterialXGenGlsl/GlslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ GlslShaderGenerator::GlslShaderGenerator() :
//

StringVec elementNames;

// <!-- <switch> -->
elementNames = {
// <!-- 'which' type : float -->
"IM_switch_float_" + GlslShaderGenerator::TARGET,
"IM_switch_color3_" + GlslShaderGenerator::TARGET,
"IM_switch_color4_" + GlslShaderGenerator::TARGET,
"IM_switch_float_" + GlslShaderGenerator::TARGET,
"IM_switch_color3_" + GlslShaderGenerator::TARGET,
"IM_switch_color4_" + GlslShaderGenerator::TARGET,
"IM_switch_vector2_" + GlslShaderGenerator::TARGET,
"IM_switch_vector3_" + GlslShaderGenerator::TARGET,
"IM_switch_vector4_" + GlslShaderGenerator::TARGET,

// <!-- 'which' type : integer -->
"IM_switch_floatI_" + GlslShaderGenerator::TARGET,
"IM_switch_color3I_" + GlslShaderGenerator::TARGET,
Expand All @@ -85,39 +85,39 @@ GlslShaderGenerator::GlslShaderGenerator() :
"IM_swizzle_float_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_float_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_float_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : color3 -->
"IM_swizzle_color3_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_color3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_color4_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color3_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : color4 -->
"IM_swizzle_color4_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_color3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_color4_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_color4_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : vector2 -->
"IM_swizzle_vector2_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_color3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_color4_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector2_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : vector3 -->
"IM_swizzle_vector3_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_color3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_color4_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_vector2_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_vector3_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector3_vector4_" + GlslShaderGenerator::TARGET,

// <!-- from type : vector4 -->
"IM_swizzle_vector4_float_" + GlslShaderGenerator::TARGET,
"IM_swizzle_vector4_color3_" + GlslShaderGenerator::TARGET,
Expand Down
6 changes: 3 additions & 3 deletions source/MaterialXGenMdl/MdlShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ ShaderPtr MdlShaderGenerator::generate(const string& name, ElementPtr element, G
{
emitLine("float3 displacement__ = " + result + ".geometry.displacement", stage);
emitLine("color finalOutput__ = mk_color3("
"r: math::dot(displacement__, state::texture_tangent_u(0)),"
"g: math::dot(displacement__, state::texture_tangent_v(0)),"
"b: math::dot(displacement__, state::normal()))", stage);
"r: math::dot(displacement__, state::texture_tangent_u(0)),"
"g: math::dot(displacement__, state::texture_tangent_v(0)),"
"b: math::dot(displacement__, state::normal()))", stage);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMdl/MdlSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MdlFilenameTypeSyntax : public ScalarTypeSyntax
// assuming it ends with a slash ...
if (outputValue.back() == '/')
{
return getDefaultValue(true);
return getDefaultValue(true);
}
// ... or the last segment does not have an extension suffix
size_t idx_s = outputValue.find_last_of('/');
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMdl/Nodes/ClosureCompoundNodeMdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void ClosureCompoundNodeMdl::emitFunctionDefinition(const ShaderNode& node, GenC
{
if (!outputSocket->getConnection())
continue;

const ShaderNode* upstream = outputSocket->getConnection()->getNode();
const bool isMaterialExpr = (upstream->hasClassification(ShaderNode::Classification::CLOSURE) ||
upstream->hasClassification(ShaderNode::Classification::SHADER));
Expand Down
24 changes: 12 additions & 12 deletions source/MaterialXGenMdl/Nodes/ClosureLayerNodeMdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ const string& MixBsdfNodeMdl::getOperatorName(size_t index) const
{
switch (index)
{
case 0:
return StringConstantsMdl::FG;
case 1:
return StringConstantsMdl::BG;
default:
return StringConstantsMdl::EMPTY;
case 0:
return StringConstantsMdl::FG;
case 1:
return StringConstantsMdl::BG;
default:
return StringConstantsMdl::EMPTY;
}
}

Expand All @@ -386,12 +386,12 @@ const string& AddOrMultiplyBsdfNodeMdl::getOperatorName(size_t index) const
{
switch (index)
{
case 0:
return StringConstantsMdl::IN1;
case 1:
return StringConstantsMdl::IN2;
default:
return StringConstantsMdl::EMPTY;
case 0:
return StringConstantsMdl::IN1;
case 1:
return StringConstantsMdl::IN2;
default:
return StringConstantsMdl::EMPTY;
}
}

Expand Down
16 changes: 8 additions & 8 deletions source/MaterialXGenMdl/Nodes/ClosureLayerNodeMdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ class MX_GENMDL_API StringConstantsMdl

public:
/// String constants
static const string TOP; ///< layer parameter name of the top component
static const string TOP; ///< layer parameter name of the top component
static const string BASE; ///< layer parameter name of the base component
static const string FG; ///< parameter of the mix node
static const string BG; ///< parameter of the mix node
static const string IN1; ///< parameter of the add and multiply nodes
static const string IN2; ///< parameter of the add and multiply nodes
static const string FG; ///< parameter of the mix node
static const string BG; ///< parameter of the mix node
static const string IN1; ///< parameter of the add and multiply nodes
static const string IN2; ///< parameter of the add and multiply nodes

static const string THICKNESS; ///< thickness parameter name of the thin_film_bsdf
static const string IOR; ///< ior parameter name of the thin_film_bsdf
static const string IOR; ///< ior parameter name of the thin_film_bsdf

static const string THIN_FILM_THICKNESS; ///< helper parameter name for transporting thickness
static const string THIN_FILM_IOR; ///< helper parameter name for transporting ior
static const string THIN_FILM_IOR; ///< helper parameter name for transporting ior

static const string EMPTY; ///< the empty string ""
};
Expand All @@ -41,7 +41,7 @@ class MX_GENMDL_API StringConstantsMdl
/// thin_film_bsdf through layers and mixers, etc., to the elemental bsdfs that support thin film.
/// Because thin-film can not be layered on any BSDF in MDL, we try to push down the parameters to
/// the nodes that support thin-film.
template<typename TBase> class CarryThinFilmParameters : public TBase
template <typename TBase> class CarryThinFilmParameters : public TBase
{
public:
/// Add the thin film inputs for transporting the parameter.
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMsl/MslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ void MslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& co
emitLightData(context, stage);
}
}

bool needsLightBuffer = lighting && context.getOptions().hwMaxActiveLightSources > 0;

emitMathMatrixScalarMathOperators(context, stage);
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenOsl/OslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ void OslShaderGenerator::emitShaderInputs(const VariableBlock& inputs, ShaderSta
// which is a struct containing a file string and a colorspace string.
// For the published shader interface we here split this into two separate inputs,
// which gives a nicer shader interface with widget metadata on each input.

ValuePtr value = input->getValue();
const string valueStr = value ? value->getValueString() : EMPTY_STRING;

Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXGenShader/HwShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element
if (geomprop)
{
// A default geomprop was assigned to this graph input.
// For all internal connections to this input, break the connection
// For all internal connections to this input, break the connection
// and assign a geomprop node that generates this data.
// Note: If a geomprop node exists already it is reused,
// Note: If a geomprop node exists already it is reused,
// so only a single node per geometry type is created.
ShaderInputVec connections = socket->getConnections();
for (auto connection : connections)
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/Nodes/HwTransformNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const string HwTransformNode::WORLD = "world";

void HwTransformNode::createVariables(const ShaderNode& node, GenContext&, Shader& shader) const
{
const string toSpace = getToSpace(node);
const string toSpace = getToSpace(node);
const string fromSpace = getFromSpace(node);
const string& matrix = getMatrix(fromSpace, toSpace);
if (!matrix.empty())
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/ShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void ShaderGenerator::registerImplementation(const string& name, CreatorFunction

void ShaderGenerator::registerImplementation(const StringVec& nameVec, CreatorFunction<ShaderNodeImpl> creator)
{
for(const string& name : nameVec)
for (const string& name : nameVec)
{
_implFactory.registerClass(name, creator);
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/ShaderGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class MX_GENSHADER_API ShaderGenerator

/// Register a shader node implementation for a given implementation element name
void registerImplementation(const string& name, CreatorFunction<ShaderNodeImpl> creator);

/// Register a shader node implementation for a given set of implementation element names
void registerImplementation(const StringVec& nameVec, CreatorFunction<ShaderNodeImpl> creator);

Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/ShaderNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ ShaderNodePtr ShaderNode::create(const ShaderGraph* parent, const string& name,
else if (nodeDef.getNodeString() == CONSTANT)
{
newNode->_classification = Classification::TEXTURE | Classification::CONSTANT;
}
}
else if (nodeDef.getNodeString() == DOT)
{
newNode->_classification = Classification::TEXTURE | Classification::DOT;
Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXGenShader/ShaderStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ ShaderPort* VariableBlock::add(const TypeDesc* type, const string& name, ValuePt
else if (type != it->second->getType())
{
throw ExceptionShaderGenError("Trying to add shader port '" + name + "' with type '" +
type->getName() + "', but existing shader port with type '" +
it->second->getType()->getName() + "' was found");
type->getName() + "', but existing shader port with type '" +
it->second->getType()->getName() + "' was found");
}
return it->second.get();
}
Expand Down
6 changes: 3 additions & 3 deletions source/MaterialXGraphEditor/FileDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class FileDialog
public:
enum Flags
{
SelectDirectory = 1 << 0, // select directory instead of regular file
EnterNewFilename = 1 << 1, // allow user to enter new filename when selecting regular file
NoTitleBar = 1 << 2, // hide window title bar
SelectDirectory = 1 << 0, // select directory instead of regular file
EnterNewFilename = 1 << 1, // allow user to enter new filename when selecting regular file
NoTitleBar = 1 << 2, // hide window title bar
};

public:
Expand Down
3 changes: 1 addition & 2 deletions source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2620,7 +2620,6 @@ void Graph::addLink(ed::PinId startPinId, ed::PinId endPinId)
break;
}
}

}

// Since we accepted new link, lets add one to our list of links.
Expand Down Expand Up @@ -3668,7 +3667,7 @@ void Graph::addNodePopup(bool cursor)
// Filter extra nodes - includes inputs, outputs, groups, and node graphs
const std::string NODEGRAPH_ENTRY = "Node Graph";

// Filter nodedefs and add to menu if matches filter
// Filter nodedefs and add to menu if matches filter
for (auto node : _nodesToAdd)
{
// Filter out list of nodes
Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXGraphEditor/RenderView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void RenderView::loadMesh(const mx::FilePath& filename)
_cameraTarget = mx::Vector3();

initCamera();

if (_shadowMap)
{
_imageHandler->releaseRenderResources(_shadowMap);
Expand Down Expand Up @@ -848,7 +848,7 @@ void RenderView::initCamera()
{
_viewCamera->setViewportSize(mx::Vector2((float) _viewWidth, (float) _viewHeight));

if ( _geometryHandler->getMeshes().empty())
if (_geometryHandler->getMeshes().empty())
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGraphEditor/UiNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class UiPin
{
if (_connections[i]->_pinId == pin->_pinId)
{
_connections.erase(_connections.begin()+i);
_connections.erase(_connections.begin() + i);
}
}
for (size_t i = 0; i < pin->_connections.size(); i++)
Expand Down
8 changes: 4 additions & 4 deletions source/MaterialXRender/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Matrix44 Camera::createViewMatrix(const Vector3& eye,
}

Matrix44 Camera::createPerspectiveMatrixZP(float left, float right,
float bottom, float top,
float nearP, float farP)
float bottom, float top,
float nearP, float farP)
{
return Matrix44(
(2.0f * nearP) / (right - left), 0.0f, (right + left) / (right - left), 0.0f,
Expand All @@ -34,8 +34,8 @@ Matrix44 Camera::createPerspectiveMatrixZP(float left, float right,
}

Matrix44 Camera::createOrthographicMatrixZP(float left, float right,
float bottom, float top,
float nearP, float farP)
float bottom, float top,
float nearP, float farP)
{
return Matrix44(
2.0f / (right - left), 0.0f, 0.0f, 0.0f,
Expand Down
Loading

0 comments on commit 4bdfb7f

Please sign in to comment.