Skip to content

Commit e1b1592

Browse files
author
Roberto De Ioris
committed
correctly returns bone index when adding a new bone to a skeleton
1 parent 514501f commit e1b1592

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Source/UnrealEnginePython/Private/UObject/UEPySkeletal.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ PyObject *py_ue_skeleton_add_bone(ue_PyUObject *self, PyObject * args) {
160160
if (!transform)
161161
return PyErr_Format(PyExc_Exception, "argument is not a FTransform");
162162

163+
if (skeleton->GetReferenceSkeleton().FindBoneIndex(FName(UTF8_TO_TCHAR(name))) > -1) {
164+
return PyErr_Format(PyExc_Exception, "bone %s already exists", name);
165+
}
166+
163167
#if WITH_EDITOR
164168
skeleton->PreEditChange(nullptr);
165169
#endif
@@ -180,7 +184,7 @@ PyObject *py_ue_skeleton_add_bone(ue_PyUObject *self, PyObject * args) {
180184
#endif
181185
skeleton->MarkPackageDirty();
182186

183-
Py_RETURN_NONE;
187+
return PyLong_FromLong(skeleton->GetReferenceSkeleton().FindBoneIndex(FName(UTF8_TO_TCHAR(name))));
184188
}
185189
#endif
186190

@@ -602,7 +606,7 @@ PyObject *py_ue_skeletal_mesh_add_lod(ue_PyUObject *self, PyObject * args) {
602606
int32 lod_index = resource->LODModels.Add(new FStaticLODModel());
603607

604608
FSkeletalMeshLODInfo lod_info;
605-
609+
606610
mesh->LODInfo.Add(lod_info);
607611

608612
return PyLong_FromLong(lod_index);

0 commit comments

Comments
 (0)