本文整理汇总了C++中SelectionIntersection::assignIfCloser方法的典型用法代码示例。如果您正苦于以下问题:C++ SelectionIntersection::assignIfCloser方法的具体用法?C++ SelectionIntersection::assignIfCloser怎么用?C++ SelectionIntersection::assignIfCloser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectionIntersection
的用法示例。
在下文中一共展示了SelectionIntersection::assignIfCloser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BestPoint
void BestPoint(std::size_t count, Vector4 clipped[9], SelectionIntersection& best, clipcull_t cull) {
Vector3 normalised[9];
{
for(std::size_t i=0; i<count; ++i)
{
normalised[i][0] = clipped[i][0] / clipped[i][3];
normalised[i][1] = clipped[i][1] / clipped[i][3];
normalised[i][2] = clipped[i][2] / clipped[i][3];
}
}
if(cull != eClipCullNone && count > 2)
{
double signed_area = triangle_signed_area_XY(normalised[0], normalised[1], normalised[2]);
if((cull == eClipCullCW && signed_area > 0)
|| (cull == eClipCullCCW && signed_area < 0))
return;
}
if(count == 2)
{
Segment3D segment(normalised[0], normalised[1]);
Point3D point = segment_closest_point_to_point(segment, Vector3(0, 0, 0));
best.assignIfCloser(SelectionIntersection(point.z(), 0));
}
else if(count > 2 && !point_test_polygon_2d(Vector3(0, 0, 0), normalised, normalised + count))
{
point_iterator_t end = normalised + count;
for(point_iterator_t previous = end-1, current = normalised; current != end; previous = current, ++current)
{
Segment3D segment(*previous, *current);
Point3D point = segment_closest_point_to_point(segment, Vector3(0, 0, 0));
double depth = point.z();
point.z() = 0;
double distance = point.getLengthSquared();
best.assignIfCloser(SelectionIntersection(depth, distance));
}
}
else if(count > 2)
{
best.assignIfCloser(
SelectionIntersection(
static_cast<float>(
Ray(Vector3(0, 0, 0), Vector3(0, 0, 1)).getDistance(
Plane3(normalised[0], normalised[1], normalised[2])
)),
0
)
);
}
}