Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bone Search #85

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

sudojunior
Copy link
Contributor

@sudojunior sudojunior commented Dec 15, 2022

  • SearchText matches regardless of text case. (Thanks @Fayti1703)

Changes between ab3c6a1...19e24e0

  • Use of ImGuiTreeNodeFlags was abandoned for a new enum associated to bone relationships.
    This currently encompasses Self and Child / Descendant, but can be expanded to include:
    • Ancestor
    • Direct Parent
    • Splitting Child and Descendant
  • New enum now uses FontAwesomeIcon to describe its association, if any exists - but can be changed to use colours or utilize both in varying capacities.
  • Icon representations:
    • Selected (current): {wand}, (descendent): 🧙🏻
    • Queried / Searched (current): 🔍, (descendent): 🔍 (hollow)

image

Representation is expected to change to be more accessible, as is the core functionality and quality of code if this is to merge.

- Bullet will only show if the text matches.
- Selected will show if it  or a descendant is the current target.
+ OpenOnArrow still works if Bullet is shown in its place.

! Unsure about the style in themselves, but they should be uniquely distinct from each other.
* Unsure on preference, but mainly for selecting bones when the empty space is selected... rather than the text.
* Bullet would have shown as if it had children to expand upon.
* new enum added specific for selection and query results
* search results for both are quite agressive when adding the icons
* intention is to have colors mapped to these results and then pick the first one it matches to
* additional possibility to add ancestor query results on top of child results
Comment on lines 69 to 74
var criteria = HighlightCriteria.None;

var show = DrawBoneNode(bone, flag, () => OverlayWindow.SetGizmoOwner(bone.UniqueName));
if (show) {
if (isSelected) criteria ^= HighlightCriteria.Selected;
if (isQueried) criteria ^= HighlightCriteria.Queried;
if (hasChildSelected) criteria ^= HighlightCriteria.ChildSelected;
if (hasChildInQuery) criteria ^= HighlightCriteria.ChildQueried;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attempts to unify this into a single method, went well initially - but hit a wall with CS0315 when the generic was not satisfied with using the enum (the XOR operator wasn't satisfied either, which would have required each value of the enum to be type cast as an integer).

var criteria = ApplyMulti(
  HighlightCriteria.None,
  new [] {
    (HighlightCriteria.Selected, Skeleton.IsBoneSelected(bone)),
    (HighlightCriteria.Queried, BoneDoesMatch(bone)),
    (HighlightCriteria.ChildSelected, decendents.Any(BoneDoesMatch)),
    (HighlightCriteria.ChildQueried, decendents.Any(bone => Skeleton.IsBoneSelected(bone)))
  }
);

private static T ApplyMulti<T>(T initial, (T, bool)[] pairs) where T : IBitwiseOperators<T, T, T> {
  T result = initial;

  foreach (var (value, condition) in pairs) {
    if (condition) result ^= value;
  }

  return result;
}

The use of an array only for this, would also have been excessive for its repeated calls, overall performance and impact on garbage collection.

Ktisis/Interface/Components/BoneTree.cs Outdated Show resolved Hide resolved
Ktisis/Interface/Components/BoneTree.cs Outdated Show resolved Hide resolved
Ktisis/Interface/Components/BoneTree.cs Outdated Show resolved Hide resolved
Ktisis/Interface/Components/BoneTree.cs Outdated Show resolved Hide resolved
Ktisis/Interface/Components/BoneTree.cs Outdated Show resolved Hide resolved
Ktisis/Interface/Components/BoneTree.cs Outdated Show resolved Hide resolved
Ktisis/Interface/Components/BoneTree.cs Outdated Show resolved Hide resolved
private static Vector2 _FrameMin;
private static Vector2 _FrameMax;

private static string SearchText = "";

public static unsafe void Draw(Actor* actor) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDE0036 was raised in accordance with .editorconfig.

Suggested change
public static unsafe void Draw(Actor* actor) {
public unsafe static void Draw(Actor* actor) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants