-
Notifications
You must be signed in to change notification settings - Fork 0
Merge Modifier Refactoring #28
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
Merged
Merged
Conversation
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
handling - Introduced a new `direction` parameter to control the displacement direction of the ripple effect on vertices. - Updated the `setPhaseShift` method to wrap the phase shift within the range [0, 2π), ensuring proper wave phase handling. - Refined the logic for applying the ripple effect to vertices, now using the `direction` vector to control the displacement direction. - Replaced the previous per-vertex normal calculation with a simplified approach that uses the `direction` vector for vertex displacement. - Updated the constructor to include default `direction` values for a downward ripple by default. - Improved method names and added documentation to reflect the changes in the ripple effect's functionality.
- Added a static method `normalizeAngle` to normalize input angles to the range [0, 2π] radians. - Handles floating-point precision issues by snapping small values (< 1e-6) to zero. - Ensures consistent angle representation by wrapping negative angles into the positive range. - Useful for ensuring robust and accurate angle calculations across applications.
Vertices - Added the WaveModifier class that simulates wave deformation on a 3D mesh. - The wave effect follows the equation: y = A * sin((2π / λ) * (D ⋅ P) + ϕ), where: - A: Amplitude (height of wave peaks), - λ: Wavelength (distance between wave peaks), - D: Direction (vector for wave propagation), - P: Vertex position (location of vertex in space), - ϕ: Phase (offset for wave animation). - Default wave direction is set along the X-axis, with default amplitude and wavelength of 1. - Provides flexibility to adjust amplitude, wavelength, phase, and direction for custom wave effects. - Applies the wave deformation efficiently by using parallel stream processing to modify mesh vertices. - Includes validation for non-negative amplitude and positive wavelength to ensure correct behavior. - Added JavaDoc documentation for clarity on functionality and usage.
- Added input validation for `factor`, `radius`, and `center` to ensure valid values. - Implemented parallel stream processing for improved performance in `spherify` method. - Introduced `setMesh` method to encapsulate mesh assignment logic. - Updated constructors to streamline initialization with default values. - Enhanced documentation with JavaDoc for better code readability and maintainability. - Adjusted `modify` method to handle null meshes and ensure robust error handling. - Improved calculation of new vertex positions by refactoring logic for clarity and correctness.
- Introduced `InflateModifier` class to apply inflation or deflation to a 3D mesh. - The modifier displaces mesh vertices along their normals based on an inflation factor and direction (OUTWARD or INWARD). - Added validation for the inflation factor to ensure it's non-negative. - Added detailed JavaDoc for the class, methods, and fields to improve clarity and maintainability. - Incorporated functionality to handle the direction of inflation and vertex normal calculation for displacement.
optimizations - Updated `lerpLocal(Vector3f finalVec, float changeAmnt)`: - Added short-circuit logic for `changeAmnt` values of 0 and 1 to avoid unnecessary calculations. - Ensured precision by bypassing floating-point operations in trivial cases. - Maintained the "local" behavior by directly modifying `this`. - Updated `lerpLocal(Vector3f beginVec, Vector3f finalVec, float changeAmnt)`: - Added short-circuit logic for `changeAmnt` values of 0 and 1 to directly assign `beginVec` or `finalVec`. - Improved efficiency by reducing unnecessary calculations for boundary cases. - Ensured consistency in mutability by modifying `this` as expected. - Added safeguards to handle floating-point precision issues and improve robustness. - Tested both methods for various edge cases (e.g., `changeAmnt = 0`, `changeAmnt = 1`, and intermediate values) to ensure correctness and reliability.
improve rotation handling - Switched from a simple for-loop to `parallelStream()` for improved performance during vertex transformations. - Added synchronization to ensure thread-safe access to shared vertices during rotation. - Updated the logic to check for empty meshes before attempting transformations. - Improved `setAngle()` to avoid unnecessary computations by skipping redundant angle updates. - Added initialization and updates for the rotation matrix on angle changes to ensure accurate transformations. - Provided comprehensive JavaDoc for fields and methods to improve code maintainability and developer understanding.
improve rotation handling - Switched from a simple for-loop to `parallelStream()` for improved performance during vertex transformations. - Added synchronization to ensure thread-safe access to shared vertices during rotation. - Updated the logic to check for empty meshes before attempting transformations. - Improved `setAngle()` to avoid unnecessary computations by skipping redundant angle updates. - Added initialization and updates for the rotation matrix on angle changes to ensure accurate transformations. - Provided comprehensive JavaDoc for fields and methods to improve code maintainability and developer understanding.
improve rotation handling - Switched from a simple for-loop to `parallelStream()` for improved performance during vertex transformations. - Added synchronization to ensure thread-safe access to shared vertices during rotation. - Updated the logic to check for empty meshes before attempting transformations. - Improved `setAngle()` to avoid unnecessary computations by skipping redundant angle updates. - Added initialization and updates for the rotation matrix on angle changes to ensure accurate transformations. - Provided comprehensive JavaDoc for fields and methods to improve code maintainability and developer understanding.
RotateYModifier, and RotateZModifier - Replaced traditional iteration with `parallelStream()` to leverage parallel processing for improved performance. - Updated rotation logic to apply transformations concurrently across mesh vertices. - Removed unnecessary synchronization to ensure thread-safe operations without added overhead. - Ensured efficient and scalable computation when dealing with large meshes.
- Changed the vertex scaling logic to use `parallelStream` for better performance with large meshes. - Checked for empty vertex lists to avoid unnecessary computations. - Improved null handling with explicit validation for mesh before processing. - Added comprehensive JavaDoc comments for better maintainability and understanding of the code.
- Added a check to ensure the mesh has vertices before performing spherification. - Avoid unnecessary processing if `mesh.vertices` is empty. - Improved stability by handling edge cases gracefully.
parallel processing - Added null check to ensure `mesh` is valid before proceeding. - Skipped processing if the mesh has no vertices to avoid unnecessary computation. - Implemented parallel processing with `parallelStream()` for improved performance on large meshes. - Improved robustness by validating the `factor` before performing deformations.
- Added a default constructor setting the default bending factor to 0.5f. - Included comprehensive JavaDocs for all fields and methods to improve maintainability and clarity. - Added validation to ensure bending only applies with a valid factor. - Optimized vertex processing using parallel streams for performance on large meshes. - Improved edge-case handling for null or empty meshes.
- Added EPSILON threshold (1e-6f) for precise center alignment checks. - Enhanced `modify` method to handle null and empty mesh cases gracefully. - Refactored code for better readability with helper methods: - `setMesh()`: Assigns the current mesh. - `calculateBounds()`: Computes the bounding box of the mesh. - `meshIsAlreadyCentered()`: Checks if the mesh is aligned with the target center. - Improved null safety for `setCenter` with validation. - Added JavaDoc for all fields and methods for better code documentation and maintainability.
parallel processing - Updated the translation logic to use Vector3f for cleaner, safer, and more flexible handling. - Applied parallel streams to translate vertices efficiently on large meshes. - Removed redundant float fields (`deltaX`, `deltaY`, `deltaZ`) in favor of a single Vector3f delta. - Improved input validation to handle null and edge case inputs robustly. - Added updated Javadoc for clarity and maintainability.
behavior - Added comprehensive documentation to IMeshModifier explaining its purpose as part of the mesh transformation system. - Clarified that `modify()` returns a reference to the same mesh passed in, reflecting its modified state. - Improved usability understanding for developers by providing context on design choices and use cases.
Updated JavaDoc to provide detailed explanations
Introduced validation for target dimensions to ensure values are
positive.
Optimized calculateScale to handle edge cases (zero max dimensions).
Replaced redundant min and max helper methods with direct calls to
Mathf.
Enhanced method names for better readability
(getMinimumTargetDimension, getMaximumSourceDimension).
Added null checks and safeguards for empty meshes.
Added target dimension validation
- Added JavaDoc to provide detailed explanations - Added null checks to prevent invalid operations on null Mesh or Face inputs. - Enhanced the `invertFaceIndices` method to operate without unnecessary array copying. - Separated validation logic into reusable methods for single-face and collection processing. - Improved readability and defensive programming by ensuring only valid operations are performed.
mesh.faces - Added a null check for the `mesh` parameter in the `modify(Mesh3D mesh)` method to ensure `mesh.faces` is not accessed if `mesh` is null. - Throwing an `IllegalArgumentException` for null meshes to align with other validation logic in the class.
Replaced sequential processing with parallelStream() for face
modification.
Improved performance for large collections of faces by leveraging
parallelism.
Ensured thread safety by isolating invertFaceIndices operations to
individual faces.
Updated JavaDoc for FlipFacesModifier to specify that the modifier only flips the indices of mesh faces. Added a note explaining that it does not ensure correct vertex order relative to surface normals or geometric properties, and additional adjustments may be required for rendering or normal recalculations.
- Renamed `distance` to `targetRadius` to better reflect its purpose. - Enhanced edge case handling in `pushPullVertex` to prevent NaN issues for vertices located exactly at the center. - Improved JavaDoc with detailed descriptions and examples to clarify the behavior and intended usage of the modifier. - Replaced sequential vertex modification loop with `parallelStream()` to optimize performance for larger meshes. - Introduced a constant `EPSILON` for numerical stability in vertex displacement calculations. - Added explicit null checks for input validation, ensuring better robustness and error reporting. - Improved readability and consistency by refactoring method names and comments.
- Updated class documentation to enhance clarity and provide a detailed description of the modifier's purpose and usage. - Added safeguards against null or empty mesh input. - Optimized the mesh translation process by replacing the manual loop with a parallelized stream-based approach for better performance on large meshes. - Included considerations for simple ground planes, mesh orientation assumptions, and topology requirements in the documentation.
handling - Reorganized the `InsetModifier` class to improve readability and modularity: - Introduced utility methods like `processFaceEdges`, `createInsetVertices`, and `createFaceAt` for better separation of concerns. - Added error handling to ensure `Mesh3D` and `Face3D` inputs are non-null. - Incorporated `GeometryUtil.getMidpoint` for calculating midpoints, replacing inline calculations. - Simplified edge processing by separating inset factor calculation and vertex processing logic. - Improved method and variable naming for better code comprehension: - Examples include `processFaceEdges` (formerly inline loop logic) and `calculateInsetFactor`. - Preserved backward compatibility with the original logic while optimizing performance and maintainability.
- Deprecated direct mesh transformations (e.g., `rotateY`, `translateX`) in favor of modular modifier classes like `RotateYModifier` and `TranslateModifier`. - Added JavaDoc comments to clarify usage and functionality.
ExtrudeModifier Class - Moved extrusion logic from the legacy `Mesh3DUtil.extrudeFace` method to the new `ExtrudeModifier` class. - Deprecated the old `Mesh3DUtil.extrudeFace` method to encourage usage of the new, more modular `ExtrudeModifier`. - Enhanced modularity by encapsulating extrusion functionality within `ExtrudeModifier`. - Improved handling of scaling, extrusion amount, and optional removal of extruded faces. - Streamlined codebase by centralizing logic for mesh extrusion, improving maintainability.
readability. - Removed html clutter from the class java-doc by using pre
- Added detailed explanation on isolated single-face operations and their impact. - Included caution regarding edge splitting and unintended side-effects. - Provided clarity for implementers on maintaining mesh integrity during modifications.
- Transitioned to a cleaner, focused structure - Improved method and variable naming for better readability. - Extracted `calculateSpikeTip` - Enhanced JavaDoc documentation to provide detailed explanations of logic and behavior. - Streamlined the spike creation logic by separating calculations and geometric computations. - Improved validation and operation logic, ensuring robustness against edge cases. - Added detailed descriptions to class and methods to align with the new design intentions.
robustness - Added validation to ensure the mesh is not null, improving error handling. - Introduced a `setMesh` method to cleanly manage the current mesh instance. - Replaced sequential processing with parallelStream for better performance on large meshes. - Optimized normal updates by directly modifying existing vectors to reduce object creation and memory overhead. - Enhanced code readability and maintainability with a structured approach. This update ensures the modifier is faster and more robust, making it suitable for large-scale mesh operations.
improved structure and validation - Renamed `WireframeModifier` to `PseudoWireframeModifier` to better reflect its behavior as a pseudo-wireframe effect. - Added detailed validation to ensure mesh integrity and constraints for `holePercentage` and `thickness`. - Enhanced Javadoc to clarify differences between traditional wireframe modifiers (like Blender's) and this pseudo-implementation. - Improved method encapsulation and added null checks to prevent invalid operations.
- Included the `WidthType` enum directly within the `BevelEdgesModifier` class, as it is logically tied to its behavior. - Removed the separate class file for `WidthType` to simplify the structure and maintain better cohesion. - Improved organization and reduced unnecessary complexity by encapsulating the enum where it's most relevant.
compatibility - Unified JUnit 5 dependencies to version 5.11.3 - Updated maven-surefire-plugin to version 3.0.0-M5 for JUnit 5 support - Removed redundant `junit-platform-runner` - Ensured consistent versions across testing dependencies - Prepared build system for smooth testing with JUnit 5
- Updated the `divideLocal` method to avoid reassignment of the input parameter `a`. - Ensured proper functionality by using the `this` keyword for color components (r, g, b, a). - Addressed potential confusion and bugs caused by parameter shadowing. Thanks and shout-out to my nerd coding buddy and long-time friend tim for pointing this out—you're a lifesaver!
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.
No description provided.