You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 17:36:07 +00:00
Merge pull request #103845 from aaronfranke/fix-ed-stuck-cam-nonfin-xform
Fix stuck editor cameras and fix 3D error spam for non-finite transforms
This commit is contained in:
@@ -4882,31 +4882,30 @@ void CanvasItemEditor::_focus_selection(int p_op) {
|
|||||||
if (!ci) {
|
if (!ci) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const Transform2D canvas_item_transform = ci->get_global_transform();
|
||||||
// counting invisible items, for now
|
if (!canvas_item_transform.is_finite()) {
|
||||||
//if (!ci->is_visible_in_tree()) continue;
|
continue;
|
||||||
++count;
|
}
|
||||||
|
|
||||||
Rect2 item_rect;
|
Rect2 item_rect;
|
||||||
if (ci->_edit_use_rect()) {
|
if (ci->_edit_use_rect()) {
|
||||||
item_rect = ci->_edit_get_rect();
|
item_rect = ci->_edit_get_rect();
|
||||||
} else {
|
} else {
|
||||||
item_rect = Rect2();
|
item_rect = Rect2();
|
||||||
}
|
}
|
||||||
|
Vector2 pos = canvas_item_transform.get_origin();
|
||||||
Vector2 pos = ci->get_global_transform().get_origin();
|
const Vector2 scale = canvas_item_transform.get_scale();
|
||||||
Vector2 scale = ci->get_global_transform().get_scale();
|
const real_t angle = canvas_item_transform.get_rotation();
|
||||||
real_t angle = ci->get_global_transform().get_rotation();
|
|
||||||
pos = ci->get_viewport()->get_popup_base_transform().xform(pos);
|
pos = ci->get_viewport()->get_popup_base_transform().xform(pos);
|
||||||
|
|
||||||
Transform2D t(angle, Vector2(0.f, 0.f));
|
Transform2D t(angle, Vector2(0.f, 0.f));
|
||||||
item_rect = t.xform(item_rect);
|
item_rect = t.xform(item_rect);
|
||||||
Rect2 canvas_item_rect(pos + scale * item_rect.position, scale * item_rect.size);
|
Rect2 canvas_item_rect(pos + scale * item_rect.position, scale * item_rect.size);
|
||||||
if (count == 1) {
|
if (count == 0) {
|
||||||
rect = canvas_item_rect;
|
rect = canvas_item_rect;
|
||||||
} else {
|
} else {
|
||||||
rect = rect.merge(canvas_item_rect);
|
rect = rect.merge(canvas_item_rect);
|
||||||
}
|
}
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_op == VIEW_FRAME_TO_SELECTION && rect.size.x > CMP_EPSILON && rect.size.y > CMP_EPSILON) {
|
if (p_op == VIEW_FRAME_TO_SELECTION && rect.size.x > CMP_EPSILON && rect.size.y > CMP_EPSILON) {
|
||||||
|
|||||||
@@ -3001,6 +3001,9 @@ void Node3DEditorViewport::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Transform3D t = sp->get_global_gizmo_transform();
|
Transform3D t = sp->get_global_gizmo_transform();
|
||||||
|
if (!t.is_finite()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
AABB new_aabb = _calculate_spatial_bounds(sp);
|
AABB new_aabb = _calculate_spatial_bounds(sp);
|
||||||
|
|
||||||
exist = true;
|
exist = true;
|
||||||
@@ -4349,29 +4352,34 @@ void Node3DEditorViewport::focus_selection() {
|
|||||||
|
|
||||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||||
|
|
||||||
for (Node *E : selection) {
|
for (Node *node : selection) {
|
||||||
Node3D *sp = Object::cast_to<Node3D>(E);
|
Node3D *node_3d = Object::cast_to<Node3D>(node);
|
||||||
if (!sp) {
|
if (!node_3d) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
|
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(node_3d);
|
||||||
if (!se) {
|
if (!se) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (se->gizmo.is_valid()) {
|
if (se->gizmo.is_valid()) {
|
||||||
for (const KeyValue<int, Transform3D> &GE : se->subgizmos) {
|
for (const KeyValue<int, Transform3D> &GE : se->subgizmos) {
|
||||||
center += se->gizmo->get_subgizmo_transform(GE.key).origin;
|
const Vector3 pos = se->gizmo->get_subgizmo_transform(GE.key).origin;
|
||||||
count++;
|
if (pos.is_finite()) {
|
||||||
|
center += pos;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const Vector3 pos = node_3d->get_global_gizmo_transform().origin;
|
||||||
center += sp->get_global_gizmo_transform().origin;
|
if (pos.is_finite()) {
|
||||||
count++;
|
center += pos;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count != 0) {
|
if (count > 1) {
|
||||||
center /= count;
|
center /= count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4481,20 +4489,23 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos, Node3D
|
|||||||
}
|
}
|
||||||
|
|
||||||
AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, bool p_omit_top_level, const Transform3D *p_bounds_orientation) {
|
AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, bool p_omit_top_level, const Transform3D *p_bounds_orientation) {
|
||||||
AABB bounds;
|
|
||||||
|
|
||||||
Transform3D bounds_orientation;
|
|
||||||
if (p_bounds_orientation) {
|
|
||||||
bounds_orientation = *p_bounds_orientation;
|
|
||||||
} else {
|
|
||||||
bounds_orientation = p_parent->get_global_transform();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!p_parent) {
|
if (!p_parent) {
|
||||||
return AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4));
|
return AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4));
|
||||||
}
|
}
|
||||||
|
const Transform3D parent_transform = p_parent->get_global_transform();
|
||||||
|
if (!parent_transform.is_finite()) {
|
||||||
|
return AABB();
|
||||||
|
}
|
||||||
|
AABB bounds;
|
||||||
|
|
||||||
const Transform3D xform_to_top_level_parent_space = bounds_orientation.affine_inverse() * p_parent->get_global_transform();
|
Transform3D bounds_orientation;
|
||||||
|
Transform3D xform_to_top_level_parent_space;
|
||||||
|
if (p_bounds_orientation) {
|
||||||
|
bounds_orientation = *p_bounds_orientation;
|
||||||
|
xform_to_top_level_parent_space = bounds_orientation.affine_inverse() * parent_transform;
|
||||||
|
} else {
|
||||||
|
bounds_orientation = parent_transform;
|
||||||
|
}
|
||||||
|
|
||||||
const VisualInstance3D *visual_instance = Object::cast_to<VisualInstance3D>(p_parent);
|
const VisualInstance3D *visual_instance = Object::cast_to<VisualInstance3D>(p_parent);
|
||||||
if (visual_instance) {
|
if (visual_instance) {
|
||||||
@@ -6276,6 +6287,9 @@ void Node3DEditor::update_transform_gizmo() {
|
|||||||
if (se && se->gizmo.is_valid()) {
|
if (se && se->gizmo.is_valid()) {
|
||||||
for (const KeyValue<int, Transform3D> &E : se->subgizmos) {
|
for (const KeyValue<int, Transform3D> &E : se->subgizmos) {
|
||||||
Transform3D xf = se->sp->get_global_transform() * se->gizmo->get_subgizmo_transform(E.key);
|
Transform3D xf = se->sp->get_global_transform() * se->gizmo->get_subgizmo_transform(E.key);
|
||||||
|
if (!xf.is_finite()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
gizmo_center += xf.origin;
|
gizmo_center += xf.origin;
|
||||||
if ((unsigned int)count == se->subgizmos.size() - 1 && local_gizmo_coords) {
|
if ((unsigned int)count == se->subgizmos.size() - 1 && local_gizmo_coords) {
|
||||||
gizmo_basis = xf.basis;
|
gizmo_basis = xf.basis;
|
||||||
@@ -6300,6 +6314,9 @@ void Node3DEditor::update_transform_gizmo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Transform3D xf = sel_item->sp->get_global_transform();
|
Transform3D xf = sel_item->sp->get_global_transform();
|
||||||
|
if (!xf.is_finite()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
gizmo_center += xf.origin;
|
gizmo_center += xf.origin;
|
||||||
if (count == selection.size() - 1 && local_gizmo_coords) {
|
if (count == selection.size() - 1 && local_gizmo_coords) {
|
||||||
gizmo_basis = xf.basis;
|
gizmo_basis = xf.basis;
|
||||||
|
|||||||
Reference in New Issue
Block a user