mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 02:35:06 +08:00
fix: issues with MAMoveIndependentlyManager error handling
Closes: #1386
This commit is contained in:
parent
7967fcf121
commit
e0f9e95df3
@ -199,12 +199,6 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
|||||||
_anyError[0] = false;
|
_anyError[0] = false;
|
||||||
_anyDirty[0] = false;
|
_anyDirty[0] = false;
|
||||||
|
|
||||||
var clearErrors = new JClearErrorFlags
|
|
||||||
{
|
|
||||||
ErrorFlags = _errorFlags
|
|
||||||
};
|
|
||||||
var clearErrorsHandle = clearErrors.Schedule(_errorFlags.Length, 16);
|
|
||||||
|
|
||||||
var readVp = new JReadTransforms
|
var readVp = new JReadTransforms
|
||||||
{
|
{
|
||||||
States = _vpState,
|
States = _vpState,
|
||||||
@ -227,15 +221,17 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
|||||||
SceneRootParent = _falseArray
|
SceneRootParent = _falseArray
|
||||||
};
|
};
|
||||||
|
|
||||||
var readVpHandle = readVp.Schedule(_virtualParents, clearErrorsHandle);
|
var clearVpHandle = new JInitLocalStateAndErrorFlags
|
||||||
var clearVpHandle = new JClearRootTransforms
|
|
||||||
{
|
{
|
||||||
States = _vpState,
|
States = _vpState,
|
||||||
SceneRootParent = _sceneRootParent
|
SceneRootParent = _sceneRootParent,
|
||||||
}.Schedule(_vpState.Length, 16, readVpHandle);
|
ErrorFlags = _errorFlags
|
||||||
var readTpHandle = readTp.Schedule(_trueParents, clearErrorsHandle);
|
}.Schedule(_vpState.Length, 16);
|
||||||
var readTargetHandle = readTarget.Schedule(_targets, clearErrorsHandle);
|
|
||||||
var readHandle = JobHandle.CombineDependencies(clearVpHandle, readTpHandle, readTargetHandle);
|
var readVpHandle = readVp.Schedule(_virtualParents, clearVpHandle);
|
||||||
|
var readTpHandle = readTp.Schedule(_trueParents, clearVpHandle);
|
||||||
|
var readTargetHandle = readTarget.Schedule(_targets, clearVpHandle);
|
||||||
|
var readHandle = JobHandle.CombineDependencies(readVpHandle, readTpHandle, readTargetHandle);
|
||||||
|
|
||||||
var compute = new JCompute
|
var compute = new JCompute
|
||||||
{
|
{
|
||||||
@ -300,10 +296,19 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
|||||||
for (var i = 0; i < _mappingStates.Length; i++)
|
for (var i = 0; i < _mappingStates.Length; i++)
|
||||||
{
|
{
|
||||||
if (_errorFlags[i] && _slotToState.TryGetValue(i, out var state))
|
if (_errorFlags[i] && _slotToState.TryGetValue(i, out var state))
|
||||||
|
{
|
||||||
|
if (state != null)
|
||||||
{
|
{
|
||||||
Deactivate(state);
|
Deactivate(state);
|
||||||
reactivate.Add(state.MoveIndep);
|
reactivate.Add(state.MoveIndep);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Hmm - how did we end up with a null here?
|
||||||
|
_slotToState.Remove(i);
|
||||||
|
_enabled[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var moveIndep in reactivate)
|
foreach (var moveIndep in reactivate)
|
||||||
@ -433,22 +438,24 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
|||||||
|
|
||||||
private void Deactivate(State state)
|
private void Deactivate(State state)
|
||||||
{
|
{
|
||||||
|
if (state?.Segment == null) return;
|
||||||
if (!_anyDirty.IsCreated) return; // domain reload timing issues
|
if (!_anyDirty.IsCreated) return; // domain reload timing issues
|
||||||
|
|
||||||
|
_moveIndeps.Remove(state.MoveIndep);
|
||||||
|
if (_moveIndeps.Count == 0) UpdateRegistered = false;
|
||||||
|
|
||||||
for (var i = 0; i < state.Segment.Length; i++)
|
for (var i = 0; i < state.Segment.Length; i++)
|
||||||
{
|
{
|
||||||
var j = i + state.Segment.Offset;
|
var j = i + state.Segment.Offset;
|
||||||
_enabled[j] = false;
|
_enabled[j] = false;
|
||||||
_virtualParents[j] = null;
|
if (_virtualParents.isCreated && _virtualParentsT.Length > j) _virtualParents[j] = null;
|
||||||
_trueParents[j] = null;
|
if (_trueParents.isCreated && _trueParents.length > j) _trueParents[j] = null;
|
||||||
_targets[j] = null;
|
if (_targets.isCreated && _targets.length > j) _targets[j] = null;
|
||||||
_slotToState.Remove(j);
|
_slotToState.Remove(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
_nativeMemoryManager.Free(state.Segment);
|
_nativeMemoryManager.Free(state.Segment);
|
||||||
_moveIndeps.Remove(state.MoveIndep);
|
state.Segment = null;
|
||||||
|
|
||||||
if (_moveIndeps.Count == 0) UpdateRegistered = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BurstCompile]
|
[BurstCompile]
|
||||||
@ -482,15 +489,21 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
|||||||
|
|
||||||
// For some reason checking SceneRootParent in JReadTransforms was ignored...?
|
// For some reason checking SceneRootParent in JReadTransforms was ignored...?
|
||||||
// Maybe IJobParallelForTransform doesn't execute on null transforms.
|
// Maybe IJobParallelForTransform doesn't execute on null transforms.
|
||||||
private struct JClearRootTransforms : IJobParallelFor
|
private struct JInitLocalStateAndErrorFlags : IJobParallelFor
|
||||||
{
|
{
|
||||||
[WriteOnly] public NativeArray<TransformState> States;
|
|
||||||
[ReadOnly] public NativeArray<bool> SceneRootParent;
|
[ReadOnly] public NativeArray<bool> SceneRootParent;
|
||||||
|
[WriteOnly] public NativeArray<TransformState> States;
|
||||||
|
[WriteOnly] public NativeArray<bool> ErrorFlags;
|
||||||
|
|
||||||
public void Execute(int index)
|
public void Execute(int index)
|
||||||
{
|
{
|
||||||
|
ErrorFlags[index] = true;
|
||||||
|
|
||||||
if (SceneRootParent[index])
|
if (SceneRootParent[index])
|
||||||
{
|
{
|
||||||
|
// Clear error flags since we're effectively handling the read
|
||||||
|
ErrorFlags[index] = false;
|
||||||
|
|
||||||
States[index] = new TransformState
|
States[index] = new TransformState
|
||||||
{
|
{
|
||||||
localToWorldMatrix = Matrix4x4.identity,
|
localToWorldMatrix = Matrix4x4.identity,
|
||||||
@ -519,9 +532,10 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
|||||||
|
|
||||||
if (SceneRootParent[index]) return;
|
if (SceneRootParent[index]) return;
|
||||||
|
|
||||||
if (!transform.isValid)
|
var failed = !transform.isValid;
|
||||||
|
ErrorFlags[index] = failed;
|
||||||
|
if (failed)
|
||||||
{
|
{
|
||||||
ErrorFlags[index] = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user