浏览代码

Portals - fix gizmo margin scaling

If the user changed the portal Z scale in the editor the portal margin display could become incorrectly sized.

This is because the portal margin is measured in world space units, and has to be back calculated into model space using the inverse global transform of the portal node. The model space size of the margin is thus tied to the current scale of the node.

This PR forces updating the gizmo each time the transform is changed. This isn't super efficient, but as this is an editor only feature it should be okay, and it is unlikely to be a performance problem.
lawnjelly 4 年之前
父节点
当前提交
d578ea99b9
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      scene/3d/portal.cpp

+ 9 - 0
scene/3d/portal.cpp

@@ -167,6 +167,15 @@ void Portal::_notification(int p_what) {
 		case NOTIFICATION_TRANSFORM_CHANGED: {
 			// keep the world points and the visual server up to date
 			portal_update();
+
+			// In theory we shouldn't need to update the gizmo when the transform
+			// changes .. HOWEVER, the portal margin is displayed in world space units,
+			// back transformed to model space.
+			// If the Z scale is changed by the user, the portal margin length can become incorrect
+			// and needs 'resyncing' to the global scale of the portal node.
+			// We really only need to do this when Z scale is changed, but it is easier codewise
+			// to always change it, unless we have evidence this is a performance problem.
+			update_gizmo();
 		} break;
 	}
 }