diff options
author | Jacek Antonelli | 2008-08-15 23:45:07 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:07 -0500 |
commit | 8465910c79b8e746e04fd581cca2d60399e569b9 (patch) | |
tree | f43fec3e83c46e0d6190dca923d6fb268b52ffdd /linden/indra/llmath | |
parent | Second Life viewer sources 1.18.2.1 (diff) | |
download | meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.zip meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.gz meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.bz2 meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.xz |
Second Life viewer sources 1.18.3.2-RC
Diffstat (limited to 'linden/indra/llmath')
-rw-r--r-- | linden/indra/llmath/llvolume.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp index c0a33c7..1a25b3d 100644 --- a/linden/indra/llmath/llvolume.cpp +++ b/linden/indra/llmath/llvolume.cpp | |||
@@ -461,6 +461,20 @@ F32 next_power_of_two(F32 value) | |||
461 | return pow(2.0f, power); | 461 | return pow(2.0f, power); |
462 | } | 462 | } |
463 | 463 | ||
464 | F32 nearest_power_of_two(F32 value) | ||
465 | { | ||
466 | // nearest in the linear sense means closest w/r/t a "halfway" point. | ||
467 | // in the exponential sense, the "halfway" point isn't 1/2, it's 1/sqrt(2). | ||
468 | |||
469 | // our windows build hates the math.h defines, so do it here. -qarl | ||
470 | F32 const INVSQRT2 = 0.7071067812f; | ||
471 | |||
472 | F32 answer = next_power_of_two(value * INVSQRT2); | ||
473 | |||
474 | // llwarns << value << " -> " << answer << llendl; | ||
475 | |||
476 | return answer; | ||
477 | } | ||
464 | 478 | ||
465 | 479 | ||
466 | BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split, BOOL is_sculpted) | 480 | BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split, BOOL is_sculpted) |
@@ -605,7 +619,7 @@ BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split, BOOL is_sculpted) | |||
605 | S32 sides = (S32)circle_detail; | 619 | S32 sides = (S32)circle_detail; |
606 | 620 | ||
607 | if (is_sculpted) | 621 | if (is_sculpted) |
608 | sides = (S32)next_power_of_two((F32)sides); | 622 | sides = (S32)nearest_power_of_two((F32)sides - 1); |
609 | 623 | ||
610 | genNGon(sides); | 624 | genNGon(sides); |
611 | 625 | ||
@@ -1152,7 +1166,7 @@ BOOL LLPath::generate(F32 detail, S32 split, BOOL is_sculpted) | |||
1152 | S32 sides = (S32)llfloor(llfloor((MIN_DETAIL_FACES * detail + twist_mag * 3.5f * (detail-0.5f))) * mParams.getRevolutions()); | 1166 | S32 sides = (S32)llfloor(llfloor((MIN_DETAIL_FACES * detail + twist_mag * 3.5f * (detail-0.5f))) * mParams.getRevolutions()); |
1153 | 1167 | ||
1154 | if (is_sculpted) | 1168 | if (is_sculpted) |
1155 | sides = (S32)next_power_of_two((F32)sides); | 1169 | sides = (S32)nearest_power_of_two((F32)sides - 1); |
1156 | 1170 | ||
1157 | genNGon(sides); | 1171 | genNGon(sides); |
1158 | } | 1172 | } |
@@ -1829,7 +1843,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, | |||
1829 | sNumMeshPoints += mMesh.size(); | 1843 | sNumMeshPoints += mMesh.size(); |
1830 | 1844 | ||
1831 | S32 vertex_change = 0; | 1845 | S32 vertex_change = 0; |
1832 | // first test to see if image has enough variation to create geometry | 1846 | // first test to see if image has enough variation to create non-degenerate geometry |
1833 | if (!data_is_empty) | 1847 | if (!data_is_empty) |
1834 | { | 1848 | { |
1835 | S32 last_index = 0; | 1849 | S32 last_index = 0; |
@@ -1855,12 +1869,13 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, | |||
1855 | 1869 | ||
1856 | if (fabs((F32)(sculpt_data[index] - sculpt_data[last_index])) + | 1870 | if (fabs((F32)(sculpt_data[index] - sculpt_data[last_index])) + |
1857 | fabs((F32)(sculpt_data[index+1] - sculpt_data[last_index+1])) + | 1871 | fabs((F32)(sculpt_data[index+1] - sculpt_data[last_index+1])) + |
1858 | fabs((F32)(sculpt_data[index+2] - sculpt_data[last_index+2])) > 256 * 0.02) | 1872 | fabs((F32)(sculpt_data[index+2] - sculpt_data[last_index+2])) > 0) |
1859 | vertex_change++; | 1873 | vertex_change++; |
1860 | 1874 | ||
1861 | last_index = index; | 1875 | last_index = index; |
1862 | } | 1876 | } |
1863 | if ((F32)vertex_change / sizeS / sizeT < 0.05) // less than 5% | 1877 | |
1878 | if ((F32)vertex_change / sizeS / sizeT < 0.02) // less than 2% | ||
1864 | data_is_empty = TRUE; | 1879 | data_is_empty = TRUE; |
1865 | } | 1880 | } |
1866 | 1881 | ||