added camera_world_to_pixel_point

This commit is contained in:
Sara 2023-10-06 23:43:35 +02:00
parent c62fed8ec2
commit 0c9e840986
2 changed files with 10 additions and 0 deletions

View file

@ -33,3 +33,12 @@ SDL_FRect camera_world_to_pixel_rect(Camera* self, SDL_FRect* world_space) {
size.x, size.y size.x, size.y
}; };
} }
Vector camera_world_to_pixel_point(Camera* self, Vector point) {
Transform t = self->transform;
t.rotation = 0;
t.scale = OneVector;
t = transform_invert(t);
return vmulff(transform_point(&t, point), g_render_resolution.x / self->fov);
}

View file

@ -18,5 +18,6 @@ extern Camera g_camera;
extern void camera_init(); extern void camera_init();
extern SDL_FRect camera_screen_to_world_space(Camera* self, SDL_FRect* camera_space); extern SDL_FRect camera_screen_to_world_space(Camera* self, SDL_FRect* camera_space);
extern SDL_FRect camera_world_to_pixel_rect(Camera* self, SDL_FRect* world_space); extern SDL_FRect camera_world_to_pixel_rect(Camera* self, SDL_FRect* world_space);
extern Vector camera_world_to_pixel_point(Camera* self, Vector point);
#endif // !_fencer_camera_h #endif // !_fencer_camera_h