Skip to content

Commit

Permalink
Apply to sub points as well
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat committed Nov 20, 2024
1 parent e56987e commit 3a93d1b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions main_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,16 +713,23 @@ func (pe *pcdeditor) runImpl(ctx context.Context) error {
pointSize := pe.cmd.PointSize()
selectMode := pe.cmd.SelectMode()

totalPoints := 0
if hasPointCloud && pp.Points > 0 {
totalPoints += pp.Points
}
if hasSubPointCloud && ppSub.Points > 0 && selectMode == selectModeInsert {
totalPoints += ppSub.Points
}
samplingRatio := 1
if pe.vi.dragging() {
samplingRatio = 1 + totalPoints/nPointSamplingStart
}

if hasPointCloud && pp.Points > 0 {
// Render PointCloud
gl.UseProgram(program)
clean := enableVertexAttribs(gl, aVertexPosition, aVertexLabel, aSelectMask)

samplingRatio := 1
if pe.vi.dragging() {
samplingRatio = 1 + pp.Points/nPointSamplingStart
}

switch selectMode {
case selectModeRect, selectModeInsert:
gl.Uniform1i(uUseSelectMask, 0)
Expand Down Expand Up @@ -768,14 +775,17 @@ func (pe *pcdeditor) runImpl(ctx context.Context) error {
gl.UseProgram(programSub)
clean := enableVertexAttribs(gl, aVertexPosition)
gl.BindBuffer(gl.ARRAY_BUFFER, posSubBuf)
gl.VertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, ppSub.Stride(), 0)
gl.VertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, ppSub.Stride()*samplingRatio, 0)
trans := cursorsToTrans(cursors)
gl.UniformMatrix4fv(
uModelViewMatrixLocationSub, false,
modelViewMatrix.Mul(trans),
)
gl.Uniform1f(uPointSizeBaseSub, pointSize)
gl.DrawArrays(gl.POINTS, 0, ppSub.Points-1)
n := ppSub.Points / samplingRatio
for i := 0; i < n; i += maxDrawArraysPoints {
gl.DrawArrays(gl.POINTS, i, min(n-i, maxDrawArraysPoints)-1)
}

gl.Disable(gl.BLEND)
clean()
Expand Down

0 comments on commit 3a93d1b

Please sign in to comment.