Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh.h
| Show First 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | #ifdef __INTERSECTION_REFINE__ | ||||
| return res; | return res; | ||||
| #else | #else | ||||
| const float epsilon_f = 1e-4f; | const float epsilon_f = 1e-4f; | ||||
| return P + epsilon_f*Ng; | return P + epsilon_f*Ng; | ||||
| #endif | #endif | ||||
| } | } | ||||
| #if defined(__SHADOW_RECORD_ALL__) || defined (__VOLUME_RECORD_ALL__) | #if defined(__SHADOW_RECORD_ALL__) || defined(__VOLUME_RECORD_ALL__) | ||||
| /* ToDo: Move to another file? */ | /* ToDo: Move to another file? */ | ||||
| ccl_device int intersections_compare(const void *a, const void *b) | ccl_device int intersections_compare(const void *a, const void *b) | ||||
| { | { | ||||
| const Intersection *isect_a = (const Intersection*)a; | const Intersection *isect_a = (const Intersection*)a; | ||||
| const Intersection *isect_b = (const Intersection*)b; | const Intersection *isect_b = (const Intersection*)b; | ||||
| if(isect_a->t < isect_b->t) | if(isect_a->t < isect_b->t) | ||||
| return -1; | return -1; | ||||
| else if(isect_a->t > isect_b->t) | else if(isect_a->t > isect_b->t) | ||||
| return 1; | return 1; | ||||
| else | else | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| ccl_device_inline void sort_intersections(Intersection *hits, uint num_hits) | |||||
| { | |||||
| #ifdef __KERNEL_GPU__ | |||||
| /* Use bubble sort which has more friendly memory pattern on GPU. */ | |||||
| int i, j; | |||||
| for(i = 0; i < num_hits; ++i) { | |||||
| for(j = 0; j < num_hits - 1; ++j) { | |||||
| if(hits[j].t < hits[j + 1].t) { | |||||
| Intersection tmp = hits[j]; | |||||
| hits[j] = hits[j + 1]; | |||||
| hits[j + 1] = tmp; | |||||
| } | |||||
| } | |||||
| } | |||||
| #else | |||||
| qsort(hits, num_hits, sizeof(Intersection), intersections_compare); | |||||
| #endif | #endif | ||||
| } | |||||
| #endif /* __SHADOW_RECORD_ALL__ | __VOLUME_RECORD_ALL__ */ | |||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||