aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/llvolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llmath/llvolume.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp
index 1a25b3d..7f2a663 100644
--- a/linden/indra/llmath/llvolume.cpp
+++ b/linden/indra/llmath/llvolume.cpp
@@ -78,6 +78,11 @@ const F32 TAPER_MAX = 1.f;
78const F32 SKEW_MIN = -0.95f; 78const F32 SKEW_MIN = -0.95f;
79const F32 SKEW_MAX = 0.95f; 79const F32 SKEW_MAX = 0.95f;
80 80
81const S32 SCULPT_REZ_1 = 6; // changed from 4 to 6 - 6 looks round whereas 4 looks square
82const S32 SCULPT_REZ_2 = 8;
83const S32 SCULPT_REZ_3 = 16;
84const S32 SCULPT_REZ_4 = 32;
85
81BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm) 86BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
82{ 87{
83 LLVector3 test = (pt2-pt1)%(pt3-pt2); 88 LLVector3 test = (pt2-pt1)%(pt3-pt2);
@@ -455,25 +460,27 @@ LLProfile::Face* LLProfile::addHole(BOOL flat, F32 sides, F32 offset, F32 box_ho
455} 460}
456 461
457 462
458F32 next_power_of_two(F32 value) 463S32 sculpt_sides(F32 detail)
459{
460 S32 power = (S32)llceil((F32)log((double)value)/(F32)log(2.0));
461 return pow(2.0f, power);
462}
463
464F32 nearest_power_of_two(F32 value)
465{ 464{
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 465
469 // our windows build hates the math.h defines, so do it here. -qarl 466 // detail is usually one of: 1, 1.5, 2.5, 4.0.
470 F32 const INVSQRT2 = 0.7071067812f;
471 467
472 F32 answer = next_power_of_two(value * INVSQRT2); 468 if (detail <= 1.0)
473 469 {
474 // llwarns << value << " -> " << answer << llendl; 470 return SCULPT_REZ_1;
475 471 }
476 return answer; 472 if (detail <= 2.0)
473 {
474 return SCULPT_REZ_2;
475 }
476 if (detail <= 3.0)
477 {
478 return SCULPT_REZ_3;
479 }
480 else
481 {
482 return SCULPT_REZ_4;
483 }
477} 484}
478 485
479 486
@@ -619,7 +626,7 @@ BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split, BOOL is_sculpted)
619 S32 sides = (S32)circle_detail; 626 S32 sides = (S32)circle_detail;
620 627
621 if (is_sculpted) 628 if (is_sculpted)
622 sides = (S32)nearest_power_of_two((F32)sides - 1); 629 sides = sculpt_sides(detail);
623 630
624 genNGon(sides); 631 genNGon(sides);
625 632
@@ -1166,7 +1173,7 @@ BOOL LLPath::generate(F32 detail, S32 split, BOOL is_sculpted)
1166 S32 sides = (S32)llfloor(llfloor((MIN_DETAIL_FACES * detail + twist_mag * 3.5f * (detail-0.5f))) * mParams.getRevolutions()); 1173 S32 sides = (S32)llfloor(llfloor((MIN_DETAIL_FACES * detail + twist_mag * 3.5f * (detail-0.5f))) * mParams.getRevolutions());
1167 1174
1168 if (is_sculpted) 1175 if (is_sculpted)
1169 sides = (S32)nearest_power_of_two((F32)sides - 1); 1176 sides = sculpt_sides(detail);
1170 1177
1171 genNGon(sides); 1178 genNGon(sides);
1172 } 1179 }