@@ -47,15 +47,15 @@ typedef struct
47
47
typedef struct
48
48
{
49
49
// BVH structure
50
- __global FatBvhNode const * nodes ;
50
+ __global FatBvhNode const * nodes ;
51
51
// Scene positional data
52
- __global float3 const * vertices ;
52
+ __global float3 const * vertices ;
53
53
// Scene indices
54
- __global Face const * faces ;
54
+ __global Face const * faces ;
55
55
// Shape IDs
56
- __global ShapeData const * shapes ;
56
+ __global ShapeData const * shapes ;
57
57
// Extra data
58
- __global int const * extra ;
58
+ __global int const * extra ;
59
59
} SceneData ;
60
60
61
61
/*************************************************************************
@@ -68,7 +68,7 @@ HELPER FUNCTIONS
68
68
BVH FUNCTIONS
69
69
**************************************************************************/
70
70
// intersect a ray with leaf BVH node
71
- bool IntersectLeafClosest (
71
+ void IntersectLeafClosest (
72
72
SceneData const * scenedata ,
73
73
int faceidx ,
74
74
ray const * r , // ray to instersect
@@ -91,11 +91,8 @@ bool IntersectLeafClosest(
91
91
{
92
92
isect -> primid = face .id ;
93
93
isect -> shapeid = scenedata -> shapes [face .shapeidx ].id ;
94
- return true;
95
94
}
96
95
}
97
-
98
- return false;
99
96
}
100
97
101
98
// intersect a ray with leaf BVH node
@@ -250,10 +247,10 @@ bool IntersectSceneClosest(SceneData const* scenedata, ray const* r, Intersectio
250
247
if (r -> o .w < 0.f )
251
248
return false;
252
249
253
- int stack [32 ];
250
+ int stack [32 ];
254
251
255
- int * sptr = stack ;
256
- * sptr ++ = -1 ;
252
+ int * sptr = stack ;
253
+ * sptr ++ = -1 ;
257
254
258
255
int idx = 0 ;
259
256
FatBvhNode node ;
@@ -278,8 +275,8 @@ bool IntersectSceneClosest(SceneData const* scenedata, ray const* r, Intersectio
278
275
{
279
276
IntersectLeafClosest (scenedata , STARTIDX (node .lbound ), r , isect );
280
277
}
281
-
282
- if (rightleaf )
278
+
279
+ if (rightleaf )
283
280
{
284
281
IntersectLeafClosest (scenedata , STARTIDX (node .rbound ), r , isect );
285
282
}
@@ -298,7 +295,7 @@ bool IntersectSceneClosest(SceneData const* scenedata, ray const* r, Intersectio
298
295
deferred = (int )node .rbound .pmax .w ;
299
296
}
300
297
301
- * sptr ++ = deferred ;
298
+ * sptr ++ = deferred ;
302
299
continue ;
303
300
}
304
301
else if (lefthit > 0 )
@@ -312,7 +309,7 @@ bool IntersectSceneClosest(SceneData const* scenedata, ray const* r, Intersectio
312
309
continue ;
313
310
}
314
311
315
- idx = * -- sptr ;
312
+ idx = * -- sptr ;
316
313
}
317
314
318
315
return isect -> shapeid >= 0 ;
@@ -357,13 +354,13 @@ bool IntersectSceneAny(SceneData const* scenedata, ray const* r, __global int* s
357
354
if (leftleaf )
358
355
{
359
356
if (IntersectLeafAny (scenedata , STARTIDX (node .lbound ), r ))
360
- return true;
357
+ return true;
361
358
}
362
359
363
360
if (rightleaf )
364
361
{
365
362
if (IntersectLeafAny (scenedata , STARTIDX (node .rbound ), r ))
366
- return true;
363
+ return true;
367
364
}
368
365
369
366
if (lefthit > 0.f && righthit > 0.f )
@@ -394,17 +391,17 @@ bool IntersectSceneAny(SceneData const* scenedata, ray const* r, __global int* s
394
391
395
392
* lsptr = deferred ;
396
393
lsptr += 64 ;
397
- continue ;
394
+ continue ;
398
395
}
399
396
else if (lefthit > 0 )
400
397
{
401
398
idx = (int )node .lbound .pmax .w ;
402
- continue ;
399
+ continue ;
403
400
}
404
401
else if (righthit > 0 )
405
402
{
406
403
idx = (int )node .rbound .pmax .w ;
407
- continue ;
404
+ continue ;
408
405
}
409
406
410
407
lsptr -= 64 ;
@@ -436,10 +433,10 @@ bool IntersectSceneAny(SceneData const* scenedata, ray const* r)
436
433
if (r -> o .w < 0.f )
437
434
return false;
438
435
439
- int stack [32 ];
436
+ int stack [32 ];
440
437
441
- int * sptr = stack ;
442
- * sptr ++ = -1 ;
438
+ int * sptr = stack ;
439
+ * sptr ++ = -1 ;
443
440
444
441
int idx = 0 ;
445
442
FatBvhNode node ;
@@ -450,7 +447,7 @@ bool IntersectSceneAny(SceneData const* scenedata, ray const* r)
450
447
float righthit = 0.f ;
451
448
int step = 0 ;
452
449
453
- bool found = false;
450
+ bool found = false;
454
451
455
452
while (idx > -1 )
456
453
{
@@ -465,19 +462,19 @@ bool IntersectSceneAny(SceneData const* scenedata, ray const* r)
465
462
if (leftleaf )
466
463
{
467
464
if (IntersectLeafAny (scenedata , STARTIDX (node .lbound ), r ))
468
- {
469
- found = true;
470
- break ;
471
- }
465
+ {
466
+ found = true;
467
+ break ;
468
+ }
472
469
}
473
470
474
- if (rightleaf )
471
+ if (rightleaf )
475
472
{
476
473
if (IntersectLeafAny (scenedata , STARTIDX (node .rbound ), r ))
477
- {
478
- found = true;
479
- break ;
480
- }
474
+ {
475
+ found = true;
476
+ break ;
477
+ }
481
478
}
482
479
483
480
if (lefthit > 0.f && righthit > 0.f )
@@ -494,7 +491,7 @@ bool IntersectSceneAny(SceneData const* scenedata, ray const* r)
494
491
deferred = (int )node .rbound .pmax .w ;
495
492
}
496
493
497
- * sptr ++ = deferred ;
494
+ * sptr ++ = deferred ;
498
495
}
499
496
else if (lefthit > 0 )
500
497
{
@@ -505,8 +502,8 @@ bool IntersectSceneAny(SceneData const* scenedata, ray const* r)
505
502
idx = (int )node .rbound .pmax .w ;
506
503
}
507
504
508
- if (lefthit <= 0.f && righthit <= 0.f )
509
- idx = * -- sptr ;
505
+ if (lefthit <= 0.f && righthit <= 0.f )
506
+ idx = * -- sptr ;
510
507
}
511
508
512
509
return found ;
0 commit comments