本文整理汇总了C++中Point2::normalized方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2::normalized方法的具体用法?C++ Point2::normalized怎么用?C++ Point2::normalized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2
的用法示例。
在下文中一共展示了Point2::normalized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) {
switch ( shape_type ) {
case CAPSULE_SHAPE: {
if (idx < 2) {
Ref<CapsuleShape2D> capsule = node->get_shape();
real_t parameter = Math::abs(p_point[idx]);
if (idx==0) {
capsule->set_radius(parameter);
} else if (idx==1){
capsule->set_height(parameter*2 - capsule->get_radius()*2);
}
canvas_item_editor->get_viewport_control()->update();
}
} break;
case CIRCLE_SHAPE: {
Ref<CircleShape2D> circle = node->get_shape();
circle->set_radius(p_point.length());
canvas_item_editor->get_viewport_control()->update();
} break;
case CONCAVE_POLYGON_SHAPE: {
} break;
case CONVEX_POLYGON_SHAPE: {
} break;
case LINE_SHAPE: {
if (idx<2) {
Ref<LineShape2D> line = node->get_shape();
if (idx==0){
line->set_d(p_point.length());
}else{
line->set_normal(p_point.normalized());
}
canvas_item_editor->get_viewport_control()->update();
}
} break;
case RAY_SHAPE: {
Ref<RayShape2D> ray = node->get_shape();
ray->set_length(Math::abs(p_point.y));
canvas_item_editor->get_viewport_control()->update();
} break;
case RECTANGLE_SHAPE: {
if (idx<2) {
Ref<RectangleShape2D> rect = node->get_shape();
Vector2 extents = rect->get_extents();
extents[idx] = p_point[idx];
rect->set_extents(extents.abs());
canvas_item_editor->get_viewport_control()->update();
}
} break;
case SEGMENT_SHAPE: {
if (edit_handle < 2) {
Ref<SegmentShape2D> seg = node->get_shape();
if (idx==0) {
seg->set_a(p_point);
} else if (idx==1) {
seg->set_b(p_point);
}
canvas_item_editor->get_viewport_control()->update();
}
} break;
}
}