aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
diff options
context:
space:
mode:
authorRobert Adams2012-07-31 09:23:05 -0700
committerRobert Adams2012-07-31 09:23:05 -0700
commit50dbb9ffe480b08f13f7bebb8259193dc00f88dd (patch)
tree20a35e254d4ec9180b75af2e0a02e61dec53e028 /OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-50dbb9ffe480b08f13f7bebb8259193dc00f88dd.zip
opensim-SC-50dbb9ffe480b08f13f7bebb8259193dc00f88dd.tar.gz
opensim-SC-50dbb9ffe480b08f13f7bebb8259193dc00f88dd.tar.bz2
opensim-SC-50dbb9ffe480b08f13f7bebb8259193dc00f88dd.tar.xz
BulletSim: add parameters and API calls for setting ERP and CFM.
Set ERP and CFM in linkset constraints. Reorder rebuilding of object bodies so they are not rebuilt everytime something is linked and unlinked.
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs56
1 files changed, 50 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 3bc2100..6f8430c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -117,10 +117,50 @@ public class BSLinkset
117 } 117 }
118 118
119 // An existing linkset had one of its members rebuilt or something. 119 // An existing linkset had one of its members rebuilt or something.
120 // Undo all the physical linking and rebuild the physical linkset. 120 // Go through the linkset and rebuild the pointers to the bodies of the linkset members.
121 public bool RefreshLinkset(BSPrim requestor) 121 public BSLinkset RefreshLinkset(BSPrim requestor)
122 { 122 {
123 return true; 123 BSLinkset ret = requestor.Linkset;
124
125 lock (m_linksetActivityLock)
126 {
127 System.IntPtr aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, m_linksetRoot.LocalID);
128 if (aPtr == System.IntPtr.Zero)
129 {
130 // That's odd. We can't find the root of the linkset.
131 // The linkset is somehow dead. The requestor is now a member of a linkset of one.
132 DetailLog("{0},RefreshLinkset.RemoveRoot,child={1}", m_linksetRoot.LocalID, m_linksetRoot.LocalID);
133 ret = RemoveMeFromLinkset(m_linksetRoot);
134 }
135 else
136 {
137 // Reconstruct the pointer to the body of the linkset root.
138 DetailLog("{0},RefreshLinkset.RebuildRoot,rootID={1},ptr={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, aPtr);
139 m_linksetRoot.Body = new BulletBody(m_linksetRoot.LocalID, aPtr);
140
141 List<BSPrim> toRemove = new List<BSPrim>();
142 foreach (BSPrim bsp in m_children)
143 {
144 aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, bsp.LocalID);
145 if (aPtr == System.IntPtr.Zero)
146 {
147 toRemove.Add(bsp);
148 }
149 else
150 {
151 // Reconstruct the pointer to the body of the linkset root.
152 DetailLog("{0},RefreshLinkset.RebuildChild,rootID={1},ptr={2}", bsp.LocalID, m_linksetRoot.LocalID, aPtr);
153 bsp.Body = new BulletBody(bsp.LocalID, aPtr);
154 }
155 }
156 foreach (BSPrim bsp in toRemove)
157 {
158 RemoveChildFromLinkset(bsp);
159 }
160 }
161 }
162
163 return ret;
124 } 164 }
125 165
126 166
@@ -256,10 +296,13 @@ public class BSLinkset
256 DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); 296 DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID);
257 BSConstraint constrain = m_scene.Constraints.CreateConstraint( 297 BSConstraint constrain = m_scene.Constraints.CreateConstraint(
258 m_scene.World, m_linksetRoot.Body, childPrim.Body, 298 m_scene.World, m_linksetRoot.Body, childPrim.Body,
259 childRelativePosition, 299 // childRelativePosition,
260 childRelativeRotation, 300 // childRelativeRotation,
301 OMV.Vector3.Zero,
302 OMV.Quaternion.Identity,
261 OMV.Vector3.Zero, 303 OMV.Vector3.Zero,
262 OMV.Quaternion.Identity); 304 OMV.Quaternion.Identity
305 );
263 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 306 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
264 constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 307 constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
265 308
@@ -268,6 +311,7 @@ public class BSLinkset
268 constrain.TranslationalLimitMotor(m_scene.BoolNumeric(m_scene.Params.linkConstraintEnableTransMotor), 311 constrain.TranslationalLimitMotor(m_scene.BoolNumeric(m_scene.Params.linkConstraintEnableTransMotor),
269 m_scene.Params.linkConstraintTransMotorMaxVel, 312 m_scene.Params.linkConstraintTransMotorMaxVel,
270 m_scene.Params.linkConstraintTransMotorMaxForce); 313 m_scene.Params.linkConstraintTransMotorMaxForce);
314 constrain.SetCFMAndERP(m_scene.Params.linkConstraintCFM, m_scene.Params.linkConstraintERP);
271 315
272 } 316 }
273 317