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