// File: /workspace/github_cpp_makefile_star2_O3/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 0x1cd26
movq %rdi, %rbx
cmpl $0x0, 0x28(%rdi)
je 0x1cd26
cmpl $0x0, 0x2c(%rbx)
je 0x1cd26
leaq 0x48(%rbx), %r14
movq %r14, %rdi
callq 0x6c7d2
leaq 0xe8149(%rip), %rax     # 0x104cd8
movsd (%rax), %xmm1
movapd 0x9e4b5(%rip), %xmm2    # 0xbb050
xorpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jb 0x1cbaf
ucomisd %xmm0, %xmm1
jae 0x1cd26
movl $0xd0, %edi
callq 0x115b0
movq %rax, %r15
movl 0x28(%rbx), %esi
movl 0x2c(%rbx), %edx
movq %rax, %rdi
movq %r14, %rcx
callq 0x5f72a
movq %r15, 0x90(%rbx)
movsd 0x9e43c(%rip), %xmm0    # 0xbb018
movq %r15, %rdi
callq 0x617b0
movq 0x88(%rbx), %rax
cmpl $0x0, 0x34(%rax)
jle 0x1cd26
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 0x6f0e0
addq $0x48, %rbp
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x6f0e0
addq $0x48, %r14
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x6f0e0
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 0x6696e
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
leaq 0x60(%rsp), %rdi
movq %rbp, %rsi
callq 0x6696e
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x6696e
movapd 0x70(%rsp), %xmm0
movapd 0x9f1ed(%rip), %xmm1    # 0xbbea0
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 0x6580a
incq %r15
movq 0x88(%rbx), %rax
movslq 0x34(%rax), %rcx
cmpq %rcx, %r15
jl 0x1cc02
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 0x11a60