52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
/* -----------------------------------------------------------------------------
|
|
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 <uint> pol_index;
|
|
ComputePolygonIndex(pol_index);
|
|
|
|
Array <VertexToVertex> vtx_to_vtx;
|
|
ComputeVertexToVertex(vtx_to_vtx);
|
|
|
|
Array <Color> 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 <Color>::Swap(rgb, dst);
|
|
}
|
|
}
|
|
//------------------------------------------------------------------------------
|