本文整理汇总了C++中FloatRect::intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatRect::intersects方法的具体用法?C++ FloatRect::intersects怎么用?C++ FloatRect::intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatRect
的用法示例。
在下文中一共展示了FloatRect::intersects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: interactionWitnUnlifeObject
void MainPerson::interactionWitnUnlifeObject(vector<UnlifeObject> *unlifeObjects, const Time & deltaTime)// ИСПРАВЬ for enity and mainPerson
{
float dx(movement.x);
float dy(movement.y);
float x;
float y;
x = getXPos();
y = getYPos();
// Проверка на выход за карту
if (((x < (SIZE_BLOCK * WIDTH_MAP)) && (x > 0))
&& (y < (SIZE_BLOCK * (LONG_MAP - 1)) && (y > 0))) {
Sprite *spriteObject;
FloatRect objectBound;
int levelUnlifeObject;
Sprite *transparentSpiteObject;
FloatRect objectAltBound;
FloatRect entityBound;
vector<UnlifeObject> &objects = *unlifeObjects;
for (int i = 0; i != objects.size(); ++i) {
levelUnlifeObject = objects[i].currentLevel;
spriteObject = objects[i].spriteObject;
objectBound = spriteObject->getGlobalBounds();
transparentSpiteObject = objects[i].transparentSpiteObject;
objectAltBound = transparentSpiteObject->getGlobalBounds();
entityBound = spriteEntity->getGlobalBounds();
if (entityBound.intersects(objectBound) && (levelUnlifeObject == currentLevelFloor + 1)) {
if (direction >= Direction::UP_LEFT) {
// Чтобы скорость по диагонали была равной скорости по вертикали и горизонтали
x -= DIAGONAL_SCALE_SPEED * dx * deltaTime.asSeconds();
y -= DIAGONAL_SCALE_SPEED * dy * deltaTime.asSeconds();
} else {
x -= dx * deltaTime.asSeconds();
y -= dy * deltaTime.asSeconds();
}
direction = NONE_DIRECTION;
break;
} else if (entityBound.intersects(objectAltBound) && (levelUnlifeObject == currentLevelFloor + 1)) {
transparentSpiteObject->setColor(TRANSPARENT_COLOR);
} else {
transparentSpiteObject->setColor(NORMAL_COLOR);
}
}
} else {
x = (int)getXPos();
y = (int)getYPos();
}
spriteEntity->setPosition(x, y);
movement = { 0.f, 0.f };
}
示例2:
void le::AI::MoveToObject( Vector2f Factor , Body::TYPE_MOVE typeMove , BasicPersonages *Personage , bool UseY )
{
FloatRect TempRect = this->Personage->GetRect();
if ( !UseY )
TempRect.top = Personage->GetRect().top;
if ( !TempRect.intersects( Personage->GetRect() ) )
{
if ( this->Personage->GetRect().left < Personage->GetRect().left )
{
this->Personage->GetBody().MoveBody( Vector2f( Factor.x , 0 ) , typeMove );
this->Personage->GetAnimationManager().Flip( true );
}
else
{
this->Personage->GetBody().MoveBody( Vector2f( -Factor.x , 0 ) , typeMove );
this->Personage->GetAnimationManager().Flip( false );
}
if ( UseY )
{
if ( this->Personage->GetRect().top < Personage->GetRect().top )
this->Personage->GetBody().MoveBody( Vector2f( 0 , -Factor.y ) , typeMove );
else
this->Personage->GetBody().MoveBody( Vector2f( 0 , Factor.y ) , typeMove );
}
}
}
示例3: checkIntersection
bool SVGSVGElement::checkIntersection(SVGElement* element, const FloatRect& rect)
{
// TODO : take into account pointer-events?
// FIXME: Why is element ignored??
// FIXME: Implement me (see bug 11274)
return rect.intersects(getBBox());
}
示例4: paintToTextureMapper
void LayerBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
{
Vector<TextureMapperTile*> tilesToPaint;
// We have to do this every time we paint, in case the opacity has changed.
HashMap<int, LayerBackingStoreTile>::iterator end = m_tiles.end();
FloatRect coveredRect;
for (HashMap<int, LayerBackingStoreTile>::iterator it = m_tiles.begin(); it != end; ++it) {
LayerBackingStoreTile& tile = it->second;
if (!tile.texture())
continue;
if (tile.scale() == m_scale) {
tilesToPaint.append(&tile);
coveredRect.unite(tile.rect());
continue;
}
// Only show the previous tile if the opacity is high, otherwise effect looks like a bug.
// We show the previous-scale tile anyway if it doesn't intersect with any current-scale tile.
if (opacity < 0.95 && coveredRect.intersects(tile.rect()))
continue;
tilesToPaint.prepend(&tile);
}
// TODO: When the TextureMapper makes a distinction between some edges exposed and no edges
// exposed, the value passed should be an accurate reflection of the tile subset that we are
// passing. For now we just "estimate" since LayerBackingStore doesn't keep information about
// the total tiled surface rect at the moment.
unsigned edgesExposed = m_tiles.size() > 1 ? TextureMapper::NoEdges : TextureMapper::AllEdges;
for (size_t i = 0; i < tilesToPaint.size(); ++i)
tilesToPaint[i]->paint(textureMapper, transform, opacity, mask, edgesExposed);
}
示例5: isCutOff
//! Checks if all neighbour tile know about the owner of the label
bool Renderer::isCutOff(const FloatRect& box, const FloatRect& owner)
{
bool tooLarge = false;
for (int i = 0; i < 8 && !tooLarge; i++)
tooLarge = box.intersects(neighbours[i]) && !neighbourRequests[i].intersects(owner);
return tooLarge;
}
示例6: paintInfoIntersectsRepaintRect
bool SVGRenderSupport::paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo& paintInfo)
{
if (localTransform.isIdentity())
return localRepaintRect.intersects(paintInfo.rect);
return localTransform.mapRect(localRepaintRect).intersects(paintInfo.rect);
}
示例7: interactionWitnUnlifeObject
void Entity::interactionWitnUnlifeObject(vector<UnlifeObject> &unlifeObjects , const float deltaTime)// ÈÑÏÐÀÂÜ for enity and mainPerson
{
wasCollision = false;
collision.clear();
Sprite *spriteObject;
FloatRect objectBound;
int levelUnlifeObject;
Sprite *transparentSpiteObject;
FloatRect objectAltBound;
spriteEntity->move(movement);
FloatRect entityBound = spriteEntity->getGlobalBounds();
spriteEntity->move(-movement);
for (int i = 0; i < unlifeObjects.size(); i++) {
levelUnlifeObject = unlifeObjects[i].currentLevel;
spriteObject = unlifeObjects[i].spriteObject;
objectBound = spriteObject->getGlobalBounds();
transparentSpiteObject = unlifeObjects[i].transparentSpiteObject;
objectAltBound = transparentSpiteObject->getGlobalBounds();
if (entityBound.intersects(objectBound) && (levelUnlifeObject == currentLevelFloor + 1)) {
wasCollision = true;
collision.posObject = unlifeObjects[i].getPosition();
collision.levelObject = unlifeObjects[i].currentLevel;
directions.directionWalk = NONE_DIRECTION;
break;
}
else if (type->id == idEntity::playerEntity) {
if (entityBound.intersects(objectAltBound) && (levelUnlifeObject == currentLevelFloor + 1)) {
transparentSpiteObject->setColor(TRANSPARENT_COLOR);
}
else {
transparentSpiteObject->setColor(NORMAL_COLOR);
}
}
}
}
示例8: Contact
bool Enemy::Contact(Player &player)
{
FloatRect playr = player.GetGlobalBounds();
FloatRect enmy = GetGlobalBounds();
if(enmy.intersects(playr)) return true;
return false;
}
示例9: paintCustomHighlight
void RootInlineBox::paintCustomHighlight(RenderObject::PaintInfo& paintInfo, int tx, int ty, const AtomicString& highlightType)
{
if (!object()->shouldPaintWithinRoot(paintInfo) || object()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
return;
// Get the inflated rect so that we can properly hit test.
FloatRect rootRect(tx + xPos(), ty + selectionTop(), width(), selectionHeight());
FloatRect inflatedRect = object()->document()->frame()->customHighlightLineRect(highlightType, rootRect);
if (inflatedRect.intersects(paintInfo.rect))
object()->document()->frame()->paintCustomHighlight(highlightType, rootRect, rootRect, false, true);
}
示例10: intersectsAllowingEmpty
// FloatRect::intersects does not consider horizontal or vertical lines (because of isEmpty()).
// So special-case handling of such lines.
static bool intersectsAllowingEmpty(const FloatRect& r, const FloatRect& other)
{
if (r.isEmpty() && other.isEmpty())
return false;
if (r.isEmpty() && !other.isEmpty()) {
return (other.contains(r.x(), r.y()) && !other.contains(r.maxX(), r.maxY()))
|| (!other.contains(r.x(), r.y()) && other.contains(r.maxX(), r.maxY()));
}
if (other.isEmpty() && !r.isEmpty())
return intersectsAllowingEmpty(other, r);
return r.intersects(other);
}
示例11: isLayerVisible
// Returns true if any part of the layer falls within the visibleRect
bool LayerRendererChromium::isLayerVisible(LayerChromium* layer, const TransformationMatrix& matrix, const IntRect& visibleRect)
{
// Form the matrix used by the shader to map the corners of the layer's
// bounds into clip space.
TransformationMatrix renderMatrix = matrix;
renderMatrix.scale3d(layer->bounds().width(), layer->bounds().height(), 1);
renderMatrix.multiply(m_projectionMatrix);
FloatRect layerRect(-0.5, -0.5, 1, 1);
FloatRect mappedRect = renderMatrix.mapRect(layerRect);
// The layer is visible if it intersects any part of a rectangle whose origin
// is at (-1, -1) and size is 2x2.
return mappedRect.intersects(FloatRect(-1, -1, 2, 2));
}
示例12: dropTilesOutsideRect
void TiledBackingStore::dropTilesOutsideRect(const IntRect& keepRect)
{
FloatRect keepRectF = keepRect;
Vector<Tile::Coordinate> toRemove;
TileMap::iterator end = m_tiles.end();
for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
Tile::Coordinate coordinate = it->second->coordinate();
FloatRect tileRect = it->second->rect();
if (!tileRect.intersects(keepRectF))
toRemove.append(coordinate);
}
unsigned removeCount = toRemove.size();
for (unsigned n = 0; n < removeCount; ++n)
removeTile(toRemove[n]);
}
示例13: CollidesWith
bool BoundingBox::CollidesWith (
const ICollidable& other,
const Vector2& offset) const
{
if (GetZ () >= other.GetZ () + other.GetH () ||
GetZ () + GetH () <= other.GetZ ())
return false;
FloatRect rect (
spatial3Info_.GetRectangle ().left + offset.x,
spatial3Info_.GetRectangle ().top + offset.y,
spatial3Info_.GetRectangle ().width,
spatial3Info_.GetRectangle ().height);
return rect.intersects (other.GetRectangle ());
}
示例14: interactionWithEntity
void Entity::interactionWithEntity(vector<Entity> *enemys , int id , const float deltaTime)// ÈÑÏÐÀÂÜ for enity and mainPerson
{
if (!wasCollision) {
float &dx = movement.x;
float &dy = movement.y;
float x;
float y;
x = getXPos();
y = getYPos();
Sprite *spriteObject;
FloatRect objectBound;
int levelUnlifeObject;
spriteEntity->move(movement);
FloatRect entityBound = spriteEntity->getGlobalBounds();
spriteEntity->move(-movement);
vector<Entity> &objects = *enemys;
for (int i = 0; i != objects.size(); ++i) {
if (id != i) {
levelUnlifeObject = objects[i].currentLevelFloor;
spriteObject = objects[i].spriteEntity;
objectBound = spriteObject->getGlobalBounds();
if (entityBound.intersects(objectBound) && (levelUnlifeObject == currentLevelFloor)) {
wasCollision = true;
founds.findEnemy = &objects[i];
directions.directionWalk = NONE_DIRECTION;
break;
}
}
}
}
}
示例15: paintCustomHighlight
void RootInlineBox::paintCustomHighlight(RenderObject::PaintInfo& paintInfo, int tx, int ty, const AtomicString& highlightType)
{
if (!renderer()->shouldPaintWithinRoot(paintInfo) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
return;
Frame* frame = renderer()->document()->frame();
if (!frame)
return;
Page* page = frame->page();
if (!page)
return;
// Get the inflated rect so that we can properly hit test.
FloatRect rootRect(tx + x(), ty + selectionTop(), width(), selectionHeight());
FloatRect inflatedRect = page->chrome()->client()->customHighlightRect(renderer()->node(), highlightType, rootRect);
if (inflatedRect.intersects(paintInfo.rect))
page->chrome()->client()->paintCustomHighlight(renderer()->node(), highlightType, rootRect, rootRect, false, true);
}