gKit2 light
Loading...
Searching...
No Matches
Instance Struct Reference

instance pour le bvh, cf fonctions bounds() et intersect(). More...

Public Member Functions

 Instance (const BBox &bounds, const Transform &model, BVH &bvh, const int id)
BBox bounds () const
Hit intersect (const Ray &ray, const float htmax) const
 Instance (const BBox &bounds, const Transform &model, BVH *bvh, const int id)
BBox bounds () const
Hit intersect (const Ray &ray, const float htmax) const
 Instance (const BBox &bounds, const Transform &model, BVH *bvh, const int id)
BBox bounds () const
Hit intersect (const Ray &ray, const float htmax) const

Public Attributes

Transform object_transform
BBox world_bounds
BVHobject_bvh
int instance_id

Protected Member Functions

BBox transform (const BBox &bbox, const Transform &m)
BBox transform (const BBox &bbox, const Transform &m)
BBox transform (const BBox &bbox, const Transform &m)

Detailed Description

instance pour le bvh, cf fonctions bounds() et intersect().

Definition at line 302 of file tuto_bvh2.cpp.

Constructor & Destructor Documentation

◆ Instance() [1/3]

Instance::Instance ( const BBox & bounds,
const Transform & model,
BVH & bvh,
const int id )
inline

Definition at line 309 of file tuto_bvh2.cpp.

309 :
310 object_transform(Inverse(model)), world_bounds(transform(bounds, model)),
311 object_bvh(&bvh),
312 instance_id(id)
313 {}
Transform Inverse(const Transform &m)
renvoie l'inverse de la matrice.
Definition mat.cpp:197

◆ Instance() [2/3]

Instance::Instance ( const BBox & bounds,
const Transform & model,
BVH * bvh,
const int id )
inline

Definition at line 318 of file tuto_bvh2_gltf.cpp.

318 :
319 object_transform(Inverse(model)), world_bounds(transform(bounds, model)),
320 object_bvh(bvh),
321 instance_id(id)
322 {}

◆ Instance() [3/3]

Instance::Instance ( const BBox & bounds,
const Transform & model,
BVH * bvh,
const int id )
inline

Definition at line 318 of file tuto_bvh2_gltf_brdf.cpp.

318 :
319 object_transform(Inverse(model)), world_bounds(transform(bounds, model)),
320 object_bvh(bvh),
321 instance_id(id)
322 {}

Member Function Documentation

◆ bounds() [1/3]

BBox Instance::bounds ( ) const
inline

Definition at line 315 of file tuto_bvh2.cpp.

315{ return world_bounds; }

◆ intersect() [1/3]

Hit Instance::intersect ( const Ray & ray,
const float htmax ) const
inline

Definition at line 317 of file tuto_bvh2.cpp.

318 {
319 // transforme le rayon
320 Ray object_ray(object_transform(ray.o), object_transform(ray.d), htmax);
321 // et intersection dans le bvh de l'objet instancie...
322
323 Hit hit= object_bvh->intersect(object_ray, htmax);
324 if(hit)
325 // si intersection, stocker aussi l'indice de l'instance, cf retrouver la transformation et la matiere associee au mesh/triangle...
326 hit.instance_id= instance_id;
327
328 return hit;
329 }

◆ transform() [1/3]

BBox Instance::transform ( const BBox & bbox,
const Transform & m )
inlineprotected

Definition at line 332 of file tuto_bvh2.cpp.

333 {
334 BBox bounds= BBox( m(bbox.pmin) );
335 // enumere les sommets de la bbox
336 for(unsigned i= 1; i < 8; i++)
337 {
338 // chaque sommet de la bbox est soit pmin soit pmax sur chaque axe...
339 Point p= bbox.pmin;
340 if(i & 1) p.x= bbox.pmax.x;
341 if(i & 2) p.y= bbox.pmax.y;
342 if(i & 4) p.z= bbox.pmax.z;
343
344 // transforme le sommet de l'englobant
345 bounds.insert( m(p) );
346 }
347
348 return bounds;
349 }

◆ bounds() [2/3]

BBox Instance::bounds ( ) const
inline

Definition at line 324 of file tuto_bvh2_gltf.cpp.

324{ return world_bounds; }

◆ intersect() [2/3]

Hit Instance::intersect ( const Ray & ray,
const float htmax ) const
inline

Definition at line 326 of file tuto_bvh2_gltf.cpp.

327 {
328 // transforme le rayon
329 Ray object_ray(object_transform(ray.o), object_transform(ray.d), htmax);
330 // et intersection dans le bvh de l'objet instancie...
331
332 Hit hit= object_bvh->intersect(object_ray, htmax);
333 if(hit)
334 // si intersection, stocker aussi l'indice de l'instance, cf retrouver la transformation et la matiere associee au mesh/triangle...
335 hit.instance_id= instance_id;
336
337 return hit;
338 }

◆ transform() [2/3]

BBox Instance::transform ( const BBox & bbox,
const Transform & m )
inlineprotected

Definition at line 341 of file tuto_bvh2_gltf.cpp.

342 {
343 BBox bounds= BBox( m(bbox.pmin) );
344 // enumere les sommets de la bbox
345 for(unsigned i= 1; i < 8; i++)
346 {
347 // chaque sommet de la bbox est soit pmin soit pmax sur chaque axe...
348 Point p= bbox.pmin;
349 if(i & 1) p.x= bbox.pmax.x;
350 if(i & 2) p.y= bbox.pmax.y;
351 if(i & 4) p.z= bbox.pmax.z;
352
353 // transforme le sommet de l'englobant
354 bounds.insert( m(p) );
355 }
356
357 return bounds;
358 }

◆ bounds() [3/3]

BBox Instance::bounds ( ) const
inline

Definition at line 324 of file tuto_bvh2_gltf_brdf.cpp.

324{ return world_bounds; }

◆ intersect() [3/3]

Hit Instance::intersect ( const Ray & ray,
const float htmax ) const
inline

Definition at line 326 of file tuto_bvh2_gltf_brdf.cpp.

327 {
328 // transforme le rayon
329 Ray object_ray(object_transform(ray.o), object_transform(ray.d), htmax);
330 // et intersection dans le bvh de l'objet instancie...
331
332 Hit hit= object_bvh->intersect(object_ray, htmax);
333 if(hit)
334 // si intersection, stocker aussi l'indice de l'instance, cf retrouver la transformation et la matiere associee au mesh/triangle...
335 hit.instance_id= instance_id;
336
337 return hit;
338 }

◆ transform() [3/3]

BBox Instance::transform ( const BBox & bbox,
const Transform & m )
inlineprotected

Definition at line 341 of file tuto_bvh2_gltf_brdf.cpp.

342 {
343 BBox bounds= BBox( m(bbox.pmin) );
344 // enumere les sommets de la bbox
345 for(unsigned i= 1; i < 8; i++)
346 {
347 // chaque sommet de la bbox est soit pmin soit pmax sur chaque axe...
348 Point p= bbox.pmin;
349 if(i & 1) p.x= bbox.pmax.x;
350 if(i & 2) p.y= bbox.pmax.y;
351 if(i & 4) p.z= bbox.pmax.z;
352
353 // transforme le sommet de l'englobant
354 bounds.insert( m(p) );
355 }
356
357 return bounds;
358 }

Member Data Documentation

◆ object_transform

Transform Instance::object_transform

Definition at line 304 of file tuto_bvh2.cpp.

◆ world_bounds

BBox Instance::world_bounds

Definition at line 305 of file tuto_bvh2.cpp.

◆ object_bvh

BVH * Instance::object_bvh

Definition at line 306 of file tuto_bvh2.cpp.

◆ instance_id

int Instance::instance_id

Definition at line 307 of file tuto_bvh2.cpp.


The documentation for this struct was generated from the following files: