当前位置: 首页>>代码示例>>C++>>正文


C++ OgreWorldPtr::Raycast方法代码示例

本文整理汇总了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;
}
开发者ID:360degrees-fi,项目名称:tundra,代码行数:72,代码来源:RayVisibilityFilter.cpp


注:本文中的OgreWorldPtr::Raycast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。