BulletSim: pass both root and child BSPhysObjects to Extension function. Update routines to use the new parameters list from above change.

varregion
Robert Adams 2013-08-20 13:09:40 -07:00
parent 995314f91f
commit d09c35f506
3 changed files with 41 additions and 35 deletions

View File

@ -220,7 +220,8 @@ public class ExtendedPhysics : INonSharedRegionModule
containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition);
containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation);
ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType));
object[] parms2 = { rootPhysActor, null, linksetType };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2));
Thread.Sleep(150); // longer than one heartbeat tick
containingGroup.ScriptSetPhysicsStatus(true);
@ -229,7 +230,8 @@ public class ExtendedPhysics : INonSharedRegionModule
{
// Non-physical linksets don't have a physical instantiation so there is no state to
// worry about being updated.
ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType));
object[] parms2 = { rootPhysActor, null, linksetType };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2));
}
}
else
@ -271,7 +273,8 @@ public class ExtendedPhysics : INonSharedRegionModule
PhysicsActor rootPhysActor = rootPart.PhysActor;
if (rootPhysActor != null)
{
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType));
object[] parms2 = { rootPhysActor, null };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType, parms2));
}
else
{
@ -315,8 +318,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{
object[] parms = { childPhysActor, typeCode };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms));
object[] parms2 = { rootPhysActor, childPhysActor, typeCode };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2));
}
return ret;
@ -334,8 +337,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{
object[] parms = { childPhysActor };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms));
object[] parms2 = { rootPhysActor, childPhysActor };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms2));
}
return ret;
@ -354,8 +357,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{
object[] parms = { childPhysActor , PHYS_LINK_TYPE_FIXED };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms));
object[] parms2 = { rootPhysActor, childPhysActor , PHYS_LINK_TYPE_FIXED };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2));
}
return ret;
@ -412,7 +415,7 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{
object[] parms2 = AddToBeginningOfArray(childPhysActor, parms);
object[] parms2 = AddToBeginningOfArray(rootPhysActor, childPhysActor, parms);
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, parms2));
}
@ -518,11 +521,12 @@ public class ExtendedPhysics : INonSharedRegionModule
}
// Return an array of objects with the passed object as the first object of a new array
private object[] AddToBeginningOfArray(object firstOne, object[] prevArray)
private object[] AddToBeginningOfArray(object firstOne, object secondOne, object[] prevArray)
{
object[] newArray = new object[1 + prevArray.Length];
object[] newArray = new object[2 + prevArray.Length];
newArray[0] = firstOne;
prevArray.CopyTo(newArray, 1);
newArray[1] = secondOne;
prevArray.CopyTo(newArray, 2);
return newArray;
}

View File

@ -385,7 +385,7 @@ public sealed class BSLinksetConstraints : BSLinkset
linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot,
true /*useLinearReferenceFrameA*/,
true /*disableCollisionsBetweenLinkedBodies*/);
DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}",
DetailLog("{0},BSLinksetConstraint.BuildConstraint,spring,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6}",
rootPrim.LocalID,
rootPrim.LocalID, rootPrim.PhysBody.AddrString,
linkInfo.member.LocalID, linkInfo.member.PhysBody.AddrString,
@ -492,12 +492,12 @@ public sealed class BSLinksetConstraints : BSLinkset
object ret = null;
switch (pFunct)
{
// pParams = [ BSPhysObject child, integer linkType ]
// pParams = [ BSPhysObject root, BSPhysObject child, integer linkType ]
case ExtendedPhysics.PhysFunctChangeLinkType:
if (pParams.Length > 1)
if (pParams.Length > 2)
{
int requestedType = (int)pParams[1];
DetailLog("{0},BSLinksetConstraint.SetLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType);
int requestedType = (int)pParams[2];
DetailLog("{0},BSLinksetConstraint.ChangeLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType);
if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE
|| requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE
|| requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE
@ -505,9 +505,11 @@ public sealed class BSLinksetConstraints : BSLinkset
|| requestedType == (int)ConstraintType.CONETWIST_CONSTRAINT_TYPE
|| requestedType == (int)ConstraintType.SLIDER_CONSTRAINT_TYPE)
{
BSPrimLinkable child = pParams[0] as BSPrimLinkable;
BSPrimLinkable child = pParams[1] as BSPrimLinkable;
if (child != null)
{
DetailLog("{0},BSLinksetConstraint.ChangeLinkType,rootID={1},childID={2},type={3}",
LinksetRoot.LocalID, LinksetRoot.LocalID, child.LocalID, requestedType);
m_physicsScene.TaintedObject(child.LocalID, "BSLinksetConstraint.PhysFunctChangeLinkType", delegate()
{
// Pick up all the constraints currently created.
@ -523,17 +525,17 @@ public sealed class BSLinksetConstraints : BSLinkset
linkInfoC.ResetLink();
linkInfoC.constraintType = (ConstraintType)requestedType;
ret = (object)true;
DetailLog("{0},BSLinksetConstraint.SetLinkType,link={1},type={2}",
DetailLog("{0},BSLinksetConstraint.ChangeLinkType,link={1},type={2}",
linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType);
}
else
{
DetailLog("{0},BSLinksetConstraint.SetLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID);
DetailLog("{0},BSLinksetConstraint.ChangeLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID);
}
}
else
{
DetailLog("{0},BSLinksetConstraint.SetLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID);
DetailLog("{0},BSLinksetConstraint.ChangeLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID);
}
// Cause the whole linkset to be rebuilt in post-taint time.
Refresh(child);
@ -551,11 +553,11 @@ public sealed class BSLinksetConstraints : BSLinkset
}
}
break;
// pParams = []
// pParams = [ BSPhysObject root, BSPhysObject child ]
case ExtendedPhysics.PhysFunctGetLinkType:
if (pParams.Length > 0)
{
BSPrimLinkable child = pParams[0] as BSPrimLinkable;
BSPrimLinkable child = pParams[1] as BSPrimLinkable;
if (child != null)
{
BSLinkInfo linkInfo = null;
@ -573,14 +575,14 @@ public sealed class BSLinksetConstraints : BSLinkset
}
}
break;
// pParams = [ BSPhysObject child, int op, object opParams, int op, object opParams, ... ]
// pParams = [ BSPhysObject root, BSPhysObject child, int op, object opParams, int op, object opParams, ... ]
case ExtendedPhysics.PhysFunctChangeLinkParams:
// There should be two parameters: the childActor and a list of parameters to set
try
{
if (pParams.Length > 1)
if (pParams.Length > 2)
{
BSPrimLinkable child = pParams[0] as BSPrimLinkable;
BSPrimLinkable child = pParams[1] as BSPrimLinkable;
BSLinkInfo baseLinkInfo = null;
if (TryGetLinkInfo(child, out baseLinkInfo))
{
@ -592,7 +594,7 @@ public sealed class BSLinksetConstraints : BSLinkset
OMV.Vector3 valueVector;
OMV.Quaternion valueQuaternion;
int opIndex = 1;
int opIndex = 2;
while (opIndex < pParams.Length)
{
int thisOp = (int)pParams[opIndex];

View File

@ -288,7 +288,7 @@ public class BSPrimLinkable : BSPrimDisplaced
switch (pFunct)
{
// physGetLinksetType();
// pParams = []
// pParams = [ BSPhysObject root, null ]
case ExtendedPhysics.PhysFunctGetLinksetType:
{
ret = (object)LinksetType;
@ -296,12 +296,12 @@ public class BSPrimLinkable : BSPrimDisplaced
break;
}
// physSetLinksetType(type);
// pParams = [ BSPhysObject child, integer type ]
// pParams = [ BSPhysObject root, null, integer type ]
case ExtendedPhysics.PhysFunctSetLinksetType:
{
if (pParams.Length > 0)
if (pParams.Length > 2)
{
BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[0];
BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[2];
if (Linkset.IsRoot(this))
{
PhysScene.TaintedObject(LocalID, "BSPrim.PhysFunctSetLinksetType", delegate()
@ -317,21 +317,21 @@ public class BSPrimLinkable : BSPrimDisplaced
break;
}
// physChangeLinkType(linknum, typeCode);
// pParams = [ BSPhysObject child, integer linkType ]
// pParams = [ BSPhysObject root, BSPhysObject child, integer linkType ]
case ExtendedPhysics.PhysFunctChangeLinkType:
{
ret = Linkset.Extension(pFunct, pParams);
break;
}
// physGetLinkType(linknum);
// pParams = [ BSPhysObject child ]
// pParams = [ BSPhysObject root, BSPhysObject child ]
case ExtendedPhysics.PhysFunctGetLinkType:
{
ret = Linkset.Extension(pFunct, pParams);
break;
}
// physChangeLinkParams(linknum, [code, value, code, value, ...]);
// pParams = [ BSPhysObject child, object[] [ string op, object opParam, string op, object opParam, ... ] ]
// pParams = [ BSPhysObject root, BSPhysObject child, object[] [ string op, object opParam, string op, object opParam, ... ] ]
case ExtendedPhysics.PhysFunctChangeLinkParams:
{
ret = Linkset.Extension(pFunct, pParams);