Blender V5.0
deg_builder_pchanmap.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2015 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include <cstdio>
12#include <cstring>
13
14namespace blender::deg {
15
17{
18 map_.foreach_item([](StringRefNull key, const Set<StringRefNull> &values) {
19 printf(" %s : { ", key.data());
20 for (StringRefNull val : values) {
21 printf("%s, ", val.data());
22 }
23 printf("}\n");
24 });
25}
26
27void RootPChanMap::add_bone(const char *bone, const char *root)
28{
29 map_.lookup_or_add_default(bone).add(root);
30}
31
32bool RootPChanMap::has_common_root(const char *bone1, const char *bone2) const
33{
34 const Set<StringRefNull> *bone1_roots = map_.lookup_ptr(bone1);
35 const Set<StringRefNull> *bone2_roots = map_.lookup_ptr(bone2);
36
37 if (bone1_roots == nullptr) {
38 // fprintf("RootPChanMap: bone1 '%s' not found (%s => %s)\n", bone1, bone1, bone2);
39 // print_debug();
40 return false;
41 }
42
43 if (bone2_roots == nullptr) {
44 // fprintf("RootPChanMap: bone2 '%s' not found (%s => %s)\n", bone2, bone1, bone2);
45 // print_debug();
46 return false;
47 }
48
49 return Set<StringRefNull>::Intersects(*bone1_roots, *bone2_roots);
50}
51
52} // namespace blender::deg
static bool Intersects(const Set &a, const Set &b)
Definition BLI_set.hh:647
constexpr const char * data() const
#define printf(...)
Map< StringRefNull, Set< StringRefNull > > map_
bool has_common_root(const char *bone1, const char *bone2) const
void add_bone(const char *bone, const char *root)