本文整理汇总了C++中WorldObject::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldObject::getType方法的具体用法?C++ WorldObject::getType怎么用?C++ WorldObject::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldObject
的用法示例。
在下文中一共展示了WorldObject::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectEnemy
void Actor::selectEnemy()
{
if (m_enemyEvaluator.empty())
setEnemyEvaluator();
float maxDanger = 0.f;
WorldObject* enemy = NULL;
for(MemoryFrames::iterator it= m_memoryFrames.begin(), end = m_memoryFrames.end(); it != end; it++)
{
WorldObject* object = it->second.object;
WorldObjectType objectType = object->getType();
if (objectType != WorldObject::WO_ACTOR && objectType != WorldObject::WO_GRENADE)
continue;
float danger = m_enemyEvaluator(this, object);
if (danger > maxDanger)
{
maxDanger = danger;
enemy = object;
m_alertness = ENEMY_ALERTNESS;
}
}
setEnemy(enemy);
}
示例2: CheckCollision
/*
This should be the order of the checks:
-Raycast, to see if we've got a bullet-through-paper scenario
--If raycasts intersect, then figure out what time the two boxes collided,
---then determine which sides collided
-Overlap test
--If overlapping, determine which sides collided
*/
CollisionType WorldObject::CheckCollision(const WorldObject &other)
{
//Static stuff ignores each other.
if(this->type == WorldObjectType::Static && other.getType() == WorldObjectType::Static)
return CollisionType::None;
AABB A0( aabb );//current state of AABB A
AABB B0 = other.getAABB();//current state of AABB other
AABB A1( A0.Position() + velocity, A0.Extents() ); //Projected state of us
AABB B1( B0.Position() + (other.getVelocity()), B0.Extents()); //Projected state of other
const sf::Vector2f va = velocity;//displacement of A
const sf::Vector2f vb = other.getVelocity();//displacement of B
float timeMin = 0.0f, timeMax = 0.0f;
//the problem is solved in A's frame of reference
//relative velocity (in normalized time)
sf::Vector2f v = vb - va;
//first times of overlap along each axis
sf::Vector2f u_0(0,0);
//last times of overlap along each axis
sf::Vector2f u_1(1,1);
//check if they were overlapping on the current frame
if( A0.overlaps(B0) )
{
timeMin = timeMax = 0;
//AABB::SideIntersectionResults results = A1.CheckIntersections(B1);
return CollisionType::Absolute;
}
//Prediction:
if(A1.overlaps(B1))
{
//TestCollisionMethod(A1, B1);
//TestCollisionMethod(B1, A1);
//AABB::SideIntersectionResults results = A1.CheckIntersections(B1);
return CollisionType::Prediction;
}
sf::Vector2f intersectionPoint;
return CollisionType::None;
//if(!SFMLTest::DoLinesIntersect(A0.P, A1.P, B0.P, B1.P, intersectionPoint))
//return CollisionType::None;
//Find the time at which we would come to the intersection point
//Difference between intersection point and where we started this frame
sf::Vector2f intersectionTime = intersectionPoint - A0.Position();
//What percentage of our velocity is the distance we are from the intersection point?
intersectionTime.x /= va.x;
intersectionTime.y /= va.y;
//TODO: Bullet through paper problem using the above intersection time
return CollisionType::None;
//find the possible first and last times
//of overlap along each axis
/*sf::Vector2f AMin = A0.min(), AMax = A0.max();
sf::Vector2f BMin = B0.min(), BMax = B0.max();
//X
if( AMax.x < BMin.x && v.x < 0)
u_0.x = (AMax.x - BMin.x) / v.x;
else if(BMax.x < AMin.x && v.x > 0)
u_0.x = (AMin.x - BMax.x) / v.x;
if(BMax.x > AMin.x && v.x < 0)
u_1.x = (AMin.x - BMax.x) / v.x;
else if( AMax.x > BMin.x && v.x > 0)
u_1.x = (AMax.x - BMin.x) / v.x;
//Y
if( AMax.y < BMin.y && v.y < 0)
u_0.y = (AMax.y - BMin.y) / v.y;
else if(BMax.y < AMin.y && v.y > 0)
u_0.y = (AMin.y - BMax.y) / v.y;
if(BMax.y > AMin.y && v.y < 0)
u_1.y = (AMin.y - BMax.y) / v.y;
else if( AMax.y > BMin.y && v.y > 0)
u_1.y = (AMax.y - BMin.y) / v.y;
//Z
if( AMax.z < BMin.z && v.z < 0)
u_0.z = (AMax.z - BMin.z) / v.z;
//.........这里部分代码省略.........