Example #1
0
/// \brief Modify the heightfield data using the TerrainMod objects which
/// are attached to this Segment.
///
/// Usually called from Segment::populate(). It is not normally necessary to
/// call this function from the application.
void Segment::applyMod(const TerrainMod *t) 
{
    int lx,hx,ly,hy;
    WFMath::AxisBox<2> bbox=t->bbox();
    bbox.shift(WFMath::Vector<2>(-m_xRef, -m_yRef));
    if (clipToSegment(bbox, lx, hx, ly, hy)) {
        for (int i=ly; i<=hy; i++) {
            for (int j=lx; j<=hx; j++) {
                t->apply(m_points[i * m_size + j], j + m_xRef, i + m_yRef);
            }
        }
    }

    //currently mods dont fix the normals
    invalidate(false);
}
Example #2
0
/// \brief Modify the heightfield data using the TerrainMod objects which
/// are attached to this Segment.
///
/// Usually called from Segment::populate(). It is not normally necessary to
/// call this function from the application.
void Segment::applyMod(const TerrainMod *t)
{
    int lx,hx,ly,hy;
    float* points = m_heightMap.getData();
    WFMath::AxisBox<2> bbox=t->bbox();
    bbox.shift(WFMath::Vector<2>(-m_xRef, -m_yRef));
    if (clipToSegment(bbox, lx, hx, ly, hy)) {
        for (int i=ly; i<=hy; i++) {
            for (int j=lx; j<=hx; j++) {
                float& h = points[i * m_size + j];
                t->apply(h, j + m_xRef, i + m_yRef);
                m_heightMap.checkMaxMin(h);
            }
        }
    }

    //currently mods dont fix the normals
    invalidate(false);
}
Example #3
0
/// \brief Modify the heightfield data using the TerrainMod objects which
/// are attached to this Segment.
///
/// Usually called from Segment::populate(). It is not normally necessary to
/// call this function from the application.
void Segment::applyMod(TerrainMod const *t)
{
  unsigned int lx, hx, ly, hy;
  Effector::box const & bbox = t->bbox();

  rect_type local_box;
  boost::geometry::strategy::transform::translate_transformer<float, 2, 2>
  translate((float)-m_xRef, (float)-m_yRef);
  boost::geometry::transform(bbox, local_box, translate);

  if (clipToSegment(local_box, lx, hx, ly, hy))
  {
    for (unsigned int i = ly; i <= hy; i++)
    {
      for (unsigned int j = lx; j <= hx; j++)
      {
        t->apply(m_points[i * m_size + j], j + m_xRef, i + m_yRef);
      }
    }
  }

  //currently mods dont fix the normals
  invalidate(false);
}