[codereview] Moved depth to constructor.

This commit is contained in:
Dmitry Kunin 2014-01-13 16:38:56 +03:00 committed by Alex Zolotarev
parent ab1183d9e3
commit fedf07299e
3 changed files with 6 additions and 19 deletions

View file

@ -5,21 +5,10 @@
namespace df
{
AreaShape::AreaShape(const Color & c)
AreaShape::AreaShape(const Color & c, float depth)
: m_color(c)
, m_depth(0.0f)
{
}
void AreaShape::SetDepth(float depth)
{
if (m_depth != depth)
{
m_depth = depth;
for (size_t i = 0; i < m_vertexes.size() ; ++i)
m_vertexes[i].m_z = m_depth;
}
}
, m_depth(depth)
{}
void AreaShape::AddTriangle(const m2::PointF & v1,
const m2::PointF & v2,

View file

@ -13,8 +13,7 @@ namespace df
class AreaShape : public MapShape
{
public:
AreaShape(Color const & c);
void SetDepth(float depth);
AreaShape(Color const & c, float depth);
void AddTriangle(const m2::PointF & v1,
const m2::PointF & v2,

View file

@ -8,8 +8,7 @@ namespace
{
df::AreaShape * CreateFakeShape1()
{
df::AreaShape * shape = new df::AreaShape(Extract(0xFFEEAABB));
shape->SetDepth(0.3f);
df::AreaShape * shape = new df::AreaShape(Extract(0xFFEEAABB), 0.3f);
shape->AddTriangle(m2::PointF(0.0f, 0.0f),
m2::PointF(1.0f, 0.0f),
m2::PointF(0.0f, 1.0f));
@ -22,7 +21,7 @@ namespace
df::AreaShape * CreateFakeShape2()
{
df::AreaShape * shape = new df::AreaShape(Extract(0xFF66AAFF));
df::AreaShape * shape = new df::AreaShape(Extract(0xFF66AAFF), 0.0f);
shape->AddTriangle(m2::PointF(-0.5f, 0.5f),
m2::PointF(0.5f, 1.5f),
m2::PointF(0.5f, -0.5f));