当前位置: 首页>>代码示例>>C++>>正文


C++ DVector::remove方法代码示例

本文整理汇总了C++中DVector::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ DVector::remove方法的具体用法?C++ DVector::remove怎么用?C++ DVector::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DVector的用法示例。


在下文中一共展示了DVector::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: forward_input_event


//.........这里部分代码省略.........
								undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
								undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
								undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
								undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
								undo_redo->commit_action();

								edited_point=-1;
								return true;
							}
						}
					} if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {

						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;
									closest_outline=j;
									closest_idx=i;
								}
							}
						}

						if (closest_idx>=0) {


							DVector<Vector2> poly = node->get_navigation_polygon()->get_outline(closest_outline);

							if (poly.size()>3) {
								undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
								undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"set_outline",closest_outline,poly);
								poly.remove(closest_idx);
								undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"set_outline",closest_outline,poly);
								undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
								undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
								undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
								undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
								undo_redo->commit_action();
							} else {

								undo_redo->create_action(TTR("Remove Poly And Point"));
								undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"add_outline_at_index",poly,closest_outline);
								poly.remove(closest_idx);
								undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"remove_outline",closest_outline);
								undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
								undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
								undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
								undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
								undo_redo->commit_action();

							}
							return true;
						}
					}



				} break;
			}



		} break;
		case InputEvent::MOUSE_MOTION: {

			const InputEventMouseMotion &mm=p_event.mouse_motion;

			if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) {

				Vector2 gpoint = Point2(mm.x,mm.y);
				Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
				cpoint=canvas_item_editor->snap_point(cpoint);
				edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint);

				canvas_item_editor->get_viewport_control()->update();

			}

		} break;
	}

	return false;
}
开发者ID:BenjaDev,项目名称:godot,代码行数:101,代码来源:navigation_polygon_editor_plugin.cpp


注:本文中的DVector::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。