// File: tomfunkhouser[P]gaps/apps/gapsview/gapsview.cpp
// Function: DrawPointSet(gaps::R3PointSet*, int, int)
static void
DrawPointSet(R3PointSet *pointset,
  int model_index, int color_scheme)
{
  // Check if should draw point set
  if (!show_pointsets) return;

  // Draw points
  if (show_points) {
    glDisable(GL_LIGHTING);    
    RNLoadRgb(0.0, 0.0, 1.0);
    glPointSize(3);
    if (color_scheme == PICK_COLOR_SCHEME) {
      RNGrfxBegin(RN_GRFX_POINTS);
      for (int i = 0; i < pointset->NPoints(); i++) {
        const R3Point& position = pointset->PointPosition(i);
        LoadColorIndex(model_index, POINTSET_POINT_ELEMENT_TYPE, i);
        R3LoadPoint(position);
      }
      RNGrfxEnd();
    }
    else {
      RNFlags draw_flags = R3_VERTICES_DRAW_FLAG;
      if (color_scheme == RGB_COLOR_SCHEME) 
        draw_flags.Add(R3_VERTEX_COLORS_DRAW_FLAG);
      pointset->Draw(draw_flags);
    }
    glPointSize(1);
  }
  
  // Draw normals
  if (show_normals) {
    glDisable(GL_LIGHTING);
    RNLoadRgb(0.0, 1.0, 0.0);
    RNGrfxBegin(RN_GRFX_LINES);
    RNScalar d = 0.0025 * world_bbox.DiagonalRadius();
    for (int i = 0; i < pointset->NPoints(); i++) {
      const R3Point& position = pointset->PointPosition(i);
      const R3Vector& normal = pointset->PointNormal(i);
      R3LoadPoint(position);
      R3LoadPoint(position + d * normal);
    }
    RNGrfxEnd();
  }
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movl %esi, 0x8c(%rsp)
movl %edx, 0x88(%rsp)
cmpl $0x0, 0x2be7b0(%rip)    # 0x2efb74
jne 0x313cb
jmp 0x315ff
cmpl $0x0, 0x2be7a6(%rip)    # 0x2efb78
je 0x314f9
movl $0xb50, %edi            # imm = 0xB50
callq 0x2a130
xorps %xmm1, %xmm1
movsd 0x234c23(%rip), %xmm2   # 0x266010
movaps %xmm1, %xmm0
callq 0x38d60
movss 0x234d1b(%rip), %xmm0   # 0x266118
callq 0x29700
cmpl $0x5, 0x88(%rsp)
jne 0x31499
xorl %edi, %edi
callq 0x38d90
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x90(%rsp), %rdi
callq 0x38db0
movl %eax, %ecx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
jge 0x31492
movq 0x90(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x38dc0
movq %rax, 0x78(%rsp)
movl 0x8c(%rsp), %edi
movl 0x84(%rsp), %edx
movl $0x1, %esi
callq 0x340b0
movq 0x78(%rsp), %rdi
callq 0x38e20
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x31422
callq 0x38e40
jmp 0x314ec
leaq 0x70(%rsp), %rdi
movl $0x4, %esi
callq 0x38e50
cmpl $0x1, 0x88(%rsp)
jne 0x314d0
leaq 0x68(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x38e50
movq 0x68(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x38e70
movq 0x90(%rsp), %rdi
movq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rsi
callq 0x184020
movss 0x234c20(%rip), %xmm0   # 0x266114
callq 0x29700
cmpl $0x0, 0x2cd7c8(%rip)    # 0x2fecc8
je 0x315ff
movl $0xb50, %edi            # imm = 0xB50
callq 0x2a130
xorps %xmm2, %xmm2
movsd 0x234af5(%rip), %xmm1   # 0x266010
movaps %xmm2, %xmm0
callq 0x38d60
movl $0x1, %edi
callq 0x38d90
leaq 0x2cd304(%rip), %rdi    # 0x2fe838
callq 0x38be0
movaps %xmm0, %xmm1
movsd 0x234b44(%rip), %xmm0   # 0x266088
mulsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x90(%rsp), %rdi
callq 0x38db0
movl %eax, %ecx
movl 0x8(%rsp), %eax
cmpl %ecx, %eax
jge 0x315fa
movq 0x90(%rsp), %rdi
movl 0x54(%rsp), %esi
callq 0x38dc0
movq %rax, 0x48(%rsp)
movq 0x90(%rsp), %rdi
movl 0x54(%rsp), %esi
callq 0x38eb0
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
callq 0x38e20
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
movsd 0x58(%rsp), %xmm0
movq 0x40(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x38f20
movq (%rsp), %rsi
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x180350
leaq 0x28(%rsp), %rdi
callq 0x38e20
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x31556
callq 0x38e40
addq $0x98, %rsp
retq
nopw (%rax,%rax)