本文整理汇总了C++中DVector::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ DVector::insert方法的具体用法?C++ DVector::insert怎么用?C++ DVector::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DVector
的用法示例。
在下文中一共展示了DVector::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: forward_input_event
//.........这里部分代码省略.........
for(int j=0;j<node->get_navigation_polygon()->get_outline_count();j++) {
DVector<Vector2> points=node->get_navigation_polygon()->get_outline(j);
int pc=points.size();
DVector<Vector2>::Read poly=points.read();
for(int i=0;i<pc;i++) {
Vector2 points[2] ={ xform.xform(poly[i]),
xform.xform(poly[(i+1)%pc]) };
Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points);
if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2)
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
if (d<closest_dist && d<grab_treshold) {
closest_dist=d;
closest_outline=j;
closest_pos=cp;
closest_idx=i;
}
}
}
if (closest_idx>=0) {
pre_move_edit=node->get_navigation_polygon()->get_outline(closest_outline);
DVector<Point2> poly = pre_move_edit;
poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos));
edited_point=closest_idx+1;
edited_outline=closest_outline;
edited_point_pos=xform.affine_inverse().xform(closest_pos);
node->get_navigation_polygon()->set_outline(closest_outline,poly);
canvas_item_editor->get_viewport_control()->update();
return true;
}
} else {
//look for points to move
int closest_outline=-1;
int closest_idx=-1;
Vector2 closest_pos;
real_t closest_dist=1e10;
for(int j=0;j<node->get_navigation_polygon()->get_outline_count();j++) {
DVector<Vector2> points=node->get_navigation_polygon()->get_outline(j);
int pc=points.size();
DVector<Vector2>::Read poly=points.read();
for(int i=0;i<pc;i++) {
Vector2 cp =xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
if (d<closest_dist && d<grab_treshold) {
closest_dist=d;
closest_pos=cp;