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)) 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; return ret;
@ -323,7 +324,7 @@ public class ExtendedPhysics : INonSharedRegionModule
// physGetLinkType(integer linkNum) // physGetLinkType(integer linkNum)
[ScriptInvocation] [ScriptInvocation]
public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum, int typeCode) public int physGetLinkType(UUID hostID, UUID scriptID, int linkNum)
{ {
int ret = -1; int ret = -1;
if (!Enabled) return ret; if (!Enabled) return ret;
@ -333,7 +334,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) 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; return ret;
@ -352,7 +354,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) 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; return ret;
@ -409,7 +412,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) 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; return ret;
@ -513,6 +517,15 @@ public class ExtendedPhysics : INonSharedRegionModule
return ret; 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. // Extension() returns an object. Convert that object into the integer error we expect to return.
private int MakeIntError(object extensionRet) 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 // real world coordinate of midpoint between the two objects
OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); 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.LocalID, rootPrim.PhysBody, linkInfo.member.PhysBody,
rootPrim.Position, linkInfo.member.Position, midPoint); rootPrim.Position, linkInfo.member.Position, midPoint);
@ -492,11 +492,12 @@ public sealed class BSLinksetConstraints : BSLinkset
object ret = null; object ret = null;
switch (pFunct) switch (pFunct)
{ {
// pParams = (int linkNUm, PhysActor linkChild) // pParams = [ BSPhysObject child, integer linkType ]
case ExtendedPhysics.PhysFunctChangeLinkType: case ExtendedPhysics.PhysFunctChangeLinkType:
if (pParams.Length > 1) if (pParams.Length > 1)
{ {
int requestedType = (int)pParams[1]; int requestedType = (int)pParams[1];
DetailLog("{0},BSLinksetConstraint.SetLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType);
if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE if (requestedType == (int)ConstraintType.FIXED_CONSTRAINT_TYPE
|| requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_CONSTRAINT_TYPE
|| requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.D6_SPRING_CONSTRAINT_TYPE
@ -507,7 +508,7 @@ public sealed class BSLinksetConstraints : BSLinkset
BSPrimLinkable child = pParams[0] as BSPrimLinkable; BSPrimLinkable child = pParams[0] as BSPrimLinkable;
if (child != null) if (child != null)
{ {
m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkFixed", delegate() m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkType", delegate()
{ {
// Pick up all the constraints currently created. // Pick up all the constraints currently created.
RemoveDependencies(child); RemoveDependencies(child);
@ -522,15 +523,35 @@ public sealed class BSLinksetConstraints : BSLinkset
linkInfoC.ResetLink(); linkInfoC.ResetLink();
linkInfoC.constraintType = (ConstraintType)requestedType; linkInfoC.constraintType = (ConstraintType)requestedType;
ret = (object)true; 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. // Cause the whole linkset to be rebuilt in post-taint time.
Refresh(child); 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; break;
// pParams = []
case ExtendedPhysics.PhysFunctGetLinkType: case ExtendedPhysics.PhysFunctGetLinkType:
if (pParams.Length > 0) if (pParams.Length > 0)
{ {
@ -544,11 +565,15 @@ public sealed class BSLinksetConstraints : BSLinkset
if (linkInfoC != null) if (linkInfoC != null)
{ {
ret = (object)(int)linkInfoC.constraintType; ret = (object)(int)linkInfoC.constraintType;
DetailLog("{0},BSLinksetConstraint.GetLinkType,link={1},type={2}",
linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType);
} }
} }
} }
} }
break; break;
// pParams = [ BSPhysObject child, int op, object opParams, int op, object opParams, ... ]
case ExtendedPhysics.PhysFunctChangeLinkParams: case ExtendedPhysics.PhysFunctChangeLinkParams:
// There should be two parameters: the childActor and a list of parameters to set // There should be two parameters: the childActor and a list of parameters to set
try try
@ -556,7 +581,6 @@ public sealed class BSLinksetConstraints : BSLinkset
if (pParams.Length > 1) if (pParams.Length > 1)
{ {
BSPrimLinkable child = pParams[0] as BSPrimLinkable; BSPrimLinkable child = pParams[0] as BSPrimLinkable;
object[] setOps = (object[])pParams[1];
BSLinkInfo baseLinkInfo = null; BSLinkInfo baseLinkInfo = null;
if (TryGetLinkInfo(child, out baseLinkInfo)) if (TryGetLinkInfo(child, out baseLinkInfo))
{ {
@ -568,85 +592,106 @@ public sealed class BSLinksetConstraints : BSLinkset
OMV.Vector3 valueVector; OMV.Vector3 valueVector;
OMV.Quaternion valueQuaternion; OMV.Quaternion valueQuaternion;
int opIndex = 0; int opIndex = 1;
while (opIndex < setOps.Length) 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) switch (thisOp)
{ {
case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC: case ExtendedPhysics.PHYS_PARAM_FRAMEINA_LOC:
valueVector = (OMV.Vector3)setOps[opIndex + 1]; valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.frameInAloc = valueVector; linkInfo.frameInAloc = valueVector;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT: case ExtendedPhysics.PHYS_PARAM_FRAMEINA_ROT:
valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1];
linkInfo.frameInArot = valueQuaternion; linkInfo.frameInArot = valueQuaternion;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC: case ExtendedPhysics.PHYS_PARAM_FRAMEINB_LOC:
valueVector = (OMV.Vector3)setOps[opIndex + 1]; valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.frameInBloc = valueVector; linkInfo.frameInBloc = valueVector;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT: case ExtendedPhysics.PHYS_PARAM_FRAMEINB_ROT:
valueQuaternion = (OMV.Quaternion)setOps[opIndex + 1]; valueQuaternion = (OMV.Quaternion)pParams[opIndex + 1];
linkInfo.frameInBrot = valueQuaternion; linkInfo.frameInBrot = valueQuaternion;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW: case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_LOW:
valueVector = (OMV.Vector3)setOps[opIndex + 1]; valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.linearLimitLow = valueVector; linkInfo.linearLimitLow = valueVector;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH: case ExtendedPhysics.PHYS_PARAM_LINEAR_LIMIT_HIGH:
valueVector = (OMV.Vector3)setOps[opIndex + 1]; valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.linearLimitHigh = valueVector; linkInfo.linearLimitHigh = valueVector;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW: case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_LOW:
valueVector = (OMV.Vector3)setOps[opIndex + 1]; valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.angularLimitLow = valueVector; linkInfo.angularLimitLow = valueVector;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH: case ExtendedPhysics.PHYS_PARAM_ANGULAR_LIMIT_HIGH:
valueVector = (OMV.Vector3)setOps[opIndex + 1]; valueVector = (OMV.Vector3)pParams[opIndex + 1];
linkInfo.angularLimitHigh = valueVector; linkInfo.angularLimitHigh = valueVector;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET: case ExtendedPhysics.PHYS_PARAM_USE_FRAME_OFFSET:
valueBool = (bool)setOps[opIndex + 1]; valueBool = (bool)pParams[opIndex + 1];
linkInfo.useFrameOffset = valueBool; linkInfo.useFrameOffset = valueBool;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR: case ExtendedPhysics.PHYS_PARAM_ENABLE_TRANSMOTOR:
valueBool = (bool)setOps[opIndex + 1]; valueBool = (bool)pParams[opIndex + 1];
linkInfo.enableTransMotor = valueBool; linkInfo.enableTransMotor = valueBool;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL: case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXVEL:
valueFloat = (float)setOps[opIndex + 1]; valueFloat = (float)pParams[opIndex + 1];
linkInfo.transMotorMaxVel = valueFloat; linkInfo.transMotorMaxVel = valueFloat;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE: case ExtendedPhysics.PHYS_PARAM_TRANSMOTOR_MAXFORCE:
valueFloat = (float)setOps[opIndex + 1]; valueFloat = (float)pParams[opIndex + 1];
linkInfo.transMotorMaxForce = valueFloat; linkInfo.transMotorMaxForce = valueFloat;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_CFM: case ExtendedPhysics.PHYS_PARAM_CFM:
valueFloat = (float)setOps[opIndex + 1]; valueFloat = (float)pParams[opIndex + 1];
linkInfo.cfm = valueFloat; linkInfo.cfm = valueFloat;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_ERP: case ExtendedPhysics.PHYS_PARAM_ERP:
valueFloat = (float)setOps[opIndex + 1]; valueFloat = (float)pParams[opIndex + 1];
linkInfo.erp = valueFloat; linkInfo.erp = valueFloat;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS: case ExtendedPhysics.PHYS_PARAM_SOLVER_ITERATIONS:
valueFloat = (float)setOps[opIndex + 1]; valueFloat = (float)pParams[opIndex + 1];
linkInfo.solverIterations = valueFloat; linkInfo.solverIterations = valueFloat;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING: case ExtendedPhysics.PHYS_PARAM_SPRING_DAMPING:
valueFloat = (float)setOps[opIndex + 1]; valueFloat = (float)pParams[opIndex + 1];
linkInfo.springDamping = valueFloat; linkInfo.springDamping = valueFloat;
opIndex += 2;
break; break;
case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS: case ExtendedPhysics.PHYS_PARAM_SPRING_STIFFNESS:
valueFloat = (float)setOps[opIndex + 1]; valueFloat = (float)pParams[opIndex + 1];
linkInfo.springStiffness = valueFloat; linkInfo.springStiffness = valueFloat;
opIndex += 2;
break; break;
default: default:
break; break;
} }
} }
} }
// Something changed so a rebuild is in order
Refresh(child);
} }
} }
} }

View File

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

View File

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

View File

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