Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: vrm spring bone #1508

Merged
merged 14 commits into from
Dec 31, 2024
Merged

fix: vrm spring bone #1508

merged 14 commits into from
Dec 31, 2024

Conversation

emadurandal
Copy link
Collaborator

No description provided.

Yuki Shimada added 14 commits December 29, 2024 23:14
…Vector3

- Introduced a new static method `getQuaternionAngle` in Quaternion to compute the rotation angle of a quaternion.
- Added `clampRotation` method in Quaternion to limit rotation angles using spherical linear interpolation (slerp).
- Implemented `_multiplyMatrix4` method in Vector3 to perform matrix multiplication with a 4x4 matrix, enhancing vector transformation capabilities.
- Added `multiplyMatrix4` method in both Vector3 and Vector3d classes for convenient access to matrix multiplication functionality.
…nd new vector/matrix imports

- Added `Vector4` and `Matrix44` imports to support advanced vector and matrix operations.
- Implemented quaternion clamping in the rotation calculations to limit rotation angles, improving stability in physics simulations.
- Refactored the bone processing logic to enhance clarity and maintainability, ensuring better handling of bone transformations.
- Updated comments to clarify the purpose of commented-out code related to matrix transformations.
…tionality

- Implemented logic to assign the center node of the VRM spring if specified, improving the handling of spring dynamics.
- Enhanced the integration of scene graph entities with the VRM model, ensuring better representation of the spring's structure.
- Refactored the `fromToRotation` method in `Quaternion` to improve clarity and efficiency by replacing commented-out code with a more streamlined implementation.
- Updated `VRMSpringBone` to simplify the retrieval of world positions by removing unnecessary temporary vector usage.
- Enhanced `VRMSpringBonePhysicsStrategy` by replacing multiple `multiplyTo` and `addTo` calls with cleaner `multiply` and `add` methods, improving readability and maintainability.
- Introduced `Matrix44` import for advanced matrix operations, enhancing the overall functionality of the physics strategy.
- Improved quaternion and vector operations to ensure better performance in physics simulations.
…ld space calculations

- Added `initialLocalChildPosition` to `VRMSpringBone` for improved child bone positioning.
- Refactored `setup` method to calculate `currentTail` using the new initial position logic.
- Introduced `_calcWorldSpaceBoneLength` method to compute bone length based on world space coordinates.
- Updated `VRMSpringBonePhysicsStrategy` to call `_calcWorldSpaceBoneLength` during processing, ensuring accurate physics calculations.
- Enhanced matrix operations with new methods for transforming coordinates between world and center spaces.
…culations

- Added backup transform functionality in the `setup` method to preserve the initial state of the node.
- Updated `_calcWorldSpaceBoneLength` method to simplify world position retrieval by using direct property access instead of matrix operations.
- Improved overall clarity and maintainability of the `VRMSpringBone` class with these enhancements.
…nd simplified setup

- Introduced `vrmSpringBoneBonAxisCoeff` and `vrmSpringBoneToCoeff` in Config.ts to allow for customizable spring behavior.
- Refactored the `setup` method in `VRMSpringBone` to remove unnecessary parameters, streamlining the initialization process.
- Updated `VRMSpringBonePhysicsStrategy` to utilize the new coefficients for improved rotation calculations, enhancing the physics simulation accuracy.
- Cleaned up commented-out code to improve readability and maintainability across the physics strategy implementation.
…al tracking

- Added `__lastProcessBeginTime` and `__intervalProcessBegin` to the `Time` class for improved tracking of process intervals.
- Updated `VRMSpringBonePhysicsStrategy` to utilize `Time.intervalProcessBegin` for calculating stiffness and gravity forces, enhancing the accuracy of physics simulations.
- Cleaned up commented-out code and improved readability in the physics strategy implementation.
- Modified conditional checks for the center node in both Vrm0xImporter and VrmImporter to ensure that the center is not only non-null but also not equal to -1, enhancing the robustness of spring bone functionality.
- This change improves the handling of center nodes in the VRM model, ensuring accurate scene graph representation.
- Removed commented-out code in `fromToRotation` and `fromToRotationTo` methods for clarity.
- Simplified the logic for handling edge cases in quaternion calculations, enhancing performance and readability.
- Updated quaternion normalization process to ensure consistent output in rotation calculations.
- Improved overall maintainability of the Quaternion class by cleaning up unnecessary complexity.
- Replaced division by determinant with multiplication by its inverse to enhance performance and readability in the Matrix44 class.
- Improved clarity by introducing an `invDet` variable, streamlining the matrix inversion logic.
- Ensured consistent handling of determinant checks to maintain robustness in matrix operations.
…hysicsStrategy

- Introduced temporary vector and quaternion variables to reduce object creation and improve performance during calculations.
- Replaced multiple `multiply` and `add` calls with `multiplyTo` and `addTo` methods for better memory efficiency and clarity.
- Enhanced the handling of inertia, stiffness, and collision responses to streamline physics calculations.
- Improved readability by cleaning up commented-out code and ensuring consistent use of temporary variables across methods.
…ry variable usage

- Removed unnecessary temporary vector and quaternion variables to enhance memory efficiency.
- Updated bone tail calculations to utilize existing temporary vectors, improving performance and clarity.
- Cleaned up code for better readability and maintainability, ensuring consistent use of temporary variables across methods.
@emadurandal emadurandal merged commit 369571b into main Dec 31, 2024
3 of 4 checks passed
@emadurandal emadurandal deleted the fix/vrm-spring-bone-6 branch December 31, 2024 23:22
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant