Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A mistake in range determination. #2

Open
lidan233 opened this issue Jul 29, 2021 · 3 comments
Open

A mistake in range determination. #2

lidan233 opened this issue Jul 29, 2021 · 3 comments

Comments

@lidan233
Copy link

` ############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?

@lidan233
Copy link
Author

In other words, I notice my morton code is not increase. So how to fixed it?

@lyd405121
Copy link
Owner

给个输入的数据,比如obj给我,我来调一下,主要我也在厂里打工,不会很及时回复,见谅

In other words, I notice my morton code is not increase. So how to fixed it?

@lyd405121
Copy link
Owner

In other words, I notice my morton code is not increase. So how to fixed it?

  • Recently, I make a new repostory to do bvh things
  • And about the morton code which not increasing, we can use an leaf collapse process to combine those primitive as a leaf node
  • Here is a slide about all things bvh constructing process which is wirrten by him
  • ploc-slides.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants