fix: RGBA8 node not setting outputs correctly, added buffer output

This commit is contained in:
WerWolv 2024-01-09 09:49:07 +01:00
parent d43f25ec70
commit 4668f429fb
2 changed files with 18 additions and 6 deletions

View File

@ -259,6 +259,7 @@
"hex.builtin.nodes.constants.rgba8.output.b": "Blue",
"hex.builtin.nodes.constants.rgba8.output.g": "Green",
"hex.builtin.nodes.constants.rgba8.output.r": "Red",
"hex.builtin.nodes.constants.rgba8.output.color": "RGBA8",
"hex.builtin.nodes.constants.string": "String",
"hex.builtin.nodes.constants.string.header": "String",
"hex.builtin.nodes.control_flow": "Control flow",

View File

@ -144,10 +144,13 @@ namespace hex::plugin::builtin {
class NodeRGBA8 : public dp::Node {
public:
NodeRGBA8() : Node("hex.builtin.nodes.constants.rgba8.header",
{ dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.r"),
{
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.r"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.g"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.b"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.a") }) { }
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.a"),
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.constants.rgba8.output.color"),
}) { }
void drawNode() override {
ImGui::PushItemWidth(200_scaled);
@ -156,10 +159,18 @@ namespace hex::plugin::builtin {
}
void process() override {
this->setBufferOnOutput(0, wolv::util::toBytes<u8>(u8(m_color.Value.x * 0xFF)));
this->setBufferOnOutput(1, wolv::util::toBytes<u8>(u8(m_color.Value.y * 0xFF)));
this->setBufferOnOutput(2, wolv::util::toBytes<u8>(u8(m_color.Value.z * 0xFF)));
this->setBufferOnOutput(3, wolv::util::toBytes<u8>(u8(m_color.Value.w * 0xFF)));
this->setIntegerOnOutput(0, u8(m_color.Value.x * 0xFF));
this->setIntegerOnOutput(1, u8(m_color.Value.y * 0xFF));
this->setIntegerOnOutput(2, u8(m_color.Value.z * 0xFF));
this->setIntegerOnOutput(3, u8(m_color.Value.w * 0xFF));
std::array buffer = {
u8(m_color.Value.x * 0xFF),
u8(m_color.Value.y * 0xFF),
u8(m_color.Value.z * 0xFF),
u8(m_color.Value.w * 0xFF)
};
this->setBufferOnOutput(4, buffer);
}
void store(nlohmann::json &j) const override {