some little changed
This commit is contained in:
@ -15,6 +15,17 @@ namespace Prism
|
||||
{
|
||||
glm::vec3 Origin, Direction;
|
||||
|
||||
Ray(const glm::vec3& origin, const glm::vec3& direction)
|
||||
{
|
||||
Origin = origin;
|
||||
Direction = direction;
|
||||
}
|
||||
|
||||
static Ray Zero()
|
||||
{
|
||||
return {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f} };
|
||||
}
|
||||
|
||||
bool IntersectsAABB(const AABB& aabb, float& t) const
|
||||
{
|
||||
glm::vec3 dirfrac;
|
||||
|
||||
@ -46,11 +46,9 @@ namespace Prism
|
||||
if (Input::IsKeyPressed(Key::LEFT_ALT))
|
||||
{
|
||||
const glm::vec2& mouse{ Input::GetMouseX(), Input::GetMouseY() };
|
||||
glm::vec2 delta = mouse - m_InitialMousePosition;
|
||||
const glm::vec2 delta = (mouse - m_InitialMousePosition) * 0.003f;
|
||||
m_InitialMousePosition = mouse;
|
||||
|
||||
delta *= deltaTime.GetSeconds();
|
||||
|
||||
if (Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_MIDDLE))
|
||||
MousePan(delta);
|
||||
else if (Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_LEFT))
|
||||
@ -68,17 +66,17 @@ namespace Prism
|
||||
dispatcher.Dispatch<MouseScrolledEvent>(PM_BIND_EVENT_FN(Camera::OnMouseScroll));
|
||||
}
|
||||
|
||||
glm::vec3 Camera::GetUpDirection()
|
||||
glm::vec3 Camera::GetUpDirection() const
|
||||
{
|
||||
return glm::rotate(GetOrientation(), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
}
|
||||
|
||||
glm::vec3 Camera::GetRightDirection()
|
||||
glm::vec3 Camera::GetRightDirection() const
|
||||
{
|
||||
return glm::rotate(GetOrientation(), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
glm::vec3 Camera::GetForwardDirection()
|
||||
glm::vec3 Camera::GetForwardDirection() const
|
||||
{
|
||||
return glm::rotate(GetOrientation(), glm::vec3(0.0f, 0.0f, -1.0f));
|
||||
}
|
||||
@ -125,12 +123,12 @@ namespace Prism
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec3 Camera::CalculatePosition()
|
||||
glm::vec3 Camera::CalculatePosition() const
|
||||
{
|
||||
return m_FocalPoint - GetForwardDirection() * m_Distance;
|
||||
}
|
||||
|
||||
glm::quat Camera::GetOrientation()
|
||||
glm::quat Camera::GetOrientation() const
|
||||
{
|
||||
return glm::quat(glm::vec3(-m_Pitch, -m_Yaw, 0.0f));
|
||||
}
|
||||
|
||||
@ -32,14 +32,18 @@ namespace Prism
|
||||
const glm::mat4& GetViewMatrix() const { return m_ViewMatrix; }
|
||||
glm::mat4 GetViewProjection() const { return m_ProjectionMatrix * m_ViewMatrix; }
|
||||
|
||||
glm::vec3 GetUpDirection();
|
||||
glm::vec3 GetRightDirection();
|
||||
glm::vec3 GetForwardDirection();
|
||||
glm::vec3 GetUpDirection() const;
|
||||
glm::vec3 GetRightDirection() const;
|
||||
glm::vec3 GetForwardDirection() const;
|
||||
const glm::vec3& GetPosition() const { return m_Position; }
|
||||
glm::quat GetOrientation() const;
|
||||
|
||||
float GetExposure() const { return m_Exposure; }
|
||||
float& GetExposure() { return m_Exposure; }
|
||||
|
||||
float GetPitch() const { return m_Pitch; }
|
||||
float GetYaw() const { return m_Yaw; }
|
||||
|
||||
public:
|
||||
inline void SetViewportSize(const uint32_t width, const uint32_t height) { m_ViewportWidth = width; m_ViewportHeight = height; }
|
||||
private:
|
||||
@ -50,8 +54,7 @@ namespace Prism
|
||||
void MouseRotate(const glm::vec2& delta);
|
||||
void MouseZoom(float delta);
|
||||
|
||||
glm::vec3 CalculatePosition();
|
||||
glm::quat GetOrientation();
|
||||
glm::vec3 CalculatePosition() const;
|
||||
|
||||
std::pair<float, float> PanSpeed() const;
|
||||
float RotationSpeed() const;
|
||||
|
||||
Reference in New Issue
Block a user