connections

connections rendering and logic finished.
can make rendering better in future updates such as using geo shaders for bezier curves and smoother lines.
This commit is contained in:
marauder2k7 2024-03-05 20:39:33 +00:00
parent 66d8f0f55c
commit 949f788a0a
4 changed files with 424 additions and 64 deletions

View file

@ -96,7 +96,7 @@ void GuiShaderNode::onRemove()
Parent::onRemove();
}
void GuiShaderNode::onRender(Point2I offset, const RectI& updateRect, const S32 nodeSize)
void GuiShaderNode::renderNode(Point2I offset, const RectI& updateRect, const S32 nodeSize)
{
if (!mProfile)
return Parent::onRender(offset, updateRect);
@ -191,7 +191,7 @@ void GuiShaderNode::onRender(Point2I offset, const RectI& updateRect, const S32
drawer->drawText(mProfile->mFont, slotPos + offset, output->name);
if (output->pos == Point2I::Zero || mPrevNodeSize != nodeSize)
output->pos = Point2I(getExtent().x - (nodeSize / 2), slotPos.y + ((mProfile->mFont->getFontSize() / 2) - (nodeSize / 2)));
output->pos = Point2I(getExtent().x - (nodeSize / 2) - 1 , slotPos.y + ((mProfile->mFont->getFontSize() / 2) - (nodeSize / 2)));
slotPos.y += textPadY;
}

View file

@ -58,31 +58,43 @@ enum class DataDimensions
Mat4x4,
};
struct NodeInput
// parent class for sockets detection in shaderEditor.
struct NodeSocket
{
String name;
DataDimensions dimensions;
NodeSocket()
:name(String::EmptyString), dimensions(DataDimensions::Dynamic)
{}
NodeSocket(String inName, DataDimensions inDim)
:name(inName), dimensions(inDim)
{}
public:
virtual ~NodeSocket() {}
};
struct NodeInput : NodeSocket
{
Point2I pos = Point2I::Zero;
NodeInput()
:name(String::EmptyString), dimensions(DataDimensions::Dynamic)
:NodeSocket()
{}
NodeInput(String inName , DataDimensions inDim)
:name(inName), dimensions(inDim)
:NodeSocket(inName , inDim)
{}
};
struct NodeOutput
struct NodeOutput : NodeSocket
{
String name;
DataDimensions dimensions;
Point2I pos = Point2I::Zero;
NodeOutput()
:name(String::EmptyString), dimensions(DataDimensions::Dynamic)
:NodeSocket()
{}
NodeOutput(String inName, DataDimensions inDim)
:name(inName), dimensions(inDim)
:NodeSocket(inName, inDim)
{}
};
@ -107,8 +119,7 @@ public:
virtual bool onAdd() override;
virtual void onRemove() override;
void onRender(Point2I offset, const RectI& updateRect, const S32 nodeSize);
void renderNode(Point2I offset, const RectI& updateRect, const S32 nodeSize);
// Serialization functions
void write(Stream& stream, U32 tabStop = 0, U32 flags = 0);
void read(Stream& stream);