Perf: Improve Shark AI performance by optimizing proximity checks and caching spline data#6
Open
adhishcantcode wants to merge 3 commits into
Open
Conversation
Switched Vector3.Distance to sqrMagnitude to reduce CPU overhead. Fixed OnInkHit dependency to prevent simulation crashes. Improved frame rate from 43 to 95 FPS.
Refactored proximity checks to use sqrMagnitude and moved heavy spline calculations to Start(). Reduced CPU latency from 22.8ms to 10.5ms.
Author
|
Hi, I wanted to share a quick update regarding this PR. I’ve tested the changes thoroughly and verified the performance improvements and stability across different scenarios. The optimization reduces frame time significantly and improves overall runtime efficiency. I’m currently applying for GSoC 2026 with the AR Gravity & Planetary Physics Simulator project and this contribution is part of my work with the mARine codebase. I would really appreciate any feedback or suggestions whenever you have time. Thanks! |
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.
Description
This PR improves the runtime performance of the Predator (Shark) AI system by optimizing per-frame computations and reducing unnecessary mathematical overhead.
The changes significantly improve frame rate and reduce CPU usage, especially in scenarios with many active agents, ensuring a smoother experience on mobile AR devices.
Key Optimizations
Test Setup
Visual Proof
Before Optimization (~43 FPS)
After Optimization (~95 FPS)
Scene Stress Test (50+ Agents)
Runtime Demonstration
Impact
Notes