-
Notifications
You must be signed in to change notification settings - Fork 165
3d camera feature #256
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
base: main
Are you sure you want to change the base?
3d camera feature #256
Conversation
Summary of ChangesHello @Mosch0512, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new 3D camera feature, enabling players to control their viewpoint with greater flexibility. The system allows for dynamic zooming, horizontal rotation, and vertical pitching around the character, enhancing the overall immersion and perspective. To support this new camera, several rendering components have been updated to correctly display terrain, effects, and pointers, ensuring visual consistency and functionality across different camera settings. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new CCustomCamera3D system, enabling players to control camera zoom, horizontal rotation, and vertical pitch using the mouse wheel and middle mouse button, toggled by the F9 key. The new camera system dynamically adjusts rendering parameters such as frustum culling, object visibility range, pointer scaling, and terrain rendering bounds based on the camera's zoom level to prevent visual artifacts when zoomed out. It also includes a fix for an incorrect mouse button state in Winmain.cpp and ensures proper camera state restoration in ZzzOpenglUtil.cpp. Review comments suggest replacing while loops for angle normalization with fmodf, using a dedicated boolean flag instead of (0,0,0) to track the initial camera offset, removing an unused m_bF9KeyPressed member, and replacing several 'magic numbers' with named constants for improved readability and maintainability, along with removing a debug logging block.
7fdf626 to
64344d5
Compare
… module and replace legacy functions across the codebase. Remove redundant utility methods from `ZzzOpenglUtil`.
…ogic in `CameraUtility` with a modular and reusable design.
…luding `DefaultCamera`, `OrbitalCamera`, and editor-only `FreeFlyCamera`. Integrate mode switching via F9 key.
…ng modularity and enabling culling logic for `DefaultCamera` and `OrbitalCamera`.
…ining compatibility with legacy frustum logic.
…port; retain legacy frustum logic as fallback.
…amic culling; update frustum logic in `DefaultCamera` and `OrbitalCamera` to use `ViewFar`.
… `ICamera` and update rendering logic for compatibility.
…opped items, weather effects, item labels, and UI; refactored related logic for improved clarity and modularity.
…amera` and `Frustum` integration; update rendering functions for compatibility.
… scenarios in `DefaultCamera` and `OrbitalCamera`
…rendering steps for sth
…cing change checks to reduce unnecessary rebuilds; improve performance by ~20-25%. Adjust fallback logic and add support for tour mode camera positioning in `DefaultCamera`.
…r mode, validate tour position, and set default LoginScene camera values.
…itor far-plane override logic for improved frustum control.
…rbital camera offsets, default zoom, and fog pitch thresholds for improved depth, visibility, and character framing.
…alculations for dropped items to reflect camera movement.
…helper functions for clarity and reusability.
… with hardcoded 640×480 reference scaling for consistent UI rendering and game viewport calculations.
…config.ini` management. Add resolution-dependent camera updates and inventory slot refresh for 3D rendering.
…mensions` and `UpdateAllCameraDimensions` methods to streamline width and height adjustments for proper rendering. Ensure dimensions are updated during window resizing.
…onstants.h` for unified culling definitions. Replace hardcoded culling radii with constants across terrain, objects, characters, and items. Add debug visualization of culling spheres in DevEditor.
…eConfig::GetInstance()`
… tile loops based on camera position and view distance instead of iterating all 256x256 tiles
…ck cull radius from 18000 to 1500
…d 16 expensive frustum tests per block
…rbital → Legacy → Default
…nCamera() Replaces the DefaultCamera-inherited stub with a full standalone ICamera implementation that exactly replicates the original camera logic: position calculation, angle setting, FOV, view distance, and custom camera distance. Uses cheap distance-based culling instead of 3D frustum sphere tests.
Add Frustum::TestPoint2D() — a cheap 2D ground-plane projection test using the convex hull of frustum vertices projected to XY. Computed once per frame via Andrew's monotone chain, then tested with the same cross-product winding algorithm as the original TestFrustrum2D. Replace expensive 6-plane sphere tests (~100K/frame) with the cheap 2D test for: TestFrustrum2D shim, ShouldCullTerrain in DefaultCamera and OrbitalCamera. Fix LegacyCamera: replace removed globals (CameraDistance, CameraDistanceTarget, g_fCameraCustomDistance) with CameraState members (m_State.Distance, m_State.DistanceTarget, m_State.CustomDistance).
TestFrustrum2D/TestFrustrum were calling CameraManager::Instance() + virtual GetActiveCamera() + virtual GetFrustum() tens of thousands of times per frame. Now cached once after camera update via CacheActiveFrustum(), reducing each call to a single pointer deref.
…tum AABB, fix release build - Disable fog for Legacy/other cameras to match main branch behavior - Use frustum AABB for tight terrain iteration bounds instead of circle fallback - Move cached frustum pointers before UpdateFrustrumBounds (scope fix) - Guard MuEditorConsoleUI.h includes with #ifdef _EDITOR for non-editor builds - Enable RenderDebugInfo in _EDITOR builds (not just _DEBUG)
- Restore CreateFrustrum2D/CreateFrustrum with FrustrumX/Y arrays from main branch, adapted for g_Camera.* globals - Restore original TestFrustrum2D (4-vertex cross-product winding) and TestFrustrum (5-plane dot product) using file-static arrays - Revert ZzzObject block/object/LoginScene culling to TestFrustrum2D - Revert ZzzCharacter visibility to TestFrustrum2D - Revert RenderTerrainFrustrum to TestFrustrum2D - Remove unused ICamera* parameter passing from RenderGameWorld - Simplify fog logic: replace strcmp with CameraMode enum check - Simplify MoveMainCamera: remove UpdateFrustrumBounds call
OrbitalCamera's Frustum class already computes a correct 2D ground projection, but the legacy rendering pipeline ignored it and used hardcoded trapezoid tables that assume fixed pitch. This bridges the gap: - Expand FrustrumX/Y arrays to [8] with FrustrumCount for convex hulls - CreateFrustrum2D copies camera's 2D projection when Orbital is active - TestFrustrum2D uses FrustrumCount instead of hardcoded 4 - Add Get2DCount/Get2DX/Get2DY public accessors to Frustum class - Rename UpdateConfigForZoom to UpdateConfigForView (zoom-only scaling) - Update fog to 80% start / 90% end of far plane for OrbitalCamera
Replace vertical FOV with horizontal FOV (hFov) throughout the camera system. Vertical FOV is now derived at runtime via HFovToVFov() based on current aspect ratio. This gives wider FOV on widescreen displays while preserving the original ~30° vFOV on 4:3 for DefaultCamera. - CameraConfig: fov→hFov, add HFovToVFov() utility - OrbitalCamera: hFov=90° (~59° vFOV on 16:9), farPlane 7560→3800 - DefaultCamera/CharacterScene: hFov=40° (preserves original look) - DevEditor: slider shows hFOV + computed vFOV, add objectCullRange - FreeFlyCamera/LegacyCamera: same hFov→vFov conversion pattern
…and color coding - Scale far-plane vertices by RENDER_DISTANCE_MULTIPLIER to match actual GL projection - Add semi-transparent filled side planes for volume visibility from any angle - Draw 2D convex hull ground projection on terrain with elevation-following subdivision - Color-code wireframe: green (near), red (far), yellow (sides), cyan (camera)
…k-down crash - Add yellow ground projection showing 10% buffer zone outside green frustum footprint - Expand 2D culling hull by 10% from centroid so terrain renders within buffer zone - Compute FreeFly iteration bounds from expanded hull instead of original AABB - Fix degenerate cross product in OrbitalCamera when looking straight down at 90° elevation
- Add UpdateFrustum() to LegacyCamera so spectating shows proper frustum wireframe - SetConfig() now triggers frustum rebuild in LegacyCamera - Compute actual frustum apex (eye position) from near/far plane geometry instead of using near-plane center, fixing camera marker placement - Add degenerate cross-product fix to DefaultCamera::UpdateFrustum()
added 3d camera
its not perfect i had to limit the pitch when camera is close to ground due to rendering issues i could not solve
closes #253