diff options
author | UbitUmarov | 2015-08-20 17:04:37 +0100 |
---|---|---|
committer | UbitUmarov | 2015-08-20 17:04:37 +0100 |
commit | 379362facfbc8c50660d546520d4ea78257d04ae (patch) | |
tree | 160d770c90518d8d6aebf8edb554f4c362470024 /OpenSim/Region/Physics/OdePlugin/OdeScene.cs | |
parent | make it compatible with avn, no point making avn compatible with it (diff) | |
download | opensim-SC-379362facfbc8c50660d546520d4ea78257d04ae.zip opensim-SC-379362facfbc8c50660d546520d4ea78257d04ae.tar.gz opensim-SC-379362facfbc8c50660d546520d4ea78257d04ae.tar.bz2 opensim-SC-379362facfbc8c50660d546520d4ea78257d04ae.tar.xz |
make basic ode work with var regions for contribution back to CORE. ( avn
partial compatibility code needs to be reverted). Cant fully test.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 285 |
1 files changed, 135 insertions, 150 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 1b7d2bf..820e649 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs | |||
@@ -25,6 +25,14 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | // Ubit changes for varsize regions | ||
29 | // using a large Heightfield geometry for terrain | ||
30 | // ODE ode should handle it fine | ||
31 | // EXCEPT raycasts, those need to have limited range | ||
32 | // (even in normal regions) | ||
33 | // or aplication stack will just blowup | ||
34 | |||
35 | |||
28 | //#define USE_DRAWSTUFF | 36 | //#define USE_DRAWSTUFF |
29 | //#define SPAM | 37 | //#define SPAM |
30 | 38 | ||
@@ -263,8 +271,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
263 | 271 | ||
264 | private Random fluidRandomizer = new Random(Environment.TickCount); | 272 | private Random fluidRandomizer = new Random(Environment.TickCount); |
265 | 273 | ||
266 | private const uint m_regionWidth = Constants.RegionSize; | 274 | public bool m_suportCombine = true; |
267 | private const uint m_regionHeight = Constants.RegionSize; | 275 | |
276 | private uint m_regionWidth = Constants.RegionSize; | ||
277 | private uint m_regionHeight = Constants.RegionSize; | ||
268 | 278 | ||
269 | private float ODE_STEPSIZE = 0.0178f; | 279 | private float ODE_STEPSIZE = 0.0178f; |
270 | private float metersInSpace = 29.9f; | 280 | private float metersInSpace = 29.9f; |
@@ -290,7 +300,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
290 | 300 | ||
291 | private readonly IntPtr contactgroup; | 301 | private readonly IntPtr contactgroup; |
292 | 302 | ||
293 | internal IntPtr WaterGeom; | 303 | // internal IntPtr WaterGeom; |
294 | 304 | ||
295 | private float nmTerrainContactFriction = 255.0f; | 305 | private float nmTerrainContactFriction = 255.0f; |
296 | private float nmTerrainContactBounce = 0.1f; | 306 | private float nmTerrainContactBounce = 0.1f; |
@@ -507,17 +517,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
507 | public d.Vector3 xyz = new d.Vector3(128.1640f, 128.3079f, 25.7600f); | 517 | public d.Vector3 xyz = new d.Vector3(128.1640f, 128.3079f, 25.7600f); |
508 | public d.Vector3 hpr = new d.Vector3(125.5000f, -17.0000f, 0.0000f); | 518 | public d.Vector3 hpr = new d.Vector3(125.5000f, -17.0000f, 0.0000f); |
509 | 519 | ||
510 | // TODO: unused: private uint heightmapWidth = m_regionWidth + 1; | ||
511 | // TODO: unused: private uint heightmapHeight = m_regionHeight + 1; | ||
512 | // TODO: unused: private uint heightmapWidthSamples; | ||
513 | // TODO: unused: private uint heightmapHeightSamples; | ||
514 | |||
515 | private volatile int m_global_contactcount = 0; | 520 | private volatile int m_global_contactcount = 0; |
516 | 521 | ||
517 | private Vector3 m_worldOffset = Vector3.Zero; | 522 | private Vector3 m_worldOffset = Vector3.Zero; |
518 | public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); | 523 | public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); |
519 | private PhysicsScene m_parentScene = null; | 524 | private PhysicsScene m_parentScene = null; |
520 | 525 | ||
526 | float spacesPerMeterX; | ||
527 | float spacesPerMeterY; | ||
528 | int spaceGridMaxX; | ||
529 | int spaceGridMaxY; | ||
530 | |||
521 | private ODERayCastRequestManager m_rayCastManager; | 531 | private ODERayCastRequestManager m_rayCastManager; |
522 | 532 | ||
523 | /// <summary> | 533 | /// <summary> |
@@ -551,7 +561,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
551 | viewthread.Start(); | 561 | viewthread.Start(); |
552 | #endif | 562 | #endif |
553 | 563 | ||
554 | _watermap = new float[258 * 258]; | 564 | // _watermap = new float[258 * 258]; |
555 | 565 | ||
556 | // Zero out the prim spaces array (we split our space into smaller spaces so | 566 | // Zero out the prim spaces array (we split our space into smaller spaces so |
557 | // we can hit test less. | 567 | // we can hit test less. |
@@ -572,6 +582,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
572 | } | 582 | } |
573 | #endif | 583 | #endif |
574 | 584 | ||
585 | public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) | ||
586 | { | ||
587 | WorldExtents.X = regionExtent.X; | ||
588 | m_regionWidth = (uint)regionExtent.X; | ||
589 | WorldExtents.Y = regionExtent.Y; | ||
590 | m_regionHeight = (uint)regionExtent.Y; | ||
591 | m_suportCombine = false; | ||
592 | Initialise(meshmerizer, config); | ||
593 | } | ||
594 | |||
575 | // Initialize the mesh plugin | 595 | // Initialize the mesh plugin |
576 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | 596 | public override void Initialise(IMesher meshmerizer, IConfigSource config) |
577 | { | 597 | { |
@@ -699,7 +719,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
699 | 719 | ||
700 | contacts = new d.ContactGeom[contactsPerCollision]; | 720 | contacts = new d.ContactGeom[contactsPerCollision]; |
701 | 721 | ||
702 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; | 722 | spacesPerMeterX = 1.0f / metersInSpace; |
723 | spacesPerMeterY = 1.0f / metersInSpace; | ||
724 | |||
725 | spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeterX); | ||
726 | spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeterY); | ||
727 | |||
728 | // ubit: limit number of spaces | ||
729 | if (spaceGridMaxX > 40) | ||
730 | { | ||
731 | spaceGridMaxX = 40; | ||
732 | spacesPerMeterX = WorldExtents.X / spaceGridMaxX; | ||
733 | } | ||
734 | if (spaceGridMaxY > 40) | ||
735 | { | ||
736 | spaceGridMaxY = 40; | ||
737 | spacesPerMeterY = WorldExtents.X / spaceGridMaxY; | ||
738 | } | ||
739 | |||
740 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; | ||
741 | |||
742 | // make this index limits | ||
743 | spaceGridMaxX--; | ||
744 | spaceGridMaxY--; | ||
745 | |||
746 | |||
703 | 747 | ||
704 | // Centeral contact friction and bounce | 748 | // Centeral contact friction and bounce |
705 | // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why | 749 | // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why |
@@ -1883,6 +1927,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1883 | 1927 | ||
1884 | public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) | 1928 | public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) |
1885 | { | 1929 | { |
1930 | if (!m_suportCombine) | ||
1931 | return; | ||
1886 | m_worldOffset = offset; | 1932 | m_worldOffset = offset; |
1887 | WorldExtents = new Vector2(extents.X, extents.Y); | 1933 | WorldExtents = new Vector2(extents.X, extents.Y); |
1888 | m_parentScene = pScene; | 1934 | m_parentScene = pScene; |
@@ -1891,12 +1937,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1891 | // Recovered for use by fly height. Kitto Flora | 1937 | // Recovered for use by fly height. Kitto Flora |
1892 | internal float GetTerrainHeightAtXY(float x, float y) | 1938 | internal float GetTerrainHeightAtXY(float x, float y) |
1893 | { | 1939 | { |
1894 | int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
1895 | int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
1896 | |||
1897 | IntPtr heightFieldGeom = IntPtr.Zero; | 1940 | IntPtr heightFieldGeom = IntPtr.Zero; |
1941 | int offsetX = 0; | ||
1942 | int offsetY = 0; | ||
1898 | 1943 | ||
1899 | if (RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom)) | 1944 | if (m_suportCombine) |
1945 | { | ||
1946 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
1947 | offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
1948 | } | ||
1949 | |||
1950 | if(RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom)) | ||
1900 | { | 1951 | { |
1901 | if (heightFieldGeom != IntPtr.Zero) | 1952 | if (heightFieldGeom != IntPtr.Zero) |
1902 | { | 1953 | { |
@@ -1910,8 +1961,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1910 | (int)x < 0.001f || (int)y < 0.001f) | 1961 | (int)x < 0.001f || (int)y < 0.001f) |
1911 | return 0; | 1962 | return 0; |
1912 | 1963 | ||
1913 | x = x - offsetX; | 1964 | x = x - offsetX + 1f; |
1914 | y = y - offsetY; | 1965 | y = y - offsetY + 1f; |
1915 | 1966 | ||
1916 | index = (int)((int)x * ((int)Constants.RegionSize + 2) + (int)y); | 1967 | index = (int)((int)x * ((int)Constants.RegionSize + 2) + (int)y); |
1917 | 1968 | ||
@@ -2763,16 +2814,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2763 | { | 2814 | { |
2764 | int[] returnint = new int[2]; | 2815 | int[] returnint = new int[2]; |
2765 | 2816 | ||
2766 | returnint[0] = (int) (pos.X/metersInSpace); | 2817 | returnint[0] = (int) (pos.X * spacesPerMeterX); |
2767 | 2818 | ||
2768 | if (returnint[0] > ((int) (259f/metersInSpace))) | 2819 | if (returnint[0] > spaceGridMaxX) |
2769 | returnint[0] = ((int) (259f/metersInSpace)); | 2820 | returnint[0] = spaceGridMaxX; |
2770 | if (returnint[0] < 0) | 2821 | if (returnint[0] < 0) |
2771 | returnint[0] = 0; | 2822 | returnint[0] = 0; |
2772 | 2823 | ||
2773 | returnint[1] = (int) (pos.Y/metersInSpace); | 2824 | returnint[1] = (int)(pos.Y * spacesPerMeterY); |
2774 | if (returnint[1] > ((int) (259f/metersInSpace))) | 2825 | if (returnint[1] > spaceGridMaxY) |
2775 | returnint[1] = ((int) (259f/metersInSpace)); | 2826 | returnint[1] = spaceGridMaxY; |
2776 | if (returnint[1] < 0) | 2827 | if (returnint[1] < 0) |
2777 | returnint[1] = 0; | 2828 | returnint[1] = 0; |
2778 | 2829 | ||
@@ -3526,6 +3577,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3526 | get { return false; } | 3577 | get { return false; } |
3527 | } | 3578 | } |
3528 | 3579 | ||
3580 | /* godd try.. but not a fix | ||
3529 | #region ODE Specific Terrain Fixes | 3581 | #region ODE Specific Terrain Fixes |
3530 | private float[] ResizeTerrain512NearestNeighbour(float[] heightMap) | 3582 | private float[] ResizeTerrain512NearestNeighbour(float[] heightMap) |
3531 | { | 3583 | { |
@@ -3792,7 +3844,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3792 | } | 3844 | } |
3793 | 3845 | ||
3794 | #endregion | 3846 | #endregion |
3795 | 3847 | */ | |
3796 | public override void SetTerrain(float[] heightMap) | 3848 | public override void SetTerrain(float[] heightMap) |
3797 | { | 3849 | { |
3798 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) | 3850 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) |
@@ -3813,71 +3865,63 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3813 | int startTime = Util.EnvironmentTickCount(); | 3865 | int startTime = Util.EnvironmentTickCount(); |
3814 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", Name, pOffset); | 3866 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", Name, pOffset); |
3815 | 3867 | ||
3816 | // this._heightmap[i] = (double)heightMap[i]; | 3868 | |
3817 | // dbm (danx0r) -- creating a buffer zone of one extra sample all around | ||
3818 | //_origheightmap = heightMap; | ||
3819 | |||
3820 | float[] _heightmap; | 3869 | float[] _heightmap; |
3821 | 3870 | ||
3822 | // zero out a heightmap array float array (single dimension [flattened])) | 3871 | // ok im lasy this are just a aliases |
3823 | //if ((int)Constants.RegionSize == 256) | 3872 | uint regionsizeX = m_regionWidth; |
3824 | // _heightmap = new float[514 * 514]; | 3873 | uint regionsizeY = m_regionHeight; |
3825 | //else | ||
3826 | |||
3827 | _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))]; | ||
3828 | |||
3829 | uint heightmapWidth = Constants.RegionSize + 1; | ||
3830 | uint heightmapHeight = Constants.RegionSize + 1; | ||
3831 | |||
3832 | uint heightmapWidthSamples; | ||
3833 | 3874 | ||
3834 | uint heightmapHeightSamples; | 3875 | // map is rotated |
3876 | uint heightmapWidth = regionsizeY + 2; | ||
3877 | uint heightmapHeight = regionsizeX + 2; | ||
3835 | 3878 | ||
3836 | //if (((int)Constants.RegionSize) == 256) | 3879 | uint heightmapWidthSamples = heightmapWidth + 1; |
3837 | //{ | 3880 | uint heightmapHeightSamples = heightmapHeight + 1; |
3838 | // heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2; | ||
3839 | // heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2; | ||
3840 | // heightmapWidth++; | ||
3841 | // heightmapHeight++; | ||
3842 | //} | ||
3843 | //else | ||
3844 | //{ | ||
3845 | 3881 | ||
3846 | heightmapWidthSamples = (uint)Constants.RegionSize + 1; | 3882 | _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples]; |
3847 | heightmapHeightSamples = (uint)Constants.RegionSize + 1; | ||
3848 | //} | ||
3849 | 3883 | ||
3850 | const float scale = 1.0f; | 3884 | const float scale = 1.0f; |
3851 | const float offset = 0.0f; | 3885 | const float offset = 0.0f; |
3852 | const float thickness = 0.2f; | 3886 | const float thickness = 10f; |
3853 | const int wrap = 0; | 3887 | const int wrap = 0; |
3854 | 3888 | ||
3855 | int regionsize = (int) Constants.RegionSize + 2; | ||
3856 | //Double resolution | ||
3857 | //if (((int)Constants.RegionSize) == 256) | ||
3858 | // heightMap = ResizeTerrain512Interpolation(heightMap); | ||
3859 | 3889 | ||
3890 | float hfmin = float.MaxValue; | ||
3891 | float hfmax = float.MinValue; | ||
3892 | float val; | ||
3893 | uint xx; | ||
3894 | uint yy; | ||
3860 | 3895 | ||
3861 | // if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256) | 3896 | uint maxXX = regionsizeX - 1; |
3862 | // regionsize = 512; | 3897 | uint maxYY = regionsizeY - 1; |
3863 | 3898 | ||
3864 | float hfmin = 2000; | 3899 | // flipping map adding one margin all around so things don't fall in edges |
3865 | float hfmax = -2000; | 3900 | |
3866 | 3901 | uint xt = 0; | |
3867 | for (int x = 0; x < heightmapWidthSamples; x++) | 3902 | xx = 0; |
3903 | |||
3904 | for (uint x = 0; x < heightmapWidthSamples; x++) | ||
3868 | { | 3905 | { |
3869 | for (int y = 0; y < heightmapHeightSamples; y++) | 3906 | if (x > 1 && xx < maxXX) |
3907 | xx++; | ||
3908 | yy = 0; | ||
3909 | for (uint y = 0; y < heightmapHeightSamples; y++) | ||
3870 | { | 3910 | { |
3871 | int xx = Util.Clip(x - 1, 0, regionsize - 1); | 3911 | if (y > 1 && y < maxYY) |
3872 | int yy = Util.Clip(y - 1, 0, regionsize - 1); | 3912 | yy += regionsizeX; |
3873 | 3913 | ||
3874 | 3914 | val = heightMap[yy + xx]; | |
3875 | float val= heightMap[yy * (int)Constants.RegionSize + xx]; | 3915 | if (val < 0.0f) |
3876 | _heightmap[x * ((int)Constants.RegionSize + 2) + y] = val; | 3916 | val = 0.0f; |
3877 | 3917 | _heightmap[xt + y] = val; | |
3878 | hfmin = (val < hfmin) ? val : hfmin; | 3918 | |
3879 | hfmax = (val > hfmax) ? val : hfmax; | 3919 | if (hfmin > val) |
3920 | hfmin = val; | ||
3921 | if (hfmax < val) | ||
3922 | hfmax = val; | ||
3880 | } | 3923 | } |
3924 | xt += heightmapHeightSamples; | ||
3881 | } | 3925 | } |
3882 | 3926 | ||
3883 | lock (OdeLock) | 3927 | lock (OdeLock) |
@@ -3898,9 +3942,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3898 | 3942 | ||
3899 | } | 3943 | } |
3900 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 3944 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
3901 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth + 1, heightmapHeight + 1, | 3945 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight, |
3902 | (int)heightmapWidthSamples + 1, (int)heightmapHeightSamples + 1, scale, | 3946 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, |
3903 | offset, thickness, wrap); | 3947 | offset, thickness, wrap); |
3948 | |||
3904 | d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); | 3949 | d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); |
3905 | GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); | 3950 | GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); |
3906 | if (GroundGeom != IntPtr.Zero) | 3951 | if (GroundGeom != IntPtr.Zero) |
@@ -3915,17 +3960,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3915 | 3960 | ||
3916 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); | 3961 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); |
3917 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); | 3962 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); |
3918 | //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1)); | ||
3919 | 3963 | ||
3920 | q1 = q1 * q2; | 3964 | q1 = q1 * q2; |
3921 | //q1 = q1 * q3; | ||
3922 | Vector3 v3; | 3965 | Vector3 v3; |
3923 | float angle; | 3966 | float angle; |
3924 | q1.GetAxisAngle(out v3, out angle); | 3967 | q1.GetAxisAngle(out v3, out angle); |
3925 | 3968 | ||
3926 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 3969 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
3927 | d.GeomSetRotation(GroundGeom, ref R); | 3970 | d.GeomSetRotation(GroundGeom, ref R); |
3928 | d.GeomSetPosition(GroundGeom, (pOffset.X + ((int)Constants.RegionSize * 0.5f)), (pOffset.Y + ((int)Constants.RegionSize * 0.5f)), 0); | 3971 | d.GeomSetPosition(GroundGeom, pOffset.X + regionsizeX * 0.5f, pOffset.Y + regionsizeY * 0.5f, 0); |
3929 | IntPtr testGround = IntPtr.Zero; | 3972 | IntPtr testGround = IntPtr.Zero; |
3930 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) | 3973 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) |
3931 | { | 3974 | { |
@@ -3950,89 +3993,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3950 | 3993 | ||
3951 | public override bool SupportsCombining() | 3994 | public override bool SupportsCombining() |
3952 | { | 3995 | { |
3953 | return true; | 3996 | return m_suportCombine; |
3954 | } | 3997 | } |
3955 | 3998 | ||
3956 | // public override void UnCombine(PhysicsScene pScene) | ||
3957 | // { | ||
3958 | // IntPtr localGround = IntPtr.Zero; | ||
3959 | //// float[] localHeightfield; | ||
3960 | // bool proceed = false; | ||
3961 | // List<IntPtr> geomDestroyList = new List<IntPtr>(); | ||
3962 | // | ||
3963 | // lock (OdeLock) | ||
3964 | // { | ||
3965 | // if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround)) | ||
3966 | // { | ||
3967 | // foreach (IntPtr geom in TerrainHeightFieldHeights.Keys) | ||
3968 | // { | ||
3969 | // if (geom == localGround) | ||
3970 | // { | ||
3971 | //// localHeightfield = TerrainHeightFieldHeights[geom]; | ||
3972 | // proceed = true; | ||
3973 | // } | ||
3974 | // else | ||
3975 | // { | ||
3976 | // geomDestroyList.Add(geom); | ||
3977 | // } | ||
3978 | // } | ||
3979 | // | ||
3980 | // if (proceed) | ||
3981 | // { | ||
3982 | // m_worldOffset = Vector3.Zero; | ||
3983 | // WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); | ||
3984 | // m_parentScene = null; | ||
3985 | // | ||
3986 | // foreach (IntPtr g in geomDestroyList) | ||
3987 | // { | ||
3988 | // // removingHeightField needs to be done or the garbage collector will | ||
3989 | // // collect the terrain data before we tell ODE to destroy it causing | ||
3990 | // // memory corruption | ||
3991 | // if (TerrainHeightFieldHeights.ContainsKey(g)) | ||
3992 | // { | ||
3993 | //// float[] removingHeightField = TerrainHeightFieldHeights[g]; | ||
3994 | // TerrainHeightFieldHeights.Remove(g); | ||
3995 | // | ||
3996 | // if (RegionTerrain.ContainsKey(g)) | ||
3997 | // { | ||
3998 | // RegionTerrain.Remove(g); | ||
3999 | // } | ||
4000 | // | ||
4001 | // d.GeomDestroy(g); | ||
4002 | // //removingHeightField = new float[0]; | ||
4003 | // } | ||
4004 | // } | ||
4005 | // | ||
4006 | // } | ||
4007 | // else | ||
4008 | // { | ||
4009 | // m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data."); | ||
4010 | // } | ||
4011 | // } | ||
4012 | // } | ||
4013 | // } | ||
4014 | |||
4015 | public override void SetWaterLevel(float baseheight) | 3999 | public override void SetWaterLevel(float baseheight) |
4016 | { | 4000 | { |
4017 | waterlevel = baseheight; | 4001 | waterlevel = baseheight; |
4018 | randomizeWater(waterlevel); | 4002 | // randomizeWater(waterlevel); |
4019 | } | 4003 | } |
4020 | 4004 | ||
4005 | /* | ||
4021 | private void randomizeWater(float baseheight) | 4006 | private void randomizeWater(float baseheight) |
4022 | { | 4007 | { |
4023 | const uint heightmapWidth = m_regionWidth + 2; | 4008 | uint heightmapWidth = m_regionWidth + 2; |
4024 | const uint heightmapHeight = m_regionHeight + 2; | 4009 | uint heightmapHeight = m_regionHeight + 2; |
4025 | const uint heightmapWidthSamples = m_regionWidth + 2; | 4010 | uint heightmapWidthSamples = m_regionWidth + 2; |
4026 | const uint heightmapHeightSamples = m_regionHeight + 2; | 4011 | uint heightmapHeightSamples = m_regionHeight + 2; |
4027 | const float scale = 1.0f; | 4012 | float scale = 1.0f; |
4028 | const float offset = 0.0f; | 4013 | float offset = 0.0f; |
4029 | const float thickness = 2.9f; | 4014 | float thickness = 2.9f; |
4030 | const int wrap = 0; | 4015 | int wrap = 0; |
4031 | 4016 | ||
4032 | for (int i = 0; i < (258 * 258); i++) | 4017 | for (int i = 0; i < (258 * 258); i++) |
4033 | { | 4018 | { |
4034 | _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f); | 4019 | _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f); |
4035 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); | 4020 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); |
4036 | } | 4021 | } |
4037 | 4022 | ||
4038 | lock (OdeLock) | 4023 | lock (OdeLock) |
@@ -4043,8 +4028,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4043 | } | 4028 | } |
4044 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 4029 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
4045 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight, | 4030 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight, |
4046 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, | 4031 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, |
4047 | offset, thickness, wrap); | 4032 | offset, thickness, wrap); |
4048 | d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); | 4033 | d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); |
4049 | WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); | 4034 | WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); |
4050 | if (WaterGeom != IntPtr.Zero) | 4035 | if (WaterGeom != IntPtr.Zero) |
@@ -4072,7 +4057,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4072 | d.GeomSetPosition(WaterGeom, 128, 128, 0); | 4057 | d.GeomSetPosition(WaterGeom, 128, 128, 0); |
4073 | } | 4058 | } |
4074 | } | 4059 | } |
4075 | 4060 | */ | |
4076 | public override void Dispose() | 4061 | public override void Dispose() |
4077 | { | 4062 | { |
4078 | _worldInitialized = false; | 4063 | _worldInitialized = false; |