From d95f6ee7981c2478eb0ebfe8bc5ffe4f7874f300 Mon Sep 17 00:00:00 2001 From: cignoni Date: Tue, 17 Jun 2008 23:08:53 +0000 Subject: [PATCH] Added a constructor from point4 of the same type to allow the use of Point4 operator; e.g. col1 = col2 + col3 Added Clamp operator to get rid of out of 0..1 range values for floats --- vcg/space/color4.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vcg/space/color4.h b/vcg/space/color4.h index f4ea11f4..2cac1e5b 100644 --- a/vcg/space/color4.h +++ b/vcg/space/color4.h @@ -118,6 +118,7 @@ public: inline Color4 ( const T nx, const T ny, const T nz , const T nw ) :Point4(nx,ny,nz,nw) {}; // inline Color4 ( Color4 &c) :Point4(c) {}; + inline Color4 ( const Point4 &c) :Point4(c) {}; inline Color4 (){}; inline Color4 (ColorConstant cc); template @@ -362,6 +363,14 @@ inline Color4::Color4(Color4::ColorConstant cc) Import(Color4((Color4::ColorConstant)cc)); } +inline Color4 Clamp(Color4 &c) +{ + c[0]=math::Clamp(c[0],0.0f,1.0f); + c[1]=math::Clamp(c[1],0.0f,1.0f); + c[2]=math::Clamp(c[2],0.0f,1.0f); + c[3]=math::Clamp(c[3],0.0f,1.0f); + return c; +} typedef Color4 Color4b; typedef Color4 Color4f;