// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::UpdateMeshFaceIndex()
void RGBDSurface::
UpdateMeshFaceIndex(void)
{
  // Check everything
  if (!mesh) return;
  if (width == 0) return;
  if (height == 0) return;
  if (RNIsZero(surface_bbox.Area())) return;
  
  // Create face index
  mesh_face_index = new R2Grid(width, height, surface_bbox);

  // Update mesh face index grid
  mesh_face_index->Clear(R2_GRID_UNKNOWN_VALUE);
  for (int i = 0; i < mesh->NFaces(); i++) {
    R3MeshFace *face = mesh->Face(i);
    R3MeshVertex *v0 = mesh->VertexOnFace(face, 0);
    R3MeshVertex *v1 = mesh->VertexOnFace(face, 1);
    R3MeshVertex *v2 = mesh->VertexOnFace(face, 2);
    R2Point s0 = mesh->VertexTextureCoords(v0);
    R2Point s1 = mesh->VertexTextureCoords(v1);
    R2Point s2 = mesh->VertexTextureCoords(v2);
    mesh_face_index->RasterizeWorldTriangle(s0, s1, s2, i, R2_GRID_REPLACE_OPERATION);
  }

  // For debugging
  // mesh_face_index->WriteFile("mesh_face_index.pfm");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
cmpq $0x0, 0x88(%rdi)
je 0x1cf2a
movq %rdi, %rbx
cmpl $0x0, 0x28(%rdi)
je 0x1cf2a
cmpl $0x0, 0x2c(%rbx)
je 0x1cf2a
leaq 0x48(%rbx), %r14
movq %r14, %rdi
callq 0x6d5e8
leaq 0xe9f55(%rip), %rax     # 0x106ce8
movsd (%rax), %xmm1
movapd 0xa02b1(%rip), %xmm2    # 0xbd050
xorpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jb 0x1cdb3
ucomisd %xmm0, %xmm1
jae 0x1cf2a
movl $0xd0, %edi
callq 0x115b0
movq %rax, %r15
movl 0x28(%rbx), %esi
movl 0x2c(%rbx), %edx
movq %rax, %rdi
movq %r14, %rcx
callq 0x604c0
movq %r15, 0x90(%rbx)
movsd 0xa0238(%rip), %xmm0    # 0xbd018
movq %r15, %rdi
callq 0x62582
movq 0x88(%rbx), %rax
cmpl $0x0, 0x34(%rax)
jle 0x1cf2a
xorl %r15d, %r15d
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %r13
movq 0x28(%rax), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rbp
movq 0x18(%rax), %r14
addq $0x48, %rsi
leaq 0x40(%rsp), %rdi
callq 0x6fef0
addq $0x48, %rbp
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x6fef0
addq $0x48, %r14
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x6fef0
movq 0x90(%rbx), %rbp
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd %xmm0, (%rsp)
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x677e2
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
leaq 0x60(%rsp), %rdi
movq %rbp, %rsi
callq 0x677e2
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x677e2
movapd 0x70(%rsp), %xmm0
movapd 0xa0fe9(%rip), %xmm1    # 0xbdea0
addpd %xmm1, %xmm0
cvttpd2dq %xmm0, %xmm0
movlpd %xmm0, 0x18(%rsp)
movapd 0x60(%rsp), %xmm0
addpd %xmm1, %xmm0
cvttpd2dq %xmm0, %xmm0
movlpd %xmm0, 0x10(%rsp)
movapd 0x50(%rsp), %xmm0
addpd %xmm1, %xmm0
cvttpd2dq %xmm0, %xmm0
movlpd %xmm0, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
movsd (%rsp), %xmm0
movapd %xmm0, %xmm1
movapd %xmm0, %xmm2
movl $0x2, %r8d
callq 0x66612
incq %r15
movq 0x88(%rbx), %rax
movslq 0x34(%rax), %rcx
cmpq %rcx, %r15
jl 0x1ce06
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0xd0, %esi
movq %r15, %rdi
callq 0x115c0
movq %rbx, %rdi
callq 0x11a70