diff options
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdeScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 309 |
1 files changed, 159 insertions, 150 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 5953557..7f4a809 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; | ||
1943 | |||
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 | } | ||
1898 | 1949 | ||
1899 | if (RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom)) | 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 | ||
@@ -1969,11 +2020,35 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1969 | 2020 | ||
1970 | #region Add/Remove Entities | 2021 | #region Add/Remove Entities |
1971 | 2022 | ||
2023 | <<<<<<< HEAD | ||
1972 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) | 2024 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) |
1973 | { | 2025 | { |
1974 | OdeCharacter newAv | 2026 | OdeCharacter newAv |
1975 | = new OdeCharacter( | 2027 | = new OdeCharacter( |
1976 | avName, this, position, velocity, size, avPIDD, avPIDP, | 2028 | avName, this, position, velocity, size, avPIDD, avPIDP, |
2029 | ======= | ||
2030 | /* core version | ||
2031 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) | ||
2032 | { | ||
2033 | OdeCharacter newAv | ||
2034 | = new OdeCharacter( | ||
2035 | avName, this, position, velocity, size, avPIDD, avPIDP, | ||
2036 | avCapRadius, avStandupTensor, avDensity, | ||
2037 | avMovementDivisorWalk, avMovementDivisorRun); | ||
2038 | |||
2039 | newAv.Flying = isFlying; | ||
2040 | newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; | ||
2041 | newAv.m_avatarplanted = avplanted; | ||
2042 | |||
2043 | return newAv; | ||
2044 | } | ||
2045 | */ | ||
2046 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | ||
2047 | { | ||
2048 | OdeCharacter newAv | ||
2049 | = new OdeCharacter( | ||
2050 | avName, this, position, Vector3.Zero, size, avPIDD, avPIDP, | ||
2051 | >>>>>>> avn/ubitvar | ||
1977 | avCapRadius, avStandupTensor, avDensity, | 2052 | avCapRadius, avStandupTensor, avDensity, |
1978 | avMovementDivisorWalk, avMovementDivisorRun); | 2053 | avMovementDivisorWalk, avMovementDivisorRun); |
1979 | 2054 | ||
@@ -2747,16 +2822,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2747 | { | 2822 | { |
2748 | int[] returnint = new int[2]; | 2823 | int[] returnint = new int[2]; |
2749 | 2824 | ||
2750 | returnint[0] = (int) (pos.X/metersInSpace); | 2825 | returnint[0] = (int) (pos.X * spacesPerMeterX); |
2751 | 2826 | ||
2752 | if (returnint[0] > ((int) (259f/metersInSpace))) | 2827 | if (returnint[0] > spaceGridMaxX) |
2753 | returnint[0] = ((int) (259f/metersInSpace)); | 2828 | returnint[0] = spaceGridMaxX; |
2754 | if (returnint[0] < 0) | 2829 | if (returnint[0] < 0) |
2755 | returnint[0] = 0; | 2830 | returnint[0] = 0; |
2756 | 2831 | ||
2757 | returnint[1] = (int) (pos.Y/metersInSpace); | 2832 | returnint[1] = (int)(pos.Y * spacesPerMeterY); |
2758 | if (returnint[1] > ((int) (259f/metersInSpace))) | 2833 | if (returnint[1] > spaceGridMaxY) |
2759 | returnint[1] = ((int) (259f/metersInSpace)); | 2834 | returnint[1] = spaceGridMaxY; |
2760 | if (returnint[1] < 0) | 2835 | if (returnint[1] < 0) |
2761 | returnint[1] = 0; | 2836 | returnint[1] = 0; |
2762 | 2837 | ||
@@ -3510,6 +3585,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3510 | get { return false; } | 3585 | get { return false; } |
3511 | } | 3586 | } |
3512 | 3587 | ||
3588 | /* godd try.. but not a fix | ||
3513 | #region ODE Specific Terrain Fixes | 3589 | #region ODE Specific Terrain Fixes |
3514 | private float[] ResizeTerrain512NearestNeighbour(float[] heightMap) | 3590 | private float[] ResizeTerrain512NearestNeighbour(float[] heightMap) |
3515 | { | 3591 | { |
@@ -3776,7 +3852,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3776 | } | 3852 | } |
3777 | 3853 | ||
3778 | #endregion | 3854 | #endregion |
3779 | 3855 | */ | |
3780 | public override void SetTerrain(float[] heightMap) | 3856 | public override void SetTerrain(float[] heightMap) |
3781 | { | 3857 | { |
3782 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) | 3858 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) |
@@ -3797,71 +3873,63 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3797 | int startTime = Util.EnvironmentTickCount(); | 3873 | int startTime = Util.EnvironmentTickCount(); |
3798 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", Name, pOffset); | 3874 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", Name, pOffset); |
3799 | 3875 | ||
3800 | // this._heightmap[i] = (double)heightMap[i]; | 3876 | |
3801 | // dbm (danx0r) -- creating a buffer zone of one extra sample all around | ||
3802 | //_origheightmap = heightMap; | ||
3803 | |||
3804 | float[] _heightmap; | 3877 | float[] _heightmap; |
3805 | 3878 | ||
3806 | // zero out a heightmap array float array (single dimension [flattened])) | 3879 | // ok im lasy this are just a aliases |
3807 | //if ((int)Constants.RegionSize == 256) | 3880 | uint regionsizeX = m_regionWidth; |
3808 | // _heightmap = new float[514 * 514]; | 3881 | uint regionsizeY = m_regionHeight; |
3809 | //else | ||
3810 | |||
3811 | _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))]; | ||
3812 | 3882 | ||
3813 | uint heightmapWidth = Constants.RegionSize + 1; | 3883 | // map is rotated |
3814 | uint heightmapHeight = Constants.RegionSize + 1; | 3884 | uint heightmapWidth = regionsizeY + 2; |
3885 | uint heightmapHeight = regionsizeX + 2; | ||
3815 | 3886 | ||
3816 | uint heightmapWidthSamples; | 3887 | uint heightmapWidthSamples = heightmapWidth + 1; |
3888 | uint heightmapHeightSamples = heightmapHeight + 1; | ||
3817 | 3889 | ||
3818 | uint heightmapHeightSamples; | 3890 | _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples]; |
3819 | |||
3820 | //if (((int)Constants.RegionSize) == 256) | ||
3821 | //{ | ||
3822 | // heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2; | ||
3823 | // heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2; | ||
3824 | // heightmapWidth++; | ||
3825 | // heightmapHeight++; | ||
3826 | //} | ||
3827 | //else | ||
3828 | //{ | ||
3829 | |||
3830 | heightmapWidthSamples = (uint)Constants.RegionSize + 1; | ||
3831 | heightmapHeightSamples = (uint)Constants.RegionSize + 1; | ||
3832 | //} | ||
3833 | 3891 | ||
3834 | const float scale = 1.0f; | 3892 | const float scale = 1.0f; |
3835 | const float offset = 0.0f; | 3893 | const float offset = 0.0f; |
3836 | const float thickness = 0.2f; | 3894 | const float thickness = 10f; |
3837 | const int wrap = 0; | 3895 | const int wrap = 0; |
3838 | 3896 | ||
3839 | int regionsize = (int) Constants.RegionSize + 2; | ||
3840 | //Double resolution | ||
3841 | //if (((int)Constants.RegionSize) == 256) | ||
3842 | // heightMap = ResizeTerrain512Interpolation(heightMap); | ||
3843 | 3897 | ||
3898 | float hfmin = float.MaxValue; | ||
3899 | float hfmax = float.MinValue; | ||
3900 | float val; | ||
3901 | uint xx; | ||
3902 | uint yy; | ||
3844 | 3903 | ||
3845 | // if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256) | 3904 | uint maxXX = regionsizeX - 1; |
3846 | // regionsize = 512; | 3905 | uint maxYY = regionsizeY - 1; |
3847 | 3906 | ||
3848 | float hfmin = 2000; | 3907 | // flipping map adding one margin all around so things don't fall in edges |
3849 | float hfmax = -2000; | 3908 | |
3850 | 3909 | uint xt = 0; | |
3851 | for (int x = 0; x < heightmapWidthSamples; x++) | 3910 | xx = 0; |
3911 | |||
3912 | for (uint x = 0; x < heightmapWidthSamples; x++) | ||
3852 | { | 3913 | { |
3853 | for (int y = 0; y < heightmapHeightSamples; y++) | 3914 | if (x > 1 && xx < maxXX) |
3915 | xx++; | ||
3916 | yy = 0; | ||
3917 | for (uint y = 0; y < heightmapHeightSamples; y++) | ||
3854 | { | 3918 | { |
3855 | int xx = Util.Clip(x - 1, 0, regionsize - 1); | 3919 | if (y > 1 && y < maxYY) |
3856 | int yy = Util.Clip(y - 1, 0, regionsize - 1); | 3920 | yy += regionsizeX; |
3857 | 3921 | ||
3858 | 3922 | val = heightMap[yy + xx]; | |
3859 | float val= heightMap[yy * (int)Constants.RegionSize + xx]; | 3923 | if (val < 0.0f) |
3860 | _heightmap[x * ((int)Constants.RegionSize + 2) + y] = val; | 3924 | val = 0.0f; |
3861 | 3925 | _heightmap[xt + y] = val; | |
3862 | hfmin = (val < hfmin) ? val : hfmin; | 3926 | |
3863 | hfmax = (val > hfmax) ? val : hfmax; | 3927 | if (hfmin > val) |
3928 | hfmin = val; | ||
3929 | if (hfmax < val) | ||
3930 | hfmax = val; | ||
3864 | } | 3931 | } |
3932 | xt += heightmapHeightSamples; | ||
3865 | } | 3933 | } |
3866 | 3934 | ||
3867 | lock (OdeLock) | 3935 | lock (OdeLock) |
@@ -3882,9 +3950,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3882 | 3950 | ||
3883 | } | 3951 | } |
3884 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 3952 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
3885 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth + 1, heightmapHeight + 1, | 3953 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight, |
3886 | (int)heightmapWidthSamples + 1, (int)heightmapHeightSamples + 1, scale, | 3954 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, |
3887 | offset, thickness, wrap); | 3955 | offset, thickness, wrap); |
3956 | |||
3888 | d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); | 3957 | d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); |
3889 | GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); | 3958 | GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); |
3890 | if (GroundGeom != IntPtr.Zero) | 3959 | if (GroundGeom != IntPtr.Zero) |
@@ -3899,17 +3968,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3899 | 3968 | ||
3900 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); | 3969 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); |
3901 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); | 3970 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); |
3902 | //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1)); | ||
3903 | 3971 | ||
3904 | q1 = q1 * q2; | 3972 | q1 = q1 * q2; |
3905 | //q1 = q1 * q3; | ||
3906 | Vector3 v3; | 3973 | Vector3 v3; |
3907 | float angle; | 3974 | float angle; |
3908 | q1.GetAxisAngle(out v3, out angle); | 3975 | q1.GetAxisAngle(out v3, out angle); |
3909 | 3976 | ||
3910 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 3977 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
3911 | d.GeomSetRotation(GroundGeom, ref R); | 3978 | d.GeomSetRotation(GroundGeom, ref R); |
3912 | d.GeomSetPosition(GroundGeom, (pOffset.X + ((int)Constants.RegionSize * 0.5f)), (pOffset.Y + ((int)Constants.RegionSize * 0.5f)), 0); | 3979 | d.GeomSetPosition(GroundGeom, pOffset.X + regionsizeX * 0.5f, pOffset.Y + regionsizeY * 0.5f, 0); |
3913 | IntPtr testGround = IntPtr.Zero; | 3980 | IntPtr testGround = IntPtr.Zero; |
3914 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) | 3981 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) |
3915 | { | 3982 | { |
@@ -3934,89 +4001,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3934 | 4001 | ||
3935 | public override bool SupportsCombining() | 4002 | public override bool SupportsCombining() |
3936 | { | 4003 | { |
3937 | return true; | 4004 | return m_suportCombine; |
3938 | } | 4005 | } |
3939 | 4006 | ||
3940 | // public override void UnCombine(PhysicsScene pScene) | ||
3941 | // { | ||
3942 | // IntPtr localGround = IntPtr.Zero; | ||
3943 | //// float[] localHeightfield; | ||
3944 | // bool proceed = false; | ||
3945 | // List<IntPtr> geomDestroyList = new List<IntPtr>(); | ||
3946 | // | ||
3947 | // lock (OdeLock) | ||
3948 | // { | ||
3949 | // if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround)) | ||
3950 | // { | ||
3951 | // foreach (IntPtr geom in TerrainHeightFieldHeights.Keys) | ||
3952 | // { | ||
3953 | // if (geom == localGround) | ||
3954 | // { | ||
3955 | //// localHeightfield = TerrainHeightFieldHeights[geom]; | ||
3956 | // proceed = true; | ||
3957 | // } | ||
3958 | // else | ||
3959 | // { | ||
3960 | // geomDestroyList.Add(geom); | ||
3961 | // } | ||
3962 | // } | ||
3963 | // | ||
3964 | // if (proceed) | ||
3965 | // { | ||
3966 | // m_worldOffset = Vector3.Zero; | ||
3967 | // WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); | ||
3968 | // m_parentScene = null; | ||
3969 | // | ||
3970 | // foreach (IntPtr g in geomDestroyList) | ||
3971 | // { | ||
3972 | // // removingHeightField needs to be done or the garbage collector will | ||
3973 | // // collect the terrain data before we tell ODE to destroy it causing | ||
3974 | // // memory corruption | ||
3975 | // if (TerrainHeightFieldHeights.ContainsKey(g)) | ||
3976 | // { | ||
3977 | //// float[] removingHeightField = TerrainHeightFieldHeights[g]; | ||
3978 | // TerrainHeightFieldHeights.Remove(g); | ||
3979 | // | ||
3980 | // if (RegionTerrain.ContainsKey(g)) | ||
3981 | // { | ||
3982 | // RegionTerrain.Remove(g); | ||
3983 | // } | ||
3984 | // | ||
3985 | // d.GeomDestroy(g); | ||
3986 | // //removingHeightField = new float[0]; | ||
3987 | // } | ||
3988 | // } | ||
3989 | // | ||
3990 | // } | ||
3991 | // else | ||
3992 | // { | ||
3993 | // m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data."); | ||
3994 | // } | ||
3995 | // } | ||
3996 | // } | ||
3997 | // } | ||
3998 | |||
3999 | public override void SetWaterLevel(float baseheight) | 4007 | public override void SetWaterLevel(float baseheight) |
4000 | { | 4008 | { |
4001 | waterlevel = baseheight; | 4009 | waterlevel = baseheight; |
4002 | randomizeWater(waterlevel); | 4010 | // randomizeWater(waterlevel); |
4003 | } | 4011 | } |
4004 | 4012 | ||
4013 | /* | ||
4005 | private void randomizeWater(float baseheight) | 4014 | private void randomizeWater(float baseheight) |
4006 | { | 4015 | { |
4007 | const uint heightmapWidth = m_regionWidth + 2; | 4016 | uint heightmapWidth = m_regionWidth + 2; |
4008 | const uint heightmapHeight = m_regionHeight + 2; | 4017 | uint heightmapHeight = m_regionHeight + 2; |
4009 | const uint heightmapWidthSamples = m_regionWidth + 2; | 4018 | uint heightmapWidthSamples = m_regionWidth + 2; |
4010 | const uint heightmapHeightSamples = m_regionHeight + 2; | 4019 | uint heightmapHeightSamples = m_regionHeight + 2; |
4011 | const float scale = 1.0f; | 4020 | float scale = 1.0f; |
4012 | const float offset = 0.0f; | 4021 | float offset = 0.0f; |
4013 | const float thickness = 2.9f; | 4022 | float thickness = 2.9f; |
4014 | const int wrap = 0; | 4023 | int wrap = 0; |
4015 | 4024 | ||
4016 | for (int i = 0; i < (258 * 258); i++) | 4025 | for (int i = 0; i < (258 * 258); i++) |
4017 | { | 4026 | { |
4018 | _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f); | 4027 | _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f); |
4019 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); | 4028 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); |
4020 | } | 4029 | } |
4021 | 4030 | ||
4022 | lock (OdeLock) | 4031 | lock (OdeLock) |
@@ -4027,8 +4036,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4027 | } | 4036 | } |
4028 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 4037 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
4029 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight, | 4038 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight, |
4030 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, | 4039 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, |
4031 | offset, thickness, wrap); | 4040 | offset, thickness, wrap); |
4032 | d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); | 4041 | d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); |
4033 | WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); | 4042 | WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); |
4034 | if (WaterGeom != IntPtr.Zero) | 4043 | if (WaterGeom != IntPtr.Zero) |
@@ -4056,7 +4065,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4056 | d.GeomSetPosition(WaterGeom, 128, 128, 0); | 4065 | d.GeomSetPosition(WaterGeom, 128, 128, 0); |
4057 | } | 4066 | } |
4058 | } | 4067 | } |
4059 | 4068 | */ | |
4060 | public override void Dispose() | 4069 | public override void Dispose() |
4061 | { | 4070 | { |
4062 | _worldInitialized = false; | 4071 | _worldInitialized = false; |