本文整理汇总了C++中Hit::didHit方法的典型用法代码示例。如果您正苦于以下问题:C++ Hit::didHit方法的具体用法?C++ Hit::didHit怎么用?C++ Hit::didHit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hit
的用法示例。
在下文中一共展示了Hit::didHit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retHit
Hit BVH::BVHNode::trace(const AABB_Ray & aabb_ray, const Ray & ray, Amount minT)
{
Hit retHit(ray);
//First check to see if this hit intersects with this node.
Amount thisT = getBox().intersect(aabb_ray);
if(thisT > 0 && (thisT < minT || minT < 0))
{
if(this->left != nullptr)
{
Hit hLeft = this->left->trace(aabb_ray,ray,minT);
if(hLeft.didHit() && (hLeft.getT() < minT || minT < 0))
{
retHit = hLeft;
minT = hLeft.getT();
}
}
if(this->right != nullptr)
{
Hit hRight = this->right->trace(aabb_ray,ray,minT);
if(hRight.didHit() && (hRight.getT() < minT || minT < 0))
{
retHit = hRight;
}
}
}
return retHit;
}
示例2: box
#include "geometry/Box.hpp"
#include "math/Transform.hpp"
TEST_CASE("Box intersection Test", "[Box]")
{
Box box(Vector3(-1,-1,-1), Vector3(1,1,1));
//Six intersecting sides
Hit h1 = box.intersect(Ray(Vector3(0,0,10),Vector3(0,0,-1)),1);
Hit h2 = box.intersect(Ray(Vector3(10,0,0),Vector3(-1,0,0)),1);
Hit h3 = box.intersect(Ray(Vector3(0,10,0),Vector3(0,-1,0)),1);
Hit h4 = box.intersect(Ray(Vector3(0,0,-10),Vector3(0,0,1)),1);
Hit h5 = box.intersect(Ray(Vector3(-10,0,0),Vector3(1,0,0)),1);
Hit h6 = box.intersect(Ray(Vector3(0,-10,0),Vector3(0,1,0)),1);
REQUIRE(h1.didHit());
REQUIRE(h2.didHit());
REQUIRE(h3.didHit());
REQUIRE(h4.didHit());
REQUIRE(h5.didHit());
REQUIRE(h6.didHit());
REQUIRE(h1.getNormal() == Vector3(0,0,1));
REQUIRE(h2.getNormal() == Vector3(1,0,0));
REQUIRE(h3.getNormal() == Vector3(0,1,0));
REQUIRE(h4.getNormal() == Vector3(0,0,-1));
REQUIRE(h5.getNormal() == Vector3(-1,0,0));
REQUIRE(h6.getNormal() == Vector3(0,-1,0));
}