summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llmath.h39
-rw-r--r--indra/llmath/llvolume.cpp66
-rw-r--r--indra/llmath/llvolume.h2
-rw-r--r--indra/llmath/m4math.cpp50
-rw-r--r--indra/llmath/m4math.h2
5 files changed, 91 insertions, 68 deletions
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index 25b29ac1a8..eea7c977fb 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -29,6 +29,7 @@
#include <cmath>
#include <cstdlib>
+#include <vector>
#include "lldefs.h"
//#include "llstl.h" // *TODO: Remove when LLString is gone
//#include "llstring.h" // *TODO: Remove when LLString is gone
@@ -497,6 +498,44 @@ inline F32 llgaussian(F32 x, F32 o)
return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
}
+//helper function for removing outliers
+template <class VEC_TYPE>
+inline void ll_remove_outliers(std::vector<VEC_TYPE>& data, F32 k)
+{
+ if (data.size() < 100)
+ { //not enough samples
+ return;
+ }
+
+ VEC_TYPE Q1 = data[data.size()/4];
+ VEC_TYPE Q3 = data[data.size()-data.size()/4-1];
+
+ VEC_TYPE min = (VEC_TYPE) ((F32) Q1-k * (F32) (Q3-Q1));
+ VEC_TYPE max = (VEC_TYPE) ((F32) Q3+k * (F32) (Q3-Q1));
+
+ U32 i = 0;
+ while (i < data.size() && data[i] < min)
+ {
+ i++;
+ }
+
+ S32 j = data.size()-1;
+ while (j > 0 && data[j] > max)
+ {
+ j--;
+ }
+
+ if (j < data.size()-1)
+ {
+ data.erase(data.begin()+j, data.end());
+ }
+
+ if (i > 0)
+ {
+ data.erase(data.begin(), data.begin()+i);
+ }
+}
+
// Include simd math header
#include "llsimdmath.h"
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index c4be176353..dc360818d6 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2143,72 +2143,6 @@ bool LLVolumeFace::VertexData::compareNormal(const LLVolumeFace::VertexData& rhs
return retval;
}
-BOOL LLVolume::createVolumeFacesFromFile(const std::string& file_name)
-{
- std::ifstream is;
-
- is.open(file_name.c_str(), std::ifstream::in | std::ifstream::binary);
-
- BOOL success = createVolumeFacesFromStream(is);
-
- is.close();
-
- return success;
-}
-
-BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
-{
- mSculptLevel = -1; // default is an error occured
-
- LLSD header;
- {
- if (!LLSDSerialize::deserialize(header, is, 1024*1024*1024))
- {
- llwarns << "Mesh header parse error. Not a valid mesh asset!" << llendl;
- return FALSE;
- }
- }
-
- std::string nm[] =
- {
- "lowest_lod",
- "low_lod",
- "medium_lod",
- "high_lod"
- };
-
- S32 lod = llclamp((S32) mDetail, 0, 3);
-
- while (lod < 4 &&
- (header[nm[lod]]["offset"].asInteger() == -1 ||
- header[nm[lod]]["size"].asInteger() == 0 ))
- {
- ++lod;
- }
-
- if (lod >= 4)
- {
- lod = llclamp((S32) mDetail, 0, 3);
-
- while (lod >= 0 &&
- (header[nm[lod]]["offset"].asInteger() == -1 ||
- header[nm[lod]]["size"].asInteger() == 0) )
- {
- --lod;
- }
-
- if (lod < 0)
- {
- llwarns << "Mesh header missing LOD offsets. Not a valid mesh asset!" << llendl;
- return FALSE;
- }
- }
-
- is.seekg(header[nm[lod]]["offset"].asInteger(), std::ios_base::cur);
-
- return unpackVolumeFaces(is, header[nm[lod]]["size"].asInteger());
-}
-
bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
{
//input stream is now pointing at a zlib compressed block of LLSD
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 60b64b1285..01bfbd858b 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -1048,8 +1048,6 @@ protected:
BOOL generate();
void createVolumeFaces();
public:
- virtual BOOL createVolumeFacesFromFile(const std::string& file_name);
- virtual BOOL createVolumeFacesFromStream(std::istream& is);
virtual bool unpackVolumeFaces(std::istream& is, S32 size);
virtual void makeTetrahedron();
diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp
index 8741400e52..bad4deb4de 100644
--- a/indra/llmath/m4math.cpp
+++ b/indra/llmath/m4math.cpp
@@ -829,4 +829,54 @@ std::ostream& operator<<(std::ostream& s, const LLMatrix4 &a)
return s;
}
+LLSD LLMatrix4::getValue() const
+{
+ LLSD ret;
+
+ ret[0] = mMatrix[0][0];
+ ret[1] = mMatrix[0][1];
+ ret[2] = mMatrix[0][2];
+ ret[3] = mMatrix[0][3];
+
+ ret[4] = mMatrix[1][0];
+ ret[5] = mMatrix[1][1];
+ ret[6] = mMatrix[1][2];
+ ret[7] = mMatrix[1][3];
+
+ ret[8] = mMatrix[2][0];
+ ret[9] = mMatrix[2][1];
+ ret[10] = mMatrix[2][2];
+ ret[11] = mMatrix[2][3];
+
+ ret[12] = mMatrix[3][0];
+ ret[13] = mMatrix[3][1];
+ ret[14] = mMatrix[3][2];
+ ret[15] = mMatrix[3][3];
+
+ return ret;
+}
+
+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();
+}
+
diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h
index 3588f36758..a7dce10397 100644
--- a/indra/llmath/m4math.h
+++ b/indra/llmath/m4math.h
@@ -119,6 +119,8 @@ public:
~LLMatrix4(void); // Destructor
+ LLSD getValue() const;
+ void setValue(const LLSD&);
//////////////////////////////
//