本文整理汇总了C++中Drawable::Intersect方法的典型用法代码示例。如果您正苦于以下问题:C++ Drawable::Intersect方法的具体用法?C++ Drawable::Intersect怎么用?C++ Drawable::Intersect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drawable
的用法示例。
在下文中一共展示了Drawable::Intersect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
const Drawable *Scene::Intersect(const Ray &ray)
{
bool hit = false;
Vector3d closestPos = 0;
Drawable *closest = NULL;
for (std::vector<Drawable *>::const_iterator i = m_DrawableList.begin(); i != m_DrawableList.end(); i++) {
Drawable *d = *i;
Vector3d pos;
Vector3d normal;
if (d->Intersect(ray, pos, normal)) {
// std::cout << "collision ray " << ray << " pos " << pos << std::endl;
if (!hit || (pos - ray.origin).LengthSquared() < (closestPos - ray.origin).LengthSquared()) {
closestPos = pos;
closest = d;
}
hit = true;
}
}
if (hit)
return closest;
return NULL;
}
示例2: DoesIntersect
bool Scene::DoesIntersect(const Ray &ray)
{
for (std::vector<Drawable *>::const_iterator i = m_DrawableList.begin(); i != m_DrawableList.end(); i++) {
Drawable *d = *i;
if (d->Intersect(ray)) {
return true;
}
}
return false;
}