本文整理汇总了C++中OgreWorldPtr::Raycast方法的典型用法代码示例。如果您正苦于以下问题:C++ OgreWorldPtr::Raycast方法的具体用法?C++ OgreWorldPtr::Raycast怎么用?C++ OgreWorldPtr::Raycast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OgreWorldPtr
的用法示例。
在下文中一共展示了OgreWorldPtr::Raycast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Filter
bool RayVisibilityFilter::Filter(const IMParameters& params)
{
if(enabled_)
{
float cutoffrange = range_ * range_;
if(params.headless)
return true;
if(params.distance < cutoffrange) //If the entity is close enough, only then do a raycast
{
std::map<entity_id_t, bool>::iterator it;
it = params.connection->syncState->visibleEntities.find(params.changed_entity->Id());
/*Check when was the last time we raycasted and dont do it if its not the time*/
int lastRaycasted = im_->FindLastRaycastedEntity(params.connection, params.changed_entity->Id());
int currentTime = im_->ElapsedTime();
if(it != params.connection->syncState->visibleEntities.end() && (lastRaycasted + raycastinterval_) > currentTime) //If the entity is located from the map
{
if(it->second == true) //bool which contains a value determining if the entity was visible to the user last time it was raycasted
{
#ifdef IM_DEBUG
if(params.connection->ConnectionId() == 1)
::LogInfo("Not the time to raycast, returning true. Last " + QString::number(lastRaycasted + raycastinterval_) + " Current " + QString::number(currentTime));
#endif
return true;
}
else
{
#ifdef IM_DEBUG
if(params.connection->ConnectionId() == 1)
::LogInfo("Not the time to raycast, returning false. Last " + QString::number(lastRaycasted + raycastinterval_) + " Current " + QString::number(currentTime));
#endif
return false;
}
}
else
{
Ray ray(params.client_position, (params.entity_position - params.client_position).Normalized());
RaycastResult *result = 0;
OgreWorldPtr w = params.scene->GetWorld<OgreWorld>();
result = w->Raycast(ray, 0xFFFFFFFF);
im_->UpdateLastRaycastedEntity(params.connection, params.changed_entity->Id());
if(result && result->entity && result->entity->Id() == params.changed_entity->Id()) //If the ray hit someone and its our target entity
{
im_->UpdateEntityVisibility(params.connection, params.changed_entity->Id(), true);
#ifdef IM_DEBUG
::LogInfo("Entity " + QString::number(params.changed_entity->Id()) + " is visible to connection " + QString::number(params.connection->ConnectionId()));
#endif
return true;
}
else
{
im_->UpdateEntityVisibility(params.connection, params.changed_entity->Id(), false);
im_->UpdateRelevance(params.connection, params.changed_entity->Id(), 0);
return false;
}
}
}
else
return false;
}
else
return true;
}