Skip to content

⚡ Bolt: Optimize visibility checks for far targets - #2

Draft
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
bolt/optimize-visibility-distance-check-9426146196505327225
Draft

⚡ Bolt: Optimize visibility checks for far targets#2
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
bolt/optimize-visibility-distance-check-9426146196505327225

Conversation

@google-labs-jules

Copy link
Copy Markdown

💡 What: Added distance_to_squared to Vector3 and updated VisibilitySystem to use it for the initial range check. The system now returns early for targets beyond MAX_VISIBILITY_DISTANCE, skipping the expensive sqrt calculation (unless needed for return) and completely avoiding the angle_to calculation (which uses acos).

🎯 Why: compute_visibility is 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_visibility for targets at 5000 units (far) and 500 units (close).

  • Far (Old): ~0.67s
  • Far (New): ~0.33s
  • Close: ~0.76s (unchanged)

PR created automatically by Jules for task 9426146196505327225 started by @Pl4yer-ONE

- 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
@google-labs-jules

Copy link
Copy Markdown
Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

0 participants