// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::DrawPoints(int, int) const
void RGBDImage::
DrawPoints(int color_scheme, int skip) const
{
  // Push transformation
  CameraToWorld().Push();

  // Enable lighting and material
  if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_LIGHTING);
  }

  // Draw color
  LoadColor(color_scheme);

  // Set point size
  glPointSize(2);

  // Draw points
  if (color_scheme != RGBD_RENDER_COLOR_SCHEME) {
    RNGrfxBegin(RN_GRFX_POINTS);
    R3Point world_position;
    for (int ix = 0; ix < NPixels(RN_X); ix += skip) {
      for (int iy = 0; iy < NPixels(RN_Y); iy += skip) {
        if (RGBDTransformImageToCamera(R2Point(ix+0.5, iy+0.5), world_position, this)) {
          if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) RNLoadRgb(PixelColor(ix, iy));
          R3LoadPoint(world_position);
        }
      }
    }
    RNGrfxEnd();
  }
  else {
    RNGrfxBegin(RN_GRFX_POINTS);
    R3Point world_position, p1, p2;
    for (int ix = 0; ix < NPixels(RN_X); ix += skip) {
      for (int iy = 0; iy < NPixels(RN_Y); iy += skip) {
        if (!RGBDTransformImageToCamera(R2Point(ix+0.5, iy+0.5), world_position, this)) continue;
        if (!RGBDTransformImageToCamera(R2Point(ix+1, iy), p1, this)) continue;
        if (!RGBDTransformImageToCamera(R2Point(ix, iy+1), p2, this)) continue;
        R3Plane plane(world_position, p1, p2);
        R3LoadNormal(plane.Normal());
        R3LoadPoint(world_position);
      }
    }
    RNGrfxEnd();
  }

  // Reset point size
  glPointSize(1);
  
  // Disable lighting and material
  if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    glDisable(GL_COLOR_MATERIAL);
    glDisable(GL_LIGHTING);
  }

  // Pop transformation
  CameraToWorld().Pop();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, %r14d
movl %esi, %ebx
movq %rdi, %r15
addq $0x30, %rdi
movq 0x30(%r15), %rax
movq %rdi, 0x20(%rsp)
callq *0xb0(%rax)
cmpl $0x2, %ebx
movl %ebx, 0xc(%rsp)
jne 0x1ef91
movl $0xb57, %edi            # imm = 0xB57
callq 0x11540
movl $0x408, %edi            # imm = 0x408
movl $0x1602, %esi           # imm = 0x1602
callq 0x113b0
movl $0xb50, %edi            # imm = 0xB50
callq 0x11540
movq (%r15), %rax
movq %r15, %rdi
movl %ebx, %esi
callq *0xf0(%rax)
movss 0x9f27e(%rip), %xmm0    # 0xbe0a0
callq 0x11090
movq $0x0, 0x10(%rsp)
xorl %edi, %edi
callq 0x11150
leaq 0x40(%rsp), %rdi
callq 0x4be44
leaq 0x90(%rsp), %rdi
callq 0x4be44
leaq 0x58(%rsp), %rdi
callq 0x4be44
cmpl $0x0, 0x28(%r15)
jle 0x1f070
leaq 0x70(%rsp), %r12
leaq 0x40(%rsp), %r13
leaq 0x90(%rsp), %rbx
cmpl $0x0, 0x2c(%r15)
jle 0x1ef75
movq 0x10(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x28(%rsp)
addsd 0x9e186(%rip), %xmm0    # 0xbd020
movsd %xmm0, 0x38(%rsp)
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x30(%rsp)
movl $0x1, %ebp
leal -0x1(%rbp), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd %xmm1, 0x18(%rsp)
addsd 0x9e154(%rip), %xmm1    # 0xbd020
movq %r12, %rdi
movsd 0x38(%rsp), %xmm0
callq 0x6fee6
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x16507
testl %eax, %eax
je 0x1ef5e
movq %r12, %rdi
movsd 0x30(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
callq 0x6fee6
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x16507
testl %eax, %eax
je 0x1ef5e
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movq %r12, %rdi
movsd 0x28(%rsp), %xmm0
callq 0x6fee6
movq %r12, %rdi
leaq 0x58(%rsp), %rsi
movq %r15, %rdx
callq 0x16507
testl %eax, %eax
je 0x1ef5e
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
leaq 0x58(%rsp), %rcx
callq 0x4ab32
movq %r12, %rdi
callq 0x118d0
movq %r13, %rdi
callq 0x11170
leal (%r14,%rbp), %eax
decl %eax
movl %ebp, %ecx
addl %r14d, %ecx
movl %ecx, %ebp
cmpl 0x2c(%r15), %eax
jl 0x1eeb4
movq 0x10(%rsp), %rax
addl %r14d, %eax
movq %rax, 0x10(%rsp)
cmpl 0x28(%r15), %eax
jl 0x1ee75
jmp 0x1f070
movq (%r15), %rax
movq %r15, %rdi
movl %ebx, %esi
callq *0xf0(%rax)
movss 0x9f0f9(%rip), %xmm0    # 0xbe0a0
callq 0x11090
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x11150
leaq 0x70(%rsp), %rdi
callq 0x4be44
cmpl $0x0, 0x28(%r15)
jle 0x1f070
leaq 0x40(%rsp), %r12
leaq 0x70(%rsp), %r13
cmpl $0x0, 0x2c(%r15)
jle 0x1f063
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
addsd 0x9e032(%rip), %xmm0    # 0xbd020
movsd %xmm0, 0x18(%rsp)
xorl %ebp, %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
addsd 0x9e01b(%rip), %xmm1    # 0xbd020
movq %r12, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x6fee6
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x16507
testl %eax, %eax
je 0x1f05a
cmpl $0x1, 0xc(%rsp)
jne 0x1f052
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x1d9d8
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
callq 0x11900
movq %r13, %rdi
callq 0x11170
addl %r14d, %ebp
cmpl 0x2c(%r15), %ebp
jl 0x1eff6
addl %r14d, %ebx
cmpl 0x28(%r15), %ebx
jl 0x1efd4
callq 0x117d0
movss 0x9f027(%rip), %xmm0    # 0xbe0a4
callq 0x11090
cmpl $0x2, 0xc(%rsp)
jne 0x1f09d
movl $0xb57, %edi            # imm = 0xB57
callq 0x11180
movl $0xb50, %edi            # imm = 0xB50
callq 0x11180
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop