@@ -265,11 +265,11 @@ ISAAC_HOST_DEVICE_INLINE void check_coord( isaac_float3& coord, const TLocalSize
265265 if (coord.z < isaac_float (0 ))
266266 coord.z = isaac_float (0 );
267267 if ( coord.x >= isaac_float (local_size.value .x ) )
268- coord.x = isaac_float (local_size.value .x )-isaac_float (1 );
268+ coord.x = isaac_float (local_size.value .x )-isaac_float (1 )-FLT_MIN ;
269269 if ( coord.y >= isaac_float (local_size.value .y ) )
270- coord.y = isaac_float (local_size.value .y )-isaac_float (1 );
270+ coord.y = isaac_float (local_size.value .y )-isaac_float (1 )-FLT_MIN ;
271271 if ( coord.z >= isaac_float (local_size.value .z ) )
272- coord.z = isaac_float (local_size.value .z )-isaac_float (1 );
272+ coord.z = isaac_float (local_size.value .z )-isaac_float (1 )-FLT_MIN ;
273273}
274274
275275template <
@@ -293,7 +293,11 @@ struct merge_source_iterator
293293 typename TFeedback,
294294 typename TStep,
295295 typename TStepLength,
296- typename TScale
296+ typename TScale,
297+ typename TFirst,
298+ typename TLast,
299+ typename TStartNormal,
300+ typename TEndNormal
297301 >
298302 ISAAC_HOST_DEVICE_INLINE void operator ()(
299303 const NR& nr,
@@ -307,7 +311,11 @@ struct merge_source_iterator
307311 TFeedback& feedback,
308312 const TStep& step,
309313 const TStepLength& stepLength,
310- const TScale& scale
314+ const TScale& scale,
315+ const TFirst& first,
316+ const TLast& last,
317+ const TStartNormal& start_normal,
318+ const TEndNormal& end_normal
311319 ) const
312320 {
313321 if ( mpl::at_c< TFilter, NR::value >::type::value )
@@ -374,6 +382,18 @@ struct merge_source_iterator
374382 (get_value< TInterpolation, NR >( source, back, pointerArray, local_size, scale ) -
375383 get_value< TInterpolation, NR >( source, front, pointerArray, local_size, scale )) / d3
376384 };
385+ if (first)
386+ {
387+ gradient.x = start_normal.x ;
388+ gradient.y = start_normal.y ;
389+ gradient.z = start_normal.z ;
390+ }
391+ if (last)
392+ {
393+ gradient.x = end_normal.x ;
394+ gradient.y = end_normal.y ;
395+ gradient.z = end_normal.z ;
396+ }
377397 isaac_float l = sqrt (
378398 gradient.x * gradient.x +
379399 gradient.y * gradient.y +
@@ -526,6 +546,8 @@ template <
526546 isaac_float3 count_start[ISAAC_VECTOR_ELEM];
527547 isaac_float3 local_size_f[ISAAC_VECTOR_ELEM];
528548 isaac_float3 count_end[ISAAC_VECTOR_ELEM];
549+ isaac_float3 start_normal[ISAAC_VECTOR_ELEM];
550+ isaac_float3 end_normal[ISAAC_VECTOR_ELEM];
529551
530552 ISAAC_ELEM_ITERATE (e)
531553 {
@@ -608,8 +630,22 @@ template <
608630 ISAAC_SWITCH_IF_SMALLER ( count_end[e].z , count_start[e].z )
609631
610632 // calc intersection of all three super planes and save in [count_start.x ; count_end.x]
611- count_start[e].x = ISAAC_MAX ( ISAAC_MAX ( count_start[e].x , count_start[e].y ), count_start[e].z );
612- count_end[e].x = ISAAC_MIN ( ISAAC_MIN ( count_end[e].x , count_end[e].y ), count_end[e].z );
633+ float max_start = ISAAC_MAX ( ISAAC_MAX ( count_start[e].x , count_start[e].y ), count_start[e].z );
634+ if (count_start[e].x == max_start)
635+ start_normal[e] = {-1 ,0 ,0 };
636+ if (count_start[e].y == max_start)
637+ start_normal[e] = {0 ,-1 ,0 };
638+ if (count_start[e].z == max_start)
639+ start_normal[e] = {0 ,0 ,-1 };
640+ count_start[e].x = max_start;
641+ float min_end = ISAAC_MIN ( ISAAC_MIN ( count_end[e].x , count_end[e].y ), count_end[e].z );
642+ if (count_end[e].x == min_end)
643+ end_normal[e] = {-1 ,0 ,0 };
644+ if (count_end[e].y == min_end)
645+ end_normal[e] = {0 ,-1 ,0 };
646+ if (count_end[e].z == min_end)
647+ end_normal[e] = {0 ,0 ,-1 };
648+ count_end[e].x = min_end;
613649 if ( count_start[e].x > count_end[e].x )
614650 {
615651 if (!finish[e])
@@ -680,7 +716,12 @@ template <
680716 finish[e] = true ;
681717 }
682718 if ( first[e] < intersection_step[e] )
719+ {
683720 first[e] = ceil ( intersection_step[e] );
721+ start_normal[e].x = clipping[e].elem [i].normal .x ;
722+ start_normal[e].y = clipping[e].elem [i].normal .y ;
723+ start_normal[e].z = clipping[e].elem [i].normal .z ;
724+ }
684725 }
685726 else
686727 {
@@ -691,7 +732,12 @@ template <
691732 finish[e] = true ;
692733 }
693734 if ( last[e] > intersection_step[e] )
735+ {
694736 last[e] = floor ( intersection_step[e] );
737+ end_normal[e].x = clipping[e].elem [i].normal .x ;
738+ end_normal[e].y = clipping[e].elem [i].normal .y ;
739+ end_normal[e].z = clipping[e].elem [i].normal .z ;
740+ }
695741 }
696742 }
697743 }
@@ -720,6 +766,8 @@ template <
720766 value[e].z = 0 ;
721767 value[e].w = 0 ;
722768 result[e] = 0 ;
769+ bool firstRound = (i == first[e]);
770+ bool lastRound = (i == last[e]);
723771 isaac_for_each_with_mpl_params
724772 (
725773 sources,
@@ -739,7 +787,11 @@ template <
739787 result[e],
740788 step_vec[e],
741789 step,
742- scale
790+ scale,
791+ firstRound,
792+ lastRound,
793+ start_normal[e],
794+ end_normal[e]
743795 );
744796 /* if ( mpl::size< TSourceList >::type::value > 1)
745797 value = value / isaac_float( mpl::size< TSourceList >::type::value );*/
0 commit comments