summaryrefslogtreecommitdiff
path: root/scene/resources/skin.h
blob: a7e55bfa89973dcb16c5a8ef38474f74245376bb (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
#ifndef SKIN_H
#define SKIN_H

#include "core/resource.h"

class Skin : public Resource {
	GDCLASS(Skin, Resource)

	struct Bind {
		int bone;
		Transform pose;
	};

	Vector<Bind> binds;

	Bind *binds_ptr;
	int bind_count;

protected:
	bool _set(const StringName &p_name, const Variant &p_value);
	bool _get(const StringName &p_name, Variant &r_ret) const;
	void _get_property_list(List<PropertyInfo> *p_list) const;

	static void _bind_methods();

public:
	void set_bind_count(int p_size);
	inline int get_bind_count() const { return bind_count; }

	void add_bind(int p_bone, const Transform &p_pose);

	void set_bind_bone(int p_index, int p_bone);
	void set_bind_pose(int p_index, const Transform &p_pose);

	inline int get_bind_bone(int p_index) const {
#ifdef DEBUG_ENABLED
		ERR_FAIL_INDEX_V(p_index, bind_count, -1);
#endif
		return binds_ptr[p_index].bone;
	}

	inline Transform get_bind_pose(int p_index) const {
#ifdef DEBUG_ENABLED
		ERR_FAIL_INDEX_V(p_index, bind_count, Transform());
#endif
		return binds_ptr[p_index].pose;
	}

	void clear_binds();

	Skin();
};

#endif // SKIN_H