//CFTTConvex - [2020-04-13 11:57:46]
#ifndef _CFTTCONVEX_H_
#define _CFTTCONVEX_H_

#include "CFTTVector32.h"
#include "CFTTPlane32.h"
#include "TFTTFace.h"

/*
001C1380 CFTTConvex::CFTTConvex()
001C1394 CFTTConvex::CFTTConvex(TFTTVertex *,TFTTEdge *,TFTTFace *,uchar,uchar,uchar)
001C13B8 CFTTConvex::~CFTTConvex()
001C0418 CFTTConvex::Set(TFTTVertex *,TFTTEdge *,TFTTFace *,uchar,uchar,uchar)
001C0488 CFTTConvex::Split(CFTTPlane32 const&,CFTTConvex*&)
001C0734 CFTTConvex::SetTetraBuffer(TFTTTetrahedron *,uchar)
001C0740 CFTTConvex::GenerateTetrahedra()
001C0B24 CFTTConvex::GetVolume(bool)
001C0B60 CFTTConvex::Split(CFTTPlane32 const&,CFTTConvex*&,CFTTConvex*&)
001C0BA4 CFTTConvex::GetNumTetras()
001C0BAC CFTTConvex::GenerateRandomTetra()
001C0D00 CFTTConvex::SetTriangleBuffer(TFTTTriangle *,uchar)
001C0D10 CFTTConvex::GenerateTriangles()
001C107C CFTTConvex::ProjectTriangles(CFTTVector32)
001C11EC CFTTConvex::GetArea(bool)
001C122C CFTTConvex::GenerateRandomTri(CFTTVector32)
001C13F8 CFTTConvex::GetSplitType(CFTTPlane32 const&)
001C148C CFTTConvex::FlipDistances()
001C14B0 CFTTConvex::Clip()
001C14CE CFTTConvex::Clone(CFTTConvex const&)
001C154C CFTTConvex::ProcessVertices()
001C15BC CFTTConvex::ProcessEdges()
001C16D8 CFTTConvex::ProcessFaces()
001C17FC CFTTConvex::Cleanup()
001C1A28 CFTTConvex::GetOpenPolyline(TFTTFace const&,uchar &,uchar &)
*/

typedef unsigned char uchar;
typedef unsigned short ushort;

struct TFTTVertex {
  CFTTVector32 vector_0;
  float field_C;
  uchar field_10;// bool field_10;
  bool field_11;
  char field_12;  //为了对齐
  char field_13;  //为了对齐
};

struct TFTTEdge {
  uchar field_0;   //vertex index
  uchar field_1;  //vertex index
  char field_2;
  char field_3;
  int field_4;
  bool field_8;
  char field_9;  //为了对齐
  char field_A;  //为了对齐
  char field_B;  //为了对齐
};

struct TFTTTetrahedron {
  CFTTVector32 vec32_0;
  //float field_0;
  //float field_4;
  //float field_8;
  CFTTVector32 vec32_C;
  // float field_C;
  // float field_10;
  // float field_14;
  CFTTVector32 vec32_18;
  // float field_18;
  // float field_1C;
  // float field_20;
  CFTTVector32 vec32_24;
  //float field_24;
  //int field_28;  //type??
  //float field_2C;
  uchar field_30;
  uchar field_31;
  uchar field_32;
  uchar field_33;
  float field_34;
};

struct TFTTTriangle {
  //CFTTPlane32 plane_0;
  CFTTVector32 vec32_0;
  CFTTVector32 vec32_C;
  //float field_0;
  //CFTTPlane32 plane_4;
  //float field_14;
  CFTTVector32 vec32_18;
  //float field_18; // x
  //float field_1C; // y
  //float field_20; // z
  uchar field_24[3];
  uchar field_27;
  float fTriangleArea_28;
};

class CFTTConvex {
public:
  CFTTConvex();                                                           //001C1380
  CFTTConvex(TFTTVertex *, TFTTEdge *, TFTTFace *, uchar, uchar, uchar);  //001C1394
  ~CFTTConvex();                                                          //001C13B8
  void Set(TFTTVertex *, TFTTEdge *, TFTTFace *, uchar, uchar, uchar);    //001C0418
  //里面函数调用传参很奇怪
  static void Split(CFTTPlane32 const &, CFTTConvex *&);           //001C0488
  void SetTetraBuffer(TFTTTetrahedron *, uchar);                 //001C0734
  void GenerateTetrahedra();                                     //001C0740
  float GetVolume(bool);                                         //001C0B24
  static uint Split(CFTTPlane32 const &, CFTTConvex *&, CFTTConvex *&);  //001C0B60
  uchar GetNumTetras();                                          //001C0BA4
  CFTTVector32 GenerateRandomTetra();                                    //001C0BAC
  void SetTriangleBuffer(TFTTTriangle *, uchar);                 //001C0D00
  void GenerateTriangles();                                      //001C0D10
  void ProjectTriangles(CFTTVector32);                           //001C107C
  float GetArea(bool);                                            //001C11EC
  CFTTVector32 GenerateRandomTri(CFTTVector32);                  //001C122C
  int GetSplitType(CFTTPlane32 const &);                         //001C13F8
  void FlipDistances();                                          //001C148C
  void Clip();                                                   //001C14B0
  void Clone(CFTTConvex const &);                                //001C14CE
  void ProcessVertices();                                        //001C154C
  void ProcessEdges();                                           //001C15BC
  void ProcessFaces();                                           //001C16D8
  void Cleanup();                                                //001C17FC
  bool GetOpenPolyline(TFTTFace const &, uchar &, uchar &);      //001C1A28

  TFTTVertex *list_TFTTVertex_field_0;
  TFTTEdge *list_TFTTEdge_field_4;
  TFTTFace *list_TFTTFace_field_8;
  uchar field_C[0x30];   // Vertex index
  uchar field_3C[0x40];  // Edge index
  TFTTTetrahedron *list_TFTTTetrahedron_field_7C;
  TFTTTriangle *list_TFTTTriangle_field_80;
  uchar field_84;  //list_TFTTVertex_field_0 size
  uchar field_85;  //list_TFTTEdge_field_4 size
  uchar field_86;  //list_TFTTFace_field_8 size
  uchar field_87;  //list_TFTTTetrahedron_field_7C size
  uchar ucTrianleListCount_88;  //list_TFTTTriangle_field_80 size
  char field_89;
  char field_8A;
  char field_8B;
  float field_8C;
  float fTotalTrianglesArea_90;
};

#endif  //_CFTTCONVEX_H_