本文整理汇总了C++中Vector2::IsInRange方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2::IsInRange方法的具体用法?C++ Vector2::IsInRange怎么用?C++ Vector2::IsInRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2
的用法示例。
在下文中一共展示了Vector2::IsInRange方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CollideCircleCircle
bool Collider::CollideCircleCircle(CircleCollider* a, CircleCollider* b, CollisionData *collisionData)
{
//TODO: store data in collisionData!
Vector2 diff = b->GetCenter() - a->GetCenter();
return (diff.IsInRange(a->radius + b->radius));
}
示例2: IntersectsPoint
bool CircleCollider::IntersectsPoint(const Vector2& point, CollisionData *collisionData)
{
Vector2 ePos = GetEntityPosition();
Vector2 diff = point - (ePos + offset);
return (diff.IsInRange(radius));
}
示例3: CollideCircleCircle
bool Collider::CollideCircleCircle(CircleCollider* a, CircleCollider* b)
{
Vector2 aOff = a->GetEntityPosition();
Vector2 bOff = b->GetEntityPosition();
Vector2 diff = (b->offset + bOff) - (a->offset + aOff);
return (diff.IsInRange(a->radius + b->radius));
}
示例4: CollideCircleCircle
bool Collider::CollideCircleCircle(CircleCollider* a, CircleCollider* b, CollisionData *collisionData)
{
Vector2 diff = a->GetCenter() - b->GetCenter();
if (diff.IsInRange(a->GetRadius() + b->GetRadius()))
{
if (collisionData)
{
collisionData->normal = diff.GetNormalized();
collisionData->penetration = (a->GetRadius() + b->GetRadius()) - diff.GetMagnitude();
collisionData->hitPoint = diff * 0.5f + b->GetCenter();
}
return true;
}
return false;
}
示例5: GetNearestEntityByControlPoint
Entity* Scene::GetNearestEntityByControlPoint(const Vector2 &position, const std::string &tag, Entity *ignoreEntity)
{
float smallestSqrMag = -1.0f;
Entity *nearestEntity = NULL;
std::list<Entity*> *entities = &this->entities;
if (tag != "")
{
entities = GetAllTag(tag);
}
if (entities != NULL)
{
for (std::list<Entity*>::iterator i = entities->begin(); i != entities->end(); ++i)
{
if ((*i) != ignoreEntity)
{
Vector2 diff = (*i)->GetWorldPosition() - position;
if (diff.IsInRange(ENTITY_CONTROLPOINT_SIZE))
{
float sqrMag = diff.GetSquaredMagnitude();
if (smallestSqrMag == -1 || sqrMag < smallestSqrMag)
{
smallestSqrMag = sqrMag;
nearestEntity = (*i);
}
}
}
//Entity *nearestChild = (*i)->GetNearestEntityByControlPoint(position, tag, ignoreEntity, smallestSqrMag);
//if (nearestChild)
//{
// nearestEntity = nearestChild;
//}
}
}
return nearestEntity;
}
示例6: CollideCircleCircle
bool Collider::CollideCircleCircle(CircleCollider* a, CircleCollider* b)
{
Vector2 diff = b->GetCenter() - a->GetCenter();
return (diff.IsInRange(a->radius + b->radius));
}