Skip to content
Snippets Groups Projects
Commit cc08591d authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Add string parser to Vector4

parent 01858532
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,12 @@
// LLVector4
// WARNING: Don't use these for global const definitions!
// For example:
// const LLQuaternion(0.5f * F_PI, LLVector3d::zero);
// at the top of a *.cpp file might not give you what you think.
const LLVector4 LLVector4::zero(0.f, 0.f, 0.f, 0.f);
// Axis-Angle rotations
/*
......@@ -102,6 +108,24 @@ std::ostream& operator<<(std::ostream& s, const LLVector4 &a)
}
BOOL LLVector4::parseVector4(const std::string& buf, LLVector4* value)
{
if (buf.empty() || value == NULL)
{
return FALSE;
}
LLVector4 v;
S32 count = sscanf(buf.c_str(), "%lf %lf %lf %lf", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3);
if (4 == count)
{
value->setVec(v);
return TRUE;
}
return FALSE;
}
// Non-member functions
F32 angle_between( const LLVector4& a, const LLVector4& b )
......
......@@ -44,6 +44,9 @@ class LLVector4
{
public:
F32 mV[LENGTHOFVECTOR4];
const static LLVector4 zero;
LLVector4(); // Initializes LLVector4 to (0, 0, 0, 1)
explicit LLVector4(const F32 *vec); // Initializes LLVector4 to (vec[0]. vec[1], vec[2], vec[3])
explicit LLVector4(const F64 *vec); // Initialized LLVector4 to ((F32) vec[0], (F32) vec[1], (F32) vec[3], (F32) vec[4]);
......@@ -135,6 +138,8 @@ class LLVector4
friend const LLVector4& operator/=(LLVector4 &a, F32 k); // Return a divided by scaler k
friend LLVector4 operator-(const LLVector4 &a); // Return vector -a
static BOOL parseVector4(const std::string& buf, LLVector4* value);
};
// Non-member functions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment