Commits

davep  committed 8f39e88 Merge

merge

  • Participants
  • Parent commits 962d737, 79ad36b

Comments (0)

Files changed (1)

File indra/llmath/llvolume.cpp

 #include "llsdserialize.h"
 #include "llvector4a.h"
 #include "llmatrix4a.h"
+#include "lltimer.h"
 
 #define DEBUG_SILHOUETTE_BINORMALS 0
 #define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette
 			}
 
 			U16* indices = (U16*) &(idx[0]);
-			for (U32 j = 0; j < idx.size()/2; ++j)
+			U32 count = idx.size()/2;
+			for (U32 j = 0; j < count; ++j)
 			{
 				face.mIndices[j] = indices[j];
 			}
 			U32 num_verts = pos.size()/(3*2);
 			face.resizeVertices(num_verts);
 
-			if (mdl[i].has("Weights"))
-			{
-				face.allocateWeights(num_verts);
-
-				LLSD::Binary weights = mdl[i]["Weights"];
-
-				U32 idx = 0;
-
-				U32 cur_vertex = 0;
-				while (idx < weights.size() && cur_vertex < num_verts)
-				{
-					const U8 END_INFLUENCES = 0xFF;
-					U8 joint = weights[idx++];
-
-					U32 cur_influence = 0;
-					LLVector4 wght(0,0,0,0);
-
-					while (joint != END_INFLUENCES && idx < weights.size())
-					{
-						U16 influence = weights[idx++];
-						influence |= ((U16) weights[idx++] << 8);
-
-						F32 w = llclamp((F32) influence / 65535.f, 0.f, 0.99999f);
-						wght.mV[cur_influence++] = (F32) joint + w;
-
-						if (cur_influence >= 4)
-						{
-							joint = END_INFLUENCES;
-						}
-						else
-						{
-							joint = weights[idx++];
-						}
-					}
-
-					face.mWeights[cur_vertex].loadua(wght.mV);
-
-					cur_vertex++;
-				}
-
-				if (cur_vertex != num_verts || idx != weights.size())
-				{
-					llwarns << "Vertex weight count does not match vertex count!" << llendl;
-				}
-					
-			}
-
 			LLVector3 minp;
 			LLVector3 maxp;
 			LLVector2 min_tc; 
 
 			LLVector4a pos_range;
 			pos_range.setSub(max_pos, min_pos);
-			LLVector2 tc_range = max_tc - min_tc;
+			LLVector2 tc_range2 = max_tc - min_tc;
+			LLVector4a tc_range;
+			tc_range.set(tc_range2[0], tc_range2[1], tc_range2[0], tc_range2[1]);
+			LLVector4a min_tc4(min_tc[0], min_tc[1], min_tc[0], min_tc[1]);
 
 			LLVector4a* pos_out = face.mPositions;
 			LLVector4a* norm_out = face.mNormals;
-			LLVector2* tc_out = face.mTexCoords;
-
-			for (U32 j = 0; j < num_verts; ++j)
+			LLVector4a* tc_out = (LLVector4a*) face.mTexCoords;
+
 			{
-				U16* v = (U16*) &(pos[j*3*2]);
-
-				pos_out->set((F32) v[0], (F32) v[1], (F32) v[2]);
-				pos_out->div(65535.f);
-				pos_out->mul(pos_range);
-				pos_out->add(min_pos);
-
-				pos_out++;
-
-				U16* n = (U16*) &(norm[j*3*2]);
-
-				norm_out->set((F32) n[0], (F32) n[1], (F32) n[2]);
-				norm_out->div(65535.f);
-				norm_out->mul(2.f);
-				norm_out->sub(1.f);
-				norm_out++;
-
-				U16* t = (U16*) &(tc[j*2*2]);
-
-				tc_out->mV[0] = (F32) t[0] / 65535.f * tc_range.mV[0] + min_tc.mV[0];
-				tc_out->mV[1] =	(F32) t[1] / 65535.f * tc_range.mV[1] + min_tc.mV[1];
-
-				tc_out++;
+				U16* v = (U16*) &(pos[0]);
+				for (U32 j = 0; j < num_verts; ++j)
+				{
+					pos_out->set((F32) v[0], (F32) v[1], (F32) v[2]);
+					pos_out->div(65535.f);
+					pos_out->mul(pos_range);
+					pos_out->add(min_pos);
+					pos_out++;
+					v += 3;
+				}
+
 			}
 
-			
+			{
+				U16* n = (U16*) &(norm[0]);
+				for (U32 j = 0; j < num_verts; ++j)
+				{
+					norm_out->set((F32) n[0], (F32) n[1], (F32) n[2]);
+					norm_out->div(65535.f);
+					norm_out->mul(2.f);
+					norm_out->sub(1.f);
+					norm_out++;
+					n += 3;
+				}
+			}
+
+			{
+				U16* t = (U16*) &(tc[0]);
+				for (U32 j = 0; j < num_verts; j+=2)
+				{
+					if (j < num_verts-1)
+					{
+						tc_out->set((F32) t[0], (F32) t[1], (F32) t[2], (F32) t[3]);
+					}
+					else
+					{
+						tc_out->set((F32) t[0], (F32) t[1], 0.f, 0.f);
+					}
+
+					t += 4;
+
+					tc_out->div(65535.f);
+					tc_out->mul(tc_range);
+					tc_out->add(min_tc4);
+
+					tc_out++;
+				}
+			}
+
+			if (mdl[i].has("Weights"))
+			{
+				face.allocateWeights(num_verts);
+
+				LLSD::Binary weights = mdl[i]["Weights"];
+
+				U32 idx = 0;
+
+				U32 cur_vertex = 0;
+				while (idx < weights.size() && cur_vertex < num_verts)
+				{
+					const U8 END_INFLUENCES = 0xFF;
+					U8 joint = weights[idx++];
+
+					U32 cur_influence = 0;
+					LLVector4 wght(0,0,0,0);
+
+					while (joint != END_INFLUENCES && idx < weights.size())
+					{
+						U16 influence = weights[idx++];
+						influence |= ((U16) weights[idx++] << 8);
+
+						F32 w = llclamp((F32) influence / 65535.f, 0.f, 0.99999f);
+						wght.mV[cur_influence++] = (F32) joint + w;
+
+						if (cur_influence >= 4)
+						{
+							joint = END_INFLUENCES;
+						}
+						else
+						{
+							joint = weights[idx++];
+						}
+					}
+
+					face.mWeights[cur_vertex].loadua(wght.mV);
+
+					cur_vertex++;
+				}
+
+				if (cur_vertex != num_verts || idx != weights.size())
+				{
+					llwarns << "Vertex weight count does not match vertex count!" << llendl;
+				}
+					
+			}
+
 			// modifier flags?
 			bool do_mirror = (mParams.getSculptType() & LL_SCULPT_FLAG_MIRROR);
 			bool do_invert = (mParams.getSculptType() &LL_SCULPT_FLAG_INVERT);
 			}
 		}
 	}
-
+	
 	mSculptLevel = 0;  // success!
 
 	cacheOptimize();