diff --git a/src/easymesh/easymesh-parser.y b/src/easymesh/easymesh-parser.y index b31a4139..6878f1a3 100644 --- a/src/easymesh/easymesh-parser.y +++ b/src/easymesh/easymesh-parser.y @@ -147,14 +147,16 @@ transform_command: primitive_command: T_CYLINDER args6 { mc.m_mesh.AppendCylinder((int)$2.f0, $2.f1, $2.f2, $2.f3, - (int)$2.f4, (int)$2.f5); } + (int)$2.f4, (int)$2.f5, 0); } + | T_CYLINDER args7 { mc.m_mesh.AppendCylinder((int)$2.f0, $2.f1, + $2.f2, $2.f3, + (int)$2.f4, (int)$2.f5, (int)$2.f6); } | T_BOX args3 { mc.m_mesh.AppendBox(vec3($2.f0, $2.f1, $2.f2)); } | T_SMOOTHCHAMFBOX args4 { mc.m_mesh.AppendSmoothChamfBox(vec3($2.f0, $2.f1, $2.f2), $2.f3); } | T_FLATCHAMFBOX args4 { mc.m_mesh.AppendFlatChamfBox(vec3($2.f0, $2.f1, $2.f2), $2.f3); } - | T_SPHERE args4 { mc.m_mesh.AppendSphere($2.f0, - vec3($2.f1, $2.f2, $2.f3)); } + | T_SPHERE args2 { mc.m_mesh.AppendSphere($2.f0, $2.f1); } | T_CAPSULE args3 { mc.m_mesh.AppendCapsule($2.f0, $2.f1, $2.f2); } | T_TORUS args3 { mc.m_mesh.AppendTorus((int)$2.f0, $2.f1, $2.f2); } | T_STAR args5 { mc.m_mesh.AppendStar((int)$2.f0, $2.f1, $2.f2, diff --git a/src/easymesh/easymesh.cpp b/src/easymesh/easymesh.cpp index 2c7d009a..06daf25b 100644 --- a/src/easymesh/easymesh.cpp +++ b/src/easymesh/easymesh.cpp @@ -47,7 +47,8 @@ namespace lol //----------------------------------------------------------------------------- EasyMesh::EasyMesh() - : m_color(0), m_color2(0), m_ignore_winding_on_scale(0) + : m_color(0), m_color2(0), m_ignore_winding_on_scale(0), + m_texcoord_offset(vec2(.0f)), m_texcoord_scale(vec2(1.f)) { m_cursors.Push(0, 0); } @@ -478,7 +479,7 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) //csgs : CSGSubstractLoss() -> m0_Outside (csg_operation == CSGUsage::SubstractLoss && ((mesh_id == 0 && tri_list[k].m1 == LEAF_BACK) || mesh_id == 1)) || - //csga : CSGAnd() -> Inside + Inside + //csga : CSGAnd() -> m0_Inside + m1_Inside (csg_operation == CSGUsage::And && tri_list[k].m1 == LEAF_FRONT)) { triangle_to_kill.Push(tri_idx); @@ -487,7 +488,7 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) //Triangle Invert Test if (//csgs : CSGSubstract() -> m0_Outside + m1_Inside-inverted (csg_operation == CSGUsage::Substract && mesh_id == 1 && tri_list[k].m1 == LEAF_BACK) || - //csgx : CSGXor() -> Outside/Inside-inverted + Outside/Inside-inverted + //csgx : CSGXor() -> m0_Outside/m0_Inside-inverted + m1_Outside/m1_Inside-inverted (csg_operation == CSGUsage::Xor && tri_list[k].m1 == LEAF_BACK)) { //a Xor means we will share vertices with the outside, so duplicate the vertices. @@ -546,7 +547,6 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) //DONE for the splitting ! } - //----------------------------------------------------------------------------- void EasyMesh::ToggleScaleWinding() { @@ -749,7 +749,7 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) vec3 v02 = m_vert[v[2]].m1 - m_vert[v[0]].m1; vec3 v_dir = normalize(cross(m_vert[m_indices[cur_tri]].m2, v01)); vec2 texu_dir = uv[1] - uv[0]; - vec2 texv_dir = vec2(texu_dir.y, -texu_dir.x); + vec2 texv_dir = vec2(texu_dir.y, texu_dir.x); //Final calculations uv[2] = texu_dir * dot(v01, v02) + texv_dir * dot(v_dir, v02); @@ -776,7 +776,7 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) //Get connected triangles and go from there. for (int j = 0; j < 3; j++) { -#if 0 +#if 1 //This finds triangle that are connected to this triangle vert_dict.FindConnectedTriangles(ivec2(v[j], v[(j + 1) % 3]), tri_list, tri_check, &tri_done); #else @@ -787,6 +787,17 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) } else if (uv_set == 3) { + for (int j = 0; j < 3; j++) + { + m_vert[tri_list[cur_tri]].m4 = vec2(-1.0f); + m_vert[tri_list[cur_tri + 1]].m4 = vec2(-1.0f); + m_vert[tri_list[cur_tri + 2]].m4 = vec2(-1.0f); + } + + //uv[0] = vec2(-1.0f); + //uv[1] = vec2(-1.0f); + //uv[2] = vec2(-1.0f); + /* bool tri_present = false; for (int j = 0; j < tri_done.Count(); j++) if (cur_tri == tri_done[j]) @@ -794,6 +805,7 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) if (!tri_present) tri_done << cur_tri; tri_check.Remove(0); + */ } if (tri_check.Count() == 0 && tri_done.Count() != tri_count) @@ -820,6 +832,13 @@ void EasyMesh::SetVertColor(vec4 const &color) m_vert[i].m3 = color; } +//----------------------------------------------------------------------------- +void EasyMesh::SetTexCoordData(vec2 const &new_offset, vec2 const &new_scale) +{ + m_texcoord_offset = new_offset; + m_texcoord_scale = new_scale; +} + //----------------------------------------------------------------------------- void EasyMesh::SetCurVertNormal(vec3 const &normal) { @@ -832,6 +851,15 @@ void EasyMesh::SetCurVertColor(vec4 const &color) m_vert[m_vert.Count() - 1].m3 = color; } +//----------------------------------------------------------------------------- +void EasyMesh::SetCurVertTexCoord(vec2 const &texcoord) +{ +#if VERTEX_USEAGE == VU_BONES +#elif VERTEX_USEAGE == VU_TEX_UV + m_vert[m_vert.Count() - 1].m4 = (texcoord * m_texcoord_scale) + m_texcoord_offset; +#endif +} + //----------------------------------------------------------------------------- void EasyMesh::Translate(vec3 const &v) { @@ -840,14 +868,14 @@ void EasyMesh::Translate(vec3 const &v) } //----------------------------------------------------------------------------- -void EasyMesh::RotateX(float t) { Rotate(t, vec3(1, 0, 0)); } -void EasyMesh::RotateY(float t) { Rotate(t, vec3(0, 1, 0)); } -void EasyMesh::RotateZ(float t) { Rotate(t, vec3(0, 0, 1)); } +void EasyMesh::RotateX(float angle) { Rotate(angle, vec3(1, 0, 0)); } +void EasyMesh::RotateY(float angle) { Rotate(angle, vec3(0, 1, 0)); } +void EasyMesh::RotateZ(float angle) { Rotate(angle, vec3(0, 0, 1)); } //----------------------------------------------------------------------------- -void EasyMesh::Rotate(float t, vec3 const &axis) +void EasyMesh::Rotate(float angle, vec3 const &axis) { - mat3 m = mat3::rotate(t, axis); + mat3 m = mat3::rotate(angle, axis); for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) { m_vert[i].m1 = m * m_vert[i].m1; @@ -906,8 +934,8 @@ void EasyMesh::TaperX(float y, float z, float xoff) /* FIXME: this code breaks normals! */ for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) { - m_vert[i].m1.y *= 1.f + (y * m_vert[i].m1.x + xoff); - m_vert[i].m1.z *= 1.f + (z * m_vert[i].m1.x + xoff); + m_vert[i].m1.y *= 1.f + (y * abs(m_vert[i].m1.x) + xoff); + m_vert[i].m1.z *= 1.f + (z * abs(m_vert[i].m1.x) + xoff); } } @@ -916,8 +944,8 @@ void EasyMesh::TaperY(float x, float z, float yoff) { for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) { - m_vert[i].m1.x *= 1.f + (x * m_vert[i].m1.y + yoff); - m_vert[i].m1.z *= 1.f + (z * m_vert[i].m1.y + yoff); + m_vert[i].m1.x *= 1.f + (x * abs(m_vert[i].m1.y) + yoff); + m_vert[i].m1.z *= 1.f + (z * abs(m_vert[i].m1.y) + yoff); } } @@ -926,8 +954,8 @@ void EasyMesh::TaperZ(float x, float y, float zoff) { for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) { - m_vert[i].m1.x *= 1.f + (x * m_vert[i].m1.z + zoff); - m_vert[i].m1.y *= 1.f + (y * m_vert[i].m1.z + zoff); + m_vert[i].m1.x *= 1.f + (x * abs(m_vert[i].m1.z) + zoff); + m_vert[i].m1.y *= 1.f + (y * abs(m_vert[i].m1.z) + zoff); } } @@ -979,12 +1007,21 @@ void EasyMesh::DupAndScale(vec3 const &s) //----------------------------------------------------------------------------- void EasyMesh::AppendCylinder(int nsides, float h, float r1, float r2, - int dualside, int smooth) + int dualside, int smooth, int close) { + //SAVE + vec4 Saved_Color = m_color; + vec4 Saved_Color2 = m_color2; + vec2 Save_texcoord_offset = m_texcoord_offset; + vec2 Save_texcoord_scale = m_texcoord_scale; + int vbase = m_vert.Count(); - mat3 rotmat = mat3::rotate(360.0f / nsides, 0.f, 1.f, 0.f); + mat3 rotmat = mat3::rotate(360.0f / (float)nsides, 0.f, 1.f, 0.f); vec3 p1(r1, -h * .5f, 0.f), p2(r2, h * .5f, 0.f), n; + vec2 uv1(.0f, .0f), uv2(.0f, 1.0f), uvadd(1.0f / (float)nsides, .0f); + if (close) + SetTexCoordData(vec2(.0f), vec2(1.0f, .5f)); /* Construct normal */ if (r2 != .0f) @@ -1000,8 +1037,8 @@ void EasyMesh::AppendCylinder(int nsides, float h, float r1, float r2, * means duplicating the vertices again... */ for (int i = 0; i < nsides; i++) { - AddVertex(p1); SetCurVertNormal(n); - AddVertex(p2); SetCurVertNormal(n); + AddVertex(p1); SetCurVertNormal(n); SetCurVertTexCoord(uv1); + AddVertex(p2); SetCurVertNormal(n); SetCurVertTexCoord(uv2); SetCurVertColor(m_color2); if (smooth) @@ -1012,13 +1049,13 @@ void EasyMesh::AppendCylinder(int nsides, float h, float r1, float r2, AppendQuad(i * 2, i * 2 + 1, j * 2 + 1, j * 2, vbase); } - p1 = rotmat * p1; - p2 = rotmat * p2; + p1 = rotmat * p1; uv1 += uvadd; + p2 = rotmat * p2; uv2 += uvadd; if (!smooth) { - AddVertex(p1); SetCurVertNormal(n); - AddVertex(p2); SetCurVertNormal(n); + AddVertex(p1); SetCurVertNormal(n); SetCurVertTexCoord(uv1); + AddVertex(p2); SetCurVertNormal(n); SetCurVertTexCoord(uv2); SetCurVertColor(m_color2); AppendQuad(i * 4 + 2, i * 4 + 3, i * 4 + 1, i * 4, vbase); @@ -1028,6 +1065,34 @@ void EasyMesh::AppendCylinder(int nsides, float h, float r1, float r2, n = rotmat * n; } + + if (close) + { + //START + OpenBrace(); + //LOWER DISC + SetTexCoordData(vec2(.0f, .5f), vec2(.5f, .5f)); + SetCurColor(m_color); + AppendDisc(nsides, r1); + Translate(vec3(.0f, h, .0f)); + RotateX(180.0f); + //UPPER DISC + SetTexCoordData(vec2(.5f, .5f), vec2(.5f, .5f)); + SetCurColor(m_color2); + AppendDisc(nsides, r2); + Translate(vec3(.0f, h * .5f, .0f)); + CloseBrace(); + } + //RESTORE + SetCurColor(Saved_Color); + SetCurColor2(Saved_Color2); + SetTexCoordData(Save_texcoord_offset, Save_texcoord_scale); +} + +//----------------------------------------------------------------------------- +void EasyMesh::AppendSphere(int ndivisions, float r) +{ + AppendCapsule(ndivisions, 0.f, r); } //----------------------------------------------------------------------------- @@ -1036,11 +1101,18 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float r) int ibase = m_indices.Count(); Array vertices; + float uv_h = 0; + float uv_r = 0; /* FIXME: we don't know how to handle even-divided capsules, so we * force the count to be odd. */ if (h) + { ndivisions |= 1; + //calculate uv h&r percents + uv_h = (float)h / (float)(h + r * 2); + uv_r = (float)r / (float)(h + r * 2); + } /* Fill in the icosahedron vertices, rotating them so that there * is a vertex at [0 1 0] and [0 -1 0] after normalisation. */ @@ -1083,14 +1155,31 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float r) p[0] + vb, p[0] + vc, p[0] + vb + vc }; + vec2 uv[4]; /* FIXME: when we normalise here, we get a volume that is slightly * smaller than the sphere of radius 1, since we are not using * the midradius. */ for (int k = 0; k < 4; k++) - p[k] = normalize(p[k]) * r; + { + //keep normalized until the end of the UV calculations + p[k] = normalize(p[k]); + + uv[k].x = (lol::atan2(p[k].z, p[k].x) + (float)M_PI) / ((float)M_PI * 2.f); + if (abs(p[k].y) >= 1.0f) + uv[k].x = -1.f; + uv[k].y = (lol::atan2(p[k].y, dot(p[k], normalize(p[k] * vec3(1.f,0.f,1.f)))) + (float)M_PI_2) / (float)M_PI; + if (h) + { + if (uv[k].y > .5f) + uv[k].y = uv_r + uv_h + (uv[k].y - .5f) * uv_r * 2.f; + else + uv[k].y *= uv_r * 2.f; + } + p[k] *= r; + } - /* If this is a capsule, grow in the Z direction */ + /* If this is a capsule, grow in the Y direction */ if (h > 0.f) { for (int k = 0; k < 4; k++) @@ -1098,20 +1187,40 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float r) } /* Add zero, one or two triangles */ - if (y < line - 1) - { - AddVertex(p[0]); - AddVertex(p[1]); - AddVertex(p[2]); - AppendTriangle(0, 2, 1, m_vert.Count() - 3); - } - - if (y < line - 2) + int id[] = { 0, 1, 2, + 1, 3 ,2 }; + int l = 6; + while ((l -= 3) >= 0) { - AddVertex(p[1]); - AddVertex(p[3]); - AddVertex(p[2]); - AppendTriangle(0, 2, 1, m_vert.Count() - 3); + if ((l == 0 && y < line - 1) || (l == 3 && y < line - 2)) + { + int k = -1; + while (++k < 3) + { + int rid[] = { id[k + l], id[(k + 1) % 3 + l] }; + if (uv[rid[0]].x >= .0f && + uv[rid[1]].x >= .0f && + abs(uv[rid[0]].x - uv[rid[1]].x) > .5f) + { + if (uv[rid[0]].x < uv[rid[1]].x) + uv[rid[0]].x += 1.0f; + else + uv[rid[1]].x += 1.0f; + } + } + k = -1; + while (++k < 3) + { + int rid[] = { id[k + l], id[(k + 1) % 3 + l], id[(k + 2) % 3 + l] }; + AddVertex(p[rid[0]]); + if (uv[rid[0]].x < .0f) + SetCurVertTexCoord(vec2((uv[rid[1]].x + uv[rid[2]].x) * .5f, + uv[rid[0]].y)); + else + SetCurVertTexCoord(uv[rid[0]]); + } + AppendTriangle(0, 2, 1, m_vert.Count() - 3); + } } y++; @@ -1127,15 +1236,6 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float r) ComputeNormals(ibase, m_indices.Count() - ibase); } -//----------------------------------------------------------------------------- -void EasyMesh::AppendSphere(int ndivisions, vec3 const &size) -{ - OpenBrace(); - AppendCapsule(ndivisions, 0.f, 1.f); - Scale(size); - CloseBrace(); -} - //----------------------------------------------------------------------------- void EasyMesh::AppendTorus(int ndivisions, float r1, float r2) { @@ -1151,16 +1251,22 @@ void EasyMesh::AppendTorus(int ndivisions, float r1, float r2) { int i2 = (i + di) % nidiv; int j2 = (j + dj) % njdiv; - float x = 0.5f * (r1 + r2) + 0.5f * (r2 - r1) * (float)lol::cos(2.0 * M_PI * i2 / nidiv); + + //Location on the donut + float x = 0.5f * (r2 - r1) * (float)lol::cos(2.0 * M_PI * i2 / nidiv) + 0.5f * (r1 + r2); float y = 0.5f * (r2 - r1) * (float)lol::sin(2.0 * M_PI * i2 / nidiv); float z = 0.0f; + //Center circle float ca = (float)lol::cos(2.0 * M_PI * j2 / njdiv); float sa = (float)lol::sin(2.0 * M_PI * j2 / njdiv); + + //Actual location float x2 = x * ca - z * sa; float z2 = z * ca + x * sa; AddVertex(vec3(x2, y, z2)); + SetCurVertTexCoord(vec2((float)(i + di) / (float)nidiv, (float)(j + dj) / (float)nidiv)); } AppendTriangle(0, 2, 3, m_vert.Count() - 4); @@ -1202,35 +1308,62 @@ void EasyMesh::AppendBox(vec3 const &size, float chamf, bool smooth) vec3 d = size * 0.5f; + //Side vertices AddVertex(vec3(-d.x, -d.y, -d.z - chamf)); + SetCurVertTexCoord(vec2(0.f, .5f)); AddVertex(vec3(-d.x, +d.y, -d.z - chamf)); + SetCurVertTexCoord(vec2(0.f, 0.f)); AddVertex(vec3(+d.x, +d.y, -d.z - chamf)); + SetCurVertTexCoord(vec2(.5f, 0.f)); AddVertex(vec3(+d.x, -d.y, -d.z - chamf)); + SetCurVertTexCoord(vec2(.5f, .5f)); AddVertex(vec3(-d.x - chamf, -d.y, +d.z)); + SetCurVertTexCoord(vec2(.5f, 0.5f)); AddVertex(vec3(-d.x - chamf, +d.y, +d.z)); + SetCurVertTexCoord(vec2(.5f, 0.f)); AddVertex(vec3(-d.x - chamf, +d.y, -d.z)); + SetCurVertTexCoord(vec2(1.f, 0.f)); AddVertex(vec3(-d.x - chamf, -d.y, -d.z)); + SetCurVertTexCoord(vec2(1.f, .5f)); AddVertex(vec3(+d.x, -d.y, +d.z + chamf)); + SetCurVertTexCoord(vec2(0.f, .5f)); AddVertex(vec3(+d.x, +d.y, +d.z + chamf)); + SetCurVertTexCoord(vec2(0.f, 0.f)); AddVertex(vec3(-d.x, +d.y, +d.z + chamf)); + SetCurVertTexCoord(vec2(.5f, 0.f)); AddVertex(vec3(-d.x, -d.y, +d.z + chamf)); + SetCurVertTexCoord(vec2(.5f, .5f)); AddVertex(vec3(+d.x + chamf, -d.y, -d.z)); + SetCurVertTexCoord(vec2(.5f, .5f)); AddVertex(vec3(+d.x + chamf, +d.y, -d.z)); + SetCurVertTexCoord(vec2(.5f, .0f)); AddVertex(vec3(+d.x + chamf, +d.y, +d.z)); + SetCurVertTexCoord(vec2(1.f, .0f)); AddVertex(vec3(+d.x + chamf, -d.y, +d.z)); + SetCurVertTexCoord(vec2(1.f, .5f)); + //Bottom vertices AddVertex(vec3(-d.x, -d.y - chamf, +d.z)); + SetCurVertTexCoord(vec2(0.f, 1.f)); AddVertex(vec3(-d.x, -d.y - chamf, -d.z)); + SetCurVertTexCoord(vec2(0.f, .5f)); AddVertex(vec3(+d.x, -d.y - chamf, -d.z)); + SetCurVertTexCoord(vec2(.5f, .5f)); AddVertex(vec3(+d.x, -d.y - chamf, +d.z)); + SetCurVertTexCoord(vec2(.5f, 1.f)); + //Top vertices AddVertex(vec3(-d.x, +d.y + chamf, -d.z)); + SetCurVertTexCoord(vec2(0.f, 1.f)); AddVertex(vec3(-d.x, +d.y + chamf, +d.z)); + SetCurVertTexCoord(vec2(0.f, .5f)); AddVertex(vec3(+d.x, +d.y + chamf, +d.z)); + SetCurVertTexCoord(vec2(.5f, .5f)); AddVertex(vec3(+d.x, +d.y + chamf, -d.z)); + SetCurVertTexCoord(vec2(.5f, 1.f)); /* The 6 quads on each side of the box */ for (int i = 0; i < 24; i += 4) @@ -1288,31 +1421,35 @@ void EasyMesh::AppendBox(vec3 const &size, float chamf, bool smooth) void EasyMesh::AppendStar(int nbranches, float r1, float r2, int fade, int fade2) { + //TODO: It would probably be good to think of another way of UV painting this, like "branch repeating" int vbase = m_vert.Count(); + float maxr = max(r1, r2); - AddVertex(vec3(0.f, 0.f, 0.f)); + AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); mat3 rotmat = mat3::rotate(180.0f / nbranches, 0.f, 1.f, 0.f); vec3 p1(r1, 0.f, 0.f), p2(r2, 0.f, 0.f); + vec3 uv1(0.f, 0.f, -.5f * ((float)r1 / maxr)), + uv2(0.f, 0.f, -.5f * ((float)r2 / maxr)); - p2 = rotmat * p2; + p2 = rotmat * p2; uv2 = rotmat * uv2; rotmat = rotmat * rotmat; for (int i = 0; i < nbranches; i++) { - AddVertex(p1); + AddVertex(p1); SetCurVertTexCoord(uv1.xz + vec2(.5f)); if (fade2) SetCurVertColor(m_color2); - AddVertex(p2); + AddVertex(p2); SetCurVertTexCoord(uv2.xz + vec2(.5f)); if (fade) SetCurVertColor(m_color2); AppendQuad(0, 2 * i + 1, 2 * i + 2, (2 * i + 3) % (2 * nbranches), vbase); - p1 = rotmat * p1; - p2 = rotmat * p2; + p1 = rotmat * p1; uv1 = rotmat * uv1; + p2 = rotmat * p2; uv2 = rotmat * uv2; } } @@ -1321,33 +1458,38 @@ void EasyMesh::AppendExpandedStar(int nbranches, float r1, float r2, float extrar) { int vbase = m_vert.Count(); + float maxr = (float)max(max(r1, r2), max(r1 + extrar, r2 + extrar)); - AddVertex(vec3(0.f, 0.f, 0.f)); + AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); mat3 rotmat = mat3::rotate(180.0f / nbranches, 0.f, 1.f, 0.f); vec3 p1(r1, 0.f, 0.f), p2(r2, 0.f, 0.f), p3(r1 + extrar, 0.f, 0.f), p4(r2 + extrar, 0.f, 0.f);; + vec3 uv1(0.f, 0.f, -.5f * ((float)r1 / maxr)), + uv2(0.f, 0.f, -.5f * ((float)r2 / maxr)), + uv3(0.f, 0.f, -.5f * ((float)(r1 + extrar) / maxr)), + uv4(0.f, 0.f, -.5f * ((float)(r2 + extrar) / maxr)); - p2 = rotmat * p2; - p4 = rotmat * p4; + p2 = rotmat * p2; uv2 = rotmat * uv2; + p4 = rotmat * p4; uv4 = rotmat * uv4; rotmat = rotmat * rotmat; for (int i = 0; i < nbranches; i++) { - AddVertex(p1); - AddVertex(p2); - AddVertex(p3); SetCurVertColor(m_color2); - AddVertex(p4); SetCurVertColor(m_color2); + AddVertex(p1); SetCurVertTexCoord(uv1.xz + vec2(.5f)); + AddVertex(p2); SetCurVertTexCoord(uv2.xz + vec2(.5f)); + AddVertex(p3); SetCurVertTexCoord(uv3.xz + vec2(.5f)); SetCurVertColor(m_color2); + AddVertex(p4); SetCurVertTexCoord(uv4.xz + vec2(.5f)); SetCurVertColor(m_color2); int j = (i + 1) % nbranches; AppendQuad(0, 4 * i + 1, 4 * i + 2, 4 * j + 1, vbase); AppendQuad(4 * i + 1, 4 * i + 3, 4 * i + 4, 4 * i + 2, vbase); AppendQuad(4 * j + 1, 4 * i + 2, 4 * i + 4, 4 * j + 3, vbase); - p1 = rotmat * p1; - p2 = rotmat * p2; - p3 = rotmat * p3; - p4 = rotmat * p4; + p1 = rotmat * p1; uv1 = rotmat * uv1; + p2 = rotmat * p2; uv2 = rotmat * uv2; + p3 = rotmat * p3; uv3 = rotmat * uv3; + p4 = rotmat * p4; uv4 = rotmat * uv4; } } @@ -1356,18 +1498,20 @@ void EasyMesh::AppendDisc(int nsides, float r, int fade) { int vbase = m_vert.Count(); - AddVertex(vec3(0.f, 0.f, 0.f)); + AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); mat3 rotmat = mat3::rotate(360.0f / nsides, 0.f, 1.f, 0.f); vec3 p1(r, 0.f, 0.f); + vec3 uv(.5f, .0f, .0f); for (int i = 0; i < nsides; i++) { - AddVertex(p1); + AddVertex(p1); SetCurVertTexCoord(uv.xz + vec2(.5f, .5f)); if (fade) SetCurVertColor(m_color2); AppendTriangle(0, i + 1, ((i + 1) % nsides) + 1, vbase); p1 = rotmat * p1; + uv = rotmat * uv; } } @@ -1377,13 +1521,13 @@ void EasyMesh::AppendSimpleTriangle(float size, int fade) mat3 m = mat3::rotate(120.f, 0.f, 1.f, 0.f); vec3 p(0.f, 0.f, size); - AddVertex(p); + AddVertex(p); SetCurVertTexCoord(vec2(.5f, 0.133975f)); p = m * p; - AddVertex(p); + AddVertex(p); SetCurVertTexCoord(vec2(1.f, 1.f)); if (fade) SetCurVertColor(m_color2); p = m * p; - AddVertex(p); + AddVertex(p); SetCurVertTexCoord(vec2(0.f, 1.f)); if (fade) SetCurVertColor(m_color2); @@ -1399,16 +1543,16 @@ void EasyMesh::AppendSimpleQuad(float size, int fade) //----------------------------------------------------------------------------- void EasyMesh::AppendSimpleQuad(vec2 p1, vec2 p2, float z, int fade) { - AddVertex(vec3(p2.x, z, -p1.y)); - AddVertex(vec3(p2.x, z, -p2.y)); - AddVertex(vec3(p1.x, z, -p2.y)); + AddVertex(vec3(p2.x, z, -p1.y)); SetCurVertTexCoord(vec2(0.f, 1.f)); + AddVertex(vec3(p2.x, z, -p2.y)); SetCurVertTexCoord(vec2(0.f, 0.f)); + AddVertex(vec3(p1.x, z, -p2.y)); SetCurVertTexCoord(vec2(1.f, 0.f)); if (fade) SetCurVertColor(m_color2); - AddVertex(vec3(p1.x, z, -p1.y)); + AddVertex(vec3(p1.x, z, -p1.y)); SetCurVertTexCoord(vec2(1.f, 1.f)); if (fade) SetCurVertColor(m_color2); - AppendQuad(3, 2, 1, 0, m_vert.Count() - 4); + AppendQuad(0, 1, 2, 3, m_vert.Count() - 4); ComputeNormals(m_indices.Count() - 6, 6); } @@ -1430,6 +1574,7 @@ void EasyMesh::AppendCog(int nbsides, float h, float r10, float r20, vec3 p[12]; + //Upper points p[0] = vec3(r10, h * .5f, 0.f); p[1] = rotmat * p[0]; p[2] = vec3(r1, h * .5f, 0.f); @@ -1437,6 +1582,7 @@ void EasyMesh::AppendCog(int nbsides, float h, float r10, float r20, p[4] = smat1 * (rotmat * vec3(r1 + r12, h * .5f, 0.f)); p[5] = smat2 * (rotmat * p[4]); + //Lower points p[6] = vec3(r20, h * -.5f, 0.f); p[7] = rotmat * p[6]; p[8] = vec3(r2, h * -.5f, 0.f); @@ -1450,37 +1596,199 @@ void EasyMesh::AppendCog(int nbsides, float h, float r10, float r20, rotmat = rotmat * rotmat; + //UV base computation + float maxr = max(max(r1 + r12, r2 + r22), max(r10, r20)); + float InLn = length(p[1] - p[0]); + float CogLn[8] = { .0f, .0f, .0f, .0f, .0f, .0f, .0f, .0f }; + for (int i = 0; i < 3; i++) + { + for (int j = 0, k = 2; j < 8 && k < 12; j += 4, k += 6) + { + CogLn[j + i] = length(p[k + i + 1] - p[k + i]); + CogLn[j + 3] += CogLn[j + i]; + if (i == 1) //Add 3to4 twice since it's automatically completed by +1 loop. + CogLn[j + 3] += CogLn[j + i]; + } + } + + //Choose the biggest cog length + int CogSrc = (CogLn[7] > CogLn[3])?(4):(0); + CogLn[3] = CogLn[CogSrc + 3]; + for (int i = 0; i < 3; i++) + CogLn[i] = CogLn[CogSrc + i] / CogLn[CogSrc + 3]; + + //Calculate Cog Modifiers + vec2 InUV[2] = { vec2(.0f), vec2(.5f) }; + vec2 CogUV[2] = { vec2(.0f), vec2(.5f) }; + vec2 upadd = vec2(.25f, .75f); + vec2 lowadd = vec2(.75f, .75f); + { + if (h < InLn) + { + InUV[0].x = 1.0f; + InUV[0].y = h / InLn; + InUV[1].x = .0f; + InUV[1].y -= InUV[0].y * .5f; + } + else + { + InUV[0].x = InLn / h; + InUV[0].y = 1.0f; + InUV[1].x -= InUV[0].x * .5f; + InUV[1].y = .0f; + } + if (h < CogLn[3]) + { + CogUV[0].x = 1.0f; + CogUV[0].y = h / CogLn[3]; + CogUV[1].x = .0f; + CogUV[1].y -= CogUV[0].y * .5f; + } + else + { + CogUV[0].x = CogLn[3] / h; + CogUV[0].y = 1.0f; + CogUV[1].x -= CogUV[0].x * .5f; + CogUV[1].y = .0f; + } + if (InUV[0].x + CogUV[0].x < .5f) + { + InUV[1].x = .0f; + CogUV[1].x = .5f - CogUV[0].x; + upadd = vec2(.75f, .25f); + lowadd = vec2(.75f, .75f); + } + else if (InUV[0].y + CogUV[0].y < .5f) + { + InUV[1].y = .0f; + CogUV[1].y = .5f - CogUV[0].y; + } + else + { + InUV[0] *= .5f; + InUV[1] *= .5f; + CogUV[0] *= .5f; + CogUV[1] *= .5f; + InUV[1] += vec2(.5f, .0f); + } + } + + //Build UV tab + vec2 uv[12]; float CogSz; + //Upper points + CogSz = 1.0f - CogLn[1]; + uv[0] = vec2(0.f, 0.f) * InUV[0] + InUV[1]; + uv[1] = vec2(1.f, 0.f) * InUV[0] + InUV[1]; + uv[5] = vec2(CogSz, 0.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[2]; + uv[4] = vec2(CogSz, 0.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[1]; + uv[3] = vec2(CogSz, 0.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[0]; + uv[2] = vec2(0.f, 0.f) * CogUV[0] + CogUV[1]; + + //Lower points + CogSz = 1.0f - CogLn[1]; + uv[6] = vec2(0.f, 1.f) * InUV[0] + InUV[1]; + uv[7] = vec2(1.f, 1.f) * InUV[0] + InUV[1]; + uv[11] = vec2(CogSz, 1.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[2]; + uv[10] = vec2(CogSz, 1.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[1]; + uv[ 9] = vec2(CogSz, 1.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[0]; + uv[ 8] = vec2(0.f, 1.f) * CogUV[0] + CogUV[1]; + + //Gear generation loop for (int i = 0; i < nbsides; i++) { + int j = 3 * 12 * i, + k = 3 * 12 * ((i + 1) % nbsides); + + int q[] = { /* The top and bottom faces */ + j, j, j, j, + j, j, j, j, + j, j, k, k, + k, k, j, j, + j, j, j, k, + k, j, j, j, + /* The inner side quads */ + j, j, j, j, + j, k, k, j, + /* The outer side quads */ + j, j, j, j, + j, j, j, j, + j, j, j, j, + k, j, j, k + }; + int m[] = { /* The top and bottom faces */ + 0, 2, 3, 1, + 7, 9, 8, 6, + 1, 3, 2, 0, + 6, 8, 9, 7, + 3, 4, 5, 2, + 8, 11, 10, 9, + /* The inner side quads */ + 0, 1, 7, 6, + 1, 0, 6, 7, + /* The outer side quads */ + 3, 2, 8, 9, + 4, 3, 9, 10, + 5, 4, 10, 11, + 2, 5, 11, 8 + }; + int a[] = { /* The top and bottom faces */ + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + /* The inner side quads */ + 1, 1, 1, 1, + 2, 2, 2, 2, + /* The outer side quads */ + 1, 1, 1, 1, + 1, 2, 2, 1, + 1, 2, 2, 1, + 2, 2, 2, 2 + }; + /* Each vertex will share three faces, so three different * normals, therefore we add each vertex three times. */ for (int n = 0; n < 3 * 12; n++) { - AddVertex(p[n / 3]); - if (n / 3 >= 6) + int d = n / 3; + int m = d % 6; + AddVertex(p[d]); + if (n % 3 == 0) //Top-Bottom logic + { + vec2 tmp = (p[d].xz / maxr); + vec2 add; + if (d >= 6) + { + tmp *= -1.0f; + add = lowadd; + } + else + add = upadd; + SetCurVertTexCoord(tmp * vec2(.25f) + add); + } + else if (m == 0 || m == 1) //inner Logic + SetCurVertTexCoord(uv[d]); + else //Cog logic + { + if (m == 2 && n % 3 == 2) + SetCurVertTexCoord(vec2(1.f, (d == 2)?(0.f):(1.f)) * CogUV[0] + CogUV[1]); + else + SetCurVertTexCoord(uv[d]); + } + if (d >= 6) SetCurVertColor(m_color2); } - int j = 3 * 12 * i, k = 3 * 12 * ((i + 1) % nbsides); - - /* The top and bottom faces */ - AppendQuad(j, j + 6, j + 9, j + 3, vbase); - AppendQuad(j + 21, j + 27, j + 24, j + 18, vbase); - AppendQuad(j + 3, j + 9, k + 6, k, vbase); - AppendQuad(k + 18, k + 24, j + 27, j + 21, vbase); - AppendQuad(j + 9, j + 12, j + 15, k + 6, vbase); - AppendQuad(k + 24, j + 33, j + 30, j + 27, vbase); - - /* The inner side quads */ - AppendQuad(j + 1, j + 4, j + 22, j + 19, vbase); - AppendQuad(j + 5, k + 2, k + 20, j + 23, vbase); - - /* The outer side quads */ - AppendQuad(j + 10, j + 7, j + 25, j + 28, vbase); - AppendQuad(j + 13, j + 11, j + 29, j + 31, vbase); - AppendQuad(j + 16, j + 14, j + 32, j + 34, vbase); - AppendQuad(k + 8, j + 17, j + 35, k + 26, vbase); - + int l = -4; + while ((l += 4) < 48) + AppendQuad(q[l + 0] + m[l + 0] * 3 + a[l + 0], + q[l + 1] + m[l + 1] * 3 + a[l + 1], + q[l + 2] + m[l + 2] * 3 + a[l + 2], + q[l + 3] + m[l + 3] * 3 + a[l + 3], + vbase); + for (int n = 0; n < 12; n++) p[n] = rotmat * p[n]; } diff --git a/src/easymesh/easymesh.h b/src/easymesh/easymesh.h index ed25a6ba..c91200a5 100644 --- a/src/easymesh/easymesh.h +++ b/src/easymesh/easymesh.h @@ -78,6 +78,21 @@ private: Array master_list; }; +struct MeshBuildOperation +{ + enum Value + { + Scale_Winding = 1 << 0, + + All = 0xffffffff + } + m_value; + + inline MeshBuildOperation(Value v) : m_value(v) {} + inline MeshBuildOperation(uint64_t i) : m_value((Value)i) {} + inline operator Value() { return m_value; } +}; + class EasyMesh { friend class EasyMeshParser; @@ -98,21 +113,33 @@ private: private: void MeshCsg(CSGUsage csg_operation); public: + /* [cmd:csgu] Performs a Union operation as (mesh0_Outside + mesh1_Outside) */ void CsgUnion() { MeshCsg(CSGUsage::Union); } + /* [cmd:csgs] Performs a Substract operation as (mesh0_Outside + mesh1_Inside-inverted) */ void CsgSubstract() { MeshCsg(CSGUsage::Substract); } + /* [cmd:csgsl] Performs a Substract operation without keeping the mesh1 part */ void CsgSubstractLoss() { MeshCsg(CSGUsage::SubstractLoss); } + /* [cmd:csga] Performs an And operation as (mesh0_Inside + mesh1_Inside) */ void CsgAnd() { MeshCsg(CSGUsage::And); } + /* [cmd:csgx] Performs a Xor operation as (m0_Outside/m0_Inside-inverted + m1_Outside/m1_Inside-inverted) */ void CsgXor() { MeshCsg(CSGUsage::Xor); } public: + /* [cmd:[] from this point onward, any operation will not be performed on previous vertices */ void OpenBrace(); + /* [cmd:]] Merge current vertices with previous context */ void CloseBrace(); - + /* [cmd:tsw] When activation, on negative-scaling, normal fixing will not occur */ void ToggleScaleWinding(); + /* [cmd:sc] Set vertices color */ void SetCurColor(vec4 const &color); + /* [cmd:scb] Set vertices color 2 */ void SetCurColor2(vec4 const &color); private: + //------------------------------------------------------------------------- + //Internal : Basic triangle/vertex operations + //------------------------------------------------------------------------- void AddVertex(vec3 const &coord); void AddDuplicateVertex(int i); void AppendQuad(int i1, int i2, int i3, int i4, int base); @@ -120,52 +147,183 @@ private: void AppendTriangle(int i1, int i2, int i3, int base); void AppendTriangleDuplicateVerts(int i1, int i2, int i3, int base); void ComputeNormals(int start, int vcount); -public: +public: //DEBUG void ComputeTexCoord(float uv_scale, int uv_offset); + + //------------------------------------------------------------------------- + //Vertices operations + //------------------------------------------------------------------------- void SetVertColor(vec4 const &color); + void SetTexCoordData(vec2 const &new_offset, vec2 const &new_scale); void SetCurVertNormal(vec3 const &normal); void SetCurVertColor(vec4 const &color); + void SetCurVertTexCoord(vec2 const &texcoord); public: //------------------------------------------------------------------------- //Mesh transform operations //------------------------------------------------------------------------- + + /* [cmd:t/tx/ty/tz] Translate vertices + - v : Translation quantity. + */ void Translate(vec3 const &v); - void RotateX(float t); - void RotateY(float t); - void RotateZ(float t); - void Rotate(float t, vec3 const &axis); + /* See Rotate */ + void RotateX(float angle); + /* See Rotate */ + void RotateY(float angle); + /* See Rotate */ + void RotateZ(float angle); + /* [cmd:r/rx/ry/rz] Rotate vertices + - angle : rotation quantity. + - axis : rotation axis. + */ + void Rotate(float angle, vec3 const &axis); + /* [cmd:rj] Randomly move vertices along Origin-to-vertex as o2v *= (1.0 + rand(r)) + - r : jitter maximum value. + */ void RadialJitter(float r); + //TODO : twist + //TODO : bend + //TODO : stretch + //TODO : shear + /* [cmd:tax] multiply y&z by (1.0 + (n * x + xoff)) + - y : value of n for y. + - z : value of n for z. + - xoff : value of xoff. + */ void TaperX(float y, float z, float xoff); + /* [cmd:tay] multiply x&z by (1.0 + (n * y + yoff)) + - x : value of n for x. + - z : value of n for z. + - yoff : value of yoff. + */ void TaperY(float x, float z, float yoff); + /* [cmd:taz] multiply x&y by (1.0 + (n * z + zoff)) + - x : value of n for x. + - y : value of n for y. + - zoff : value of zoff. + */ void TaperZ(float x, float y, float zoff); + /* [cmd:s/sx/sy/sz] Scale vertices + - s : scale quantity. + */ void Scale(vec3 const &s); + /* [cmd:mx] Mirror vertices through X-plane + Acts as an OpenBrace + */ void MirrorX(); + /* [cmd:my] Mirror vertices through Y-plane + Acts as an OpenBrace + */ void MirrorY(); + /* [cmd:mz] Mirror vertices through Z-plane + Acts as an OpenBrace + */ void MirrorZ(); + /* [no-cmd] Duplicates vertices and scale duplicate + Acts as an OpenBrace + */ void DupAndScale(vec3 const &s); + /* [cmd:ch] Performs a chamfer operation //TODO : Make it work. + - f : Chamfer quantity. + */ void Chamfer(float f); //------------------------------------------------------------------------- //Mesh shape operations //------------------------------------------------------------------------- + + /* [cmd:ac] Cylinder centered on (0,0,0) with BBox [-max(r1, r2), -.5*h, -max(r1, r2)][max(r1, r2), .5*h, max(r1, r2)] + - nbsides : Number of sides. + - h : Height of the cylinder. + - r1 : Lower radius. TODO:convert to diameter to be coherent with other funcs + - r2 : Upper radius. TODO:convert to diameter to be coherent with other funcs + - dualside : if (1) will also create inner sides : TOOD:TOREMOVE?? : needed ? + - smooth : if (1) will smooth normals : TOOD:TOREMOVE : smooth should be handled elsewhere + - close : if (1) will add discs to close the cylinder + */ void AppendCylinder(int nsides, float h, float r1, float r2, - int dualside, int smooth); + int dualside, int smooth, int close); + /* [cmd:asph] Sphere centered on (0,0,0) with BBox [-size][size] + - ndivisions : number of subdivisions each Sphere triangle will sustain. + - size : size of the Sphere. + */ + void AppendSphere(int ndivisions, float r); + /* [cmd:acap] Capsule centered on (0,0,0) with BBox [-r, -(r+h) ,-r][r, (r+h) ,r] + - ndivisions : number of subdivisions each Sphere triangle will sustain. + - h : Inner height. + - r : Radius. TODO:convert to diameter to be coherent with other funcs + */ void AppendCapsule(int ndivisions, float h, float r); - void AppendSphere(int ndivisions, vec3 const &size); + /* [cmd:ato] Torus centered on (0,0,0) with BBox [-r2][r2] + - ndivisions : number of subdivisions of the torus. + - r1 : Inner radius. TODO:convert to diameter to be coherent with other funcs + - r2 : Outer radius. TODO:convert to diameter to be coherent with other funcs + */ void AppendTorus(int ndivisions, float r1, float r2); + /* [cmd:ab] Box centered on (0,0,0) with BBox [-.5 * size][.5 * size] + - size : size of the box. + - chamf : size of the chamfer. + - smooth : if (1) will smooth normals : TOOD:TOREMOVE : smooth should be handled elsewhere + */ void AppendBox(vec3 const &size, float chamf = 0.f); + //Same as AppendBox void AppendSmoothChamfBox(vec3 const &size, float chamf); + //Same as AppendBox void AppendFlatChamfBox(vec3 const &size, float chamf); + //Same as AppendBox void AppendBox(vec3 const &size, float chamf, bool smooth); + /* [cmd:as] + Append a Star centered on (0,0,0) contained within a disc of "max(r1, r2)" radius. + - nbranches : Number of branches. + - r1 : Length of the branches. + - r2 : Length of the "branch" located between r1-branches. + - fade : if (1) in-between branches use Color2. + - fade2 : if (1) Star branches use Color2. + */ void AppendStar(int nbranches, float r1, float r2, int fade = 0, int fade2 = 0); + /* [cmd:aes] Star centered on (0,0,0) contained within a disc of "max(max(r1, r2), max(r1 + extrar, r2 + extrar))" radius. + Expanded star branches use Color2. + - nbranches : Number of branches. + - r1 : Length of the branches. + - r2 : Length of the "branch" located between r1-branches. + - extrar : Extra length added to expand all branches. + */ void AppendExpandedStar(int nbranches, float r1, float r2, float extrar); + /* [cmd:ad] Disc centered on (0,0,0) with BBox [-size][size] + - nbsides : Number of sides. + - r : Radius. TODO:convert to diameter to be coherent with other funcs + - fade : if (1) Outer vertices will use Color2 + */ void AppendDisc(int nsides, float r, int fade = 0); + /* [cmd:at] Triangle centered on (0,0,0) contained within a disc of "size" radius. + - size : Size of vector : origin-TO-vertex. + - fade : if (1) 2nd & 3rd Vertices will use Color2 + */ void AppendSimpleTriangle(float size, int fade = 0); + /* [cmd:aq] Quad centered on (0,0,0) contained within BBox [-size,0,-size][size,0,size] + - size : Size of quad. + - fade : if (1) 3rd & 4th Vertices will use Color2 + */ void AppendSimpleQuad(float size, int fade = 0); +private: + //complex version of above one void AppendSimpleQuad(vec2 p1, vec2 p2, float z = 0.f, int fade = 0); +public: + /* [cmd:acg] Gear centered on (0,0,0) contained within BBox [-max(r1,r2), -.5*h, -max(r1, r2)][max(r1, r2), .5*h, max(r1, r2)] + - h : Height of the Gear. + - r10 : Upper Inner radius. + - r20 : Lower Inner radius. + - r1 : Upper Outer radius. + - r2 : Lower Outer radius. + - r12 : Upper Cog radius. + - r22 : Lower Cog radius. + - sidemul : multiplier for the size of the cogs. + - offset : useless + */ void AppendCog(int nbsides, float h, float r10, float r20, float r1, float r2, float r12, float r22, float sidemul, int offset); @@ -201,6 +359,9 @@ private: Array m_cursors; //When this flag is up, negative scaling will not invert faces. bool m_ignore_winding_on_scale; + //Texture coordinate modifiers. + vec2 m_texcoord_offset; + vec2 m_texcoord_scale; /* FIXME: put this in a separate class so that we can copy meshes. */ struct diff --git a/src/easymesh/shinydebugUV.lolfx b/src/easymesh/shinydebugUV.lolfx index ec625ce4..5c70c78a 100644 --- a/src/easymesh/shinydebugUV.lolfx +++ b/src/easymesh/shinydebugUV.lolfx @@ -50,7 +50,45 @@ varying vec2 pass_TexCoord; void main(void) { - gl_FragColor = vec4(mod(pass_TexCoord.x, 1.0f), 0.2, mod(pass_TexCoord.y, 1.0), 1.0) * length(normalize(pass_Color.xyz)) * length(normalize(pass_TNormal)); + float mode = 0.0; + if (mode == 0.0) + { + gl_FragColor = vec4(mod(pass_TexCoord.x, 1.0f), + 0.1, + mod(pass_TexCoord.y, 1.0), 1.0); + } + else + { + float col = ((mod(mode, 2.0) == 1)?(mod(pass_TexCoord.x, 1.0)):(mod(pass_TexCoord.y, 1.0))); + if (mode == 1 || mode == 2) + { + if (col > 1.0/3.0) gl_FragColor.r = 0.0; + else gl_FragColor.r = min(col, 1.0/3.0); + if (col > 2.0/3.0) gl_FragColor.g = 0.0; + else gl_FragColor.g = min(max(col, 1.0/3.0) - 1.0/3.0, 1.0/3.0); + gl_FragColor.b = min(max(col, 2.0/3.0) - 2.0/3.0, 1.0/3.0); + } + else if (mode == 3 || mode == 4) + { + if (col > 0.5) gl_FragColor.r = 0.0; + else gl_FragColor.r = min(col, 0.5); + gl_FragColor.g = min(max(col, 0.5) - 0.5, 0.5); + gl_FragColor.b = 0.1; + } + else if (mode == 5 || mode == 6) + { + gl_FragColor.r = col; + gl_FragColor.g = 0.1; + gl_FragColor.b = 0.1; + } + } + + gl_FragColor.a = 1.0; + gl_FragColor *= + //= pass_Color * + length(normalize(pass_TexCoord)) * + length(normalize(pass_Color.xyz)) * + length(normalize(pass_TNormal)); } [vert.hlsl] diff --git a/src/generated/easymesh-parser.cpp b/src/generated/easymesh-parser.cpp index cd01cd55..7f536458 100644 --- a/src/generated/easymesh-parser.cpp +++ b/src/generated/easymesh-parser.cpp @@ -35,7 +35,7 @@ /* First part of user declarations. */ -/* Line 293 of lalr1.cc */ +/* Line 310 of lalr1.cc */ #line 1 "easymesh/easymesh-parser.y" // @@ -61,7 +61,7 @@ -/* Line 293 of lalr1.cc */ +/* Line 310 of lalr1.cc */ #line 66 "generated/easymesh-parser.cpp" @@ -69,7 +69,7 @@ /* User implementation prologue. */ -/* Line 299 of lalr1.cc */ +/* Line 316 of lalr1.cc */ #line 66 "easymesh/easymesh-parser.y" #include "easymesh/easymesh-compiler.h" @@ -78,7 +78,7 @@ #define yylex mc.m_lexer->lex -/* Line 299 of lalr1.cc */ +/* Line 316 of lalr1.cc */ #line 83 "generated/easymesh-parser.cpp" #ifndef YY_ @@ -93,26 +93,6 @@ # endif #endif -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).begin = YYRHSLOC (Rhs, 1).begin; \ - (Current).end = YYRHSLOC (Rhs, N).end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ - } \ - while (false) -#endif - /* Suppress unused-variable warnings by "using" E. */ #define YYUSE(e) ((void) (e)) @@ -164,8 +144,9 @@ do { \ namespace lol { -/* Line 382 of lalr1.cc */ -#line 169 "generated/easymesh-parser.cpp" +/* Line 379 of lalr1.cc */ +#line 149 "generated/easymesh-parser.cpp" +#if YYERROR_VERBOSE /* Return YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is @@ -204,6 +185,7 @@ namespace lol { return yystr; } +#endif /// Build a parser object. EasyMeshParser::EasyMeshParser (class EasyMeshCompiler& mc_yyarg) @@ -304,18 +286,6 @@ namespace lol { } #endif - inline bool - EasyMeshParser::yy_pact_value_is_default_ (int yyvalue) - { - return yyvalue == yypact_ninf_; - } - - inline bool - EasyMeshParser::yy_table_value_is_error_ (int yyvalue) - { - return yyvalue == yytable_ninf_; - } - int EasyMeshParser::parse () { @@ -337,7 +307,7 @@ namespace lol { /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. - location_type yyerror_range[3]; + location_type yyerror_range[2]; /// $$. semantic_type yyval; @@ -375,7 +345,7 @@ namespace lol { /* Try to take a decision without lookahead. */ yyn = yypact_[yystate]; - if (yy_pact_value_is_default_ (yyn)) + if (yyn == yypact_ninf_) goto yydefault; /* Read a lookahead token. */ @@ -408,8 +378,8 @@ namespace lol { yyn = yytable_[yyn]; if (yyn <= 0) { - if (yy_table_value_is_error_ (yyn)) - goto yyerrlab; + if (yyn == 0 || yyn == yytable_ninf_) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -465,28 +435,28 @@ namespace lol { { case 7: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 90 "easymesh/easymesh-parser.y" { mc.m_mesh.OpenBrace(); } break; case 8: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 94 "easymesh/easymesh-parser.y" { mc.m_mesh.CloseBrace(); } break; case 14: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 109 "easymesh/easymesh-parser.y" { 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)); } break; case 15: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 110 "easymesh/easymesh-parser.y" { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); vec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); @@ -495,14 +465,14 @@ namespace lol { case 16: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 113 "easymesh/easymesh-parser.y" { 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)); } break; case 17: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 114 "easymesh/easymesh-parser.y" { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); vec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); @@ -511,374 +481,378 @@ namespace lol { case 18: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 120 "easymesh/easymesh-parser.y" { mc.m_mesh.Chamfer((yysemantic_stack_[(2) - (2)].args).f0); } break; case 19: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 121 "easymesh/easymesh-parser.y" { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); } break; case 20: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 122 "easymesh/easymesh-parser.y" { mc.m_mesh.Translate(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); } break; case 21: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 123 "easymesh/easymesh-parser.y" { mc.m_mesh.Translate(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); } break; case 22: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 124 "easymesh/easymesh-parser.y" { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } break; case 23: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 125 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateX((yysemantic_stack_[(2) - (2)].args).f0); } break; case 24: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 126 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateY((yysemantic_stack_[(2) - (2)].args).f0); } break; case 25: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 127 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateZ((yysemantic_stack_[(2) - (2)].args).f0); } break; case 26: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 128 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 27: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 129 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 28: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 130 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 29: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 131 "easymesh/easymesh-parser.y" { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, 1.0, 1.0)); } break; case 30: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 132 "easymesh/easymesh-parser.y" { mc.m_mesh.Scale(vec3(1.0, (yysemantic_stack_[(2) - (2)].args).f0, 1.0)); } break; case 31: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 133 "easymesh/easymesh-parser.y" { mc.m_mesh.Scale(vec3(1.0, 1.0, (yysemantic_stack_[(2) - (2)].args).f0)); } break; case 32: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 134 "easymesh/easymesh-parser.y" { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } break; case 33: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 135 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorX(); } break; case 34: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 136 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorY(); } break; case 35: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 137 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorZ(); } break; case 36: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 138 "easymesh/easymesh-parser.y" { mc.m_mesh.RadialJitter((yysemantic_stack_[(2) - (2)].args).f0); } break; case 37: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 139 "easymesh/easymesh-parser.y" { mc.m_mesh.ToggleScaleWinding(); } break; case 38: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 140 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgUnion(); } break; case 39: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 141 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgSubstract(); } break; case 40: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 142 "easymesh/easymesh-parser.y" - { mc.m_mesh.CsgAnd(); } + { mc.m_mesh.CsgSubstractLoss(); } break; case 41: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 143 "easymesh/easymesh-parser.y" - { mc.m_mesh.CsgXor(); } + { mc.m_mesh.CsgAnd(); } break; case 42: -/* Line 690 of lalr1.cc */ -#line 147 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, - (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3, - (int)(yysemantic_stack_[(2) - (2)].args).f4, (int)(yysemantic_stack_[(2) - (2)].args).f5); } +/* Line 677 of lalr1.cc */ +#line 144 "easymesh/easymesh-parser.y" + { mc.m_mesh.CsgXor(); } break; case 43: -/* Line 690 of lalr1.cc */ -#line 150 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } +/* Line 677 of lalr1.cc */ +#line 148 "easymesh/easymesh-parser.y" + { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, + (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3, + (int)(yysemantic_stack_[(2) - (2)].args).f4, (int)(yysemantic_stack_[(2) - (2)].args).f5, 0); } break; case 44: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 151 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendSmoothChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, - (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); } + { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, + (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3, + (int)(yysemantic_stack_[(2) - (2)].args).f4, (int)(yysemantic_stack_[(2) - (2)].args).f5, (int)(yysemantic_stack_[(2) - (2)].args).f6); } break; case 45: -/* Line 690 of lalr1.cc */ -#line 153 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendFlatChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, - (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); } +/* Line 677 of lalr1.cc */ +#line 154 "easymesh/easymesh-parser.y" + { mc.m_mesh.AppendBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } break; case 46: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 155 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendSphere((yysemantic_stack_[(2) - (2)].args).f0, - vec3((yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); } + { mc.m_mesh.AppendSmoothChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, + (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); } break; case 47: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 157 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendCapsule((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } + { mc.m_mesh.AppendFlatChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, + (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); } break; case 48: -/* Line 690 of lalr1.cc */ -#line 158 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendTorus((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } +/* Line 677 of lalr1.cc */ +#line 159 "easymesh/easymesh-parser.y" + { mc.m_mesh.AppendSphere((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 49: -/* Line 690 of lalr1.cc */ -#line 159 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, - (int)(yysemantic_stack_[(2) - (2)].args).f3, (int)(yysemantic_stack_[(2) - (2)].args).f4); } +/* Line 677 of lalr1.cc */ +#line 160 "easymesh/easymesh-parser.y" + { mc.m_mesh.AppendCapsule((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 50: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 161 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendExpandedStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, - (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } + { mc.m_mesh.AppendTorus((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 51: -/* Line 690 of lalr1.cc */ -#line 163 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendDisc((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (int)(yysemantic_stack_[(2) - (2)].args).f2); } +/* Line 677 of lalr1.cc */ +#line 162 "easymesh/easymesh-parser.y" + { mc.m_mesh.AppendStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, + (int)(yysemantic_stack_[(2) - (2)].args).f3, (int)(yysemantic_stack_[(2) - (2)].args).f4); } break; case 52: -/* Line 690 of lalr1.cc */ +/* Line 677 of lalr1.cc */ #line 164 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); } + { mc.m_mesh.AppendExpandedStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, + (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } break; case 53: -/* Line 690 of lalr1.cc */ -#line 165 "easymesh/easymesh-parser.y" - { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); } +/* Line 677 of lalr1.cc */ +#line 166 "easymesh/easymesh-parser.y" + { mc.m_mesh.AppendDisc((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (int)(yysemantic_stack_[(2) - (2)].args).f2); } break; case 54: -/* Line 690 of lalr1.cc */ -#line 166 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 167 "easymesh/easymesh-parser.y" + { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); } + break; + + case 55: + +/* Line 677 of lalr1.cc */ +#line 168 "easymesh/easymesh-parser.y" + { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); } + break; + + case 56: + +/* Line 677 of lalr1.cc */ +#line 169 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendCog((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (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, (yysemantic_stack_[(2) - (2)].args).f7, (yysemantic_stack_[(2) - (2)].args).f8, (int)(yysemantic_stack_[(2) - (2)].args).f9); } break; - case 55: + case 57: -/* Line 690 of lalr1.cc */ -#line 171 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 174 "easymesh/easymesh-parser.y" { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); } break; - case 56: + case 58: -/* Line 690 of lalr1.cc */ -#line 172 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 175 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 57: + case 59: -/* Line 690 of lalr1.cc */ -#line 173 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 176 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 58: + case 60: -/* Line 690 of lalr1.cc */ -#line 174 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 177 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 59: + case 61: -/* Line 690 of lalr1.cc */ -#line 175 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 178 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 60: + case 62: -/* Line 690 of lalr1.cc */ -#line 176 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 179 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 61: + case 63: -/* Line 690 of lalr1.cc */ -#line 177 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 180 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 62: + case 64: -/* Line 690 of lalr1.cc */ -#line 178 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 181 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 63: + case 65: -/* Line 690 of lalr1.cc */ -#line 179 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 182 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f8 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 64: + case 66: -/* Line 690 of lalr1.cc */ -#line 180 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 183 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f9 = (yysemantic_stack_[(2) - (2)].fval); } break; - case 65: + case 67: -/* Line 690 of lalr1.cc */ -#line 183 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 186 "easymesh/easymesh-parser.y" { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); } break; - case 66: + case 68: -/* Line 690 of lalr1.cc */ -#line 184 "easymesh/easymesh-parser.y" +/* Line 677 of lalr1.cc */ +#line 187 "easymesh/easymesh-parser.y" { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); } break; -/* Line 690 of lalr1.cc */ -#line 868 "generated/easymesh-parser.cpp" +/* Line 677 of lalr1.cc */ +#line 853 "generated/easymesh-parser.cpp" default: break; } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action - invokes YYABORT, YYACCEPT, or YYERROR immediately after altering - yychar. In the case of YYABORT or YYACCEPT, an incorrect - destructor might then be invoked immediately. In the case of - YYERROR, subsequent parser actions might lead to an incorrect - destructor call or verbose syntax error message before the - lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); yypop_ (yylen); @@ -902,20 +876,14 @@ namespace lol { | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yytranslate_ (yychar); - /* If not already recovering from an error, report this error. */ if (!yyerrstatus_) { ++yynerrs_; - if (yychar == yyempty_) - yytoken = yyempty_; error (yylloc, yysyntax_error_ (yystate, yytoken)); } - yyerror_range[1] = yylloc; + yyerror_range[0] = yylloc; if (yyerrstatus_ == 3) { /* If just tried and failed to reuse lookahead token after an @@ -950,7 +918,7 @@ namespace lol { if (false) goto yyerrorlab; - yyerror_range[1] = yylocation_stack_[yylen - 1]; + yyerror_range[0] = yylocation_stack_[yylen - 1]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ yypop_ (yylen); @@ -967,7 +935,7 @@ namespace lol { for (;;) { yyn = yypact_[yystate]; - if (!yy_pact_value_is_default_ (yyn)) + if (yyn != yypact_ninf_) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) @@ -982,7 +950,7 @@ namespace lol { if (yystate_stack_.height () == 1) YYABORT; - yyerror_range[1] = yylocation_stack_[0]; + yyerror_range[0] = yylocation_stack_[0]; yydestruct_ ("Error: popping", yystos_[yystate], &yysemantic_stack_[0], &yylocation_stack_[0]); @@ -991,10 +959,10 @@ namespace lol { YY_STACK_PRINT (); } - yyerror_range[2] = yylloc; + yyerror_range[1] = yylloc; // Using YYLLOC is tempting, but would change the location of // the lookahead. YYLOC is available though. - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); @@ -1017,13 +985,7 @@ namespace lol { yyreturn: if (yychar != yyempty_) - { - /* Make sure we have latest lookahead translation. See comments - at user semantic actions for why this is necessary. */ - yytoken = yytranslate_ (yychar); - yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, - &yylloc); - } + yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ @@ -1042,97 +1004,51 @@ namespace lol { // Generate an error message. std::string - EasyMeshParser::yysyntax_error_ (int yystate, int yytoken) + EasyMeshParser::yysyntax_error_ (int yystate, int tok) { - std::string yyres; - // Number of reported tokens (one for the "unexpected", one per - // "expected"). - size_t yycount = 0; - // Its maximum. - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - // Arguments of yyformat. - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yytoken) is - if this state is a consistent state with a default action. - Thus, detecting the absence of a lookahead is sufficient to - determine that there is no unexpected or expected token to - report. In that case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is - a consistent state with a default action. There might have - been a previous inconsistent state, consistent state with a - non-default action, or user semantic action that manipulated - yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state - merging (from LALR or IELR) and default reductions corrupt the - expected token list. However, the list is correct for - canonical LR with one exception: it will still contain any - token that will not be accepted due to an error action in a - later state. - */ - if (yytoken != yyempty_) + std::string res; + YYUSE (yystate); +#if YYERROR_VERBOSE + int yyn = yypact_[yystate]; + if (yypact_ninf_ < yyn && yyn <= yylast_) { - yyarg[yycount++] = yytname_[yytoken]; - int yyn = yypact_[yystate]; - if (!yy_pact_value_is_default_ (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = yylast_ - yyn + 1; - int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; - for (int yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ - && !yy_table_value_is_error_ (yytable_[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - break; - } - else - yyarg[yycount++] = yytname_[yyx]; - } - } - } - - char const* yyformat = 0; - switch (yycount) - { -#define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -#undef YYCASE_ + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + int count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + ++count; + + // FIXME: This method of building the message is not compatible + // with internationalization. It should work like yacc.c does it. + // That is, first build a string that looks like this: + // "syntax error, unexpected %s or %s or %s" + // Then, invoke YY_ on this string. + // Finally, use the string as a format to output + // yytname_[tok], etc. + // Until this gets fixed, this message appears in English only. + res = "syntax error, unexpected "; + res += yytnamerr_ (yytname_[tok]); + if (count < 5) + { + count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + { + res += (!count++) ? ", expecting " : " or "; + res += yytnamerr_ (yytname_[x]); + } + } } - - // Argument number. - size_t yyi = 0; - for (char const* yyp = yyformat; *yyp; ++yyp) - if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) - { - yyres += yytnamerr_ (yyarg[yyi++]); - ++yyp; - } - else - yyres += *yyp; - return yyres; + else +#endif + res = YY_("syntax error"); + return res; } @@ -1142,46 +1058,46 @@ namespace lol { const signed char EasyMeshParser::yypact_[] = { - -3, 19, 28, 26, 26, 26, 26, -10, 26, 26, - 26, 26, -10, 26, 26, 26, 26, -10, 26, 26, - -10, 26, -10, -10, -10, -10, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - -10, 41, 49, -3, -3, 81, -10, -10, -10, -10, - -10, -10, 26, 26, 26, 26, -10, -10, -10, -10, + -3, 29, 31, 16, 16, 16, 16, -10, 16, 16, + 16, 16, -10, 16, 16, 16, 16, -10, 16, 16, + -10, 16, -10, -10, -10, -10, -10, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, -10, 42, 50, -3, -3, 83, -10, -10, -10, + -10, -10, -10, 16, 16, 16, 16, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10, -10, -10, -10, -10, 26, 26, -10, -10, - -10, -10, -10, -10, -10, -10, -10, -10, -10, 26, - 26, 26, 26, -10, -10, -10, -10, -10, 5, -10, + -10, -10, -10, -10, -10, -10, -10, 16, 16, 16, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, - -10, -10 + -10, 16, 16, 16, 16, -10, -10, -10, -10, -10, + 5, -10, -10, -10, -10, -10, -10, -10, -10, -10, + -10, -10, -10, -10 }; - /* YYDEFACT[S] -- default reduction number in state S. Performed when - YYTABLE doesn't specify something else to do. Zero means the - default is an error. */ + /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ const unsigned char EasyMeshParser::yydefact_[] = { 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 34, 0, 0, 0, 0, 35, 0, 0, - 37, 0, 38, 39, 40, 41, 0, 0, 0, 0, + 37, 0, 38, 39, 40, 41, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7, 0, 0, 3, 0, 5, 9, 11, 12, 13, - 65, 15, 0, 0, 0, 0, 14, 55, 17, 16, - 19, 23, 26, 29, 20, 24, 27, 30, 21, 25, - 28, 31, 22, 32, 36, 18, 0, 0, 42, 43, - 44, 45, 46, 47, 49, 50, 51, 52, 53, 0, - 0, 0, 0, 54, 48, 1, 2, 4, 0, 10, - 66, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 8, 6 + 0, 7, 0, 0, 3, 0, 5, 9, 11, 12, + 13, 67, 15, 0, 0, 0, 0, 14, 57, 17, + 16, 19, 23, 26, 29, 20, 24, 27, 30, 21, + 25, 28, 31, 22, 32, 36, 18, 0, 0, 43, + 44, 45, 46, 47, 48, 49, 51, 52, 53, 54, + 55, 0, 0, 0, 0, 56, 50, 1, 2, 4, + 0, 10, 68, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 8, 6 }; /* YYPGOTO[NTERM-NUM]. */ - const signed char + const short int EasyMeshParser::yypgoto_[] = { -10, -10, -4, -10, -10, -10, -10, 9, -10, -10, - -10, 44, 40, 118, 125, 23, 21, -10, -10, -10, + -10, 45, 25, 121, 128, 33, 26, 32, -10, -10, -10, -9 }; @@ -1189,14 +1105,14 @@ namespace lol { const signed char EasyMeshParser::yydefgoto_[] = { - -1, 41, 42, 43, 44, 111, 45, 46, 47, 48, - 49, 53, 54, 55, 76, 77, 78, 90, 91, 92, - 93, 57 + -1, 42, 43, 44, 45, 113, 46, 47, 48, 49, + 50, 54, 55, 56, 77, 78, 79, 80, 93, 94, + 95, 58 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF_, syntax error. */ + number is the opposite. If zero, do what YYDEFACT says. */ const signed char EasyMeshParser::yytable_ninf_ = -1; const unsigned char EasyMeshParser::yytable_[] = @@ -1204,19 +1120,20 @@ namespace lol { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 97, - 98, 95, 40, 100, 101, 102, 103, 60, 61, 96, - 63, 110, 64, 65, 99, 67, 84, 68, 69, 89, - 71, 0, 50, 51, 0, 74, 52, 104, 105, 50, - 75, 50, 58, 52, 0, 52, 87, 88, 0, 0, - 106, 107, 108, 109, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 62, 0, 0, 56, 59, 66, 0, - 0, 0, 0, 70, 0, 0, 72, 73, 0, 0, - 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, - 83, 0, 0, 86, 80, 81, 82, 94, 0, 85 + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 99, 100, 97, 41, 102, 103, 104, 105, 61, 62, + 98, 64, 112, 65, 66, 101, 68, 84, 69, 70, + 51, 72, 89, 90, 53, 91, 75, 86, 106, 107, + 108, 92, 76, 51, 52, 51, 59, 53, 0, 53, + 0, 0, 108, 109, 110, 111, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 63, 0, 0, 57, + 60, 67, 0, 0, 0, 0, 71, 0, 0, 73, + 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 81, 0, 0, 0, 85, 0, 0, 88, 82, 83, + 0, 96, 0, 87 }; /* YYCHECK. */ @@ -1226,19 +1143,20 @@ namespace lol { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, - 44, 0, 45, 52, 53, 54, 55, 3, 4, 0, - 6, 46, 8, 9, 45, 11, 33, 13, 14, 38, - 16, -1, 43, 44, -1, 21, 47, 76, 77, 43, - 26, 43, 44, 47, -1, 47, 36, 37, -1, -1, - 89, 90, 91, 92, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 5, -1, -1, 1, 2, 10, -1, - -1, -1, -1, 15, -1, -1, 18, 19, -1, -1, - -1, -1, -1, -1, -1, -1, 28, -1, -1, -1, - 32, -1, -1, 35, 29, 30, 31, 39, -1, 34 + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 44, 45, 0, 46, 53, 54, 55, 56, 3, 4, + 0, 6, 47, 8, 9, 46, 11, 32, 13, 14, + 44, 16, 37, 38, 48, 39, 21, 34, 77, 78, + 79, 39, 27, 44, 45, 44, 45, 48, -1, 48, + -1, -1, 91, 92, 93, 94, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 5, -1, -1, 1, + 2, 10, -1, -1, -1, -1, 15, -1, -1, 18, + 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 29, -1, -1, -1, 33, -1, -1, 36, 30, 31, + -1, 40, -1, 35 }; /* STOS_[STATE-NUM] -- The (internal number of the) accessing @@ -1250,14 +1168,14 @@ namespace lol { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 45, 49, 50, 51, 52, 54, 55, 56, 57, 58, - 43, 44, 47, 59, 60, 61, 62, 69, 44, 62, - 59, 59, 61, 59, 59, 59, 61, 59, 59, 59, - 61, 59, 61, 61, 59, 59, 62, 63, 64, 61, - 62, 62, 62, 61, 63, 62, 61, 60, 60, 64, - 65, 66, 67, 68, 61, 0, 0, 50, 50, 55, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 46, 53 + 42, 46, 50, 51, 52, 53, 55, 56, 57, 58, + 59, 44, 45, 48, 60, 61, 62, 63, 70, 45, + 63, 60, 60, 62, 60, 60, 60, 62, 60, 60, + 60, 62, 60, 62, 62, 60, 60, 63, 64, 65, + 66, 62, 63, 63, 61, 62, 64, 63, 62, 61, + 61, 65, 66, 67, 68, 69, 62, 0, 0, 51, + 51, 56, 70, 70, 70, 70, 70, 70, 70, 70, + 70, 70, 47, 54 }; #if YYDEBUG @@ -1270,7 +1188,7 @@ namespace lol { 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 91, 93, 45 + 295, 296, 297, 298, 299, 300, 91, 93, 45 }; #endif @@ -1278,13 +1196,13 @@ namespace lol { const unsigned char EasyMeshParser::yyr1_[] = { - 0, 48, 49, 50, 50, 51, 51, 52, 53, 54, - 54, 55, 55, 55, 56, 56, 56, 56, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 69 + 0, 49, 50, 51, 51, 52, 52, 53, 54, 55, + 55, 56, 56, 56, 57, 57, 57, 57, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 70 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -1295,9 +1213,9 @@ namespace lol { 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 2 + 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 1, 2 }; #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE @@ -1311,15 +1229,15 @@ namespace lol { "T_ROTATEY", "T_TAPERY", "T_SCALEY", "T_MIRRORY", "T_TRANSLATEZ", "T_ROTATEZ", "T_TAPERZ", "T_SCALEZ", "T_MIRRORZ", "T_TRANSLATE", "T_SCALE", "T_TOGGLESCALEWINDING", "T_RADIALJITTER", "T_CSGUNION", - "T_CSGSUBSTRACT", "T_CSGAND", "T_CSGXOR", "T_CHAMFER", "T_CYLINDER", - "T_BOX", "T_SMOOTHCHAMFBOX", "T_FLATCHAMFBOX", "T_SPHERE", "T_CAPSULE", - "T_STAR", "T_EXPANDEDSTAR", "T_DISC", "T_TRIANGLE", "T_QUAD", "T_COG", - "T_TORUS", "T_ERROR", "NUMBER", "COLOR", "'['", "']'", "'-'", "$accept", - "mesh_description", "mesh_expression_list", "mesh_expression", - "mesh_open", "mesh_close", "mesh_command_list", "mesh_command", - "color_command", "transform_command", "primitive_command", "args1", - "args2", "args3", "args4", "args5", "args6", "args7", "args8", "args9", - "args10", "number", 0 + "T_CSGSUBSTRACT", "T_CSGSUBSTRACTLOSS", "T_CSGAND", "T_CSGXOR", + "T_CHAMFER", "T_CYLINDER", "T_BOX", "T_SMOOTHCHAMFBOX", "T_FLATCHAMFBOX", + "T_SPHERE", "T_CAPSULE", "T_STAR", "T_EXPANDEDSTAR", "T_DISC", + "T_TRIANGLE", "T_QUAD", "T_COG", "T_TORUS", "T_ERROR", "NUMBER", "COLOR", + "'['", "']'", "'-'", "$accept", "mesh_description", + "mesh_expression_list", "mesh_expression", "mesh_open", "mesh_close", + "mesh_command_list", "mesh_command", "color_command", + "transform_command", "primitive_command", "args1", "args2", "args3", + "args4", "args5", "args6", "args7", "args8", "args9", "args10", "number", 0 }; #endif @@ -1328,25 +1246,25 @@ namespace lol { const EasyMeshParser::rhs_number_type EasyMeshParser::yyrhs_[] = { - 49, 0, -1, 50, 0, -1, 51, -1, 51, 50, - -1, 54, -1, 52, 50, 53, -1, 45, -1, 46, - -1, 55, -1, 54, 55, -1, 56, -1, 57, -1, - 58, -1, 3, 62, -1, 3, 44, -1, 4, 62, - -1, 4, 44, -1, 28, 59, -1, 5, 59, -1, - 10, 59, -1, 15, 59, -1, 20, 61, -1, 6, - 59, -1, 11, 59, -1, 16, 59, -1, 7, 61, - -1, 12, 61, -1, 17, 61, -1, 8, 59, -1, - 13, 59, -1, 18, 59, -1, 21, 61, -1, 9, - -1, 14, -1, 19, -1, 23, 59, -1, 22, -1, - 24, -1, 25, -1, 26, -1, 27, -1, 29, 64, - -1, 30, 61, -1, 31, 62, -1, 32, 62, -1, - 33, 62, -1, 34, 61, -1, 41, 61, -1, 35, - 63, -1, 36, 62, -1, 37, 61, -1, 38, 60, - -1, 39, 60, -1, 40, 68, -1, 69, -1, 59, - 69, -1, 60, 69, -1, 61, 69, -1, 62, 69, - -1, 63, 69, -1, 64, 69, -1, 65, 69, -1, - 66, 69, -1, 67, 69, -1, 43, -1, 47, 69, - -1 + 50, 0, -1, 51, 0, -1, 52, -1, 52, 51, + -1, 55, -1, 53, 51, 54, -1, 46, -1, 47, + -1, 56, -1, 55, 56, -1, 57, -1, 58, -1, + 59, -1, 3, 63, -1, 3, 45, -1, 4, 63, + -1, 4, 45, -1, 29, 60, -1, 5, 60, -1, + 10, 60, -1, 15, 60, -1, 20, 62, -1, 6, + 60, -1, 11, 60, -1, 16, 60, -1, 7, 62, + -1, 12, 62, -1, 17, 62, -1, 8, 60, -1, + 13, 60, -1, 18, 60, -1, 21, 62, -1, 9, + -1, 14, -1, 19, -1, 23, 60, -1, 22, -1, + 24, -1, 25, -1, 26, -1, 27, -1, 28, -1, + 30, 65, -1, 30, 66, -1, 31, 62, -1, 32, + 63, -1, 33, 63, -1, 34, 61, -1, 35, 62, + -1, 42, 62, -1, 36, 64, -1, 37, 63, -1, + 38, 62, -1, 39, 61, -1, 40, 61, -1, 41, + 69, -1, 70, -1, 60, 70, -1, 61, 70, -1, + 62, 70, -1, 63, 70, -1, 64, 70, -1, 65, + 70, -1, 66, 70, -1, 67, 70, -1, 68, 70, + -1, 44, -1, 48, 70, -1 }; /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in @@ -1358,9 +1276,9 @@ namespace lol { 23, 26, 28, 30, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 91, 93, 95, 98, 100, 102, - 104, 106, 108, 111, 114, 117, 120, 123, 126, 129, - 132, 135, 138, 141, 144, 147, 149, 152, 155, 158, - 161, 164, 167, 170, 173, 176, 178 + 104, 106, 108, 110, 113, 116, 119, 122, 125, 128, + 131, 134, 137, 140, 143, 146, 149, 152, 154, 157, + 160, 163, 166, 169, 172, 175, 178, 181, 183 }; /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ @@ -1371,9 +1289,9 @@ namespace lol { 99, 103, 104, 105, 109, 110, 113, 114, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, - 142, 143, 147, 150, 151, 153, 155, 157, 158, 159, - 161, 163, 164, 165, 166, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 183, 184 + 142, 143, 144, 148, 151, 154, 155, 157, 159, 160, + 161, 162, 164, 166, 167, 168, 169, 174, 175, 176, + 177, 178, 179, 180, 181, 182, 183, 186, 187 }; // Print the state stack on the debug stream. @@ -1417,12 +1335,12 @@ namespace lol { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 47, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 48, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 45, 2, 46, 2, 2, 2, 2, 2, 2, + 2, 46, 2, 47, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -1442,7 +1360,8 @@ namespace lol { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45 }; if ((unsigned int) t <= yyuser_token_number_max_) return translate_table[t]; @@ -1451,26 +1370,26 @@ namespace lol { } const int EasyMeshParser::yyeof_ = 0; - const int EasyMeshParser::yylast_ = 159; + const int EasyMeshParser::yylast_ = 163; const int EasyMeshParser::yynnts_ = 22; const int EasyMeshParser::yyempty_ = -2; - const int EasyMeshParser::yyfinal_ = 95; + const int EasyMeshParser::yyfinal_ = 97; const int EasyMeshParser::yyterror_ = 1; const int EasyMeshParser::yyerrcode_ = 256; - const int EasyMeshParser::yyntokens_ = 48; + const int EasyMeshParser::yyntokens_ = 49; - const unsigned int EasyMeshParser::yyuser_token_number_max_ = 299; + const unsigned int EasyMeshParser::yyuser_token_number_max_ = 300; const EasyMeshParser::token_number_type EasyMeshParser::yyundef_token_ = 2; } // lol -/* Line 1136 of lalr1.cc */ -#line 1470 "generated/easymesh-parser.cpp" +/* Line 1053 of lalr1.cc */ +#line 1389 "generated/easymesh-parser.cpp" -/* Line 1138 of lalr1.cc */ -#line 187 "easymesh/easymesh-parser.y" +/* Line 1055 of lalr1.cc */ +#line 190 "easymesh/easymesh-parser.y" void lol::EasyMeshParser::error(const EasyMeshParser::location_type& l, diff --git a/src/generated/easymesh-parser.h b/src/generated/easymesh-parser.h index 5d68b950..2884e2cf 100644 --- a/src/generated/easymesh-parser.h +++ b/src/generated/easymesh-parser.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton interface for Bison LALR(1) parsers in C++ @@ -40,6 +40,20 @@ #include #include #include "stack.hh" + + +namespace lol { + +/* Line 34 of lalr1.cc */ +#line 49 "generated/easymesh-parser.h" + class position; + class location; + +} // lol + +/* Line 34 of lalr1.cc */ +#line 56 "generated/easymesh-parser.h" + #include "location.hh" /* Enabling traces. */ @@ -60,11 +74,30 @@ # define YYTOKEN_TABLE 0 #endif +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).begin = (Rhs)[1].begin; \ + (Current).end = (Rhs)[N].end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = (Rhs)[0].end; \ + } \ +} while (false) +#endif + namespace lol { -/* Line 35 of lalr1.cc */ -#line 68 "generated/easymesh-parser.h" +/* Line 34 of lalr1.cc */ +#line 101 "generated/easymesh-parser.h" /// A Bison parser. class EasyMeshParser @@ -75,7 +108,7 @@ namespace lol { union semantic_type { -/* Line 35 of lalr1.cc */ +/* Line 34 of lalr1.cc */ #line 36 "easymesh/easymesh-parser.y" float fval; @@ -85,8 +118,8 @@ namespace lol { -/* Line 35 of lalr1.cc */ -#line 90 "generated/easymesh-parser.h" +/* Line 34 of lalr1.cc */ +#line 123 "generated/easymesh-parser.h" }; #else typedef YYSTYPE semantic_type; @@ -122,25 +155,26 @@ namespace lol { T_RADIALJITTER = 278, T_CSGUNION = 279, T_CSGSUBSTRACT = 280, - T_CSGAND = 281, - T_CSGXOR = 282, - T_CHAMFER = 283, - T_CYLINDER = 284, - T_BOX = 285, - T_SMOOTHCHAMFBOX = 286, - T_FLATCHAMFBOX = 287, - T_SPHERE = 288, - T_CAPSULE = 289, - T_STAR = 290, - T_EXPANDEDSTAR = 291, - T_DISC = 292, - T_TRIANGLE = 293, - T_QUAD = 294, - T_COG = 295, - T_TORUS = 296, - T_ERROR = 297, - NUMBER = 298, - COLOR = 299 + T_CSGSUBSTRACTLOSS = 281, + T_CSGAND = 282, + T_CSGXOR = 283, + T_CHAMFER = 284, + T_CYLINDER = 285, + T_BOX = 286, + T_SMOOTHCHAMFBOX = 287, + T_FLATCHAMFBOX = 288, + T_SPHERE = 289, + T_CAPSULE = 290, + T_STAR = 291, + T_EXPANDEDSTAR = 292, + T_DISC = 293, + T_TRIANGLE = 294, + T_QUAD = 295, + T_COG = 296, + T_TORUS = 297, + T_ERROR = 298, + NUMBER = 299, + COLOR = 300 }; }; @@ -214,14 +248,6 @@ namespace lol { /// The location stack. location_stack_type yylocation_stack_; - /// Whether the given \c yypact_ value indicates a defaulted state. - /// \param yyvalue the value to check - static bool yy_pact_value_is_default_ (int yyvalue); - - /// Whether the given \c yytable_ value indicates a syntax error. - /// \param yyvalue the value to check - static bool yy_table_value_is_error_ (int yyvalue); - /// Internal symbol numbers. typedef unsigned char token_number_type; /* Tables. */ @@ -229,12 +255,12 @@ namespace lol { static const signed char yypact_[]; static const signed char yypact_ninf_; - /// For a state, default reduction number. + /// For a state, default rule to reduce. /// Unless\a yytable_ specifies something else to do. /// Zero means the default is an error. static const unsigned char yydefact_[]; - static const signed char yypgoto_[]; + static const short int yypgoto_[]; static const signed char yydefgoto_[]; /// What to do in a state. @@ -260,8 +286,10 @@ namespace lol { static const char* const yytname_[]; #endif +#if YYERROR_VERBOSE /// Convert the symbol name \a n to a form suitable for a diagnostic. - static std::string yytnamerr_ (const char *n); + virtual std::string yytnamerr_ (const char *n); +#endif #if YYDEBUG /// A type to store symbol numbers and -1. @@ -319,8 +347,8 @@ namespace lol { } // lol -/* Line 35 of lalr1.cc */ -#line 324 "generated/easymesh-parser.h" +/* Line 34 of lalr1.cc */ +#line 352 "generated/easymesh-parser.h" diff --git a/src/generated/easymesh-scanner.cpp b/src/generated/easymesh-scanner.cpp index cf0f8cf0..e7526e6f 100644 --- a/src/generated/easymesh-scanner.cpp +++ b/src/generated/easymesh-scanner.cpp @@ -330,8 +330,8 @@ typedef unsigned char YY_CHAR; *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 51 -#define YY_END_OF_BUFFER 52 +#define YY_NUM_RULES 52 +#define YY_END_OF_BUFFER 53 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -339,17 +339,17 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[82] = +static yyconst flex_int16_t yy_accept[83] = { 0, - 0, 0, 52, 50, 49, 48, 50, 50, 45, 50, - 44, 46, 47, 50, 50, 50, 50, 17, 7, 0, - 0, 44, 44, 0, 27, 28, 31, 0, 0, 34, - 35, 38, 3, 0, 19, 20, 21, 22, 8, 9, + 0, 0, 53, 51, 50, 49, 51, 51, 46, 51, + 45, 47, 48, 51, 51, 51, 51, 17, 7, 0, + 0, 45, 45, 0, 28, 29, 32, 0, 0, 35, + 36, 39, 3, 0, 19, 20, 21, 22, 8, 9, 10, 1, 14, 15, 16, 0, 0, 4, 5, 6, - 0, 0, 44, 0, 30, 32, 0, 0, 0, 39, - 0, 2, 11, 12, 13, 18, 40, 29, 33, 36, - 37, 25, 24, 23, 26, 41, 0, 42, 0, 43, - 0 + 0, 0, 45, 0, 31, 33, 0, 0, 0, 40, + 0, 2, 11, 12, 13, 18, 41, 30, 34, 37, + 38, 26, 24, 23, 27, 42, 25, 0, 43, 0, + 44, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -365,9 +365,9 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 1, 12, 1, 1, 1, 13, 14, 15, 16, - 17, 18, 19, 20, 1, 21, 1, 1, 22, 1, - 23, 24, 25, 26, 27, 28, 29, 1, 30, 31, - 32, 33, 1, 1, 1, 1, 1, 1, 1, 1, + 17, 18, 19, 20, 1, 21, 1, 22, 23, 1, + 24, 25, 26, 27, 28, 29, 30, 1, 31, 32, + 33, 34, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -384,78 +384,78 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[34] = +static yyconst flex_int32_t yy_meta[35] = { 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1 + 1, 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[90] = +static yyconst flex_int16_t yy_base[91] = { 0, - 0, 0, 111, 112, 112, 112, 0, 27, 29, 102, - 31, 112, 112, 35, 20, 11, 24, 39, 60, 0, - 101, 51, 57, 70, 112, 64, 112, 81, 92, 112, - 64, 83, 112, 86, 112, 112, 112, 112, 112, 112, - 112, 90, 112, 112, 112, 49, 73, 112, 112, 112, - 0, 93, 91, 73, 112, 112, 82, 81, 74, 112, - 71, 112, 112, 112, 112, 112, 0, 112, 112, 112, - 112, 112, 112, 112, 112, 0, 0, 0, 0, 112, - 112, 88, 87, 84, 83, 67, 64, 62, 44 + 0, 0, 113, 114, 114, 114, 0, 28, 30, 104, + 32, 114, 114, 36, 27, 11, 25, 41, 35, 0, + 103, 69, 70, 76, 114, 47, 114, 82, 94, 114, + 46, 84, 114, 88, 114, 114, 114, 114, 114, 114, + 114, 92, 114, 114, 114, 56, 74, 114, 114, 114, + 0, 96, 95, 76, 114, 114, 85, 83, 76, 114, + 70, 114, 114, 114, 114, 114, 0, 114, 114, 114, + 114, 114, 73, 114, 114, 0, 114, 0, 0, 0, + 114, 114, 92, 91, 90, 89, 83, 70, 68, 39 } ; -static yyconst flex_int16_t yy_def[90] = +static yyconst flex_int16_t yy_def[91] = { 0, - 81, 1, 81, 81, 81, 81, 82, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 83, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 84, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 85, 81, 81, 81, - 81, 81, 81, 81, 81, 86, 87, 88, 89, 81, - 0, 81, 81, 81, 81, 81, 81, 81, 81 + 82, 1, 82, 82, 82, 82, 83, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 84, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 85, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 86, 82, 82, 82, + 82, 82, 82, 82, 82, 87, 82, 88, 89, 90, + 82, 0, 82, 82, 82, 82, 82, 82, 82, 82 } ; -static yyconst flex_int16_t yy_nxt[146] = +static yyconst flex_int16_t yy_nxt[149] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 4, 4, 12, 13, 14, 4, 15, 4, 4, 4, 4, 4, - 4, 16, 4, 4, 4, 17, 18, 19, 4, 4, - 4, 4, 4, 21, 22, 21, 22, 21, 22, 33, - 24, 35, 36, 37, 38, 80, 34, 24, 25, 26, - 27, 28, 29, 42, 39, 40, 41, 21, 22, 30, - 24, 31, 32, 79, 23, 78, 24, 24, 77, 43, - 44, 45, 46, 24, 52, 52, 54, 53, 58, 63, - 64, 65, 55, 72, 76, 67, 47, 59, 51, 20, - 48, 49, 50, 71, 70, 69, 68, 73, 53, 74, - - 53, 75, 66, 62, 61, 60, 57, 56, 23, 23, - 81, 3, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81 + 4, 4, 16, 4, 4, 4, 17, 18, 19, 4, + 4, 4, 4, 4, 21, 22, 21, 22, 21, 22, + 81, 24, 35, 36, 37, 38, 33, 46, 24, 25, + 26, 27, 28, 29, 34, 42, 39, 40, 41, 54, + 58, 30, 47, 31, 32, 55, 48, 49, 50, 80, + 59, 79, 43, 44, 45, 21, 22, 23, 24, 24, + 52, 52, 72, 53, 78, 24, 24, 63, 64, 65, + 76, 67, 51, 20, 77, 71, 70, 73, 69, 74, + + 68, 75, 53, 53, 66, 62, 61, 60, 57, 56, + 23, 23, 82, 3, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82 } ; -static yyconst flex_int16_t yy_chk[146] = +static yyconst flex_int16_t yy_chk[149] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 8, 8, 9, 9, 11, 11, 15, - 11, 16, 16, 16, 17, 89, 15, 11, 14, 14, - 14, 14, 14, 18, 17, 17, 17, 22, 22, 14, - 22, 14, 14, 88, 23, 87, 23, 22, 86, 18, - 18, 18, 19, 23, 24, 24, 26, 24, 31, 46, - 46, 46, 26, 61, 85, 84, 19, 31, 83, 82, - 19, 19, 19, 59, 58, 57, 54, 61, 53, 61, - - 52, 61, 47, 42, 34, 32, 29, 28, 21, 10, - 3, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81 + 1, 1, 1, 1, 8, 8, 9, 9, 11, 11, + 90, 11, 16, 16, 16, 17, 15, 19, 11, 14, + 14, 14, 14, 14, 15, 18, 17, 17, 17, 26, + 31, 14, 19, 14, 14, 26, 19, 19, 19, 89, + 31, 88, 18, 18, 18, 22, 22, 23, 22, 23, + 24, 24, 61, 24, 87, 22, 23, 46, 46, 46, + 86, 85, 84, 83, 73, 59, 58, 61, 57, 61, + + 54, 61, 53, 52, 47, 42, 34, 32, 29, 28, + 21, 10, 3, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82 } ; /* The intent behind this definition is that it'll catch @@ -670,13 +670,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 82 ) + if ( yy_current_state >= 83 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 81 ); + while ( yy_current_state != 82 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -819,81 +819,86 @@ YY_RULE_SETUP case 25: YY_RULE_SETUP #line 77 "easymesh/easymesh-scanner.l" -{ return token::T_CSGAND; } +{ return token::T_CSGSUBSTRACTLOSS; } YY_BREAK case 26: YY_RULE_SETUP #line 78 "easymesh/easymesh-scanner.l" -{ return token::T_CSGXOR; } +{ return token::T_CSGAND; } YY_BREAK case 27: YY_RULE_SETUP -#line 80 "easymesh/easymesh-scanner.l" -{ return token::T_BOX; } +#line 79 "easymesh/easymesh-scanner.l" +{ return token::T_CSGXOR; } YY_BREAK case 28: YY_RULE_SETUP #line 81 "easymesh/easymesh-scanner.l" -{ return token::T_CYLINDER; } +{ return token::T_BOX; } YY_BREAK case 29: YY_RULE_SETUP #line 82 "easymesh/easymesh-scanner.l" -{ return token::T_CAPSULE; } +{ return token::T_CYLINDER; } YY_BREAK case 30: YY_RULE_SETUP #line 83 "easymesh/easymesh-scanner.l" -{ return token::T_COG; } +{ return token::T_CAPSULE; } YY_BREAK case 31: YY_RULE_SETUP #line 84 "easymesh/easymesh-scanner.l" -{ return token::T_DISC; } +{ return token::T_COG; } YY_BREAK case 32: YY_RULE_SETUP #line 85 "easymesh/easymesh-scanner.l" -{ return token::T_EXPANDEDSTAR; } +{ return token::T_DISC; } YY_BREAK case 33: YY_RULE_SETUP #line 86 "easymesh/easymesh-scanner.l" -{ return token::T_FLATCHAMFBOX; } +{ return token::T_EXPANDEDSTAR; } YY_BREAK case 34: YY_RULE_SETUP #line 87 "easymesh/easymesh-scanner.l" -{ return token::T_QUAD; } +{ return token::T_FLATCHAMFBOX; } YY_BREAK case 35: YY_RULE_SETUP #line 88 "easymesh/easymesh-scanner.l" -{ return token::T_STAR; } +{ return token::T_QUAD; } YY_BREAK case 36: YY_RULE_SETUP #line 89 "easymesh/easymesh-scanner.l" -{ return token::T_SMOOTHCHAMFBOX; } +{ return token::T_STAR; } YY_BREAK case 37: YY_RULE_SETUP #line 90 "easymesh/easymesh-scanner.l" -{ return token::T_SPHERE; } +{ return token::T_SMOOTHCHAMFBOX; } YY_BREAK case 38: YY_RULE_SETUP #line 91 "easymesh/easymesh-scanner.l" -{ return token::T_TRIANGLE; } +{ return token::T_SPHERE; } YY_BREAK case 39: YY_RULE_SETUP #line 92 "easymesh/easymesh-scanner.l" -{ return token::T_TORUS; } +{ return token::T_TRIANGLE; } YY_BREAK case 40: YY_RULE_SETUP -#line 94 "easymesh/easymesh-scanner.l" +#line 93 "easymesh/easymesh-scanner.l" +{ return token::T_TORUS; } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 95 "easymesh/easymesh-scanner.l" { uint32_t tmp = std::strtol(yytext + 1, NULL, 16); yylval->u32val = 0x11000000u * (tmp >> 8) @@ -902,9 +907,9 @@ YY_RULE_SETUP | 0x000000ffu; return token::COLOR; } YY_BREAK -case 41: +case 42: YY_RULE_SETUP -#line 101 "easymesh/easymesh-scanner.l" +#line 102 "easymesh/easymesh-scanner.l" { uint32_t tmp = std::strtol(yytext + 1, NULL, 16); yylval->u32val = 0x11000000u * (tmp >> 12) @@ -913,64 +918,64 @@ YY_RULE_SETUP | 0x00000011u * (tmp & 0xf); return token::COLOR; } YY_BREAK -case 42: +case 43: YY_RULE_SETUP -#line 108 "easymesh/easymesh-scanner.l" +#line 109 "easymesh/easymesh-scanner.l" { yylval->u32val = 0xffu | 0x100u * (uint32_t)std::strtol(yytext + 1, NULL, 16); return token::COLOR; } YY_BREAK -case 43: +case 44: YY_RULE_SETUP -#line 112 "easymesh/easymesh-scanner.l" +#line 113 "easymesh/easymesh-scanner.l" { yylval->u32val = (uint32_t)std::strtol(yytext + 1, NULL, 16); return token::COLOR; } YY_BREAK -case 44: +case 45: YY_RULE_SETUP -#line 115 "easymesh/easymesh-scanner.l" +#line 116 "easymesh/easymesh-scanner.l" { yylval->fval = std::atof(yytext); return token::NUMBER; } YY_BREAK -case 45: -YY_RULE_SETUP -#line 117 "easymesh/easymesh-scanner.l" -{ return token_type('-'); } - YY_BREAK case 46: YY_RULE_SETUP #line 118 "easymesh/easymesh-scanner.l" -{ return token_type('['); } +{ return token_type('-'); } YY_BREAK case 47: YY_RULE_SETUP #line 119 "easymesh/easymesh-scanner.l" -{ return token_type(']'); } +{ return token_type('['); } YY_BREAK case 48: YY_RULE_SETUP #line 120 "easymesh/easymesh-scanner.l" -{ /* ignore this */ } +{ return token_type(']'); } YY_BREAK case 49: -/* rule 49 can match eol */ YY_RULE_SETUP #line 121 "easymesh/easymesh-scanner.l" { /* ignore this */ } YY_BREAK case 50: +/* rule 50 can match eol */ YY_RULE_SETUP #line 122 "easymesh/easymesh-scanner.l" -{ return token::T_ERROR; } +{ /* ignore this */ } YY_BREAK case 51: YY_RULE_SETUP -#line 124 "easymesh/easymesh-scanner.l" +#line 123 "easymesh/easymesh-scanner.l" +{ return token::T_ERROR; } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 125 "easymesh/easymesh-scanner.l" ECHO; YY_BREAK -#line 974 "generated/easymesh-scanner.cpp" +#line 979 "generated/easymesh-scanner.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1352,7 +1357,7 @@ int yyFlexLexer::yy_get_next_buffer() while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 82 ) + if ( yy_current_state >= 83 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1380,11 +1385,11 @@ int yyFlexLexer::yy_get_next_buffer() while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 82 ) + if ( yy_current_state >= 83 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 81); + yy_is_jam = (yy_current_state == 82); return yy_is_jam ? 0 : yy_current_state; } @@ -1871,7 +1876,7 @@ void EasyMeshfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 124 "easymesh/easymesh-scanner.l" +#line 125 "easymesh/easymesh-scanner.l" diff --git a/test/MeshViewer.cpp b/test/MeshViewer.cpp index 90f401c2..257fd2f7 100644 --- a/test/MeshViewer.cpp +++ b/test/MeshViewer.cpp @@ -301,8 +301,8 @@ public: m_meshes.Push(EasyMesh(), false, .0f, vec3(.0f)); if (!m_meshes.Last().m1.Compile(cmd.C())) m_meshes.Pop(); - else - m_meshes.Last().m1.ComputeTexCoord(0.2f, 2); + //else + // m_meshes.Last().m1.ComputeTexCoord(0.2f, 2); } } } diff --git a/test/MeshViewerBuffer.txt b/test/MeshViewerBuffer.txt index 10c70392..e1a34ba8 100644 --- a/test/MeshViewerBuffer.txt +++ b/test/MeshViewerBuffer.txt @@ -1,11 +1,18 @@ -[sc#88f ab 4 4 4] -//[sc#ff2 asph 2 4 4 4] -//[sc#ff2 acap 2 4 4] -//[sc#ff2 ac 12 4 4 4 0 0] +[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 tax .4 .4 0] +//[sc#ff2 asph 2 4 tx 4 tax 1 1 0] +//[sc#ff2 acap 1 4 4] +//[sc#ff2 scb#ff2 ac 10 4 4 4 0 0 1] +//[sc#ff2 scb#ff2 ad 10 4 0] +//[sc#ff2 scb#ff2 ato 40 1 4] +//[sc#ff2 scb#2ff at 4 1] +//[sc#ff2 scb#2ff aq 4 0] +//[sc#ff2 scb#2ff aes 5 3 6 2] +//[sc#ff2 scb#2ff as 5 2 5 0 0] +//[sc#ff2 scb#2ff acg 2 10 .1 .1 .4 .4 .1 .1 0 1] //[sc#ff2 asph 2 10 10 10] //[sc#400 asph 2 10 10 10 t 2 2 2 csgs] -//[sc#88f afcb 10 10 10 .25 tx 0 sc 0.1] -//[sc#22f afcb 10 10 10 .25 t 2 2 2 csgs] +//[sc#88f afcb 10 10 10 .25 tx 0] +//[sc#fff afcb 10 10 10 .25 t 2 2 2] //[sc#fff afcb 7 7 7 .25] //[sc#ff2 afcb 7 7 7 .25 t 1 1 1]