BulletSim: Extension parameters passed through the classes made to pass just and array of objects rather than a mixture of parameters and array. Makes understanding and parsing what is being passed much easier.

0.7.6-extended
Robert Adams 2013-08-20 08:14:08 -07:00 committed by Justin Clark-Casey (justincc)
parent 1f740926a2
commit 21a046e622
5 changed files with 98 additions and 35 deletions

View File

@ -315,7 +315,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, typeCode));
object[] parms = { childPhysActor, typeCode };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms));
}
return ret;
@ -323,7 +324,7 @@ public class ExtendedPhysics : INonSharedRegionModule
// physGetLinkType(integer linkNum)
[ScriptInvocation]
public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode)
public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum)
{
int ret = -1;
if (!Enabled) return ret;
@ -333,7 +334,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, childPhysActor));
object[] parms = { childPhysActor };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms));
}
return ret;
@ -352,7 +354,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, childPhysActor, PHYS_LINK_TYPE_FIXED));
object[] parms = { childPhysActor , PHYS_LINK_TYPE_FIXED };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms));
}
return ret;
@ -409,7 +412,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, childPhysActor, parms));
object[] parms2 = AddToBeginningOfArray(childPhysActor, parms);
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkParams, parms2));
}
return ret;
@ -513,6 +517,15 @@ public class ExtendedPhysics : INonSharedRegionModule
return ret;
}
// Return an array of objects with the passed object as the first object of a new array
private object[] AddToBeginningOfArray(object firstOne, object[] prevArray)
{
object[] newArray = new object[1 + prevArray.Length];
newArray[0] = firstOne;
prevArray.CopyTo(newArray, 1);
return newArray;
}
// Extension() returns an object. Convert that object into the integer error we expect to return.
private int MakeIntError(object extensionRet)
{

View File

@ -343,7 +343,7 @@ public sealed class BSLinksetConstraints : BSLinkset
// real world coordinate of midpoint between the two objects
OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2);
DetailLog("{0},BSLinksetConstraint.BuildConstraint,6Dof,rBody={1},cBody={2},rLoc={3},cLoc={4},midLoc={7}",
DetailLog("{0},BSLinksetConstraint.BuildConstraint,6Dof,rBody={1},cBody={2},rLoc={3},cLoc={4},midLoc={5}",
rootPrim.LocalID, rootPrim.PhysBody, linkInfo.member.PhysBody,
rootPrim.Position, linkInfo.member.Position, midPoint);
@ -492,11 +492,12 @@ public sealed class BSLinksetConstraints : BSLinkset
object ret = null;
switch (pFunct)
{
// pParams = (int linkNUm, PhysActor linkChild)
// pParams = [ BSPhysObject child, integer linkType ]
case ExtendedPhysics.PhysFunctChangeLinkType:
if (pParams.Length > 1)
{
int requestedType = (int)pParams[1];
DetailLog("{0},BSLinksetConstraint.SetLinkType,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
@ -507,7 +508,7 @@ public sealed class BSLinksetConstraints : BSLinkset
BSPrimLinkable child = pParams[0] as BSPrimLinkable;
if (child != null)
{
m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate()
m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkType", delegate()
{
// Pick up all the constraints currently created.
RemoveDependencies(child);
@ -522,15 +523,35 @@ public sealed class BSLinksetConstraints : BSLinkset
linkInfoC.ResetLink();
linkInfoC.constraintType = (ConstraintType)requestedType;
ret = (object)true;
DetailLog("{0},BSLinksetConstraint.SetLinkType,link={1},type={2}",
linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType);
}
else
{
DetailLog("{0},BSLinksetConstraint.SetLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID);
}
}
else
{
DetailLog("{0},BSLinksetConstraint.SetLinkType,noLinkInfoForChild,childID={1}", LinksetRoot.LocalID, child.LocalID);
}
// Cause the whole linkset to be rebuilt in post-taint time.
Refresh(child);
});
}
else
{
DetailLog("{0},BSLinksetConstraint.SetLinkType,childNotBSPrimLinkable", LinksetRoot.LocalID);
}
}
else
{
DetailLog("{0},BSLinksetConstraint.SetLinkType,illegalRequestedType,reqested={1},spring={2}",
LinksetRoot.LocalID, requestedType, ((int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE));
}
}
break;
// pParams = []
case ExtendedPhysics.PhysFunctGetLinkType:
if (pParams.Length > 0)
{
@ -544,11 +565,15 @@ public sealed class BSLinksetConstraints : BSLinkset
if (linkInfoC != null)
{
ret = (object)(int)linkInfoC.constraintType;
DetailLog("{0},BSLinksetConstraint.GetLinkType,link={1},type={2}",
linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType);
}
}
}
}
break;
// pParams = [ 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
@ -556,7 +581,6 @@ public sealed class BSLinksetConstraints : BSLinkset
if (pParams.Length > 1)
{
BSPrimLinkable child = pParams[0] as BSPrimLinkable;
object[] setOps = (object[])pParams[1];
BSLinkInfo baseLinkInfo = null;
if (TryGetLinkInfo(child, out baseLinkInfo))
{
@ -568,85 +592,106 @@ public sealed class BSLinksetConstraints : BSLinkset
OMV.Vector3 valueVector;
OMV.Quaternion valueQuaternion;
int opIndex = 0;
while (opIndex < setOps.Length)
int opIndex = 1;
while (opIndex < pParams.Length)
{
int thisOp = (int)setOps[opIndex];
int thisOp = (int)pParams[opIndex];
DetailLog("{0},BSLinksetConstraint.ChangeLinkParams2,op={1},val={2}",
linkInfo.member.LocalID, thisOp, pParams[opIndex+1]);
switch (thisOp)
{
case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC:
valueVector = (OMV.Vector3)setOps[opIndex + 1];
valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.frameInAloc = valueVector;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT:
valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1];
valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1];
linkInfo.frameInArot = valueQuaternion;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC:
valueVector = (OMV.Vector3)setOps[opIndex + 1];
valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.frameInBloc = valueVector;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT:
valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1];
valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1];
linkInfo.frameInBrot = valueQuaternion;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW:
valueVector = (OMV.Vector3)setOps[opIndex + 1];
valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.linearLimitLow = valueVector;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH:
valueVector = (OMV.Vector3)setOps[opIndex + 1];
valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.linearLimitHigh = valueVector;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW:
valueVector = (OMV.Vector3)setOps[opIndex + 1];
valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.angularLimitLow = valueVector;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH:
valueVector = (OMV.Vector3)setOps[opIndex + 1];
valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.angularLimitHigh = valueVector;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET:
valueBool = (bool)setOps[opIndex + 1];
valueBool = (bool)pParams[opIndex + 1];
linkInfo.useFrameOffset = valueBool;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR:
valueBool = (bool)setOps[opIndex + 1];
valueBool = (bool)pParams[opIndex + 1];
linkInfo.enableTransMotor = valueBool;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL:
valueFloat = (float)setOps[opIndex + 1];
valueFloat = (float)pParams[opIndex + 1];
linkInfo.transMotorMaxVel = valueFloat;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE:
valueFloat = (float)setOps[opIndex + 1];
valueFloat = (float)pParams[opIndex + 1];
linkInfo.transMotorMaxForce = valueFloat;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_CFM:
valueFloat = (float)setOps[opIndex + 1];
valueFloat = (float)pParams[opIndex + 1];
linkInfo.cfm = valueFloat;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_ERP:
valueFloat = (float)setOps[opIndex + 1];
valueFloat = (float)pParams[opIndex + 1];
linkInfo.erp = valueFloat;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS:
valueFloat = (float)setOps[opIndex + 1];
valueFloat = (float)pParams[opIndex + 1];
linkInfo.solverIterations = valueFloat;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING:
valueFloat = (float)setOps[opIndex + 1];
valueFloat = (float)pParams[opIndex + 1];
linkInfo.springDamping = valueFloat;
opIndex += 2;
break;
case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS:
valueFloat = (float)setOps[opIndex + 1];
valueFloat = (float)pParams[opIndex + 1];
linkInfo.springStiffness = valueFloat;
opIndex += 2;
break;
default:
break;
}
}
}
// Something changed so a rebuild is in order
Refresh(child);
}
}
}

View File

@ -1552,6 +1552,7 @@ public class BSPrim : BSPhysObject
#region Extension
public override object Extension(string pFunct, params object[] pParams)
{
DetailLog("{0} BSPrim.Extension,op={1}", LocalID, pFunct);
object ret = null;
switch (pFunct)
{

View File

@ -283,17 +283,20 @@ public class BSPrimLinkable : BSPrimDisplaced
#region Extension
public override object Extension(string pFunct, params object[] pParams)
{
DetailLog("{0} BSPrimLinkable.Extension,op={1},nParam={2}", LocalID, pFunct, pParams.Length);
object ret = null;
switch (pFunct)
{
// physGetLinksetType();
// pParams = []
case ExtendedPhysics.PhysFunctGetLinksetType:
{
ret = (object)LinksetType;
m_log.DebugFormat("{0} Extension.physGetLinksetType, type={1}", LogHeader, ret);
DetailLog("{0},BSPrimLinkable.Extension.physGetLinksetType,type={1}", LocalID, ret);
break;
}
// physSetLinksetType(type);
// pParams = [ BSPhysObject child, integer type ]
case ExtendedPhysics.PhysFunctSetLinksetType:
{
if (pParams.Length > 0)
@ -304,8 +307,8 @@ public class BSPrimLinkable : BSPrimDisplaced
PhysScene.TaintedObject("BSPrim.PhysFunctSetLinksetType", delegate()
{
// Cause the linkset type to change
m_log.DebugFormat("{0} Extension.physSetLinksetType, oldType={1}, newType={2}",
LogHeader, Linkset.LinksetImpl, linksetType);
DetailLog("{0},BSPrimLinkable.Extension.physSetLinksetType, oldType={1},newType={2}",
LocalID, Linkset.LinksetImpl, linksetType);
ConvertLinkset(linksetType);
});
}
@ -314,21 +317,21 @@ public class BSPrimLinkable : BSPrimDisplaced
break;
}
// physChangeLinkType(linknum, typeCode);
// Params: PhysActor linkedPrim, int typeCode
// pParams = [ BSPhysObject child, integer linkType ]
case ExtendedPhysics.PhysFunctChangeLinkType:
{
ret = Linkset.Extension(pFunct, pParams);
break;
}
// physGetLinkType(linknum);
// Params: PhysActor linkedPrim
// pParams = [ BSPhysObject child ]
case ExtendedPhysics.PhysFunctGetLinkType:
{
ret = Linkset.Extension(pFunct, pParams);
break;
}
// physChangeLinkParams(linknum, [code, value, code, value, ...]);
// Params: PhysActor linkedPrim, object[] params
// pParams = [ BSPhysObject child, object[] [ string op, object opParam, string op, object opParam, ... ] ]
case ExtendedPhysics.PhysFunctChangeLinkParams:
{
ret = Linkset.Extension(pFunct, pParams);

View File

@ -869,6 +869,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
#region Extensions
public override object Extension(string pFunct, params object[] pParams)
{
DetailLog("{0} BSScene.Extension,op={1}", DetailLogZero, pFunct);
return base.Extension(pFunct, pParams);
}
#endregion // Extensions