summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2009-11-24 07:38:04 -0600
committerDave Parks <davep@lindenlab.com>2009-11-24 07:38:04 -0600
commit62233f22469cdc66042fc7bbbbd367dbb7212fde (patch)
treeb89982d6b2076694953492646310f5f210e6698e /indra/llmath
parent5f44d4398a6d8abd05bba1d6c76831d674095ac1 (diff)
Fix for copying of tetrahedrons in place of mesh LODs.
Fix for bad tetrahedron bounding box. Bad fix for simultaneous loading of multiple LODs.
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llvolume.cpp31
-rw-r--r--indra/llmath/llvolume.h5
-rw-r--r--indra/llmath/llvolumemgr.cpp13
-rw-r--r--indra/llmath/llvolumemgr.h1
4 files changed, 47 insertions, 3 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 84da1b3c62..515b1061f9 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1676,6 +1676,7 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
mFaceMask = 0x0;
mDetail = detail;
mSculptLevel = -2;
+ mIsTetrahedron = FALSE;
mLODScaleBias.setVec(1,1,1);
// set defaults
@@ -1905,7 +1906,7 @@ BOOL LLVolume::createVolumeFacesFromFile(const std::string& file_name)
BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
{
mSculptLevel = -1; // default is an error occured
-
+
LLSD header;
{
if (!LLSDSerialize::deserialize(header, is, 1024*1024*1024))
@@ -2048,6 +2049,11 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
{
U32 face_count = mdl.size();
+ if (face_count == 0)
+ {
+ llerrs << "WTF?" << llendl;
+ }
+
mVolumeFaces.resize(face_count);
for (U32 i = 0; i < face_count; ++i)
@@ -2063,8 +2069,9 @@ BOOL LLVolume::createVolumeFacesFromStream(std::istream& is)
//copy out indices
face.mIndices.resize(idx.size()/2);
- if (idx.empty())
+ if (idx.empty() || face.mIndices.size() < 3)
{ //why is there an empty index list?
+ llerrs <<"WTF?" << llendl;
continue;
}
@@ -2150,6 +2157,11 @@ void tetrahedron_set_normal(LLVolumeFace::VertexData* cv)
cv[2].mNormal = nrm;
}
+BOOL LLVolume::isTetrahedron()
+{
+ return mIsTetrahedron;
+}
+
void LLVolume::makeTetrahedron()
{
mVolumeFaces.clear();
@@ -2165,6 +2177,9 @@ void LLVolume::makeTetrahedron()
LLVector3(x,-x,-x)
};
+ face.mExtents[0].setVec(-x,-x,-x);
+ face.mExtents[1].setVec(x,x,x);
+
LLVolumeFace::VertexData cv[3];
//set texture coordinates
@@ -2225,12 +2240,19 @@ void LLVolume::makeTetrahedron()
mVolumeFaces.push_back(face);
mSculptLevel = 0;
+ mIsTetrahedron = TRUE;
}
void LLVolume::copyVolumeFaces(LLVolume* volume)
{
+ if (volume->isTetrahedron())
+ {
+ llerrs << "WTF?" << llendl;
+ }
+
mVolumeFaces = volume->mVolumeFaces;
mSculptLevel = 0;
+ mIsTetrahedron = FALSE;
}
S32 const LL_SCULPT_MESH_MAX_FACES = 8;
@@ -2615,6 +2637,11 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
LLMemType m1(LLMemType::MTYPE_VOLUME);
U8 sculpt_type = mParams.getSculptType();
+ if (sculpt_type & LL_SCULPT_TYPE_MASK == LL_SCULPT_TYPE_MESH)
+ {
+ llerrs << "WTF?" << llendl;
+ }
+
BOOL data_is_empty = FALSE;
if (sculpt_width == 0 || sculpt_height == 0 || sculpt_components < 3 || sculpt_data == NULL)
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index bf2854ede9..8e57f2e280 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -904,7 +904,8 @@ 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
@@ -970,11 +971,13 @@ public:
virtual BOOL createVolumeFacesFromFile(const std::string& file_name);
virtual BOOL createVolumeFacesFromStream(std::istream& is);
virtual void makeTetrahedron();
+ virtual BOOL isTetrahedron();
protected:
BOOL mUnique;
F32 mDetail;
S32 mSculptLevel;
+ BOOL mIsTetrahedron;
LLVolumeParams mParams;
LLPath *mPathp;
diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp
index 61c5a0adc9..419e0015ba 100644
--- a/indra/llmath/llvolumemgr.cpp
+++ b/indra/llmath/llvolumemgr.cpp
@@ -375,6 +375,19 @@ F32 LLVolumeLODGroup::getVolumeScaleFromDetail(const S32 detail)
return mDetailScales[detail];
}
+S32 LLVolumeLODGroup::getVolumeDetailFromScale(const F32 detail)
+{
+ for (S32 i = 1; i < 4; i++)
+ {
+ if (mDetailScales[i] > detail)
+ {
+ return i-1;
+ }
+ }
+
+ return 3;
+}
+
F32 LLVolumeLODGroup::dump()
{
F32 usage = 0.f;
diff --git a/indra/llmath/llvolumemgr.h b/indra/llmath/llvolumemgr.h
index a78ea76a1a..f5dc4cd748 100644
--- a/indra/llmath/llvolumemgr.h
+++ b/indra/llmath/llvolumemgr.h
@@ -59,6 +59,7 @@ public:
static S32 getDetailFromTan(const F32 tan_angle);
static void getDetailProximity(const F32 tan_angle, F32 &to_lower, F32& to_higher);
static F32 getVolumeScaleFromDetail(const S32 detail);
+ static S32 getVolumeDetailFromScale(F32 scale);
LLVolume* refLOD(const S32 detail);
BOOL derefLOD(LLVolume *volumep);