[EEP] Add all the new llinventory windlight settings files

Also add v3colorutil.h
Also update LLQuaternion and its LLSD pieces
This commit is contained in:
Lirusaito
2019-03-24 21:36:41 -04:00
parent fdffe2e06a
commit 28c814e4ef
18 changed files with 5341 additions and 10 deletions

View File

@@ -87,6 +87,7 @@ set(llmath_HEADER_FILES
raytrace.h
v2math.h
v3color.h
v3colorutil.h
v3dmath.h
v3math.h
v4color.h

View File

@@ -104,6 +104,11 @@ LLQuaternion::LLQuaternion(const LLVector3 &x_axis,
normalize();
}
LLQuaternion::LLQuaternion(const LLSD &sd)
{
setValue(sd);
}
// Quatizations
void LLQuaternion::quantize16(F32 lower, F32 upper)
{
@@ -860,6 +865,26 @@ void LLQuaternion::getAngleAxis(F32* angle, LLVector3 &vec) const
}
}
const LLQuaternion& LLQuaternion::setFromAzimuthAndAltitude(F32 azimuthRadians, F32 altitudeRadians)
{
// euler angle inputs are complements of azimuth/altitude which are measured from zenith
F32 pitch = llclamp(F_PI_BY_TWO - altitudeRadians, 0.0f, F_PI_BY_TWO);
F32 yaw = llclamp(F_PI_BY_TWO - azimuthRadians, 0.0f, F_PI_BY_TWO);
setEulerAngles(0.0f, pitch, yaw);
return *this;
}
void LLQuaternion::getAzimuthAndAltitude(F32 &azimuthRadians, F32 &altitudeRadians)
{
F32 rick_roll;
F32 pitch;
F32 yaw;
getEulerAngles(&rick_roll, &pitch, &yaw);
// make these measured from zenith
altitudeRadians = llclamp(F_PI_BY_TWO - pitch, 0.0f, F_PI_BY_TWO);
azimuthRadians = llclamp(F_PI_BY_TWO - yaw, 0.0f, F_PI_BY_TWO);
}
// quaternion does not need to be normalized
void LLQuaternion::getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) const
{

View File

@@ -28,6 +28,7 @@
#define LLQUATERNION_H
#include <iostream>
#include "llsd.h"
#ifndef LLMATH_H //enforce specific include order to avoid tangling inline dependencies
#error "Please include llmath.h first."
@@ -63,6 +64,10 @@ public:
LLQuaternion(const LLVector3 &x_axis,
const LLVector3 &y_axis,
const LLVector3 &z_axis); // Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis]
explicit LLQuaternion(const LLSD &sd); // Initializes Quaternion from LLSD array.
LLSD getValue() const;
void setValue(const LLSD& sd);
BOOL isIdentity() const;
BOOL isNotIdentity() const;
@@ -79,6 +84,7 @@ public:
const LLQuaternion& set(const F32 *q); // Sets Quaternion to normalize(quat[VX], quat[VY], quat[VZ], quat[VW])
const LLQuaternion& set(const LLMatrix3 &mat); // Sets Quaternion to mat2quat(mat)
const LLQuaternion& set(const LLMatrix4 &mat); // Sets Quaternion to mat2quat(mat)
const LLQuaternion& setFromAzimuthAndAltitude(F32 azimuth, F32 altitude);
const LLQuaternion& setAngleAxis(F32 angle, F32 x, F32 y, F32 z); // Sets Quaternion to axis_angle2quat(angle, x, y, z)
const LLQuaternion& setAngleAxis(F32 angle, const LLVector3 &vec); // Sets Quaternion to axis_angle2quat(angle, vec)
@@ -100,6 +106,7 @@ public:
void getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const; // returns rotation in radians about axis x,y,z
void getAngleAxis(F32* angle, LLVector3 &vec) const;
void getEulerAngles(F32 *roll, F32* pitch, F32 *yaw) const;
void getAzimuthAndAltitude(F32 &azimuth, F32 &altitude);
F32 normalize(); // Normalizes Quaternion and returns magnitude
F32 normQuat(); // deprecated
@@ -166,6 +173,24 @@ public:
//static U32 mMultCount;
};
inline LLSD LLQuaternion::getValue() const
{
LLSD ret;
ret[0] = mQ[0];
ret[1] = mQ[1];
ret[2] = mQ[2];
ret[3] = mQ[3];
return ret;
}
inline void LLQuaternion::setValue(const LLSD& sd)
{
mQ[0] = sd[0].asReal();
mQ[1] = sd[1].asReal();
mQ[2] = sd[2].asReal();
mQ[3] = sd[3].asReal();
}
// checker
inline BOOL LLQuaternion::isFinite() const
{

115
indra/llmath/v3colorutil.h Normal file
View File

@@ -0,0 +1,115 @@
/**
* @file v3color.h
* @brief LLColor3 class header file.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_V3COLORUTIL_H
#define LL_V3COLORUTIL_H
#include "v3color.h"
inline LLColor3 componentDiv(LLColor3 const &left, LLColor3 const & right)
{
return LLColor3(left.mV[0] / right.mV[0],
left.mV[1] / right.mV[1],
left.mV[2] / right.mV[2]);
}
inline LLColor3 componentMult(LLColor3 const &left, LLColor3 const & right)
{
return LLColor3(left.mV[0] * right.mV[0],
left.mV[1] * right.mV[1],
left.mV[2] * right.mV[2]);
}
inline LLColor3 componentExp(LLColor3 const &v)
{
return LLColor3(exp(v.mV[0]),
exp(v.mV[1]),
exp(v.mV[2]));
}
inline LLColor3 componentPow(LLColor3 const &v, F32 exponent)
{
return LLColor3(pow(v.mV[0], exponent),
pow(v.mV[1], exponent),
pow(v.mV[2], exponent));
}
inline LLColor3 componentSaturate(LLColor3 const &v)
{
return LLColor3(std::max(std::min(v.mV[0], 1.f), 0.f),
std::max(std::min(v.mV[1], 1.f), 0.f),
std::max(std::min(v.mV[2], 1.f), 0.f));
}
inline LLColor3 componentSqrt(LLColor3 const &v)
{
return LLColor3(sqrt(v.mV[0]),
sqrt(v.mV[1]),
sqrt(v.mV[2]));
}
inline void componentMultBy(LLColor3 & left, LLColor3 const & right)
{
left.mV[0] *= right.mV[0];
left.mV[1] *= right.mV[1];
left.mV[2] *= right.mV[2];
}
inline LLColor3 colorMix(LLColor3 const & left, LLColor3 const & right, F32 amount)
{
return (left + ((right - left) * amount));
}
inline LLColor3 smear(F32 val)
{
return LLColor3(val, val, val);
}
inline F32 color_intens(const LLColor3 &col)
{
return col.mV[0] + col.mV[1] + col.mV[2];
}
inline F32 color_max(const LLColor3 &col)
{
return llmax(col.mV[0], col.mV[1], col.mV[2]);
}
inline F32 color_max(const LLColor4 &col)
{
return llmax(col.mV[0], col.mV[1], col.mV[2]);
}
inline F32 color_min(const LLColor3 &col)
{
return llmin(col.mV[0], col.mV[1], col.mV[2]);
}
#endif