Allow renaming bones and blendshapes.
(cherry picked from commit d13568a8d1
)
This commit is contained in:
parent
f8c4ffcdde
commit
11b8b8ad27
8 changed files with 58 additions and 0 deletions
|
@ -97,6 +97,16 @@
|
|||
Will regenerate normal maps for the [ArrayMesh].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_blend_shape_name">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="index" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="name" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="surface_find_by_name" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
|
|
|
@ -212,6 +212,16 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_bone_name">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="bone_idx" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="name" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_bone_parent">
|
||||
<return type="void">
|
||||
</return>
|
||||
|
|
|
@ -440,6 +440,18 @@ String Skeleton::get_bone_name(int p_bone) const {
|
|||
return bones[p_bone].name;
|
||||
}
|
||||
|
||||
void Skeleton::set_bone_name(int p_bone, const String &p_name) {
|
||||
ERR_FAIL_INDEX(p_bone, bones.size());
|
||||
|
||||
for (int i = 0; i < bones.size(); i++) {
|
||||
if (i != p_bone) {
|
||||
ERR_FAIL_COND(bones[i].name == p_name);
|
||||
}
|
||||
}
|
||||
|
||||
bones.write[p_bone].name = p_name;
|
||||
}
|
||||
|
||||
bool Skeleton::is_bone_parent_of(int p_bone, int p_parent_bone_id) const {
|
||||
|
||||
int parent_of_bone = get_bone_parent(p_bone);
|
||||
|
@ -855,6 +867,7 @@ void Skeleton::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("add_bone", "name"), &Skeleton::add_bone);
|
||||
ClassDB::bind_method(D_METHOD("find_bone", "name"), &Skeleton::find_bone);
|
||||
ClassDB::bind_method(D_METHOD("get_bone_name", "bone_idx"), &Skeleton::get_bone_name);
|
||||
ClassDB::bind_method(D_METHOD("set_bone_name", "bone_idx", "name"), &Skeleton::set_bone_name);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bone_parent", "bone_idx"), &Skeleton::get_bone_parent);
|
||||
ClassDB::bind_method(D_METHOD("set_bone_parent", "bone_idx", "parent_idx"), &Skeleton::set_bone_parent);
|
||||
|
|
|
@ -161,6 +161,7 @@ public:
|
|||
void add_bone(const String &p_name);
|
||||
int find_bone(const String &p_name) const;
|
||||
String get_bone_name(int p_bone) const;
|
||||
void set_bone_name(int p_bone, const String &p_name);
|
||||
|
||||
bool is_bone_parent_of(int p_bone_id, int p_parent_bone_id) const;
|
||||
|
||||
|
|
|
@ -918,6 +918,23 @@ StringName ArrayMesh::get_blend_shape_name(int p_index) const {
|
|||
ERR_FAIL_INDEX_V(p_index, blend_shapes.size(), StringName());
|
||||
return blend_shapes[p_index];
|
||||
}
|
||||
|
||||
void ArrayMesh::set_blend_shape_name(int p_index, const StringName &p_name) {
|
||||
ERR_FAIL_INDEX(p_index, blend_shapes.size());
|
||||
|
||||
StringName name = p_name;
|
||||
int found = blend_shapes.find(name);
|
||||
if (found != -1 && found != p_index) {
|
||||
int count = 2;
|
||||
do {
|
||||
name = String(p_name) + " " + itos(count);
|
||||
count++;
|
||||
} while (blend_shapes.find(name) != -1);
|
||||
}
|
||||
|
||||
blend_shapes.write[p_index] = name;
|
||||
}
|
||||
|
||||
void ArrayMesh::clear_blend_shapes() {
|
||||
|
||||
ERR_FAIL_COND_MSG(surfaces.size(), "Can't set shape key count if surfaces are already created.");
|
||||
|
@ -1439,6 +1456,7 @@ void ArrayMesh::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("add_blend_shape", "name"), &ArrayMesh::add_blend_shape);
|
||||
ClassDB::bind_method(D_METHOD("get_blend_shape_count"), &ArrayMesh::get_blend_shape_count);
|
||||
ClassDB::bind_method(D_METHOD("get_blend_shape_name", "index"), &ArrayMesh::get_blend_shape_name);
|
||||
ClassDB::bind_method(D_METHOD("set_blend_shape_name", "index", "name"), &ArrayMesh::set_blend_shape_name);
|
||||
ClassDB::bind_method(D_METHOD("clear_blend_shapes"), &ArrayMesh::clear_blend_shapes);
|
||||
ClassDB::bind_method(D_METHOD("set_blend_shape_mode", "mode"), &ArrayMesh::set_blend_shape_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_blend_shape_mode"), &ArrayMesh::get_blend_shape_mode);
|
||||
|
|
|
@ -129,6 +129,7 @@ public:
|
|||
virtual Ref<Material> surface_get_material(int p_idx) const = 0;
|
||||
virtual int get_blend_shape_count() const = 0;
|
||||
virtual StringName get_blend_shape_name(int p_index) const = 0;
|
||||
virtual void set_blend_shape_name(int p_index, const StringName &p_name) = 0;
|
||||
|
||||
PoolVector<Face3> get_faces() const;
|
||||
Ref<TriangleMesh> generate_triangle_mesh() const;
|
||||
|
@ -195,6 +196,7 @@ public:
|
|||
void add_blend_shape(const StringName &p_name);
|
||||
int get_blend_shape_count() const;
|
||||
StringName get_blend_shape_name(int p_index) const;
|
||||
void set_blend_shape_name(int p_index, const StringName &p_name);
|
||||
void clear_blend_shapes();
|
||||
|
||||
void set_blend_shape_mode(BlendShapeMode p_mode);
|
||||
|
|
|
@ -177,6 +177,9 @@ StringName PrimitiveMesh::get_blend_shape_name(int p_index) const {
|
|||
return StringName();
|
||||
}
|
||||
|
||||
void PrimitiveMesh::set_blend_shape_name(int p_index, const StringName &p_name) {
|
||||
}
|
||||
|
||||
AABB PrimitiveMesh::get_aabb() const {
|
||||
if (pending_request) {
|
||||
_update();
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
virtual Ref<Material> surface_get_material(int p_idx) const;
|
||||
virtual int get_blend_shape_count() const;
|
||||
virtual StringName get_blend_shape_name(int p_index) const;
|
||||
virtual void set_blend_shape_name(int p_index, const StringName &p_name);
|
||||
virtual AABB get_aabb() const;
|
||||
virtual RID get_rid() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue