-
Notifications
You must be signed in to change notification settings - Fork 396
/
Copy pathrtcore.cpp
1776 lines (1588 loc) · 64.8 KB
/
rtcore.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#define RTC_EXPORT_API
#include "default.h"
#include "device.h"
#include "scene.h"
#include "context.h"
#include "../geometry/filter.h"
#include "../../include/embree3/rtcore_ray.h"
using namespace embree;
RTC_NAMESPACE_BEGIN;
/* mutex to make API thread safe */
static MutexSys g_mutex;
RTC_API RTCDevice rtcNewDevice(const char* config)
{
RTC_CATCH_BEGIN;
RTC_TRACE(rtcNewDevice);
Lock<MutexSys> lock(g_mutex);
Device* device = new Device(config);
return (RTCDevice) device->refInc();
RTC_CATCH_END(nullptr);
return (RTCDevice) nullptr;
}
RTC_API void rtcRetainDevice(RTCDevice hdevice)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcRetainDevice);
RTC_VERIFY_HANDLE(hdevice);
Lock<MutexSys> lock(g_mutex);
device->refInc();
RTC_CATCH_END(nullptr);
}
RTC_API void rtcReleaseDevice(RTCDevice hdevice)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcReleaseDevice);
RTC_VERIFY_HANDLE(hdevice);
Lock<MutexSys> lock(g_mutex);
device->refDec();
RTC_CATCH_END(nullptr);
}
RTC_API ssize_t rtcGetDeviceProperty(RTCDevice hdevice, RTCDeviceProperty prop)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetDeviceProperty);
RTC_VERIFY_HANDLE(hdevice);
Lock<MutexSys> lock(g_mutex);
return device->getProperty(prop);
RTC_CATCH_END(device);
return 0;
}
RTC_API void rtcSetDeviceProperty(RTCDevice hdevice, const RTCDeviceProperty prop, ssize_t val)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetDeviceProperty);
const bool internal_prop = (size_t)prop >= 1000000 && (size_t)prop < 1000004;
if (!internal_prop) RTC_VERIFY_HANDLE(hdevice); // allow NULL device for special internal settings
Lock<MutexSys> lock(g_mutex);
device->setProperty(prop,val);
RTC_CATCH_END(device);
}
RTC_API RTCError rtcGetDeviceError(RTCDevice hdevice)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetDeviceError);
if (device == nullptr) return Device::getThreadErrorCode();
else return device->getDeviceErrorCode();
RTC_CATCH_END(device);
return RTC_ERROR_UNKNOWN;
}
RTC_API void rtcSetDeviceErrorFunction(RTCDevice hdevice, RTCErrorFunction error, void* userPtr)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetDeviceErrorFunction);
RTC_VERIFY_HANDLE(hdevice);
device->setErrorFunction(error, userPtr);
RTC_CATCH_END(device);
}
RTC_API void rtcSetDeviceMemoryMonitorFunction(RTCDevice hdevice, RTCMemoryMonitorFunction memoryMonitor, void* userPtr)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetDeviceMemoryMonitorFunction);
device->setMemoryMonitorFunction(memoryMonitor, userPtr);
RTC_CATCH_END(device);
}
RTC_API RTCBuffer rtcNewBuffer(RTCDevice hdevice, size_t byteSize)
{
RTC_CATCH_BEGIN;
RTC_TRACE(rtcNewBuffer);
RTC_VERIFY_HANDLE(hdevice);
Buffer* buffer = new Buffer((Device*)hdevice, byteSize);
return (RTCBuffer)buffer->refInc();
RTC_CATCH_END((Device*)hdevice);
return nullptr;
}
RTC_API RTCBuffer rtcNewSharedBuffer(RTCDevice hdevice, void* ptr, size_t byteSize)
{
RTC_CATCH_BEGIN;
RTC_TRACE(rtcNewSharedBuffer);
RTC_VERIFY_HANDLE(hdevice);
Buffer* buffer = new Buffer((Device*)hdevice, byteSize, ptr);
return (RTCBuffer)buffer->refInc();
RTC_CATCH_END((Device*)hdevice);
return nullptr;
}
RTC_API void* rtcGetBufferData(RTCBuffer hbuffer)
{
Buffer* buffer = (Buffer*)hbuffer;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetBufferData);
RTC_VERIFY_HANDLE(hbuffer);
return buffer->data();
RTC_CATCH_END2(buffer);
return nullptr;
}
RTC_API void rtcRetainBuffer(RTCBuffer hbuffer)
{
Buffer* buffer = (Buffer*)hbuffer;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcRetainBuffer);
RTC_VERIFY_HANDLE(hbuffer);
buffer->refInc();
RTC_CATCH_END2(buffer);
}
RTC_API void rtcReleaseBuffer(RTCBuffer hbuffer)
{
Buffer* buffer = (Buffer*)hbuffer;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcReleaseBuffer);
RTC_VERIFY_HANDLE(hbuffer);
buffer->refDec();
RTC_CATCH_END2(buffer);
}
RTC_API RTCScene rtcNewScene (RTCDevice hdevice)
{
RTC_CATCH_BEGIN;
RTC_TRACE(rtcNewScene);
RTC_VERIFY_HANDLE(hdevice);
Scene* scene = new Scene((Device*)hdevice);
return (RTCScene) scene->refInc();
RTC_CATCH_END((Device*)hdevice);
return nullptr;
}
RTC_API RTCDevice rtcGetSceneDevice(RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetSceneDevice);
RTC_VERIFY_HANDLE(hscene);
return (RTCDevice)scene->device->refInc(); // user will own one additional device reference
RTC_CATCH_END2(scene);
return (RTCDevice)nullptr;
}
RTC_API void rtcSetSceneProgressMonitorFunction(RTCScene hscene, RTCProgressMonitorFunction progress, void* ptr)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetSceneProgressMonitorFunction);
RTC_VERIFY_HANDLE(hscene);
Lock<MutexSys> lock(g_mutex);
scene->setProgressMonitorFunction(progress,ptr);
RTC_CATCH_END2(scene);
}
RTC_API void rtcSetSceneBuildQuality (RTCScene hscene, RTCBuildQuality quality)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetSceneBuildQuality);
RTC_VERIFY_HANDLE(hscene);
if (quality != RTC_BUILD_QUALITY_LOW &&
quality != RTC_BUILD_QUALITY_MEDIUM &&
quality != RTC_BUILD_QUALITY_HIGH)
throw std::runtime_error("invalid build quality");
scene->setBuildQuality(quality);
RTC_CATCH_END2(scene);
}
RTC_API void rtcSetSceneFlags (RTCScene hscene, RTCSceneFlags flags)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetSceneFlags);
RTC_VERIFY_HANDLE(hscene);
scene->setSceneFlags(flags);
RTC_CATCH_END2(scene);
}
RTC_API RTCSceneFlags rtcGetSceneFlags(RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetSceneFlags);
RTC_VERIFY_HANDLE(hscene);
return scene->getSceneFlags();
RTC_CATCH_END2(scene);
return RTC_SCENE_FLAG_NONE;
}
RTC_API void rtcCommitScene (RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcCommitScene);
RTC_VERIFY_HANDLE(hscene);
scene->commit(false);
RTC_CATCH_END2(scene);
}
RTC_API void rtcJoinCommitScene (RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcJoinCommitScene);
RTC_VERIFY_HANDLE(hscene);
scene->commit(true);
RTC_CATCH_END2(scene);
}
RTC_API void rtcGetSceneBounds(RTCScene hscene, RTCBounds* bounds_o)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetSceneBounds);
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
BBox3fa bounds = scene->bounds.bounds();
bounds_o->lower_x = bounds.lower.x;
bounds_o->lower_y = bounds.lower.y;
bounds_o->lower_z = bounds.lower.z;
bounds_o->align0 = 0;
bounds_o->upper_x = bounds.upper.x;
bounds_o->upper_y = bounds.upper.y;
bounds_o->upper_z = bounds.upper.z;
bounds_o->align1 = 0;
RTC_CATCH_END2(scene);
}
RTC_API void rtcGetSceneLinearBounds(RTCScene hscene, RTCLinearBounds* bounds_o)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetSceneBounds);
RTC_VERIFY_HANDLE(hscene);
if (bounds_o == nullptr)
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"invalid destination pointer");
if (scene->isModified())
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
bounds_o->bounds0.lower_x = scene->bounds.bounds0.lower.x;
bounds_o->bounds0.lower_y = scene->bounds.bounds0.lower.y;
bounds_o->bounds0.lower_z = scene->bounds.bounds0.lower.z;
bounds_o->bounds0.align0 = 0;
bounds_o->bounds0.upper_x = scene->bounds.bounds0.upper.x;
bounds_o->bounds0.upper_y = scene->bounds.bounds0.upper.y;
bounds_o->bounds0.upper_z = scene->bounds.bounds0.upper.z;
bounds_o->bounds0.align1 = 0;
bounds_o->bounds1.lower_x = scene->bounds.bounds1.lower.x;
bounds_o->bounds1.lower_y = scene->bounds.bounds1.lower.y;
bounds_o->bounds1.lower_z = scene->bounds.bounds1.lower.z;
bounds_o->bounds1.align0 = 0;
bounds_o->bounds1.upper_x = scene->bounds.bounds1.upper.x;
bounds_o->bounds1.upper_y = scene->bounds.bounds1.upper.y;
bounds_o->bounds1.upper_z = scene->bounds.bounds1.upper.z;
bounds_o->bounds1.align1 = 0;
RTC_CATCH_END2(scene);
}
RTC_API void rtcCollide (RTCScene hscene0, RTCScene hscene1, RTCCollideFunc callback, void* userPtr)
{
Scene* scene0 = (Scene*) hscene0;
Scene* scene1 = (Scene*) hscene1;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcCollide);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene0);
RTC_VERIFY_HANDLE(hscene1);
if (scene0->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene got not committed");
if (scene1->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene got not committed");
if (scene0->device != scene1->device) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scenes are from different devices");
auto nUserPrims0 = scene0->getNumPrimitives (Geometry::MTY_USER_GEOMETRY, false);
auto nUserPrims1 = scene1->getNumPrimitives (Geometry::MTY_USER_GEOMETRY, false);
if (scene0->numPrimitives() != nUserPrims0 && scene1->numPrimitives() != nUserPrims1) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scenes must only contain user geometries with a single timestep");
#endif
scene0->intersectors.collide(scene0,scene1,callback,userPtr);
RTC_CATCH_END(scene0->device);
}
inline bool pointQuery(Scene* scene, RTCPointQuery* query, RTCPointQueryContext* userContext, RTCPointQueryFunction queryFunc, void* userPtr)
{
bool changed = false;
if (userContext->instStackSize > 0)
{
const AffineSpace3fa transform = AffineSpace3fa_load_unaligned((AffineSpace3fa*)userContext->world2inst[userContext->instStackSize-1]);
float similarityScale = 0.f;
const bool similtude = similarityTransform(transform, &similarityScale);
assert((similtude && similarityScale > 0) || (!similtude && similarityScale == 0.f));
PointQuery query_inst;
query_inst.p = xfmPoint(transform, Vec3fa(query->x, query->y, query->z));
query_inst.radius = query->radius * similarityScale;
query_inst.time = query->time;
PointQueryContext context_inst(scene, (PointQuery*)query,
similtude ? POINT_QUERY_TYPE_SPHERE : POINT_QUERY_TYPE_AABB,
queryFunc, userContext, similarityScale, userPtr);
changed = scene->intersectors.pointQuery((PointQuery*)&query_inst, &context_inst);
}
else
{
PointQueryContext context(scene, (PointQuery*)query,
POINT_QUERY_TYPE_SPHERE, queryFunc, userContext, 1.f, userPtr);
changed = scene->intersectors.pointQuery((PointQuery*)query, &context);
}
return changed;
}
RTC_API bool rtcPointQuery(RTCScene hscene, RTCPointQuery* query, RTCPointQueryContext* userContext, RTCPointQueryFunction queryFunc, void* userPtr)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcPointQuery);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
RTC_VERIFY_HANDLE(userContext);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene got not committed");
if (((size_t)query) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "query not aligned to 16 bytes");
if (((size_t)userContext) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "context not aligned to 16 bytes");
#endif
return pointQuery(scene, query, userContext, queryFunc, userPtr);
RTC_CATCH_END2_FALSE(scene);
}
RTC_API bool rtcPointQuery4 (const int* valid, RTCScene hscene, RTCPointQuery4* query, struct RTCPointQueryContext* userContext, RTCPointQueryFunction queryFunc, void** userPtrN)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcPointQuery4);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene got not committed");
if (((size_t)valid) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
if (((size_t)query) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "query not aligned to 16 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(point_query.travs,cnt,cnt,cnt);
bool changed = false;
PointQuery4* query4 = (PointQuery4*)query;
PointQuery query1;
for (size_t i=0; i<4; i++) {
if (!valid[i]) continue;
query4->get(i,query1);
changed |= pointQuery(scene, (RTCPointQuery*)&query1, userContext, queryFunc, userPtrN?userPtrN[i]:NULL);
query4->set(i,query1);
}
return changed;
RTC_CATCH_END2_FALSE(scene);
}
RTC_API bool rtcPointQuery8 (const int* valid, RTCScene hscene, RTCPointQuery8* query, struct RTCPointQueryContext* userContext, RTCPointQueryFunction queryFunc, void** userPtrN)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcPointQuery8);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene got not committed");
if (((size_t)valid) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
if (((size_t)query) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "query not aligned to 16 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(point_query.travs,cnt,cnt,cnt);
bool changed = false;
PointQuery8* query8 = (PointQuery8*)query;
PointQuery query1;
for (size_t i=0; i<8; i++) {
if (!valid[i]) continue;
query8->get(i,query1);
changed |= pointQuery(scene, (RTCPointQuery*)&query1, userContext, queryFunc, userPtrN?userPtrN[i]:NULL);
query8->set(i,query1);
}
return changed;
RTC_CATCH_END2_FALSE(scene);
}
RTC_API bool rtcPointQuery16 (const int* valid, RTCScene hscene, RTCPointQuery16* query, struct RTCPointQueryContext* userContext, RTCPointQueryFunction queryFunc, void** userPtrN)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcPointQuery16);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene got not committed");
if (((size_t)valid) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
if (((size_t)query) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "query not aligned to 16 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(point_query.travs,cnt,cnt,cnt);
bool changed = false;
PointQuery16* query16 = (PointQuery16*)query;
PointQuery query1;
for (size_t i=0; i<16; i++) {
if (!valid[i]) continue;
PointQuery query1; query16->get(i,query1);
changed |= pointQuery(scene, (RTCPointQuery*)&query1, userContext, queryFunc, userPtrN?userPtrN[i]:NULL);
query16->set(i,query1);
}
return changed;
RTC_CATCH_END2_FALSE(scene);
}
RTC_API void rtcIntersect1 (RTCScene hscene, RTCIntersectContext* user_context, RTCRayHit* rayhit)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIntersect1);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)rayhit) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
#endif
STAT3(normal.travs,1,1,1);
IntersectContext context(scene,user_context);
scene->intersectors.intersect(*rayhit,&context);
#if defined(DEBUG)
((RayHit*)rayhit)->verifyHit();
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcIntersect4 (const int* valid, RTCScene hscene, RTCIntersectContext* user_context, RTCRayHit4* rayhit)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIntersect4);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)valid) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
if (((size_t)rayhit) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit not aligned to 16 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(normal.travs,cnt,cnt,cnt);
IntersectContext context(scene,user_context);
#if !defined(EMBREE_RAY_PACKETS)
RayHit4* ray4 = (RayHit4*) rayhit;
for (size_t i=0; i<4; i++) {
if (!valid[i]) continue;
RayHit ray1; ray4->get(i,ray1);
scene->intersectors.intersect((RTCRayHit&)ray1,&context);
ray4->set(i,ray1);
}
#else
scene->intersectors.intersect4(valid,*rayhit,&context);
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcIntersect8 (const int* valid, RTCScene hscene, RTCIntersectContext* user_context, RTCRayHit8* rayhit)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIntersect8);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)valid) & 0x1F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 32 bytes");
if (((size_t)rayhit) & 0x1F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit not aligned to 32 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<8; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(normal.travs,cnt,cnt,cnt);
IntersectContext context(scene,user_context);
#if !defined(EMBREE_RAY_PACKETS)
RayHit8* ray8 = (RayHit8*) rayhit;
for (size_t i=0; i<8; i++) {
if (!valid[i]) continue;
RayHit ray1; ray8->get(i,ray1);
scene->intersectors.intersect((RTCRayHit&)ray1,&context);
ray8->set(i,ray1);
}
#else
if (likely(scene->intersectors.intersector8))
scene->intersectors.intersect8(valid,*rayhit,&context);
else
scene->device->rayStreamFilters.intersectSOA(scene,(char*)rayhit,8,1,sizeof(RTCRayHit8),&context);
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcIntersect16 (const int* valid, RTCScene hscene, RTCIntersectContext* user_context, RTCRayHit16* rayhit)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIntersect16);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)valid) & 0x3F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 64 bytes");
if (((size_t)rayhit) & 0x3F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit not aligned to 64 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<16; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(normal.travs,cnt,cnt,cnt);
IntersectContext context(scene,user_context);
#if !defined(EMBREE_RAY_PACKETS)
RayHit16* ray16 = (RayHit16*) rayhit;
for (size_t i=0; i<16; i++) {
if (!valid[i]) continue;
RayHit ray1; ray16->get(i,ray1);
scene->intersectors.intersect((RTCRayHit&)ray1,&context);
ray16->set(i,ray1);
}
#else
if (likely(scene->intersectors.intersector16))
scene->intersectors.intersect16(valid,*rayhit,&context);
else
scene->device->rayStreamFilters.intersectSOA(scene,(char*)rayhit,16,1,sizeof(RTCRayHit16),&context);
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcIntersect1M (RTCScene hscene, RTCIntersectContext* user_context, RTCRayHit* rayhit, unsigned int M, size_t byteStride)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIntersect1M);
#if defined (EMBREE_RAY_PACKETS)
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)rayhit ) & 0x03) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
#endif
STAT3(normal.travs,M,M,M);
IntersectContext context(scene,user_context);
/* fast codepath for single rays */
if (likely(M == 1)) {
if (likely(rayhit->ray.tnear <= rayhit->ray.tfar))
scene->intersectors.intersect(*rayhit,&context);
}
/* codepath for streams */
else {
scene->device->rayStreamFilters.intersectAOS(scene,rayhit,M,byteStride,&context);
}
#else
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"rtcIntersect1M not supported");
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcIntersect1Mp (RTCScene hscene, RTCIntersectContext* user_context, RTCRayHit** rn, unsigned int M)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIntersect1Mp);
#if defined (EMBREE_RAY_PACKETS)
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)rn) & 0x03) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
#endif
STAT3(normal.travs,M,M,M);
IntersectContext context(scene,user_context);
/* fast codepath for single rays */
if (likely(M == 1)) {
if (likely(rn[0]->ray.tnear <= rn[0]->ray.tfar))
scene->intersectors.intersect(*rn[0],&context);
}
/* codepath for streams */
else {
scene->device->rayStreamFilters.intersectAOP(scene,rn,M,&context);
}
#else
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"rtcIntersect1Mp not supported");
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcIntersectNM (RTCScene hscene, RTCIntersectContext* user_context, struct RTCRayHitN* rayhit, unsigned int N, unsigned int M, size_t byteStride)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIntersectNM);
#if defined (EMBREE_RAY_PACKETS)
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)rayhit) & 0x03) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
#endif
STAT3(normal.travs,N*M,N*M,N*M);
IntersectContext context(scene,user_context);
/* code path for single ray streams */
if (likely(N == 1))
{
/* fast code path for streams of size 1 */
if (likely(M == 1)) {
if (likely(((RTCRayHit*)rayhit)->ray.tnear <= ((RTCRayHit*)rayhit)->ray.tfar))
scene->intersectors.intersect(*(RTCRayHit*)rayhit,&context);
}
/* normal codepath for single ray streams */
else {
scene->device->rayStreamFilters.intersectAOS(scene,(RTCRayHit*)rayhit,M,byteStride,&context);
}
}
/* code path for ray packet streams */
else {
scene->device->rayStreamFilters.intersectSOA(scene,(char*)rayhit,N,M,byteStride,&context);
}
#else
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"rtcIntersectNM not supported");
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcIntersectNp (RTCScene hscene, RTCIntersectContext* user_context, const RTCRayHitNp* rayhit, unsigned int N)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIntersectNp);
#if defined (EMBREE_RAY_PACKETS)
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)rayhit->ray.org_x ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.org_x not aligned to 4 bytes");
if (((size_t)rayhit->ray.org_y ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.org_y not aligned to 4 bytes");
if (((size_t)rayhit->ray.org_z ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.org_z not aligned to 4 bytes");
if (((size_t)rayhit->ray.dir_x ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.dir_x not aligned to 4 bytes");
if (((size_t)rayhit->ray.dir_y ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.dir_y not aligned to 4 bytes");
if (((size_t)rayhit->ray.dir_z ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.dir_z not aligned to 4 bytes");
if (((size_t)rayhit->ray.tnear ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.dir_x not aligned to 4 bytes");
if (((size_t)rayhit->ray.tfar ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.tnear not aligned to 4 bytes");
if (((size_t)rayhit->ray.time ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.time not aligned to 4 bytes");
if (((size_t)rayhit->ray.mask ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->ray.mask not aligned to 4 bytes");
if (((size_t)rayhit->hit.Ng_x ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->hit.Ng_x not aligned to 4 bytes");
if (((size_t)rayhit->hit.Ng_y ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->hit.Ng_y not aligned to 4 bytes");
if (((size_t)rayhit->hit.Ng_z ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->hit.Ng_z not aligned to 4 bytes");
if (((size_t)rayhit->hit.u ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->hit.u not aligned to 4 bytes");
if (((size_t)rayhit->hit.v ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->hit.v not aligned to 4 bytes");
if (((size_t)rayhit->hit.geomID) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->hit.geomID not aligned to 4 bytes");
if (((size_t)rayhit->hit.primID) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->hit.primID not aligned to 4 bytes");
if (((size_t)rayhit->hit.instID) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "rayhit->hit.instID not aligned to 4 bytes");
#endif
STAT3(normal.travs,N,N,N);
IntersectContext context(scene,user_context);
scene->device->rayStreamFilters.intersectSOP(scene,rayhit,N,&context);
#else
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"rtcIntersectNp not supported");
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcOccluded1 (RTCScene hscene, RTCIntersectContext* user_context, RTCRay* ray)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcOccluded1);
STAT3(shadow.travs,1,1,1);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)ray) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
#endif
IntersectContext context(scene,user_context);
scene->intersectors.occluded(*ray,&context);
RTC_CATCH_END2(scene);
}
RTC_API void rtcOccluded4 (const int* valid, RTCScene hscene, RTCIntersectContext* user_context, RTCRay4* ray)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcOccluded4);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)valid) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
if (((size_t)ray) & 0x0F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(shadow.travs,cnt,cnt,cnt);
IntersectContext context(scene,user_context);
#if !defined(EMBREE_RAY_PACKETS)
RayHit4* ray4 = (RayHit4*) ray;
for (size_t i=0; i<4; i++) {
if (!valid[i]) continue;
RayHit ray1; ray4->get(i,ray1);
scene->intersectors.occluded((RTCRay&)ray1,&context);
ray4->geomID[i] = ray1.geomID;
}
#else
scene->intersectors.occluded4(valid,*ray,&context);
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcOccluded8 (const int* valid, RTCScene hscene, RTCIntersectContext* user_context, RTCRay8* ray)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcOccluded8);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)valid) & 0x1F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 32 bytes");
if (((size_t)ray) & 0x1F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 32 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<8; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(shadow.travs,cnt,cnt,cnt);
IntersectContext context(scene,user_context);
#if !defined(EMBREE_RAY_PACKETS)
RayHit8* ray8 = (RayHit8*) ray;
for (size_t i=0; i<8; i++) {
if (!valid[i]) continue;
RayHit ray1; ray8->get(i,ray1);
scene->intersectors.occluded((RTCRay&)ray1,&context);
ray8->set(i,ray1);
}
#else
if (likely(scene->intersectors.intersector8))
scene->intersectors.occluded8(valid,*ray,&context);
else
scene->device->rayStreamFilters.occludedSOA(scene,(char*)ray,8,1,sizeof(RTCRay8),&context);
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcOccluded16 (const int* valid, RTCScene hscene, RTCIntersectContext* user_context, RTCRay16* ray)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcOccluded16);
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)valid) & 0x3F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 64 bytes");
if (((size_t)ray) & 0x3F) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 64 bytes");
#endif
STAT(size_t cnt=0; for (size_t i=0; i<16; i++) cnt += ((int*)valid)[i] == -1;);
STAT3(shadow.travs,cnt,cnt,cnt);
IntersectContext context(scene,user_context);
#if !defined(EMBREE_RAY_PACKETS)
RayHit16* ray16 = (RayHit16*) ray;
for (size_t i=0; i<16; i++) {
if (!valid[i]) continue;
RayHit ray1; ray16->get(i,ray1);
scene->intersectors.occluded((RTCRay&)ray1,&context);
ray16->set(i,ray1);
}
#else
if (likely(scene->intersectors.intersector16))
scene->intersectors.occluded16(valid,*ray,&context);
else
scene->device->rayStreamFilters.occludedSOA(scene,(char*)ray,16,1,sizeof(RTCRay16),&context);
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcOccluded1M(RTCScene hscene, RTCIntersectContext* user_context, RTCRay* ray, unsigned int M, size_t byteStride)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcOccluded1M);
#if defined (EMBREE_RAY_PACKETS)
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)ray) & 0x03) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
#endif
STAT3(shadow.travs,M,M,M);
IntersectContext context(scene,user_context);
/* fast codepath for streams of size 1 */
if (likely(M == 1)) {
if (likely(ray->tnear <= ray->tfar))
scene->intersectors.occluded (*ray,&context);
}
/* codepath for normal streams */
else {
scene->device->rayStreamFilters.occludedAOS(scene,ray,M,byteStride,&context);
}
#else
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"rtcOccluded1M not supported");
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcOccluded1Mp(RTCScene hscene, RTCIntersectContext* user_context, RTCRay** ray, unsigned int M)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcOccluded1Mp);
#if defined (EMBREE_RAY_PACKETS)
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)ray) & 0x03) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
#endif
STAT3(shadow.travs,M,M,M);
IntersectContext context(scene,user_context);
/* fast codepath for streams of size 1 */
if (likely(M == 1)) {
if (likely(ray[0]->tnear <= ray[0]->tfar))
scene->intersectors.occluded (*ray[0],&context);
}
/* codepath for normal streams */
else {
scene->device->rayStreamFilters.occludedAOP(scene,ray,M,&context);
}
#else
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"rtcOccluded1Mp not supported");
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcOccludedNM(RTCScene hscene, RTCIntersectContext* user_context, RTCRayN* ray, unsigned int N, unsigned int M, size_t byteStride)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcOccludedNM);
#if defined (EMBREE_RAY_PACKETS)
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (byteStride < sizeof(RTCRayHit)) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"byteStride too small");
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)ray) & 0x03) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
#endif
STAT3(shadow.travs,N*M,N*N,N*N);
IntersectContext context(scene,user_context);
/* codepath for single rays */
if (likely(N == 1))
{
/* fast path for streams of size 1 */
if (likely(M == 1)) {
if (likely(((RTCRay*)ray)->tnear <= ((RTCRay*)ray)->tfar))
scene->intersectors.occluded (*(RTCRay*)ray,&context);
}
/* codepath for normal ray streams */
else {
scene->device->rayStreamFilters.occludedAOS(scene,(RTCRay*)ray,M,byteStride,&context);
}
}
/* code path for ray packet streams */
else {
scene->device->rayStreamFilters.occludedSOA(scene,(char*)ray,N,M,byteStride,&context);
}
#else
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"rtcOccludedNM not supported");
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcOccludedNp(RTCScene hscene, RTCIntersectContext* user_context, const RTCRayNp* ray, unsigned int N)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcOccludedNp);
#if defined (EMBREE_RAY_PACKETS)
#if defined(DEBUG)
RTC_VERIFY_HANDLE(hscene);
if (scene->isModified()) throw_RTCError(RTC_ERROR_INVALID_OPERATION,"scene not committed");
if (((size_t)ray->org_x ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "org_x not aligned to 4 bytes");
if (((size_t)ray->org_y ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "org_y not aligned to 4 bytes");
if (((size_t)ray->org_z ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "org_z not aligned to 4 bytes");
if (((size_t)ray->dir_x ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "dir_x not aligned to 4 bytes");
if (((size_t)ray->dir_y ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "dir_y not aligned to 4 bytes");
if (((size_t)ray->dir_z ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "dir_z not aligned to 4 bytes");
if (((size_t)ray->tnear ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "dir_x not aligned to 4 bytes");
if (((size_t)ray->tfar ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "tnear not aligned to 4 bytes");
if (((size_t)ray->time ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "time not aligned to 4 bytes");
if (((size_t)ray->mask ) & 0x03 ) throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "mask not aligned to 4 bytes");
#endif
STAT3(shadow.travs,N,N,N);
IntersectContext context(scene,user_context);
scene->device->rayStreamFilters.occludedSOP(scene,ray,N,&context);
#else
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"rtcOccludedNp not supported");
#endif
RTC_CATCH_END2(scene);
}
RTC_API void rtcRetainScene (RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcRetainScene);
RTC_VERIFY_HANDLE(hscene);
scene->refInc();
RTC_CATCH_END2(scene);
}
RTC_API void rtcReleaseScene (RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcReleaseScene);
RTC_VERIFY_HANDLE(hscene);
scene->refDec();
RTC_CATCH_END2(scene);
}
RTC_API void rtcSetGeometryInstancedScene(RTCGeometry hgeometry, RTCScene hscene)
{
Geometry* geometry = (Geometry*) hgeometry;
Ref<Scene> scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetGeometryInstancedScene);
RTC_VERIFY_HANDLE(hgeometry);
RTC_VERIFY_HANDLE(hscene);
geometry->setInstancedScene(scene);
RTC_CATCH_END2(geometry);
}
AffineSpace3fa loadTransform(RTCFormat format, const float* xfm)
{
AffineSpace3fa space = one;
switch (format)
{
case RTC_FORMAT_FLOAT3X4_ROW_MAJOR:
space = AffineSpace3fa(Vec3fa(xfm[ 0], xfm[ 4], xfm[ 8]),
Vec3fa(xfm[ 1], xfm[ 5], xfm[ 9]),
Vec3fa(xfm[ 2], xfm[ 6], xfm[10]),
Vec3fa(xfm[ 3], xfm[ 7], xfm[11]));
break;
case RTC_FORMAT_FLOAT3X4_COLUMN_MAJOR:
space = AffineSpace3fa(Vec3fa(xfm[ 0], xfm[ 1], xfm[ 2]),
Vec3fa(xfm[ 3], xfm[ 4], xfm[ 5]),
Vec3fa(xfm[ 6], xfm[ 7], xfm[ 8]),
Vec3fa(xfm[ 9], xfm[10], xfm[11]));
break;
case RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR:
space = AffineSpace3fa(Vec3fa(xfm[ 0], xfm[ 1], xfm[ 2]),
Vec3fa(xfm[ 4], xfm[ 5], xfm[ 6]),
Vec3fa(xfm[ 8], xfm[ 9], xfm[10]),
Vec3fa(xfm[12], xfm[13], xfm[14]));
break;