Restore pixel perfect camera code.

This commit is contained in:
2024-11-25 20:59:29 -06:00
parent a2c841288d
commit de55029356
19 changed files with 245 additions and 31 deletions

View File

@@ -56,6 +56,20 @@ float_t Camera::getAspect() {
return rt->getWidth() / rt->getHeight();
}
float_t Camera::lookAtPixelPerfect(
const glm::vec3 &position,
const glm::vec3 &look,
const float_t &scale
) {
return this->getItem()->lookAtPixelPerfect(
position,
look,
this->getRenderTarget()->getHeight(),
this->fov,
scale
);
}
void Camera::setRenderTarget(std::shared_ptr<RenderTarget> renderTarget) {
onResizeListener();
this->renderTarget = renderTarget;

View File

@@ -57,6 +57,20 @@ namespace Dawn {
*/
glm::mat4 getProjection();
/**
* Shorthand for getItem()->lookAtPixelPerfect()
*
* @param position Position to look from.
* @param look Position to look at.
* @param scale Scale to use. At scale 1 then the centerest pixel is 1:1.
* @return The Z distance that was calculated.
*/
float_t lookAtPixelPerfect(
const glm::vec3 &position,
const glm::vec3 &look,
const float_t &scale = 1.0f
);
/**
* Sets the render target for this camera.
*