Skip to content

Commit 7560295

Browse files
author
devsh
committed
stop abusing inheritance with IExprLeaf it will just lead to diamond inheritance
1 parent 40300d4 commit 7560295

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

include/nbl/asset/material_compiler3/CFrontendIR.h

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,6 @@ class CFrontendIR : public CNodePool
177177
virtual _TypedHandle<IExprNode> getChildHandle_impl(const uint8_t ix) const = 0;
178178
};
179179

180-
//! Base class for leaf node
181-
class IExprLeaf : public IExprNode
182-
{
183-
public:
184-
inline uint8_t getChildCount() const override final {return 0;}
185-
};
186-
187180
//! Base class for leaf node quantities which contribute additively to the Lighting Integral
188181
class IContributor : public IExprNode
189182
{
@@ -192,9 +185,10 @@ class CFrontendIR : public CNodePool
192185
};
193186

194187
// This node could also represent non directional emission, but we have another node for that
195-
class CSpectralVariable final : public IExprLeaf
188+
class CSpectralVariable final : public IExprNode
196189
{
197190
public:
191+
inline uint8_t getChildCount() const override final { return 0; }
198192
inline const std::string_view getTypeName() const override {return "nbl::CSpectralVariable";}
199193
// Variable length but has no children
200194

@@ -256,6 +250,7 @@ class CFrontendIR : public CNodePool
256250
std::destroy_n(pWonky->knots.params,getKnotCount());
257251
}
258252

253+
inline _TypedHandle<IExprNode> getChildHandle_impl(const uint8_t ix) const override {return {};}
259254
inline bool invalid(const SInvalidCheckArgs& args) const override
260255
{
261256
auto pWonky = reinterpret_cast<const SCreationParams<1>*>(this+1);
@@ -465,13 +460,17 @@ class CFrontendIR : public CNodePool
465460
class CDeltaTransmission final : public IBxDF
466461
{
467462
public:
463+
inline uint8_t getChildCount() const override {return 0;}
468464
inline const std::string_view getTypeName() const override {return "nbl::CDeltaTransmission";}
469465
static inline uint32_t calc_size()
470466
{
471467
return sizeof(CDeltaTransmission);
472468
}
473469
inline uint32_t getSize() const override {return calc_size();}
474470
inline CDeltaTransmission() = default;
471+
472+
protected:
473+
inline _TypedHandle<IExprNode> getChildHandle_impl(const uint8_t ix) const override {return {};}
475474
};
476475
// Because of Schussler et. al 2017 every one of these nodes splits into 2 (if no L dependence) or 3 during canonicalization
477476
class COrenNayar final : public IBxDF
@@ -571,6 +570,22 @@ class CFrontendIR : public CNodePool
571570
protected:
572571
using CNodePool::CNodePool;
573572

573+
inline core::string getNodeID(const TypedHandle<const INode> handle) const {return core::string("_")+std::to_string(handle.untyped.value);}
574+
inline core::string getLabelledNodeID(const TypedHandle<const INode> handle) const
575+
{
576+
const INode* node = deref(handle);
577+
core::string retval = getNodeID(handle);
578+
retval += " [label=\"";
579+
retval += node->getTypeName();
580+
if (const auto* debug=deref(node->debugInfo); debug && !debug->data().empty())
581+
{
582+
retval += "\\n";
583+
retval += std::string_view(reinterpret_cast<const char*>(debug->data().data()),debug->data().size());
584+
}
585+
retval += "\"]";
586+
return retval;
587+
}
588+
574589
core::vector<TypedHandle<const CLayer>> m_rootNodes;
575590
};
576591

0 commit comments

Comments
 (0)