Skip to content

Commit 47300fd

Browse files
author
devsh
committed
make all Frontend children mandatory unless stated otherwise
1 parent 82c53d1 commit 47300fd

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

include/nbl/asset/material_compiler3/CFrontendIR.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,18 @@ class CFrontendIR : public CNodePool
265265
bool isBTDF;
266266
// there's space for 7 more bools
267267
};
268-
virtual inline bool invalid(const SInvalidCheckArgs&) const {return false;}
268+
// by default all children are mandatory
269+
virtual inline bool invalid(const SInvalidCheckArgs& args) const
270+
{
271+
const auto childCount = getChildCount();
272+
for (uint8_t i=0u; i<childCount; i++)
273+
if (const auto childHandle=getChildHandle_impl(i); !childHandle)
274+
{
275+
args.logger.log("Default `IExprNode::invalid` child #%u missing!",system::ILogger::ELL_ERROR,i);
276+
return true;
277+
}
278+
return false;
279+
}
269280
virtual _TypedHandle<IExprNode> getChildHandle_impl(const uint8_t ix) const = 0;
270281

271282
virtual inline core::string getLabelSuffix() const {return "";}
@@ -481,6 +492,7 @@ class CFrontendIR : public CNodePool
481492
{
482493
protected:
483494
inline TypedHandle<IExprNode> getChildHandle_impl(const uint8_t ix) const override final {return ix ? (ix!=1 ? extinction:transmittance):reflectance;}
495+
NBL_API bool invalid(const SInvalidCheckArgs& args) const override;
484496
inline void printDot(std::ostringstream& sstr, const core::string& selfID) const override
485497
{
486498
sstr << "\n\t" << selfID << " -> " << selfID << "_computeTransmittance [label=\"computeTransmittance = " << (computeTransmittance ? "true":"false") << "\"]";

src/nbl/asset/material_compiler3/CFrontendIR.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,30 @@ bool CFrontendIR::CFresnel::invalid(const SInvalidCheckArgs& args) const
5757
}
5858
}
5959
}
60-
else
60+
else if (orientedImagEta)
6161
{
6262
args.logger.log("Oriented Imaginary Eta node of correct type must be attached, but is %u of type %s",ELL_ERROR,orientedImagEta,args.pool->getTypeName(orientedImagEta).data());
6363
return true;
6464
}
6565
return false;
6666
}
6767

68+
bool CFrontendIR::CThinInfiniteScatterCorrection::invalid(const SInvalidCheckArgs& args) const
69+
{
70+
if (!args.pool->deref(reflectance))
71+
{
72+
args.logger.log("Reflectance node of correct type must be attached, but is %u of type %s",ELL_ERROR,reflectance,args.pool->getTypeName(reflectance).data());
73+
return true;
74+
}
75+
if (!args.pool->deref(transmittance))
76+
{
77+
args.logger.log("Reflectance node of correct type must be attached, but is %u of type %s",ELL_ERROR,transmittance,args.pool->getTypeName(transmittance).data());
78+
return true;
79+
}
80+
// TODO: check extinction
81+
return false;
82+
}
83+
6884
bool CFrontendIR::COrenNayar::invalid(const SInvalidCheckArgs& args) const
6985
{
7086
if (!ndParams)

0 commit comments

Comments
 (0)