Ignore:
Timestamp:
Feb 5, 2013, 12:18:18 AM (7 years ago)
Author:
touky
Message:

easymesh : CSG operation is now handled with a safe enum.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/easymesh/easymesh.cpp

    r2318 r2350  
    208208}
    209209
    210 void EasyMesh::MeshCsg(int csg_operation)
     210void EasyMesh::MeshCsg(CSGUsage csg_operation)
    211211{
    212212    //A vertex dictionnary for vertices on the same spot.
     
    310310                    //Triangle Kill Test
    311311                    if (//csgu : CSGUnion() -> m0_Outside + m1_Outside
    312                         (csg_operation == CSG_UNION && tri_list[k].m1 == LEAF_BACK) ||
     312                        (csg_operation == CSGUsage::Union && tri_list[k].m1 == LEAF_BACK) ||
    313313                        //csgs : CSGSubstract() -> m0_Outside + m1_Inside-inverted
    314                         (csg_operation == CSG_SUBSTRACT &&
     314                        (csg_operation == CSGUsage::Substract &&
    315315                            ((mesh_id == 0 && tri_list[k].m1 == LEAF_BACK) ||
    316316                            (mesh_id == 1 && tri_list[k].m1 == LEAF_FRONT))) ||
     317                        //csgs : CSGSubstractLoss() -> m0_Outside
     318                        (csg_operation == CSGUsage::SubstractLoss &&
     319                            ((mesh_id == 0 && tri_list[k].m1 == LEAF_BACK) || mesh_id == 1)) ||
    317320                        //csga : CSGAnd() -> Inside + Inside
    318                         (csg_operation == CSG_AND && tri_list[k].m1 == LEAF_FRONT))
     321                        (csg_operation == CSGUsage::And && tri_list[k].m1 == LEAF_FRONT))
    319322                    {
    320323                        triangle_to_kill.Push(tri_idx);
     
    323326                    //Triangle Invert Test
    324327                    if (//csgs : CSGSubstract() -> m0_Outside + m1_Inside-inverted
    325                         (csg_operation == CSG_SUBSTRACT && mesh_id == 1 && tri_list[k].m1 == LEAF_BACK) ||
     328                        (csg_operation == CSGUsage::Substract && mesh_id == 1 && tri_list[k].m1 == LEAF_BACK) ||
    326329                        //csgx : CSGXor() -> Outside/Inside-inverted + Outside/Inside-inverted
    327                         (csg_operation == CSG_XOR && tri_list[k].m1 == LEAF_BACK))
     330                        (csg_operation == CSGUsage::Xor && tri_list[k].m1 == LEAF_BACK))
    328331                    {
    329332                        //a Xor means we will share vertices with the outside, so duplicate the vertices.
    330333                        //TODO : This operation disconnect all triangle, in some cases, not a good thing.
    331                         if (csg_operation == CSG_XOR)
     334                        if (csg_operation == CSGUsage::Xor)
    332335                        {
    333336                            for (int l = 0; l < 3; l++)
     
    571574void EasyMesh::AddVertex(vec3 const &coord)
    572575{
     576    //TODO : m_vert.Push(coord, vec3(0.f, 1.f, 0.f), m_color, ivec2(0), vec2(0));
    573577    m_vert.Push(coord, vec3(0.f, 1.f, 0.f), m_color);
    574578}
     
    576580void EasyMesh::AddDuplicateVertex(int i)
    577581{
    578     m_vert.Push(m_vert[i].m1, vec3(0.f, 1.f, 0.f), m_vert[i].m3);
     582    m_vert << m_vert[i];
    579583}
    580584
     
    770774
    771775    for (int i = 0; i < vlen; i++)
    772         m_vert << m_vert[m_cursors.Last().m1++];
     776        AddDuplicateVertex(m_cursors.Last().m1++);
    773777
    774778    for (int i = 0; i < tlen; i++)
Note: See TracChangeset for help on using the changeset viewer.