Changeset 2226


Ignore:
Timestamp:
Jan 17, 2013, 9:49:29 PM (10 years ago)
Author:
touky
Message:

Added CSG v0.001a : not optimized, too much operation makes it slow. triangle count is not optimized.
Useage : "...[.... csg*]" equals "current mesh -CSG- the mesh in the braces".
Keywords : CsgUnion<csgu>, CsgSubstract<csgs>, CsgAnd<csga>, CsgXor<csgx>
TODO : cleanup useless code.
TODO : Some bugs are still present, some face that disappear should not.
TODO : Correct epsilon useage (see geometry files).
TODO : Coplanar face are not handled -at all-.
TODO : Vertex count goes through the roof in case of a Xor.

Location:
trunk
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r2225 r2226  
    3131    \
    3232    easymesh/easymesh.cpp easymesh/easymesh.h \
     33    easymesh/csgbsp.cpp easymesh/csgbsp.h \
    3334    easymesh/shiny.lolfx \
    3435    easymesh/easymesh-compiler.cpp easymesh/easymesh-compiler.h \
  • trunk/src/core.h

    r2225 r2226  
    133133#include "image/image.h"
    134134#include "application/application.h"
     135#include "easymesh/csgbsp.h"
    135136#include "easymesh/easymesh.h"
    136137
  • trunk/src/easymesh/easymesh-compiler.cpp

    r2183 r2226  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    5 //            (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
    6 //            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
     4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     5//            (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
     6//            (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    77//   This program is free software; you can redistribute it and/or
    88//   modify it under the terms of the Do What The Fuck You Want To
  • trunk/src/easymesh/easymesh-compiler.h

    r2183 r2226  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    5 //            (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
    6 //            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
     4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     5//            (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
     6//            (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    77//   This program is free software; you can redistribute it and/or
    88//   modify it under the terms of the Do What The Fuck You Want To
  • trunk/src/easymesh/easymesh-parser.y

    r2183 r2226  
    33// Lol Engine
    44//
    5 // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    6 //            (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
    7 //            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
     5// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     6//            (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
     7//            (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    88//   This program is free software; you can redistribute it and/or
    99//   modify it under the terms of the Do What The Fuck You Want To
     
    4949%token T_TRANSLATEZ T_ROTATEZ T_TAPERZ T_SCALEZ T_MIRRORZ
    5050%token T_TRANSLATE T_SCALE T_TOGGLESCALEWINDING
     51%token T_CSGUNION T_CSGSUBSTRACT T_CSGAND T_CSGXOR
    5152%token T_CHAMFER
    5253
     
    117118
    118119transform_command:
    119     T_CHAMFER args1     { mc.m_mesh.Chamfer($2.f0); }
    120   | T_TRANSLATEX args1  { mc.m_mesh.Translate(vec3($2.f0, 0, 0)); }
    121   | T_TRANSLATEY args1  { mc.m_mesh.Translate(vec3(0, $2.f0, 0)); }
    122   | T_TRANSLATEZ args1  { mc.m_mesh.Translate(vec3(0, 0, $2.f0)); }
    123   | T_TRANSLATE args3   { mc.m_mesh.Translate(vec3($2.f0, $2.f1, $2.f2)); }
    124   | T_ROTATEX args1     { mc.m_mesh.RotateX($2.f0); }
    125   | T_ROTATEY args1     { mc.m_mesh.RotateY($2.f0); }
    126   | T_ROTATEZ args1     { mc.m_mesh.RotateZ($2.f0); }
    127   | T_TAPERX args3      { mc.m_mesh.TaperX($2.f0, $2.f1, $2.f2); }
    128   | T_TAPERY args3      { mc.m_mesh.TaperY($2.f0, $2.f1, $2.f2); }
    129   | T_TAPERZ args3      { mc.m_mesh.TaperZ($2.f0, $2.f1, $2.f2); }
    130   | T_SCALEX args1      { mc.m_mesh.Scale(vec3($2.f0, 1.0, 1.0)); }
    131   | T_SCALEY args1      { mc.m_mesh.Scale(vec3(1.0, $2.f0, 1.0)); }
    132   | T_SCALEZ args1      { mc.m_mesh.Scale(vec3(1.0, 1.0, $2.f0)); }
    133   | T_SCALE args3       { mc.m_mesh.Scale(vec3($2.f0, $2.f1, $2.f2)); }
    134   | T_MIRRORX           { mc.m_mesh.MirrorX(); }
    135   | T_MIRRORY           { mc.m_mesh.MirrorY(); }
    136   | T_MIRRORZ           { mc.m_mesh.MirrorZ(); }
    137   | T_TOGGLESCALEWINDING { mc.m_mesh.ToggleScaleWinding(); }
     120    T_CHAMFER args1        { mc.m_mesh.Chamfer($2.f0); }
     121  | T_TRANSLATEX args1     { mc.m_mesh.Translate(vec3($2.f0, 0, 0)); }
     122  | T_TRANSLATEY args1     { mc.m_mesh.Translate(vec3(0, $2.f0, 0)); }
     123  | T_TRANSLATEZ args1     { mc.m_mesh.Translate(vec3(0, 0, $2.f0)); }
     124  | T_TRANSLATE args3      { mc.m_mesh.Translate(vec3($2.f0, $2.f1, $2.f2)); }
     125  | T_ROTATEX args1        { mc.m_mesh.RotateX($2.f0); }
     126  | T_ROTATEY args1        { mc.m_mesh.RotateY($2.f0); }
     127  | T_ROTATEZ args1        { mc.m_mesh.RotateZ($2.f0); }
     128  | T_TAPERX args3         { mc.m_mesh.TaperX($2.f0, $2.f1, $2.f2); }
     129  | T_TAPERY args3         { mc.m_mesh.TaperY($2.f0, $2.f1, $2.f2); }
     130  | T_TAPERZ args3         { mc.m_mesh.TaperZ($2.f0, $2.f1, $2.f2); }
     131  | T_SCALEX args1         { mc.m_mesh.Scale(vec3($2.f0, 1.0, 1.0)); }
     132  | T_SCALEY args1         { mc.m_mesh.Scale(vec3(1.0, $2.f0, 1.0)); }
     133  | T_SCALEZ args1         { mc.m_mesh.Scale(vec3(1.0, 1.0, $2.f0)); }
     134  | T_SCALE args3          { mc.m_mesh.Scale(vec3($2.f0, $2.f1, $2.f2)); }
     135  | T_MIRRORX              { mc.m_mesh.MirrorX(); }
     136  | T_MIRRORY              { mc.m_mesh.MirrorY(); }
     137  | T_MIRRORZ              { mc.m_mesh.MirrorZ(); }
     138  | T_TOGGLESCALEWINDING   { mc.m_mesh.ToggleScaleWinding(); }
     139  | T_CSGUNION             { mc.m_mesh.CsgUnion(); }
     140  | T_CSGSUBSTRACT         { mc.m_mesh.CsgSubstract(); }
     141  | T_CSGAND               { mc.m_mesh.CsgAnd(); }
     142  | T_CSGXOR               { mc.m_mesh.CsgXor(); }
    138143    ;
    139144
  • trunk/src/easymesh/easymesh-scanner.l

    r2183 r2226  
    33// Lol Engine
    44//
    5 // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    6 //            (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
    7 //            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
     5// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     6//            (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
     7//            (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    88//   This program is free software; you can redistribute it and/or
    99//   modify it under the terms of the Do What The Fuck You Want To
     
    7171my    { return token::T_MIRRORY; }
    7272mz    { return token::T_MIRRORZ; }
     73
     74csgu  { return token::T_CSGUNION; }
     75csgs  { return token::T_CSGSUBSTRACT; }
     76csga  { return token::T_CSGAND; }
     77csgx  { return token::T_CSGXOR; }
    7378
    7479ab    { return token::T_BOX; }
  • trunk/src/easymesh/easymesh.cpp

    r2211 r2226  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    5 //            (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
    6 //            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
     4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     5//            (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
     6//            (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    77//   This program is free software; you can redistribute it and/or
    88//   modify it under the terms of the Do What The Fuck You Want To
     
    7676    m_gpu.modelview = m_gpu.shader->GetUniformLocation("in_ModelView");
    7777    m_gpu.view = m_gpu.shader->GetUniformLocation("in_View");
    78         m_gpu.invview = m_gpu.shader->GetUniformLocation("in_Inv_View");
     78    m_gpu.invview = m_gpu.shader->GetUniformLocation("in_Inv_View");
    7979    m_gpu.proj = m_gpu.shader->GetUniformLocation("in_Proj");
    8080    m_gpu.normalmat = m_gpu.shader->GetUniformLocation("in_NormalMat");
     
    142142}
    143143
     144
     145//-------------------
     146// "Collisions" functions
     147//-------------------
     148#define VX_ALONE -2
     149#define VX_MASTER -1
     150
     151//helpers func to retrieve a vertex.
     152int FindVertexInDict(int search_idx, Array< int, int > const &vertex_dict)
     153{
     154    //Resolve current vertex idx in the dictionnary (if exist)
     155    for (int j = 0; j < vertex_dict.Count(); j++)
     156        if (vertex_dict[j].m1 == search_idx)
     157            return j;
     158    return -1;
     159}
     160
     161//helpers func to retrieve a triangle.
     162int FindTriangleInDict(int search_idx, Array< int, Array< vec3, vec3, vec3 > > const &triangle_isec)
     163{
     164    //Resolve current vertex idx in the dictionnary (if exist)
     165    for (int j = 0; j < triangle_isec.Count(); j++)
     166        if (triangle_isec[j].m1 == search_idx)
     167            return j;
     168    return -1;
     169}
     170
     171//Will update the given list with all the vertices on the same spot.
     172void EasyMesh::UpdateVertexDict(Array< int, int > &vertex_dict)
     173{
     174    //First, build the vertex Dictionnary
     175    for (int i = 0; i < m_vert.Count(); i++)
     176    {
     177        int CurIdx = FindVertexInDict(i, vertex_dict);
     178       
     179        //go through all vertices and do the match-up.
     180        if (CurIdx == -1)
     181        {
     182            for (int j = i + 1; j < m_vert.Count(); j++)
     183            {
     184                if (sqlength(m_vert[i].m1 - m_vert[j].m1) < CSG_EPSILON)
     185                {
     186                    if (CurIdx == -1)
     187                    {
     188                        CurIdx = vertex_dict.Count();
     189                        vertex_dict.Push(i, VX_MASTER);
     190                    }
     191                    vertex_dict.Push(j, CurIdx);
     192                }
     193            }
     194        }
     195    }
     196}
     197
     198void EasyMesh::MeshCsg(int csg_operation)
     199{
     200    //A vertex dictionnary for vertices on the same spot.
     201    Array< int, int > vertex_dict;
     202    //This list keeps track of the triangle that will need deletion at the end.
     203    Array< int > triangle_to_kill;
     204    //Listing for each triangle of the vectors intersecting it. <tri_Id, <Point0, Point1, tri_isec_Normal>>
     205    Array< int, Array< vec3, vec3, vec3 > > triangle_isec;
     206    //keep a track of the intersection point on the triangle. <pos, side_id>
     207    Array< vec3, int > triangle_vertex;
     208    for (int k = 0; k < 10; k++)
     209        triangle_vertex.Push(vec3(.0f), 0);
     210
     211    //bsp infos
     212    CsgBsp mesh_bsp_0;
     213    CsgBsp mesh_bsp_1;
     214
     215    //BSP BUILD : We use the brace logic, csg should be used as : "[ exp .... [exp .... csg]]"
     216    int cursor_start = (m_cursors.Count() < 2)?(0):(m_cursors[(m_cursors.Count() - 2)].m2);
     217    for (int mesh_id = 0; mesh_id < 2; mesh_id++)
     218    {
     219        int start_point     = (mesh_id == 0)?(cursor_start):(m_cursors.Last().m2);
     220        int end_point       = (mesh_id == 0)?(m_cursors.Last().m2):(m_indices.Count());
     221        CsgBsp &mesh_bsp  = (mesh_id == 0)?(mesh_bsp_0):(mesh_bsp_1);
     222        for (int i = start_point; i < end_point; i += 3)
     223            mesh_bsp.AddTriangleToTree(i, m_vert[m_indices[i]].m1, m_vert[m_indices[i + 1]].m1, m_vert[m_indices[i + 2]].m1);
     224    }
     225
     226    //BSP Useage : let's crunch all triangles on the correct BSP
     227    int indices_count = m_indices.Count();
     228    for (int mesh_id = 0; mesh_id < 2; mesh_id++)
     229    {
     230        int start_point     = (mesh_id == 0)?(cursor_start):(m_cursors.Last().m2);
     231        int end_point       = (mesh_id == 0)?(m_cursors.Last().m2):(indices_count);
     232        CsgBsp &mesh_bsp  = (mesh_id == 0)?(mesh_bsp_1):(mesh_bsp_0);
     233        Array< vec3, int, int, float > vert_list;
     234        Array< int, int, int, int > tri_list;
     235        vec3 n0(.0f); vec3 n1(.0f);
     236        vec4 c0(.0f); vec4 c1(.0f);
     237
     238        //Reserve some memory
     239        vert_list.Reserve(3);
     240        tri_list.Reserve(3);
     241
     242        for (int i = start_point; i < end_point; i += 3)
     243        {
     244            int Result = mesh_bsp.TestTriangleToTree(m_vert[m_indices[i]].m1, m_vert[m_indices[i + 1]].m1, m_vert[m_indices[i + 2]].m1, vert_list, tri_list);
     245            int tri_base_idx = m_indices.Count();
     246
     247            //one split has been done, we need to had the new vertices & the new triangles.
     248            if (Result == 1)
     249            {
     250                triangle_to_kill.Push(i);
     251#if 1
     252                int base_idx = m_vert.Count();
     253                for (int k = 3; k < vert_list.Count(); k++)
     254                {
     255                    int P0 = (vert_list[k].m2 < 3)?(m_indices[i + vert_list[k].m2]):(base_idx + vert_list[k].m2 - 3);
     256                    int P1 = (vert_list[k].m3 < 3)?(m_indices[i + vert_list[k].m3]):(base_idx + vert_list[k].m3 - 3);
     257
     258                    AddVertex(vert_list[k].m1);
     259
     260                    //Normal : bad calculations there.
     261                    n0 = m_vert[P0].m2;
     262                    n1 = m_vert[P1].m2;
     263                    SetCurVertNormal(normalize(n0 + (n1 - n0) * vert_list[k].m4));
     264
     265#if 1
     266                    //Color
     267                    c0 = m_vert[P0].m3;
     268                    c1 = m_vert[P1].m3;
     269                    vec4 res = c0 + ((c1 - c0) * vert_list[k].m4);
     270                    SetCurVertColor(res);
     271#else
     272                    if (mesh_id == 0)
     273                        SetCurVertColor(vec4(1.0f, .0f, .0f, 1.0f));
     274                    else
     275                        SetCurVertColor(vec4(.0f, 1.0f, 1.0f, 1.0f));
     276#endif
     277                }
     278                for (int k = 0; k < tri_list.Count(); k++)
     279                {
     280                    int P0 = (tri_list[k].m2 < 3)?(m_indices[i + tri_list[k].m2]):(base_idx + (tri_list[k].m2 - 3));
     281                    int P1 = (tri_list[k].m3 < 3)?(m_indices[i + tri_list[k].m3]):(base_idx + (tri_list[k].m3 - 3));
     282                    int P2 = (tri_list[k].m4 < 3)?(m_indices[i + tri_list[k].m4]):(base_idx + (tri_list[k].m4 - 3));
     283                    AppendTriangle(P0, P1, P2, 0);
     284                }
     285#endif
     286            }
     287#if 1
     288            //Main case
     289            if (Result >= 0)
     290            {
     291                for (int k = 0; k < tri_list.Count(); k++)
     292                {
     293                    int tri_idx = ((tri_list.Count() == 1)?(i):(tri_base_idx + k * 3));
     294
     295                    //Triangle Kill Test
     296                    if (//csgu : CSGUnion() -> m0_Outside + m1_Outside
     297                        (csg_operation == CSG_UNION && tri_list[k].m1 == LEAF_BACK) ||
     298                        //csgs : CSGSubstract() -> m0_Outside + m1_Inside-inverted
     299                        (csg_operation == CSG_SUBSTRACT &&
     300                            ((mesh_id == 0 && tri_list[k].m1 == LEAF_BACK) ||
     301                            (mesh_id == 1 && tri_list[k].m1 == LEAF_FRONT))) ||
     302                        //csga : CSGAnd() -> Inside + Inside
     303                        (csg_operation == CSG_AND && tri_list[k].m1 == LEAF_FRONT))
     304                    {
     305                        triangle_to_kill.Push(tri_idx);
     306                    }
     307
     308                    //Triangle Invert Test
     309                    if (//csgs : CSGSubstract() -> m0_Outside + m1_Inside-inverted
     310                        (csg_operation == CSG_SUBSTRACT && mesh_id == 1 && tri_list[k].m1 == LEAF_BACK) ||
     311                        //csgx : CSGXor() -> Outside/Inside-inverted + Outside/Inside-inverted
     312                        (csg_operation == CSG_XOR && tri_list[k].m1 == LEAF_BACK))
     313                    {
     314                        //a Xor means we will share vertices with the outside, so duplicate the vertices.
     315                        //TODO : This operation disconnect all triangle, in some cases, not a good thing.
     316                        if (csg_operation == CSG_XOR)
     317                        {
     318                            for (int l = 0; l < 3; l++)
     319                            {
     320                                AddDuplicateVertex(m_indices[tri_idx + l]);
     321                                m_indices[tri_idx + l] = m_vert.Count() - 1;
     322                            }
     323                        }
     324                        m_indices[tri_idx + 1] += m_indices[tri_idx + 2];
     325                        m_indices[tri_idx + 2]  = m_indices[tri_idx + 1] - m_indices[tri_idx + 2];
     326                        m_indices[tri_idx + 1]  = m_indices[tri_idx + 1] - m_indices[tri_idx + 2];
     327                        ComputeNormals(tri_idx, 3);
     328                    }
     329                }
     330            }
     331#endif
     332            vert_list.Empty();
     333            tri_list.Empty();
     334        }
     335    }
     336
     337    for (int i = 0; i < m_vert.Count(); i++)
     338        if (length(m_vert[i].m2) < 1.0f)
     339            i = i;
     340
     341    int dir = 1;
     342    for (int i = 0; i >= 0 && i < triangle_to_kill.Count() - 1; i += dir)
     343    {
     344        if (triangle_to_kill[i] < triangle_to_kill[i + 1] && dir < 0)
     345            dir = 1;
     346        if (triangle_to_kill[i] == triangle_to_kill[i + 1])
     347        {
     348            triangle_to_kill.Remove(i);
     349            dir = -1;
     350        }
     351        if (triangle_to_kill[i] > triangle_to_kill[i + 1])
     352        {
     353            triangle_to_kill[i]     += triangle_to_kill[i + 1];
     354            triangle_to_kill[i + 1]  = triangle_to_kill[i] - triangle_to_kill[i + 1];
     355            triangle_to_kill[i]      = triangle_to_kill[i] - triangle_to_kill[i + 1];
     356            dir = -1;
     357        }
     358        if (i == 0 && dir == -1)
     359            dir = 1;
     360    }
     361    for (int i = triangle_to_kill.Count() - 1; i >= 0; i--)
     362        m_indices.Remove(triangle_to_kill[i], 3);
     363
     364    m_cursors.Last().m1 = m_vert.Count();
     365    m_cursors.Last().m2 = m_indices.Count();
     366
     367#if 0
     368    UpdateVertexDict(vertex_dict);
     369
     370    for (int t0 = 0; t0 < m_indices.Count(); t0 += 3)
     371    {
     372        for (int t1 = t0 + 3; t1 < m_indices.Count(); t1 += 3)
     373        {
     374            int CommonVertices = 0;
     375            //Search for common vertices, if > 1 the two triangle share a side, so no split is required.
     376            for (int k = 0; k < 3; k++)
     377            {
     378                int ref_master = FindVertexInDict(m_indices[t0 + k], vertex_dict);
     379                if (ref_master != -1)
     380                {
     381                    if (vertex_dict[ref_master].m2 != VX_MASTER)
     382                        ref_master = vertex_dict[ref_master].m2;
     383                    for (int l = 0; l < 3; l++)
     384                    {
     385                        int test_master = FindVertexInDict(m_indices[t1 + l], vertex_dict);
     386                        if (test_master != -1)
     387                        {
     388                            if (vertex_dict[test_master].m2 != VX_MASTER)
     389                                test_master = vertex_dict[test_master].m2;
     390                            if (test_master == ref_master)
     391                            {
     392                                CommonVertices++;
     393                                break;
     394                            }
     395                        }
     396                    }
     397                }
     398            }
     399
     400            if (CommonVertices < 2)
     401            {
     402                vec3 iP0, iP1;
     403                //Build the triangle intersection list
     404                if (TriangleIsectTriangle(m_vert[m_indices[t0]].m1, m_vert[m_indices[t0 + 1]].m1, m_vert[m_indices[t0 + 2]].m1,
     405                                          m_vert[m_indices[t1]].m1, m_vert[m_indices[t1 + 1]].m1, m_vert[m_indices[t1 + 2]].m1,
     406                                          iP0, iP1))
     407                {
     408                    int CurIdx = FindTriangleInDict(t0, triangle_isec);
     409                    if (CurIdx == -1)
     410                    {
     411                        CurIdx = triangle_isec.Count();
     412                        triangle_isec.Push(t0, Array<vec3, vec3, vec3>());
     413                    }
     414                    triangle_isec[CurIdx].m2.Push(iP0, iP1, vec3(.0f));
     415                    CurIdx = FindTriangleInDict(t1, triangle_isec);
     416                    if (CurIdx == -1)
     417                    {
     418                        CurIdx = triangle_isec.Count();
     419                        triangle_isec.Push(t1, Array<vec3, vec3, vec3>());
     420                    }
     421                    triangle_isec[CurIdx].m2.Push(iP0, iP1, vec3(.0f));
     422                }
     423            }
     424        }
     425    }
     426
     427    /* seems to be counter-productive in some rare cases. */
     428    /*
     429    //Every intersection has been found, let's remove those that exist twice.
     430    for(int i = 0; i < triangle_isec.Count(); i++)
     431    {
     432        for(int j = 0; j < triangle_isec[i].m2.Count(); j++)
     433        {
     434            for(int k = j + 1; k < triangle_isec[i].m2.Count(); k++)
     435            {
     436                //if the two Dir-vector are parallel & the fist Dir-vector is parallel to the (P0, P1)-vector, this is the same intersection, so kill it.
     437                if (abs(dot(normalize(triangle_isec[i].m2[j].m2 - triangle_isec[i].m2[j].m1),
     438                            normalize(triangle_isec[i].m2[k].m2 - triangle_isec[i].m2[k].m1)))
     439                        >= 1.0 &&
     440                    abs(dot(normalize(triangle_isec[i].m2[j].m2 - triangle_isec[i].m2[j].m1),
     441                            normalize(triangle_isec[i].m2[k].m1 - triangle_isec[i].m2[j].m1)))
     442                        >= 1.0 )
     443                    triangle_isec[i].m2.Remove(k--);
     444            }
     445        }
     446    }
     447    */
     448
     449    //Now, the triangle intersection tab should be nice and cosy, so we can start actually cutting some triangles.
     450    vec3 isecV[2] = { vec3(.0f), vec3(.0f) };
     451    int isecI[2] = { -1, -1 };
     452    int v_idx0 = 0; int v_idx1 = 0;
     453    int new_v_idx[2] = { 0, 0 };
     454    vec3 n0(.0f); vec3 n1(.0f);
     455    vec4 c0(.0f); vec4 c1(.0f);
     456    for(int i = 0; i < triangle_isec.Count(); i++)
     457    {
     458        int tri_idx = triangle_isec[i].m1;
     459        for(int j = 0; j < triangle_isec[i].m2.Count(); j++)
     460        {
     461            //Get intersection on actual triangle sides.
     462            if (RayIsectTriangleSide(m_vert[m_indices[tri_idx]].m1, m_vert[m_indices[tri_idx + 1]].m1, m_vert[m_indices[tri_idx + 2]].m1,
     463                                     triangle_isec[i].m2[j].m1, triangle_isec[i].m2[j].m2,
     464                                     isecV[0], isecI[0], isecV[1], isecI[1]))
     465            {
     466                //Check if the found intersections point are in the triangle. If not, ignore.
     467                //Cases are :
     468                //  1) at least one dot is negative (one point in the triangle).
     469                //  2) the two dot are positive but the intersection point are on all parts of the triangle, and therefore negative.
     470                //If one of the point is on one side, some calculations tweak are needed.
     471                //If the two points are on the triangle sides, just go with it.
     472                bool should_proceed_with_cutting = true;
     473                //find out if points are on one of the side
     474                int p0_tri_idx = ((sqlength(triangle_isec[i].m2[j].m1 - isecV[0]) < CSG_EPSILON)?(0):(
     475                                    (sqlength(triangle_isec[i].m2[j].m1 - isecV[1]) < CSG_EPSILON)?(1):(-1)));
     476                int p1_tri_idx = ((sqlength(triangle_isec[i].m2[j].m2 - isecV[0]) < CSG_EPSILON)?(0):(
     477                                    (sqlength(triangle_isec[i].m2[j].m2 - isecV[1]) < CSG_EPSILON)?(1):(-1)));
     478                if (p0_tri_idx < 0 || p1_tri_idx < 0)
     479                {
     480                    float dot0 = (p0_tri_idx >= 0)?(1.0f):(dot(triangle_isec[i].m2[j].m1 - isecV[0],
     481                                                               triangle_isec[i].m2[j].m1 - isecV[1]));
     482                    float dot1 = (p1_tri_idx >= 0)?(1.0f):(dot(triangle_isec[i].m2[j].m2 - isecV[0],
     483                                                               triangle_isec[i].m2[j].m2 - isecV[1]));
     484                    float dot2 = dot(triangle_isec[i].m2[j].m1 - isecV[(p0_tri_idx == -1)?(0):(1 - p0_tri_idx)],
     485                                     triangle_isec[i].m2[j].m2 - isecV[(p1_tri_idx == -1)?(0):(1 - p1_tri_idx)]);
     486                    should_proceed_with_cutting = (((dot0 < .0f) || dot1 < .0f) || (dot0 > .0f && dot1 > .0f && dot2 < .0f));
     487                }
     488                if (should_proceed_with_cutting)
     489                {
     490                    //Add the new vertices
     491                    int b_idx = 0;
     492                    for(int k = 0; k < 2; k++)
     493                    {
     494                        if (b_idx == isecI[k])
     495                            b_idx++;
     496
     497                        new_v_idx[k] = m_vert.Count();
     498                        AddVertex(isecV[k]);
     499                        //bad calculations of normal there.
     500                        n0 = m_vert[m_indices[tri_idx + isecI[k]]].m2;
     501                        n1 = m_vert[m_indices[tri_idx + (isecI[k] + 1) % 3]].m2;
     502                        SetCurVertNormal(normalize((n0 + n1) * .5f));
     503                        //color
     504#if 0
     505                        c0 = m_vert[m_indices[tri_idx + isecI[k]]].m3;
     506                        c1 = m_vert[m_indices[tri_idx + (isecI[k] + 1) % 3]].m3;
     507                        SetCurVertColor((c0 + c1) * .5f);
     508#else
     509                        SetCurVertColor(vec4(1.0f, 0.0f, 0.0f, 1.0f));
     510#endif
     511                    }
     512
     513                    //small trick, b_idx is the side index that has no intersection.
     514                    v_idx0 = (b_idx == 1)?(1):(0);
     515                    v_idx1 = (b_idx == 1)?(0):(1);
     516
     517                    //Add the new triangles
     518                    AppendTriangle(m_indices[tri_idx + b_idx],              new_v_idx[v_idx0], new_v_idx[v_idx1], 0);
     519                    AppendTriangle(m_indices[tri_idx + ((b_idx + 2) % 3)],  new_v_idx[v_idx1], new_v_idx[v_idx0], 0);
     520                    //Replace the current triangle by on of the new one, instead of erasing it.
     521                    m_indices[tri_idx + ((b_idx + 2) % 3)] = new_v_idx[v_idx0];
     522
     523                    if (j + 1 < triangle_isec[i].m2.Count())
     524                    {
     525                        triangle_isec[i].m2.Remove(j--);
     526                        //add the two new triangle to the checklist.
     527                        triangle_isec.Push(m_indices.Count() - 6, triangle_isec[i].m2);
     528                        triangle_isec.Push(m_indices.Count() - 3, triangle_isec[i].m2);
     529                    }
     530                }
     531            }
     532        }
     533    }
     534#endif
     535    //DONE for the splitting !
     536}
     537
     538
     539//-------------------
     540
    144541void EasyMesh::ToggleScaleWinding()
    145542{
     
    435832     * is a vertex at [0 1 0] and [0 -1 0] after normalisation. */
    436833    float phi = 0.5f + 0.5f * sqrt(5.f);
    437     mat3 mat = mat3::rotate(asin(1.f / sqrt(2.f + phi)) * (180.f / M_PI),
     834    mat3 mat = mat3::rotate(asin(1.f / sqrt(2.f + phi)) * (180.f / (float)M_PI),
    438835                            vec3(0.f, 0.f, 1.f));
    439836    for (int i = 0; i < 4; i++)
     
    539936            int i2 = (i + di) % nidiv;
    540937            int j2 = (j + dj) % njdiv;
    541             float x = 0.5f * (r1 + r2) + 0.5 * (r2 - r1) * lol::cos(2.0 * M_PI * i2 / nidiv);
    542             float y = 0.5f * (r2 - r1) * lol::sin(2.0 * M_PI * i2 / nidiv);
     938            float x = 0.5f * (r1 + r2) + 0.5f * (r2 - r1) * (float)lol::cos(2.0 * M_PI * i2 / nidiv);
     939            float y = 0.5f * (r2 - r1) * (float)lol::sin(2.0 * M_PI * i2 / nidiv);
    543940            float z = 0.0f;
    544941
    545             float ca = lol::cos(2.0 * M_PI * j2 / njdiv);
    546             float sa = lol::sin(2.0 * M_PI * j2 / njdiv);
     942            float ca = (float)lol::cos(2.0 * M_PI * j2 / njdiv);
     943            float sa = (float)lol::sin(2.0 * M_PI * j2 / njdiv);
    547944            float x2 = x * ca - z * sa;
    548945            float z2 = z * ca + x * sa;
  • trunk/src/easymesh/easymesh.h

    r2209 r2226  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    5 //            (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
    6 //            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
     4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     5//            (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
     6//            (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    77//   This program is free software; you can redistribute it and/or
    88//   modify it under the terms of the Do What The Fuck You Want To
     
    3333    void Render(mat4 const &model, float damage = 0.f);
    3434
     35private:
     36    void UpdateVertexDict(Array< int, int > &vertex_dict);
     37//DEBUG
     38public:
     39#define CSG_UNION       0
     40#define CSG_SUBSTRACT   1
     41#define CSG_AND         2
     42#define CSG_XOR         3
     43
     44    void MeshCsg(int csg_operation);
     45    void CsgUnion()     { MeshCsg(CSG_UNION); }
     46    void CsgSubstract() { MeshCsg(CSG_SUBSTRACT); }
     47    void CsgAnd()       { MeshCsg(CSG_AND); }
     48    void CsgXor()       { MeshCsg(CSG_XOR); }
     49
     50public:
    3551    void OpenBrace();
    3652    void CloseBrace();
    3753
    38         void ToggleScaleWinding();
     54    void ToggleScaleWinding();
    3955    void SetCurColor(vec4 const &color);
    4056    void SetCurColor2(vec4 const &color);
     
    93109    vec4 m_color, m_color2;
    94110    Array<uint16_t> m_indices;
     111    //<coord, norm, color>
    95112    Array<vec3, vec3, vec4> m_vert;
     113    //<vert count, indices count>
    96114    Array<int, int> m_cursors;
    97         bool m_ignore_winding_on_scale;
     115    bool m_ignore_winding_on_scale;
    98116
    99117    /* FIXME: put this in a separate class so that we can copy meshes. */
  • trunk/src/easymesh/shiny.lolfx

    r2149 r2226  
    6666    /* World properties */
    6767    float ambient_mul = 0.5;
    68     vec3 ambient_color = vec3(0.0, 0.0, 0.0);
     68    vec3 ambient_color = vec3(0.5, 0.5, 0.5);
    6969    vec3 diffuse_color = vec3(0.4, 0.4, 0.4);
    7070    vec3 specular_color = vec3(1.0, 1.0, 0.6);
  • trunk/src/generated/easymesh-parser.cpp

    r2183 r2226  
    1 /* A Bison parser, made by GNU Bison 2.5.  */
     1/* A Bison parser, made by GNU Bison 2.4.2.  */
    22
    33/* Skeleton implementation for Bison LALR(1) parsers in C++
    44   
    5       Copyright (C) 2002-2011 Free Software Foundation, Inc.
     5      Copyright (C) 2002-2010 Free Software Foundation, Inc.
    66   
    77   This program is free software: you can redistribute it and/or modify
     
    3636/* First part of user declarations.  */
    3737
    38 /* Line 293 of lalr1.cc  */
     38/* Line 310 of lalr1.cc  */
    3939#line 1 "easymesh/easymesh-parser.y"
    4040
     
    4242// Lol Engine
    4343//
    44 // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    45 //            (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
    46 //            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
     44// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     45//            (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
     46//            (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    4747//   This program is free software; you can redistribute it and/or
    4848//   modify it under the terms of the Do What The Fuck You Want To
     
    6262
    6363
    64 /* Line 293 of lalr1.cc  */
     64/* Line 310 of lalr1.cc  */
    6565#line 66 "generated/easymesh-parser.cpp"
    6666
     
    7070/* User implementation prologue.  */
    7171
    72 /* Line 299 of lalr1.cc  */
    73 #line 65 "easymesh/easymesh-parser.y"
     72/* Line 316 of lalr1.cc  */
     73#line 66 "easymesh/easymesh-parser.y"
    7474
    7575#include "easymesh/easymesh-compiler.h"
     
    7979
    8080
    81 /* Line 299 of lalr1.cc  */
     81/* Line 316 of lalr1.cc  */
    8282#line 83 "generated/easymesh-parser.cpp"
    8383
     
    9494#endif
    9595
    96 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
    97    If N is 0, then set CURRENT to the empty location which ends
    98    the previous symbol: RHS[0] (always defined).  */
    99 
    100 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
    101 #ifndef YYLLOC_DEFAULT
    102 # define YYLLOC_DEFAULT(Current, Rhs, N)                               \
    103  do                                                                    \
    104    if (N)                                                              \
    105      {                                                                 \
    106        (Current).begin = YYRHSLOC (Rhs, 1).begin;                      \
    107        (Current).end   = YYRHSLOC (Rhs, N).end;                        \
    108      }                                                                 \
    109    else                                                                \
    110      {                                                                 \
    111        (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;        \
    112      }                                                                 \
    113  while (false)
    114 #endif
    115 
    11696/* Suppress unused-variable warnings by "using" E.  */
    11797#define YYUSE(e) ((void) (e))
     
    165145namespace lol {
    166146
    167 /* Line 382 of lalr1.cc  */
    168 #line 169 "generated/easymesh-parser.cpp"
     147/* Line 379 of lalr1.cc  */
     148#line 149 "generated/easymesh-parser.cpp"
     149#if YYERROR_VERBOSE
    169150
    170151  /* Return YYSTR after stripping away unnecessary quotes and
     
    205186  }
    206187
     188#endif
    207189
    208190  /// Build a parser object.
     
    305287#endif
    306288
    307   inline bool
    308   EasyMeshParser::yy_pact_value_is_default_ (int yyvalue)
    309   {
    310     return yyvalue == yypact_ninf_;
    311   }
    312 
    313   inline bool
    314   EasyMeshParser::yy_table_value_is_error_ (int yyvalue)
    315   {
    316     return yyvalue == yytable_ninf_;
    317   }
    318 
    319289  int
    320290  EasyMeshParser::parse ()
     
    338308    location_type yylloc;
    339309    /// The locations where the error started and ended.
    340     location_type yyerror_range[3];
     310    location_type yyerror_range[2];
    341311
    342312    /// $$.
     
    376346    /* Try to take a decision without lookahead.  */
    377347    yyn = yypact_[yystate];
    378     if (yy_pact_value_is_default_ (yyn))
     348    if (yyn == yypact_ninf_)
    379349      goto yydefault;
    380350
     
    409379    if (yyn <= 0)
    410380      {
    411         if (yy_table_value_is_error_ (yyn))
    412           goto yyerrlab;
     381        if (yyn == 0 || yyn == yytable_ninf_)
     382        goto yyerrlab;
    413383        yyn = -yyn;
    414384        goto yyreduce;
     
    466436          case 7:
    467437
    468 /* Line 690 of lalr1.cc  */
    469 #line 89 "easymesh/easymesh-parser.y"
     438/* Line 677 of lalr1.cc  */
     439#line 90 "easymesh/easymesh-parser.y"
    470440    { mc.m_mesh.OpenBrace(); }
    471441    break;
     
    473443  case 8:
    474444
    475 /* Line 690 of lalr1.cc  */
    476 #line 93 "easymesh/easymesh-parser.y"
     445/* Line 677 of lalr1.cc  */
     446#line 94 "easymesh/easymesh-parser.y"
    477447    { mc.m_mesh.CloseBrace(); }
    478448    break;
     
    480450  case 14:
    481451
    482 /* Line 690 of lalr1.cc  */
    483 #line 108 "easymesh/easymesh-parser.y"
     452/* Line 677 of lalr1.cc  */
     453#line 109 "easymesh/easymesh-parser.y"
    484454    { mc.m_mesh.SetCurColor(vec4((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); }
    485455    break;
     
    487457  case 15:
    488458
    489 /* Line 690 of lalr1.cc  */
    490 #line 109 "easymesh/easymesh-parser.y"
     459/* Line 677 of lalr1.cc  */
     460#line 110 "easymesh/easymesh-parser.y"
    491461    { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
    492462                      vec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
     
    496466  case 16:
    497467
    498 /* Line 690 of lalr1.cc  */
    499 #line 112 "easymesh/easymesh-parser.y"
     468/* Line 677 of lalr1.cc  */
     469#line 113 "easymesh/easymesh-parser.y"
    500470    { mc.m_mesh.SetCurColor2(vec4((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); }
    501471    break;
     
    503473  case 17:
    504474
    505 /* Line 690 of lalr1.cc  */
    506 #line 113 "easymesh/easymesh-parser.y"
     475/* Line 677 of lalr1.cc  */
     476#line 114 "easymesh/easymesh-parser.y"
    507477    { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
    508478                      vec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
     
    512482  case 18:
    513483
    514 /* Line 690 of lalr1.cc  */
    515 #line 119 "easymesh/easymesh-parser.y"
     484/* Line 677 of lalr1.cc  */
     485#line 120 "easymesh/easymesh-parser.y"
    516486    { mc.m_mesh.Chamfer((yysemantic_stack_[(2) - (2)].args).f0); }
    517487    break;
     
    519489  case 19:
    520490
    521 /* Line 690 of lalr1.cc  */
    522 #line 120 "easymesh/easymesh-parser.y"
     491/* Line 677 of lalr1.cc  */
     492#line 121 "easymesh/easymesh-parser.y"
    523493    { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); }
    524494    break;
     
    526496  case 20:
    527497
    528 /* Line 690 of lalr1.cc  */
    529 #line 121 "easymesh/easymesh-parser.y"
     498/* Line 677 of lalr1.cc  */
     499#line 122 "easymesh/easymesh-parser.y"
    530500    { mc.m_mesh.Translate(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); }
    531501    break;
     
    533503  case 21:
    534504
    535 /* Line 690 of lalr1.cc  */
    536 #line 122 "easymesh/easymesh-parser.y"
     505/* Line 677 of lalr1.cc  */
     506#line 123 "easymesh/easymesh-parser.y"
    537507    { mc.m_mesh.Translate(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); }
    538508    break;
     
    540510  case 22:
    541511
    542 /* Line 690 of lalr1.cc  */
    543 #line 123 "easymesh/easymesh-parser.y"
     512/* Line 677 of lalr1.cc  */
     513#line 124 "easymesh/easymesh-parser.y"
    544514    { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
    545515    break;
     
    547517  case 23:
    548518
    549 /* Line 690 of lalr1.cc  */
    550 #line 124 "easymesh/easymesh-parser.y"
     519/* Line 677 of lalr1.cc  */
     520#line 125 "easymesh/easymesh-parser.y"
    551521    { mc.m_mesh.RotateX((yysemantic_stack_[(2) - (2)].args).f0); }
    552522    break;
     
    554524  case 24:
    555525
    556 /* Line 690 of lalr1.cc  */
    557 #line 125 "easymesh/easymesh-parser.y"
     526/* Line 677 of lalr1.cc  */
     527#line 126 "easymesh/easymesh-parser.y"
    558528    { mc.m_mesh.RotateY((yysemantic_stack_[(2) - (2)].args).f0); }
    559529    break;
     
    561531  case 25:
    562532
    563 /* Line 690 of lalr1.cc  */
    564 #line 126 "easymesh/easymesh-parser.y"
     533/* Line 677 of lalr1.cc  */
     534#line 127 "easymesh/easymesh-parser.y"
    565535    { mc.m_mesh.RotateZ((yysemantic_stack_[(2) - (2)].args).f0); }
    566536    break;
     
    568538  case 26:
    569539
    570 /* Line 690 of lalr1.cc  */
    571 #line 127 "easymesh/easymesh-parser.y"
     540/* Line 677 of lalr1.cc  */
     541#line 128 "easymesh/easymesh-parser.y"
    572542    { mc.m_mesh.TaperX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
    573543    break;
     
    575545  case 27:
    576546
    577 /* Line 690 of lalr1.cc  */
    578 #line 128 "easymesh/easymesh-parser.y"
     547/* Line 677 of lalr1.cc  */
     548#line 129 "easymesh/easymesh-parser.y"
    579549    { mc.m_mesh.TaperY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
    580550    break;
     
    582552  case 28:
    583553
    584 /* Line 690 of lalr1.cc  */
    585 #line 129 "easymesh/easymesh-parser.y"
     554/* Line 677 of lalr1.cc  */
     555#line 130 "easymesh/easymesh-parser.y"
    586556    { mc.m_mesh.TaperZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
    587557    break;
     
    589559  case 29:
    590560
    591 /* Line 690 of lalr1.cc  */
    592 #line 130 "easymesh/easymesh-parser.y"
     561/* Line 677 of lalr1.cc  */
     562#line 131 "easymesh/easymesh-parser.y"
    593563    { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, 1.0, 1.0)); }
    594564    break;
     
    596566  case 30:
    597567
    598 /* Line 690 of lalr1.cc  */
    599 #line 131 "easymesh/easymesh-parser.y"
     568/* Line 677 of lalr1.cc  */
     569#line 132 "easymesh/easymesh-parser.y"
    600570    { mc.m_mesh.Scale(vec3(1.0, (yysemantic_stack_[(2) - (2)].args).f0, 1.0)); }
    601571    break;
     
    603573  case 31:
    604574
    605 /* Line 690 of lalr1.cc  */
    606 #line 132 "easymesh/easymesh-parser.y"
     575/* Line 677 of lalr1.cc  */
     576#line 133 "easymesh/easymesh-parser.y"
    607577    { mc.m_mesh.Scale(vec3(1.0, 1.0, (yysemantic_stack_[(2) - (2)].args).f0)); }
    608578    break;
     
    610580  case 32:
    611581
    612 /* Line 690 of lalr1.cc  */
    613 #line 133 "easymesh/easymesh-parser.y"
     582/* Line 677 of lalr1.cc  */
     583#line 134 "easymesh/easymesh-parser.y"
    614584    { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
    615585    break;
     
    617587  case 33:
    618588
    619 /* Line 690 of lalr1.cc  */
    620 #line 134 "easymesh/easymesh-parser.y"
     589/* Line 677 of lalr1.cc  */
     590#line 135 "easymesh/easymesh-parser.y"
    621591    { mc.m_mesh.MirrorX(); }
    622592    break;
     
    624594  case 34:
    625595
    626 /* Line 690 of lalr1.cc  */
    627 #line 135 "easymesh/easymesh-parser.y"
     596/* Line 677 of lalr1.cc  */
     597#line 136 "easymesh/easymesh-parser.y"
    628598    { mc.m_mesh.MirrorY(); }
    629599    break;
     
    631601  case 35:
    632602
    633 /* Line 690 of lalr1.cc  */
    634 #line 136 "easymesh/easymesh-parser.y"
     603/* Line 677 of lalr1.cc  */
     604#line 137 "easymesh/easymesh-parser.y"
    635605    { mc.m_mesh.MirrorZ(); }
    636606    break;
     
    638608  case 36:
    639609
    640 /* Line 690 of lalr1.cc  */
    641 #line 137 "easymesh/easymesh-parser.y"
     610/* Line 677 of lalr1.cc  */
     611#line 138 "easymesh/easymesh-parser.y"
    642612    { mc.m_mesh.ToggleScaleWinding(); }
    643613    break;
     
    645615  case 37:
    646616
    647 /* Line 690 of lalr1.cc  */
     617/* Line 677 of lalr1.cc  */
     618#line 139 "easymesh/easymesh-parser.y"
     619    { mc.m_mesh.CsgUnion(); }
     620    break;
     621
     622  case 38:
     623
     624/* Line 677 of lalr1.cc  */
     625#line 140 "easymesh/easymesh-parser.y"
     626    { mc.m_mesh.CsgSubstract(); }
     627    break;
     628
     629  case 39:
     630
     631/* Line 677 of lalr1.cc  */
    648632#line 141 "easymesh/easymesh-parser.y"
     633    { mc.m_mesh.CsgAnd(); }
     634    break;
     635
     636  case 40:
     637
     638/* Line 677 of lalr1.cc  */
     639#line 142 "easymesh/easymesh-parser.y"
     640    { mc.m_mesh.CsgXor(); }
     641    break;
     642
     643  case 41:
     644
     645/* Line 677 of lalr1.cc  */
     646#line 146 "easymesh/easymesh-parser.y"
    649647    { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    650648                                                 (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3,
     
    652650    break;
    653651
    654   case 38:
    655 
    656 /* Line 690 of lalr1.cc  */
    657 #line 144 "easymesh/easymesh-parser.y"
     652  case 42:
     653
     654/* Line 677 of lalr1.cc  */
     655#line 149 "easymesh/easymesh-parser.y"
    658656    { mc.m_mesh.AppendBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
    659657    break;
    660658
    661   case 39:
    662 
    663 /* Line 690 of lalr1.cc  */
    664 #line 145 "easymesh/easymesh-parser.y"
     659  case 43:
     660
     661/* Line 677 of lalr1.cc  */
     662#line 150 "easymesh/easymesh-parser.y"
    665663    { mc.m_mesh.AppendSmoothChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    666664                                                            (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); }
    667665    break;
    668666
    669   case 40:
    670 
    671 /* Line 690 of lalr1.cc  */
    672 #line 147 "easymesh/easymesh-parser.y"
     667  case 44:
     668
     669/* Line 677 of lalr1.cc  */
     670#line 152 "easymesh/easymesh-parser.y"
    673671    { mc.m_mesh.AppendFlatChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    674672                                                          (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); }
    675673    break;
    676674
    677   case 41:
    678 
    679 /* Line 690 of lalr1.cc  */
    680 #line 149 "easymesh/easymesh-parser.y"
     675  case 45:
     676
     677/* Line 677 of lalr1.cc  */
     678#line 154 "easymesh/easymesh-parser.y"
    681679    { mc.m_mesh.AppendSphere((yysemantic_stack_[(2) - (2)].args).f0,
    682680                                               vec3((yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); }
    683681    break;
    684682
    685   case 42:
    686 
    687 /* Line 690 of lalr1.cc  */
    688 #line 151 "easymesh/easymesh-parser.y"
     683  case 46:
     684
     685/* Line 677 of lalr1.cc  */
     686#line 156 "easymesh/easymesh-parser.y"
    689687    { mc.m_mesh.AppendCapsule((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
    690688    break;
    691689
    692   case 43:
    693 
    694 /* Line 690 of lalr1.cc  */
    695 #line 152 "easymesh/easymesh-parser.y"
     690  case 47:
     691
     692/* Line 677 of lalr1.cc  */
     693#line 157 "easymesh/easymesh-parser.y"
    696694    { mc.m_mesh.AppendTorus((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
    697695    break;
    698696
    699   case 44:
    700 
    701 /* Line 690 of lalr1.cc  */
    702 #line 153 "easymesh/easymesh-parser.y"
     697  case 48:
     698
     699/* Line 677 of lalr1.cc  */
     700#line 158 "easymesh/easymesh-parser.y"
    703701    { mc.m_mesh.AppendStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2,
    704702                                             (int)(yysemantic_stack_[(2) - (2)].args).f3, (int)(yysemantic_stack_[(2) - (2)].args).f4); }
    705703    break;
    706704
    707   case 45:
    708 
    709 /* Line 690 of lalr1.cc  */
    710 #line 155 "easymesh/easymesh-parser.y"
     705  case 49:
     706
     707/* Line 677 of lalr1.cc  */
     708#line 160 "easymesh/easymesh-parser.y"
    711709    { mc.m_mesh.AppendExpandedStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    712710                                                     (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); }
    713711    break;
    714712
    715   case 46:
    716 
    717 /* Line 690 of lalr1.cc  */
    718 #line 157 "easymesh/easymesh-parser.y"
     713  case 50:
     714
     715/* Line 677 of lalr1.cc  */
     716#line 162 "easymesh/easymesh-parser.y"
    719717    { mc.m_mesh.AppendDisc((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (int)(yysemantic_stack_[(2) - (2)].args).f2); }
    720718    break;
    721719
    722   case 47:
    723 
    724 /* Line 690 of lalr1.cc  */
    725 #line 158 "easymesh/easymesh-parser.y"
     720  case 51:
     721
     722/* Line 677 of lalr1.cc  */
     723#line 163 "easymesh/easymesh-parser.y"
    726724    { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); }
    727725    break;
    728726
    729   case 48:
    730 
    731 /* Line 690 of lalr1.cc  */
    732 #line 159 "easymesh/easymesh-parser.y"
     727  case 52:
     728
     729/* Line 677 of lalr1.cc  */
     730#line 164 "easymesh/easymesh-parser.y"
    733731    { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); }
    734732    break;
    735733
    736   case 49:
    737 
    738 /* Line 690 of lalr1.cc  */
    739 #line 160 "easymesh/easymesh-parser.y"
     734  case 53:
     735
     736/* Line 677 of lalr1.cc  */
     737#line 165 "easymesh/easymesh-parser.y"
    740738    { mc.m_mesh.AppendCog((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    741739                                 (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3, (yysemantic_stack_[(2) - (2)].args).f4, (yysemantic_stack_[(2) - (2)].args).f5, (yysemantic_stack_[(2) - (2)].args).f6,
     
    743741    break;
    744742
    745   case 50:
    746 
    747 /* Line 690 of lalr1.cc  */
    748 #line 165 "easymesh/easymesh-parser.y"
     743  case 54:
     744
     745/* Line 677 of lalr1.cc  */
     746#line 170 "easymesh/easymesh-parser.y"
    749747    { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); }
    750748    break;
    751749
    752   case 51:
    753 
    754 /* Line 690 of lalr1.cc  */
    755 #line 166 "easymesh/easymesh-parser.y"
     750  case 55:
     751
     752/* Line 677 of lalr1.cc  */
     753#line 171 "easymesh/easymesh-parser.y"
    756754    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); }
    757755    break;
    758756
    759   case 52:
    760 
    761 /* Line 690 of lalr1.cc  */
    762 #line 167 "easymesh/easymesh-parser.y"
     757  case 56:
     758
     759/* Line 677 of lalr1.cc  */
     760#line 172 "easymesh/easymesh-parser.y"
    763761    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); }
    764762    break;
    765763
    766   case 53:
    767 
    768 /* Line 690 of lalr1.cc  */
    769 #line 168 "easymesh/easymesh-parser.y"
     764  case 57:
     765
     766/* Line 677 of lalr1.cc  */
     767#line 173 "easymesh/easymesh-parser.y"
    770768    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); }
    771769    break;
    772770
    773   case 54:
    774 
    775 /* Line 690 of lalr1.cc  */
    776 #line 169 "easymesh/easymesh-parser.y"
     771  case 58:
     772
     773/* Line 677 of lalr1.cc  */
     774#line 174 "easymesh/easymesh-parser.y"
    777775    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); }
    778776    break;
    779777
    780   case 55:
    781 
    782 /* Line 690 of lalr1.cc  */
    783 #line 170 "easymesh/easymesh-parser.y"
     778  case 59:
     779
     780/* Line 677 of lalr1.cc  */
     781#line 175 "easymesh/easymesh-parser.y"
    784782    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); }
    785783    break;
    786784
    787   case 56:
    788 
    789 /* Line 690 of lalr1.cc  */
    790 #line 171 "easymesh/easymesh-parser.y"
     785  case 60:
     786
     787/* Line 677 of lalr1.cc  */
     788#line 176 "easymesh/easymesh-parser.y"
    791789    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); }
    792790    break;
    793791
    794   case 57:
    795 
    796 /* Line 690 of lalr1.cc  */
    797 #line 172 "easymesh/easymesh-parser.y"
     792  case 61:
     793
     794/* Line 677 of lalr1.cc  */
     795#line 177 "easymesh/easymesh-parser.y"
    798796    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); }
    799797    break;
    800798
    801   case 58:
    802 
    803 /* Line 690 of lalr1.cc  */
    804 #line 173 "easymesh/easymesh-parser.y"
     799  case 62:
     800
     801/* Line 677 of lalr1.cc  */
     802#line 178 "easymesh/easymesh-parser.y"
    805803    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f8 = (yysemantic_stack_[(2) - (2)].fval); }
    806804    break;
    807805
    808   case 59:
    809 
    810 /* Line 690 of lalr1.cc  */
    811 #line 174 "easymesh/easymesh-parser.y"
     806  case 63:
     807
     808/* Line 677 of lalr1.cc  */
     809#line 179 "easymesh/easymesh-parser.y"
    812810    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f9 = (yysemantic_stack_[(2) - (2)].fval); }
    813811    break;
    814812
    815   case 60:
    816 
    817 /* Line 690 of lalr1.cc  */
    818 #line 177 "easymesh/easymesh-parser.y"
     813  case 64:
     814
     815/* Line 677 of lalr1.cc  */
     816#line 182 "easymesh/easymesh-parser.y"
    819817    { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); }
    820818    break;
    821819
    822   case 61:
    823 
    824 /* Line 690 of lalr1.cc  */
    825 #line 178 "easymesh/easymesh-parser.y"
     820  case 65:
     821
     822/* Line 677 of lalr1.cc  */
     823#line 183 "easymesh/easymesh-parser.y"
    826824    { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); }
    827825    break;
     
    829827
    830828
    831 /* Line 690 of lalr1.cc  */
    832 #line 833 "generated/easymesh-parser.cpp"
     829/* Line 677 of lalr1.cc  */
     830#line 831 "generated/easymesh-parser.cpp"
    833831        default:
    834832          break;
    835833      }
    836     /* User semantic actions sometimes alter yychar, and that requires
    837        that yytoken be updated with the new translation.  We take the
    838        approach of translating immediately before every use of yytoken.
    839        One alternative is translating here after every semantic action,
    840        but that translation would be missed if the semantic action
    841        invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
    842        yychar.  In the case of YYABORT or YYACCEPT, an incorrect
    843        destructor might then be invoked immediately.  In the case of
    844        YYERROR, subsequent parser actions might lead to an incorrect
    845        destructor call or verbose syntax error message before the
    846        lookahead is translated.  */
    847834    YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
    848835
     
    868855  `------------------------------------*/
    869856  yyerrlab:
    870     /* Make sure we have latest lookahead translation.  See comments at
    871        user semantic actions for why this is necessary.  */
    872     yytoken = yytranslate_ (yychar);
    873 
    874857    /* If not already recovering from an error, report this error.  */
    875858    if (!yyerrstatus_)
    876859      {
    877860        ++yynerrs_;
    878         if (yychar == yyempty_)
    879           yytoken = yyempty_;
    880861        error (yylloc, yysyntax_error_ (yystate, yytoken));
    881862      }
    882863
    883     yyerror_range[1] = yylloc;
     864    yyerror_range[0] = yylloc;
    884865    if (yyerrstatus_ == 3)
    885866      {
     
    916897      goto yyerrorlab;
    917898
    918     yyerror_range[1] = yylocation_stack_[yylen - 1];
     899    yyerror_range[0] = yylocation_stack_[yylen - 1];
    919900    /* Do not reclaim the symbols of the rule which action triggered
    920901       this YYERROR.  */
     
    933914      {
    934915        yyn = yypact_[yystate];
    935         if (!yy_pact_value_is_default_ (yyn))
     916        if (yyn != yypact_ninf_)
    936917        {
    937918          yyn += yyterror_;
     
    948929        YYABORT;
    949930
    950         yyerror_range[1] = yylocation_stack_[0];
     931        yyerror_range[0] = yylocation_stack_[0];
    951932        yydestruct_ ("Error: popping",
    952933                     yystos_[yystate],
     
    957938      }
    958939
    959     yyerror_range[2] = yylloc;
     940    yyerror_range[1] = yylloc;
    960941    // Using YYLLOC is tempting, but would change the location of
    961942    // the lookahead.  YYLOC is available though.
    962     YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
     943    YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
    963944    yysemantic_stack_.push (yylval);
    964945    yylocation_stack_.push (yyloc);
     
    983964  yyreturn:
    984965    if (yychar != yyempty_)
    985       {
    986         /* Make sure we have latest lookahead translation.  See comments
    987            at user semantic actions for why this is necessary.  */
    988         yytoken = yytranslate_ (yychar);
    989         yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval,
    990                      &yylloc);
    991       }
     966      yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
    992967
    993968    /* Do not reclaim the symbols of the rule which action triggered
     
    1008983  // Generate an error message.
    1009984  std::string
    1010   EasyMeshParser::yysyntax_error_ (int yystate, int yytoken)
    1011   {
    1012     std::string yyres;
    1013     // Number of reported tokens (one for the "unexpected", one per
    1014     // "expected").
    1015     size_t yycount = 0;
    1016     // Its maximum.
    1017     enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
    1018     // Arguments of yyformat.
    1019     char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
    1020 
    1021     /* There are many possibilities here to consider:
    1022        - If this state is a consistent state with a default action, then
    1023          the only way this function was invoked is if the default action
    1024          is an error action.  In that case, don't check for expected
    1025          tokens because there are none.
    1026        - The only way there can be no lookahead present (in yytoken) is
    1027          if this state is a consistent state with a default action.
    1028          Thus, detecting the absence of a lookahead is sufficient to
    1029          determine that there is no unexpected or expected token to
    1030          report.  In that case, just report a simple "syntax error".
    1031        - Don't assume there isn't a lookahead just because this state is
    1032          a consistent state with a default action.  There might have
    1033          been a previous inconsistent state, consistent state with a
    1034          non-default action, or user semantic action that manipulated
    1035          yychar.
    1036        - Of course, the expected token list depends on states to have
    1037          correct lookahead information, and it depends on the parser not
    1038          to perform extra reductions after fetching a lookahead from the
    1039          scanner and before detecting a syntax error.  Thus, state
    1040          merging (from LALR or IELR) and default reductions corrupt the
    1041          expected token list.  However, the list is correct for
    1042          canonical LR with one exception: it will still contain any
    1043          token that will not be accepted due to an error action in a
    1044          later state.
    1045     */
    1046     if (yytoken != yyempty_)
     985  EasyMeshParser::yysyntax_error_ (int yystate, int tok)
     986  {
     987    std::string res;
     988    YYUSE (yystate);
     989#if YYERROR_VERBOSE
     990    int yyn = yypact_[yystate];
     991    if (yypact_ninf_ < yyn && yyn <= yylast_)
    1047992      {
    1048         yyarg[yycount++] = yytname_[yytoken];
    1049         int yyn = yypact_[yystate];
    1050         if (!yy_pact_value_is_default_ (yyn))
    1051           {
    1052             /* Start YYX at -YYN if negative to avoid negative indexes in
    1053                YYCHECK.  In other words, skip the first -YYN actions for
    1054                this state because they are default actions.  */
    1055             int yyxbegin = yyn < 0 ? -yyn : 0;
    1056             /* Stay within bounds of both yycheck and yytname.  */
    1057             int yychecklim = yylast_ - yyn + 1;
    1058             int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
    1059             for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
    1060               if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
    1061                   && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
    1062                 {
    1063                   if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
    1064                     {
    1065                       yycount = 1;
    1066                       break;
    1067                     }
    1068                   else
    1069                     yyarg[yycount++] = yytname_[yyx];
    1070                 }
    1071           }
     993        /* Start YYX at -YYN if negative to avoid negative indexes in
     994           YYCHECK.  */
     995        int yyxbegin = yyn < 0 ? -yyn : 0;
     996
     997        /* Stay within bounds of both yycheck and yytname.  */
     998        int yychecklim = yylast_ - yyn + 1;
     999        int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
     1000        int count = 0;
     1001        for (int x = yyxbegin; x < yyxend; ++x)
     1002          if (yycheck_[x + yyn] == x && x != yyterror_)
     1003            ++count;
     1004
     1005        // FIXME: This method of building the message is not compatible
     1006        // with internationalization.  It should work like yacc.c does it.
     1007        // That is, first build a string that looks like this:
     1008        // "syntax error, unexpected %s or %s or %s"
     1009        // Then, invoke YY_ on this string.
     1010        // Finally, use the string as a format to output
     1011        // yytname_[tok], etc.
     1012        // Until this gets fixed, this message appears in English only.
     1013        res = "syntax error, unexpected ";
     1014        res += yytnamerr_ (yytname_[tok]);
     1015        if (count < 5)
     1016          {
     1017            count = 0;
     1018            for (int x = yyxbegin; x < yyxend; ++x)
     1019              if (yycheck_[x + yyn] == x && x != yyterror_)
     1020                {
     1021                  res += (!count++) ? ", expecting " : " or ";
     1022                  res += yytnamerr_ (yytname_[x]);
     1023                }
     1024          }
    10721025      }
    1073 
    1074     char const* yyformat = 0;
    1075     switch (yycount)
    1076       {
    1077 #define YYCASE_(N, S)                         \
    1078         case N:                               \
    1079           yyformat = S;                       \
    1080         break
    1081         YYCASE_(0, YY_("syntax error"));
    1082         YYCASE_(1, YY_("syntax error, unexpected %s"));
    1083         YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
    1084         YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
    1085         YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
    1086         YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
    1087 #undef YYCASE_
    1088       }
    1089 
    1090     // Argument number.
    1091     size_t yyi = 0;
    1092     for (char const* yyp = yyformat; *yyp; ++yyp)
    1093       if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
    1094         {
    1095           yyres += yytnamerr_ (yyarg[yyi++]);
    1096           ++yyp;
    1097         }
    1098       else
    1099         yyres += *yyp;
    1100     return yyres;
     1026    else
     1027#endif
     1028      res = YY_("syntax error");
     1029    return res;
    11011030  }
    11021031
     
    11041033  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    11051034     STATE-NUM.  */
    1106   const signed char EasyMeshParser::yypact_ninf_ = -48;
     1035  const signed char EasyMeshParser::yypact_ninf_ = -10;
    11071036  const signed char
    11081037  EasyMeshParser::yypact_[] =
    11091038  {
    1110         37,   -27,    89,   -32,   -32,   -32,   -32,   -48,   -32,   -32,
    1111      -32,   -32,   -48,   -32,   -32,   -32,   -32,   -48,   -32,   -32,
    1112      -48,   -32,   -32,   -32,   -32,   -32,   -32,   -32,   -32,   -32,
    1113      -32,   -32,   -32,   -32,   -32,   -48,     5,    13,    37,    37,
    1114       75,   -48,   -48,   -48,   -48,   -48,   -48,   -32,   -32,   -32,
    1115      -32,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,
    1116      -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,
    1117      -32,   -32,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,
    1118      -48,   -48,   -48,   -32,   -32,   -32,   -32,   -48,   -48,   -48,
    1119      -48,   -48,   -25,   -48,   -48,   -48,   -48,   -48,   -48,   -48,
    1120      -48,   -48,   -48,   -48,   -48,   -48
     1039        -3,    18,    27,    16,    16,    16,    16,   -10,    16,    16,
     1040      16,    16,   -10,    16,    16,    16,    16,   -10,    16,    16,
     1041     -10,   -10,   -10,   -10,   -10,    16,    16,    16,    16,    16,
     1042      16,    16,    16,    16,    16,    16,    16,    16,    16,   -10,
     1043      40,    48,    -3,    -3,    79,   -10,   -10,   -10,   -10,   -10,
     1044     -10,    16,    16,    16,    16,   -10,   -10,   -10,   -10,   -10,
     1045     -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,
     1046     -10,   -10,   -10,   -10,    16,    16,   -10,   -10,   -10,   -10,
     1047     -10,   -10,   -10,   -10,   -10,   -10,   -10,    16,    16,    16,
     1048      16,   -10,   -10,   -10,   -10,   -10,     5,   -10,   -10,   -10,
     1049     -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10
    11211050  };
    11221051
    1123   /* YYDEFACT[S] -- default reduction number in state S.  Performed when
    1124      YYTABLE doesn't specify something else to do.  Zero means the
    1125      default is an error.  */
     1052  /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
     1053     doesn't specify something else to do.  Zero means the default is an
     1054     error.  */
    11261055  const unsigned char
    11271056  EasyMeshParser::yydefact_[] =
     
    11291058         0,     0,     0,     0,     0,     0,     0,    33,     0,     0,
    11301059       0,     0,    34,     0,     0,     0,     0,    35,     0,     0,
    1131       36,     0,     0,     0,     0,     0,     0,     0,     0,     0,
    1132        0,     0,     0,     0,     0,     7,     0,     0,     3,     0,
    1133        5,     9,    11,    12,    13,    60,    15,     0,     0,     0,
    1134        0,    14,    50,    17,    16,    19,    23,    26,    29,    20,
    1135       24,    27,    30,    21,    25,    28,    31,    22,    32,    18,
    1136        0,     0,    37,    38,    39,    40,    41,    42,    44,    45,
    1137       46,    47,    48,     0,     0,     0,     0,    49,    43,     1,
    1138        2,     4,     0,    10,    61,    51,    52,    53,    54,    55,
    1139       56,    57,    58,    59,    8,     6
     1060      36,    37,    38,    39,    40,     0,     0,     0,     0,     0,
     1061       0,     0,     0,     0,     0,     0,     0,     0,     0,     7,
     1062       0,     0,     3,     0,     5,     9,    11,    12,    13,    64,
     1063      15,     0,     0,     0,     0,    14,    54,    17,    16,    19,
     1064      23,    26,    29,    20,    24,    27,    30,    21,    25,    28,
     1065      31,    22,    32,    18,     0,     0,    41,    42,    43,    44,
     1066      45,    46,    48,    49,    50,    51,    52,     0,     0,     0,
     1067       0,    53,    47,     1,     2,     4,     0,    10,    65,    55,
     1068      56,    57,    58,    59,    60,    61,    62,    63,    8,     6
    11401069  };
    11411070
     
    11441073  EasyMeshParser::yypgoto_[] =
    11451074  {
    1146        -48,   -48,   -19,   -48,   -48,   -48,   -48,   -15,   -48,   -48,
    1147      -48,   109,    -4,    -1,     6,    -7,     1,   -48,   -48,   -48,
    1148      -48,   -47
     1075       -10,   -10,    -4,   -10,   -10,   -10,   -10,     9,   -10,   -10,
     1076     -10,    43,    36,   115,   122,    23,    26,   -10,   -10,   -10,
     1077     -10,    -9
    11491078  };
    11501079
     
    11531082  EasyMeshParser::yydefgoto_[] =
    11541083  {
    1155         -1,    36,    37,    38,    39,   105,    40,    41,    42,    43,
    1156       44,    48,    49,    50,    70,    71,    72,    84,    85,    86,
    1157       87,    52
     1084        -1,    40,    41,    42,    43,   109,    44,    45,    46,    47,
     1085      48,    52,    53,    54,    74,    75,    76,    88,    89,    90,
     1086      91,    56
    11581087  };
    11591088
    11601089  /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    11611090     positive, shift that token.  If negative, reduce the rule which
    1162      number is the opposite.  If YYTABLE_NINF_, syntax error.  */
     1091     number is the opposite.  If zero, do what YYDEFACT says.  */
    11631092  const signed char EasyMeshParser::yytable_ninf_ = -1;
    11641093  const unsigned char
    11651094  EasyMeshParser::yytable_[] =
    11661095  {
    1167         94,    95,    96,    97,    57,    89,    45,    51,    54,    61,
    1168       47,    45,    46,    90,    65,    47,   104,    67,    68,    91,
    1169       92,    78,    73,    98,    99,    93,    77,    81,    82,    80,
    1170       74,    75,    76,    88,    83,    79,   100,   101,   102,   103,
    1171        1,     2,     3,     4,     5,     6,     7,     8,     9,    10,
     1096         1,     2,     3,     4,     5,     6,     7,     8,     9,    10,
    11721097      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
    11731098      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
    1174       31,    32,    33,    34,     0,     0,     0,    35,     1,     2,
    1175        3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
    1176       13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
    1177       23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
    1178       33,    34,    55,    56,     0,    58,     0,    59,    60,     0,
    1179       62,     0,    63,    64,     0,    66,     0,    45,    53,     0,
    1180       69,    47
     1099      31,    32,    33,    34,    35,    36,    37,    38,    95,    96,
     1100      93,    39,    98,    99,   100,   101,    59,    60,    94,    62,
     1101     108,    63,    64,    97,    66,    82,    67,    68,    49,    70,
     1102      49,    50,    51,    87,    51,   102,   103,     0,    73,    49,
     1103      57,    85,    86,    51,     0,     0,     0,     0,   104,   105,
     1104     106,   107,     1,     2,     3,     4,     5,     6,     7,     8,
     1105       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
     1106      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
     1107      29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
     1108      61,     0,     0,    55,    58,    65,     0,     0,     0,     0,
     1109      69,     0,     0,    71,    72,     0,     0,     0,     0,     0,
     1110       0,     0,    77,     0,     0,     0,    81,     0,     0,    84,
     1111      78,    79,    80,    92,     0,    83
    11811112  };
    11821113
     
    11851116  EasyMeshParser::yycheck_[] =
    11861117  {
    1187         47,    48,    49,    50,     5,     0,    38,     1,     2,    10,
    1188       42,    38,    39,     0,    15,    42,    41,    18,    19,    38,
    1189       39,    28,    23,    70,    71,    40,    27,    31,    32,    30,
    1190       24,    25,    26,    34,    33,    29,    83,    84,    85,    86,
    1191        3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
     1118         3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
    11921119      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
    11931120      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
    1194       33,    34,    35,    36,    -1,    -1,    -1,    40,     3,     4,
    1195        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
    1196       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
    1197       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
    1198       35,    36,     3,     4,    -1,     6,    -1,     8,     9,    -1,
    1199       11,    -1,    13,    14,    -1,    16,    -1,    38,    39,    -1,
    1200       21,    42
     1121      33,    34,    35,    36,    37,    38,    39,    40,    42,    43,
     1122       0,    44,    51,    52,    53,    54,     3,     4,     0,     6,
     1123      45,     8,     9,    44,    11,    32,    13,    14,    42,    16,
     1124      42,    43,    46,    37,    46,    74,    75,    -1,    25,    42,
     1125      43,    35,    36,    46,    -1,    -1,    -1,    -1,    87,    88,
     1126      89,    90,     3,     4,     5,     6,     7,     8,     9,    10,
     1127      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
     1128      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
     1129      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
     1130       5,    -1,    -1,     1,     2,    10,    -1,    -1,    -1,    -1,
     1131      15,    -1,    -1,    18,    19,    -1,    -1,    -1,    -1,    -1,
     1132      -1,    -1,    27,    -1,    -1,    -1,    31,    -1,    -1,    34,
     1133      28,    29,    30,    38,    -1,    33
    12011134  };
    12021135
     
    12091142      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
    12101143      22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
    1211       32,    33,    34,    35,    36,    40,    44,    45,    46,    47,
    1212       49,    50,    51,    52,    53,    38,    39,    42,    54,    55,
    1213       56,    57,    64,    39,    57,    54,    54,    56,    54,    54,
    1214       54,    56,    54,    54,    54,    56,    54,    56,    56,    54,
    1215       57,    58,    59,    56,    57,    57,    57,    56,    58,    57,
    1216       56,    55,    55,    59,    60,    61,    62,    63,    56,     0,
    1217        0,    45,    45,    50,    64,    64,    64,    64,    64,    64,
    1218       64,    64,    64,    64,    41,    48
     1144      32,    33,    34,    35,    36,    37,    38,    39,    40,    44,
     1145      48,    49,    50,    51,    53,    54,    55,    56,    57,    42,
     1146      43,    46,    58,    59,    60,    61,    68,    43,    61,    58,
     1147      58,    60,    58,    58,    58,    60,    58,    58,    58,    60,
     1148      58,    60,    60,    58,    61,    62,    63,    60,    61,    61,
     1149      61,    60,    62,    61,    60,    59,    59,    63,    64,    65,
     1150      66,    67,    60,     0,     0,    49,    49,    54,    68,    68,
     1151      68,    68,    68,    68,    68,    68,    68,    68,    45,    52
    12191152  };
    12201153
     
    12291162     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
    12301163     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
    1231       91,    93,    45
     1164     295,   296,   297,   298,    91,    93,    45
    12321165  };
    12331166#endif
     
    12371170  EasyMeshParser::yyr1_[] =
    12381171  {
    1239          0,    43,    44,    45,    45,    46,    46,    47,    48,    49,
    1240       49,    50,    50,    50,    51,    51,    51,    51,    52,    52,
    1241       52,    52,    52,    52,    52,    52,    52,    52,    52,    52,
    1242       52,    52,    52,    52,    52,    52,    52,    53,    53,    53,
    1243       53,    53,    53,    53,    53,    53,    53,    53,    53,    53,
    1244       54,    55,    56,    57,    58,    59,    60,    61,    62,    63,
    1245       64,    64
     1172         0,    47,    48,    49,    49,    50,    50,    51,    52,    53,
     1173      53,    54,    54,    54,    55,    55,    55,    55,    56,    56,
     1174      56,    56,    56,    56,    56,    56,    56,    56,    56,    56,
     1175      56,    56,    56,    56,    56,    56,    56,    56,    56,    56,
     1176      56,    57,    57,    57,    57,    57,    57,    57,    57,    57,
     1177      57,    57,    57,    57,    58,    59,    60,    61,    62,    63,
     1178      64,    65,    66,    67,    68,    68
    12461179  };
    12471180
     
    12531186       2,     1,     1,     1,     2,     2,     2,     2,     2,     2,
    12541187       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1255        2,     2,     2,     1,     1,     1,     1,     2,     2,     2,
    1256        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1188       2,     2,     2,     1,     1,     1,     1,     1,     1,     1,
    12571189       1,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1258        1,     2
     1190       2,     2,     2,     2,     1,     2,     2,     2,     2,     2,
     1191       2,     2,     2,     2,     1,     2
    12591192  };
    12601193
     
    12691202  "T_ROTATEY", "T_TAPERY", "T_SCALEY", "T_MIRRORY", "T_TRANSLATEZ",
    12701203  "T_ROTATEZ", "T_TAPERZ", "T_SCALEZ", "T_MIRRORZ", "T_TRANSLATE",
    1271   "T_SCALE", "T_TOGGLESCALEWINDING", "T_CHAMFER", "T_CYLINDER", "T_BOX",
     1204  "T_SCALE", "T_TOGGLESCALEWINDING", "T_CSGUNION", "T_CSGSUBSTRACT",
     1205  "T_CSGAND", "T_CSGXOR", "T_CHAMFER", "T_CYLINDER", "T_BOX",
    12721206  "T_SMOOTHCHAMFBOX", "T_FLATCHAMFBOX", "T_SPHERE", "T_CAPSULE", "T_STAR",
    12731207  "T_EXPANDEDSTAR", "T_DISC", "T_TRIANGLE", "T_QUAD", "T_COG", "T_TORUS",
     
    12861220  EasyMeshParser::yyrhs_[] =
    12871221  {
    1288         44,     0,    -1,    45,     0,    -1,    46,    -1,    46,    45,
    1289       -1,    49,    -1,    47,    45,    48,    -1,    40,    -1,    41,
    1290       -1,    50,    -1,    49,    50,    -1,    51,    -1,    52,    -1,
    1291       53,    -1,     3,    57,    -1,     3,    39,    -1,     4,    57,
    1292       -1,     4,    39,    -1,    23,    54,    -1,     5,    54,    -1,
    1293       10,    54,    -1,    15,    54,    -1,    20,    56,    -1,     6,
    1294       54,    -1,    11,    54,    -1,    16,    54,    -1,     7,    56,
    1295       -1,    12,    56,    -1,    17,    56,    -1,     8,    54,    -1,
    1296       13,    54,    -1,    18,    54,    -1,    21,    56,    -1,     9,
    1297       -1,    14,    -1,    19,    -1,    22,    -1,    24,    59,    -1,
    1298       25,    56,    -1,    26,    57,    -1,    27,    57,    -1,    28,
    1299       57,    -1,    29,    56,    -1,    36,    56,    -1,    30,    58,
    1300       -1,    31,    57,    -1,    32,    56,    -1,    33,    55,    -1,
    1301       34,    55,    -1,    35,    63,    -1,    64,    -1,    54,    64,
    1302       -1,    55,    64,    -1,    56,    64,    -1,    57,    64,    -1,
    1303       58,    64,    -1,    59,    64,    -1,    60,    64,    -1,    61,
    1304       64,    -1,    62,    64,    -1,    38,    -1,    42,    64,    -1
     1222        48,     0,    -1,    49,     0,    -1,    50,    -1,    50,    49,
     1223      -1,    53,    -1,    51,    49,    52,    -1,    44,    -1,    45,
     1224      -1,    54,    -1,    53,    54,    -1,    55,    -1,    56,    -1,
     1225      57,    -1,     3,    61,    -1,     3,    43,    -1,     4,    61,
     1226      -1,     4,    43,    -1,    27,    58,    -1,     5,    58,    -1,
     1227      10,    58,    -1,    15,    58,    -1,    20,    60,    -1,     6,
     1228      58,    -1,    11,    58,    -1,    16,    58,    -1,     7,    60,
     1229      -1,    12,    60,    -1,    17,    60,    -1,     8,    58,    -1,
     1230      13,    58,    -1,    18,    58,    -1,    21,    60,    -1,     9,
     1231      -1,    14,    -1,    19,    -1,    22,    -1,    23,    -1,    24,
     1232      -1,    25,    -1,    26,    -1,    28,    63,    -1,    29,    60,
     1233      -1,    30,    61,    -1,    31,    61,    -1,    32,    61,    -1,
     1234      33,    60,    -1,    40,    60,    -1,    34,    62,    -1,    35,
     1235      61,    -1,    36,    60,    -1,    37,    59,    -1,    38,    59,
     1236      -1,    39,    67,    -1,    68,    -1,    58,    68,    -1,    59,
     1237      68,    -1,    60,    68,    -1,    61,    68,    -1,    62,    68,
     1238      -1,    63,    68,    -1,    64,    68,    -1,    65,    68,    -1,
     1239      66,    68,    -1,    42,    -1,    46,    68,    -1
    13051240  };
    13061241
     
    13131248      23,    26,    28,    30,    32,    35,    38,    41,    44,    47,
    13141249      50,    53,    56,    59,    62,    65,    68,    71,    74,    77,
    1315       80,    83,    86,    89,    91,    93,    95,    97,   100,   103,
    1316      106,   109,   112,   115,   118,   121,   124,   127,   130,   133,
    1317      136,   138,   141,   144,   147,   150,   153,   156,   159,   162,
    1318      165,   167
     1250      80,    83,    86,    89,    91,    93,    95,    97,    99,   101,
     1251     103,   105,   108,   111,   114,   117,   120,   123,   126,   129,
     1252     132,   135,   138,   141,   144,   146,   149,   152,   155,   158,
     1253     161,   164,   167,   170,   173,   175
    13191254  };
    13201255
     
    13231258  EasyMeshParser::yyrline_[] =
    13241259  {
    1325          0,    75,    75,    79,    80,    84,    85,    89,    93,    97,
    1326       98,   102,   103,   104,   108,   109,   112,   113,   119,   120,
    1327      121,   122,   123,   124,   125,   126,   127,   128,   129,   130,
    1328      131,   132,   133,   134,   135,   136,   137,   141,   144,   145,
    1329      147,   149,   151,   152,   153,   155,   157,   158,   159,   160,
    1330      165,   166,   167,   168,   169,   170,   171,   172,   173,   174,
    1331      177,   178
     1260         0,    76,    76,    80,    81,    85,    86,    90,    94,    98,
     1261      99,   103,   104,   105,   109,   110,   113,   114,   120,   121,
     1262     122,   123,   124,   125,   126,   127,   128,   129,   130,   131,
     1263     132,   133,   134,   135,   136,   137,   138,   139,   140,   141,
     1264     142,   146,   149,   150,   152,   154,   156,   157,   158,   160,
     1265     162,   163,   164,   165,   170,   171,   172,   173,   174,   175,
     1266     176,   177,   178,   179,   182,   183
    13321267  };
    13331268
     
    13731308       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    13741309       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1375        2,     2,     2,     2,     2,    42,     2,     2,     2,     2,
    1376        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1377        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1378        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1379        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1380        2,    40,     2,    41,     2,     2,     2,     2,     2,     2,
     1310       2,     2,     2,     2,     2,    46,     2,     2,     2,     2,
     1311       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1312       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1313       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1314       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1315       2,    44,     2,    45,     2,     2,     2,     2,     2,     2,
    13811316       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    13821317       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     
    13981333      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
    13991334      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
    1400       35,    36,    37,    38,    39
     1335      35,    36,    37,    38,    39,    40,    41,    42,    43
    14011336    };
    14021337    if ((unsigned int) t <= yyuser_token_number_max_)
     
    14071342
    14081343  const int EasyMeshParser::yyeof_ = 0;
    1409   const int EasyMeshParser::yylast_ = 131;
     1344  const int EasyMeshParser::yylast_ = 155;
    14101345  const int EasyMeshParser::yynnts_ = 22;
    14111346  const int EasyMeshParser::yyempty_ = -2;
    1412   const int EasyMeshParser::yyfinal_ = 89;
     1347  const int EasyMeshParser::yyfinal_ = 93;
    14131348  const int EasyMeshParser::yyterror_ = 1;
    14141349  const int EasyMeshParser::yyerrcode_ = 256;
    1415   const int EasyMeshParser::yyntokens_ = 43;
    1416 
    1417   const unsigned int EasyMeshParser::yyuser_token_number_max_ = 294;
     1350  const int EasyMeshParser::yyntokens_ = 47;
     1351
     1352  const unsigned int EasyMeshParser::yyuser_token_number_max_ = 298;
    14181353  const EasyMeshParser::token_number_type EasyMeshParser::yyundef_token_ = 2;
    14191354
     
    14211356} // lol
    14221357
    1423 /* Line 1136 of lalr1.cc  */
    1424 #line 1425 "generated/easymesh-parser.cpp"
    1425 
    1426 
    1427 /* Line 1138 of lalr1.cc  */
    1428 #line 181 "easymesh/easymesh-parser.y"
     1358/* Line 1053 of lalr1.cc  */
     1359#line 1360 "generated/easymesh-parser.cpp"
     1360
     1361
     1362/* Line 1055 of lalr1.cc  */
     1363#line 186 "easymesh/easymesh-parser.y"
    14291364
    14301365
  • trunk/src/generated/easymesh-parser.h

    r2152 r2226  
    1 /* A Bison parser, made by GNU Bison 2.5.  */
     1/* A Bison parser, made by GNU Bison 2.4.2.  */
    22
    33/* Skeleton interface for Bison LALR(1) parsers in C++
    44   
    5       Copyright (C) 2002-2011 Free Software Foundation, Inc.
     5      Copyright (C) 2002-2010 Free Software Foundation, Inc.
    66   
    77   This program is free software: you can redistribute it and/or modify
     
    4141#include <iostream>
    4242#include "stack.hh"
     43
     44
     45namespace lol {
     46
     47/* Line 34 of lalr1.cc  */
     48#line 49 "generated/easymesh-parser.h"
     49  class position;
     50  class location;
     51
     52} // lol
     53
     54/* Line 34 of lalr1.cc  */
     55#line 56 "generated/easymesh-parser.h"
     56
    4357#include "location.hh"
    4458
     
    6175#endif
    6276
     77/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
     78   If N is 0, then set CURRENT to the empty location which ends
     79   the previous symbol: RHS[0] (always defined).  */
     80
     81#ifndef YYLLOC_DEFAULT
     82# define YYLLOC_DEFAULT(Current, Rhs, N)                \
     83do {                                                    \
     84  if (N)                                                \
     85    {                                                   \
     86      (Current).begin = (Rhs)[1].begin;                 \
     87      (Current).end   = (Rhs)[N].end;                   \
     88    }                                                   \
     89  else                                                  \
     90    {                                                   \
     91      (Current).begin = (Current).end = (Rhs)[0].end;   \
     92    }                                                   \
     93} while (false)
     94#endif
     95
    6396
    6497namespace lol {
    6598
    66 /* Line 35 of lalr1.cc  */
    67 #line 68 "generated/easymesh-parser.h"
     99/* Line 34 of lalr1.cc  */
     100#line 101 "generated/easymesh-parser.h"
    68101
    69102  /// A Bison parser.
     
    76109    {
    77110
    78 /* Line 35 of lalr1.cc  */
     111/* Line 34 of lalr1.cc  */
    79112#line 36 "easymesh/easymesh-parser.y"
    80113
     
    86119
    87120
    88 /* Line 35 of lalr1.cc  */
    89 #line 90 "generated/easymesh-parser.h"
     121/* Line 34 of lalr1.cc  */
     122#line 123 "generated/easymesh-parser.h"
    90123    };
    91124#else
     
    120153     T_SCALE = 276,
    121154     T_TOGGLESCALEWINDING = 277,
    122      T_CHAMFER = 278,
    123      T_CYLINDER = 279,
    124      T_BOX = 280,
    125      T_SMOOTHCHAMFBOX = 281,
    126      T_FLATCHAMFBOX = 282,
    127      T_SPHERE = 283,
    128      T_CAPSULE = 284,
    129      T_STAR = 285,
    130      T_EXPANDEDSTAR = 286,
    131      T_DISC = 287,
    132      T_TRIANGLE = 288,
    133      T_QUAD = 289,
    134      T_COG = 290,
    135      T_TORUS = 291,
    136      T_ERROR = 292,
    137      NUMBER = 293,
    138      COLOR = 294
     155     T_CSGUNION = 278,
     156     T_CSGSUBSTRACT = 279,
     157     T_CSGAND = 280,
     158     T_CSGXOR = 281,
     159     T_CHAMFER = 282,
     160     T_CYLINDER = 283,
     161     T_BOX = 284,
     162     T_SMOOTHCHAMFBOX = 285,
     163     T_FLATCHAMFBOX = 286,
     164     T_SPHERE = 287,
     165     T_CAPSULE = 288,
     166     T_STAR = 289,
     167     T_EXPANDEDSTAR = 290,
     168     T_DISC = 291,
     169     T_TRIANGLE = 292,
     170     T_QUAD = 293,
     171     T_COG = 294,
     172     T_TORUS = 295,
     173     T_ERROR = 296,
     174     NUMBER = 297,
     175     COLOR = 298
    139176   };
    140177
     
    210247    location_stack_type yylocation_stack_;
    211248
    212     /// Whether the given \c yypact_ value indicates a defaulted state.
    213     /// \param yyvalue   the value to check
    214     static bool yy_pact_value_is_default_ (int yyvalue);
    215 
    216     /// Whether the given \c yytable_ value indicates a syntax error.
    217     /// \param yyvalue   the value to check
    218     static bool yy_table_value_is_error_ (int yyvalue);
    219 
    220249    /// Internal symbol numbers.
    221250    typedef unsigned char token_number_type;
     
    225254    static const signed char yypact_ninf_;
    226255
    227     /// For a state, default reduction number.
     256    /// For a state, default rule to reduce.
    228257    /// Unless\a  yytable_ specifies something else to do.
    229258    /// Zero means the default is an error.
     
    256285#endif
    257286
     287#if YYERROR_VERBOSE
    258288    /// Convert the symbol name \a n to a form suitable for a diagnostic.
    259     static std::string yytnamerr_ (const char *n);
     289    virtual std::string yytnamerr_ (const char *n);
     290#endif
    260291
    261292#if YYDEBUG
     
    315346} // lol
    316347
    317 /* Line 35 of lalr1.cc  */
    318 #line 319 "generated/easymesh-parser.h"
     348/* Line 34 of lalr1.cc  */
     349#line 350 "generated/easymesh-parser.h"
    319350
    320351
  • trunk/src/generated/easymesh-scanner.cpp

    r2183 r2226  
    331331        (yy_c_buf_p) = yy_cp;
    332332
    333 #define YY_NUM_RULES 46
    334 #define YY_END_OF_BUFFER 47
     333#define YY_NUM_RULES 50
     334#define YY_END_OF_BUFFER 51
    335335/* This struct is not used in this scanner,
    336336   but its presence is necessary. */
     
    340340        flex_int32_t yy_nxt;
    341341        };
    342 static yyconst flex_int16_t yy_accept[75] =
     342static yyconst flex_int16_t yy_accept[81] =
    343343    {   0,
    344         0,    0,   47,   45,   44,   43,   45,   45,   40,   45,
    345        39,   41,   42,   45,   45,   45,   45,   17,    7,    0,
    346         0,   39,   39,    0,   22,   23,   26,    0,    0,   29,
    347        30,   33,    3,   19,   20,   21,    8,    9,   10,    1,
    348        14,   15,   16,    0,    0,    4,    5,    6,    0,    0,
    349        39,    0,   25,   27,    0,    0,    0,   34,    2,   11,
    350        12,   13,   18,   35,   24,   28,   31,   32,   36,    0,
    351        37,    0,   38,    0
     344        0,    0,   51,   49,   48,   47,   49,   49,   44,   49,
     345       43,   45,   46,   49,   49,   49,   49,   17,    7,    0,
     346        0,   43,   43,    0,   26,   27,   30,    0,    0,   33,
     347       34,   37,    3,    0,   19,   20,   21,    8,    9,   10,
     348        1,   14,   15,   16,    0,    0,    4,    5,    6,    0,
     349        0,   43,    0,   29,   31,    0,    0,    0,   38,    0,
     350        2,   11,   12,   13,   18,   39,   28,   32,   35,   36,
     351       24,   23,   22,   25,   40,    0,   41,    0,   42,    0
    352352    } ;
    353353
     
    366366
    367367       17,   18,   19,   20,    1,    1,    1,    1,   21,    1,
    368        22,   23,   24,   25,   26,   27,    1,    1,   28,   29,
    369        30,   31,    1,    1,    1,    1,    1,    1,    1,    1,
     368       22,   23,   24,   25,   26,   27,   28,    1,   29,   30,
     369       31,   32,    1,    1,    1,    1,    1,    1,    1,    1,
    370370        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    371371        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
     
    384384    } ;
    385385
    386 static yyconst flex_int32_t yy_meta[32] =
     386static yyconst flex_int32_t yy_meta[33] =
    387387    {   0,
    388388        1,    1,    1,    1,    1,    1,    1,    2,    2,    2,
    389389        1,    1,    2,    2,    2,    2,    2,    2,    1,    1,
    390390        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    391         1
     391        1,    1
    392392    } ;
    393393
    394 static yyconst flex_int16_t yy_base[83] =
     394static yyconst flex_int16_t yy_base[89] =
    395395    {   0,
    396         0,    0,  102,  103,  103,  103,    0,   25,   27,   93,
    397        29,  103,  103,   33,   80,   11,   14,   23,   48,    0,
    398        91,   48,   54,   61,  103,   57,  103,   72,   82,  103,
    399        57,   74,  103,  103,  103,  103,  103,  103,  103,   81,
    400       103,  103,  103,   52,   66,  103,  103,  103,    0,   85,
    401        84,   68,  103,  103,   76,   75,   68,  103,  103,  103,
    402       103,  103,  103,    0,  103,  103,  103,  103,    0,    0,
    403         0,    0,  103,  103,   85,   84,   83,   82,   73,   71,
    404        66,   61
     396        0,    0,  109,  110,  110,  110,    0,   26,   28,  100,
     397       30,  110,  110,   34,   19,   11,   23,   41,   61,    0,
     398       99,   58,   59,   72,  110,   44,  110,   80,   90,  110,
     399       47,   82,  110,   84,  110,  110,  110,  110,  110,  110,
     400       88,  110,  110,  110,   51,   71,  110,  110,  110,    0,
     401       90,   88,   72,  110,  110,   80,   76,   69,  110,   71,
     402      110,  110,  110,  110,  110,    0,  110,  110,  110,  110,
     403      110,  110,  110,  110,    0,    0,    0,    0,  110,  110,
     404       86,   84,   83,   77,   62,   57,   44,   42
    405405    } ;
    406406
    407 static yyconst flex_int16_t yy_def[83] =
     407static yyconst flex_int16_t yy_def[89] =
    408408    {   0,
    409        74,    1,   74,   74,   74,   74,   75,   74,   74,   74,
    410        74,   74,   74,   74,   74,   74,   74,   74,   74,   76,
    411        74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
    412        74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
    413        74,   74,   74,   74,   74,   74,   74,   74,   77,   74,
    414        74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
    415        74,   74,   74,   78,   74,   74,   74,   74,   79,   80,
    416        81,   82,   74,    0,   74,   74,   74,   74,   74,   74,
    417        74,   74
     409       80,    1,   80,   80,   80,   80,   81,   80,   80,   80,
     410       80,   80,   80,   80,   80,   80,   80,   80,   80,   82,
     411       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     412       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     413       80,   80,   80,   80,   80,   80,   80,   80,   80,   83,
     414       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     415       80,   80,   80,   80,   80,   84,   80,   80,   80,   80,
     416       80,   80,   80,   80,   85,   86,   87,   88,   80,    0,
     417       80,   80,   80,   80,   80,   80,   80,   80
    418418    } ;
    419419
    420 static yyconst flex_int16_t yy_nxt[135] =
     420static yyconst flex_int16_t yy_nxt[143] =
    421421    {   0,
    422422        4,    5,    6,    7,    8,    9,   10,   11,    4,    4,
    423423       12,   13,   14,    4,   15,    4,    4,    4,    4,    4,
    424424       16,    4,    4,    4,   17,   18,   19,    4,    4,    4,
    425         4,   21,   22,   21,   22,   21,   22,   40,   24,   34,
    426        35,   36,   37,   38,   39,   24,   25,   26,   27,   28,
    427        29,   41,   42,   43,   21,   22,   30,   24,   31,   32,
    428        44,   23,   73,   24,   24,   50,   50,   72,   51,   52,
    429        24,   56,   71,   45,   70,   53,   46,   47,   48,   57,
    430        60,   61,   62,   69,   64,   49,   20,   68,   67,   66,
    431        65,   51,   51,   63,   59,   58,   55,   54,   23,   33,
    432 
    433        23,   74,    3,   74,   74,   74,   74,   74,   74,   74,
    434        74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
    435        74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
    436        74,   74,   74,   74
     425        4,    4,   21,   22,   21,   22,   21,   22,   33,   24,
     426       35,   36,   37,   79,   34,   78,   24,   25,   26,   27,
     427       28,   29,   38,   39,   40,   41,   53,   30,   77,   31,
     428       32,   57,   54,   76,   21,   22,   23,   24,   24,   58,
     429       42,   43,   44,   45,   24,   24,   51,   51,   75,   52,
     430       62,   63,   64,   71,   66,   50,   46,   20,   70,   69,
     431       47,   48,   49,   68,   67,   52,   72,   52,   73,   65,
     432
     433       74,   61,   60,   59,   56,   55,   23,   23,   80,    3,
     434       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     435       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     436       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     437       80,   80
    437438    } ;
    438439
    439 static yyconst flex_int16_t yy_chk[135] =
     440static yyconst flex_int16_t yy_chk[143] =
    440441    {   0,
    441442        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    442443        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    443444        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    444         1,    8,    8,    9,    9,   11,   11,   18,   11,   16,
    445        16,   16,   17,   17,   17,   11,   14,   14,   14,   14,
    446        14,   18,   18,   18,   22,   22,   14,   22,   14,   14,
    447        19,   23,   82,   23,   22,   24,   24,   81,   24,   26,
    448        23,   31,   80,   19,   79,   26,   19,   19,   19,   31,
    449        44,   44,   44,   78,   77,   76,   75,   57,   56,   55,
    450        52,   51,   50,   45,   40,   32,   29,   28,   21,   15,
    451 
    452        10,    3,   74,   74,   74,   74,   74,   74,   74,   74,
    453        74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
    454        74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
    455        74,   74,   74,   74
     445        1,    1,    8,    8,    9,    9,   11,   11,   15,   11,
     446       16,   16,   16,   88,   15,   87,   11,   14,   14,   14,
     447       14,   14,   17,   17,   17,   18,   26,   14,   86,   14,
     448       14,   31,   26,   85,   22,   22,   23,   22,   23,   31,
     449       18,   18,   18,   19,   22,   23,   24,   24,   84,   24,
     450       45,   45,   45,   60,   83,   82,   19,   81,   58,   57,
     451       19,   19,   19,   56,   53,   52,   60,   51,   60,   46,
     452
     453       60,   41,   34,   32,   29,   28,   21,   10,    3,   80,
     454       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     455       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     456       80,   80,   80,   80,   80,   80,   80,   80,   80,   80,
     457       80,   80
    456458    } ;
    457459
     
    468470// Lol Engine
    469471//
    470 // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    471 //            (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
    472 //            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
     472// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
     473//            (c) 2009-2013 Cédric Lecacheur <jordx@free.fr>
     474//            (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    473475//   This program is free software; you can redistribute it and/or
    474476//   modify it under the terms of the Do What The Fuck You Want To
     
    502504#define YY_NO_UNISTD_H
    503505#define YY_USER_ACTION yylloc->columns(yyleng);
    504 #line 505 "generated/easymesh-scanner.cpp"
     506#line 507 "generated/easymesh-scanner.cpp"
    505507
    506508#define INITIAL 0
     
    615617
    616618
    617 #line 618 "generated/easymesh-scanner.cpp"
     619#line 620 "generated/easymesh-scanner.cpp"
    618620
    619621        if ( !(yy_init) )
     
    668670                                {
    669671                                yy_current_state = (int) yy_def[yy_current_state];
    670                                 if ( yy_current_state >= 75 )
     672                                if ( yy_current_state >= 81 )
    671673                                        yy_c = yy_meta[(unsigned int) yy_c];
    672674                                }
     
    674676                        ++yy_cp;
    675677                        }
    676                 while ( yy_current_state != 74 );
     678                while ( yy_current_state != 80 );
    677679                yy_cp = (yy_last_accepting_cpos);
    678680                yy_current_state = (yy_last_accepting_state);
     
    802804YY_RULE_SETUP
    803805#line 74 "easymesh/easymesh-scanner.l"
     806{ return token::T_CSGUNION; }
     807        YY_BREAK
     808case 23:
     809YY_RULE_SETUP
     810#line 75 "easymesh/easymesh-scanner.l"
     811{ return token::T_CSGSUBSTRACT; }
     812        YY_BREAK
     813case 24:
     814YY_RULE_SETUP
     815#line 76 "easymesh/easymesh-scanner.l"
     816{ return token::T_CSGAND; }
     817        YY_BREAK
     818case 25:
     819YY_RULE_SETUP
     820#line 77 "easymesh/easymesh-scanner.l"
     821{ return token::T_CSGXOR; }
     822        YY_BREAK
     823case 26:
     824YY_RULE_SETUP
     825#line 79 "easymesh/easymesh-scanner.l"
    804826{ return token::T_BOX; }
    805827        YY_BREAK
    806 case 23:
    807 YY_RULE_SETUP
    808 #line 75 "easymesh/easymesh-scanner.l"
     828case 27:
     829YY_RULE_SETUP
     830#line 80 "easymesh/easymesh-scanner.l"
    809831{ return token::T_CYLINDER; }
    810832        YY_BREAK
    811 case 24:
    812 YY_RULE_SETUP
    813 #line 76 "easymesh/easymesh-scanner.l"
     833case 28:
     834YY_RULE_SETUP
     835#line 81 "easymesh/easymesh-scanner.l"
    814836{ return token::T_CAPSULE; }
    815837        YY_BREAK
    816 case 25:
    817 YY_RULE_SETUP
    818 #line 77 "easymesh/easymesh-scanner.l"
     838case 29:
     839YY_RULE_SETUP
     840#line 82 "easymesh/easymesh-scanner.l"
    819841{ return token::T_COG; }
    820842        YY_BREAK
    821 case 26:
    822 YY_RULE_SETUP
    823 #line 78 "easymesh/easymesh-scanner.l"
     843case 30:
     844YY_RULE_SETUP
     845#line 83 "easymesh/easymesh-scanner.l"
    824846{ return token::T_DISC; }
    825847        YY_BREAK
    826 case 27:
    827 YY_RULE_SETUP
    828 #line 79 "easymesh/easymesh-scanner.l"
     848case 31:
     849YY_RULE_SETUP
     850#line 84 "easymesh/easymesh-scanner.l"
    829851{ return token::T_EXPANDEDSTAR; }
    830852        YY_BREAK
    831 case 28:
    832 YY_RULE_SETUP
    833 #line 80 "easymesh/easymesh-scanner.l"
     853case 32:
     854YY_RULE_SETUP
     855#line 85 "easymesh/easymesh-scanner.l"
    834856{ return token::T_FLATCHAMFBOX; }
    835857        YY_BREAK
    836 case 29:
    837 YY_RULE_SETUP
    838 #line 81 "easymesh/easymesh-scanner.l"
     858case 33:
     859YY_RULE_SETUP
     860#line 86 "easymesh/easymesh-scanner.l"
    839861{ return token::T_QUAD; }
    840862        YY_BREAK
    841 case 30:
    842 YY_RULE_SETUP
    843 #line 82 "easymesh/easymesh-scanner.l"
     863case 34:
     864YY_RULE_SETUP
     865#line 87 "easymesh/easymesh-scanner.l"
    844866{ return token::T_STAR; }
    845867        YY_BREAK
    846 case 31:
    847 YY_RULE_SETUP
    848 #line 83 "easymesh/easymesh-scanner.l"
     868case 35:
     869YY_RULE_SETUP
     870#line 88 "easymesh/easymesh-scanner.l"
    849871{ return token::T_SMOOTHCHAMFBOX; }
    850872        YY_BREAK
    851 case 32:
    852 YY_RULE_SETUP
    853 #line 84 "easymesh/easymesh-scanner.l"
     873case 36:
     874YY_RULE_SETUP
     875#line 89 "easymesh/easymesh-scanner.l"
    854876{ return token::T_SPHERE; }
    855877        YY_BREAK
    856 case 33:
    857 YY_RULE_SETUP
    858 #line 85 "easymesh/easymesh-scanner.l"
     878case 37:
     879YY_RULE_SETUP
     880#line 90 "easymesh/easymesh-scanner.l"
    859881{ return token::T_TRIANGLE; }
    860882        YY_BREAK
    861 case 34:
    862 YY_RULE_SETUP
    863 #line 86 "easymesh/easymesh-scanner.l"
     883case 38:
     884YY_RULE_SETUP
     885#line 91 "easymesh/easymesh-scanner.l"
    864886{ return token::T_TORUS; }
    865887        YY_BREAK
    866 case 35:
    867 YY_RULE_SETUP
    868 #line 88 "easymesh/easymesh-scanner.l"
     888case 39:
     889YY_RULE_SETUP
     890#line 93 "easymesh/easymesh-scanner.l"
    869891{
    870892        uint32_t tmp = std::strtol(yytext + 1, NULL, 16);
     
    875897        return token::COLOR; }
    876898        YY_BREAK
    877 case 36:
    878 YY_RULE_SETUP
    879 #line 95 "easymesh/easymesh-scanner.l"
     899case 40:
     900YY_RULE_SETUP
     901#line 100 "easymesh/easymesh-scanner.l"
    880902{
    881903        uint32_t tmp = std::strtol(yytext + 1, NULL, 16);
     
    886908        return token::COLOR; }
    887909        YY_BREAK
    888 case 37:
    889 YY_RULE_SETUP
    890 #line 102 "easymesh/easymesh-scanner.l"
     910case 41:
     911YY_RULE_SETUP
     912#line 107 "easymesh/easymesh-scanner.l"
    891913{
    892914        yylval->u32val = 0xffu
     
    894916        return token::COLOR; }
    895917        YY_BREAK
    896 case 38:
    897 YY_RULE_SETUP
    898 #line 106 "easymesh/easymesh-scanner.l"
     918case 42:
     919YY_RULE_SETUP
     920#line 111 "easymesh/easymesh-scanner.l"
    899921{
    900922        yylval->u32val = (uint32_t)std::strtol(yytext + 1, NULL, 16);
    901923        return token::COLOR; }
    902924        YY_BREAK
    903 case 39:
    904 YY_RULE_SETUP
    905 #line 109 "easymesh/easymesh-scanner.l"
     925case 43:
     926YY_RULE_SETUP
     927#line 114 "easymesh/easymesh-scanner.l"
    906928{
    907929        yylval->fval = std::atof(yytext); return token::NUMBER; }
    908930        YY_BREAK
    909 case 40:
    910 YY_RULE_SETUP
    911 #line 111 "easymesh/easymesh-scanner.l"
     931case 44:
     932YY_RULE_SETUP
     933#line 116 "easymesh/easymesh-scanner.l"
    912934{ return token_type('-'); }
    913935        YY_BREAK
    914 case 41:
    915 YY_RULE_SETUP
    916 #line 112 "easymesh/easymesh-scanner.l"
     936case 45:
     937YY_RULE_SETUP
     938#line 117 "easymesh/easymesh-scanner.l"
    917939{ return token_type('['); }
    918940        YY_BREAK
    919 case 42:
    920 YY_RULE_SETUP
    921 #line 113 "easymesh/easymesh-scanner.l"
     941case 46:
     942YY_RULE_SETUP
     943#line 118 "easymesh/easymesh-scanner.l"
    922944{ return token_type(']'); }
    923945        YY_BREAK
    924 case 43:
    925 YY_RULE_SETUP
    926 #line 114 "easymesh/easymesh-scanner.l"
     946case 47:
     947YY_RULE_SETUP
     948#line 119 "easymesh/easymesh-scanner.l"
    927949{ /* ignore this */ }
    928950        YY_BREAK
    929 case 44:
    930 /* rule 44 can match eol */
    931 YY_RULE_SETUP
    932 #line 115 "easymesh/easymesh-scanner.l"
     951case 48:
     952/* rule 48 can match eol */
     953YY_RULE_SETUP
     954#line 120 "easymesh/easymesh-scanner.l"
    933955{ /* ignore this */ }
    934956        YY_BREAK
    935 case 45:
    936 YY_RULE_SETUP
    937 #line 116 "easymesh/easymesh-scanner.l"
     957case 49:
     958YY_RULE_SETUP
     959#line 121 "easymesh/easymesh-scanner.l"
    938960{ return token::T_ERROR; }
    939961        YY_BREAK
    940 case 46:
    941 YY_RULE_SETUP
    942 #line 118 "easymesh/easymesh-scanner.l"
     962case 50:
     963YY_RULE_SETUP
     964#line 123 "easymesh/easymesh-scanner.l"
    943965ECHO;
    944966        YY_BREAK
    945 #line 946 "generated/easymesh-scanner.cpp"
     967#line 968 "generated/easymesh-scanner.cpp"
    946968case YY_STATE_EOF(INITIAL):
    947969        yyterminate();
     
    13251347                        {
    13261348                        yy_current_state = (int) yy_def[yy_current_state];
    1327                         if ( yy_current_state >= 75 )
     1349                        if ( yy_current_state >= 81 )
    13281350                                yy_c = yy_meta[(unsigned int) yy_c];
    13291351                        }
     
    13531375                {
    13541376                yy_current_state = (int) yy_def[yy_current_state];
    1355                 if ( yy_current_state >= 75 )
     1377                if ( yy_current_state >= 81 )
    13561378                        yy_c = yy_meta[(unsigned int) yy_c];
    13571379                }
    13581380        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
    1359         yy_is_jam = (yy_current_state == 74);
     1381        yy_is_jam = (yy_current_state == 80);
    13601382
    13611383        return yy_is_jam ? 0 : yy_current_state;
     
    18441866#define YYTABLES_NAME "yytables"
    18451867
    1846 #line 118 "easymesh/easymesh-scanner.l"
     1868#line 123 "easymesh/easymesh-scanner.l"
    18471869
    18481870
  • trunk/src/lolcore.vcxproj

    r2225 r2226  
    241241    <ClCompile Include="debug\stats.cpp" />
    242242    <ClCompile Include="dict.cpp" />
     243    <ClCompile Include="easymesh\csgbsp.cpp" />
    243244    <ClCompile Include="easymesh\easymesh-compiler.cpp" />
    244245    <ClCompile Include="easymesh\easymesh.cpp" />
     
    556557    <ClInclude Include="debug\stats.h" />
    557558    <ClInclude Include="dict.h" />
     559    <ClInclude Include="easymesh\csgbsp.h" />
    558560    <ClInclude Include="easymesh\easymesh-compiler.h" />
    559561    <ClInclude Include="easymesh\easymesh.h" />
  • trunk/src/lolcore.vcxproj.filters

    r2225 r2226  
    658658      <Filter>math</Filter>
    659659    </ClCompile>
     660    <ClCompile Include="easymesh\csgbsp.cpp">
     661      <Filter>easymesh</Filter>
     662    </ClCompile>
    660663  </ItemGroup>
    661664  <ItemGroup>
     
    16341637    <ClInclude Include="lol\math\geometry.h">
    16351638      <Filter>lol\math</Filter>
     1639    </ClInclude>
     1640    <ClInclude Include="easymesh\csgbsp.h">
     1641      <Filter>easymesh</Filter>
    16361642    </ClInclude>
    16371643  </ItemGroup>
  • trunk/tutorial/05_easymesh.cpp

    r2183 r2226  
    22// Lol Engine - EasyMesh tutorial
    33//
    4 // Copyright: (c) 2011-2012 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2011-2013 Sam Hocevar <sam@hocevar.net>
     5//            (c) 2012-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
    56//   This program is free software; you can redistribute it and/or
    67//   modify it under the terms of the Do What The Fuck You Want To
     
    2930        m_gears.Push(EasyMesh(), mat4(1.0f), 180.0f / 18);
    3031
    31         m_gears[0].m1.Compile("sc#f9f scb#f9f acg 12 10 5 5 20 20 5 5 0.1 0 s .1 .1 .1");
     32        m_gears[0].m1.Compile("[sc#00f ab 8 1 8 ty -.25]\
     33                              [sc#f9f scb#f9f acg 12 10 5 5 20 20 5 5 0.1 0 s .1 .1 .1 ty -.1 csgu]\
     34                              [sc#fff scb#000 acg 12 10 10 10 20 20 5 5 0.1 0 s .05 .05 .05 tx -1.5 ty .3 csgu]\
     35                              [sc#00f ab 5 3 9 tx 2.5 csgs]\
     36                              [[ sc#fff ab 3   1.4 2   tx -2 tz -2 \
     37                               [sc#fff ab 2.1  .7 1.1 ty .5 tx -1.4 tz -1.4 csgs] mz] csgu] \
     38                              ");
     39        //m_gears[0].m1.Compile("[sc#f9f scb#f9f acg 12 10 5 5 20 20 5 5 0.1 0 s .1 .1 .1 [sc#00f ab 3 1 2 ty .25 tx 1 csgs]]");
    3240        m_gears[1].m1.Compile("sc#ff9 scb#ff9 acg 54 10 95 95 90 90 -5 -5 0.1 0 s .1 .1 .1");
    33         m_gears[2].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1");
    34         m_gears[3].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1");
    35         m_gears[4].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1");
     41        //m_gears[2].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]");
     42        //m_gears[3].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]");
     43        //m_gears[4].m1.Compile("sc#9ff scb#9ff acg 18 10 5 5 30 30 5 5 0.1 0 s .1 .1 .1 [sc#00f scb#00f ab 2 2 2 tx 1.5]");
     44        m_gears[2].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csgu]]");
     45        m_gears[3].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csgs]]");
     46        m_gears[4].m1.Compile("[sc#0f0 ab 2 2 2 t .8 .8 .8 rx 20 ry 20 [sc#00f ab 2 2 2 tx 0 csga]]");
    3647
    3748        m_angle = 0;
     
    4051                              vec3(0.f, 0.f, 0.f),
    4152                              vec3(0, 1, 0));
    42         m_camera->SetPerspective(70.f, 960.f, 600.f, .1f, 1000.f);
     53        m_camera->SetPerspective(30.f, 960.f, 600.f, .1f, 1000.f);
    4354        m_camera->SetTarget(vec3(0.f, -1.f, 0.f));
    44         m_camera->SetPosition(vec3(-15.f, 10.f, 0.f));
     55        m_camera->SetPosition(vec3(-15.f, 5.f, 0.f));
    4556        Ticker::Ref(m_camera);
    4657
     
    5970        m_angle += seconds * 70.0f;
    6071        m_mat = mat4::rotate(10.0f, vec3(0, 0, 1))
    61               * mat4::rotate(m_angle, vec3(0, 1, 0));
     72                * mat4::rotate(100, vec3(0, 1, 0));
     73        //      * mat4::rotate(m_angle, vec3(0, 1, 0));
    6274
    63         m_gears[0].m3 += seconds * 150.0f;
    64         m_gears[1].m3 += seconds * 150.0f * -2 / 9;
    65         m_gears[2].m3 += seconds * 150.0f * -2 / 3;
    66         m_gears[3].m3 += seconds * 150.0f * -2 / 3;
    67         m_gears[4].m3 += seconds * 150.0f * -2 / 3;
     75        m_gears[0].m3 += seconds * 20.0f;
     76        m_gears[1].m3 += seconds * 20.0f * -2 / 9;
     77        m_gears[2].m3 += seconds * 20.0f * -2 / 3;
     78        m_gears[3].m3 += seconds * 20.0f * -2 / 3;
     79        m_gears[4].m3 += seconds * 20.0f * -2 / 3;
    6880
    69         m_gears[0].m2 = mat4::translate(vec3(0, 0, 0))
    70                       * mat4::rotate(m_gears[0].m3, vec3(0, 1, 0));
     81        m_gears[0].m2 = mat4::translate(vec3(0, -1, 0))
     82                      * mat4::rotate(m_gears[0].m3 - 130.0f, vec3(0, 1, 0))
     83                      * mat4::rotate(40.0f, vec3(0, 0, 1));
    7184        m_gears[1].m2 = mat4::translate(vec3(0, 0, 0))
    7285                      * mat4::rotate(m_gears[1].m3, vec3(0, 1, 0));
    7386        m_gears[2].m2 = mat4::translate(vec3(0, 0, 5.5f))
    74                       * mat4::rotate(m_gears[2].m3, vec3(0, 1, 0));
     87                      * mat4::rotate(m_gears[2].m3 - 40.0f, vec3(0, 1, 0))
     88                      * mat4::rotate(90.0f, vec3(0, 0, 1));
    7589        m_gears[3].m2 = mat4::translate(vec3(5.5f * lol::sqrt(3.f) * 0.5f, 0, -5.5f * 0.5f))
    76                       * mat4::rotate(m_gears[3].m3, vec3(0, 1, 0));
     90                      * mat4::rotate(m_gears[3].m3 - 140.0f, vec3(0, 1, 0))
     91                      * mat4::rotate(-70.0f, vec3(0, 0, 1));
    7792        m_gears[4].m2 = mat4::translate(vec3(-5.5f * lol::sqrt(3.f) * 0.5f, 0, -5.5f * 0.5f))
    78                       * mat4::rotate(m_gears[4].m3, vec3(0, 1, 0));
     93                      * mat4::rotate(m_gears[4].m3 - 80.0f, vec3(0, 1, 0));
    7994    }
    8095
Note: See TracChangeset for help on using the changeset viewer.