Fix #106002: crash when passing field into Switch node when it doesn't support it
Pull Request: https://projects.blender.org/blender/blender/pulls/106006
This commit is contained in:
parent
16b93486ca
commit
b0045cc797
|
@ -145,11 +145,16 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
|
|||
}
|
||||
|
||||
class LazyFunctionForSwitchNode : public LazyFunction {
|
||||
private:
|
||||
bool can_be_field_ = false;
|
||||
|
||||
public:
|
||||
LazyFunctionForSwitchNode(const bNode &node)
|
||||
{
|
||||
const NodeSwitch &storage = node_storage(node);
|
||||
const eNodeSocketDatatype data_type = eNodeSocketDatatype(storage.input_type);
|
||||
can_be_field_ = ELEM(data_type, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_VECTOR, SOCK_RGBA);
|
||||
|
||||
const bNodeSocketType *socket_type = nullptr;
|
||||
for (const bNodeSocket *socket : node.output_sockets()) {
|
||||
if (socket->type == data_type) {
|
||||
|
@ -169,7 +174,7 @@ class LazyFunctionForSwitchNode : public LazyFunction {
|
|||
void execute_impl(lf::Params ¶ms, const lf::Context & /*context*/) const override
|
||||
{
|
||||
const ValueOrField<bool> condition = params.get_input<ValueOrField<bool>>(0);
|
||||
if (condition.is_field()) {
|
||||
if (condition.is_field() && can_be_field_) {
|
||||
Field<bool> condition_field = condition.as_field();
|
||||
if (condition_field.node().depends_on_input()) {
|
||||
this->execute_field(condition.as_field(), params);
|
||||
|
|
Loading…
Reference in New Issue