-
Notifications
You must be signed in to change notification settings - Fork 0
Working2 #43
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
Working2 #43
Conversation
- Removed clutter - Changed visibility of renderSelf to protected - Added getter and setter for positioning to the ui element interface
- Introduced `Anchor getAnchor()` and `void setAnchor(Anchor anchor)` methods to the UiElement interface. - These methods allow UI elements to define alignment behavior relative to their container or layout logic. - Ensured compatibility with layout systems by exposing anchor management functionality.
- Decoupled Grid3D from the Processing environment. - Improved modularity by creating a standalone 3D grid visualization class. - Added flexibility for reuse in other rendering contexts.
Decoupled the axis visualization logic from the Workspace class.
Created a standalone Axis3D class for managing and rendering 3D
axes.
Enhanced modularity and reusability of axis rendering functionality.
Added 3d line rendering to the graphics context.
**Future considerations:** - For loops in critical matrix operations, consider eventual roll-out of values for performance gains in specific use cases. This will be evaluated based on profiling results and project needs. - Replaced static constants `ZERO`, `UNIT`, and `ONE` with `ZERO` and `IDENTITY` matrices for simplicity. - Added a constructor to initialize matrices with 16 elements directly. - Refactored `identity()` method for concise reinitialization of matrices. - Improved clarity in `add`, `addLocal`, and `multiply` methods through simplifications. - Doc comprehensive documentation for `fpsViewRH` - Added utility methods like `createTranslation` for constructing translation matrices efficiently. - Ensured immutability for getter methods by returning safe copies of internal data. - Rewrote `toString` for improved matrix visualization. - Streamlined code by reducing redundant operations and adopting modern practices.
- Added Ray3f class with origin and normalized direction vector. - Included getPointAt(t) method to compute points along the ray. - Ensured direction normalization upon initialization to maintain mathematical correctness. - Added validation to ensure origin and direction are non-null. - Documented class and methods with detailed Javadocs.
- Added the `Camera` interface to abstract camera behaviors and properties for 3D rendering. - Includes methods for handling view and projection matrices, field of view, near/far clipping planes, and aspect ratio. - Added utility methods for screen-to-world ray generation and unprojection. - Provides a clean abstraction for camera-related computations in the rendering pipeline.
- Implements a basic Timer for frame rate calculation, time scaling, and elapsed time tracking. - Provides support for features such as FPS calculation, time-per-frame, and formatted time outputs. - Includes methods for slow motion and speed-up effects via time scaling. This version serves as the foundation for further improvements.
formatting
Enhanced precision and readability by using nanoseconds for
timekeeping.
Added methods for formatted time representation (HH:MM:SS) for both
scaled and unscaled total times.
Improved FPS calculation and ensured it updates accurately each
frame.
Refined methods for time-per-frame calculations, both scaled and
unscaled.
Introduced robust time scaling to support slow-motion and speed-up
effects.
Simplified class structure for better maintainability and
extensibility.
This refactor improves the usability and performance of the Timer class
for game loops and real-time applications.
- Updated package structure to place light-related classes under `engine.scene.light`. - Improves organization and aligns with the overall framework's naming conventions. - Ensures a consistent structure for scene-related components within the `engine.scene` package. Affected classes: - `DirectionalLight` - `Light` (interface) - `LightRenderer` (interface) - `LightType` (enum) - `PointLight` - `Spotlight`
Graphics Interfaces - Split rendering interfaces into three layers: - **Graphics2D**: Handles 2D rendering operations like shapes, text, and simple transformations. - **Graphics3D**: Extends Graphics2D and adds 3D rendering operations such as view/projection matrix handling and 3D transformations. - **Graphics**: Extends Graphics3D to provide a unified abstraction layer for rendering pipelines. - Improved adherence to SOLID principles by separating concerns. - Prepared architecture for potential rendering pipeline swaps (e.g., LibGDX, JOGL).
- Provided detailed documentation for all methods in the `Graphics2D` interface. - Improved clarity on purpose, parameters, return values, and usage for each method. - Enhanced maintainability and developer understanding by including context for the interface itself.
- Introduced `drawRoundRect` for drawing the outline of a rounded rectangle. - Added `fillRoundRect` to draw a filled rounded rectangle. - Both methods include parameters for position, dimensions, and corner radius. - Updated the interface to support rounded rectangle rendering.
properties - Created `Material` class to define 3D mesh visual properties under lighting conditions. - Includes properties like base color, ambient, diffuse, specular coefficients, and shininess. - Added predefined materials (white, black, red, green, blue, metallic silver, gold, glass, stone grey, water). - Added functionality to apply and release materials to/from the rendering context using `Graphics`. - Provided flexible constructors for custom and default material creation. - Included getter methods for accessing material properties. This class sets the foundation for realistic rendering effects with dynamic lighting.
management, and rendering support - Added `SceneNode` class to represent nodes in the scene graph. - Enabled parent-child relationships with methods for adding and removing children. - Introduced component system with methods to add, remove, and query components. - Implemented rendering logic with recursive traversal of children and rendering components. - Added update and cleanup mechanisms for nodes and their associated components. - Ensured proper resource management during child/component cleanup to prevent memory leaks. - Added utilities for root node retrieval and leaf node checks. - Added helper methods to handle `Transform` and `RenderComponent` lookups.
Updates
Added the Scene class to manage a hierarchy of SceneNode instances
for efficient rendering and updates.
Introduced thread-safe operations for managing root nodes and lights
using synchronized blocks.
Added a thread pool with ExecutorService to enable parallel updates
for better performance during simulation logic calculations.
Implemented methods for adding/removing nodes and lights safely,
supporting dynamic scene graph manipulation.
Added methods for rendering lights and nodes, integrating a simple
wireframe rendering mode toggle.
Included cleanup logic to ensure proper resource management by
shutting down worker threads and clearing references.
Added utility methods to query root nodes and lights safely, with
copies to prevent race conditions during access.
Integrated methods for setting and querying the active camera for
dynamic view transformations.
- Added `Particle` class to represent individual particles with properties like position, velocity, acceleration, damping, and lifetime. - Included methods for applying environmental forces, damping, and simulating motion over time. - Implemented lifecycle management with `isAlive()` to determine if a particle is still active. - Integrated utility methods for position tracking (current and old) for effects like trails and motion blur. - Designed to support visual effects such as trails, smoke, explosions, and other particle-based phenomena.
- Implemented a `MaterialFactory` class using the Builder pattern for cleaner and more modular material creation. - Added predefined materials: metallic silver, golden metallic, clear glass, stone grey, and water. - Provided JavaDocs for the class and all factory methods to improve readability and developer onboarding. - Encapsulated material properties like ambient, diffuse, specular, and shininess configuration in the Builder pattern.
Introduced the Plane class in the math package to represent a
geometric plane in 3D space.
Implemented methods to define the plane using coefficients (set
method) and calculate the signed distance from a point to the plane
(distanceToPoint).
Included getters for the plane's normal vector and distance from the
origin.
Normalization of the plane's normal vector is handled during
initialization to ensure consistency.
Added comprehensive JavaDoc for better usability and understanding
of the class functionality.
- Defined a flexible interface `ParticleRenderer` to handle particle rendering. - Methods include: - `render(Graphics g, Collection<Particle> particles)` to draw particles. - `initialize()` for resource setup. - `cleanup()` for efficient resource management. - Promotes separation of concerns and allows for multiple rendering strategies (e.g., sprites, points, trails).
- Added ParticleEmitter to handle continuous and burst-based particle emission. - Introduced configurable parameters such as velocity range, acceleration range, and lifetime range. - Implemented randomization logic for particle properties within specified ranges. - Added support for continuous emission and burst emission modes. - Integrated a thread-safe particle queue (`ConcurrentLinkedQueue`) for efficient particle management. - Provided methods for dynamic configuration of emitter properties and emission behavior.
- Added `Component` interface to represent modular, reusable behaviors in the scene graph system. - Defined lifecycle methods: `initialize()`, `update(float tpf)`, and `cleanup()` for managing component states. - Added `setOwner(SceneNode owner)` to associate components with their owning scene nodes. - Established a clear contract for components' interaction with `SceneNode` instances. - Provided detailed Javadoc to explain the purpose, lifecycle, and usage of components in the system.
- Implemented `AbstractComponent` to serve as a shared base class for all components in the scene graph. - Centralized common functionality, including the ownership management logic via `setOwner(SceneNode owner)`. - Added a convenience method `getOwner()` to retrieve the owning `SceneNode`. - Reduced boilerplate code by providing shared logic to all components. - Included clear Javadoc for better maintainability and clarity.
axis at a constant angular speed.
- Implemented `AmbientLight` with a customizable color property and default white color. - Integrated `AmbientLight` into `LightType` enum to represent global, non-directional lighting. - Updated `LightRenderer` interface to include a new method for rendering `AmbientLight`.
methods to Timer class to provide accurate real-time measurements since game startup in both float and double precision.
- Introduced the `Bounds` class to represent an axis-aligned bounding box, defined by minimum and maximum corners. - Implemented methods for checking point containment, expanding the box, encapsulating points, and calculating distances. - Added intersection methods for detecting ray and box intersections, as well as overlap between two bounding boxes. - Provided utility methods for getting and setting the minimum and maximum corners of the bounding box. This class will be useful for collision detection, frustum culling, and other spatial queries in 3D environments.
intersection - Introduced the `directionInv` field in the `Ray3f` class to store the reciprocal of the direction vector components. - Precomputing the reciprocal reduces computation overhead in operations like ray-box intersections, improving performance. - Updated the constructor to calculate and assign `directionInv` during ray initialization.
and debugging - Implemented a bounding box calculation for the Geometry class, utilizing MeshBoundsCalculator. - Bounding box is now accessible for culling and spatial partitioning optimizations. - Updated debug rendering to visualize the bounding box in red for easier debugging of mesh extents. - Added documentation explaining the broader use of the bounding box beyond debugging (e.g., for frustum culling).
|
|
||
| /** Updates the FPS calculation based on the accumulated milliseconds. */ | ||
| private void updateFPS() { | ||
| millisecondCounter += time; |
Check failure
Code scanning / CodeQL
Implicit narrowing conversion in compound assignment High
long
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 11 months ago
To fix the problem, we need to ensure that the type of the left-hand side of the compound assignment statement is at least as wide as the type of the right-hand side. In this case, we should change the type of millisecondCounter from long to float to match the type of time. This will prevent the implicit narrowing conversion and preserve the precision of the accumulated time.
-
Copy modified line R32
| @@ -31,3 +31,3 @@ | ||
| /** Accumulates milliseconds for FPS calculation. */ | ||
| private long millisecondCounter; | ||
| private float millisecondCounter; | ||
|
|
| long currentTime = System.nanoTime(); | ||
| time = (currentTime - lastTime) / 1_000_000.0f; // Convert to milliseconds | ||
| lastTime = currentTime; | ||
| totalTime += time; |
Check failure
Code scanning / CodeQL
Implicit narrowing conversion in compound assignment High
long
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 11 months ago
To fix the problem, we need to ensure that the type of the left-hand side of the compound assignment statement is at least as wide as the type of the right-hand side. In this case, we should change the type of totalTime from long to float to match the type of time. This will prevent the implicit narrowing conversion and maintain the precision of the time calculations.
- Change the type of
totalTimefromlongtofloatin theTimerclass. - Update the initialization of
totalTimein the constructor to match the new type.
-
Copy modified line R41 -
Copy modified line R54
| @@ -40,3 +40,3 @@ | ||
| /** Total elapsed time in milliseconds. */ | ||
| private long totalTime; | ||
| private float totalTime; | ||
|
|
||
| @@ -53,3 +53,3 @@ | ||
| this.time = 0; | ||
| this.totalTime = 0; | ||
| this.totalTime = 0f; | ||
| this.timeScale = 1f; |
No description provided.