summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorChristian Goetze <cg@lindenlab.com>2007-08-21 22:17:53 +0000
committerChristian Goetze <cg@lindenlab.com>2007-08-21 22:17:53 +0000
commitce0a5fe14590b8d675b885fccd5f79d7ea17a302 (patch)
tree3388e6f8ff02292ec4521d278c841801462945b8 /indra/llmath
parentb699ae454d8477d19342d320758cd993d1d28cec (diff)
EFFECTIVE MERGE: svn merge -r 66133:68118 svn+ssh://svn/svn/linden/branches/maintenance into release
Actual action: branched maintenance-r68118, merged in release, then copied result into release
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llvolume.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 7345dabf72..06f1c5c6ea 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -441,6 +441,20 @@ F32 next_power_of_two(F32 value)
return pow(2.0f, power);
}
+F32 nearest_power_of_two(F32 value)
+{
+ // nearest in the linear sense means closest w/r/t a "halfway" point.
+ // in the exponential sense, the "halfway" point isn't 1/2, it's 1/sqrt(2).
+
+ // our windows build hates the math.h defines, so do it here. -qarl
+ F32 const INVSQRT2 = 0.7071067812f;
+
+ F32 answer = next_power_of_two(value * INVSQRT2);
+
+ // llwarns << value << " -> " << answer << llendl;
+
+ return answer;
+}
BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split, BOOL is_sculpted)
@@ -585,7 +599,7 @@ BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split, BOOL is_sculpted)
S32 sides = (S32)circle_detail;
if (is_sculpted)
- sides = (S32)next_power_of_two((F32)sides);
+ sides = (S32)nearest_power_of_two((F32)sides - 1);
genNGon(sides);
@@ -1132,7 +1146,7 @@ BOOL LLPath::generate(F32 detail, S32 split, BOOL is_sculpted)
S32 sides = (S32)llfloor(llfloor((MIN_DETAIL_FACES * detail + twist_mag * 3.5f * (detail-0.5f))) * mParams.getRevolutions());
if (is_sculpted)
- sides = (S32)next_power_of_two((F32)sides);
+ sides = (S32)nearest_power_of_two((F32)sides - 1);
genNGon(sides);
}
@@ -1809,7 +1823,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
sNumMeshPoints += mMesh.size();
S32 vertex_change = 0;
- // first test to see if image has enough variation to create geometry
+ // first test to see if image has enough variation to create non-degenerate geometry
if (!data_is_empty)
{
S32 last_index = 0;
@@ -1835,12 +1849,13 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
if (fabs((F32)(sculpt_data[index] - sculpt_data[last_index])) +
fabs((F32)(sculpt_data[index+1] - sculpt_data[last_index+1])) +
- fabs((F32)(sculpt_data[index+2] - sculpt_data[last_index+2])) > 256 * 0.02)
+ fabs((F32)(sculpt_data[index+2] - sculpt_data[last_index+2])) > 0)
vertex_change++;
last_index = index;
}
- if ((F32)vertex_change / sizeS / sizeT < 0.05) // less than 5%
+
+ if ((F32)vertex_change / sizeS / sizeT < 0.02) // less than 2%
data_is_empty = TRUE;
}