` ############algrithm##############
@ti.func
def determineRange(self, idx):
l_r_range = ti.cast(ti.Vector([0, self.primitive_count-1]), ti.i32)
if idx != 0:
self_code = self.morton_code_s[idx][0]
l = idx-1
r = idx+1
l_code = self.morton_code_s[l][0]
r_code = self.morton_code_s[r][0]
if (l_code == self_code ) & (r_code == self_code) :
l_r_range[0] = idx
while idx < self.primitive_count-1:
idx += 1
if(idx >= self.primitive_count-1):
break
if (self.morton_code_s[idx][0] != self.morton_code_s[idx+1][0]):
break
l_r_range[1] = idx
else:
L_delta = UF.common_upper_bits(self_code, l_code)
R_delta = UF.common_upper_bits(self_code, r_code)
d = -1
if R_delta > L_delta:
d = 1
delta_min = min(L_delta, R_delta)
l_max = 2
delta = -1
i_tmp = idx + d * l_max
if ( (0 <= i_tmp) &(i_tmp < self.primitive_count)):
delta = UF.common_upper_bits(self_code, self.morton_code_s[i_tmp][0])
while delta > delta_min:
l_max <<= 1
i_tmp = idx + d * l_max
delta = -1
if ( (0 <= i_tmp) & (i_tmp < self.primitive_count)):
delta = UF.common_upper_bits(self_code, self.morton_code_s[i_tmp][0])
l = 0
t = l_max >> 1
while(t > 0):
i_tmp = idx + (l + t) * d
delta = -1
if ( (0 <= i_tmp) & (i_tmp < self.primitive_count)):
delta = UF.common_upper_bits(self_code, self.morton_code_s[i_tmp][0])
if(delta > delta_min):
l += t
t >>= 1
l_r_range[0] = idx
l_r_range[1] = idx + l * d
if(d < 0):
tmp = l_r_range[0]
l_r_range[0] = l_r_range[1]
l_r_range[1] = tmp
return l_r_range`
In this code, I find delta may be equal to delta_min at the end of 'while delta > delta_min:'. Therefore, at last, l_r_range[1] = l_r_range[0]'. This is a mistake?