Cleanup: Remove ptr For Owned Children.
This commit is contained in:
parent
930b8a3932
commit
6524ceb8cf
Notes:
blender-bot
2023-02-14 08:38:11 +01:00
Referenced by issue #87292, "File Output" node does not saves anything Referenced by issue #87252, 2.93 file output node broken with more than 4 inputs
|
@ -39,38 +39,24 @@ NodeOperation::NodeOperation()
|
|||
this->m_btree = nullptr;
|
||||
}
|
||||
|
||||
NodeOperation::~NodeOperation()
|
||||
NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index)
|
||||
{
|
||||
while (!this->m_outputs.is_empty()) {
|
||||
delete (this->m_outputs.pop_last());
|
||||
}
|
||||
while (!this->m_inputs.is_empty()) {
|
||||
delete (this->m_inputs.pop_last());
|
||||
}
|
||||
return &m_outputs[index];
|
||||
}
|
||||
|
||||
NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index) const
|
||||
NodeOperationInput *NodeOperation::getInputSocket(unsigned int index)
|
||||
{
|
||||
BLI_assert(index < m_outputs.size());
|
||||
return m_outputs[index];
|
||||
}
|
||||
|
||||
NodeOperationInput *NodeOperation::getInputSocket(unsigned int index) const
|
||||
{
|
||||
BLI_assert(index < m_inputs.size());
|
||||
return m_inputs[index];
|
||||
return &m_inputs[index];
|
||||
}
|
||||
|
||||
void NodeOperation::addInputSocket(DataType datatype, ResizeMode resize_mode)
|
||||
{
|
||||
NodeOperationInput *socket = new NodeOperationInput(this, datatype, resize_mode);
|
||||
m_inputs.append(socket);
|
||||
m_inputs.append(NodeOperationInput(this, datatype, resize_mode));
|
||||
}
|
||||
|
||||
void NodeOperation::addOutputSocket(DataType datatype)
|
||||
{
|
||||
NodeOperationOutput *socket = new NodeOperationOutput(this, datatype);
|
||||
m_outputs.append(socket);
|
||||
m_outputs.append(NodeOperationOutput(this, datatype));
|
||||
}
|
||||
|
||||
void NodeOperation::determineResolution(unsigned int resolution[2],
|
||||
|
@ -79,11 +65,12 @@ void NodeOperation::determineResolution(unsigned int resolution[2],
|
|||
unsigned int temp[2];
|
||||
unsigned int temp2[2];
|
||||
|
||||
// TODO(jbakker): Replace for loops with direct array access.
|
||||
for (unsigned int index = 0; index < m_inputs.size(); index++) {
|
||||
NodeOperationInput *input = m_inputs[index];
|
||||
if (input->isConnected()) {
|
||||
NodeOperationInput &input = m_inputs[index];
|
||||
if (input.isConnected()) {
|
||||
if (index == this->m_resolutionInputSocketIndex) {
|
||||
input->determineResolution(resolution, preferredResolution);
|
||||
input.determineResolution(resolution, preferredResolution);
|
||||
temp2[0] = resolution[0];
|
||||
temp2[1] = resolution[1];
|
||||
break;
|
||||
|
@ -91,14 +78,15 @@ void NodeOperation::determineResolution(unsigned int resolution[2],
|
|||
}
|
||||
}
|
||||
for (unsigned int index = 0; index < m_inputs.size(); index++) {
|
||||
NodeOperationInput *input = m_inputs[index];
|
||||
if (input->isConnected()) {
|
||||
NodeOperationInput &input = m_inputs[index];
|
||||
if (input.isConnected()) {
|
||||
if (index != this->m_resolutionInputSocketIndex) {
|
||||
input->determineResolution(temp, temp2);
|
||||
input.determineResolution(temp, temp2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeOperation::setResolutionInputSocketIndex(unsigned int index)
|
||||
{
|
||||
this->m_resolutionInputSocketIndex = index;
|
||||
|
|
|
@ -37,9 +37,6 @@ class OpenCLDevice;
|
|||
class ReadBufferOperation;
|
||||
class WriteBufferOperation;
|
||||
|
||||
class NodeOperationInput;
|
||||
class NodeOperationOutput;
|
||||
|
||||
class NodeOperation;
|
||||
typedef NodeOperation SocketReader;
|
||||
|
||||
|
@ -73,6 +70,99 @@ enum class PixelSampler {
|
|||
Bicubic = 2,
|
||||
};
|
||||
|
||||
class NodeOperationInput {
|
||||
private:
|
||||
NodeOperation *m_operation;
|
||||
|
||||
/** Datatype of this socket. Is used for automatically data transformation.
|
||||
* \section data-conversion
|
||||
*/
|
||||
DataType m_datatype;
|
||||
|
||||
/** Resize mode of this socket */
|
||||
ResizeMode m_resizeMode;
|
||||
|
||||
/** Connected output */
|
||||
NodeOperationOutput *m_link;
|
||||
|
||||
public:
|
||||
NodeOperationInput(NodeOperation *op,
|
||||
DataType datatype,
|
||||
ResizeMode resizeMode = ResizeMode::Center);
|
||||
|
||||
NodeOperation &getOperation() const
|
||||
{
|
||||
return *m_operation;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
return m_datatype;
|
||||
}
|
||||
|
||||
void setLink(NodeOperationOutput *link)
|
||||
{
|
||||
m_link = link;
|
||||
}
|
||||
NodeOperationOutput *getLink() const
|
||||
{
|
||||
return m_link;
|
||||
}
|
||||
bool isConnected() const
|
||||
{
|
||||
return m_link;
|
||||
}
|
||||
|
||||
void setResizeMode(ResizeMode resizeMode)
|
||||
{
|
||||
this->m_resizeMode = resizeMode;
|
||||
}
|
||||
ResizeMode getResizeMode() const
|
||||
{
|
||||
return this->m_resizeMode;
|
||||
}
|
||||
|
||||
SocketReader *getReader();
|
||||
|
||||
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
|
||||
#endif
|
||||
};
|
||||
|
||||
class NodeOperationOutput {
|
||||
private:
|
||||
NodeOperation *m_operation;
|
||||
|
||||
/** Datatype of this socket. Is used for automatically data transformation.
|
||||
* \section data-conversion
|
||||
*/
|
||||
DataType m_datatype;
|
||||
|
||||
public:
|
||||
NodeOperationOutput(NodeOperation *op, DataType datatype);
|
||||
|
||||
NodeOperation &getOperation() const
|
||||
{
|
||||
return *m_operation;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
return m_datatype;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief determine the resolution of this data going through this socket
|
||||
* \param resolution: the result of this operation
|
||||
* \param preferredResolution: the preferable resolution as no resolution could be determined
|
||||
*/
|
||||
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief NodeOperation contains calculation logic
|
||||
*
|
||||
|
@ -81,8 +171,8 @@ enum class PixelSampler {
|
|||
*/
|
||||
class NodeOperation {
|
||||
private:
|
||||
blender::Vector<NodeOperationInput *> m_inputs;
|
||||
blender::Vector<NodeOperationOutput *> m_outputs;
|
||||
blender::Vector<NodeOperationInput> m_inputs;
|
||||
blender::Vector<NodeOperationOutput> m_outputs;
|
||||
|
||||
/**
|
||||
* \brief the index of the input socket that will be used to determine the resolution
|
||||
|
@ -136,7 +226,9 @@ class NodeOperation {
|
|||
unsigned int m_height;
|
||||
|
||||
public:
|
||||
virtual ~NodeOperation();
|
||||
virtual ~NodeOperation()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int getNumberOfInputSockets() const
|
||||
{
|
||||
|
@ -146,12 +238,12 @@ class NodeOperation {
|
|||
{
|
||||
return m_outputs.size();
|
||||
}
|
||||
NodeOperationOutput *getOutputSocket(unsigned int index) const;
|
||||
NodeOperationOutput *getOutputSocket() const
|
||||
NodeOperationOutput *getOutputSocket(unsigned int index);
|
||||
NodeOperationOutput *getOutputSocket()
|
||||
{
|
||||
return getOutputSocket(0);
|
||||
}
|
||||
NodeOperationInput *getInputSocket(unsigned int index) const;
|
||||
NodeOperationInput *getInputSocket(unsigned int index);
|
||||
|
||||
/** Check if this is an input operation
|
||||
* An input operation is an operation that only has output sockets and no input sockets
|
||||
|
@ -430,7 +522,7 @@ class NodeOperation {
|
|||
* Return the meta data associated with this branch.
|
||||
*
|
||||
* The return parameter holds an instance or is an nullptr. */
|
||||
virtual std::unique_ptr<MetaData> getMetaData() const
|
||||
virtual std::unique_ptr<MetaData> getMetaData()
|
||||
{
|
||||
return std::unique_ptr<MetaData>();
|
||||
}
|
||||
|
@ -529,96 +621,3 @@ class NodeOperation {
|
|||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
|
||||
#endif
|
||||
};
|
||||
|
||||
class NodeOperationInput {
|
||||
private:
|
||||
NodeOperation *m_operation;
|
||||
|
||||
/** Datatype of this socket. Is used for automatically data transformation.
|
||||
* \section data-conversion
|
||||
*/
|
||||
DataType m_datatype;
|
||||
|
||||
/** Resize mode of this socket */
|
||||
ResizeMode m_resizeMode;
|
||||
|
||||
/** Connected output */
|
||||
NodeOperationOutput *m_link;
|
||||
|
||||
public:
|
||||
NodeOperationInput(NodeOperation *op,
|
||||
DataType datatype,
|
||||
ResizeMode resizeMode = ResizeMode::Center);
|
||||
|
||||
NodeOperation &getOperation() const
|
||||
{
|
||||
return *m_operation;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
return m_datatype;
|
||||
}
|
||||
|
||||
void setLink(NodeOperationOutput *link)
|
||||
{
|
||||
m_link = link;
|
||||
}
|
||||
NodeOperationOutput *getLink() const
|
||||
{
|
||||
return m_link;
|
||||
}
|
||||
bool isConnected() const
|
||||
{
|
||||
return m_link;
|
||||
}
|
||||
|
||||
void setResizeMode(ResizeMode resizeMode)
|
||||
{
|
||||
this->m_resizeMode = resizeMode;
|
||||
}
|
||||
ResizeMode getResizeMode() const
|
||||
{
|
||||
return this->m_resizeMode;
|
||||
}
|
||||
|
||||
SocketReader *getReader();
|
||||
|
||||
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
|
||||
#endif
|
||||
};
|
||||
|
||||
class NodeOperationOutput {
|
||||
private:
|
||||
NodeOperation *m_operation;
|
||||
|
||||
/** Datatype of this socket. Is used for automatically data transformation.
|
||||
* \section data-conversion
|
||||
*/
|
||||
DataType m_datatype;
|
||||
|
||||
public:
|
||||
NodeOperationOutput(NodeOperation *op, DataType datatype);
|
||||
|
||||
NodeOperation &getOperation() const
|
||||
{
|
||||
return *m_operation;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
return m_datatype;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief determine the resolution of this data going through this socket
|
||||
* \param resolution: the result of this operation
|
||||
* \param preferredResolution: the preferable resolution as no resolution could be determined
|
||||
*/
|
||||
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -49,7 +49,7 @@ ImBuf *MultilayerBaseOperation::getImBuf()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<MetaData> MultilayerColorOperation::getMetaData() const
|
||||
std::unique_ptr<MetaData> MultilayerColorOperation::getMetaData()
|
||||
{
|
||||
BLI_assert(this->m_buffer);
|
||||
MetaDataExtractCallbackData callback_data = {nullptr};
|
||||
|
|
|
@ -45,7 +45,7 @@ class MultilayerColorOperation : public MultilayerBaseOperation {
|
|||
this->addOutputSocket(DataType::Color);
|
||||
}
|
||||
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
std::unique_ptr<MetaData> getMetaData() const override;
|
||||
std::unique_ptr<MetaData> getMetaData() override;
|
||||
};
|
||||
|
||||
class MultilayerValueOperation : public MultilayerBaseOperation {
|
||||
|
|
|
@ -216,7 +216,7 @@ void RenderLayersProg::determineResolution(unsigned int resolution[2],
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<MetaData> RenderLayersProg::getMetaData() const
|
||||
std::unique_ptr<MetaData> RenderLayersProg::getMetaData()
|
||||
{
|
||||
Scene *scene = this->getScene();
|
||||
Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr;
|
||||
|
|
|
@ -123,7 +123,7 @@ class RenderLayersProg : public NodeOperation {
|
|||
void deinitExecution() override;
|
||||
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
|
||||
std::unique_ptr<MetaData> getMetaData() const override;
|
||||
std::unique_ptr<MetaData> getMetaData() override;
|
||||
};
|
||||
|
||||
class RenderLayersAOOperation : public RenderLayersProg {
|
||||
|
|
|
@ -25,7 +25,7 @@ SocketProxyOperation::SocketProxyOperation(DataType type, bool use_conversion)
|
|||
this->addOutputSocket(type);
|
||||
}
|
||||
|
||||
std::unique_ptr<MetaData> SocketProxyOperation::getMetaData() const
|
||||
std::unique_ptr<MetaData> SocketProxyOperation::getMetaData()
|
||||
{
|
||||
return this->getInputSocket(0)->getReader()->getMetaData();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class SocketProxyOperation : public NodeOperation {
|
|||
{
|
||||
m_use_conversion = use_conversion;
|
||||
}
|
||||
std::unique_ptr<MetaData> getMetaData() const override;
|
||||
std::unique_ptr<MetaData> getMetaData() override;
|
||||
|
||||
private:
|
||||
bool m_use_conversion;
|
||||
|
|
Loading…
Reference in New Issue