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

0.7.6-extended
Robert Adams 2013-08-20 13:09:40 -07:00 committed by Justin Clark-Casey (justincc)
parent 1b021e0eaa
commit 70438ff6ab
3 changed files with 41 additions and 35 deletions

View File

@ -220,7 +220,8 @@ public class ExtendedPhysics : INonSharedRegionModule
containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition);
containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); 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 Thread.Sleep(150); // longer than one heartbeat tick
containingGroup.ScriptSetPhysicsStatus(true); 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 // Non-physical linksets don't have a physical instantiation so there is no state to
// worry about being updated. // worry about being updated.
ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType)); object[] parms2 = { rootPhysActor, null, linksetType };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctSetLinksetType, parms2));
} }
} }
else else
@ -271,7 +273,8 @@ public class ExtendedPhysics : INonSharedRegionModule
PhysicsActor rootPhysActor = rootPart.PhysActor; PhysicsActor rootPhysActor = rootPart.PhysActor;
if (rootPhysActor != null) if (rootPhysActor != null)
{ {
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType)); object[] parms2 = { rootPhysActor, null };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinksetType, parms2));
} }
else else
{ {
@ -315,8 +318,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{ {
object[] parms = { childPhysActor, typeCode }; object[] parms2 = { rootPhysActor, childPhysActor, typeCode };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2));
} }
return ret; return ret;
@ -334,8 +337,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{ {
object[] parms = { childPhysActor }; object[] parms2 = { rootPhysActor, childPhysActor };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms)); ret = MakeIntError(rootPhysActor.Extension(PhysFunctGetLinkType, parms2));
} }
return ret; return ret;
@ -354,8 +357,8 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor))
{ {
object[] parms = { childPhysActor , PHYS_LINK_TYPE_FIXED }; object[] parms2 = { rootPhysActor, childPhysActor , PHYS_LINK_TYPE_FIXED };
ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms)); ret = MakeIntError(rootPhysActor.Extension(PhysFunctChangeLinkType, parms2));
} }
return ret; return ret;
@ -412,7 +415,7 @@ public class ExtendedPhysics : INonSharedRegionModule
if (GetRootAndChildPhysActors(hostID, linkNum, out rootPhysActor, out childPhysActor)) 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)); 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 // 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; newArray[0] = firstOne;
prevArray.CopyTo(newArray, 1); newArray[1] = secondOne;
prevArray.CopyTo(newArray, 2);
return newArray; return newArray;
} }

View File

@ -385,7 +385,7 @@ public sealed class BSLinksetConstraints : BSLinkset
linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot, linkInfo.frameInAloc, linkInfo.frameInArot, linkInfo.frameInBloc, linkInfo.frameInBrot,
true /*useLinearReferenceFrameA*/, true /*useLinearReferenceFrameA*/,
true /*disableCollisionsBetweenLinkedBodies*/); 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.LocalID, rootPrim.PhysBody.AddrString, rootPrim.LocalID, rootPrim.PhysBody.AddrString,
linkInfo.member.LocalID, linkInfo.member.PhysBody.AddrString, linkInfo.member.LocalID, linkInfo.member.PhysBody.AddrString,
@ -492,12 +492,12 @@ public sealed class BSLinksetConstraints : BSLinkset
object ret = null; object ret = null;
switch (pFunct) switch (pFunct)
{ {
// pParams = [ BSPhysObject child, integer linkType ] // pParams = [ BSPhysObject root, BSPhysObject child, integer linkType ]
case ExtendedPhysics.PhysFunctChangeLinkType: case ExtendedPhysics.PhysFunctChangeLinkType:
if (pParams.Length > 1) if (pParams.Length > 2)
{ {
int requestedType = (int)pParams[1]; int requestedType = (int)pParams[2];
DetailLog("{0},BSLinksetConstraint.SetLinkType,requestedType={1}", LinksetRoot.LocalID, requestedType); DetailLog("{0},BSLinksetConstraint.ChangeLinkType,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
@ -505,9 +505,11 @@ public sealed class BSLinksetConstraints : BSLinkset
|| requestedType == (int)ConstraintType.CONETWIST_CONSTRAINT_TYPE || requestedType == (int)ConstraintType.CONETWIST_CONSTRAINT_TYPE
|| requestedType == (int)ConstraintType.SLIDER_CONSTRAINT_TYPE) || requestedType == (int)ConstraintType.SLIDER_CONSTRAINT_TYPE)
{ {
BSPrimLinkable child = pParams[0] as BSPrimLinkable; BSPrimLinkable child = pParams[1] as BSPrimLinkable;
if (child != null) 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() m_physicsScene.TaintedObject(child.LocalID, "BSLinksetConstraint.PhysFunctChangeLinkType", delegate()
{ {
// Pick up all the constraints currently created. // Pick up all the constraints currently created.
@ -523,17 +525,17 @@ 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}", DetailLog("{0},BSLinksetConstraint.ChangeLinkType,link={1},type={2}",
linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType); linkInfo.member.LocalID, linkInfo.member.LocalID, linkInfoC.constraintType);
} }
else else
{ {
DetailLog("{0},BSLinksetConstraint.SetLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID); DetailLog("{0},BSLinksetConstraint.ChangeLinkType,linkInfoNotConstraint,childID={1}", LinksetRoot.LocalID, child.LocalID);
} }
} }
else 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. // Cause the whole linkset to be rebuilt in post-taint time.
Refresh(child); Refresh(child);
@ -551,11 +553,11 @@ public sealed class BSLinksetConstraints : BSLinkset
} }
} }
break; break;
// pParams = [] // pParams = [ BSPhysObject root, BSPhysObject child ]
case ExtendedPhysics.PhysFunctGetLinkType: case ExtendedPhysics.PhysFunctGetLinkType:
if (pParams.Length > 0) if (pParams.Length > 0)
{ {
BSPrimLinkable child = pParams[0] as BSPrimLinkable; BSPrimLinkable child = pParams[1] as BSPrimLinkable;
if (child != null) if (child != null)
{ {
BSLinkInfo linkInfo = null; BSLinkInfo linkInfo = null;
@ -573,14 +575,14 @@ public sealed class BSLinksetConstraints : BSLinkset
} }
} }
break; 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: 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
{ {
if (pParams.Length > 1) if (pParams.Length > 2)
{ {
BSPrimLinkable child = pParams[0] as BSPrimLinkable; BSPrimLinkable child = pParams[1] as BSPrimLinkable;
BSLinkInfo baseLinkInfo = null; BSLinkInfo baseLinkInfo = null;
if (TryGetLinkInfo(child, out baseLinkInfo)) if (TryGetLinkInfo(child, out baseLinkInfo))
{ {
@ -592,7 +594,7 @@ public sealed class BSLinksetConstraints : BSLinkset
OMV.Vector3 valueVector; OMV.Vector3 valueVector;
OMV.Quaternion valueQuaternion; OMV.Quaternion valueQuaternion;
int opIndex = 1; int opIndex = 2;
while (opIndex < pParams.Length) while (opIndex < pParams.Length)
{ {
int thisOp = (int)pParams[opIndex]; int thisOp = (int)pParams[opIndex];

View File

@ -288,7 +288,7 @@ public class BSPrimLinkable : BSPrimDisplaced
switch (pFunct) switch (pFunct)
{ {
// physGetLinksetType(); // physGetLinksetType();
// pParams = [] // pParams = [ BSPhysObject root, null ]
case ExtendedPhysics.PhysFunctGetLinksetType: case ExtendedPhysics.PhysFunctGetLinksetType:
{ {
ret = (object)LinksetType; ret = (object)LinksetType;
@ -296,12 +296,12 @@ public class BSPrimLinkable : BSPrimDisplaced
break; break;
} }
// physSetLinksetType(type); // physSetLinksetType(type);
// pParams = [ BSPhysObject child, integer type ] // pParams = [ BSPhysObject root, null, integer type ]
case ExtendedPhysics.PhysFunctSetLinksetType: 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)) if (Linkset.IsRoot(this))
{ {
PhysScene.TaintedObject(LocalID, "BSPrim.PhysFunctSetLinksetType", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.PhysFunctSetLinksetType", delegate()
@ -317,21 +317,21 @@ public class BSPrimLinkable : BSPrimDisplaced
break; break;
} }
// physChangeLinkType(linknum, typeCode); // physChangeLinkType(linknum, typeCode);
// pParams = [ BSPhysObject child, integer linkType ] // pParams = [ BSPhysObject root, 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);
// pParams = [ BSPhysObject child ] // pParams = [ BSPhysObject root, 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, ...]);
// 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: case ExtendedPhysics.PhysFunctChangeLinkParams:
{ {
ret = Linkset.Extension(pFunct, pParams); ret = Linkset.Extension(pFunct, pParams);