fix: NPEs resulting from bones being deleted under armature lock (#448)

Fixes: #447
This commit is contained in:
bd_ 2023-09-25 22:58:02 +09:00 committed by GitHub
parent 37309125ea
commit 11b10a82d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -169,6 +169,12 @@ namespace nadena.dev.modular_avatar.core.armature_lock
// Check parents haven't changed
for (int i = 0; i < _baseBones.Length; i++)
{
if (_baseBones[i] == null || _mergeBones[i] == null || _baseParentBones[i] == null ||
_mergeParentBones[i] == null)
{
return false;
}
if (_baseBones[i].parent != _baseParentBones[i] || _mergeBones[i].parent != _mergeParentBones[i])
{
return false;

View File

@ -174,6 +174,8 @@ namespace nadena.dev.modular_avatar.core.armature_lock
handle = default;
if (_disposed) return false;
LastOp.Complete();
_fault.Value = 0;
_wroteAny.Value = 0;
@ -199,6 +201,12 @@ namespace nadena.dev.modular_avatar.core.armature_lock
// Validate parents while that job is running
for (int i = 0; i < _baseBones.Length; i++)
{
if (_baseBones[i] == null || _mergeBones[i] == null || _baseParentBones[i] == null ||
_mergeParentBones[i] == null)
{
return false;
}
if (_baseBones[i].parent != _baseParentBones[i] || _mergeBones[i].parent != _mergeParentBones[i])
{
return false;