BulletSim: initial implementation of physChangeLinkFixed that resets a linkset's link back to a fixed, non-moving connection.

varregion
Robert Adams 2013-08-07 11:13:53 -07:00
parent c6a6631efc
commit f3cc20050e
3 changed files with 105 additions and 10 deletions

View File

@ -61,6 +61,10 @@ public class ExtendedPhysics : INonSharedRegionModule
// Per prim functions. See BSPrim.
public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType";
public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType";
public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed";
public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge";
public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring";
public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider";
// =============================================================
@ -250,7 +254,6 @@ public class ExtendedPhysics : INonSharedRegionModule
public int physGetLinksetType(UUID hostID, UUID scriptID)
{
int ret = -1;
if (!Enabled) return ret;
// The part that is requesting the change.
@ -287,5 +290,82 @@ public class ExtendedPhysics : INonSharedRegionModule
}
return ret;
}
[ScriptInvocation]
public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum)
{
int ret = -1;
if (!Enabled) return ret;
// The part that is requesting the change.
SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID);
if (requestingPart != null)
{
// The type is is always on the root of a linkset.
SceneObjectGroup containingGroup = requestingPart.ParentGroup;
SceneObjectPart rootPart = containingGroup.RootPart;
if (rootPart != null)
{
Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor;
if (rootPhysActor != null)
{
SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum);
if (linkPart != null)
{
Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor;
if (linkPhysActor != null)
{
ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkFixed, linkNum, linkPhysActor);
}
else
{
m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}",
LogHeader, rootPart.Name, hostID, linkNum);
}
}
else
{
m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}",
LogHeader, rootPart.Name, hostID, linkNum);
}
}
else
{
m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}",
LogHeader, rootPart.Name, hostID);
}
}
else
{
m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}",
LogHeader, requestingPart.Name, hostID);
}
}
else
{
m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID);
}
return ret;
}
[ScriptInvocation]
public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum)
{
return 0;
}
[ScriptInvocation]
public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum)
{
return 0;
}
[ScriptInvocation]
public int physChangeLinkSlider(UUID hostID, UUID scriptID, int linkNum)
{
return 0;
}
}
}

View File

@ -60,10 +60,7 @@ public class BSPrimLinkable : BSPrimDisplaced
Linkset = BSLinkset.Factory(PhysScene, this);
PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
{
Linkset.Refresh(this);
});
Linkset.Refresh(this);
}
public override void Destroy()
@ -82,7 +79,7 @@ public class BSPrimLinkable : BSPrimDisplaced
Linkset = parent.Linkset.AddMeToLinkset(this);
DetailLog("{0},BSPrimLinkset.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}",
DetailLog("{0},BSPrimLinkable.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}",
LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren);
}
return;
@ -98,7 +95,7 @@ public class BSPrimLinkable : BSPrimDisplaced
Linkset = Linkset.RemoveMeFromLinkset(this, false /* inTaintTime*/);
DetailLog("{0},BSPrimLinkset.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ",
DetailLog("{0},BSPrimLinkable.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ",
LocalID, parentBefore.LocalID, childrenBefore, Linkset.LinksetRoot.LocalID, Linkset.NumberOfChildren);
return;
}
@ -110,7 +107,7 @@ public class BSPrimLinkable : BSPrimDisplaced
set
{
base.Position = value;
PhysScene.TaintedObject("BSPrimLinkset.setPosition", delegate()
PhysScene.TaintedObject("BSPrimLinkable.setPosition", delegate()
{
Linkset.UpdateProperties(UpdatedProperties.Position, this);
});
@ -124,7 +121,7 @@ public class BSPrimLinkable : BSPrimDisplaced
set
{
base.Orientation = value;
PhysScene.TaintedObject("BSPrimLinkset.setOrientation", delegate()
PhysScene.TaintedObject("BSPrimLinkable.setOrientation", delegate()
{
Linkset.UpdateProperties(UpdatedProperties.Orientation, this);
});
@ -242,7 +239,7 @@ public class BSPrimLinkable : BSPrimDisplaced
bool ret = false;
if (LinksetType != newType)
{
DetailLog("{0},BSPrimLinkset.ConvertLinkset,oldT={1},newT={2}", LocalID, LinksetType, newType);
DetailLog("{0},BSPrimLinkable.ConvertLinkset,oldT={1},newT={2}", LocalID, LinksetType, newType);
// Set the implementation type first so the call to BSLinkset.Factory gets the new type.
this.LinksetType = newType;
@ -288,12 +285,14 @@ public class BSPrimLinkable : BSPrimDisplaced
object ret = null;
switch (pFunct)
{
// physGetLinksetType();
case BSScene.PhysFunctGetLinksetType:
{
ret = (object)LinksetType;
m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret);
break;
}
// physSetLinksetType(type);
case BSScene.PhysFunctSetLinksetType:
{
if (pParams.Length > 0)
@ -313,6 +312,18 @@ public class BSPrimLinkable : BSPrimDisplaced
}
break;
}
// physChangeLinkFixed(linknum);
// Params: int linkNum, PhysActor linkedPrim
case BSScene.PhysFunctChangeLinkFixed:
{
if (pParams.Length > 1)
{
int linkNum = (int)pParams[0];
Manager.PhysicsActor linkActor = (Manager.PhysicsActor)pParams[1];
Linkset.Refresh(this);
}
break;
}
default:
ret = base.Extension(pFunct, pParams);
break;

View File

@ -875,6 +875,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// Per prim functions. See BSPrim.
public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType";
public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType";
public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed";
public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge";
public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring";
public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider";
// =============================================================
public override object Extension(string pFunct, params object[] pParams)