本文整理汇总了C++中TSShapeInstance::castRayOpcode方法的典型用法代码示例。如果您正苦于以下问题:C++ TSShapeInstance::castRayOpcode方法的具体用法?C++ TSShapeInstance::castRayOpcode怎么用?C++ TSShapeInstance::castRayOpcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSShapeInstance
的用法示例。
在下文中一共展示了TSShapeInstance::castRayOpcode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: castRay
bool ForestItem::castRay( const Point3F &start, const Point3F &end, RayInfo *outInfo, bool rendered ) const
{
if ( !mWorldBox.collideLine( start, end ) )
return false;
Point3F s, e;
MatrixF mat = getTransform();
mat.scale( Point3F(mScale) );
mat.inverse();
mat.mulP( start, &s );
mat.mulP( end, &e );
TSForestItemData *data = (TSForestItemData*)mDataBlock;
TSShapeInstance *si = data->getShapeInstance();
if ( !si )
return false;
if ( rendered )
{
// Always raycast against detail level zero
// because it makes lots of things easier.
if ( !si->castRayRendered( s, e, outInfo, 0 ) )
return false;
if ( outInfo->userData != NULL )
*(ForestItem*)(outInfo->userData) = *this;
return true;
}
RayInfo shortest;
shortest.t = 1e8;
bool gotMatch = false;
S32 detail;
const Vector<S32> &details = data->getLOSDetails();
for (U32 i = 0; i < details.size(); i++)
{
detail = details[i];
if (detail != -1)
{
//si->animate(data->mLOSDetails[i]);
if ( si->castRayOpcode( detail, s, e, outInfo ) )
{
if (outInfo->t < shortest.t)
{
gotMatch = true;
shortest = *outInfo;
}
}
}
}
if ( !gotMatch )
return false;
// Copy out the shortest time...
*outInfo = shortest;
if ( outInfo->userData != NULL )
*(ForestItem*)(outInfo->userData) = *this;
return true;
}