You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Fix crash when box selecting remote 3D physics nodes
This commit is contained in:
@@ -2660,13 +2660,18 @@ void RuntimeNodeSelect::_find_3d_items_at_rect(const Rect2 &p_rect, Vector<Selec
|
|||||||
shape.instantiate();
|
shape.instantiate();
|
||||||
shape->set_points(points);
|
shape->set_points(points);
|
||||||
|
|
||||||
|
// Keep track of the currently listed nodes, so repeats can be ignored.
|
||||||
|
HashSet<Node *> node_list;
|
||||||
|
|
||||||
// Start with physical objects.
|
// Start with physical objects.
|
||||||
PhysicsDirectSpaceState3D *ss = root->get_world_3d()->get_direct_space_state();
|
PhysicsDirectSpaceState3D *ss = root->get_world_3d()->get_direct_space_state();
|
||||||
PhysicsDirectSpaceState3D::ShapeResult result;
|
PhysicsDirectSpaceState3D::ShapeResult results[32];
|
||||||
PhysicsDirectSpaceState3D::ShapeParameters shape_params;
|
PhysicsDirectSpaceState3D::ShapeParameters shape_params;
|
||||||
shape_params.shape_rid = shape->get_rid();
|
shape_params.shape_rid = shape->get_rid();
|
||||||
shape_params.collide_with_areas = true;
|
shape_params.collide_with_areas = true;
|
||||||
if (ss->intersect_shape(shape_params, &result, 32)) {
|
const int num_hits = ss->intersect_shape(shape_params, results, 32);
|
||||||
|
for (int i = 0; i < num_hits; i++) {
|
||||||
|
const PhysicsDirectSpaceState3D::ShapeResult &result = results[i];
|
||||||
SelectResult res;
|
SelectResult res;
|
||||||
res.item = Object::cast_to<Node>(result.collider);
|
res.item = Object::cast_to<Node>(result.collider);
|
||||||
res.order = -dist_pos.distance_to(Object::cast_to<Node3D>(res.item)->get_global_transform().origin);
|
res.order = -dist_pos.distance_to(Object::cast_to<Node3D>(res.item)->get_global_transform().origin);
|
||||||
@@ -2679,12 +2684,18 @@ void RuntimeNodeSelect::_find_3d_items_at_rect(const Rect2 &p_rect, Vector<Selec
|
|||||||
for (uint32_t &I : owners) {
|
for (uint32_t &I : owners) {
|
||||||
SelectResult res_shape;
|
SelectResult res_shape;
|
||||||
res_shape.item = Object::cast_to<Node>(collision->shape_owner_get_owner(I));
|
res_shape.item = Object::cast_to<Node>(collision->shape_owner_get_owner(I));
|
||||||
res_shape.order = res.order;
|
if (!node_list.has(res_shape.item)) {
|
||||||
r_items.push_back(res_shape);
|
node_list.insert(res_shape.item);
|
||||||
|
res_shape.order = res.order;
|
||||||
|
r_items.push_back(res_shape);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r_items.push_back(res);
|
if (!node_list.has(res.item)) {
|
||||||
|
node_list.insert(res.item);
|
||||||
|
r_items.push_back(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // PHYSICS_3D_DISABLED
|
#endif // PHYSICS_3D_DISABLED
|
||||||
|
|
||||||
@@ -2714,8 +2725,11 @@ void RuntimeNodeSelect::_find_3d_items_at_rect(const Rect2 &p_rect, Vector<Selec
|
|||||||
if (mesh_collision->inside_convex_shape(transformed_frustum.ptr(), transformed_frustum.size(), convex_points.ptr(), convex_points.size(), mesh_scale)) {
|
if (mesh_collision->inside_convex_shape(transformed_frustum.ptr(), transformed_frustum.size(), convex_points.ptr(), convex_points.size(), mesh_scale)) {
|
||||||
SelectResult res;
|
SelectResult res;
|
||||||
res.item = Object::cast_to<Node>(obj);
|
res.item = Object::cast_to<Node>(obj);
|
||||||
res.order = -dist_pos.distance_to(gt.origin);
|
if (!node_list.has(res.item)) {
|
||||||
r_items.push_back(res);
|
node_list.insert(res.item);
|
||||||
|
res.order = -dist_pos.distance_to(gt.origin);
|
||||||
|
r_items.push_back(res);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user