12#include "../ECS/Components/TaskRunnerComponent.h"
13#include "../BlueprintEditor/MathOpOperand.h"
14#include "../system/system_utils.h"
32 return static_cast<float>(
val.AsInt());
36 return val.AsBool() ? 1.0f : 0.0f;
40 throw std::runtime_error(
"Cannot convert TaskValue type to float for math operation");
45 const std::string& op,
53 result = left + right;
57 result = left - right;
61 result = left * right;
65 if (std::fabs(right) < std::numeric_limits<float>::epsilon())
67 throw std::runtime_error(
"Division by zero in MathOp");
69 result = left / right;
73 if (std::fabs(right) < std::numeric_limits<float>::epsilon())
75 throw std::runtime_error(
"Modulo by zero in MathOp");
77 result = std::fmod(left, right);
81 result = std::pow(left, right);
85 throw std::runtime_error(
"Unknown math operator: " + op);
94 const std::string& pinName,
95 const TaskGraphTemplate&
tmpl,
96 TaskRunnerComponent&
runner,
118 for (
size_t i = 0;
i <
tmpl.DataConnections.size(); ++
i)
121 if (
conn.TargetNodeID != nodeID)
139 SYSTEM_LOG <<
"[DataPinEvaluator] Failed to evaluate pin: "
140 <<
conn.SourceNodeID <<
":" <<
conn.SourcePinName
141 <<
" -> " << nodeID <<
":" <<
conn.TargetPinName
142 <<
" (Status: " <<
static_cast<int>(result.
Status) <<
")\n";
147 std::ostringstream
dstKey;
148 dstKey << nodeID <<
":" <<
conn.TargetPinName;
161 const std::string& pinName,
173 result.
ErrorMessage =
"Maximum recursion depth exceeded in data pin network";
182 result.
ErrorMessage =
"Circular dependency detected in data pin network";
201 cacheKey << nodeID <<
":" << pinName;
221 if (
node->BBKey.empty())
233 catch (
const std::exception&
e)
236 result.
ErrorMessage = std::string(
"Failed to read blackboard value: ") +
e.what();
244 if (
node->MathOperator.empty())
247 result.
ErrorMessage =
"MathOp node missing MathOperator";
270 for (
size_t i = 0;
i <
tmpl.DataConnections.size(); ++
i)
273 if (
conn.TargetNodeID == nodeID &&
conn.TargetPinName ==
"A")
301 result.
ErrorMessage =
"No data connection found for MathOp left operand (Pin mode)";
324 for (
size_t i = 0;
i <
tmpl.DataConnections.size(); ++
i)
327 if (
conn.TargetNodeID == nodeID &&
conn.TargetPinName ==
"B")
355 result.
ErrorMessage =
"No data connection found for MathOp right operand (Pin mode)";
371 catch (
const std::exception&
e)
374 result.
ErrorMessage = std::string(
"Math operation failed: ") +
e.what();
382 result.
ErrorMessage =
"Node type does not support data pin evaluation";
ComponentTypeID GetComponentTypeID_Static()
Runtime key-value store for task graph variables.
Immutable asset structure shared by all task graph runners.
static constexpr int32_t MAX_RECURSION_DEPTH
Maximum recursion depth to prevent stack overflow.
static bool EvaluateNodeInputPins(int32_t nodeID, const TaskGraphTemplate &tmpl, TaskRunnerComponent &runner, LocalBlackboard &localBB)
Evaluate all input data pins for a given node before execution.
Simple map-based blackboard for task graph runtime state.
Immutable, shareable task graph asset.
C++14-compliant type-safe value container for task parameters.
< Provides AssetID and INVALID_ASSET_ID
@ Success
Evaluation completed successfully.
@ InvalidNode
Node ID not found in template.
@ EvaluationError
Runtime error during evaluation (e.g., type mismatch)
@ CycleDetected
Circular dependency detected in data pin network.
VariableType
Type tags used by TaskValue to identify stored data.
@ Int
32-bit signed integer
@ Float
Single-precision float.
float DataPinEvaluator_TaskValueToFloat(const TaskValue &val)
TaskValue DataPinEvaluator_ComputeMath(const std::string &op, float left, float right)
@ GetBBValue
Data node – reads a Blackboard key.
@ MathOp
Data node – arithmetic operation (+, -, *, /)
DataPinEvaluationResult DataPinEvaluator_EvaluateRecursive(int32_t nodeID, const std::string &pinName, const TaskGraphTemplate &tmpl, TaskRunnerComponent &runner, LocalBlackboard &localBB, std::unordered_set< int32_t > &visitedNodes, int32_t recursionDepth)
Explicit connection between an output data pin of a source node and an input data pin of a target nod...
Result of a single data pin evaluation attempt.
@ Variable
References a blackboard variable by name.
@ Const
Literal constant value.
@ Pin
External data-input pin on the owning node.
std::string variableName
Blackboard key (mode == Variable), e.g. "mMoveSpeed".
std::string constValue
Literal string (mode == Const), e.g. "5.0".
Complete reference for a MathOp node: left operand, operator, right operand.
MathOpOperand leftOperand
Left-hand side operand (A)
MathOpOperand rightOperand
Right-hand side operand (B)
Full description of a single node in the task graph.
Per-entity runtime state for task graph execution.