本文整理汇总了C++中Polygon2::containsPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon2::containsPoint方法的具体用法?C++ Polygon2::containsPoint怎么用?C++ Polygon2::containsPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon2
的用法示例。
在下文中一共展示了Polygon2::containsPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rasterize
void BlockPhysicsComponent::rasterize(Polygon2 const &polygon)
{
Polygon2 localPolygon;
for (int i = 0; i < polygon.getSize(); ++i) {
b2Vec2 worldPoint(polygon.vertices[i].x, polygon.vertices[i].y);
b2Vec2 localPoint = body_->GetLocalPoint(worldPoint);
localPolygon.vertices.push_back(Vector2(localPoint.x, localPoint.y));
}
Box2 bounds = localPolygon.getBoundingBox();
int minX = int(10.0f * bounds.p1.x + 0.05f);
int minY = int(10.0f * bounds.p1.y + 0.05f);
int maxX = int(10.0f * bounds.p2.x + 0.05f);
int maxY = int(10.0f * bounds.p2.y + 0.05f);
for (int y = minY; y <= maxY; ++y) {
for (int x = minX; x <= maxX; ++x) {
Vector2 localPoint(0.1f * float(x), 0.1f * float(y));
if (localPolygon.containsPoint(localPoint)) {
for (int dy = -1; dy <= 1; ++dy) {
for (int dx = -1; dx <= 1; ++dx) {
if (dx == 0 || dy == 0) {
setElement(x + dx, y + dy, 1);
}
}
}
}
}
}
}