Skip to content

Commit 8ac1430

Browse files
committed
test
1 parent edaa222 commit 8ac1430

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/world/camera.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ void cg::world::camera::set_angle_of_view(float in_aov)
4040
void cg::world::camera::set_height(float in_height)
4141
{
4242
height = in_height;
43-
aspect_ratio = width/height;
43+
aspect_ratio = width / height;
4444
}
4545

4646
void cg::world::camera::set_width(float in_width)
4747
{
4848
width = in_width;
49-
aspect_ratio = width/height;
49+
aspect_ratio = width / height;
5050
}
5151

5252
void cg::world::camera::set_z_near(float in_z_near)
@@ -61,27 +61,29 @@ void cg::world::camera::set_z_far(float in_z_far)
6161

6262
const float4x4 cg::world::camera::get_view_matrix() const
6363
{
64-
float3 up{0.f,1.f,0.f};
64+
float3 up{0.f, 1.f, 0.f};
6565
float3 eye = position + get_direction();
6666

6767
float3 z_axis = normalize(position - eye);
6868
float3 x_axis = normalize(cross(up, z_axis));
69-
float3 y_axis = cross(z_axis,x_axis);
69+
float3 y_axis = cross(z_axis, x_axis);
7070
return float4x4{
7171
{x_axis.x, y_axis.x, z_axis.x, 0},
7272
{x_axis.y, y_axis.y, z_axis.y, 0},
7373
{x_axis.z, y_axis.z, z_axis.z, 0},
74-
{-dot(x_axis, position), -dot(y_axis, position), -dot(z_axis, position), 1}
75-
};
74+
{-dot(x_axis, position), -dot(y_axis, position), -dot(z_axis, position), 1}};
7675
}
7776

7877
#ifdef DX12
7978
const DirectX::XMMATRIX cg::world::camera::get_dxm_view_matrix() const
8079
{
81-
DirectX::FXMVECTOR eye_position{position.x, position.y, position.z};
82-
DirectX::FXMVECTOR eye_direction{get_direction().x, get_direction().y, get_direction().z};
83-
DirectX::FXMVECTOR up_direction{get_up().x, get_up().y, get_up().z};
84-
return DirectX::XMMatrixLookToRH(eye_position,eye_direction,up_direction);
80+
DirectX::XMFLOAT3 eye_position{position.x, position.y, position.z};
81+
DirectX::XMFLOAT3 eye_direction{get_direction().x, get_direction().y, get_direction().z};
82+
DirectX::XMFLOAT3 up_direction{get_up().x, get_up().y, get_up().z};
83+
return DirectX::XMMatrixLookToRH(
84+
DirectX::XMLoadFloat3(&eye_position),
85+
DirectX::XMLoadFloat3(&eye_direction),
86+
DirectX::XMLoadFloat3(&up_direction));
8587
}
8688

8789
const DirectX::XMMATRIX cg::world::camera::get_dxm_projection_matrix() const
@@ -90,8 +92,7 @@ const DirectX::XMMATRIX cg::world::camera::get_dxm_projection_matrix() const
9092
angle_of_view,
9193
aspect_ratio,
9294
z_near,
93-
z_far
94-
);
95+
z_far);
9596
}
9697

9798
const DirectX::XMMATRIX camera::get_dxm_mvp_matrix() const
@@ -102,12 +103,12 @@ const DirectX::XMMATRIX camera::get_dxm_mvp_matrix() const
102103

103104
const float4x4 cg::world::camera::get_projection_matrix() const
104105
{
105-
float f= 1.f/ tanf(angle_of_view/2.f);
106+
float f = 1.f / tanf(angle_of_view / 2.f);
106107
return float4x4{
107-
{f/aspect_ratio, 0, 0, 0},
108+
{f / aspect_ratio, 0, 0, 0},
108109
{0, f, 0, 0},
109-
{0, 0, z_far/(z_near-z_far), -1},
110-
{0, 0, (z_far*z_near)/(z_near-z_far), 0},
110+
{0, 0, z_far / (z_near - z_far), -1},
111+
{0, 0, (z_far * z_near) / (z_near - z_far), 0},
111112

112113
};
113114
}
@@ -120,10 +121,9 @@ const float3 cg::world::camera::get_position() const
120121
const float3 cg::world::camera::get_direction() const
121122
{
122123
return float3{
123-
sin(theta)*cos(phi),
124+
sin(theta) * cos(phi),
124125
sin(phi),
125-
-cos(theta)*cos(phi)
126-
};
126+
-cos(theta) * cos(phi)};
127127
}
128128

129129
const float3 cg::world::camera::get_right() const
@@ -133,7 +133,7 @@ const float3 cg::world::camera::get_right() const
133133

134134
const float3 cg::world::camera::get_up() const
135135
{
136-
return cross(get_right(),get_direction());
136+
return cross(get_right(), get_direction());
137137
}
138138
const float camera::get_theta() const
139139
{

0 commit comments

Comments
 (0)