Blender V5.3
IO_dupli_persistent_id.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BKE_duplilist.hh"
12
13#include <array>
14#include <cstdint>
15#include <string>
16
17namespace blender::io {
18
19/* Wrapper for DupliObject::persistent_id that can act as a map key. */
21 protected:
22 constexpr static int array_length_ = MAX_DUPLI_RECUR;
23 using PIDArray = std::array<int, array_length_>;
25
26 explicit PersistentID(const PIDArray &persistent_id_values);
27
28 public:
30 explicit PersistentID(const DupliObject *dupli_ob);
31
32 /* Return true if the persistent IDs are the same, ignoring the first digit. */
33 bool is_from_same_instancer_as(const PersistentID &other) const;
34
35 /* Construct the persistent ID of this instance's instancer. */
37
38 /* Construct a string representation by reversing the persistent ID.
39 * In case of a duplicator that is duplicated itself as well, this
40 * results in strings like:
41 * "3" for the duplicated duplicator, and
42 * "3-0", "3-1", etc. for its duplis. */
43 std::string as_object_name_suffix() const;
44
45 uint64_t hash() const;
46
47 friend bool operator==(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b);
48
49 private:
50 void copy_values_from(const PIDArray &persistent_id_values);
51};
52
53} // namespace blender::io
friend bool operator==(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b)
PersistentID(const PIDArray &persistent_id_values)
std::array< int, array_length_ > PIDArray
PersistentID instancer_pid() const
std::string as_object_name_suffix() const
bool is_from_same_instancer_as(const PersistentID &other) const
unsigned __int64 uint64_t
Definition BKE_text.h:91
constexpr int MAX_DUPLI_RECUR