From 08a9a85376770ba4f579b01f17beb0d2b8dce6ae Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 8 Feb 2009 01:05:09 +0000 Subject: * Fixes colliding with the terrain lower then 0 and higher then 256m * The actual AABB of the heightfield on the Z is now determined by the minimum and maximum heightfield value in the terrain array (assuming it's a reasonable number). This might optimize collisions in simulators that have a small difference between minimum and maximum heightfield values. --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 9a1645d..533464e 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -297,6 +297,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Create the world and the first space world = d.WorldCreate(); space = d.HashSpaceCreate(IntPtr.Zero); + contactgroup = d.JointGroupCreate(0); //contactgroup @@ -484,6 +485,8 @@ namespace OpenSim.Region.Physics.OdePlugin d.WorldSetQuickStepNumIterations(world, m_physicsiterations); //d.WorldSetContactMaxCorrectingVel(world, 1000.0f); + + for (int i = 0; i < staticPrimspace.GetLength(0); i++) { for (int j = 0; j < staticPrimspace.GetLength(1); j++) @@ -2900,15 +2903,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_log.Warn("[PHYSICS]: Non finite heightfield element detected. Setting it to 0"); resultarr2[y, x] = 0; } - - if (resultarr2[y, x] <= 0) - { - returnarr[i] = 0.0000001f; - - } - else - returnarr[i] = resultarr2[y, x]; - + returnarr[i] = resultarr2[y, x]; i++; } } @@ -2934,7 +2929,8 @@ namespace OpenSim.Region.Physics.OdePlugin //Double resolution heightMap = ResizeTerrain512Interpolation(heightMap); - + float hfmin = 2000; + float hfmax = -2000; for (int x = 0; x < heightmapWidthSamples; x++) { for (int y = 0; y < heightmapHeightSamples; y++) @@ -2944,6 +2940,8 @@ namespace OpenSim.Region.Physics.OdePlugin float val = heightMap[yy*512 + xx]; _heightmap[x*heightmapHeightSamples + y] = val; + hfmin = (val < hfmin) ? val : hfmin; + hfmax = (val > hfmax) ? val : hfmax; } } @@ -2957,7 +2955,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight, (int) heightmapWidthSamples, (int) heightmapHeightSamples, scale, offset, thickness, wrap); - d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); + d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1 , hfmax + 1 ); LandGeom = d.CreateHeightfield(space, HeightmapData, 1); if (LandGeom != IntPtr.Zero) { @@ -3047,6 +3045,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); d.GeomSetRotation(WaterGeom, ref R); d.GeomSetPosition(WaterGeom, 128, 128, 0); + } } -- cgit v1.1