bevyengine / bevyengine/bevy

Add cached matrix operations to `Camera`.

Open
#17,985 2 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Performance C-Usability S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Many `Camera` operations like `world_to_viewport` internally inverses an uncached intermediate matrix, this is quite slow if done multiple times and the user has no choice to improve the performance other than reimplementing these methods.

## What solution would you like?

Add or change the function signatures
```rust
pub fn world_to_viewport(
&self,
camera_transform: &GlobalTransform,
world_position: Vec3,
)
```

to

```rust
pub fn world_to_viewport_cached(
&self,
camera_transform: &GlobalTransform,
world_position: Vec3,
cached_matrix: &mut Option,
)
```

## What alternative(s) have you considered?

Provide functions returning the matrices.

```rust
pub fn world_to_viewport_matrix(
&self,
camera_transform: &GlobalTransform,
world_position: Vec3
) -> Mat4
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.