Skip to content

Commit

Permalink
Cap sampling ratio to make sure gl.VertexAttribIPointer stride is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
f-fl0 committed Nov 20, 2024
1 parent 97c5aa6 commit df33469
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,13 +716,20 @@ L_MAIN:
samplingRatio := 1
if pe.vi.dragging() {
totalPoints := 0
maxStride := 4
if hasPointCloud && pp.Points > 0 {
totalPoints += pp.Points
maxStride = max(pp.Stride(), maxStride)
}
if hasSubPointCloud && ppSub.Points > 0 && selectMode == selectModeInsert {
totalPoints += ppSub.Points
maxStride = max(ppSub.Stride(), maxStride)
}
samplingRatio = 1 + totalPoints/pe.cmd.NumFastRenderPoints()
// make sure the stride used in gl.VertexAttribIPointer is <= 255
if samplingRatio*maxStride > 255 {
samplingRatio = int(255.0 / maxStride)
}
}

if hasPointCloud && pp.Points > 0 {
Expand Down

0 comments on commit df33469

Please sign in to comment.