⚡ Bolt: Optimize visibility checks for far targets - #2
⚡ Bolt: Optimize visibility checks for far targets#2google-labs-jules[bot] wants to merge 1 commit into
Conversation
- Add `distance_to_squared` to `Vector3` to avoid unnecessary sqrts - Update `VisibilitySystem` to check squared distance first - Skip expensive angle calculations for out-of-range targets - Reduces visibility computation time by ~50% for distant targets
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Added
distance_to_squaredtoVector3and updatedVisibilitySystemto use it for the initial range check. The system now returns early for targets beyondMAX_VISIBILITY_DISTANCE, skipping the expensivesqrtcalculation (unless needed for return) and completely avoiding theangle_tocalculation (which usesacos).🎯 Why:
compute_visibilityis a hot path called for N*N player pairs every tick. On large maps, many players are outside visibility range. Calculating angles (trigonometry) for them is wasted CPU cycles.📊 Impact: Benchmarks show a ~50% reduction in execution time for far-away targets (from 0.67s to 0.33s for 100k iterations). Close-range performance remains unchanged.
🔬 Measurement:
Ran a benchmark script comparing 100k iterations of
compute_visibilityfor targets at 5000 units (far) and 500 units (close).PR created automatically by Jules for task 9426146196505327225 started by @Pl4yer-ONE