summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llmath/llvolume.cpp7
-rw-r--r--indra/llprimitive/llmodel.cpp122
-rw-r--r--indra/newview/llmeshrepository.cpp12
3 files changed, 43 insertions, 98 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 70e1e1f312..c44c95272e 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2239,13 +2239,12 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
}
- LLVector3 minp;
- LLVector3 maxp;
+ LLVector3 minp(-0.5f, -0.5f, -0.5f);
+ LLVector3 maxp(0.5f, 0.5f, 0.5f);
LLVector2 min_tc;
LLVector2 max_tc;
- minp.setValue(mdl[i]["PositionDomain"]["Min"]);
- maxp.setValue(mdl[i]["PositionDomain"]["Max"]);
+
LLVector4a min_pos, max_pos;
min_pos.load3(minp.mV);
max_pos.load3(maxp.mV);
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 794cdb83d5..66b5150ed4 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -50,7 +50,7 @@ std::string model_names[] =
"low_lod",
"medium_lod",
"high_lod",
- "physics_shape"
+ "physics_mesh"
};
const int MODEL_NAMES_LENGTH = sizeof(model_names) / sizeof(std::string);
@@ -1403,25 +1403,15 @@ LLSD LLModel::writeModel(
if (!decomp.mBaseHull.empty() ||
!decomp.mHull.empty())
{
- mdl["decomposition"] = decomp.asLLSD();
+ mdl["physics_convex"] = decomp.asLLSD();
}
for (U32 idx = 0; idx < MODEL_NAMES_LENGTH; ++idx)
{
if (model[idx] && model[idx]->getNumVolumeFaces() > 0)
{
- LLVector3 min_pos = LLVector3(model[idx]->getVolumeFace(0).mPositions[0].getF32ptr());
- LLVector3 max_pos = min_pos;
-
- //find position domain
- for (S32 i = 0; i < model[idx]->getNumVolumeFaces(); ++i)
- { //for each face
- const LLVolumeFace& face = model[idx]->getVolumeFace(i);
- for (U32 j = 0; j < face.mNumVertices; ++j)
- {
- update_min_max(min_pos, max_pos, face.mPositions[j].getF32ptr());
- }
- }
+ LLVector3 min_pos(-0.5f, -0.5f, -0.5f);
+ LLVector3 max_pos(0.5f, 0.5f, 0.5f);
LLVector3 pos_range = max_pos - min_pos;
@@ -1462,6 +1452,7 @@ LLSD LLModel::writeModel(
//position + normal
for (U32 k = 0; k < 3; ++k)
{ //for each component
+ llassert(pos[k] <= 0.5001f && pos[k] >= -0.5001f);
//convert to 16-bit normalized across domain
U16 val = (U16) (((pos[k]-min_pos.mV[k])/pos_range.mV[k])*65535);
@@ -1504,9 +1495,6 @@ LLSD LLModel::writeModel(
}
//write out face data
- mdl[model_names[idx]][i]["PositionDomain"]["Min"] = min_pos.getValue();
- mdl[model_names[idx]][i]["PositionDomain"]["Max"] = max_pos.getValue();
-
mdl[model_names[idx]][i]["TexCoord0Domain"]["Min"] = min_tc.getValue();
mdl[model_names[idx]][i]["TexCoord0Domain"]["Max"] = max_tc.getValue();
@@ -1608,15 +1596,15 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, BOOL nowrite)
std::string decomposition;
- if (mdl.has("decomposition"))
+ if (mdl.has("physics_convex"))
{ //write out convex decomposition
- decomposition = zip_llsd(mdl["decomposition"]);
+ decomposition = zip_llsd(mdl["physics_convex"]);
U32 size = decomposition.size();
if (size > 0)
{
- header["decomposition"]["offset"] = (LLSD::Integer) cur_offset;
- header["decomposition"]["size"] = (LLSD::Integer) size;
+ header["physics_convex"]["offset"] = (LLSD::Integer) cur_offset;
+ header["physics_convex"]["size"] = (LLSD::Integer) size;
cur_offset += size;
bytes += size;
}
@@ -1637,11 +1625,6 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, BOOL nowrite)
cur_offset += size;
bytes += size;
}
- else
- {
- header[model_names[i]]["offset"] = -1;
- header[model_names[i]]["size"] = 0;
- }
}
if (!nowrite)
@@ -1655,7 +1638,7 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, BOOL nowrite)
if (!decomposition.empty())
{ //write decomposition block
- ostr.write((const char*) decomposition.data(), header["decomposition"]["size"].asInteger());
+ ostr.write((const char*) decomposition.data(), header["physics_convex"]["size"].asInteger());
}
for (S32 i = 0; i < MODEL_NAMES_LENGTH; i++)
@@ -1794,7 +1777,7 @@ bool LLModel::loadModel(std::istream& is)
"low_lod",
"medium_lod",
"high_lod",
- "physics_shape",
+ "physics_mesh",
};
const S32 MODEL_LODS = 5;
@@ -1893,8 +1876,8 @@ bool LLModel::loadSkinInfo(LLSD& header, std::istream &is)
bool LLModel::loadDecomposition(LLSD& header, std::istream& is)
{
- S32 offset = header["decomposition"]["offset"].asInteger();
- S32 size = header["decomposition"]["size"].asInteger();
+ S32 offset = header["physics_convex"]["offset"].asInteger();
+ S32 size = header["physics_convex"]["size"].asInteger();
if (offset >= 0 && size > 0)
{
@@ -2040,15 +2023,10 @@ void LLModel::Decomposition::fromLLSD(LLSD& decomp)
mHull.resize(hulls.size());
- LLVector3 min;
- LLVector3 max;
- LLVector3 range;
-
- min.setValue(decomp["Min"]);
- max.setValue(decomp["Max"]);
- range = max-min;
+ LLVector3 min(-0.5f,-0.5f,-0.5f);
+ LLVector3 max(0.5f,0.5f,0.5f);
+ LLVector3 range = max-min;
-
for (U32 i = 0; i < hulls.size(); ++i)
{
U16 count = (hulls[i] == 0) ? 256 : hulls[i];
@@ -2064,6 +2042,7 @@ void LLModel::Decomposition::fromLLSD(LLSD& decomp)
//point must be unique
//llassert(valid.find(test) == valid.end());
valid.insert(test);
+
mHull[i].push_back(LLVector3(
(F32) p[0]/65535.f*range.mV[0]+min.mV[0],
(F32) p[1]/65535.f*range.mV[1]+min.mV[1],
@@ -2078,28 +2057,15 @@ void LLModel::Decomposition::fromLLSD(LLSD& decomp)
}
}
- if (decomp.has("Hull"))
+ if (decomp.has("BoundingVerts"))
{
- const LLSD::Binary& position = decomp["Hull"].asBinary();
+ const LLSD::Binary& position = decomp["BundingVerts"].asBinary();
U16* p = (U16*) &position[0];
- LLVector3 min;
- LLVector3 max;
- LLVector3 range;
-
- if (decomp.has("Min"))
- {
- min.setValue(decomp["Min"]);
- max.setValue(decomp["Max"]);
- }
- else
- {
- min.set(-0.5f, -0.5f, -0.5f);
- max.set(0.5f, 0.5f, 0.5f);
- }
-
- range = max-min;
+ LLVector3 min(-0.5f,-0.5f,-0.5f);
+ LLVector3 max(0.5f,0.5f,0.5f);
+ LLVector3 range = max-min;
U16 count = position.size()/6;
@@ -2130,26 +2096,11 @@ LLSD LLModel::Decomposition::asLLSD() const
}
//write decomposition block
- // ["decomposition"]["HullList"] -- list of 8 bit integers, each entry represents a hull with specified number of points
- // ["decomposition"]["PositionDomain"]["Min"/"Max"]
- // ["decomposition"]["Position"] -- list of 16-bit integers to be decoded to given domain, encoded 3D points
- // ["decomposition"]["Hull"] -- list of 16-bit integers to be decoded to given domain, encoded 3D points representing a single hull approximation of given shape
-
+ // ["physics_convex"]["HullList"] -- list of 8 bit integers, each entry represents a hull with specified number of points
+ // ["physics_convex"]["Position"] -- list of 16-bit integers to be decoded to given domain, encoded 3D points
+ // ["physics_convex"]["BoundingVerts"] -- list of 16-bit integers to be decoded to given domain, encoded 3D points representing a single hull approximation of given shape
- //get minimum and maximum
- LLVector3 min;
- if (mHull.empty())
- {
- min = mBaseHull[0];
- }
- else
- {
- min = mHull[0][0];
- }
-
- LLVector3 max = min;
-
LLSD::Binary hulls(mHull.size());
U32 total = 0;
@@ -2159,21 +2110,8 @@ LLSD LLModel::Decomposition::asLLSD() const
U32 size = mHull[i].size();
total += size;
hulls[i] = (U8) (size);
-
- for (U32 j = 0; j < mHull[i].size(); ++j)
- {
- update_min_max(min, max, mHull[i][j]);
- }
- }
-
- for (U32 i = 0; i < mBaseHull.size(); ++i)
- {
- update_min_max(min, max, mBaseHull[i]);
}
- ret["Min"] = min.getValue();
- ret["Max"] = max.getValue();
-
if (!hulls.empty())
{
ret["HullList"] = hulls;
@@ -2183,6 +2121,8 @@ LLSD LLModel::Decomposition::asLLSD() const
{
LLSD::Binary p(total*3*2);
+ LLVector3 min(-0.5f, -0.5f, -0.5f);
+ LLVector3 max(0.5f, 0.5f, 0.5f);
LLVector3 range = max-min;
U32 vert_idx = 0;
@@ -2198,6 +2138,8 @@ LLSD LLModel::Decomposition::asLLSD() const
U64 test = 0;
for (U32 k = 0; k < 3; k++)
{
+ llassert(mHull[i][j].mV[k] <= 0.50001f && mHull[i][j].mV[k] >= -0.50001f);
+
//convert to 16-bit normalized across domain
U16 val = (U16) (((mHull[i][j].mV[k]-min.mV[k])/range.mV[k])*65535);
@@ -2231,6 +2173,8 @@ LLSD LLModel::Decomposition::asLLSD() const
{
LLSD::Binary p(mBaseHull.size()*3*2);
+ LLVector3 min(-0.5f, -0.5f, -0.5f);
+ LLVector3 max(0.5f, 0.5f, 0.5f);
LLVector3 range = max-min;
U32 vert_idx = 0;
@@ -2238,6 +2182,8 @@ LLSD LLModel::Decomposition::asLLSD() const
{
for (U32 k = 0; k < 3; k++)
{
+ llassert(mBaseHull[j].mV[k] <= 0.50001f && mBaseHull[j].mV[k] >= -0.50001f);
+
//convert to 16-bit normalized across domain
U16 val = (U16) (((mBaseHull[j].mV[k]-min.mV[k])/range.mV[k])*65535);
@@ -2253,7 +2199,7 @@ LLSD LLModel::Decomposition::asLLSD() const
}
}
- ret["Hull"] = p;
+ ret["BoundingVerts"] = p;
}
return ret;
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index dd2ffdf7f1..013fc43f99 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -772,8 +772,8 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
if (header_size > 0)
{
- S32 offset = header_size + mMeshHeader[mesh_id]["decomposition"]["offset"].asInteger();
- S32 size = mMeshHeader[mesh_id]["decomposition"]["size"].asInteger();
+ S32 offset = header_size + mMeshHeader[mesh_id]["physics_convex"]["offset"].asInteger();
+ S32 size = mMeshHeader[mesh_id]["physics_convex"]["size"].asInteger();
mHeaderMutex->unlock();
@@ -844,8 +844,8 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
if (header_size > 0)
{
- S32 offset = header_size + mMeshHeader[mesh_id]["physics_shape"]["offset"].asInteger();
- S32 size = mMeshHeader[mesh_id]["physics_shape"]["size"].asInteger();
+ S32 offset = header_size + mMeshHeader[mesh_id]["physics_mesh"]["offset"].asInteger();
+ S32 size = mMeshHeader[mesh_id]["physics_mesh"]["size"].asInteger();
mHeaderMutex->unlock();
@@ -1927,7 +1927,7 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
//just in case skin info or decomposition is at the end of the file (which it shouldn't be)
lod_bytes = llmax(lod_bytes, header["skin"]["offset"].asInteger() + header["skin"]["size"].asInteger());
- lod_bytes = llmax(lod_bytes, header["decomposition"]["offset"].asInteger() + header["decomposition"]["size"].asInteger());
+ lod_bytes = llmax(lod_bytes, header["physics_convex"]["offset"].asInteger() + header["physics_convex"]["size"].asInteger());
S32 header_bytes = (S32) gMeshRepo.mThread->mMeshHeaderSize[mesh_id];
S32 bytes = lod_bytes + header_bytes;
@@ -2543,7 +2543,7 @@ void LLMeshRepository::buildHull(const LLVolumeParams& params, S32 detail)
bool LLMeshRepository::hasPhysicsShape(const LLUUID& mesh_id)
{
LLSD mesh = mThread->getMeshHeader(mesh_id);
- return mesh.has("physics_shape") && mesh["physics_shape"].has("size") && (mesh["physics_shape"]["size"].asInteger() > 0);
+ return mesh.has("physics_mesh") && mesh["physics_mesh"].has("size") && (mesh["physics_mesh"]["size"].asInteger() > 0);
}
LLSD& LLMeshRepository::getMeshHeader(const LLUUID& mesh_id)