Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lazy_function.cc « intern « functions « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 46572283e9bcf4c563128f4c01c414bee1fe60f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* SPDX-License-Identifier: GPL-2.0-or-later */

/** \file
 * \ingroup fn
 */

#include "BLI_array.hh"

#include "FN_lazy_function.hh"

namespace blender::fn::lazy_function {

std::string LazyFunction::name() const
{
  return debug_name_;
}

std::string LazyFunction::input_name(int index) const
{
  return inputs_[index].debug_name;
}

std::string LazyFunction::output_name(int index) const
{
  return outputs_[index].debug_name;
}

void *LazyFunction::init_storage(LinearAllocator<> &UNUSED(allocator)) const
{
  return nullptr;
}

void LazyFunction::destruct_storage(void *storage) const
{
  BLI_assert(storage == nullptr);
  UNUSED_VARS_NDEBUG(storage);
}

bool LazyFunction::always_used_inputs_available(const Params &params) const
{
  for (const int i : inputs_.index_range()) {
    const Input &fn_input = inputs_[i];
    if (fn_input.usage == ValueUsage::Used) {
      if (params.try_get_input_data_ptr(i) == nullptr) {
        return false;
      }
    }
  }
  return true;
}

void Params::set_default_remaining_outputs()
{
  for (const int i : fn_.outputs().index_range()) {
    if (this->output_was_set(i)) {
      continue;
    }
    const Output &fn_output = fn_.outputs()[i];
    const CPPType &type = *fn_output.type;
    void *data_ptr = this->get_output_data_ptr(i);
    type.value_initialize(data_ptr);
    this->output_set(i);
  }
}

}  // namespace blender::fn::lazy_function