mirror of
https://github.com/orange-cpp/omath.git
synced 2026-08-07 21:42:05 +00:00
patch
This commit is contained in:
@@ -10,7 +10,7 @@ namespace omath::algorithm
|
||||
template<class Camera, class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
Vector3<float> world_to_radar(const Camera& camera, const Vector3<FloatingType>& position, const FloatingType scale)
|
||||
Vector2<float> world_to_radar(const Camera& camera, const Vector3<FloatingType>& position, const FloatingType scale)
|
||||
{
|
||||
auto look_at_angles = camera.calc_look_at_angles(position);
|
||||
auto current_angles = camera.get_view_angles();
|
||||
@@ -20,7 +20,7 @@ namespace omath::algorithm
|
||||
- current_angles.yaw + decltype(current_angles.yaw)::from_degrees(180);
|
||||
const auto right_scale = right_yaw.sin() < 0 ? -1.f : 1.f;
|
||||
|
||||
return omath::Vector3<float>(static_cast<float>(yaw.sin()) * right_scale, yaw.cos(), 0.f)
|
||||
return omath::Vector2<float>(static_cast<float>(yaw.sin()) * right_scale, yaw.cos())
|
||||
* (camera.get_origin().distance_to(position) * scale);
|
||||
}
|
||||
} // namespace omath::algorithm
|
||||
|
||||
@@ -29,14 +29,12 @@ static void verify_world_to_radar_uses_engine_world_axes(const Vector3<NumericTy
|
||||
|
||||
EXPECT_NEAR(forward_radar.x, 0.f, 1e-4f);
|
||||
EXPECT_NEAR(forward_radar.y, -radar_distance, 1e-4f);
|
||||
EXPECT_NEAR(forward_radar.z, 0.f, 1e-6f);
|
||||
|
||||
const auto right_position = origin + world_right * world_distance;
|
||||
const auto right_radar = algorithm::world_to_radar(camera, right_position, scale);
|
||||
|
||||
EXPECT_NEAR(right_radar.x, radar_distance, 1e-4f);
|
||||
EXPECT_NEAR(right_radar.y, 0.f, 1e-4f);
|
||||
EXPECT_NEAR(right_radar.z, 0.f, 1e-6f);
|
||||
}
|
||||
|
||||
template<class CameraType, class NumericType>
|
||||
@@ -62,14 +60,12 @@ static void verify_world_to_radar_uses_changed_camera_yaw(const float yaw_degree
|
||||
|
||||
EXPECT_NEAR(forward_radar.x, 0.f, 1e-4f);
|
||||
EXPECT_NEAR(forward_radar.y, -radar_distance, 1e-4f);
|
||||
EXPECT_NEAR(forward_radar.z, 0.f, 1e-6f);
|
||||
|
||||
const auto left_position = origin + world_forward * world_distance;
|
||||
const auto left_radar = algorithm::world_to_radar(camera, left_position, scale);
|
||||
|
||||
EXPECT_NEAR(left_radar.x, -radar_distance, 1e-4f);
|
||||
EXPECT_NEAR(left_radar.y, 0.f, 1e-4f);
|
||||
EXPECT_NEAR(left_radar.z, 0.f, 1e-6f);
|
||||
}
|
||||
|
||||
template<class CameraType, class NumericType>
|
||||
@@ -93,7 +89,6 @@ static void verify_world_to_radar_ignores_camera_pitch(const Vector3<NumericType
|
||||
|
||||
EXPECT_NEAR(forward_radar.x, 0.f, 1e-4f);
|
||||
EXPECT_NEAR(forward_radar.y, -radar_distance, 1e-4f);
|
||||
EXPECT_NEAR(forward_radar.z, 0.f, 1e-6f);
|
||||
}
|
||||
|
||||
TEST(WorldToRadarTests, SourceEngineCamera)
|
||||
|
||||
Reference in New Issue
Block a user