core, android: add support for camera roll (#3011)

This commit is contained in:
Nathan Olson
2026-01-20 00:57:48 -08:00
committed by GitHub
parent a4cf4d3ffa
commit 10dbd5d68d
57 changed files with 1275 additions and 207 deletions

View File

@@ -180,8 +180,8 @@ TEST(FreeCameraOptions, LookAtPoint) {
ASSERT_TRUE(options.orientation);
std::tie(right, up, forward) = rotatedFrame(options.orientation.value());
ASSERT_THAT(right, Vec3NearEquals1E7(vec3{{0.0, 1.0, 0.0}}));
ASSERT_THAT(up, Vec3NearEquals1E7(vec3{{0.0, 0.0, 1.0}}));
ASSERT_THAT(right, Vec3NearEquals1E7(vec3{{0.0, 0.9714568644195829, 0.2372162738348117}}));
ASSERT_THAT(up, Vec3NearEquals1E7(vec3{{0.0, -0.23721627383481167, 0.97145686441958301}}));
ASSERT_THAT(forward, Vec3NearEquals1E7(vec3{{1.0, 0.0, 0.0}}));
// Up vector pointing downwards
@@ -226,18 +226,18 @@ TEST(FreeCameraOptions, LookAtPointInvalidInput) {
ASSERT_FALSE(options.orientation);
}
TEST(FreeCameraOptions, SetPitchBearing) {
TEST(FreeCameraOptions, SetRollPitchBearing) {
FreeCameraOptions options;
vec3 right, up, forward;
options.setPitchBearing(0.0, 0.0);
options.setRollPitchBearing(0.0, 0.0, 0.0);
ASSERT_TRUE(options.orientation);
std::tie(right, up, forward) = rotatedFrame(options.orientation.value());
ASSERT_THAT(right, Vec3NearEquals1E7(vec3{{1.0, 0.0, 0.0}}));
ASSERT_THAT(up, Vec3NearEquals1E7(vec3{{0.0, -1.0, 0.0}}));
ASSERT_THAT(forward, Vec3NearEquals1E7(vec3{{0.0, 0.0, -1.0}}));
options.setPitchBearing(0.0, 180.0);
options.setRollPitchBearing(0.0, 0.0, 180.0);
ASSERT_TRUE(options.orientation);
std::tie(right, up, forward) = rotatedFrame(options.orientation.value());
ASSERT_THAT(right, Vec3NearEquals1E7(vec3{{-1.0, 0.0, 0.0}}));
@@ -247,14 +247,14 @@ TEST(FreeCameraOptions, SetPitchBearing) {
const double cos60 = std::cos(util::deg2rad(60.0));
const double sin60 = std::sin(util::deg2rad(60.0));
options.setPitchBearing(60.0, 0.0);
options.setRollPitchBearing(0.0, 60.0, 0.0);
ASSERT_TRUE(options.orientation);
std::tie(right, up, forward) = rotatedFrame(options.orientation.value());
ASSERT_THAT(right, Vec3NearEquals1E7(vec3{{1.0, 0.0, 0.0}}));
ASSERT_THAT(up, Vec3NearEquals1E7(vec3{{0.0, -cos60, sin60}}));
ASSERT_THAT(forward, Vec3NearEquals1E7(vec3{{0.0, -sin60, -cos60}}));
options.setPitchBearing(60.0, -450);
options.setRollPitchBearing(0.0, 60.0, -450);
ASSERT_TRUE(options.orientation);
std::tie(right, up, forward) = rotatedFrame(options.orientation.value());
ASSERT_THAT(right, Vec3NearEquals1E7(vec3{{0.0, 1.0, 0.0}}));