From df334696d3af71cd6d9b85a44fe029387d18fb65 Mon Sep 17 00:00:00 2001 From: f-fl0 Date: Thu, 21 Nov 2024 00:45:12 +0900 Subject: [PATCH] Cap sampling ratio to make sure gl.VertexAttribIPointer stride is valid --- main_js.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main_js.go b/main_js.go index 3c49b4c..9b7037e 100644 --- a/main_js.go +++ b/main_js.go @@ -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 {