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

node_geometry_exec.cc « intern « nodes « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 50292cb8cfbac168bcb16eb873bcc2cd228d1d4c (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include "NOD_geometry_exec.hh"
#include "NOD_type_callbacks.hh"

namespace blender::nodes {

void GeoNodeExecParams::check_extract_input(StringRef identifier,
                                            const CPPType *requested_type) const
{
  bNodeSocket *found_socket = nullptr;
  LISTBASE_FOREACH (bNodeSocket *, socket, &node_.inputs) {
    if (identifier == socket->identifier) {
      found_socket = socket;
      break;
    }
  }
  if (found_socket == nullptr) {
    std::cout << "Did not find an input socket with the identifier '" << identifier << "'.\n";
    std::cout << "Possible identifiers are: ";
    LISTBASE_FOREACH (bNodeSocket *, socket, &node_.inputs) {
      if ((socket->flag & SOCK_UNAVAIL) == 0) {
        std::cout << "'" << socket->identifier << "', ";
      }
    }
    std::cout << "\n";
    BLI_assert(false);
  }
  else if (found_socket->flag & SOCK_UNAVAIL) {
    std::cout << "The socket corresponding to the identifier '" << identifier
              << "' is disabled.\n";
    BLI_assert(false);
  }
  else if (!input_values_.contains(identifier)) {
    std::cout << "The identifier '" << identifier
              << "' is valid, but there is no value for it anymore.\n";
    std::cout << "Most likely it has been extracted before.\n";
    BLI_assert(false);
  }
  else if (requested_type != nullptr) {
    const CPPType &expected_type = *socket_cpp_type_get(*found_socket->typeinfo);
    if (*requested_type != expected_type) {
      std::cout << "The requested type '" << requested_type->name() << "' is incorrect. Expected '"
                << expected_type.name() << "'.\n";
      BLI_assert(false);
    }
  }
}

void GeoNodeExecParams::check_set_output(StringRef identifier, const CPPType &value_type) const
{
  bNodeSocket *found_socket = nullptr;
  LISTBASE_FOREACH (bNodeSocket *, socket, &node_.outputs) {
    if (identifier == socket->identifier) {
      found_socket = socket;
      break;
    }
  }
  if (found_socket == nullptr) {
    std::cout << "Did not find an output socket with the identifier '" << identifier << "'.\n";
    std::cout << "Possible identifiers are: ";
    LISTBASE_FOREACH (bNodeSocket *, socket, &node_.outputs) {
      if ((socket->flag & SOCK_UNAVAIL) == 0) {
        std::cout << "'" << socket->identifier << "', ";
      }
    }
    std::cout << "\n";
    BLI_assert(false);
  }
  else if (found_socket->flag & SOCK_UNAVAIL) {
    std::cout << "The socket corresponding to the identifier '" << identifier
              << "' is disabled.\n";
    BLI_assert(false);
  }
  else if (output_values_.contains(identifier)) {
    std::cout << "The identifier '" << identifier << "' has been set already.\n";
    BLI_assert(false);
  }
  else {
    const CPPType &expected_type = *socket_cpp_type_get(*found_socket->typeinfo);
    if (value_type != expected_type) {
      std::cout << "The value type '" << value_type.name() << "' is incorrect. Expected '"
                << expected_type.name() << "'.\n";
      BLI_assert(false);
    }
  }
}

}  // namespace blender::nodes