diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmath/llvolume.cpp | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp index fb745b8..327f1bf 100644 --- a/linden/indra/llmath/llvolume.cpp +++ b/linden/indra/llmath/llvolume.cpp | |||
@@ -1829,13 +1829,16 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, | |||
1829 | U32 x = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_width); | 1829 | U32 x = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_width); |
1830 | U32 y = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_height); | 1830 | U32 y = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_height); |
1831 | 1831 | ||
1832 | if (y == sculpt_height) // clamp to bottom row | 1832 | if (y == sculpt_height) // stitch bottom |
1833 | { | ||
1833 | y = sculpt_height - 1; | 1834 | y = sculpt_height - 1; |
1835 | x = sculpt_width / 2; | ||
1836 | } | ||
1834 | 1837 | ||
1835 | if (x == sculpt_width) // stitch sides | 1838 | if (x == sculpt_width) // stitch sides |
1836 | x = 0; | 1839 | x = 0; |
1837 | 1840 | ||
1838 | if ((y == 0) || (y == sculpt_height-1)) // stitch top and bottom | 1841 | if (y == 0) // stitch top |
1839 | x = sculpt_width / 2; | 1842 | x = sculpt_width / 2; |
1840 | 1843 | ||
1841 | U32 index = (x + y * sculpt_width) * sculpt_components; | 1844 | U32 index = (x + y * sculpt_width) * sculpt_components; |
@@ -1847,63 +1850,69 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, | |||
1847 | 1850 | ||
1848 | last_index = index; | 1851 | last_index = index; |
1849 | } | 1852 | } |
1853 | if ((F32)vertex_change / sizeS / sizeT < 0.05) // less than 5% | ||
1854 | data_is_empty = TRUE; | ||
1850 | } | 1855 | } |
1851 | 1856 | ||
1852 | |||
1853 | if ((F32)vertex_change / sizeS / sizeT < 0.05) // less than 5% | ||
1854 | data_is_empty = TRUE; | ||
1855 | |||
1856 | |||
1857 | //generate vertex positions | 1857 | //generate vertex positions |
1858 | // Run along the path. | 1858 | if (data_is_empty) // if empty, make a sphere |
1859 | S32 s = 0, t = 0; | ||
1860 | S32 line = 0; | ||
1861 | while (s < sizeS) | ||
1862 | { | 1859 | { |
1863 | t = 0; | 1860 | S32 line = 0; |
1864 | // Run along the profile. | ||
1865 | while (t < sizeT) | ||
1866 | { | ||
1867 | S32 i = t + line; | ||
1868 | Point& pt = mMesh[i]; | ||
1869 | |||
1870 | U32 x = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_width); | ||
1871 | U32 y = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_height); | ||
1872 | 1861 | ||
1873 | if (y == sculpt_height) // clamp to bottom row | 1862 | for (S32 s = 0; s < sizeS; s++) |
1874 | y = sculpt_height - 1; | 1863 | { |
1875 | 1864 | for (S32 t = 0; t < sizeT; t++) | |
1876 | if (x == sculpt_width) // stitch sides | 1865 | { |
1877 | x = 0; | 1866 | S32 i = t + line; |
1867 | Point& pt = mMesh[i]; | ||
1878 | 1868 | ||
1879 | if ((y == 0) || (y == sculpt_height-1)) // stitch top and bottom | ||
1880 | x = sculpt_width / 2; | ||
1881 | 1869 | ||
1882 | |||
1883 | if (data_is_empty) // if empty, make a sphere | ||
1884 | { | ||
1885 | F32 u = (F32)s/(sizeS-1); | 1870 | F32 u = (F32)s/(sizeS-1); |
1886 | F32 v = (F32)t/(sizeT-1); | 1871 | F32 v = (F32)t/(sizeT-1); |
1887 | 1872 | ||
1888 | const F32 RADIUS = (F32) 0.3; | 1873 | const F32 RADIUS = (F32) 0.3; |
1889 | 1874 | ||
1890 | pt.mPos.mV[0] = (F32)(sin(F_PI * v) * cos(2.0 * F_PI * u) * RADIUS); | 1875 | pt.mPos.mV[0] = (F32)(sin(F_PI * v) * cos(2.0 * F_PI * u) * RADIUS); |
1891 | pt.mPos.mV[1] = (F32)(sin(F_PI * v) * sin(2.0 * F_PI * u) * RADIUS); | 1876 | pt.mPos.mV[1] = (F32)(sin(F_PI * v) * sin(2.0 * F_PI * u) * RADIUS); |
1892 | pt.mPos.mV[2] = (F32)(cos(F_PI * v) * RADIUS); | 1877 | pt.mPos.mV[2] = (F32)(cos(F_PI * v) * RADIUS); |
1878 | |||
1893 | } | 1879 | } |
1894 | 1880 | line += sizeT; | |
1895 | else | 1881 | } |
1882 | } | ||
1883 | else | ||
1884 | { | ||
1885 | S32 line = 0; | ||
1886 | for (S32 s = 0; s < sizeS; s++) | ||
1887 | { | ||
1888 | // Run along the profile. | ||
1889 | for (S32 t = 0; t < sizeT; t++) | ||
1896 | { | 1890 | { |
1891 | S32 i = t + line; | ||
1892 | Point& pt = mMesh[i]; | ||
1893 | |||
1894 | U32 x = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_width); | ||
1895 | U32 y = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_height); | ||
1896 | |||
1897 | if (y == sculpt_height) // stitch bottom row | ||
1898 | { | ||
1899 | y = sculpt_height - 1; | ||
1900 | x = sculpt_width / 2; | ||
1901 | } | ||
1902 | |||
1903 | if (x == sculpt_width) // stitch sides | ||
1904 | x = 0; | ||
1905 | |||
1906 | if (y == 0) // stitch top row | ||
1907 | x = sculpt_width / 2; | ||
1908 | |||
1897 | U32 index = (x + y * sculpt_width) * sculpt_components; | 1909 | U32 index = (x + y * sculpt_width) * sculpt_components; |
1898 | pt.mPos.mV[0] = sculpt_data[index ] / 256.f - 0.5f; | 1910 | pt.mPos.mV[0] = sculpt_data[index ] / 256.f - 0.5f; |
1899 | pt.mPos.mV[1] = sculpt_data[index+1] / 256.f - 0.5f; | 1911 | pt.mPos.mV[1] = sculpt_data[index+1] / 256.f - 0.5f; |
1900 | pt.mPos.mV[2] = sculpt_data[index+2] / 256.f - 0.5f; | 1912 | pt.mPos.mV[2] = sculpt_data[index+2] / 256.f - 0.5f; |
1901 | } | 1913 | } |
1902 | 1914 | line += sizeT; | |
1903 | t++; | ||
1904 | } | 1915 | } |
1905 | line += sizeT; | ||
1906 | s++; | ||
1907 | } | 1916 | } |
1908 | 1917 | ||
1909 | for (S32 i = 0; i < (S32)mProfilep->mFaces.size(); i++) | 1918 | for (S32 i = 0; i < (S32)mProfilep->mFaces.size(); i++) |