feat(editor): rotation display in UE's 0-360 convention
User pointed out the real gap: UE Details shows rotation in [0,360) (-90 reads 270); our readback exposed [-180,180] with negative zeros. GetRotation now wraps each axis to [0,360) via fmod -- strictly equivalent math (each axis has 360-degree period), so matrix-rebuild consumers like Camera::EulerRotMat are unaffected. The one consumer needing a continuous domain is the free-look pitch clamp [-89,89] in Camera::Update, which wraps back to [-180,180) before applying deltas.
This commit is contained in:
@@ -52,6 +52,14 @@ namespace Engine {
|
||||
if (mouseDX != 0 || mouseDY != 0)
|
||||
{
|
||||
glm::vec3 rot = transform.GetRotation();
|
||||
// GetRotation 是 0-360 显示域(UE Details 约定);pitch 的
|
||||
// clamp 需要连续域,wrap 回 [-180,180)(yaw 同步处理,
|
||||
// 跨 ±180 继续累减不打折返)
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
rot[i] = std::fmod(rot[i], 360.0f);
|
||||
if (rot[i] >= 180.0f) rot[i] -= 360.0f;
|
||||
if (rot[i] < -180.0f) rot[i] += 360.0f;
|
||||
}
|
||||
// 右手系绕 Y 正角度 = 向左转,鼠标右移(DX>0)应看向右
|
||||
// → yaw 取负。pitch 正角度 = 抬头,鼠标下移(DY>0)低头
|
||||
// → rot.x 直接用负号,两者符号已核对一致
|
||||
|
||||
Reference in New Issue
Block a user