Changeset 1879


Ignore:
Timestamp:
Sep 5, 2012, 3:11:45 PM (7 years ago)
Author:
sam
Message:

easymesh: minor torus mesh tweaks.

File:
1 edited

Legend:

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

    r1875 r1879  
    512512{
    513513    int ibase = m_indices.Count();
    514 
    515     for (int j = 0; j < ndivisions; j++)
    516     for (int i = 0; i < ndivisions; i++)
     514    int nidiv = ndivisions; /* Cross-section */
     515    int njdiv = ndivisions; /* Full circumference */
     516
     517    for (int j = 0; j < njdiv; j++)
     518    for (int i = 0; i < 2 * nidiv; i++)
    517519    {
    518520        for (int di = 0; di < 2; di++)
    519521        for (int dj = 0; dj < 2; dj++)
    520522        {
    521             int i2 = (i + di) % ndivisions;
    522             int j2 = (j + dj) % ndivisions;
    523             float x = 0.5f * (r1 + r2) + 0.5 * (r2 - r1) * lol::cos(2.0 * M_PI * i2 / ndivisions);
    524             float y = 0.5f * (r2 - r1) * lol::sin(2.0 * M_PI * i2 / ndivisions);
     523            int i2 = (i + di) % nidiv;
     524            int j2 = (j + dj) % njdiv;
     525            float x = 0.5f * (r1 + r2) + 0.5 * (r2 - r1) * lol::cos(2.0 * M_PI * i2 / nidiv);
     526            float y = 0.5f * (r2 - r1) * lol::sin(2.0 * M_PI * i2 / nidiv);
    525527            float z = 0.0f;
    526528
    527             float ca = lol::cos(2.0 * M_PI * j2 / ndivisions);
    528             float sa = lol::sin(2.0 * M_PI * j2 / ndivisions);
     529            float ca = lol::cos(2.0 * M_PI * j2 / njdiv);
     530            float sa = lol::sin(2.0 * M_PI * j2 / njdiv);
    529531            float x2 = x * ca - z * sa;
    530532            float z2 = z * ca + x * sa;
Note: See TracChangeset for help on using the changeset viewer.