5#ifndef __BLENDER_ID_MAP_H__
6#define __BLENDER_ID_MAP_H__
23template<
typename K,
typename T,
typename Flags = u
int>
class id_map {
31 typename map<K, T *>::iterator jt;
32 for (jt =
b_map.begin(); jt !=
b_map.end(); jt++) {
33 nodes.insert(jt->second);
36 scene->delete_nodes(nodes);
80 void add(
const K &key, T *data)
88 bool update(T *data,
const BL::ID &
id)
90 return update(data,
id,
id);
92 bool update(T *data,
const BL::ID &
id,
const BL::ID &parent)
95 if (parent.ptr.data && parent.ptr.data !=
id.ptr.data) {
111 bool add_or_update(T **r_data,
const BL::ID &
id,
const BL::ID &parent,
const K &key)
118 data = scene->create_node<T>();
124 recalc =
update(data,
id, parent);
153 typedef pair<const K, T *> TMapPair;
154 typename map<K, T *>::iterator jt;
156 for (jt =
b_map.begin(); jt !=
b_map.end(); jt++) {
157 TMapPair &pair = *jt;
160 flags.erase(pair.second);
161 scene->delete_node(pair.second);
164 new_map[pair.first] = pair.second;
180 typename map<T *, uint>::iterator it =
flags.find(data);
181 return it !=
flags.end() && (it->second & (1 << val)) != 0;
191 typename map<T *, uint>::iterator it =
flags.find(data);
192 if (it !=
flags.end()) {
193 it->second &= ~(1 << val);
195 if (it->second == 0) {
226 memcpy(
id, id_,
sizeof(
id));
229 memset(
id, 0,
sizeof(
id));
238 else if (
ob == k.
ob) {
247 return memcmp(
id, k.
id,
sizeof(
id)) < 0;
272 else if (
id == k.
id) {
291 memcpy(
id, id_,
sizeof(
id));
294 memset(
id, 0,
sizeof(
id));
304 else if (
ob == k.
ob) {
bool update(T *data, const BL::ID &id, const BL::ID &parent)
bool check_recalc(const BL::ID &id)
bool add_or_update(T **r_data, const BL::ID &id)
bool test_flag(T *data, Flags val)
void add(const K &key, T *data)
bool is_used(const K &key)
bool add_or_update(T **r_data, const BL::ID &id, const K &key)
bool update(T *data, const BL::ID &id)
void set_recalc(const BL::ID &id)
void set_flag(T *data, Flags val)
T * find(const BL::ID &id)
void set_recalc(void *id_ptr)
bool add_or_update(T **r_data, const BL::ID &id, const BL::ID &parent, const K &key)
void clear_flag(T *data, Flags val)
void post_sync(bool do_delete=true)
void set_default(T *data)
const map< K, T * > & key_to_scene_data()
#define CCL_NAMESPACE_END
@ OBJECT_PERSISTENT_ID_SIZE
GeometryKey(void *id, Geometry::Type geometry_type)
Geometry::Type geometry_type
bool operator<(const GeometryKey &k) const
ObjectKey(void *parent_, int id_[OBJECT_PERSISTENT_ID_SIZE], void *ob_, bool use_particle_hair_)
bool operator<(const ObjectKey &k) const
int id[OBJECT_PERSISTENT_ID_SIZE]
ParticleSystemKey(void *ob_, int id_[OBJECT_PERSISTENT_ID_SIZE])
int id[OBJECT_PERSISTENT_ID_SIZE]
bool operator<(const ParticleSystemKey &k) const