Skip to content

feat: Improve ArmatureDebugAppState #2491

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

capdevon
Copy link
Contributor

@capdevon capdevon commented Jun 12, 2025

Here’s a summary of the main differences between the original ArmatureDebugAppState.java file and the proposed modified version, focusing on new features, refactoring, and improvements:

1. Expanded Documentation & Comments

  • The modified file includes detailed class-level and method-level Javadoc comments, explaining the purpose of the class and its methods, which greatly improves code readability and maintainability.

2. Refined Imports

  • Wildcard imports (e.g., com.jme3.anim.*, com.jme3.input.controls.*, java.util.*, etc.) are replaced with explicit imports for only the required classes.
  • This makes the dependencies clearer and avoids unnecessary namespace pollution.

3. Field and Property Changes

  • Several new fields are added, such as Logger logger, selectionListeners, and enableJointInfoLogging.
  • The field displayAllJoints is renamed to displayNonDeformingJoints for clarity.
  • Application-specific fields like app, tmp, and tmp2 are removed, and their functionality is refactored to use local variables or utility classes.

4. Input Handling Refactor

  • Input mappings and listeners are now registered and unregistered via dedicated registerInput() and unregisterInput() methods.
  • Input action names are now constants (PICK_JOINT, TOGGLE_JOINTS), reducing the risk of typos and improving maintainability.
  • The action listener logic is improved to separate press/release actions, and click timing is handled more robustly.

5. Viewport and Debug Node Initialization

  • The debug viewport is initialized with a more descriptive name and is set to disabled by default until the state is enabled.
  • The showOnTop property is introduced, allowing the debug view to optionally render on top of other scene geometry.

6. ArmatureDebugger Management

  • The method for adding armature debuggers is overhauled:
    • Now supports immediate initialization if the AppState is already initialized.
    • Uses improved naming and utility methods for handling associated geometries.
    • Uses a visitor pattern to identify deforming joints more clearly.
  • The recursive geometry search method is renamed and clarified (findGeomscollectGeometries).

7. Selection Listener Mechanism

  • New functionality allows external listeners to be notified when a joint is selected (addSelectionListener, removeSelectionListener, notifySelectionListeners, clearSelectionListeners).

8. Improved Joint Selection and Logging

  • Joint selection now uses a Ray projected from the screen point, encapsulated in a helper method (screenPointToRay).
  • Joint info logging is now toggleable with a dedicated property and methods.

9. General Code Clean-Up & Encapsulation

  • More use of private and final modifiers for encapsulation and immutability.
  • Unused or legacy code is removed or refactored.
  • Utility classes and methods (like JointInfoVisitor) are improved and better documented.

10. Additional Utility Methods

  • New getters and setters are added for state properties (like isShowOnTop, setShowOnTop, and joint info logging toggles).

In summary:
The modified version introduces improved documentation, refines and clarifies internal logic and state management, enhances input and selection handling, supports extensibility via listeners, and overall moves the code toward better maintainability, robustness, and clarity without fundamentally changing the external behavior of the class.

image

@yaRnMcDonuts yaRnMcDonuts added this to the v3.9.0 milestone Jun 13, 2025
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