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

Fix Star Flickering by Positioning on Unit Sphere #283

Merged
merged 7 commits into from
Dec 19, 2024

Conversation

AdrienBousquieEPFL
Copy link
Contributor

Description

This pull request resolves the issue of stars flickering (disappearing and reappearing) when rendered at the middle of the screen. The problem was caused by stars being positioned on a sphere with a radius of 100, which matches the camera's maximum view distance. This update repositions all stars onto a unit sphere (radius of 1.0) to ensure consistent rendering.

Changes

  • CelestialObjectsUtils.kt:
    • Removed the SCALING_FACTOR to calculate positions on a unit sphere instead of a sphere with a radius of 100.
  • Affected Tests:
    • Updated tests in CelestialObjectsUtilTest.kt to align with the new unit sphere logic.
    • Removed hardcoded scaling factors from expected test values.

Testing

  • Verified that stars are consistently rendered on the unit sphere.
  • Confirmed no flickering or rendering inconsistencies during camera movements.
  • Ensured all affected tests pass with the new logic.

Removed `SCALING_FACTOR` in `CelestialObjectsUtils` to make the stars render on the unit sphere.

This update ensures that the stars render correctly as the 100 scale factor was making the stars tilting cause the max view distance is 100 (see `Camera.kt`).
…ed imports

Renamed package `utils` to `util` for `CelestialObjectsUtils` to maintain consistency.
Updated imports across the project to reflect the new package structure.
Moved `StarDataRepositoryTest` to align with the updated `map/stars` directory structure.
Removed unused field-of-view constants from `MapViewModel.kt`.
Adjusted formatting and fixed imports in `MapRenderer`, `Moon`, `PlanetsRepository`, and `StarsLoader`.
Cleaned up redundant dependencies and ensured consistency in utility usage.

This refactor improves code organization, readability, and adheres to updated package naming conventions.
Updated `CelestialObjectsUtilTest.kt` to adapt to the previous refactoring commit.
Added `TODO` comments for deprecated or unused test functions (`convertToHorizonCoordinates`).
@AdrienBousquieEPFL AdrienBousquieEPFL self-assigned this Dec 16, 2024
@AdrienBousquieEPFL AdrienBousquieEPFL linked an issue Dec 16, 2024 that may be closed by this pull request
Updated `Moon.kt` to include a scale of `0.05f` for rendering.
Modified `Planet.kt` to change the default scale from `0.3f` to `0.02f`.

These changes ensure consistent rendering proportions across celestial objects since we changed the projection on a unit sphere.
# Conflicts:
#	app/src/main/java/com/github/lookupgroup27/lookup/model/map/stars/StarsLoader.kt
Annotated `getMoonPhaseTextureId` in `Moon.kt` with `@VisibleForTesting` to enable testing.
Added a new test class `MoonTest` to validate moon phase texture ID mapping for various dates.
Verified results against expected drawable resources for moon phases.
Moved `StarsLoader` to the correct package `com.github.lookupgroup27.lookup.model.map.stars`.
Removed unnecessary import of `StarDataRepository`.
Simplified the creation of `Star` objects by removing the redundant `color` parameter.

Affected files:
- `StarsLoader.kt`: Adjusted package declaration, imports, and star creation logic.
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
57.14% Line Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@AdrienBousquieEPFL
Copy link
Contributor Author

Improving the code coverage in this area is highly ineffective due to the need for a full mock of a GLSurfaceView, which introduces significant overhead for testing the Moon attributes. These attributes are trivially initialized, and the effort required to cover this code does not justify the complexity it adds.

As a result, we will skip the SonarCloud analysis for this specific test to maintain efficiency and focus on more impactful improvements.

Copy link
Contributor

@mehdi-hamirifou mehdi-hamirifou left a comment

Choose a reason for hiding this comment

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

Great job addressing this issue. The changes are well done, and it's good to see the testable features were covered.

While the new code coverage falls short of passing the quality gate, this is primarily because the affected classes rely on a non-mockable OpenGL environment, making comprehensive testing challenging.

Given the limitations of the testing environment and the correctness of the implementation, I approve this pull request for merging.

@AdrienBousquieEPFL AdrienBousquieEPFL merged commit 9ea9eb4 into main Dec 19, 2024
2 of 3 checks passed
@AdrienBousquieEPFL AdrienBousquieEPFL deleted the fix/282-stars-flicker branch December 19, 2024 09:38
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.

Stars Flicker in the Middle of the Screen
2 participants