/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #include "core/geometry.h" using namespace GS; using namespace GS::Core; //------------------------------------------------------------------------------ void Geometry::SmoothRGB(uint pass_count, float max_smooth_angle) { if (!rgb) return; Array pol_index; ComputePolygonIndex(pol_index); Array vtx_to_vtx; ComputeVertexToVertex(vtx_to_vtx); Array dst(binding.GetCount()); for (uint ns = 0; ns < pass_count; ++ns) { for (uint np = 0; np < pol.GetCount(); ++np) for (uint nv = 0; nv < pol[np].vtx_count; ++nv) { uint imv = pol[np].binding[nv], iv = pol_index[np] + nv; dst[iv] = rgb[iv] * 4.f; uint nrgb = 4; for (uint nvv = 0; nvv < vtx_to_vtx[imv].vtx_count; nvv++) if (pol[vtx_to_vtx[imv].vtx[nvv].pol_index].material == pol[np].material) { dst[iv] += rgb[pol_index[vtx_to_vtx[imv].vtx[nvv].pol_index] + vtx_to_vtx[imv].vtx[nvv].vtx_index]; nrgb++; } dst[iv] /= (float)nrgb; } Array ::Swap(rgb, dst); } } //------------------------------------------------------------------------------