diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs | 7 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/OdeScene.cs | 288 |
2 files changed, 143 insertions, 152 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs index 21bfea3..aafc7c6 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs | |||
@@ -172,6 +172,13 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
172 | /// <param name="req"></param> | 172 | /// <param name="req"></param> |
173 | private void RayCast(ODERayCastRequest req) | 173 | private void RayCast(ODERayCastRequest req) |
174 | { | 174 | { |
175 | // UBIT: limit ray lenght or collisions will take all avaiable stack space | ||
176 | // this value may still be too large, depending on machine configuration | ||
177 | // of maximum stack | ||
178 | float len = req.length; | ||
179 | if (len > 250f) | ||
180 | len = 250f; | ||
181 | |||
175 | // Create the ray | 182 | // Create the ray |
176 | IntPtr ray = d.CreateRay(m_scene.space, req.length); | 183 | IntPtr ray = d.CreateRay(m_scene.space, req.length); |
177 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); | 184 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); |
diff --git a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs index f49b0f7..19b957f 100644 --- a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs +++ b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs | |||
@@ -25,6 +25,12 @@ | |||
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 | // note that raycasts need to have limited range | ||
30 | // (even in normal regions) | ||
31 | // or aplication thread stack may just blowup | ||
32 | // see RayCast(ODERayCastRequest req) | ||
33 | |||
28 | //#define USE_DRAWSTUFF | 34 | //#define USE_DRAWSTUFF |
29 | //#define SPAM | 35 | //#define SPAM |
30 | 36 | ||
@@ -270,8 +276,10 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
270 | 276 | ||
271 | private Random fluidRandomizer = new Random(Environment.TickCount); | 277 | private Random fluidRandomizer = new Random(Environment.TickCount); |
272 | 278 | ||
273 | private const uint m_regionWidth = Constants.RegionSize; | 279 | public bool m_suportCombine = true; |
274 | private const uint m_regionHeight = Constants.RegionSize; | 280 | |
281 | private uint m_regionWidth = Constants.RegionSize; | ||
282 | private uint m_regionHeight = Constants.RegionSize; | ||
275 | 283 | ||
276 | private float ODE_STEPSIZE = 0.0178f; | 284 | private float ODE_STEPSIZE = 0.0178f; |
277 | private float metersInSpace = 29.9f; | 285 | private float metersInSpace = 29.9f; |
@@ -297,7 +305,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
297 | 305 | ||
298 | private IntPtr contactgroup; | 306 | private IntPtr contactgroup; |
299 | 307 | ||
300 | internal IntPtr WaterGeom; | 308 | // internal IntPtr WaterGeom; |
301 | 309 | ||
302 | private float nmTerrainContactFriction = 255.0f; | 310 | private float nmTerrainContactFriction = 255.0f; |
303 | private float nmTerrainContactBounce = 0.1f; | 311 | private float nmTerrainContactBounce = 0.1f; |
@@ -514,17 +522,17 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
514 | public d.Vector3 xyz = new d.Vector3(128.1640f, 128.3079f, 25.7600f); | 522 | public d.Vector3 xyz = new d.Vector3(128.1640f, 128.3079f, 25.7600f); |
515 | public d.Vector3 hpr = new d.Vector3(125.5000f, -17.0000f, 0.0000f); | 523 | public d.Vector3 hpr = new d.Vector3(125.5000f, -17.0000f, 0.0000f); |
516 | 524 | ||
517 | // TODO: unused: private uint heightmapWidth = m_regionWidth + 1; | ||
518 | // TODO: unused: private uint heightmapHeight = m_regionHeight + 1; | ||
519 | // TODO: unused: private uint heightmapWidthSamples; | ||
520 | // TODO: unused: private uint heightmapHeightSamples; | ||
521 | |||
522 | private volatile int m_global_contactcount = 0; | 525 | private volatile int m_global_contactcount = 0; |
523 | 526 | ||
524 | private Vector3 m_worldOffset = Vector3.Zero; | 527 | private Vector3 m_worldOffset = Vector3.Zero; |
525 | public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); | 528 | public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); |
526 | private PhysicsScene m_parentScene = null; | 529 | private PhysicsScene m_parentScene = null; |
527 | 530 | ||
531 | float spacesPerMeterX; | ||
532 | float spacesPerMeterY; | ||
533 | int spaceGridMaxX; | ||
534 | int spaceGridMaxY; | ||
535 | |||
528 | private ODERayCastRequestManager m_rayCastManager; | 536 | private ODERayCastRequestManager m_rayCastManager; |
529 | 537 | ||
530 | 538 | ||
@@ -583,10 +591,12 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
583 | 591 | ||
584 | scene.RegisterModuleInterface<PhysicsScene>(this); | 592 | scene.RegisterModuleInterface<PhysicsScene>(this); |
585 | Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); | 593 | Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); |
586 | Initialise(); | 594 | Initialise(extent); |
587 | InitialiseFromConfig(m_config); | 595 | InitialiseFromConfig(m_config); |
596 | |||
597 | // This may not be that good since terrain may not be avaiable at this point | ||
588 | base.Initialise(scene.PhysicsRequestAsset, | 598 | base.Initialise(scene.PhysicsRequestAsset, |
589 | (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]), | 599 | (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[(int)(extent.X * extent.Y)]), |
590 | (float)scene.RegionInfo.RegionSettings.WaterHeight); | 600 | (float)scene.RegionInfo.RegionSettings.WaterHeight); |
591 | 601 | ||
592 | } | 602 | } |
@@ -613,8 +623,15 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
613 | /// Sets many properties that ODE requires to be stable | 623 | /// Sets many properties that ODE requires to be stable |
614 | /// These settings need to be tweaked 'exactly' right or weird stuff happens. | 624 | /// These settings need to be tweaked 'exactly' right or weird stuff happens. |
615 | /// </summary> | 625 | /// </summary> |
616 | private void Initialise() | 626 | private void Initialise(Vector3 regionExtent) |
617 | { | 627 | { |
628 | WorldExtents.X = regionExtent.X; | ||
629 | m_regionWidth = (uint)regionExtent.X; | ||
630 | WorldExtents.Y = regionExtent.Y; | ||
631 | m_regionHeight = (uint)regionExtent.Y; | ||
632 | |||
633 | m_suportCombine = false; | ||
634 | |||
618 | nearCallback = near; | 635 | nearCallback = near; |
619 | triCallback = TriCallback; | 636 | triCallback = TriCallback; |
620 | triArrayCallback = TriArrayCallback; | 637 | triArrayCallback = TriArrayCallback; |
@@ -633,7 +650,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
633 | viewthread.Start(); | 650 | viewthread.Start(); |
634 | #endif | 651 | #endif |
635 | 652 | ||
636 | _watermap = new float[258 * 258]; | 653 | // _watermap = new float[258 * 258]; |
637 | 654 | ||
638 | // Zero out the prim spaces array (we split our space into smaller spaces so | 655 | // Zero out the prim spaces array (we split our space into smaller spaces so |
639 | // we can hit test less. | 656 | // we can hit test less. |
@@ -780,7 +797,31 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
780 | 797 | ||
781 | contacts = new d.ContactGeom[contactsPerCollision]; | 798 | contacts = new d.ContactGeom[contactsPerCollision]; |
782 | 799 | ||
783 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; | 800 | spacesPerMeterX = 1.0f / metersInSpace; |
801 | spacesPerMeterY = 1.0f / metersInSpace; | ||
802 | |||
803 | spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeterX); | ||
804 | spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeterY); | ||
805 | |||
806 | // ubit: limit number of spaces | ||
807 | if (spaceGridMaxX > 24) | ||
808 | { | ||
809 | spaceGridMaxX = 24; | ||
810 | spacesPerMeterX = spaceGridMaxX / WorldExtents.X; | ||
811 | } | ||
812 | if (spaceGridMaxY > 24) | ||
813 | { | ||
814 | spaceGridMaxY = 24; | ||
815 | spacesPerMeterY = spaceGridMaxY / WorldExtents.Y ; | ||
816 | } | ||
817 | |||
818 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; | ||
819 | |||
820 | // make this index limits | ||
821 | spaceGridMaxX--; | ||
822 | spaceGridMaxY--; | ||
823 | |||
824 | |||
784 | 825 | ||
785 | // Centeral contact friction and bounce | 826 | // Centeral contact friction and bounce |
786 | // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why | 827 | // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why |
@@ -1964,6 +2005,8 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
1964 | 2005 | ||
1965 | public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) | 2006 | public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) |
1966 | { | 2007 | { |
2008 | if (!m_suportCombine) | ||
2009 | return; | ||
1967 | m_worldOffset = offset; | 2010 | m_worldOffset = offset; |
1968 | WorldExtents = new Vector2(extents.X, extents.Y); | 2011 | WorldExtents = new Vector2(extents.X, extents.Y); |
1969 | m_parentScene = pScene; | 2012 | m_parentScene = pScene; |
@@ -1972,12 +2015,17 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
1972 | // Recovered for use by fly height. Kitto Flora | 2015 | // Recovered for use by fly height. Kitto Flora |
1973 | internal float GetTerrainHeightAtXY(float x, float y) | 2016 | internal float GetTerrainHeightAtXY(float x, float y) |
1974 | { | 2017 | { |
1975 | int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
1976 | int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
1977 | |||
1978 | IntPtr heightFieldGeom = IntPtr.Zero; | 2018 | IntPtr heightFieldGeom = IntPtr.Zero; |
2019 | int offsetX = 0; | ||
2020 | int offsetY = 0; | ||
2021 | |||
2022 | if (m_suportCombine) | ||
2023 | { | ||
2024 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2025 | offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2026 | } | ||
1979 | 2027 | ||
1980 | if (RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom)) | 2028 | if(RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom)) |
1981 | { | 2029 | { |
1982 | if (heightFieldGeom != IntPtr.Zero) | 2030 | if (heightFieldGeom != IntPtr.Zero) |
1983 | { | 2031 | { |
@@ -1991,8 +2039,8 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
1991 | (int)x < 0.001f || (int)y < 0.001f) | 2039 | (int)x < 0.001f || (int)y < 0.001f) |
1992 | return 0; | 2040 | return 0; |
1993 | 2041 | ||
1994 | x = x - offsetX; | 2042 | x = x - offsetX + 1f; |
1995 | y = y - offsetY; | 2043 | y = y - offsetY + 1f; |
1996 | 2044 | ||
1997 | index = (int)((int)x * ((int)Constants.RegionSize + 2) + (int)y); | 2045 | index = (int)((int)x * ((int)Constants.RegionSize + 2) + (int)y); |
1998 | 2046 | ||
@@ -2828,16 +2876,16 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
2828 | { | 2876 | { |
2829 | int[] returnint = new int[2]; | 2877 | int[] returnint = new int[2]; |
2830 | 2878 | ||
2831 | returnint[0] = (int) (pos.X/metersInSpace); | 2879 | returnint[0] = (int) (pos.X * spacesPerMeterX); |
2832 | 2880 | ||
2833 | if (returnint[0] > ((int) (259f/metersInSpace))) | 2881 | if (returnint[0] > spaceGridMaxX) |
2834 | returnint[0] = ((int) (259f/metersInSpace)); | 2882 | returnint[0] = spaceGridMaxX; |
2835 | if (returnint[0] < 0) | 2883 | if (returnint[0] < 0) |
2836 | returnint[0] = 0; | 2884 | returnint[0] = 0; |
2837 | 2885 | ||
2838 | returnint[1] = (int) (pos.Y/metersInSpace); | 2886 | returnint[1] = (int)(pos.Y * spacesPerMeterY); |
2839 | if (returnint[1] > ((int) (259f/metersInSpace))) | 2887 | if (returnint[1] > spaceGridMaxY) |
2840 | returnint[1] = ((int) (259f/metersInSpace)); | 2888 | returnint[1] = spaceGridMaxY; |
2841 | if (returnint[1] < 0) | 2889 | if (returnint[1] < 0) |
2842 | returnint[1] = 0; | 2890 | returnint[1] = 0; |
2843 | 2891 | ||
@@ -3591,6 +3639,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3591 | get { return false; } | 3639 | get { return false; } |
3592 | } | 3640 | } |
3593 | 3641 | ||
3642 | /* godd try.. but not a fix | ||
3594 | #region ODE Specific Terrain Fixes | 3643 | #region ODE Specific Terrain Fixes |
3595 | private float[] ResizeTerrain512NearestNeighbour(float[] heightMap) | 3644 | private float[] ResizeTerrain512NearestNeighbour(float[] heightMap) |
3596 | { | 3645 | { |
@@ -3857,7 +3906,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3857 | } | 3906 | } |
3858 | 3907 | ||
3859 | #endregion | 3908 | #endregion |
3860 | 3909 | */ | |
3861 | public override void SetTerrain(float[] heightMap) | 3910 | public override void SetTerrain(float[] heightMap) |
3862 | { | 3911 | { |
3863 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) | 3912 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) |
@@ -3878,71 +3927,65 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3878 | int startTime = Util.EnvironmentTickCount(); | 3927 | int startTime = Util.EnvironmentTickCount(); |
3879 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", PhysicsSceneName, pOffset); | 3928 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", PhysicsSceneName, pOffset); |
3880 | 3929 | ||
3881 | // this._heightmap[i] = (double)heightMap[i]; | 3930 | |
3882 | // dbm (danx0r) -- creating a buffer zone of one extra sample all around | ||
3883 | //_origheightmap = heightMap; | ||
3884 | |||
3885 | float[] _heightmap; | 3931 | float[] _heightmap; |
3886 | 3932 | ||
3887 | // zero out a heightmap array float array (single dimension [flattened])) | 3933 | // ok im lasy this are just a aliases |
3888 | //if ((int)Constants.RegionSize == 256) | 3934 | uint regionsizeX = m_regionWidth; |
3889 | // _heightmap = new float[514 * 514]; | 3935 | uint regionsizeY = m_regionHeight; |
3890 | //else | ||
3891 | |||
3892 | _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))]; | ||
3893 | 3936 | ||
3894 | uint heightmapWidth = Constants.RegionSize + 1; | 3937 | // map is rotated |
3895 | uint heightmapHeight = Constants.RegionSize + 1; | 3938 | uint heightmapWidth = regionsizeY + 2; |
3939 | uint heightmapHeight = regionsizeX + 2; | ||
3896 | 3940 | ||
3897 | uint heightmapWidthSamples; | 3941 | uint heightmapWidthSamples = heightmapWidth + 1; |
3942 | uint heightmapHeightSamples = heightmapHeight + 1; | ||
3898 | 3943 | ||
3899 | uint heightmapHeightSamples; | 3944 | _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples]; |
3900 | 3945 | ||
3901 | //if (((int)Constants.RegionSize) == 256) | ||
3902 | //{ | ||
3903 | // heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2; | ||
3904 | // heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2; | ||
3905 | // heightmapWidth++; | ||
3906 | // heightmapHeight++; | ||
3907 | //} | ||
3908 | //else | ||
3909 | //{ | ||
3910 | |||
3911 | heightmapWidthSamples = (uint)Constants.RegionSize + 1; | ||
3912 | heightmapHeightSamples = (uint)Constants.RegionSize + 1; | ||
3913 | //} | ||
3914 | 3946 | ||
3915 | const float scale = 1.0f; | 3947 | const float scale = 1.0f; |
3916 | const float offset = 0.0f; | 3948 | const float offset = 0.0f; |
3917 | const float thickness = 0.2f; | 3949 | const float thickness = 10f; |
3918 | const int wrap = 0; | 3950 | const int wrap = 0; |
3919 | 3951 | ||
3920 | int regionsize = (int) Constants.RegionSize + 2; | ||
3921 | //Double resolution | ||
3922 | //if (((int)Constants.RegionSize) == 256) | ||
3923 | // heightMap = ResizeTerrain512Interpolation(heightMap); | ||
3924 | 3952 | ||
3953 | float hfmin = float.MaxValue; | ||
3954 | float hfmax = float.MinValue; | ||
3955 | float val; | ||
3956 | uint xx; | ||
3957 | uint yy; | ||
3925 | 3958 | ||
3926 | // if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256) | 3959 | uint maxXX = regionsizeX - 1; |
3927 | // regionsize = 512; | 3960 | uint maxYY = regionsizeY - 1; |
3928 | 3961 | ||
3929 | float hfmin = 2000; | 3962 | // flipping map adding one margin all around so things don't fall in edges |
3930 | float hfmax = -2000; | 3963 | |
3931 | 3964 | uint xt = 0; | |
3932 | for (int x = 0; x < heightmapWidthSamples; x++) | 3965 | xx = 0; |
3966 | |||
3967 | |||
3968 | for (uint x = 0; x < heightmapWidthSamples; x++) | ||
3933 | { | 3969 | { |
3934 | for (int y = 0; y < heightmapHeightSamples; y++) | 3970 | if (x > 1 && xx < maxXX) |
3971 | xx++; | ||
3972 | yy = 0; | ||
3973 | for (uint y = 0; y < heightmapHeightSamples; y++) | ||
3935 | { | 3974 | { |
3936 | int xx = Util.Clip(x - 1, 0, regionsize - 1); | 3975 | if (y > 1 && y < maxYY) |
3937 | int yy = Util.Clip(y - 1, 0, regionsize - 1); | 3976 | yy += regionsizeX; |
3938 | 3977 | ||
3939 | 3978 | val = heightMap[yy + xx]; | |
3940 | float val= heightMap[yy * (int)Constants.RegionSize + xx]; | 3979 | if (val < 0.0f) |
3941 | _heightmap[x * ((int)Constants.RegionSize + 2) + y] = val; | 3980 | val = 0.0f; |
3942 | 3981 | _heightmap[xt + y] = val; | |
3943 | hfmin = (val < hfmin) ? val : hfmin; | 3982 | |
3944 | hfmax = (val > hfmax) ? val : hfmax; | 3983 | if (hfmin > val) |
3984 | hfmin = val; | ||
3985 | if (hfmax < val) | ||
3986 | hfmax = val; | ||
3945 | } | 3987 | } |
3988 | xt += heightmapHeightSamples; | ||
3946 | } | 3989 | } |
3947 | 3990 | ||
3948 | lock (OdeLock) | 3991 | lock (OdeLock) |
@@ -3963,9 +4006,10 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3963 | 4006 | ||
3964 | } | 4007 | } |
3965 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 4008 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
3966 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth + 1, heightmapHeight + 1, | 4009 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight, |
3967 | (int)heightmapWidthSamples + 1, (int)heightmapHeightSamples + 1, scale, | 4010 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, |
3968 | offset, thickness, wrap); | 4011 | offset, thickness, wrap); |
4012 | |||
3969 | d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); | 4013 | d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); |
3970 | GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); | 4014 | GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); |
3971 | if (GroundGeom != IntPtr.Zero) | 4015 | if (GroundGeom != IntPtr.Zero) |
@@ -3980,17 +4024,15 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
3980 | 4024 | ||
3981 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); | 4025 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); |
3982 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); | 4026 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); |
3983 | //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1)); | ||
3984 | 4027 | ||
3985 | q1 = q1 * q2; | 4028 | q1 = q1 * q2; |
3986 | //q1 = q1 * q3; | ||
3987 | Vector3 v3; | 4029 | Vector3 v3; |
3988 | float angle; | 4030 | float angle; |
3989 | q1.GetAxisAngle(out v3, out angle); | 4031 | q1.GetAxisAngle(out v3, out angle); |
3990 | 4032 | ||
3991 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 4033 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
3992 | d.GeomSetRotation(GroundGeom, ref R); | 4034 | d.GeomSetRotation(GroundGeom, ref R); |
3993 | d.GeomSetPosition(GroundGeom, (pOffset.X + ((int)Constants.RegionSize * 0.5f)), (pOffset.Y + ((int)Constants.RegionSize * 0.5f)), 0); | 4035 | d.GeomSetPosition(GroundGeom, pOffset.X + regionsizeX * 0.5f, pOffset.Y + regionsizeY * 0.5f, 0); |
3994 | IntPtr testGround = IntPtr.Zero; | 4036 | IntPtr testGround = IntPtr.Zero; |
3995 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) | 4037 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) |
3996 | { | 4038 | { |
@@ -4015,89 +4057,31 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
4015 | 4057 | ||
4016 | public override bool SupportsCombining() | 4058 | public override bool SupportsCombining() |
4017 | { | 4059 | { |
4018 | return true; | 4060 | return m_suportCombine; |
4019 | } | 4061 | } |
4020 | 4062 | ||
4021 | // public override void UnCombine(PhysicsScene pScene) | ||
4022 | // { | ||
4023 | // IntPtr localGround = IntPtr.Zero; | ||
4024 | //// float[] localHeightfield; | ||
4025 | // bool proceed = false; | ||
4026 | // List<IntPtr> geomDestroyList = new List<IntPtr>(); | ||
4027 | // | ||
4028 | // lock (OdeLock) | ||
4029 | // { | ||
4030 | // if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround)) | ||
4031 | // { | ||
4032 | // foreach (IntPtr geom in TerrainHeightFieldHeights.Keys) | ||
4033 | // { | ||
4034 | // if (geom == localGround) | ||
4035 | // { | ||
4036 | //// localHeightfield = TerrainHeightFieldHeights[geom]; | ||
4037 | // proceed = true; | ||
4038 | // } | ||
4039 | // else | ||
4040 | // { | ||
4041 | // geomDestroyList.Add(geom); | ||
4042 | // } | ||
4043 | // } | ||
4044 | // | ||
4045 | // if (proceed) | ||
4046 | // { | ||
4047 | // m_worldOffset = Vector3.Zero; | ||
4048 | // WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); | ||
4049 | // m_parentScene = null; | ||
4050 | // | ||
4051 | // foreach (IntPtr g in geomDestroyList) | ||
4052 | // { | ||
4053 | // // removingHeightField needs to be done or the garbage collector will | ||
4054 | // // collect the terrain data before we tell ODE to destroy it causing | ||
4055 | // // memory corruption | ||
4056 | // if (TerrainHeightFieldHeights.ContainsKey(g)) | ||
4057 | // { | ||
4058 | //// float[] removingHeightField = TerrainHeightFieldHeights[g]; | ||
4059 | // TerrainHeightFieldHeights.Remove(g); | ||
4060 | // | ||
4061 | // if (RegionTerrain.ContainsKey(g)) | ||
4062 | // { | ||
4063 | // RegionTerrain.Remove(g); | ||
4064 | // } | ||
4065 | // | ||
4066 | // d.GeomDestroy(g); | ||
4067 | // //removingHeightField = new float[0]; | ||
4068 | // } | ||
4069 | // } | ||
4070 | // | ||
4071 | // } | ||
4072 | // else | ||
4073 | // { | ||
4074 | // m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data."); | ||
4075 | // } | ||
4076 | // } | ||
4077 | // } | ||
4078 | // } | ||
4079 | |||
4080 | public override void SetWaterLevel(float baseheight) | 4063 | public override void SetWaterLevel(float baseheight) |
4081 | { | 4064 | { |
4082 | waterlevel = baseheight; | 4065 | waterlevel = baseheight; |
4083 | randomizeWater(waterlevel); | 4066 | // randomizeWater(waterlevel); |
4084 | } | 4067 | } |
4085 | 4068 | ||
4069 | /* | ||
4086 | private void randomizeWater(float baseheight) | 4070 | private void randomizeWater(float baseheight) |
4087 | { | 4071 | { |
4088 | const uint heightmapWidth = m_regionWidth + 2; | 4072 | uint heightmapWidth = m_regionWidth + 2; |
4089 | const uint heightmapHeight = m_regionHeight + 2; | 4073 | uint heightmapHeight = m_regionHeight + 2; |
4090 | const uint heightmapWidthSamples = m_regionWidth + 2; | 4074 | uint heightmapWidthSamples = m_regionWidth + 2; |
4091 | const uint heightmapHeightSamples = m_regionHeight + 2; | 4075 | uint heightmapHeightSamples = m_regionHeight + 2; |
4092 | const float scale = 1.0f; | 4076 | float scale = 1.0f; |
4093 | const float offset = 0.0f; | 4077 | float offset = 0.0f; |
4094 | const float thickness = 2.9f; | 4078 | float thickness = 2.9f; |
4095 | const int wrap = 0; | 4079 | int wrap = 0; |
4096 | 4080 | ||
4097 | for (int i = 0; i < (258 * 258); i++) | 4081 | for (int i = 0; i < (258 * 258); i++) |
4098 | { | 4082 | { |
4099 | _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f); | 4083 | _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f); |
4100 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); | 4084 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); |
4101 | } | 4085 | } |
4102 | 4086 | ||
4103 | lock (OdeLock) | 4087 | lock (OdeLock) |
@@ -4108,8 +4092,8 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
4108 | } | 4092 | } |
4109 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 4093 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
4110 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight, | 4094 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight, |
4111 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, | 4095 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, |
4112 | offset, thickness, wrap); | 4096 | offset, thickness, wrap); |
4113 | d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); | 4097 | d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); |
4114 | WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); | 4098 | WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); |
4115 | if (WaterGeom != IntPtr.Zero) | 4099 | if (WaterGeom != IntPtr.Zero) |
@@ -4137,7 +4121,7 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
4137 | d.GeomSetPosition(WaterGeom, 128, 128, 0); | 4121 | d.GeomSetPosition(WaterGeom, 128, 128, 0); |
4138 | } | 4122 | } |
4139 | } | 4123 | } |
4140 | 4124 | */ | |
4141 | public override void Dispose() | 4125 | public override void Dispose() |
4142 | { | 4126 | { |
4143 | _worldInitialized = false; | 4127 | _worldInitialized = false; |