// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3TriangleArray.cpp
// Function: gaps::R3TriangleArray::Update()
void R3TriangleArray::
Update(void)
{
  // Mark vertices as shared
  for (int i = 0; i < vertices.NEntries(); i++) {
    R3TriangleVertex *v = vertices.Kth(i);
    v->SetSharedFlag();
  }
    
  // Recompute bounding box
  bbox = R3null_box;
  for (int i = 0; i < vertices.NEntries(); i++) {
    R3TriangleVertex *v = vertices.Kth(i);
    bbox.Union(v->Position());
  }

  // Recompute flags
  flags.Add(R3_EVERYTHING_DRAW_FLAGS);
  for (int i = 0; i < vertices.NEntries(); i++) {
    R3TriangleVertex *v = vertices.Kth(i);
    RNFlags vertex_flags = v->Flags();
    if (!(vertex_flags[R3_VERTEX_NORMALS_DRAW_FLAG]))
      flags.Remove(R3_VERTEX_NORMALS_DRAW_FLAG);
    if (!(vertex_flags[R3_VERTEX_COLORS_DRAW_FLAG]))
      flags.Remove(R3_VERTEX_COLORS_DRAW_FLAG);
    if (!(vertex_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]))
      flags.Remove(R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG);
  }

  // Invalidate VBO
  InvalidateVBO();
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0xac(%rsp)
movq 0x38(%rsp), %rdi
movl 0xac(%rsp), %eax
movl %eax, 0x34(%rsp)
addq $0x8, %rdi
callq 0x13600
movl %eax, %ecx
movl 0x34(%rsp), %eax
cmpl %ecx, %eax
jge 0x99637
movq 0x38(%rsp), %rdi
addq $0x8, %rdi
movl 0xac(%rsp), %esi
callq 0x9a260
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x9a2b0
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x995d7
movq 0x38(%rsp), %rdi
addq $0x28, %rdi
leaq 0xdf1a1(%rip), %rsi     # 0x1787e8
callq 0x37500
movl $0x0, 0x9c(%rsp)
movq 0x38(%rsp), %rdi
movl 0x9c(%rsp), %eax
movl %eax, 0x30(%rsp)
addq $0x8, %rdi
callq 0x13600
movl %eax, %ecx
movl 0x30(%rsp), %eax
cmpl %ecx, %eax
jge 0x996d5
movq 0x38(%rsp), %rdi
addq $0x8, %rdi
movl 0x9c(%rsp), %esi
callq 0x9a260
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x90(%rsp)
addq $0x28, %rax
movq %rax, 0x28(%rsp)
movq 0x90(%rsp), %rdi
callq 0x78950
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x444b0
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x99657
movq 0x38(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x20(%rsp)
leaq 0x88(%rsp), %rdi
movl $0x7777, %esi           # imm = 0x7777
callq 0x13d80
movq 0x20(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x37560
movl $0x0, 0x84(%rsp)
movq 0x38(%rsp), %rdi
movl 0x84(%rsp), %eax
movl %eax, 0x1c(%rsp)
addq $0x8, %rdi
callq 0x13600
movl %eax, %ecx
movl 0x1c(%rsp), %eax
cmpl %ecx, %eax
jge 0x99865
movq 0x38(%rsp), %rdi
addq $0x8, %rdi
movl 0x84(%rsp), %esi
callq 0x9a260
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0x9a5a0
movq %rax, 0x70(%rsp)
leaq 0x68(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x13d80
movq 0x68(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
jne 0x997b1
movq 0x38(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x10(%rsp)
leaq 0x60(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x13d80
movq 0x10(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x372b0
leaq 0x58(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x13d80
movq 0x58(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
jne 0x99800
movq 0x38(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x8(%rsp)
leaq 0x50(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x13d80
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x372b0
leaq 0x48(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x13d80
movq 0x48(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
jne 0x9984d
movq 0x38(%rsp), %rax
addq $0x60, %rax
movq %rax, (%rsp)
leaq 0x40(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x13d80
movq (%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x372b0
jmp 0x9984f
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x99712
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
addq $0xb8, %rsp
retq
nopl (%rax,%rax)