summaryrefslogtreecommitdiff
path: root/indra/llmath/llvolume.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath/llvolume.h')
-rw-r--r--indra/llmath/llvolume.h74
1 files changed, 68 insertions, 6 deletions
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index d9f80f0e30..c6a156ae37 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -49,6 +49,7 @@ class LLVolume;
//#include "vmath.h"
#include "v2math.h"
#include "v3math.h"
+#include "v4math.h"
#include "llquaternion.h"
#include "llstrider.h"
#include "v4coloru.h"
@@ -183,12 +184,15 @@ const U8 LL_SCULPT_TYPE_SPHERE = 1;
const U8 LL_SCULPT_TYPE_TORUS = 2;
const U8 LL_SCULPT_TYPE_PLANE = 3;
const U8 LL_SCULPT_TYPE_CYLINDER = 4;
+const U8 LL_SCULPT_TYPE_MESH = 5;
-const U8 LL_SCULPT_TYPE_MASK = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE | LL_SCULPT_TYPE_CYLINDER;
+const U8 LL_SCULPT_TYPE_MASK = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE |
+ LL_SCULPT_TYPE_CYLINDER | LL_SCULPT_TYPE_MESH;
const U8 LL_SCULPT_FLAG_INVERT = 64;
const U8 LL_SCULPT_FLAG_MIRROR = 128;
+const S32 LL_SCULPT_MESH_MAX_FACES = 8;
class LLProfileParams
{
@@ -575,6 +579,9 @@ public:
BOOL importLegacyStream(std::istream& input_stream);
BOOL exportLegacyStream(std::ostream& output_stream) const;
+ LLSD sculptAsLLSD() const;
+ bool sculptFromLLSD(LLSD& sd);
+
LLSD asLLSD() const;
operator LLSD() const { return asLLSD(); }
bool fromLLSD(LLSD& sd);
@@ -634,7 +641,6 @@ public:
const F32& getSkew() const { return mPathParams.getSkew(); }
const LLUUID& getSculptID() const { return mSculptID; }
const U8& getSculptType() const { return mSculptType; }
-
BOOL isConvex() const;
// 'begin' and 'end' should be in range [0, 1] (they will be clamped)
@@ -800,6 +806,8 @@ public:
void createBinormals();
void makeTriStrip();
+ void appendFace(const LLVolumeFace& face, LLMatrix4& transform, LLMatrix4& normal_tranform);
+
class VertexData
{
public:
@@ -807,8 +815,45 @@ public:
LLVector3 mNormal;
LLVector3 mBinormal;
LLVector2 mTexCoord;
+
+ bool operator<(const VertexData& rhs) const;
+ bool operator==(const VertexData& rhs) const;
+ bool compareNormal(const VertexData& rhs, F32 angle_cutoff) const;
};
+ class VertexMapData : public LLVolumeFace::VertexData
+ {
+ public:
+ U16 mIndex;
+
+ bool operator==(const LLVolumeFace::VertexData& rhs) const
+ {
+ return mPosition == rhs.mPosition &&
+ mTexCoord == rhs.mTexCoord &&
+ mNormal == rhs.mNormal;
+ }
+
+ struct ComparePosition
+ {
+ bool operator()(const LLVector3& a, const LLVector3& b) const
+ {
+ if (a.mV[0] != b.mV[0])
+ {
+ return a.mV[0] < b.mV[0];
+ }
+ if (a.mV[1] != b.mV[1])
+ {
+ return a.mV[1] < b.mV[1];
+ }
+ return a.mV[2] < b.mV[2];
+ }
+ };
+
+ typedef std::map<LLVector3, std::vector<VertexMapData>, VertexMapData::ComparePosition > PointMap;
+ };
+
+ void optimize(F32 angle_cutoff = 2.f);
+
enum
{
SINGLE_MASK = 0x0001,
@@ -843,6 +888,11 @@ public:
std::vector<U16> mTriStrip;
std::vector<S32> mEdge;
+ //list of skin weights for rigged volumes
+ // format is mWeights[vertex_index].mV[influence] = <joint_index>.<weight>
+ // mWeights.size() should be empty or match mVertices.size()
+ std::vector<LLVector4> mWeights;
+
private:
BOOL createUnCutCubeCap(LLVolume* volume, BOOL partial_build = FALSE);
BOOL createCap(LLVolume* volume, BOOL partial_build = FALSE);
@@ -853,8 +903,7 @@ class LLVolume : public LLRefCount
{
friend class LLVolumeLODGroup;
-private:
- LLVolume(const LLVolume&); // Don't implement
+protected:
~LLVolume(); // use unref
public:
@@ -876,7 +925,7 @@ public:
U8 getProfileType() const { return mParams.getProfileParams().getCurveType(); }
U8 getPathType() const { return mParams.getPathParams().getCurveType(); }
- S32 getNumFaces() const { return (S32)mProfilep->mFaces.size(); }
+ S32 getNumFaces() const;
S32 getNumVolumeFaces() const { return mVolumeFaces.size(); }
F32 getDetail() const { return mDetail; }
const LLVolumeParams& getParams() const { return mParams; }
@@ -898,12 +947,15 @@ public:
BOOL isUnique() const { return mUnique; }
S32 getSculptLevel() const { return mSculptLevel; }
-
+ void setSculptLevel(S32 level) { mSculptLevel = level; }
+
S32 *getTriangleIndices(U32 &num_indices) const;
// returns number of triangle indeces required for path/profile mesh
S32 getNumTriangleIndices() const;
+ S32 getNumTriangles() const;
+
void generateSilhouetteVertices(std::vector<LLVector3> &vertices,
std::vector<LLVector3> &normals,
std::vector<S32> &segments,
@@ -948,6 +1000,8 @@ public:
LLVector3 mLODScaleBias; // vector for biasing LOD based on scale
void sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level);
+ void copyVolumeFaces(LLVolume* volume);
+
private:
void sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type);
F32 sculptGetSurfaceArea();
@@ -958,11 +1012,19 @@ private:
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();
+ virtual BOOL isTetrahedron();
protected:
BOOL mUnique;
F32 mDetail;
S32 mSculptLevel;
+ BOOL mIsTetrahedron;
LLVolumeParams mParams;
LLPath *mPathp;