AnimationCurveI17F15.Keys セット時にソートされない不具合を修正 - #350
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements stable sorting for AnimationCurve keyframes by introducing a custom insertion sort algorithm. The change ensures that keyframes with equal time values maintain their original relative order after sorting.
- Added a new
Utilityclass with a stableInsertionSortimplementation - Updated
AnimationCurveI17F15.Keyssetter to use the stable insertion sort - Added comprehensive tests to verify stable sorting behavior for both Unity's AnimationCurve and the custom AnimationCurveI17F15
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Intar/Utility.cs | New utility class containing stable insertion sort implementation |
| Intar/Utility.cs.meta | Unity metadata file for the new Utility.cs |
| Intar/AnimationCurveI17F15.cs | Updated Keys setter to use stable insertion sort |
| Intar.Tests/AnimationCurveTest.cs | Added test case verifying stable sort behavior for AnimationCurveI17F15 |
| Intar.Tests/AnimationCurveTest.Unity.cs | Added test case verifying stable sort behavior for Unity's AnimationCurve |
Comments suppressed due to low confidence (1)
Intar/AnimationCurveI17F15.cs:117
- The
MoveKeymethod usesList<T>.Sortwhich is not stable, while theKeyssetter usesUtility.InsertionSortfor stable sorting. For consistency and to maintain stable sort behavior throughout the API, consider usingUtility.InsertionSort(keys, (a, b) => a.Time.CompareTo(b.Time))here as well.
keys.Sort((a, b) => a.Time.CompareTo(b.Time));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agate-pris
force-pushed
the
fix-sort-animation-curve-keys
branch
from
November 9, 2025 16:19
55cd7e2 to
d24e0e6
Compare
| return; | ||
| } | ||
| keys = new List<KeyframeI17F15>(value); | ||
| Utility.InsertionSort(keys, (a, b) => a.Time.CompareTo(b.Time)); |
There was a problem hiding this comment.
MoveKeyメソッド(117行目)ではList<T>.Sortを使用していますが、KeysセッターではInsertionSortを使用しており、ソートアルゴリズムが統一されていません。MoveKeyも安定ソートにするべきではないでしょうか。一貫性のため、MoveKeyでもUtility.InsertionSortを使用することを検討してください。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AnimationCurveI17F15.Keysセット時に挿入ソートを行うように修正Utiliity.InsertionSortを追加Unity.AnimationCurve.keysと動作が同等であることを確認するテストを追加