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


C++ Hit::didHit方法代码示例

本文整理汇总了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;
}
开发者ID:kyle-piddington,项目名称:PovTracer,代码行数:30,代码来源:BVH.cpp

示例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));
   

}
开发者ID:kyle-piddington,项目名称:PovTracer,代码行数:31,代码来源:Test_BoxIntersection.cpp


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