From 1ff79683128f09baf6dbaf081092fda7e5f2fe65 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 28 Mar 2011 23:50:23 -0500 Subject: SH-1225 Add skinning info to import path of .slm files. --- indra/llmath/llvolume.cpp | 50 ----------------------------------------------- indra/llmath/llvolume.h | 2 -- 2 files changed, 52 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 7a2f06da8f..dc360818d6 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -2143,56 +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::fromBinary(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", - "physics_shape", - }; - - const S32 MODEL_LODS = 5; - - S32 lod = llclamp((S32) mDetail, 0, MODEL_LODS); - - if (header[nm[lod]]["offset"].asInteger() == -1 || - header[nm[lod]]["size"].asInteger() == 0 ) - { //cannot load requested LOD - 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(); -- cgit v1.3 From f90eb750f1e8c3e300d1a079fe99d15f35201072 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 7 Apr 2011 00:29:02 -0500 Subject: SH-1292 Remove outliers from graphs in scene console to make a more useful view. --- indra/llmath/llmath.h | 39 +++++++++++++++++++++++ indra/newview/llfasttimerview.cpp | 45 +++------------------------ indra/newview/llsceneview.cpp | 65 +++++++++++++++++++-------------------- 3 files changed, 75 insertions(+), 74 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index 25b29ac1a8..97001b4062 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -29,6 +29,7 @@ #include #include +#include #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 +inline void ll_remove_outliers(std::vector& 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 = Q1-k*(Q3-Q1); + VEC_TYPE max = Q3+k*(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/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 6e78ea6bbe..35712163eb 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1040,43 +1040,6 @@ void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch result->save(out_file); } -template -void removeOutliers(std::vector& 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 = Q1-k*(Q3-Q1); - VEC_TYPE max = Q3+k*(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); - } -} - //static void LLFastTimerView::exportCharts(const std::string& base, const std::string& target) { @@ -1206,22 +1169,22 @@ void LLFastTimerView::exportCharts(const std::string& base, const std::string& t const U32 OUTLIER_CUTOFF = 512; if (base_times.size() > OUTLIER_CUTOFF) { - removeOutliers(base_times, 1.f); + ll_remove_outliers(base_times, 1.f); } if (base_execution.size() > OUTLIER_CUTOFF) { - removeOutliers(base_execution, 1.f); + ll_remove_outliers(base_execution, 1.f); } if (cur_times.size() > OUTLIER_CUTOFF) { - removeOutliers(cur_times, 1.f); + ll_remove_outliers(cur_times, 1.f); } if (cur_execution.size() > OUTLIER_CUTOFF) { - removeOutliers(cur_execution, 1.f); + ll_remove_outliers(cur_execution, 1.f); } diff --git a/indra/newview/llsceneview.cpp b/indra/newview/llsceneview.cpp index dfc13bc9b8..25a7373018 100644 --- a/indra/newview/llsceneview.cpp +++ b/indra/newview/llsceneview.cpp @@ -36,6 +36,11 @@ LLSceneView* gSceneView = NULL; +//borrow this helper function from llfasttimerview.cpp +template +void removeOutliers(std::vector& data, F32 k); + + LLSceneView::LLSceneView(const LLRect& rect) : LLFloater(LLSD()) { @@ -72,8 +77,11 @@ void LLSceneView::draw() //object sizes std::vector size[2]; - std::vector triangles[2]; - std::vector visible_triangles[2]; + std::vector triangles[2]; + std::vector visible_triangles[2]; + + S32 total_visible_triangles[] = {0, 0}; + S32 total_triangles[] = {0, 0}; U32 object_count = 0; @@ -97,9 +105,14 @@ void LLSceneView::draw() F32 radius = object->getScale().magVec(); size[idx].push_back(radius); - visible_triangles[idx].push_back(volume->getNumTriangles()); - - triangles[idx].push_back(object->getHighLODTriangleCount()); + S32 visible = volume->getNumTriangles(); + S32 high_triangles = object->getHighLODTriangleCount(); + + total_visible_triangles[idx] += visible; + total_triangles[idx] += high_triangles; + + visible_triangles[idx].push_back(visible); + triangles[idx].push_back(high_triangles); } } } @@ -116,6 +129,8 @@ void LLSceneView::draw() { //display graph of object sizes std::sort(size[idx].begin(), size[idx].end()); + ll_remove_outliers(size[idx], 1.f); + LLRect size_rect; if (idx == 0) @@ -180,8 +195,9 @@ void LLSceneView::draw() if (!triangles[idx].empty()) { //plot graph of visible/total triangles std::sort(triangles[idx].begin(), triangles[idx].end()); - std::sort(visible_triangles[idx].begin(), visible_triangles[idx].end()); - + + ll_remove_outliers(triangles[idx], 1.f); + LLRect tri_rect; if (idx == 0) { @@ -194,19 +210,17 @@ void LLSceneView::draw() gl_rect_2d(tri_rect, LLColor4::white, false); - U32 tri_domain[] = { 65536, 0 }; - - llassert(triangles[idx].size() == visible_triangles[idx].size()); - - //get domain of sizes + S32 tri_domain[] = { 65536, 0 }; + + //get domain of triangle counts for (U32 i = 0; i < triangles[idx].size(); ++i) { - tri_domain[0] = llmin(visible_triangles[idx][i], llmin(tri_domain[0], triangles[idx][i])); - tri_domain[1] = llmax(visible_triangles[idx][i], llmax(tri_domain[1], triangles[idx][i])); + tri_domain[0] = llmin(tri_domain[0], triangles[idx][i]); + tri_domain[1] = llmax(tri_domain[1], triangles[idx][i]); } U32 triangle_range = tri_domain[1]-tri_domain[0]; - + U32 count = triangles[idx].size(); U32 total = 0; @@ -234,31 +248,16 @@ void LLSceneView::draw() gGL.flush(); U32 total_visible = 0; - gGL.begin(LLRender::LINE_STRIP); - //plot visible triangles + count = visible_triangles[idx].size(); + for (U32 i = 0; i < count; ++i) { U32 tri_count = visible_triangles[idx][i]; total_visible += tri_count; - F32 y = (F32) (tri_count-tri_domain[0])/triangle_range*tri_rect.getHeight()+tri_rect.mBottom; - F32 x = (F32) i / count * tri_rect.getWidth() + tri_rect.mLeft; - - gGL.vertex2f(x,y); - - if (i%4096 == 0) - { - gGL.end(); - gGL.flush(); - gGL.begin(LLRender::LINE_STRIP); - } } - gGL.end(); - gGL.flush(); - - std::string label = llformat("%s Object Triangle Counts (Ktris) -- Min: %.2f Max: %.2f Mean: %.2f Median: %.2f (%.2f/%.2f visible) -- %d samples", - category[idx], tri_domain[0]/1024.f, tri_domain[1]/1024.f, (total/count)/1024.f, triangles[idx][count/2]/1024.f, total_visible/1024.f, total/1024.f, count); + category[idx], tri_domain[0]/1024.f, tri_domain[1]/1024.f, (total/count)/1024.f, triangles[idx][count/2]/1024.f, total_visible_triangles[idx]/1024.f, total_triangles[idx]/1024.f, count); LLFontGL::getFontMonospace()->renderUTF8(label, 0 , tri_rect.mLeft, tri_rect.mTop+margin, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); -- cgit v1.3 From 8807496ed78b36658f488d901842852d63f73cb9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 8 Apr 2011 02:11:46 -0500 Subject: attempted fix for linux build --- indra/llmath/llmath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index 97001b4062..eea7c977fb 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -510,8 +510,8 @@ inline void ll_remove_outliers(std::vector& data, F32 k) VEC_TYPE Q1 = data[data.size()/4]; VEC_TYPE Q3 = data[data.size()-data.size()/4-1]; - VEC_TYPE min = Q1-k*(Q3-Q1); - VEC_TYPE max = Q3+k*(Q3-Q1); + 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) -- cgit v1.3