You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Directly use segment points in Geometry2D/3D function parameters
This commit is contained in:
@@ -200,13 +200,11 @@ EditorPlugin::AfterGUIInput Polygon3DEditor::forward_3d_gui_input(Camera3D *p_ca
|
||||
Vector2 closest_pos;
|
||||
real_t closest_dist = 1e10;
|
||||
for (int i = 0; i < poly.size(); i++) {
|
||||
Vector2 points[2] = {
|
||||
p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))),
|
||||
p_camera->unproject_position(gt.xform(Vector3(poly[(i + 1) % poly.size()].x, poly[(i + 1) % poly.size()].y, depth)))
|
||||
};
|
||||
const Vector2 segment_a = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth)));
|
||||
const Vector2 segment_b = p_camera->unproject_position(gt.xform(Vector3(poly[(i + 1) % poly.size()].x, poly[(i + 1) % poly.size()].y, depth)));
|
||||
|
||||
Vector2 cp = Geometry2D::get_closest_point_to_segment(gpoint, points);
|
||||
if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2) {
|
||||
Vector2 cp = Geometry2D::get_closest_point_to_segment(gpoint, segment_a, segment_b);
|
||||
if (cp.distance_squared_to(segment_a) < CMP_EPSILON2 || cp.distance_squared_to(segment_b) < CMP_EPSILON2) {
|
||||
continue; //not valid to reuse point
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user