aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs123
1 files changed, 79 insertions, 44 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 6e4c373..ccb4c23 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -224,6 +224,7 @@ namespace OpenSim.Region.Physics.OdePlugin
224 private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); 224 private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
225 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); 225 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
226 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 226 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
227 private readonly HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
227 228
228 public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); 229 public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>();
229 230
@@ -1013,15 +1014,24 @@ namespace OpenSim.Region.Physics.OdePlugin
1013 1014
1014 } 1015 }
1015 1016
1016 // collide active prims with static enviroment
1017 lock (_activeprims) 1017 lock (_activeprims)
1018 { 1018 {
1019 foreach (OdePrim aprim in _activeprims)
1020 {
1021 aprim.CollisionScore = 0;
1022 aprim.IsColliding = false;
1023 }
1024 }
1025
1026 // collide active prims with static enviroment
1027 lock (_activegroups)
1028 {
1019 try 1029 try
1020 { 1030 {
1021 foreach (OdePrim prm in _activeprims) 1031 foreach (OdePrim prm in _activegroups)
1022 { 1032 {
1023 if (d.BodyIsEnabled(prm.Body)) 1033 if (d.BodyIsEnabled(prm.Body) && !prm.m_outbounds)
1024 d.SpaceCollide2(StaticSpace, prm.prim_geom, IntPtr.Zero, nearCallback); 1034 d.SpaceCollide2(StaticSpace, prm.collide_geom, IntPtr.Zero, nearCallback);
1025 } 1035 }
1026 } 1036 }
1027 catch (AccessViolationException) 1037 catch (AccessViolationException)
@@ -1029,7 +1039,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1029 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); 1039 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space");
1030 } 1040 }
1031 } 1041 }
1032
1033 // finally colide active things amoung them 1042 // finally colide active things amoung them
1034 try 1043 try
1035 { 1044 {
@@ -1039,7 +1048,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1039 { 1048 {
1040 m_log.Warn("[PHYSICS]: Unable to collide in Active space"); 1049 m_log.Warn("[PHYSICS]: Unable to collide in Active space");
1041 } 1050 }
1042
1043// _perloopContact.Clear(); 1051// _perloopContact.Clear();
1044 } 1052 }
1045 1053
@@ -1148,13 +1156,20 @@ namespace OpenSim.Region.Physics.OdePlugin
1148 1156
1149 public void addActivePrim(OdePrim activatePrim) 1157 public void addActivePrim(OdePrim activatePrim)
1150 { 1158 {
1151 // adds active prim.. (ones that should be iterated over in collisions_optimized 1159 // adds active prim..
1152 lock (_activeprims) 1160 lock (_activeprims)
1153 { 1161 {
1154 if (!_activeprims.Contains(activatePrim)) 1162 if (!_activeprims.Contains(activatePrim))
1155 _activeprims.Add(activatePrim); 1163 _activeprims.Add(activatePrim);
1156 //else 1164 }
1157 // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent"); 1165 }
1166
1167 public void addActiveGroups(OdePrim activatePrim)
1168 {
1169 lock (_activegroups)
1170 {
1171 if (!_activegroups.Contains(activatePrim))
1172 _activegroups.Add(activatePrim);
1158 } 1173 }
1159 } 1174 }
1160 1175
@@ -1186,6 +1201,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1186 _activeprims.Remove(deactivatePrim); 1201 _activeprims.Remove(deactivatePrim);
1187 } 1202 }
1188 } 1203 }
1204 public void remActiveGroup(OdePrim deactivatePrim)
1205 {
1206 lock (_activegroups)
1207 {
1208 _activegroups.Remove(deactivatePrim);
1209 }
1210 }
1189 1211
1190 public override void RemovePrim(PhysicsActor prim) 1212 public override void RemovePrim(PhysicsActor prim)
1191 { 1213 {
@@ -1258,6 +1280,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1258 { 1280 {
1259 waitForSpaceUnlock(currentspace); 1281 waitForSpaceUnlock(currentspace);
1260 d.SpaceRemove(currentspace, geom); 1282 d.SpaceRemove(currentspace, geom);
1283
1284 if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0)
1285 {
1286 d.SpaceDestroy(currentspace);
1287 }
1261 } 1288 }
1262 else 1289 else
1263 { 1290 {
@@ -1274,6 +1301,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1274 { 1301 {
1275 waitForSpaceUnlock(currentspace); 1302 waitForSpaceUnlock(currentspace);
1276 d.SpaceRemove(currentspace, geom); 1303 d.SpaceRemove(currentspace, geom);
1304
1305 if (d.SpaceGetSublevel(currentspace) > 1 && d.SpaceGetNumGeoms(currentspace) == 0)
1306 {
1307 d.SpaceDestroy(currentspace);
1308 }
1309
1277 } 1310 }
1278 } 1311 }
1279 } 1312 }
@@ -1577,42 +1610,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1577 1610
1578 statchanges += Util.EnvironmentTickCountSubtract(statstart); 1611 statchanges += Util.EnvironmentTickCountSubtract(statstart);
1579 1612
1580 // Move characters
1581 lock (_characters)
1582 {
1583 List<OdeCharacter> defects = new List<OdeCharacter>();
1584 foreach (OdeCharacter actor in _characters)
1585 {
1586 if (actor != null)
1587 actor.Move(ODE_STEPSIZE, defects);
1588 }
1589 if (defects.Count != 0)
1590 {
1591 foreach (OdeCharacter defect in defects)
1592 {
1593 RemoveCharacter(defect);
1594 }
1595 }
1596 }
1597 statchmove += Util.EnvironmentTickCountSubtract(statstart);
1598
1599 // Move other active objects
1600 lock (_activeprims)
1601 {
1602 foreach (OdePrim aprim in _activeprims)
1603 {
1604 aprim.CollisionScore = 0;
1605 aprim.IsColliding = false;
1606 aprim.Move();
1607 }
1608 }
1609
1610 statactmove += Util.EnvironmentTickCountSubtract(statstart); 1613 statactmove += Util.EnvironmentTickCountSubtract(statstart);
1611 //if ((framecount % m_randomizeWater) == 0) 1614 //if ((framecount % m_randomizeWater) == 0)
1612 // randomizeWater(waterlevel); 1615 // randomizeWater(waterlevel);
1613 1616
1614 m_rayCastManager.ProcessQueuedRequests(); 1617 m_rayCastManager.ProcessQueuedRequests();
1615 1618
1619
1620
1616 statray += Util.EnvironmentTickCountSubtract(statstart); 1621 statray += Util.EnvironmentTickCountSubtract(statstart);
1617 collision_optimized(); 1622 collision_optimized();
1618 statcol += Util.EnvironmentTickCountSubtract(statstart); 1623 statcol += Util.EnvironmentTickCountSubtract(statstart);
@@ -1642,8 +1647,35 @@ namespace OpenSim.Region.Physics.OdePlugin
1642 1647
1643 d.WorldQuickStep(world, ODE_STEPSIZE); 1648 d.WorldQuickStep(world, ODE_STEPSIZE);
1644 statstep += Util.EnvironmentTickCountSubtract(statstart); 1649 statstep += Util.EnvironmentTickCountSubtract(statstart);
1645 d.JointGroupEmpty(contactgroup); 1650
1646 totjcontact += m_global_contactcount; 1651 // Move characters
1652 lock (_characters)
1653 {
1654 List<OdeCharacter> defects = new List<OdeCharacter>();
1655 foreach (OdeCharacter actor in _characters)
1656 {
1657 if (actor != null)
1658 actor.Move(ODE_STEPSIZE, defects);
1659 }
1660 if (defects.Count != 0)
1661 {
1662 foreach (OdeCharacter defect in defects)
1663 {
1664 RemoveCharacter(defect);
1665 }
1666 }
1667 }
1668 statchmove += Util.EnvironmentTickCountSubtract(statstart);
1669
1670 // Move other active objects
1671 lock (_activegroups)
1672 {
1673 foreach (OdePrim aprim in _activegroups)
1674 {
1675 aprim.Move();
1676 }
1677 }
1678
1647 //ode.dunlock(world); 1679 //ode.dunlock(world);
1648 } 1680 }
1649 catch (Exception e) 1681 catch (Exception e)
@@ -1652,6 +1684,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1652// ode.dunlock(world); 1684// ode.dunlock(world);
1653 } 1685 }
1654 1686
1687 d.JointGroupEmpty(contactgroup);
1688 totjcontact += m_global_contactcount;
1689
1655 step_time -= ODE_STEPSIZE; 1690 step_time -= ODE_STEPSIZE;
1656 nodeframes++; 1691 nodeframes++;
1657 } 1692 }
@@ -1686,10 +1721,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1686 } 1721 }
1687 statmovchar = Util.EnvironmentTickCountSubtract(statstart); 1722 statmovchar = Util.EnvironmentTickCountSubtract(statstart);
1688 1723
1689 lock (_activeprims) 1724 lock (_activegroups)
1690 { 1725 {
1691 { 1726 {
1692 foreach (OdePrim actor in _activeprims) 1727 foreach (OdePrim actor in _activegroups)
1693 { 1728 {
1694 if (actor.IsPhysical) 1729 if (actor.IsPhysical)
1695 { 1730 {
@@ -1966,7 +2001,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1966 2001
1967 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 2002 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
1968 d.GeomSetRotation(GroundGeom, ref R); 2003 d.GeomSetRotation(GroundGeom, ref R);
1969 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f - 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f - 0.5f, 0); 2004 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
1970 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 2005 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
1971// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); 2006// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
1972 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2007 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);