Refactor: Major codebase cleanup and modernization#13
Merged
Conversation
Quick wins completed: - Replace raw pointer with unique_ptr in interactive mode (RAII) - Remove duplicate add_material(const LambertMaterial&) method - Update all call sites to use polymorphic API with make_unique - Fix memory safety issues Changes: - src/core/scene.hpp: Remove legacy add_material() overload - src/main.cpp: Use unique_ptr for interactive_material - tests/test_math_correctness.cpp: Update to polymorphic API Benefits: - Better memory safety with automatic cleanup - Consistent API usage throughout codebase - No raw pointer management needed
Implements a proper logging system to replace scattered quiet_mode booleans. New Features: - Logger class with 4 verbosity levels (Silent/Normal/Verbose/Debug) - Static API for global verbosity control - Helper methods: is_verbose(), is_quiet(), is_silent() - Command-line integration with --quiet and --verbose flags Changes: - src/core/logger.hpp: New Logger implementation - src/main.cpp: Replace quiet_mode with Logger calls throughout Benefits: - Centralized verbosity control - More granular output levels - Easier to extend in the future - Cleaner API than boolean parameters Note: Full integration into Scene/Material classes pending (those still use verbose boolean parameters, will be updated next)
## Changes ### Architecture Improvements - Extract CLI argument parsing to ArgumentParser class - Extract render logic from lambda to Renderer class - Consolidate rendering paths to unified Scene-based architecture - Create Constants namespace for magic numbers ### Code Quality - Remove fallback code paths (always use Scene system) - Consolidate performance tracking into Renderer::Stats struct - Remove unused includes (cstring in main.cpp) - Reduce console output verbosity by 30% ### Impact - main.cpp reduced by ~280 lines - Removed ~374 lines total across codebase - Improved maintainability and testability - All tests passing Co-Authored-By: Robot Assistant <noreply@example.com>
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
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.
Summary
This PR performs a comprehensive cleanup and modernization of the Educational Ray Tracer codebase, improving code organization, maintainability, and reducing complexity.
Key Changes
🏗️ Architecture Improvements
CLI Argument Parser Extraction (
src/cli/argument_parser.hpp)ArgumentParser::ConfigstructRenderer Class Extraction (
src/core/renderer.hpp)Renderer::StatsstructConstants Centralization (
src/core/constants.hpp)Constantsnamespace for magic numbers🧹 Code Cleanup
Unified Rendering Architecture
Dead Code Removal
#include <cstring>from main.cppimage_lightfallback (always use Scene lights)Verbosity Reduction
📊 Impact
Testing
./build_simple.sh)Breaking Changes
None - All existing functionality preserved.
Checklist