remove some more of obsolete ninha joints code

This commit is contained in:
UbitUmarov
2022-03-19 01:06:44 +00:00
parent 0b205b91a6
commit 9bd8e45b30
9 changed files with 120 additions and 1163 deletions

View File

@@ -2123,24 +2123,17 @@ namespace OpenSim.Region.Framework.Scenes
if (_VolumeDetectActive)
isPhantom = true;
if (IsJoint())
if ((!isPhantom || isPhysical || _VolumeDetectActive)
&& !ParentGroup.IsAttachmentCheckFull()
&& !(Shape.PathCurve == (byte)Extrusion.Flexible))
{
DoPhysicsPropertyUpdate(isPhysical, true);
AddToPhysics(isPhysical, isPhantom, building, isPhysical);
UpdatePhysicsSubscribedEvents(); // not sure if appliable here
}
else
{
if ((!isPhantom || isPhysical || _VolumeDetectActive)
&& !ParentGroup.IsAttachmentCheckFull()
&& !(Shape.PathCurve == (byte)Extrusion.Flexible))
{
AddToPhysics(isPhysical, isPhantom, building, isPhysical);
UpdatePhysicsSubscribedEvents(); // not sure if appliable here
}
else
{
PhysActor = null; // just to be sure
RemFlag(PrimFlags.CameraDecoupled);
}
PhysActor = null; // just to be sure
RemFlag(PrimFlags.CameraDecoupled);
}
}
@@ -2246,98 +2239,6 @@ namespace OpenSim.Region.Framework.Scenes
return dupe;
}
/// <summary>
/// Do a physics property update for a NINJA joint.
/// </summary>
/// <param name="UsePhysics"></param>
/// <param name="isNew"></param>
protected void DoPhysicsPropertyUpdateForNinjaJoint(bool UsePhysics, bool isNew)
{
if (UsePhysics)
{
// by turning a joint proxy object physical, we cause creation of a joint in the ODE scene.
// note that, as a special case, joints have no bodies or geoms in the physics scene, even though they are physical.
PhysicsJointType jointType;
if (IsHingeJoint())
{
jointType = PhysicsJointType.Hinge;
}
else if (IsBallJoint())
{
jointType = PhysicsJointType.Ball;
}
else
{
jointType = PhysicsJointType.Ball;
}
List<string> bodyNames = new List<string>();
string RawParams = Description;
string[] jointParams = RawParams.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries);
string trackedBodyName = null;
if (jointParams.Length >= 2)
{
for (int iBodyName = 0; iBodyName < 2; iBodyName++)
{
string bodyName = jointParams[iBodyName];
bodyNames.Add(bodyName);
if (bodyName != "NULL")
{
if (trackedBodyName == null)
{
trackedBodyName = bodyName;
}
}
}
}
SceneObjectPart trackedBody = ParentGroup.Scene.GetSceneObjectPart(trackedBodyName); // FIXME: causes a sequential lookup
Quaternion localRotation = Quaternion.Identity;
if (trackedBody != null)
{
localRotation = Quaternion.Inverse(trackedBody.RotationOffset) * this.RotationOffset;
}
else
{
// error, output it below
}
PhysicsJoint joint;
joint = ParentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType,
AbsolutePosition,
this.RotationOffset,
Description,
bodyNames,
trackedBodyName,
localRotation);
if (trackedBody == null)
{
ParentGroup.Scene.jointErrorMessage(joint, "warning: tracked body name not found! joint location will not be updated properly. joint: " + Name);
}
}
else
{
if (isNew)
{
// if the joint proxy is new, and it is not physical, do nothing. There is no joint in ODE to
// delete, and if we try to delete it, due to asynchronous processing, the deletion request
// will get processed later at an indeterminate time, which could cancel a later-arriving
// joint creation request.
}
else
{
// here we turn off the joint object, so remove the joint from the physics scene
ParentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed?
// make sure client isn't interpolating the joint proxy object
Stop();
}
}
}
/// <summary>
/// Do a physics propery update for this part.
/// now also updates phantom and volume detector
@@ -2352,92 +2253,75 @@ namespace OpenSim.Region.Framework.Scenes
if (!ParentGroup.Scene.PhysicalPrims && UsePhysics)
return;
if (IsJoint())
{
DoPhysicsPropertyUpdateForNinjaJoint(UsePhysics, isNew);
}
else
{
PhysicsActor pa = PhysActor;
PhysicsActor pa = PhysActor;
if (pa != null)
if (pa != null)
{
if (UsePhysics != pa.IsPhysical)
ClampScale(UsePhysics);
if (UsePhysics != pa.IsPhysical || isNew)
{
if (UsePhysics != pa.IsPhysical)
ClampScale(UsePhysics);
if (UsePhysics != pa.IsPhysical || isNew)
if (pa.IsPhysical) // implies UsePhysics==false for this block
{
if (pa.IsPhysical) // implies UsePhysics==false for this block
if (!isNew) // implies UsePhysics==false for this block
{
if (!isNew) // implies UsePhysics==false for this block
ParentGroup.Scene.RemovePhysicalPrim(1);
Stop();
if (pa.Phantom && !VolumeDetectActive)
{
ParentGroup.Scene.RemovePhysicalPrim(1);
Stop();
if (pa.Phantom && !VolumeDetectActive)
{
RemoveFromPhysics();
return;
}
pa.IsPhysical = UsePhysics;
pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
pa.OnOutOfBounds -= PhysicsOutOfBounds;
pa.delink();
if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
{
// destroy all joints connected to this now deactivated body
ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa);
}
RemoveFromPhysics();
return;
}
}
if (pa.IsPhysical != UsePhysics)
pa.IsPhysical = UsePhysics;
if (UsePhysics)
{
if (ParentGroup.RootPart.KeyframeMotion != null)
ParentGroup.RootPart.KeyframeMotion.Stop();
ParentGroup.RootPart.KeyframeMotion = null;
ParentGroup.Scene.AddPhysicalPrim(1);
PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
if (_parentID != 0 && _parentID != LocalId)
{
PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
if (parentPa != null)
{
pa.link(parentPa);
}
}
pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
pa.OnOutOfBounds -= PhysicsOutOfBounds;
pa.delink();
}
}
bool phan = ((m_flags & PrimFlags.Phantom) != 0);
if (pa.Phantom != phan)
pa.Phantom = phan;
if (pa.IsPhysical != UsePhysics)
pa.IsPhysical = UsePhysics;
// some engines dont' have this check still
// if (VolumeDetectActive != pa.IsVolumeDtc)
if (UsePhysics)
{
if (VolumeDetectActive)
pa.SetVolumeDetect(1);
else
pa.SetVolumeDetect(0);
}
if (ParentGroup.RootPart.KeyframeMotion != null)
ParentGroup.RootPart.KeyframeMotion.Stop();
ParentGroup.RootPart.KeyframeMotion = null;
ParentGroup.Scene.AddPhysicalPrim(1);
// If this part is a sculpt then delay the physics update until we've asynchronously loaded the
// mesh data.
// if (Shape.SculptEntry)
// CheckSculptAndLoad();
// else
ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
if (_parentID != 0 && _parentID != LocalId)
{
PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
if (parentPa != null)
{
pa.link(parentPa);
}
}
}
}
bool phan = ((m_flags & PrimFlags.Phantom) != 0);
if (pa.Phantom != phan)
pa.Phantom = phan;
// some engines dont' have this check still
// if (VolumeDetectActive != pa.IsVolumeDtc)
{
if (VolumeDetectActive)
pa.SetVolumeDetect(1);
else
pa.SetVolumeDetect(0);
}
ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
}
}
@@ -4758,53 +4642,6 @@ namespace OpenSim.Region.Framework.Scenes
SendFullUpdateToAllClients();
}
public bool IsHingeJoint()
{
// For now, we use the NINJA naming scheme for identifying joints.
// In the future, we can support other joint specification schemes such as a
// custom checkbox in the viewer GUI.
if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
{
string hingeString = "hingejoint";
return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString);
}
else
{
return false;
}
}
public bool IsBallJoint()
{
// For now, we use the NINJA naming scheme for identifying joints.
// In the future, we can support other joint specification schemes such as a
// custom checkbox in the viewer GUI.
if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
{
string ballString = "balljoint";
return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString);
}
else
{
return false;
}
}
public bool IsJoint()
{
// For now, we use the NINJA naming scheme for identifying joints.
// In the future, we can support other joint specification schemes such as a
// custom checkbox in the viewer GUI.
if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
{
return IsHingeJoint() || IsBallJoint();
}
else
{
return false;
}
}
public void UpdateExtraPhysics(ExtraPhysicsData physdata)
{
if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null)
@@ -4972,7 +4809,7 @@ namespace OpenSim.Region.Framework.Scenes
if (pa != null)
{
pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
pa.SOPName = Name;
pa.SetMaterial(Material);
pa.Density = Density;