summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llcalcparser.h2
-rw-r--r--indra/llmath/llcoord.h117
-rw-r--r--indra/llmath/llvolume.cpp7
-rw-r--r--indra/llmath/llvolume.h2
-rw-r--r--indra/llmath/m4math.cpp38
5 files changed, 89 insertions, 77 deletions
diff --git a/indra/llmath/llcalcparser.h b/indra/llmath/llcalcparser.h
index bd9c8c2519..e0ad270266 100644
--- a/indra/llmath/llcalcparser.h
+++ b/indra/llmath/llcalcparser.h
@@ -174,7 +174,7 @@ private:
F32 _log(const F32& a) const { return log(a); }
F32 _exp(const F32& a) const { return exp(a); }
F32 _fabs(const F32& a) const { return fabs(a); }
- F32 _floor(const F32& a) const { return llfloor(a); }
+ F32 _floor(const F32& a) const { return (F32)llfloor(a); }
F32 _ceil(const F32& a) const { return llceil(a); }
F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); }
diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h
index 706ad92787..9b76268afd 100644
--- a/indra/llmath/llcoord.h
+++ b/indra/llmath/llcoord.h
@@ -26,80 +26,87 @@
#ifndef LL_LLCOORD_H
#define LL_LLCOORD_H
+template<typename> class LLCoord;
+struct LL_COORD_TYPE_GL;
+struct LL_COORD_TYPE_WINDOW;
+struct LL_COORD_TYPE_SCREEN;
+
+typedef LLCoord<LL_COORD_TYPE_GL> LLCoordGL;
+typedef LLCoord<LL_COORD_TYPE_WINDOW> LLCoordWindow;
+typedef LLCoord<LL_COORD_TYPE_SCREEN> LLCoordScreen;
+
+struct LLCoordCommon
+{
+ LLCoordCommon(S32 x, S32 y) : mX(x), mY(y) {}
+ LLCoordCommon() : mX(0), mY(0) {}
+ S32 mX;
+ S32 mY;
+};
+
// A two-dimensional pixel value
-class LLCoord
+template<typename COORD_FRAME>
+class LLCoord : protected COORD_FRAME
{
public:
- S32 mX;
- S32 mY;
+ typedef LLCoord<COORD_FRAME> self_t;
+ typename COORD_FRAME::value_t mX;
+ typename COORD_FRAME::value_t mY;
LLCoord(): mX(0), mY(0)
{}
- LLCoord(S32 x, S32 y): mX(x), mY(y)
- {}
- virtual ~LLCoord()
+ LLCoord(typename COORD_FRAME::value_t x, typename COORD_FRAME::value_t y): mX(x), mY(y)
{}
- virtual void set(S32 x, S32 y) { mX = x; mY = y; }
-};
+ LLCoord(const LLCoordCommon& other)
+ {
+ COORD_FRAME::convertFromCommon(other);
+ }
+ LLCoordCommon convert() const
+ {
+ return COORD_FRAME::convertToCommon();
+ }
-// GL coordinates start in the client region of a window,
-// with left, bottom = 0, 0
-class LLCoordGL : public LLCoord
-{
-public:
- LLCoordGL() : LLCoord()
- {}
- LLCoordGL(S32 x, S32 y) : LLCoord(x, y)
- {}
- bool operator==(const LLCoordGL& other) const { return mX == other.mX && mY == other.mY; }
- bool operator!=(const LLCoordGL& other) const { return !(*this == other); }
-};
+ void set(typename COORD_FRAME::value_t x, typename COORD_FRAME::value_t y) { mX = x; mY = y;}
+ bool operator==(const self_t& other) const { return mX == other.mX && mY == other.mY; }
+ bool operator!=(const self_t& other) const { return !(*this == other); }
-//bool operator ==(const LLCoordGL& a, const LLCoordGL& b);
+ static const self_t& getTypedCoords(const COORD_FRAME& self) { return static_cast<const self_t&>(self); }
+ static self_t& getTypedCoords(COORD_FRAME& self) { return static_cast<self_t&>(self); }
+};
-// Window coords include things like window borders,
-// menu regions, etc.
-class LLCoordWindow : public LLCoord
+struct LL_COORD_TYPE_GL
{
-public:
- LLCoordWindow() : LLCoord()
- {}
- LLCoordWindow(S32 x, S32 y) : LLCoord(x, y)
- {}
- bool operator==(const LLCoordWindow& other) const { return mX == other.mX && mY == other.mY; }
- bool operator!=(const LLCoordWindow& other) const { return !(*this == other); }
-};
+ typedef S32 value_t;
+ LLCoordCommon convertToCommon() const
+ {
+ const LLCoordGL& self = LLCoordGL::getTypedCoords(*this);
+ return LLCoordCommon(self.mX, self.mY);
+ }
-// Screen coords start at left, top = 0, 0
-class LLCoordScreen : public LLCoord
+ void convertFromCommon(const LLCoordCommon& from)
+ {
+ LLCoordGL& self = LLCoordGL::getTypedCoords(*this);
+ self.mX = from.mX;
+ self.mY = from.mY;
+ }
+};
+
+struct LL_COORD_TYPE_WINDOW
{
-public:
- LLCoordScreen() : LLCoord()
- {}
- LLCoordScreen(S32 x, S32 y) : LLCoord(x, y)
- {}
- bool operator==(const LLCoordScreen& other) const { return mX == other.mX && mY == other.mY; }
- bool operator!=(const LLCoordScreen& other) const { return !(*this == other); }
+ typedef S32 value_t;
+
+ LLCoordCommon convertToCommon() const;
+ void convertFromCommon(const LLCoordCommon& from);
};
-class LLCoordFont : public LLCoord
+struct LL_COORD_TYPE_SCREEN
{
-public:
- F32 mZ;
-
- LLCoordFont() : LLCoord(), mZ(0.f)
- {}
- LLCoordFont(S32 x, S32 y, F32 z = 0) : LLCoord(x,y), mZ(z)
- {}
-
- void set(S32 x, S32 y) { LLCoord::set(x,y); mZ = 0.f; }
- void set(S32 x, S32 y, F32 z) { mX = x; mY = y; mZ = z; }
- bool operator==(const LLCoordFont& other) const { return mX == other.mX && mY == other.mY; }
- bool operator!=(const LLCoordFont& other) const { return !(*this == other); }
+ typedef S32 value_t;
+
+ LLCoordCommon convertToCommon() const;
+ void convertFromCommon(const LLCoordCommon& from);
};
-
#endif
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 0c6cf1dfae..cc9744756f 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2078,6 +2078,7 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
mFaceMask = 0x0;
mDetail = detail;
mSculptLevel = -2;
+ mSurfaceArea = 1.f; //only calculated for sculpts, defaults to 1 for all other prims
mIsMeshAssetLoaded = FALSE;
mLODScaleBias.setVec(1,1,1);
mHullPoints = NULL;
@@ -2903,7 +2904,7 @@ F32 LLVolume::sculptGetSurfaceArea()
// compute the area of the quad by taking the length of the cross product of the two triangles
LLVector3 cross1 = (p1 - p2) % (p1 - p3);
LLVector3 cross2 = (p4 - p2) % (p4 - p3);
- area += (cross1.magVec() + cross2.magVec()) / 2.0;
+ area += (cross1.magVec() + cross2.magVec()) / 2.f;
}
}
@@ -3144,6 +3145,8 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
{
F32 area = sculptGetSurfaceArea();
+ mSurfaceArea = area;
+
const F32 SCULPT_MAX_AREA = 384.f;
if (area < SCULPT_MIN_AREA || area > SCULPT_MAX_AREA)
@@ -5887,7 +5890,7 @@ F32 find_vertex_score(LLVCacheVertexData& data)
}
//bonus points for having low valence
- F32 valence_boost = powf(data.mActiveTriangles, -FindVertexScore_ValenceBoostPower);
+ F32 valence_boost = powf((F32)data.mActiveTriangles, -FindVertexScore_ValenceBoostPower);
score += FindVertexScore_ValenceBoostScale * valence_boost;
return score;
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index afd1ec5eed..76cf9de613 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -963,6 +963,7 @@ public:
S32 getNumFaces() const;
S32 getNumVolumeFaces() const { return mVolumeFaces.size(); }
F32 getDetail() const { return mDetail; }
+ F32 getSurfaceArea() const { return mSurfaceArea; }
const LLVolumeParams& getParams() const { return mParams; }
LLVolumeParams getCopyOfParams() const { return mParams; }
const LLProfile& getProfile() const { return *mProfilep; }
@@ -1065,6 +1066,7 @@ public:
BOOL mUnique;
F32 mDetail;
S32 mSculptLevel;
+ F32 mSurfaceArea; //unscaled surface area
BOOL mIsMeshAssetLoaded;
LLVolumeParams mParams;
diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp
index bad4deb4de..6a1b4143cf 100644
--- a/indra/llmath/m4math.cpp
+++ b/indra/llmath/m4math.cpp
@@ -858,25 +858,25 @@ LLSD LLMatrix4::getValue() const
void LLMatrix4::setValue(const LLSD& data)
{
- mMatrix[0][0] = data[0].asReal();
- mMatrix[0][1] = data[1].asReal();
- mMatrix[0][2] = data[2].asReal();
- mMatrix[0][3] = data[3].asReal();
-
- mMatrix[1][0] = data[4].asReal();
- mMatrix[1][1] = data[5].asReal();
- mMatrix[1][2] = data[6].asReal();
- mMatrix[1][3] = data[7].asReal();
-
- mMatrix[2][0] = data[8].asReal();
- mMatrix[2][1] = data[9].asReal();
- mMatrix[2][2] = data[10].asReal();
- mMatrix[2][3] = data[11].asReal();
-
- mMatrix[3][0] = data[12].asReal();
- mMatrix[3][1] = data[13].asReal();
- mMatrix[3][2] = data[14].asReal();
- mMatrix[3][3] = data[15].asReal();
+ mMatrix[0][0] = (F32)data[0].asReal();
+ mMatrix[0][1] = (F32)data[1].asReal();
+ mMatrix[0][2] = (F32)data[2].asReal();
+ mMatrix[0][3] = (F32)data[3].asReal();
+
+ mMatrix[1][0] = (F32)data[4].asReal();
+ mMatrix[1][1] = (F32)data[5].asReal();
+ mMatrix[1][2] = (F32)data[6].asReal();
+ mMatrix[1][3] = (F32)data[7].asReal();
+
+ mMatrix[2][0] = (F32)data[8].asReal();
+ mMatrix[2][1] = (F32)data[9].asReal();
+ mMatrix[2][2] = (F32)data[10].asReal();
+ mMatrix[2][3] = (F32)data[11].asReal();
+
+ mMatrix[3][0] = (F32)data[12].asReal();
+ mMatrix[3][1] = (F32)data[13].asReal();
+ mMatrix[3][2] = (F32)data[14].asReal();
+ mMatrix[3][3] = (F32)data[15].asReal();
}