// File: /workspace/github_cpp_makefile_star2_O3/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, 0x18(%rsp)
callq *0xb0(%rax)
cmpl $0x2, %ebx
movl %ebx, 0xc(%rsp)
jne 0x1ece5
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 $0x2, %esi
callq *0xf0(%rax)
movss 0x9d525(%rip), %xmm0    # 0xbc0a0
callq 0x11090
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x11150
leaq 0x40(%rsp), %rdi
callq 0x4b600
leaq 0x90(%rsp), %rdi
callq 0x4b600
leaq 0x58(%rsp), %rdi
callq 0x4b600
movl 0x28(%r15), %ecx
testl %ecx, %ecx
jle 0x1edca
movl 0x2c(%r15), %eax
leaq 0x70(%rsp), %r12
leaq 0x40(%rsp), %r13
leaq 0x90(%rsp), %rbx
testl %eax, %eax
jle 0x1ecd5
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x28(%rsp)
addsd 0x9c437(%rip), %xmm0    # 0xbb020
movsd %xmm0, 0x38(%rsp)
movq %rbp, 0x20(%rsp)
leal 0x1(%rbp), %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, 0x10(%rsp)
addsd 0x9c3ff(%rip), %xmm1    # 0xbb020
movq %r12, %rdi
movsd 0x38(%rsp), %xmm0
callq 0x6f0d6
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1643b
testl %eax, %eax
je 0x1ecb3
movq %r12, %rdi
movsd 0x30(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x6f0d6
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1643b
testl %eax, %eax
je 0x1ecb3
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movq %r12, %rdi
movsd 0x28(%rsp), %xmm0
callq 0x6f0d6
movq %r12, %rdi
leaq 0x58(%rsp), %rsi
movq %r15, %rdx
callq 0x1643b
testl %eax, %eax
je 0x1ecb3
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
leaq 0x58(%rsp), %rcx
callq 0x4a2ee
movq %r12, %rdi
callq 0x118c0
movq %r13, %rdi
callq 0x11170
movl 0x2c(%r15), %eax
leal (%r14,%rbp), %ecx
decl %ecx
movl %ebp, %edx
addl %r14d, %edx
movl %edx, %ebp
cmpl %eax, %ecx
jl 0x1ec09
movl 0x28(%r15), %ecx
movq 0x20(%rsp), %rbp
addl %r14d, %ebp
cmpl %ecx, %ebp
jl 0x1ebcc
jmp 0x1edca
movq (%r15), %rax
movq %r15, %rdi
movl %ebx, %esi
callq *0xf0(%rax)
movss 0x9d3a5(%rip), %xmm0    # 0xbc0a0
callq 0x11090
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x11150
leaq 0x70(%rsp), %rdi
callq 0x4b600
movl 0x28(%r15), %ecx
testl %ecx, %ecx
jle 0x1edca
movl 0x2c(%r15), %eax
leaq 0x40(%rsp), %r12
leaq 0x70(%rsp), %r13
testl %eax, %eax
jle 0x1edbf
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
addsd 0x9c2dc(%rip), %xmm0    # 0xbb020
movsd %xmm0, 0x10(%rsp)
xorl %ebp, %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
addsd 0x9c2c5(%rip), %xmm1    # 0xbb020
movq %r12, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x6f0d6
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1643b
testl %eax, %eax
je 0x1edb0
cmpl $0x1, 0xc(%rsp)
jne 0x1eda8
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x1d72e
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
callq 0x118f0
movq %r13, %rdi
callq 0x11170
addl %r14d, %ebp
movl 0x2c(%r15), %eax
cmpl %eax, %ebp
jl 0x1ed4c
movl 0x28(%r15), %ecx
addl %r14d, %ebx
cmpl %ecx, %ebx
jl 0x1ed2d
callq 0x117c0
movss 0x9d2cd(%rip), %xmm0    # 0xbc0a4
callq 0x11090
cmpl $0x2, 0xc(%rsp)
jne 0x1edf7
movl $0xb57, %edi            # imm = 0xB57
callq 0x11180
movl $0xb50, %edi            # imm = 0xB50
callq 0x11180
movq 0x18(%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