Experimental change of PhysicsVector to Vector3. Untested

0.6.8-post-fixes
John Hurliman 2009-10-25 23:16:12 -07:00
parent b6651ce790
commit d199767e69
32 changed files with 867 additions and 879 deletions

View File

@ -264,10 +264,8 @@ namespace OpenSim.Region.CoreModules.World.Land
avatar.ControllingClient.SendAlertMessage( avatar.ControllingClient.SendAlertMessage(
"You are not allowed on this parcel because you are banned. Please go away."); "You are not allowed on this parcel because you are banned. Please go away.");
avatar.PhysicsActor.Position = avatar.PhysicsActor.Position = avatar.lastKnownAllowedPosition;
new PhysicsVector(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y, avatar.PhysicsActor.Velocity = Vector3.Zero;
avatar.lastKnownAllowedPosition.Z);
avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0);
} }
else else
{ {

View File

@ -4606,7 +4606,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
case PhysicsJointType.Ball: case PhysicsJointType.Ball:
{ {
PhysicsVector jointAnchor = PhysicsScene.GetJointAnchor(joint); Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
Vector3 proxyPos = new Vector3(jointAnchor.X, jointAnchor.Y, jointAnchor.Z); Vector3 proxyPos = new Vector3(jointAnchor.X, jointAnchor.Y, jointAnchor.Z);
jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update
} }
@ -4614,7 +4614,7 @@ namespace OpenSim.Region.Framework.Scenes
case PhysicsJointType.Hinge: case PhysicsJointType.Hinge:
{ {
PhysicsVector jointAnchor = PhysicsScene.GetJointAnchor(joint); Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
// Normally, we would just ask the physics scene to return the axis for the joint. // Normally, we would just ask the physics scene to return the axis for the joint.
// Unfortunately, ODE sometimes returns <0,0,0> for the joint axis, which should // Unfortunately, ODE sometimes returns <0,0,0> for the joint axis, which should

View File

@ -1479,8 +1479,8 @@ namespace OpenSim.Region.Framework.Scenes
dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape(
dupe.RootPart.Name, dupe.RootPart.Name,
pbs, pbs,
new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, dupe.RootPart.AbsolutePosition.Z), dupe.RootPart.AbsolutePosition,
new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), dupe.RootPart.Scale,
dupe.RootPart.RotationOffset, dupe.RootPart.RotationOffset,
dupe.RootPart.PhysActor.IsPhysical); dupe.RootPart.PhysActor.IsPhysical);
@ -1595,7 +1595,7 @@ namespace OpenSim.Region.Framework.Scenes
*/ */
} }
public void applyImpulse(PhysicsVector impulse) public void applyImpulse(Vector3 impulse)
{ {
// We check if rootpart is null here because scripts don't delete if you delete the host. // We check if rootpart is null here because scripts don't delete if you delete the host.
// This means that unfortunately, we can pass a null physics actor to Simulate! // This means that unfortunately, we can pass a null physics actor to Simulate!
@ -1622,7 +1622,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void applyAngularImpulse(PhysicsVector impulse) public void applyAngularImpulse(Vector3 impulse)
{ {
// We check if rootpart is null here because scripts don't delete if you delete the host. // We check if rootpart is null here because scripts don't delete if you delete the host.
// This means that unfortunately, we can pass a null physics actor to Simulate! // This means that unfortunately, we can pass a null physics actor to Simulate!
@ -1641,7 +1641,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void setAngularImpulse(PhysicsVector impulse) public void setAngularImpulse(Vector3 impulse)
{ {
// We check if rootpart is null here because scripts don't delete if you delete the host. // We check if rootpart is null here because scripts don't delete if you delete the host.
// This means that unfortunately, we can pass a null physics actor to Simulate! // This means that unfortunately, we can pass a null physics actor to Simulate!
@ -1672,8 +1672,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (!IsAttachment) if (!IsAttachment)
{ {
PhysicsVector torque = rootpart.PhysActor.Torque; Vector3 torque = rootpart.PhysActor.Torque;
return new Vector3(torque.X, torque.Y, torque.Z); return torque;
} }
} }
} }
@ -1706,7 +1706,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (rootpart.PhysActor != null) if (rootpart.PhysActor != null)
{ {
rootpart.PhysActor.PIDTarget = new PhysicsVector(target.X, target.Y, target.Z); rootpart.PhysActor.PIDTarget = target;
rootpart.PhysActor.PIDTau = tau; rootpart.PhysActor.PIDTau = tau;
rootpart.PhysActor.PIDActive = true; rootpart.PhysActor.PIDActive = true;
} }
@ -2374,7 +2374,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_rootPart.PhysActor.IsPhysical) if (m_rootPart.PhysActor.IsPhysical)
{ {
Vector3 llmoveforce = pos - AbsolutePosition; Vector3 llmoveforce = pos - AbsolutePosition;
PhysicsVector grabforce = new PhysicsVector(llmoveforce.X, llmoveforce.Y, llmoveforce.Z); Vector3 grabforce = llmoveforce;
grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass;
m_rootPart.PhysActor.AddForce(grabforce,true); m_rootPart.PhysActor.AddForce(grabforce,true);
m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
@ -2479,7 +2479,7 @@ namespace OpenSim.Region.Framework.Scenes
rotationAxis.Normalize(); rotationAxis.Normalize();
//m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
PhysicsVector spinforce = new PhysicsVector(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor
m_rootPart.PhysActor.AddAngularForce(spinforce,true); m_rootPart.PhysActor.AddAngularForce(spinforce,true);
m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
@ -2706,8 +2706,7 @@ namespace OpenSim.Region.Framework.Scenes
if (scale.Z > m_scene.m_maxPhys) if (scale.Z > m_scene.m_maxPhys)
scale.Z = m_scene.m_maxPhys; scale.Z = m_scene.m_maxPhys;
} }
part.PhysActor.Size = part.PhysActor.Size = scale;
new PhysicsVector(scale.X, scale.Y, scale.Z);
m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
} }
//if (part.UUID != m_rootPart.UUID) //if (part.UUID != m_rootPart.UUID)
@ -2851,8 +2850,7 @@ namespace OpenSim.Region.Framework.Scenes
if (part.PhysActor != null) if (part.PhysActor != null)
{ {
part.PhysActor.Size = part.PhysActor.Size = prevScale;
new PhysicsVector(prevScale.X, prevScale.Y, prevScale.Z);
m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
} }

View File

@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes
public uint AttachmentPoint; public uint AttachmentPoint;
[XmlIgnore] [XmlIgnore]
public PhysicsVector RotationAxis = new PhysicsVector(1f, 1f, 1f); public Vector3 RotationAxis = Vector3.One;
[XmlIgnore] [XmlIgnore]
public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this
@ -537,13 +537,13 @@ namespace OpenSim.Region.Framework.Scenes
// Root prim actually goes at Position // Root prim actually goes at Position
if (_parentID == 0) if (_parentID == 0)
{ {
PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); PhysActor.Position = value;
} }
else else
{ {
// To move the child prim in respect to the group position and rotation we have to calculate // To move the child prim in respect to the group position and rotation we have to calculate
Vector3 resultingposition = GetWorldPosition(); Vector3 resultingposition = GetWorldPosition();
PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); PhysActor.Position = resultingposition;
Quaternion resultingrot = GetWorldRotation(); Quaternion resultingrot = GetWorldRotation();
PhysActor.Orientation = resultingrot; PhysActor.Orientation = resultingrot;
} }
@ -585,7 +585,7 @@ namespace OpenSim.Region.Framework.Scenes
if (_parentID != 0 && PhysActor != null) if (_parentID != 0 && PhysActor != null)
{ {
Vector3 resultingposition = GetWorldPosition(); Vector3 resultingposition = GetWorldPosition();
PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); PhysActor.Position = resultingposition;
Quaternion resultingrot = GetWorldRotation(); Quaternion resultingrot = GetWorldRotation();
PhysActor.Orientation = resultingrot; PhysActor.Orientation = resultingrot;
@ -675,7 +675,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (PhysActor.IsPhysical) if (PhysActor.IsPhysical)
{ {
PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); PhysActor.Velocity = value;
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
} }
} }
@ -817,7 +817,7 @@ if (m_shape != null) {
{ {
if (m_parentGroup.Scene.PhysicsScene != null) if (m_parentGroup.Scene.PhysicsScene != null)
{ {
PhysActor.Size = new PhysicsVector(m_shape.Scale.X, m_shape.Scale.Y, m_shape.Scale.Z); PhysActor.Size = m_shape.Scale;
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
} }
} }
@ -1225,7 +1225,7 @@ if (m_shape != null) {
/// <param name="localGlobalTF">true for the local frame, false for the global frame</param> /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
public void ApplyImpulse(Vector3 impulsei, bool localGlobalTF) public void ApplyImpulse(Vector3 impulsei, bool localGlobalTF)
{ {
PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); Vector3 impulse = impulsei;
if (localGlobalTF) if (localGlobalTF)
{ {
@ -1233,7 +1233,7 @@ if (m_shape != null) {
Quaternion AXgrot = grot; Quaternion AXgrot = grot;
Vector3 AXimpulsei = impulsei; Vector3 AXimpulsei = impulsei;
Vector3 newimpulse = AXimpulsei * AXgrot; Vector3 newimpulse = AXimpulsei * AXgrot;
impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); impulse = newimpulse;
} }
if (m_parentGroup != null) if (m_parentGroup != null)
@ -1251,7 +1251,7 @@ if (m_shape != null) {
/// <param name="localGlobalTF">true for the local frame, false for the global frame</param> /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF) public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF)
{ {
PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); Vector3 impulse = impulsei;
if (localGlobalTF) if (localGlobalTF)
{ {
@ -1259,7 +1259,7 @@ if (m_shape != null) {
Quaternion AXgrot = grot; Quaternion AXgrot = grot;
Vector3 AXimpulsei = impulsei; Vector3 AXimpulsei = impulsei;
Vector3 newimpulse = AXimpulsei * AXgrot; Vector3 newimpulse = AXimpulsei * AXgrot;
impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); impulse = newimpulse;
} }
if (m_parentGroup != null) if (m_parentGroup != null)
@ -1277,7 +1277,7 @@ if (m_shape != null) {
/// <param name="localGlobalTF">true for the local frame, false for the global frame</param> /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF)
{ {
PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); Vector3 impulse = impulsei;
if (localGlobalTF) if (localGlobalTF)
{ {
@ -1285,7 +1285,7 @@ if (m_shape != null) {
Quaternion AXgrot = grot; Quaternion AXgrot = grot;
Vector3 AXimpulsei = impulsei; Vector3 AXimpulsei = impulsei;
Vector3 newimpulse = AXimpulsei * AXgrot; Vector3 newimpulse = AXimpulsei * AXgrot;
impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); impulse = newimpulse;
} }
if (m_parentGroup != null) if (m_parentGroup != null)
@ -1333,8 +1333,8 @@ if (m_shape != null) {
PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
Name, Name,
Shape, Shape,
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), AbsolutePosition,
new PhysicsVector(Scale.X, Scale.Y, Scale.Z), Scale,
RotationOffset, RotationOffset,
RigidBody); RigidBody);
@ -1523,7 +1523,7 @@ if (m_shape != null) {
PhysicsJoint joint; PhysicsJoint joint;
joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType, joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType,
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), AbsolutePosition,
this.RotationOffset, this.RotationOffset,
Description, Description,
bodyNames, bodyNames,
@ -1708,12 +1708,12 @@ if (m_shape != null) {
} }
} }
public PhysicsVector GetForce() public Vector3 GetForce()
{ {
if (PhysActor != null) if (PhysActor != null)
return PhysActor.Force; return PhysActor.Force;
else else
return new PhysicsVector(); return Vector3.Zero;
} }
public void GetProperties(IClientAPI client) public void GetProperties(IClientAPI client)
@ -2078,7 +2078,7 @@ if (m_shape != null) {
} }
} }
public void PhysicsOutOfBounds(PhysicsVector pos) public void PhysicsOutOfBounds(Vector3 pos)
{ {
m_log.Error("[PHYSICS]: Physical Object went out of bounds."); m_log.Error("[PHYSICS]: Physical Object went out of bounds.");
@ -2564,7 +2564,7 @@ if (m_shape != null) {
} }
} }
public void SetForce(PhysicsVector force) public void SetForce(Vector3 force)
{ {
if (PhysActor != null) if (PhysActor != null)
{ {
@ -2588,7 +2588,7 @@ if (m_shape != null) {
} }
} }
public void SetVehicleVectorParam(int param, PhysicsVector value) public void SetVehicleVectorParam(int param, Vector3 value)
{ {
if (PhysActor != null) if (PhysActor != null)
{ {
@ -3430,8 +3430,8 @@ if (m_shape != null) {
PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
Name, Name,
Shape, Shape,
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), AbsolutePosition,
new PhysicsVector(Scale.X, Scale.Y, Scale.Z), Scale,
RotationOffset, RotationOffset,
UsePhysics); UsePhysics);

View File

@ -434,7 +434,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
lock (m_scene.SyncRoot) lock (m_scene.SyncRoot)
{ {
m_physicsActor.Position = new PhysicsVector(value.X, value.Y, value.Z); m_physicsActor.Position = value;
} }
} }
catch (Exception e) catch (Exception e)
@ -474,7 +474,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
lock (m_scene.SyncRoot) lock (m_scene.SyncRoot)
{ {
m_physicsActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); m_physicsActor.Velocity = value;
} }
} }
catch (Exception e) catch (Exception e)
@ -1046,7 +1046,7 @@ namespace OpenSim.Region.Framework.Scenes
m_avHeight = height; m_avHeight = height;
if (PhysicsActor != null && !IsChildAgent) if (PhysicsActor != null && !IsChildAgent)
{ {
PhysicsVector SetSize = new PhysicsVector(0.45f, 0.6f, m_avHeight); Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight);
PhysicsActor.Size = SetSize; PhysicsActor.Size = SetSize;
} }
} }
@ -3345,20 +3345,18 @@ namespace OpenSim.Region.Framework.Scenes
PhysicsScene scene = m_scene.PhysicsScene; PhysicsScene scene = m_scene.PhysicsScene;
PhysicsVector pVec = Vector3 pVec = AbsolutePosition;
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
AbsolutePosition.Z);
// Old bug where the height was in centimeters instead of meters // Old bug where the height was in centimeters instead of meters
if (m_avHeight == 127.0f) if (m_avHeight == 127.0f)
{ {
m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new PhysicsVector(0, 0, 1.56f), m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f),
isFlying); isFlying);
} }
else else
{ {
m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec,
new PhysicsVector(0, 0, m_avHeight), isFlying); new Vector3(0f, 0f, m_avHeight), isFlying);
} }
scene.AddPhysicsActorTaint(m_physicsActor); scene.AddPhysicsActorTaint(m_physicsActor);
//m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
@ -3369,7 +3367,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
private void OutOfBoundsCall(PhysicsVector pos) private void OutOfBoundsCall(Vector3 pos)
{ {
//bool flying = m_physicsActor.Flying; //bool flying = m_physicsActor.Flying;
//RemoveFromPhysicalScene(); //RemoveFromPhysicalScene();
@ -3592,7 +3590,7 @@ namespace OpenSim.Region.Framework.Scenes
*/ */
} }
internal void PushForce(PhysicsVector impulse) internal void PushForce(Vector3 impulse)
{ {
if (PhysicsActor != null) if (PhysicsActor != null)
{ {

View File

@ -525,8 +525,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get get
{ {
PhysicsVector tmp = GetSOP().PhysActor.GeometricCenter; Vector3 tmp = GetSOP().PhysActor.GeometricCenter;
return new Vector3(tmp.X, tmp.Y, tmp.Z); return tmp;
} }
} }
@ -534,8 +534,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get get
{ {
PhysicsVector tmp = GetSOP().PhysActor.CenterOfMass; Vector3 tmp = GetSOP().PhysActor.CenterOfMass;
return new Vector3(tmp.X, tmp.Y, tmp.Z); return tmp;
} }
} }
@ -543,15 +543,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get get
{ {
PhysicsVector tmp = GetSOP().PhysActor.RotationalVelocity; Vector3 tmp = GetSOP().PhysActor.RotationalVelocity;
return new Vector3(tmp.X, tmp.Y, tmp.Z); return tmp;
} }
set set
{ {
if (!CanEdit()) if (!CanEdit())
return; return;
GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); GetSOP().PhysActor.RotationalVelocity = value;
} }
} }
@ -559,15 +559,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get get
{ {
PhysicsVector tmp = GetSOP().PhysActor.Velocity; Vector3 tmp = GetSOP().PhysActor.Velocity;
return new Vector3(tmp.X, tmp.Y, tmp.Z); return tmp;
} }
set set
{ {
if (!CanEdit()) if (!CanEdit())
return; return;
GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); GetSOP().PhysActor.Velocity = value;
} }
} }
@ -575,15 +575,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get get
{ {
PhysicsVector tmp = GetSOP().PhysActor.Torque; Vector3 tmp = GetSOP().PhysActor.Torque;
return new Vector3(tmp.X, tmp.Y, tmp.Z); return tmp;
} }
set set
{ {
if (!CanEdit()) if (!CanEdit())
return; return;
GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); GetSOP().PhysActor.Torque = value;
} }
} }
@ -591,8 +591,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get get
{ {
PhysicsVector tmp = GetSOP().PhysActor.Acceleration; Vector3 tmp = GetSOP().PhysActor.Acceleration;
return new Vector3(tmp.X, tmp.Y, tmp.Z); return tmp;
} }
} }
@ -600,15 +600,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
get get
{ {
PhysicsVector tmp = GetSOP().PhysActor.Force; Vector3 tmp = GetSOP().PhysActor.Force;
return new Vector3(tmp.X, tmp.Y, tmp.Z); return tmp;
} }
set set
{ {
if (!CanEdit()) if (!CanEdit())
return; return;
GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); GetSOP().PhysActor.Force = value;
} }
} }
@ -627,7 +627,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
if (!CanEdit()) if (!CanEdit())
return; return;
GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); GetSOP().PhysActor.AddForce(force, pushforce);
} }
public void AddAngularForce(Vector3 force, bool pushforce) public void AddAngularForce(Vector3 force, bool pushforce)
@ -635,7 +635,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
if (!CanEdit()) if (!CanEdit())
return; return;
GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); GetSOP().PhysActor.AddAngularForce(force, pushforce);
} }
public void SetMomentum(Vector3 momentum) public void SetMomentum(Vector3 momentum)
@ -643,7 +643,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
if (!CanEdit()) if (!CanEdit())
return; return;
GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); GetSOP().PhysActor.SetMomentum(momentum);
} }
#endregion #endregion

View File

@ -36,20 +36,16 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{ {
public class BasicActor : PhysicsActor public class BasicActor : PhysicsActor
{ {
private PhysicsVector _position; private Vector3 _position;
private PhysicsVector _velocity; private Vector3 _velocity;
private PhysicsVector _acceleration; private Vector3 _acceleration;
private PhysicsVector _size; private Vector3 _size;
private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; private Vector3 m_rotationalVelocity;
private bool flying; private bool flying;
private bool iscolliding; private bool iscolliding;
public BasicActor() public BasicActor()
{ {
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
_size = new PhysicsVector();
} }
public override int PhysicsActorType public override int PhysicsActorType
@ -58,7 +54,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
set { return; } set { return; }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
@ -137,13 +133,13 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
get { return false; } get { return false; }
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get { return _position; } get { return _position; }
set { _position = value; } set { _position = value; }
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return _size; } get { return _size; }
set { set {
@ -162,9 +158,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
get { return 0f; } get { return 0f; }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -179,7 +175,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
} }
@ -194,25 +190,25 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get { return _velocity; } get { return _velocity; }
set { _velocity = value; } set { _velocity = value; }
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -228,7 +224,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
set { } set { }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
@ -247,24 +243,24 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{ {
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
} }
public void SetAcceleration(PhysicsVector accel) public void SetAcceleration(Vector3 accel)
{ {
_acceleration = accel; _acceleration = accel;
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
@ -272,7 +268,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{ {
} }
public override PhysicsVector PIDTarget public override Vector3 PIDTarget
{ {
set { return; } set { return; }
} }

View File

@ -54,7 +54,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{ {
} }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
{ {
BasicActor act = new BasicActor(); BasicActor act = new BasicActor();
act.Position = position; act.Position = position;
@ -77,20 +77,20 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
} }
/* /*
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
{ {
return null; return null;
} }
*/ */
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation) Vector3 size, Quaternion rotation)
{ {
return AddPrimShape(primName, pbs, position, size, rotation, false); return AddPrimShape(primName, pbs, position, size, rotation, false);
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation, bool isPhysical) Vector3 size, Quaternion rotation, bool isPhysical)
{ {
return null; return null;
} }
@ -105,26 +105,28 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
for (int i = 0; i < _actors.Count; ++i) for (int i = 0; i < _actors.Count; ++i)
{ {
BasicActor actor = _actors[i]; BasicActor actor = _actors[i];
Vector3 actorPosition = actor.Position;
Vector3 actorVelocity = actor.Velocity;
actor.Position.X += actor.Velocity.X*timeStep; actorPosition.X += actor.Velocity.X*timeStep;
actor.Position.Y += actor.Velocity.Y*timeStep; actorPosition.Y += actor.Velocity.Y*timeStep;
if (actor.Position.Y < 0) if (actor.Position.Y < 0)
{ {
actor.Position.Y = 0.1F; actorPosition.Y = 0.1F;
} }
else if (actor.Position.Y >= Constants.RegionSize) else if (actor.Position.Y >= Constants.RegionSize)
{ {
actor.Position.Y = ((int)Constants.RegionSize - 0.1f); actorPosition.Y = ((int)Constants.RegionSize - 0.1f);
} }
if (actor.Position.X < 0) if (actor.Position.X < 0)
{ {
actor.Position.X = 0.1F; actorPosition.X = 0.1F;
} }
else if (actor.Position.X >= Constants.RegionSize) else if (actor.Position.X >= Constants.RegionSize)
{ {
actor.Position.X = ((int)Constants.RegionSize - 0.1f); actorPosition.X = ((int)Constants.RegionSize - 0.1f);
} }
float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + actor.Size.Z; float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + actor.Size.Z;
@ -133,23 +135,27 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
if (actor.Position.Z + (actor.Velocity.Z*timeStep) < if (actor.Position.Z + (actor.Velocity.Z*timeStep) <
_heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 2) _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 2)
{ {
actor.Position.Z = height; actorPosition.Z = height;
actor.Velocity.Z = 0; actorVelocity.Z = 0;
actor.IsColliding = true; actor.IsColliding = true;
} }
else else
{ {
actor.Position.Z += actor.Velocity.Z*timeStep; actorPosition.Z += actor.Velocity.Z*timeStep;
actor.IsColliding = false; actor.IsColliding = false;
} }
} }
else else
{ {
actor.Position.Z = height; actorPosition.Z = height;
actor.Velocity.Z = 0; actorVelocity.Z = 0;
actor.IsColliding = true; actor.IsColliding = true;
} }
actor.Position = actorPosition;
actor.Velocity = actorVelocity;
} }
return fps; return fps;
} }

View File

@ -60,15 +60,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
private btQuaternion m_bodyOrientation; private btQuaternion m_bodyOrientation;
private btDefaultMotionState m_bodyMotionState; private btDefaultMotionState m_bodyMotionState;
private btGeneric6DofConstraint m_aMotor; private btGeneric6DofConstraint m_aMotor;
// private PhysicsVector m_movementComparision; // private Vector3 m_movementComparision;
private PhysicsVector m_position; private Vector3 m_position;
private PhysicsVector m_zeroPosition; private Vector3 m_zeroPosition;
private bool m_zeroFlag = false; private bool m_zeroFlag = false;
private bool m_lastUpdateSent = false; private bool m_lastUpdateSent = false;
private PhysicsVector m_velocity; private Vector3 m_velocity;
private PhysicsVector m_target_velocity; private Vector3 m_target_velocity;
private PhysicsVector m_acceleration; private Vector3 m_acceleration;
private PhysicsVector m_rotationalVelocity; private Vector3 m_rotationalVelocity;
private bool m_pidControllerActive = true; private bool m_pidControllerActive = true;
public float PID_D = 80.0f; public float PID_D = 80.0f;
public float PID_P = 90.0f; public float PID_P = 90.0f;
@ -96,8 +96,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes. private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
private bool m_taintRemove = false; private bool m_taintRemove = false;
// private bool m_taintedPosition = false; // private bool m_taintedPosition = false;
// private PhysicsVector m_taintedPosition_value; // private Vector3 m_taintedPosition_value;
private PhysicsVector m_taintedForce; private Vector3 m_taintedForce;
private float m_buoyancy = 0f; private float m_buoyancy = 0f;
@ -115,14 +115,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
public int m_eventsubscription = 0; public int m_eventsubscription = 0;
// private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); // private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
{ {
m_taintedForce = new PhysicsVector();
m_velocity = new PhysicsVector();
m_target_velocity = new PhysicsVector();
m_position = pos; m_position = pos;
m_zeroPosition = new PhysicsVector(pos.X, pos.Y, pos.Z); // this is a class, not a struct. Must make new, or m_zeroPosition will == position regardless m_zeroPosition = pos;
m_acceleration = new PhysicsVector();
m_parent_scene = parent_scene; m_parent_scene = parent_scene;
PID_D = pid_d; PID_D = pid_d;
PID_P = pid_p; PID_P = pid_p;
@ -161,9 +157,6 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
tempTrans1 = new btTransform(tempQuat1, tempVector1); tempTrans1 = new btTransform(tempQuat1, tempVector1);
// m_movementComparision = new PhysicsVector(0, 0, 0); // m_movementComparision = new PhysicsVector(0, 0, 0);
m_CapsuleOrientationAxis = new btVector3(1, 0, 1); m_CapsuleOrientationAxis = new btVector3(1, 0, 1);
} }
/// <summary> /// <summary>
@ -254,18 +247,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
get { return m_zeroFlag; } get { return m_zeroFlag; }
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
set set
{ {
m_pidControllerActive = true; m_pidControllerActive = true;
PhysicsVector SetSize = value; Vector3 SetSize = value;
m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
//m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
Velocity = new PhysicsVector(0f, 0f, 0f); Velocity = Vector3.Zero;
m_parent_scene.AddPhysicsActorTaint(this); m_parent_scene.AddPhysicsActorTaint(this);
} }
@ -317,12 +310,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get { return m_position; } get { return m_position; }
set set
@ -342,9 +335,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
get { return new PhysicsVector(m_target_velocity.X, m_target_velocity.Y, m_target_velocity.Z); } get { return m_target_velocity; }
set { return; } set { return; }
} }
@ -359,7 +352,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
} }
@ -374,23 +367,22 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get get
{ {
// There's a problem with PhysicsVector.Zero! Don't Use it Here!
if (m_zeroFlag) if (m_zeroFlag)
return new PhysicsVector(0f, 0f, 0f); return Vector3.Zero;
m_lastUpdateSent = false; m_lastUpdateSent = false;
return m_velocity; return m_velocity;
} }
@ -401,9 +393,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -413,7 +405,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
set { } set { }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return m_acceleration; } get { return m_acceleration; }
} }
@ -586,7 +578,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
set { return; } set { return; }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
@ -604,7 +596,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
set { m_buoyancy = value; } set { m_buoyancy = value; }
} }
public override PhysicsVector PIDTarget { set { return; } } public override Vector3 PIDTarget { set { return; } }
public override bool PIDActive { set { return; } } public override bool PIDActive { set { return; } }
public override float PIDTau { set { return; } } public override float PIDTau { set { return; } }
@ -634,7 +626,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
/// </summary> /// </summary>
/// <param name="force"></param> /// <param name="force"></param>
/// <param name="pushforce">Is this a push by a script?</param> /// <param name="pushforce">Is this a push by a script?</param>
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
if (pushforce) if (pushforce)
{ {
@ -656,7 +648,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
//m_lastUpdateSent = false; //m_lastUpdateSent = false;
} }
public void doForce(PhysicsVector force, bool now) public void doForce(Vector3 force, bool now)
{ {
tempVector3.setValue(force.X, force.Y, force.Z); tempVector3.setValue(force.X, force.Y, force.Z);
@ -671,7 +663,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
public void doImpulse(PhysicsVector force, bool now) public void doImpulse(Vector3 force, bool now)
{ {
tempVector3.setValue(force.X, force.Y, force.Z); tempVector3.setValue(force.X, force.Y, force.Z);
@ -686,12 +678,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
@ -808,7 +800,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
AvatarGeomAndBodyCreation(m_position.X, m_position.Y, AvatarGeomAndBodyCreation(m_position.X, m_position.Y,
m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2)); m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
Velocity = new PhysicsVector(0f, 0f, 0f); Velocity = Vector3.Zero;
} }
else else
@ -852,9 +844,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
//PidStatus = true; //PidStatus = true;
PhysicsVector vec = new PhysicsVector(); Vector3 vec = Vector3.Zero;
PhysicsVector vel = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); Vector3 vel = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
float movementdivisor = 1f; float movementdivisor = 1f;
@ -885,7 +877,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
// Avatar to Avatar collisions // Avatar to Avatar collisions
// Prim to avatar collisions // Prim to avatar collisions
PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2); vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2);
vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2); vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2);
if (m_flying) if (m_flying)
@ -927,7 +919,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
// We're colliding with something and we're not flying but we're moving // We're colliding with something and we're not flying but we're moving
// This means we're walking or running. // This means we're walking or running.
PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P; vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P;
if (m_target_velocity.X > 0) if (m_target_velocity.X > 0)
{ {
@ -1016,7 +1008,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
tempVector2 = Body.getInterpolationLinearVelocity(); tempVector2 = Body.getInterpolationLinearVelocity();
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
PhysicsVector vec = new PhysicsVector(tempVector1.getX(),tempVector1.getY(),tempVector1.getZ()); Vector3 vec = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
// kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
if (vec.X < -10.0f) vec.X = 0.0f; if (vec.X < -10.0f) vec.X = 0.0f;
@ -1048,7 +1040,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
else else
{ {
m_lastUpdateSent = false; m_lastUpdateSent = false;
vec = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); vec = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
m_velocity.X = (vec.X); m_velocity.X = (vec.X);
m_velocity.Y = (vec.Y); m_velocity.Y = (vec.Y);

View File

@ -43,44 +43,43 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private PhysicsVector _position; private Vector3 _position;
private PhysicsVector m_zeroPosition; private Vector3 m_zeroPosition;
private PhysicsVector _velocity; private Vector3 _velocity;
private PhysicsVector _torque = new PhysicsVector(0, 0, 0); private Vector3 _torque;
private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); private Vector3 m_lastVelocity;
private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); private Vector3 m_lastposition;
private Quaternion m_lastorientation = new Quaternion(); private Quaternion m_lastorientation = Quaternion.Identity;
private PhysicsVector m_rotationalVelocity; private Vector3 m_rotationalVelocity;
private PhysicsVector _size; private Vector3 _size;
private PhysicsVector _acceleration; private Vector3 _acceleration;
// private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f); // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
private Quaternion _orientation; private Quaternion _orientation;
private PhysicsVector m_taintposition; private Vector3 m_taintposition;
private PhysicsVector m_taintsize; private Vector3 m_taintsize;
private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); private Vector3 m_taintVelocity;
private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); private Vector3 m_taintTorque;
private Quaternion m_taintrot; private Quaternion m_taintrot;
private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); private Vector3 m_angularlock = Vector3.One;
private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); private Vector3 m_taintAngularLock = Vector3.One;
// private btGeneric6DofConstraint Amotor; // private btGeneric6DofConstraint Amotor;
private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); private Vector3 m_PIDTarget;
private float m_PIDTau = 0f; private float m_PIDTau;
private float m_PIDHoverHeight = 0f; private float m_PIDHoverHeight;
private float m_PIDHoverTau = 0f; private float m_PIDHoverTau;
private bool m_useHoverPID = false; private bool m_useHoverPID;
private PIDHoverType m_PIDHoverType = PIDHoverType.Ground; private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
private float m_targetHoverHeight = 0f; private float m_targetHoverHeight;
private float m_groundHeight = 0f; private float m_groundHeight;
private float m_waterHeight = 0f; private float m_waterHeight;
private float PID_D = 35f; private float PID_D = 35f;
private float PID_G = 25f; private float PID_G = 25f;
// private float m_tensor = 5f; // private float m_tensor = 5f;
// private int body_autodisable_frames = 20; // private int body_autodisable_frames = 20;
private IMesh primMesh = null; private IMesh primMesh;
private bool m_usePID = false;
private bool m_usePID;
private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
| CollisionCategories.Space | CollisionCategories.Space
@ -88,11 +87,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
| CollisionCategories.Character | CollisionCategories.Character
); );
private bool m_taintshape = false; private bool m_taintshape;
private bool m_taintPhysics = false; private bool m_taintPhysics;
// private bool m_collidesLand = true; // private bool m_collidesLand = true;
private bool m_collidesWater = false; private bool m_collidesWater;
public bool m_returnCollisions = false; public bool m_returnCollisions;
// Default we're a Geometry // Default we're a Geometry
// private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); // private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@ -100,23 +99,23 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
// Default, Collide with Other Geometries, spaces and Bodies // Default, Collide with Other Geometries, spaces and Bodies
// private CollisionCategories m_collisionFlags = m_default_collisionFlags; // private CollisionCategories m_collisionFlags = m_default_collisionFlags;
public bool m_taintremove = false; public bool m_taintremove;
public bool m_taintdisable = false; public bool m_taintdisable;
public bool m_disabled = false; public bool m_disabled;
public bool m_taintadd = false; public bool m_taintadd;
public bool m_taintselected = false; public bool m_taintselected;
public bool m_taintCollidesWater = false; public bool m_taintCollidesWater;
public uint m_localID = 0; public uint m_localID;
//public GCHandle gc; //public GCHandle gc;
// private CollisionLocker ode; // private CollisionLocker ode;
private bool m_taintforce = false; private bool m_taintforce;
private bool m_taintaddangularforce = false; private bool m_taintaddangularforce;
private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); private Vector3 m_force;
private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); private List<Vector3> m_forcelist = new List<Vector3>();
private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>(); private List<Vector3> m_angularforcelist = new List<Vector3>();
private IMesh _mesh; private IMesh _mesh;
private PrimitiveBaseShape _pbs; private PrimitiveBaseShape _pbs;
@ -124,40 +123,40 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
public btCollisionShape prim_geom; public btCollisionShape prim_geom;
public IntPtr _triMeshData; public IntPtr _triMeshData;
private PhysicsActor _parent = null; private PhysicsActor _parent;
private PhysicsActor m_taintparent = null; private PhysicsActor m_taintparent;
private List<BulletDotNETPrim> childrenPrim = new List<BulletDotNETPrim>(); private List<BulletDotNETPrim> childrenPrim = new List<BulletDotNETPrim>();
private bool iscolliding = false; private bool iscolliding;
private bool m_isphysical = false; private bool m_isphysical;
private bool m_isSelected = false; private bool m_isSelected;
internal bool m_isVolumeDetect = false; // If true, this prim only detects collisions but doesn't collide actively internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
private bool m_throttleUpdates = false; private bool m_throttleUpdates;
// private int throttleCounter = 0; // private int throttleCounter;
public int m_interpenetrationcount = 0; public int m_interpenetrationcount;
public float m_collisionscore = 0; public float m_collisionscore;
public int m_roundsUnderMotionThreshold = 0; public int m_roundsUnderMotionThreshold;
private int m_crossingfailures = 0; private int m_crossingfailures;
public float m_buoyancy = 0f; public float m_buoyancy;
public bool outofBounds = false; public bool outofBounds;
private float m_density = 10.000006836f; // Aluminum g/cm3; private float m_density = 10.000006836f; // Aluminum g/cm3;
public bool _zeroFlag = false; public bool _zeroFlag;
private bool m_lastUpdateSent = false; private bool m_lastUpdateSent;
private String m_primName; private String m_primName;
private PhysicsVector _target_velocity; private Vector3 _target_velocity;
public int m_eventsubscription = 0; public int m_eventsubscription;
// private CollisionEventUpdate CollisionEventsThisFrame = null; // private CollisionEventUpdate CollisionEventsThisFrame = null;
public volatile bool childPrim = false; public volatile bool childPrim;
private btVector3 tempPosition1; private btVector3 tempPosition1;
private btVector3 tempPosition2; private btVector3 tempPosition2;
@ -190,7 +189,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
public btRigidBody Body; public btRigidBody Body;
public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical) Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical)
{ {
tempPosition1 = new btVector3(0, 0, 0); tempPosition1 = new btVector3(0, 0, 0);
@ -225,8 +224,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize); AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize);
_target_velocity = new PhysicsVector(0, 0, 0); _target_velocity = Vector3.Zero;
_velocity = new PhysicsVector(); _velocity = Vector3.Zero;
_position = pos; _position = pos;
m_taintposition = pos; m_taintposition = pos;
PID_D = parent_scene.bodyPIDD; PID_D = parent_scene.bodyPIDD;
@ -244,8 +243,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
_size = size; _size = size;
m_taintsize = _size; m_taintsize = _size;
_acceleration = new PhysicsVector(); _acceleration = Vector3.Zero;
m_rotationalVelocity = PhysicsVector.Zero; m_rotationalVelocity = Vector3.Zero;
_orientation = rotation; _orientation = rotation;
m_taintrot = _orientation; m_taintrot = _orientation;
_mesh = mesh; _mesh = mesh;
@ -274,7 +273,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
get { return _zeroFlag; } get { return _zeroFlag; }
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return _size; } get { return _size; }
set { _size = value; } set { _size = value; }
@ -348,13 +347,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
m_taintparent = null; m_taintparent = null;
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); m_taintAngularLock = axis;
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get { return _position; } get { return _position; }
@ -370,9 +369,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
get { return CalculateMass(); } get { return CalculateMass(); }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
//get { return PhysicsVector.Zero; } //get { return Vector3.Zero; }
get { return m_force; } get { return m_force; }
set { m_force = value; } set { m_force = value; }
} }
@ -388,7 +387,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
//TODO: //TODO:
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
//TODO: //TODO:
} }
@ -405,23 +404,23 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get get
{ {
// Averate previous velocity with the new one so // Averate previous velocity with the new one so
// client object interpolation works a 'little' better // client object interpolation works a 'little' better
PhysicsVector returnVelocity = new PhysicsVector(); Vector3 returnVelocity;
returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2; returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2;
returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2; returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2;
returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2; returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2;
@ -436,12 +435,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get get
{ {
if (!m_isphysical || Body.Handle == IntPtr.Zero) if (!m_isphysical || Body.Handle == IntPtr.Zero)
return new PhysicsVector(0, 0, 0); return Vector3.Zero;
return _torque; return _torque;
} }
@ -459,7 +458,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
set { m_collisionscore = value; } set { m_collisionscore = value; }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
@ -528,16 +527,16 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get get
{ {
PhysicsVector pv = new PhysicsVector(0, 0, 0); Vector3 pv = Vector3.Zero;
if (_zeroFlag) if (_zeroFlag)
return pv; return pv;
m_lastUpdateSent = false; m_lastUpdateSent = false;
if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) if (m_rotationalVelocity.ApproxEquals(pv, 0.2f))
return pv; return pv;
return m_rotationalVelocity; return m_rotationalVelocity;
@ -557,7 +556,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
set { m_buoyancy = value; } set { m_buoyancy = value; }
} }
public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } } public override Vector3 PIDTarget { set { m_PIDTarget = value; ; } }
public override bool PIDActive { set { m_usePID = value; } } public override bool PIDActive { set { m_usePID = value; } }
public override float PIDTau { set { m_PIDTau = value; } } public override float PIDTau { set { m_PIDTau = value; } }
@ -567,20 +566,20 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
public override float PIDHoverTau { set { m_PIDHoverTau = value; } } public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
m_forcelist.Add(force); m_forcelist.Add(force);
m_taintforce = true; m_taintforce = true;
//m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
m_angularforcelist.Add(force); m_angularforcelist.Add(force);
m_taintaddangularforce = true; m_taintaddangularforce = true;
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
@ -778,7 +777,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
if (!_position.IsIdentical(m_taintposition, 0f)) if (!_position.ApproxEquals(m_taintposition, 0f))
{ {
m_log.Debug("[PHYSICS]: TaintMove"); m_log.Debug("[PHYSICS]: TaintMove");
changemove(timestep); changemove(timestep);
@ -796,7 +795,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
// //
if (!_size.IsIdentical(m_taintsize, 0)) if (!_size.ApproxEquals(m_taintsize, 0f))
{ {
m_log.Debug("[PHYSICS]: TaintSize"); m_log.Debug("[PHYSICS]: TaintSize");
changesize(timestep); changesize(timestep);
@ -820,7 +819,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
m_log.Debug("[PHYSICS]: TaintAngularForce"); m_log.Debug("[PHYSICS]: TaintAngularForce");
changeAddAngularForce(timestep); changeAddAngularForce(timestep);
} }
if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
{ {
m_log.Debug("[PHYSICS]: TaintTorque"); m_log.Debug("[PHYSICS]: TaintTorque");
changeSetTorque(timestep); changeSetTorque(timestep);
@ -835,7 +834,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
m_log.Debug("[PHYSICS]: TaintSelected"); m_log.Debug("[PHYSICS]: TaintSelected");
changeSelectedStatus(timestep); changeSelectedStatus(timestep);
} }
if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
{ {
m_log.Debug("[PHYSICS]: TaintVelocity"); m_log.Debug("[PHYSICS]: TaintVelocity");
changevelocity(timestep); changevelocity(timestep);
@ -849,7 +848,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
changefloatonwater(timestep); changefloatonwater(timestep);
} }
if (!m_angularlock.IsIdentical(m_taintAngularLock, 0)) if (!m_angularlock.ApproxEquals(m_taintAngularLock, 0))
{ {
m_log.Debug("[PHYSICS]: TaintAngularLock"); m_log.Debug("[PHYSICS]: TaintAngularLock");
changeAngularLock(timestep); changeAngularLock(timestep);
@ -1012,7 +1011,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
if (_parent_scene.needsMeshing(_pbs)) if (_parent_scene.needsMeshing(_pbs))
{ {
ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
// createmesh returns null when it doesn't mesh. // createmesh returns null when it doesn't mesh.
CreateGeom(IntPtr.Zero, _mesh); CreateGeom(IntPtr.Zero, _mesh);
} }
@ -1029,7 +1028,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
return _parent_scene.needsMeshing(_pbs); return _parent_scene.needsMeshing(_pbs);
} }
internal void ProcessGeomCreationAsTriMesh(PhysicsVector positionOffset, Quaternion orientation) internal void ProcessGeomCreationAsTriMesh(Vector3 positionOffset, Quaternion orientation)
{ {
// Don't need to re-enable body.. it's done in SetMesh // Don't need to re-enable body.. it's done in SetMesh
float meshlod = _parent_scene.meshSculptLOD; float meshlod = _parent_scene.meshSculptLOD;
@ -1038,7 +1037,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
meshlod = _parent_scene.MeshSculptphysicalLOD; meshlod = _parent_scene.MeshSculptphysicalLOD;
IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity) if (!positionOffset.ApproxEquals(Vector3.Zero, 0.001f) || orientation != Quaternion.Identity)
{ {
float[] xyz = new float[3]; float[] xyz = new float[3];
@ -1202,7 +1201,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
//m_log.Info("[PHYSICS]: dequeing forcelist"); //m_log.Info("[PHYSICS]: dequeing forcelist");
if (IsPhysical) if (IsPhysical)
{ {
PhysicsVector iforce = new PhysicsVector(); Vector3 iforce = Vector3.Zero;
for (int i = 0; i < m_forcelist.Count; i++) for (int i = 0; i < m_forcelist.Count; i++)
{ {
iforce = iforce + m_forcelist[i]; iforce = iforce + m_forcelist[i];
@ -1237,7 +1236,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
//m_log.Info("[PHYSICS]: dequeing forcelist"); //m_log.Info("[PHYSICS]: dequeing forcelist");
if (IsPhysical) if (IsPhysical)
{ {
PhysicsVector iforce = new PhysicsVector(); Vector3 iforce = Vector3.Zero;
for (int i = 0; i < m_angularforcelist.Count; i++) for (int i = 0; i < m_angularforcelist.Count; i++)
{ {
iforce = iforce + m_angularforcelist[i]; iforce = iforce + m_angularforcelist[i];
@ -1276,7 +1275,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
} }
m_taintTorque = new PhysicsVector(0, 0, 0); m_taintTorque = Vector3.Zero;
} }
private void changedisable(float timestep) private void changedisable(float timestep)
@ -1317,7 +1316,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
//resetCollisionAccounting(); //resetCollisionAccounting();
} }
m_taintVelocity = PhysicsVector.Zero; m_taintVelocity = Vector3.Zero;
} }
private void changelink(float timestep) private void changelink(float timestep)
@ -1361,7 +1360,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
if (m_taintparent != null) if (m_taintparent != null)
{ {
m_taintparent.Position.Z = m_taintparent.Position.Z + 0.02f; Vector3 taintparentPosition = m_taintparent.Position;
taintparentPosition.Z = m_taintparent.Position.Z + 0.02f;
m_taintparent.Position = taintparentPosition;
_parent_scene.AddPhysicsActorTaint(m_taintparent); _parent_scene.AddPhysicsActorTaint(m_taintparent);
} }
} }
@ -1382,7 +1383,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
if (_parent == null) if (_parent == null)
{ {
if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f, 1f, 1f), 0)) if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
{ {
//d.BodySetFiniteRotationMode(Body, 0); //d.BodySetFiniteRotationMode(Body, 0);
//d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@ -1395,7 +1396,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); m_angularlock = m_taintAngularLock;
} }
#endregion #endregion
@ -1460,17 +1461,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
// TODO: NEED btVector3 for Linear Velocity // TODO: NEED btVector3 for Linear Velocity
// NEED btVector3 for Position // NEED btVector3 for Position
PhysicsVector pos = new PhysicsVector(_position.X, _position.Y, _position.Z); //TODO: Insert values gotten from bullet Vector3 pos = _position; //TODO: Insert values gotten from bullet
PhysicsVector vel = new PhysicsVector(_velocity.X, _velocity.Y, _velocity.Z); Vector3 vel = _velocity;
_target_velocity = _target_velocity =
new PhysicsVector( new Vector3(
(m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
(m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
(m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
); );
if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
{ {
/* TODO: Do Bullet equiv /* TODO: Do Bullet equiv
@ -1512,8 +1513,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
PID_G = m_PIDTau + 1; PID_G = m_PIDTau + 1;
} }
PhysicsVector pos = new PhysicsVector(0, 0, 0); //TODO: Insert values gotten from bullet Vector3 pos = Vector3.Zero; //TODO: Insert values gotten from bullet
PhysicsVector vel = new PhysicsVector(0, 0, 0); Vector3 vel = Vector3.Zero;
// determine what our target height really is based on HoverType // determine what our target height really is based on HoverType
switch (m_PIDHoverType) switch (m_PIDHoverType)
@ -1545,13 +1546,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
_target_velocity = _target_velocity =
new PhysicsVector(0.0f, 0.0f, new Vector3(0.0f, 0.0f,
(m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
); );
// if velocity is zero, use position control; otherwise, velocity control // if velocity is zero, use position control; otherwise, velocity control
if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
{ {
/* TODO: Do Bullet Equiv /* TODO: Do Bullet Equiv
@ -1626,8 +1627,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
else else
{ {
if (m_zeroPosition == null) if (m_zeroPosition == null)
m_zeroPosition = new PhysicsVector(0, 0, 0); m_zeroPosition = Vector3.Zero;
m_zeroPosition.setValues(_position.X, _position.Y, _position.Z); m_zeroPosition = _position;
return; return;
} }
} }
@ -2177,7 +2178,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
//if (hasTrimesh) //if (hasTrimesh)
//{ //{
ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
// createmesh returns null when it doesn't mesh. // createmesh returns null when it doesn't mesh.
/* /*
@ -2197,11 +2198,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
if (chld == null) if (chld == null)
continue; continue;
PhysicsVector offset = chld.Position - Position; Vector3 offset = chld.Position - Position;
Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
pos *= Quaternion.Inverse(Orientation); pos *= Quaternion.Inverse(Orientation);
//pos *= Orientation; //pos *= Orientation;
offset.setValues(pos.X, pos.Y, pos.Z); offset = pos;
chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
_mesh.Append(chld._mesh); _mesh.Append(chld._mesh);
@ -2433,7 +2434,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
m_collisionscore = 0; m_collisionscore = 0;
m_disabled = false; m_disabled = false;
// The body doesn't already have a finite rotation mode set here // The body doesn't already have a finite rotation mode set here
if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
{ {
// TODO: Create Angular Motor on Axis Lock! // TODO: Create Angular Motor on Axis Lock!
} }
@ -2447,7 +2448,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
if (_parent == null) if (_parent == null)
{ {
PhysicsVector pv = new PhysicsVector(0, 0, 0); Vector3 pv = Vector3.Zero;
bool lastZeroFlag = _zeroFlag; bool lastZeroFlag = _zeroFlag;
if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero) if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero)
tempPosition3.Dispose(); tempPosition3.Dispose();
@ -2471,10 +2472,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel
tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel
_torque.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(), _torque = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(),
tempAngularVelocity1.getZ()); tempAngularVelocity1.getZ());
PhysicsVector l_position = new PhysicsVector(); Vector3 l_position = Vector3.Zero;
Quaternion l_orientation = new Quaternion(); Quaternion l_orientation = Quaternion.Identity;
m_lastposition = _position; m_lastposition = _position;
m_lastorientation = _orientation; m_lastorientation = _orientation;
@ -2598,20 +2599,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
_velocity.Z = tempLinearVelocity1.getZ(); _velocity.Z = tempLinearVelocity1.getZ();
_acceleration = ((_velocity - m_lastVelocity) / 0.1f); _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
_acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f,
_velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f,
_velocity.Z - m_lastVelocity.Z / 0.1f); _velocity.Z - m_lastVelocity.Z / 0.1f);
//m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
if (_velocity.IsIdentical(pv, 0.5f)) if (_velocity.ApproxEquals(pv, 0.5f))
{ {
m_rotationalVelocity = pv; m_rotationalVelocity = pv;
} }
else else
{ {
m_rotationalVelocity = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(), tempAngularVelocity1.getZ());
m_rotationalVelocity.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(),
tempAngularVelocity1.getZ());
} }
//m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@ -2665,7 +2664,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
m_taintremove = true; m_taintremove = true;
} }
internal void EnableAxisMotor(PhysicsVector axislock) internal void EnableAxisMotor(Vector3 axislock)
{ {
if (m_aMotor != null) if (m_aMotor != null)
DisableAxisMotor(); DisableAxisMotor();

View File

@ -139,7 +139,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
{ {
BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP, BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP,
avCapRadius, avStandupTensor, avDensity, avCapRadius, avStandupTensor, avDensity,
@ -177,14 +177,14 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
{ {
PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); Vector3 pos = position;
//pos.X = position.X; //pos.X = position.X;
//pos.Y = position.Y; //pos.Y = position.Y;
//pos.Z = position.Z; //pos.Z = position.Z;
PhysicsVector siz = new PhysicsVector(); Vector3 siz = Vector3.Zero;
siz.X = size.X; siz.X = size.X;
siz.Y = size.Y; siz.Y = size.Y;
siz.Z = size.Z; siz.Z = size.Z;
@ -201,12 +201,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
return newPrim; return newPrim;
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation)
{ {
return AddPrimShape(primName, pbs, position, size, rotation, false); return AddPrimShape(primName, pbs, position, size, rotation, false);
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical)
{ {
PhysicsActor result; PhysicsActor result;
IMesh mesh = null; IMesh mesh = null;

View File

@ -52,14 +52,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin
//private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//Vector3 //Vector3
public static Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector) public static Vector3 PhysicsVectorToXnaVector3(OpenMetaverse.Vector3 physicsVector)
{ {
return new Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z); return new Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z);
} }
public static PhysicsVector XnaVector3ToPhysicsVector(Vector3 xnaVector3) public static OpenMetaverse.Vector3 XnaVector3ToPhysicsVector(Vector3 xnaVector3)
{ {
return new PhysicsVector(xnaVector3.X, xnaVector3.Y, xnaVector3.Z); return new OpenMetaverse.Vector3(xnaVector3.X, xnaVector3.Y, xnaVector3.Z);
} }
//Quaternion //Quaternion
@ -349,7 +349,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
vertexBase = new Vector3[iVertexCount]; vertexBase = new Vector3[iVertexCount];
for (int i = 0; i < iVertexCount; i++) for (int i = 0; i < iVertexCount; i++)
{ {
PhysicsVector v = mesh.getVertexList()[i]; OpenMetaverse.Vector3 v = mesh.getVertexList()[i];
if (v != null) // Note, null has special meaning. See meshing code for details if (v != null) // Note, null has special meaning. See meshing code for details
vertexBase[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); vertexBase[i] = BulletXMaths.PhysicsVectorToXnaVector3(v);
else else
@ -392,7 +392,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
private int preCheckCollision(BulletXActor actA, Vector3 vNormal, float fDist) private int preCheckCollision(BulletXActor actA, Vector3 vNormal, float fDist)
{ {
float fstartSide; float fstartSide;
PhysicsVector v = actA.Position; OpenMetaverse.Vector3 v = actA.Position;
Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v); Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v);
fstartSide = Vector3.Dot(vNormal, v3) - fDist; fstartSide = Vector3.Dot(vNormal, v3) - fDist;
@ -404,7 +404,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{ {
Vector3 perPlaneNormal; Vector3 perPlaneNormal;
float fPerPlaneDist; float fPerPlaneDist;
PhysicsVector v = actA.Position; OpenMetaverse.Vector3 v = actA.Position;
Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v); Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v);
//check AB //check AB
Vector3 v1; Vector3 v1;
@ -573,9 +573,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) public override PhysicsActor AddAvatar(string avName, OpenMetaverse.Vector3 position, OpenMetaverse.Vector3 size, bool isFlying)
{ {
PhysicsVector pos = new PhysicsVector(); OpenMetaverse.Vector3 pos = OpenMetaverse.Vector3.Zero;
pos.X = position.X; pos.X = position.X;
pos.Y = position.Y; pos.Y = position.Y;
pos.Z = position.Z + 20; pos.Z = position.Z + 20;
@ -611,14 +611,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position,
PhysicsVector size, OpenMetaverse.Quaternion rotation) OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation)
{ {
return AddPrimShape(primName, pbs, position, size, rotation, false); return AddPrimShape(primName, pbs, position, size, rotation, false);
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position,
PhysicsVector size, OpenMetaverse.Quaternion rotation, bool isPhysical) OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation, bool isPhysical)
{ {
PhysicsActor result; PhysicsActor result;
@ -645,7 +645,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
return result; return result;
} }
public PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, OpenMetaverse.Quaternion rotation, public PhysicsActor AddPrim(String name, OpenMetaverse.Vector3 position, OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation,
IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
{ {
BulletXPrim newPrim = null; BulletXPrim newPrim = null;
@ -879,12 +879,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{ {
protected bool flying = false; protected bool flying = false;
protected bool _physical = false; protected bool _physical = false;
protected PhysicsVector _position; protected OpenMetaverse.Vector3 _position;
protected PhysicsVector _velocity; protected OpenMetaverse.Vector3 _velocity;
protected PhysicsVector _size; protected OpenMetaverse.Vector3 _size;
protected PhysicsVector _acceleration; protected OpenMetaverse.Vector3 _acceleration;
protected OpenMetaverse.Quaternion _orientation; protected OpenMetaverse.Quaternion _orientation;
protected PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; protected OpenMetaverse.Vector3 m_rotationalVelocity;
protected RigidBody rigidBody; protected RigidBody rigidBody;
protected int m_PhysicsActorType; protected int m_PhysicsActorType;
private Boolean iscolliding = false; private Boolean iscolliding = false;
@ -900,7 +900,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
get { return false; } get { return false; }
} }
public override PhysicsVector Position public override OpenMetaverse.Vector3 Position
{ {
get { return _position; } get { return _position; }
set set
@ -913,13 +913,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
} }
public override PhysicsVector RotationalVelocity public override OpenMetaverse.Vector3 RotationalVelocity
{ {
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
} }
public override PhysicsVector Velocity public override OpenMetaverse.Vector3 Velocity
{ {
get { return _velocity; } get { return _velocity; }
set set
@ -934,7 +934,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
else else
{ {
_velocity = new PhysicsVector(); _velocity = OpenMetaverse.Vector3.Zero;
} }
} }
} }
@ -944,7 +944,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
get { return 0f; } get { return 0f; }
set { } set { }
} }
public override PhysicsVector Size public override OpenMetaverse.Vector3 Size
{ {
get { return _size; } get { return _size; }
set set
@ -956,9 +956,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
} }
public override PhysicsVector Force public override OpenMetaverse.Vector3 Force
{ {
get { return PhysicsVector.Zero; } get { return OpenMetaverse.Vector3.Zero; }
set { return; } set { return; }
} }
@ -973,7 +973,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, OpenMetaverse.Vector3 value)
{ {
} }
@ -988,14 +988,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
public override PhysicsVector CenterOfMass public override OpenMetaverse.Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return OpenMetaverse.Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override OpenMetaverse.Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return OpenMetaverse.Vector3.Zero; }
} }
public override PrimitiveBaseShape Shape public override PrimitiveBaseShape Shape
@ -1009,7 +1009,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
set { return; } set { return; }
} }
public override PhysicsVector Acceleration public override OpenMetaverse.Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
@ -1036,7 +1036,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(OpenMetaverse.Vector3 axis)
{ {
} }
@ -1129,7 +1129,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
set { return; } set { return; }
} }
public virtual void SetAcceleration(PhysicsVector accel) public virtual void SetAcceleration(OpenMetaverse.Vector3 accel)
{ {
lock (BulletXScene.BulletXLock) lock (BulletXScene.BulletXLock)
{ {
@ -1143,19 +1143,19 @@ namespace OpenSim.Region.Physics.BulletXPlugin
set { } set { }
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(OpenMetaverse.Vector3 force, bool pushforce)
{ {
} }
public override PhysicsVector Torque public override OpenMetaverse.Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return OpenMetaverse.Vector3.Zero; }
set { return; } set { return; }
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(OpenMetaverse.Vector3 force, bool pushforce)
{ {
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(OpenMetaverse.Vector3 momentum)
{ {
} }
@ -1174,7 +1174,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
Translate(_position); Translate(_position);
} }
protected internal void Translate(PhysicsVector _newPos) protected internal void Translate(OpenMetaverse.Vector3 _newPos)
{ {
Vector3 _translation; Vector3 _translation;
_translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition;
@ -1186,7 +1186,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
Speed(_velocity); Speed(_velocity);
} }
protected internal void Speed(PhysicsVector _newSpeed) protected internal void Speed(OpenMetaverse.Vector3 _newSpeed)
{ {
Vector3 _speed; Vector3 _speed;
_speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed);
@ -1212,7 +1212,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
ReSize(_size); ReSize(_size);
} }
protected internal virtual void ReSize(PhysicsVector _newSize) protected internal virtual void ReSize(OpenMetaverse.Vector3 _newSize)
{ {
} }
@ -1227,7 +1227,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{ {
} }
public override PhysicsVector PIDTarget { set { return; } } public override OpenMetaverse.Vector3 PIDTarget { set { return; } }
public override bool PIDActive { set { return; } } public override bool PIDActive { set { return; } }
public override float PIDTau { set { return; } } public override float PIDTau { set { return; } }
@ -1256,19 +1256,19 @@ namespace OpenSim.Region.Physics.BulletXPlugin
/// </summary> /// </summary>
public class BulletXCharacter : BulletXActor public class BulletXCharacter : BulletXActor
{ {
public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos) public BulletXCharacter(BulletXScene parent_scene, OpenMetaverse.Vector3 pos)
: this(String.Empty, parent_scene, pos) : this(String.Empty, parent_scene, pos)
{ {
} }
public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos) public BulletXCharacter(String avName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos)
: this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(), : this(avName, parent_scene, pos, OpenMetaverse.Vector3.Zero, OpenMetaverse.Vector3.Zero, OpenMetaverse.Vector3.Zero,
OpenMetaverse.Quaternion.Identity) OpenMetaverse.Quaternion.Identity)
{ {
} }
public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, public BulletXCharacter(String avName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 velocity,
PhysicsVector size, PhysicsVector acceleration, OpenMetaverse.Quaternion orientation) OpenMetaverse.Vector3 size, OpenMetaverse.Vector3 acceleration, OpenMetaverse.Quaternion orientation)
: base(avName) : base(avName)
{ {
//This fields will be removed. They're temporal //This fields will be removed. They're temporal
@ -1323,25 +1323,25 @@ namespace OpenSim.Region.Physics.BulletXPlugin
set { return; } set { return; }
} }
public override PhysicsVector Position public override OpenMetaverse.Vector3 Position
{ {
get { return base.Position; } get { return base.Position; }
set { base.Position = value; } set { base.Position = value; }
} }
public override PhysicsVector Velocity public override OpenMetaverse.Vector3 Velocity
{ {
get { return base.Velocity; } get { return base.Velocity; }
set { base.Velocity = value; } set { base.Velocity = value; }
} }
public override PhysicsVector Size public override OpenMetaverse.Vector3 Size
{ {
get { return base.Size; } get { return base.Size; }
set { base.Size = value; } set { base.Size = value; }
} }
public override PhysicsVector Acceleration public override OpenMetaverse.Vector3 Acceleration
{ {
get { return base.Acceleration; } get { return base.Acceleration; }
} }
@ -1370,17 +1370,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin
set { base.Kinematic = value; } set { base.Kinematic = value; }
} }
public override void SetAcceleration(PhysicsVector accel) public override void SetAcceleration(OpenMetaverse.Vector3 accel)
{ {
base.SetAcceleration(accel); base.SetAcceleration(accel);
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(OpenMetaverse.Vector3 force, bool pushforce)
{ {
base.AddForce(force, pushforce); base.AddForce(force, pushforce);
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(OpenMetaverse.Vector3 momentum)
{ {
base.SetMomentum(momentum); base.SetMomentum(momentum);
} }
@ -1430,7 +1430,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
m.Translation = v3; m.Translation = v3;
rigidBody.WorldTransform = m; rigidBody.WorldTransform = m;
//When an Avie touch the ground it's vertical velocity it's reduced to ZERO //When an Avie touch the ground it's vertical velocity it's reduced to ZERO
Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); Speed(new OpenMetaverse.Vector3(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
} }
} }
@ -1452,7 +1452,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
//For now all prims have the same density, all prims are made of water. Be water my friend! :D //For now all prims have the same density, all prims are made of water. Be water my friend! :D
private const float _density = 1000.0f; private const float _density = 1000.0f;
private BulletXScene _parent_scene; private BulletXScene _parent_scene;
private PhysicsVector m_prev_position = new PhysicsVector(0, 0, 0); private OpenMetaverse.Vector3 m_prev_position;
private bool m_lastUpdateSent = false; private bool m_lastUpdateSent = false;
//added by jed zhu //added by jed zhu
private IMesh _mesh; private IMesh _mesh;
@ -1460,17 +1460,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin
public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, public BulletXPrim(String primName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 size,
OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
: this( : this(
primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, primName, parent_scene, pos, OpenMetaverse.Vector3.Zero, size, OpenMetaverse.Vector3.Zero, rotation, mesh, pbs,
isPhysical) isPhysical)
{ {
} }
public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, public BulletXPrim(String primName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 velocity,
PhysicsVector size, OpenMetaverse.Vector3 size,
PhysicsVector acceleration, OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 acceleration, OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs,
bool isPhysical) bool isPhysical)
: base(primName) : base(primName)
{ {
@ -1481,7 +1481,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
_position = pos; _position = pos;
_physical = isPhysical; _physical = isPhysical;
_velocity = _physical ? velocity : new PhysicsVector(); _velocity = _physical ? velocity : OpenMetaverse.Vector3.Zero;
_size = size; _size = size;
_acceleration = acceleration; _acceleration = acceleration;
_orientation = rotation; _orientation = rotation;
@ -1497,19 +1497,19 @@ namespace OpenSim.Region.Physics.BulletXPlugin
set { return; } set { return; }
} }
public override PhysicsVector Position public override OpenMetaverse.Vector3 Position
{ {
get { return base.Position; } get { return base.Position; }
set { base.Position = value; } set { base.Position = value; }
} }
public override PhysicsVector Velocity public override OpenMetaverse.Vector3 Velocity
{ {
get { return base.Velocity; } get { return base.Velocity; }
set { base.Velocity = value; } set { base.Velocity = value; }
} }
public override PhysicsVector Size public override OpenMetaverse.Vector3 Size
{ {
get { return _size; } get { return _size; }
set set
@ -1522,7 +1522,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
} }
public override PhysicsVector Acceleration public override OpenMetaverse.Vector3 Acceleration
{ {
get { return base.Acceleration; } get { return base.Acceleration; }
} }
@ -1583,7 +1583,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
set { base.Kinematic = value; } set { base.Kinematic = value; }
} }
public override void SetAcceleration(PhysicsVector accel) public override void SetAcceleration(OpenMetaverse.Vector3 accel)
{ {
lock (BulletXScene.BulletXLock) lock (BulletXScene.BulletXLock)
{ {
@ -1591,12 +1591,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(OpenMetaverse.Vector3 force, bool pushforce)
{ {
base.AddForce(force,pushforce); base.AddForce(force,pushforce);
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(OpenMetaverse.Vector3 momentum)
{ {
base.SetMomentum(momentum); base.SetMomentum(momentum);
} }
@ -1613,7 +1613,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
//When a Prim touch the ground it's vertical velocity it's reduced to ZERO //When a Prim touch the ground it's vertical velocity it's reduced to ZERO
//Static objects don't have linear velocity //Static objects don't have linear velocity
if (_physical) if (_physical)
Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); Speed(new OpenMetaverse.Vector3(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
} }
} }
@ -1632,7 +1632,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{ {
if (!m_lastUpdateSent) if (!m_lastUpdateSent)
{ {
_velocity = new PhysicsVector(0, 0, 0); _velocity = OpenMetaverse.Vector3.Zero;
base.ScheduleTerseUpdate(); base.ScheduleTerseUpdate();
m_lastUpdateSent = true; m_lastUpdateSent = true;
} }
@ -1654,8 +1654,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
#region Methods for updating values of RigidBody #region Methods for updating values of RigidBody
protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, OpenMetaverse.Vector3 pos,
PhysicsVector size) OpenMetaverse.Vector3 size)
{ {
//For RigidBody Constructor. The next values might change //For RigidBody Constructor. The next values might change
float _linearDamping = 0.0f; float _linearDamping = 0.0f;
@ -1683,7 +1683,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
Vector3[] v3Vertices = new Vector3[iVertexCount]; Vector3[] v3Vertices = new Vector3[iVertexCount];
for (int i = 0; i < iVertexCount; i++) for (int i = 0; i < iVertexCount; i++)
{ {
PhysicsVector v = mesh.getVertexList()[i]; OpenMetaverse.Vector3 v = mesh.getVertexList()[i];
if (v != null) // Note, null has special meaning. See meshing code for details if (v != null) // Note, null has special meaning. See meshing code for details
v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v);
else else
@ -1709,7 +1709,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
} }
protected internal void ReCreateRigidBody(PhysicsVector size) protected internal void ReCreateRigidBody(OpenMetaverse.Vector3 size)
{ {
//There is a bug when trying to remove a rigidBody that is colliding with something.. //There is a bug when trying to remove a rigidBody that is colliding with something..
try try
@ -1729,7 +1729,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
GC.Collect(); GC.Collect();
} }
protected internal override void ReSize(PhysicsVector _newSize) protected internal override void ReSize(OpenMetaverse.Vector3 _newSize)
{ {
//I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't
//so i have to do it manually. That's recreating rigidbody //so i have to do it manually. That's recreating rigidbody
@ -1744,8 +1744,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
/// </summary> /// </summary>
internal class BulletXPlanet internal class BulletXPlanet
{ {
private PhysicsVector _staticPosition; private OpenMetaverse.Vector3 _staticPosition;
// private PhysicsVector _staticVelocity; // private Vector3 _staticVelocity;
// private OpenMetaverse.Quaternion _staticOrientation; // private OpenMetaverse.Quaternion _staticOrientation;
private float _mass; private float _mass;
// private BulletXScene _parentscene; // private BulletXScene _parentscene;
@ -1759,7 +1759,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
internal BulletXPlanet(BulletXScene parent_scene, float[] heightField) internal BulletXPlanet(BulletXScene parent_scene, float[] heightField)
{ {
_staticPosition = new PhysicsVector(BulletXScene.MaxXY/2, BulletXScene.MaxXY/2, 0); _staticPosition = new OpenMetaverse.Vector3(BulletXScene.MaxXY / 2, BulletXScene.MaxXY / 2, 0);
// _staticVelocity = new PhysicsVector(); // _staticVelocity = new PhysicsVector();
// _staticOrientation = OpenMetaverse.Quaternion.Identity; // _staticOrientation = OpenMetaverse.Quaternion.Identity;
_mass = 0; //No active _mass = 0; //No active

View File

@ -28,13 +28,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenSim.Framework; using OpenSim.Framework;
using OpenMetaverse;
namespace OpenSim.Region.Physics.Manager namespace OpenSim.Region.Physics.Manager
{ {
public interface IMesher public interface IMesher
{ {
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod); IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod);
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical); IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
} }
public interface IVertex public interface IVertex
@ -43,7 +44,7 @@ namespace OpenSim.Region.Physics.Manager
public interface IMesh public interface IMesh
{ {
List<PhysicsVector> getVertexList(); List<Vector3> getVertexList();
int[] getIndexListAsInt(); int[] getIndexListAsInt();
int[] getIndexListAsIntLocked(); int[] getIndexListAsIntLocked();
float[] getVertexListAsFloatLocked(); float[] getVertexListAsFloatLocked();

View File

@ -32,8 +32,8 @@ using OpenMetaverse;
namespace OpenSim.Region.Physics.Manager namespace OpenSim.Region.Physics.Manager
{ {
public delegate void PositionUpdate(PhysicsVector position); public delegate void PositionUpdate(Vector3 position);
public delegate void VelocityUpdate(PhysicsVector velocity); public delegate void VelocityUpdate(Vector3 velocity);
public delegate void OrientationUpdate(Quaternion orientation); public delegate void OrientationUpdate(Quaternion orientation);
public enum ActorTypes : int public enum ActorTypes : int
@ -106,7 +106,7 @@ namespace OpenSim.Region.Physics.Manager
{ {
public delegate void RequestTerseUpdate(); public delegate void RequestTerseUpdate();
public delegate void CollisionUpdate(EventArgs e); public delegate void CollisionUpdate(EventArgs e);
public delegate void OutOfBounds(PhysicsVector pos); public delegate void OutOfBounds(Vector3 pos);
// disable warning: public events // disable warning: public events
#pragma warning disable 67 #pragma warning disable 67
@ -125,7 +125,7 @@ namespace OpenSim.Region.Physics.Manager
public abstract bool Stopped { get; } public abstract bool Stopped { get; }
public abstract PhysicsVector Size { get; set; } public abstract Vector3 Size { get; set; }
public abstract PrimitiveBaseShape Shape { set; } public abstract PrimitiveBaseShape Shape { set; }
@ -144,7 +144,7 @@ namespace OpenSim.Region.Physics.Manager
public abstract void delink(); public abstract void delink();
public abstract void LockAngularMotion(PhysicsVector axis); public abstract void LockAngularMotion(Vector3 axis);
public virtual void RequestPhysicsterseUpdate() public virtual void RequestPhysicsterseUpdate()
{ {
@ -159,7 +159,7 @@ namespace OpenSim.Region.Physics.Manager
} }
} }
public virtual void RaiseOutOfBounds(PhysicsVector pos) public virtual void RaiseOutOfBounds(Vector3 pos)
{ {
// Make a temporary copy of the event to avoid possibility of // Make a temporary copy of the event to avoid possibility of
// a race condition if the last subscriber unsubscribes // a race condition if the last subscriber unsubscribes
@ -187,23 +187,23 @@ namespace OpenSim.Region.Physics.Manager
} }
public abstract PhysicsVector Position { get; set; } public abstract Vector3 Position { get; set; }
public abstract float Mass { get; } public abstract float Mass { get; }
public abstract PhysicsVector Force { get; set; } public abstract Vector3 Force { get; set; }
public abstract int VehicleType { get; set; } public abstract int VehicleType { get; set; }
public abstract void VehicleFloatParam(int param, float value); public abstract void VehicleFloatParam(int param, float value);
public abstract void VehicleVectorParam(int param, PhysicsVector value); public abstract void VehicleVectorParam(int param, Vector3 value);
public abstract void VehicleRotationParam(int param, Quaternion rotation); public abstract void VehicleRotationParam(int param, Quaternion rotation);
public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
public abstract PhysicsVector GeometricCenter { get; } public abstract Vector3 GeometricCenter { get; }
public abstract PhysicsVector CenterOfMass { get; } public abstract Vector3 CenterOfMass { get; }
public abstract PhysicsVector Velocity { get; set; } public abstract Vector3 Velocity { get; set; }
public abstract PhysicsVector Torque { get; set; } public abstract Vector3 Torque { get; set; }
public abstract float CollisionScore { get; set;} public abstract float CollisionScore { get; set;}
public abstract PhysicsVector Acceleration { get; } public abstract Vector3 Acceleration { get; }
public abstract Quaternion Orientation { get; set; } public abstract Quaternion Orientation { get; set; }
public abstract int PhysicsActorType { get; set; } public abstract int PhysicsActorType { get; set; }
public abstract bool IsPhysical { get; set; } public abstract bool IsPhysical { get; set; }
@ -214,12 +214,12 @@ namespace OpenSim.Region.Physics.Manager
public abstract bool CollidingGround { get; set; } public abstract bool CollidingGround { get; set; }
public abstract bool CollidingObj { get; set; } public abstract bool CollidingObj { get; set; }
public abstract bool FloatOnWater { set; } public abstract bool FloatOnWater { set; }
public abstract PhysicsVector RotationalVelocity { get; set; } public abstract Vector3 RotationalVelocity { get; set; }
public abstract bool Kinematic { get; set; } public abstract bool Kinematic { get; set; }
public abstract float Buoyancy { get; set; } public abstract float Buoyancy { get; set; }
// Used for MoveTo // Used for MoveTo
public abstract PhysicsVector PIDTarget { set;} public abstract Vector3 PIDTarget { set; }
public abstract bool PIDActive { set;} public abstract bool PIDActive { set;}
public abstract float PIDTau { set; } public abstract float PIDTau { set; }
@ -231,9 +231,9 @@ namespace OpenSim.Region.Physics.Manager
public abstract float PIDHoverTau { set;} public abstract float PIDHoverTau { set;}
public abstract void AddForce(PhysicsVector force, bool pushforce); public abstract void AddForce(Vector3 force, bool pushforce);
public abstract void AddAngularForce(PhysicsVector force, bool pushforce); public abstract void AddAngularForce(Vector3 force, bool pushforce);
public abstract void SetMomentum(PhysicsVector momentum); public abstract void SetMomentum(Vector3 momentum);
public abstract void SubscribeEvents(int ms); public abstract void SubscribeEvents(int ms);
public abstract void UnSubscribeEvents(); public abstract void UnSubscribeEvents();
public abstract bool SubscribedEvents(); public abstract bool SubscribedEvents();
@ -246,9 +246,9 @@ namespace OpenSim.Region.Physics.Manager
get{ return false; } get{ return false; }
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -296,9 +296,9 @@ namespace OpenSim.Region.Physics.Manager
set { return; } set { return; }
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -307,9 +307,9 @@ namespace OpenSim.Region.Physics.Manager
get { return 0f; } get { return 0f; }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -324,7 +324,7 @@ namespace OpenSim.Region.Physics.Manager
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
} }
@ -344,14 +344,14 @@ namespace OpenSim.Region.Physics.Manager
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PrimitiveBaseShape Shape public override PrimitiveBaseShape Shape
@ -359,15 +359,15 @@ namespace OpenSim.Region.Physics.Manager
set { return; } set { return; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -387,9 +387,9 @@ namespace OpenSim.Region.Physics.Manager
set { } set { }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override bool IsPhysical public override bool IsPhysical
@ -436,26 +436,26 @@ namespace OpenSim.Region.Physics.Manager
{ {
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
public override PhysicsVector PIDTarget { set { return; } } public override Vector3 PIDTarget { set { return; } }
public override bool PIDActive { set { return; } } public override bool PIDActive { set { return; } }
public override float PIDTau { set { return; } } public override float PIDTau { set { return; } }
@ -464,7 +464,7 @@ namespace OpenSim.Region.Physics.Manager
public override PIDHoverType PIDHoverType { set { return; } } public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } } public override float PIDHoverTau { set { return; } }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }

View File

@ -44,7 +44,7 @@ namespace OpenSim.Region.Physics.Manager
public PhysicsJointType Type; public PhysicsJointType Type;
public string RawParams; public string RawParams;
public List<string> BodyNames = new List<string>(); public List<string> BodyNames = new List<string>();
public PhysicsVector Position; // global coords public Vector3 Position; // global coords
public Quaternion Rotation; // global coords public Quaternion Rotation; // global coords
public string ObjectNameInScene; // proxy object in scene that represents the joint position/orientation public string ObjectNameInScene; // proxy object in scene that represents the joint position/orientation
public string TrackedBodyName; // body name that this joint is attached to (ObjectNameInScene will follow TrackedBodyName) public string TrackedBodyName; // body name that this joint is attached to (ObjectNameInScene will follow TrackedBodyName)

View File

@ -64,23 +64,23 @@ namespace OpenSim.Region.Physics.Manager
public abstract void Initialise(IMesher meshmerizer, IConfigSource config); public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
public abstract PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying); public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying);
public abstract void RemoveAvatar(PhysicsActor actor); public abstract void RemoveAvatar(PhysicsActor actor);
public abstract void RemovePrim(PhysicsActor prim); public abstract void RemovePrim(PhysicsActor prim);
public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation); //To be removed Vector3 size, Quaternion rotation); //To be removed
public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation, bool isPhysical); Vector3 size, Quaternion rotation, bool isPhysical);
public virtual bool SupportsNINJAJoints public virtual bool SupportsNINJAJoints
{ {
get { return false; } get { return false; }
} }
public virtual PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, PhysicsVector position, public virtual PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation) Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
{ return null; } { return null; }
@ -129,11 +129,11 @@ namespace OpenSim.Region.Physics.Manager
} }
} }
public virtual PhysicsVector GetJointAnchor(PhysicsJoint joint) public virtual Vector3 GetJointAnchor(PhysicsJoint joint)
{ return null; } { return Vector3.Zero; }
public virtual PhysicsVector GetJointAxis(PhysicsJoint joint) public virtual Vector3 GetJointAxis(PhysicsJoint joint)
{ return null; } { return Vector3.Zero; }
public abstract void AddPhysicsActorTaint(PhysicsActor prim); public abstract void AddPhysicsActorTaint(PhysicsActor prim);
@ -212,7 +212,7 @@ namespace OpenSim.Region.Physics.Manager
// Does nothing right now // Does nothing right now
} }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
{ {
m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position); m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position);
return PhysicsActor.Null; return PhysicsActor.Null;
@ -231,21 +231,21 @@ namespace OpenSim.Region.Physics.Manager
} }
/* /*
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
{ {
m_log.InfoFormat("NullPhysicsScene : AddPrim({0},{1})", position, size); m_log.InfoFormat("NullPhysicsScene : AddPrim({0},{1})", position, size);
return PhysicsActor.Null; return PhysicsActor.Null;
} }
*/ */
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation) //To be removed Vector3 size, Quaternion rotation) //To be removed
{ {
return AddPrimShape(primName, pbs, position, size, rotation, false); return AddPrimShape(primName, pbs, position, size, rotation, false);
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation, bool isPhysical) Vector3 size, Quaternion rotation, bool isPhysical)
{ {
m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size); m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size);
return PhysicsActor.Null; return PhysicsActor.Null;

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Timers; using System.Timers;
using OpenMetaverse;
namespace OpenSim.Region.Physics.Manager namespace OpenSim.Region.Physics.Manager
{ {
@ -46,7 +47,7 @@ namespace OpenSim.Region.Physics.Manager
{ {
get { return new NullPhysicsSensor(); } get { return new NullPhysicsSensor(); }
} }
public abstract PhysicsVector Position {get; set;} public abstract Vector3 Position { get; set; }
public abstract void TimerCallback (object obj, ElapsedEventArgs eea); public abstract void TimerCallback (object obj, ElapsedEventArgs eea);
public abstract float radianarc {get; set;} public abstract float radianarc {get; set;}
public abstract string targetname {get; set;} public abstract string targetname {get; set;}
@ -58,9 +59,9 @@ namespace OpenSim.Region.Physics.Manager
public class NullPhysicsSensor : PhysicsSensor public class NullPhysicsSensor : PhysicsSensor
{ {
public override PhysicsVector Position public override Vector3 Position
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
public override void TimerCallback(object obj, ElapsedEventArgs eea) public override void TimerCallback(object obj, ElapsedEventArgs eea)

View File

@ -29,24 +29,24 @@ using System;
namespace OpenSim.Region.Physics.Manager namespace OpenSim.Region.Physics.Manager
{ {
public class PhysicsVector /*public class PhysicsVector
{ {
public float X; public float X;
public float Y; public float Y;
public float Z; public float Z;
public PhysicsVector() public Vector3()
{ {
} }
public PhysicsVector(float x, float y, float z) public Vector3(float x, float y, float z)
{ {
X = x; X = x;
Y = y; Y = y;
Z = z; Z = z;
} }
public PhysicsVector(PhysicsVector pv) : this(pv.X, pv.Y, pv.Z) public Vector3(Vector3 pv) : this(pv.X, pv.Y, pv.Z)
{ {
} }
@ -115,17 +115,17 @@ namespace OpenSim.Region.Physics.Manager
} }
// Operations // Operations
public static PhysicsVector operator +(PhysicsVector a, PhysicsVector b) public static PhysicsVector operator +(Vector3 a, Vector3 b)
{ {
return new PhysicsVector(a.X + b.X, a.Y + b.Y, a.Z + b.Z); return new PhysicsVector(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
} }
public static PhysicsVector operator -(PhysicsVector a, PhysicsVector b) public static PhysicsVector operator -(Vector3 a, Vector3 b)
{ {
return new PhysicsVector(a.X - b.X, a.Y - b.Y, a.Z - b.Z); return new PhysicsVector(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
} }
public static PhysicsVector cross(PhysicsVector a, PhysicsVector b) public static PhysicsVector cross(Vector3 a, Vector3 b)
{ {
return new PhysicsVector(a.Y*b.Z - a.Z*b.Y, a.Z*b.X - a.X*b.Z, a.X*b.Y - a.Y*b.X); return new PhysicsVector(a.Y*b.Z - a.Z*b.Y, a.Z*b.X - a.X*b.Z, a.X*b.Y - a.Y*b.X);
} }
@ -135,7 +135,7 @@ namespace OpenSim.Region.Physics.Manager
return (float) Math.Sqrt(X*X + Y*Y + Z*Z); return (float) Math.Sqrt(X*X + Y*Y + Z*Z);
} }
public static float GetDistanceTo(PhysicsVector a, PhysicsVector b) public static float GetDistanceTo(Vector3 a, Vector3 b)
{ {
float dx = a.X - b.X; float dx = a.X - b.X;
float dy = a.Y - b.Y; float dy = a.Y - b.Y;
@ -143,22 +143,22 @@ namespace OpenSim.Region.Physics.Manager
return (float) Math.Sqrt(dx * dx + dy * dy + dz * dz); return (float) Math.Sqrt(dx * dx + dy * dy + dz * dz);
} }
public static PhysicsVector operator /(PhysicsVector v, float f) public static PhysicsVector operator /(Vector3 v, float f)
{ {
return new PhysicsVector(v.X/f, v.Y/f, v.Z/f); return new PhysicsVector(v.X/f, v.Y/f, v.Z/f);
} }
public static PhysicsVector operator *(PhysicsVector v, float f) public static PhysicsVector operator *(Vector3 v, float f)
{ {
return new PhysicsVector(v.X*f, v.Y*f, v.Z*f); return new PhysicsVector(v.X*f, v.Y*f, v.Z*f);
} }
public static PhysicsVector operator *(float f, PhysicsVector v) public static PhysicsVector operator *(float f, Vector3 v)
{ {
return v*f; return v*f;
} }
public static bool isFinite(PhysicsVector v) public static bool isFinite(Vector3 v)
{ {
if (v == null) if (v == null)
return false; return false;
@ -172,7 +172,7 @@ namespace OpenSim.Region.Physics.Manager
return true; return true;
} }
public virtual bool IsIdentical(PhysicsVector v, float tolerance) public virtual bool IsIdentical(Vector3 v, float tolerance)
{ {
PhysicsVector diff = this - v; PhysicsVector diff = this - v;
float d = diff.length(); float d = diff.length();
@ -182,5 +182,5 @@ namespace OpenSim.Region.Physics.Manager
return false; return false;
} }
} }*/
} }

View File

@ -27,6 +27,7 @@
using System; using System;
using OpenSim.Framework; using OpenSim.Framework;
using OpenMetaverse;
/* /*
* This is the zero mesher. * This is the zero mesher.
@ -60,12 +61,12 @@ namespace OpenSim.Region.Physics.Manager
public class ZeroMesher : IMesher public class ZeroMesher : IMesher
{ {
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
{ {
return CreateMesh(primName, primShape, size, lod, false); return CreateMesh(primName, primShape, size, lod, false);
} }
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
{ {
// Remove the reference to the encoded JPEG2000 data so it can be GCed // Remove the reference to the encoded JPEG2000 data so it can be GCed
primShape.SculptData = OpenMetaverse.Utils.EmptyBytes; primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;

View File

@ -33,30 +33,52 @@ using OpenMetaverse;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using OpenSim.Region.Physics.Meshing; using OpenSim.Region.Physics.Meshing;
public class Vertex : PhysicsVector, IComparable<Vertex> public class Vertex : IComparable<Vertex>
{ {
public Vertex(float x, float y, float z) Vector3 vector;
: base(x, y, z)
public float X
{ {
get { return vector.X; }
set { vector.X = value; }
}
public float Y
{
get { return vector.Y; }
set { vector.Y = value; }
}
public float Z
{
get { return vector.Z; }
set { vector.Z = value; }
}
public Vertex(float x, float y, float z)
{
vector.X = x;
vector.Y = y;
vector.Z = z;
} }
public Vertex normalize() public Vertex normalize()
{ {
float tlength = length(); float tlength = vector.Length();
if (tlength != 0) if (tlength != 0f)
{ {
float mul = 1.0f / tlength; float mul = 1.0f / tlength;
return new Vertex(X * mul, Y * mul, Z * mul); return new Vertex(vector.X * mul, vector.Y * mul, vector.Z * mul);
} }
else else
{ {
return new Vertex(0, 0, 0); return new Vertex(0f, 0f, 0f);
} }
} }
public Vertex cross(Vertex v) public Vertex cross(Vertex v)
{ {
return new Vertex(Y * v.Z - Z * v.Y, Z * v.X - X * v.Z, X * v.Y - Y * v.X); return new Vertex(vector.Y * v.Z - vector.Z * v.Y, vector.Z * v.X - vector.X * v.Z, vector.X * v.Y - vector.Y * v.X);
} }
// disable warning: mono compiler moans about overloading // disable warning: mono compiler moans about overloading
@ -160,9 +182,9 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
return X * v.X + Y * v.Y + Z * v.Z; return X * v.X + Y * v.Y + Z * v.Z;
} }
public Vertex(PhysicsVector v) public Vertex(Vector3 v)
: base(v.X, v.Y, v.Z)
{ {
vector = v;
} }
public Vertex Clone() public Vertex Clone()
@ -175,11 +197,15 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f); return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f);
} }
public float Length()
{
return vector.Length();
}
public virtual bool Equals(Vertex v, float tolerance) public virtual bool Equals(Vertex v, float tolerance)
{ {
PhysicsVector diff = this - v; Vertex diff = this - v;
float d = diff.length(); float d = diff.Length();
if (d < tolerance) if (d < tolerance)
return true; return true;
@ -369,22 +395,22 @@ public class Triangle
return s1 + ";" + s2 + ";" + s3; return s1 + ";" + s2 + ";" + s3;
} }
public PhysicsVector getNormal() public Vector3 getNormal()
{ {
// Vertices // Vertices
// Vectors for edges // Vectors for edges
PhysicsVector e1; Vector3 e1;
PhysicsVector e2; Vector3 e2;
e1 = new PhysicsVector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z); e1 = new Vector3(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
e2 = new PhysicsVector(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z); e2 = new Vector3(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z);
// Cross product for normal // Cross product for normal
PhysicsVector n = PhysicsVector.cross(e1, e2); Vector3 n = Vector3.Cross(e1, e2);
// Length // Length
float l = n.length(); float l = n.Length();
// Normalized "normal" // Normalized "normal"
n = n/l; n = n/l;

View File

@ -31,6 +31,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using PrimMesher; using PrimMesher;
using OpenMetaverse;
namespace OpenSim.Region.Physics.Meshing namespace OpenSim.Region.Physics.Meshing
{ {
@ -141,12 +142,12 @@ namespace OpenSim.Region.Physics.Meshing
} }
} }
public List<PhysicsVector> getVertexList() public List<Vector3> getVertexList()
{ {
List<PhysicsVector> result = new List<PhysicsVector>(); List<Vector3> result = new List<Vector3>();
foreach (Vertex v in m_vertices.Keys) foreach (Vertex v in m_vertices.Keys)
{ {
result.Add(v); result.Add(new Vector3(v.X, v.Y, v.Z));
} }
return result; return result;
} }

View File

@ -61,7 +61,6 @@ namespace OpenSim.Region.Physics.Meshing
public class Meshmerizer : IMesher public class Meshmerizer : IMesher
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
//private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Setting baseDir to a path will enable the dumping of raw files // Setting baseDir to a path will enable the dumping of raw files
// raw files can be imported by blender so a visual inspection of the results can be done // raw files can be imported by blender so a visual inspection of the results can be done
@ -160,7 +159,7 @@ namespace OpenSim.Region.Physics.Meshing
float minZ = float.MaxValue; float minZ = float.MaxValue;
float maxZ = float.MinValue; float maxZ = float.MinValue;
foreach (Vertex v in meshIn.getVertexList()) foreach (Vector3 v in meshIn.getVertexList())
{ {
if (v != null) if (v != null)
{ {
@ -185,7 +184,7 @@ namespace OpenSim.Region.Physics.Meshing
} }
private ulong GetMeshKey(PrimitiveBaseShape pbs, PhysicsVector size, float lod) private ulong GetMeshKey(PrimitiveBaseShape pbs, Vector3 size, float lod)
{ {
ulong hash = 5381; ulong hash = 5381;
@ -247,7 +246,7 @@ namespace OpenSim.Region.Physics.Meshing
} }
private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
{ {
PrimMesh primMesh; PrimMesh primMesh;
PrimMesher.SculptMesh sculptMesh; PrimMesher.SculptMesh sculptMesh;
@ -289,9 +288,6 @@ namespace OpenSim.Region.Physics.Meshing
ManagedImage managedImage; // we never use this ManagedImage managedImage; // we never use this
OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata); OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata);
// Remove the reference to the encoded JPEG2000 data so it can be GCed
primShape.SculptData = Utils.EmptyBytes;
if (cacheSculptMaps) if (cacheSculptMaps)
{ {
try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); }
@ -315,8 +311,6 @@ namespace OpenSim.Region.Physics.Meshing
} }
} }
PrimMesher.SculptMesh.SculptType sculptType; PrimMesher.SculptMesh.SculptType sculptType;
switch ((OpenMetaverse.SculptType)primShape.SculptType) switch ((OpenMetaverse.SculptType)primShape.SculptType)
{ {
@ -351,7 +345,6 @@ namespace OpenSim.Region.Physics.Meshing
coords = sculptMesh.coords; coords = sculptMesh.coords;
faces = sculptMesh.faces; faces = sculptMesh.faces;
} }
else else
{ {
float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f; float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f;
@ -466,6 +459,8 @@ namespace OpenSim.Region.Physics.Meshing
faces = primMesh.faces; faces = primMesh.faces;
} }
// Remove the reference to any JPEG2000 sculpt data so it can be GCed
primShape.SculptData = Utils.EmptyBytes;
int numCoords = coords.Count; int numCoords = coords.Count;
int numFaces = faces.Count; int numFaces = faces.Count;
@ -488,12 +483,12 @@ namespace OpenSim.Region.Physics.Meshing
return mesh; return mesh;
} }
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
{ {
return CreateMesh(primName, primShape, size, lod, false); return CreateMesh(primName, primShape, size, lod, false);
} }
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
{ {
Mesh mesh = null; Mesh mesh = null;
ulong key = 0; ulong key = 0;

View File

@ -68,15 +68,15 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private PhysicsVector _position; private Vector3 _position;
private d.Vector3 _zeroPosition; private d.Vector3 _zeroPosition;
// private d.Matrix3 m_StandUpRotation; // private d.Matrix3 m_StandUpRotation;
private bool _zeroFlag = false; private bool _zeroFlag = false;
private bool m_lastUpdateSent = false; private bool m_lastUpdateSent = false;
private PhysicsVector _velocity; private Vector3 _velocity;
private PhysicsVector _target_velocity; private Vector3 _target_velocity;
private PhysicsVector _acceleration; private Vector3 _acceleration;
private PhysicsVector m_rotationalVelocity; private Vector3 m_rotationalVelocity;
private float m_mass = 80f; private float m_mass = 80f;
public float m_density = 60f; public float m_density = 60f;
private bool m_pidControllerActive = true; private bool m_pidControllerActive = true;
@ -99,7 +99,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_hackSentFall = false; private bool m_hackSentFall = false;
private bool m_hackSentFly = false; private bool m_hackSentFly = false;
private int m_requestedUpdateFrequency = 0; private int m_requestedUpdateFrequency = 0;
private PhysicsVector m_taintPosition = new PhysicsVector(0, 0, 0); private Vector3 m_taintPosition = Vector3.Zero;
public uint m_localID = 0; public uint m_localID = 0;
public bool m_returnCollisions = false; public bool m_returnCollisions = false;
// taints and their non-tainted counterparts // taints and their non-tainted counterparts
@ -143,22 +143,17 @@ namespace OpenSim.Region.Physics.OdePlugin
public UUID m_uuid; public UUID m_uuid;
public bool bad = false; public bool bad = false;
public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, CollisionLocker dode, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
{ {
m_uuid = UUID.Random(); m_uuid = UUID.Random();
// ode = dode; if (pos.IsFinite())
_velocity = new PhysicsVector();
_target_velocity = new PhysicsVector();
if (PhysicsVector.isFinite(pos))
{ {
if (pos.Z > 9999999) if (pos.Z > 9999999f)
{ {
pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
} }
if (pos.Z < -90000) if (pos.Z < -90000f)
{ {
pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
} }
@ -169,15 +164,13 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
_position = new PhysicsVector(((int)_parent_scene.WorldExtents.X * 0.5f), ((int)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128, 128) + 10); _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
m_taintPosition.X = _position.X; m_taintPosition.X = _position.X;
m_taintPosition.Y = _position.Y; m_taintPosition.Y = _position.Y;
m_taintPosition.Z = _position.Z; m_taintPosition.Z = _position.Z;
m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
} }
_acceleration = new PhysicsVector();
_parent_scene = parent_scene; _parent_scene = parent_scene;
PID_D = pid_d; PID_D = pid_d;
@ -189,7 +182,6 @@ namespace OpenSim.Region.Physics.OdePlugin
walkDivisor = walk_divisor; walkDivisor = walk_divisor;
runDivisor = rundivisor; runDivisor = rundivisor;
// m_StandUpRotation = // m_StandUpRotation =
// new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f, // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f,
// 0.5f); // 0.5f);
@ -205,7 +197,6 @@ namespace OpenSim.Region.Physics.OdePlugin
m_isPhysical = false; // current status: no ODE information exists m_isPhysical = false; // current status: no ODE information exists
m_tainted_isPhysical = true; // new tainted status: need to create ODE information m_tainted_isPhysical = true; // new tainted status: need to create ODE information
_parent_scene.AddPhysicsActorTaint(this); _parent_scene.AddPhysicsActorTaint(this);
m_name = avName; m_name = avName;
@ -412,20 +403,20 @@ namespace OpenSim.Region.Physics.OdePlugin
/// Not really a good choice unless you 'know' it's a good /// Not really a good choice unless you 'know' it's a good
/// spot otherwise you're likely to orbit the avatar. /// spot otherwise you're likely to orbit the avatar.
/// </summary> /// </summary>
public override PhysicsVector Position public override Vector3 Position
{ {
get { return _position; } get { return _position; }
set set
{ {
if (Body == IntPtr.Zero || Shell == IntPtr.Zero) if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
if (value.Z > 9999999) if (value.Z > 9999999f)
{ {
value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
} }
if (value.Z < -90000) if (value.Z < -90000f)
{ {
value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
} }
@ -447,7 +438,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
@ -457,20 +448,20 @@ namespace OpenSim.Region.Physics.OdePlugin
/// This property sets the height of the avatar only. We use the height to make sure the avatar stands up straight /// This property sets the height of the avatar only. We use the height to make sure the avatar stands up straight
/// and use it to offset landings properly /// and use it to offset landings properly
/// </summary> /// </summary>
public override PhysicsVector Size public override Vector3 Size
{ {
get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
set set
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
m_pidControllerActive = true; m_pidControllerActive = true;
PhysicsVector SetSize = value; Vector3 SetSize = value;
m_tainted_CAPSULE_LENGTH = (SetSize.Z*1.15f) - CAPSULE_RADIUS*2.0f; m_tainted_CAPSULE_LENGTH = (SetSize.Z*1.15f) - CAPSULE_RADIUS*2.0f;
//m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
Velocity = new PhysicsVector(0f, 0f, 0f); Velocity = Vector3.Zero;
_parent_scene.AddPhysicsActorTaint(this); _parent_scene.AddPhysicsActorTaint(this);
} }
@ -481,7 +472,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
private void AlignAvatarTiltWithCurrentDirectionOfMovement(PhysicsVector movementVector) private void AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3 movementVector)
{ {
movementVector.Z = 0f; movementVector.Z = 0f;
float magnitude = (float)Math.Sqrt((double)(movementVector.X * movementVector.X + movementVector.Y * movementVector.Y)); float magnitude = (float)Math.Sqrt((double)(movementVector.X * movementVector.X + movementVector.Y * movementVector.Y));
@ -643,7 +634,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// (with -0..0 motor stops) falls into the terrain for reasons yet // (with -0..0 motor stops) falls into the terrain for reasons yet
// to be comprehended in their entirety. // to be comprehended in their entirety.
#endregion #endregion
AlignAvatarTiltWithCurrentDirectionOfMovement(new PhysicsVector(0,0,0)); AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f); d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f); d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f); d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
@ -688,7 +679,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
} }
@ -716,9 +707,9 @@ namespace OpenSim.Region.Physics.OdePlugin
// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); // //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
// } // }
public override PhysicsVector Force public override Vector3 Force
{ {
get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); } get { return _target_velocity; }
set { return; } set { return; }
} }
@ -733,7 +724,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
} }
@ -748,14 +739,14 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PrimitiveBaseShape Shape public override PrimitiveBaseShape Shape
@ -763,18 +754,18 @@ namespace OpenSim.Region.Physics.OdePlugin
set { return; } set { return; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get { get {
// There's a problem with PhysicsVector.Zero! Don't Use it Here! // There's a problem with Vector3.Zero! Don't Use it Here!
if (_zeroFlag) if (_zeroFlag)
return new PhysicsVector(0f, 0f, 0f); return Vector3.Zero;
m_lastUpdateSent = false; m_lastUpdateSent = false;
return _velocity; return _velocity;
} }
set set
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
m_pidControllerActive = true; m_pidControllerActive = true;
_target_velocity = value; _target_velocity = value;
@ -786,9 +777,9 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -814,12 +805,12 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
public void SetAcceleration(PhysicsVector accel) public void SetAcceleration(Vector3 accel)
{ {
m_pidControllerActive = true; m_pidControllerActive = true;
_acceleration = accel; _acceleration = accel;
@ -830,9 +821,9 @@ namespace OpenSim.Region.Physics.OdePlugin
/// The PID controller takes this target velocity and tries to make it a reality /// The PID controller takes this target velocity and tries to make it a reality
/// </summary> /// </summary>
/// <param name="force"></param> /// <param name="force"></param>
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
if (PhysicsVector.isFinite(force)) if (force.IsFinite())
{ {
if (pushforce) if (pushforce)
{ {
@ -861,7 +852,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//m_lastUpdateSent = false; //m_lastUpdateSent = false;
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
} }
@ -870,7 +861,7 @@ namespace OpenSim.Region.Physics.OdePlugin
/// After all of the forces add up with 'add force' we apply them with doForce /// After all of the forces add up with 'add force' we apply them with doForce
/// </summary> /// </summary>
/// <param name="force"></param> /// <param name="force"></param>
public void doForce(PhysicsVector force) public void doForce(Vector3 force)
{ {
if (!collidelock) if (!collidelock)
{ {
@ -881,7 +872,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
@ -908,9 +899,9 @@ namespace OpenSim.Region.Physics.OdePlugin
//PidStatus = true; //PidStatus = true;
d.Vector3 localpos = d.BodyGetPosition(Body); d.Vector3 localpos = d.BodyGetPosition(Body);
PhysicsVector localPos = new PhysicsVector(localpos.X, localpos.Y, localpos.Z); Vector3 localPos = new Vector3(localpos.X, localpos.Y, localpos.Z);
if (!PhysicsVector.isFinite(localPos)) if (!localPos.IsFinite())
{ {
m_log.Warn("[PHYSICS]: Avatar Position is non-finite!"); m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
@ -946,7 +937,7 @@ namespace OpenSim.Region.Physics.OdePlugin
return; return;
} }
PhysicsVector vec = new PhysicsVector(); Vector3 vec = Vector3.Zero;
d.Vector3 vel = d.BodyGetLinearVel(Body); d.Vector3 vel = d.BodyGetLinearVel(Body);
float movementdivisor = 1f; float movementdivisor = 1f;
@ -1059,12 +1050,12 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
// end add Kitto Flora // end add Kitto Flora
} }
if (PhysicsVector.isFinite(vec)) if (vec.IsFinite())
{ {
doForce(vec); doForce(vec);
if (!_zeroFlag) if (!_zeroFlag)
{ {
AlignAvatarTiltWithCurrentDirectionOfMovement(new PhysicsVector(vec.X, vec.Y, vec.Z)); AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
} }
} }
else else
@ -1197,7 +1188,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
} }
public override PhysicsVector PIDTarget { set { return; } } public override Vector3 PIDTarget { set { return; } }
public override bool PIDActive { set { return; } } public override bool PIDActive { set { return; } }
public override float PIDTau { set { return; } } public override float PIDTau { set { return; } }
@ -1311,7 +1302,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomDestroy(Shell); d.GeomDestroy(Shell);
AvatarGeomAndBodyCreation(_position.X, _position.Y, AvatarGeomAndBodyCreation(_position.X, _position.Y,
_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
Velocity = new PhysicsVector(0f, 0f, 0f); Velocity = Vector3.Zero;
_parent_scene.geom_name_map[Shell] = m_name; _parent_scene.geom_name_map[Shell] = m_name;
_parent_scene.actor_name_map[Shell] = (PhysicsActor)this; _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
@ -1325,7 +1316,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
if (!m_taintPosition.IsIdentical(_position, 0.05f)) if (!m_taintPosition.ApproxEquals(_position, 0.05f))
{ {
if (Body != IntPtr.Zero) if (Body != IntPtr.Zero)
{ {

View File

@ -232,7 +232,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}//end ProcessFloatVehicleParam }//end ProcessFloatVehicleParam
internal void ProcessVectorVehicleParam(Vehicle pParam, PhysicsVector pValue) internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue)
{ {
switch (pParam) switch (pParam)
{ {

View File

@ -57,44 +57,43 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private PhysicsVector _position; private Vector3 _position;
private PhysicsVector _velocity; private Vector3 _velocity;
private PhysicsVector _torque = new PhysicsVector(0,0,0); private Vector3 _torque;
private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); private Vector3 m_lastVelocity;
private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); private Vector3 m_lastposition;
private Quaternion m_lastorientation = new Quaternion(); private Quaternion m_lastorientation = new Quaternion();
private PhysicsVector m_rotationalVelocity; private Vector3 m_rotationalVelocity;
private PhysicsVector _size; private Vector3 _size;
private PhysicsVector _acceleration; private Vector3 _acceleration;
// private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f); // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
private Quaternion _orientation; private Quaternion _orientation;
private PhysicsVector m_taintposition; private Vector3 m_taintposition;
private PhysicsVector m_taintsize; private Vector3 m_taintsize;
private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); private Vector3 m_taintVelocity;
private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); private Vector3 m_taintTorque;
private Quaternion m_taintrot; private Quaternion m_taintrot;
private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); private Vector3 m_angularlock = Vector3.One;
private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); private Vector3 m_taintAngularLock = Vector3.One;
private IntPtr Amotor = IntPtr.Zero; private IntPtr Amotor = IntPtr.Zero;
private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); private Vector3 m_PIDTarget;
// private PhysicsVector m_taintPIDTarget = new PhysicsVector(0, 0, 0); private float m_PIDTau;
private float m_PIDTau = 0f;
private float PID_D = 35f; private float PID_D = 35f;
private float PID_G = 25f; private float PID_G = 25f;
private bool m_usePID = false; private bool m_usePID;
// KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
// and are for non-VEHICLES only. // and are for non-VEHICLES only.
private float m_PIDHoverHeight = 0f; private float m_PIDHoverHeight;
private float m_PIDHoverTau = 0f; private float m_PIDHoverTau;
private bool m_useHoverPID = false; private bool m_useHoverPID;
private PIDHoverType m_PIDHoverType = PIDHoverType.Ground; private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
private float m_targetHoverHeight = 0f; private float m_targetHoverHeight;
private float m_groundHeight = 0f; private float m_groundHeight;
private float m_waterHeight = 0f; private float m_waterHeight;
private float m_buoyancy = 0f; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
// private float m_tensor = 5f; // private float m_tensor = 5f;
private int body_autodisable_frames = 20; private int body_autodisable_frames = 20;
@ -105,11 +104,11 @@ namespace OpenSim.Region.Physics.OdePlugin
| CollisionCategories.Body | CollisionCategories.Body
| CollisionCategories.Character | CollisionCategories.Character
); );
private bool m_taintshape = false; private bool m_taintshape;
private bool m_taintPhysics = false; private bool m_taintPhysics;
private bool m_collidesLand = true; private bool m_collidesLand = true;
private bool m_collidesWater = false; private bool m_collidesWater;
public bool m_returnCollisions = false; public bool m_returnCollisions;
// Default we're a Geometry // Default we're a Geometry
private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@ -117,85 +116,83 @@ namespace OpenSim.Region.Physics.OdePlugin
// Default, Collide with Other Geometries, spaces and Bodies // Default, Collide with Other Geometries, spaces and Bodies
private CollisionCategories m_collisionFlags = m_default_collisionFlags; private CollisionCategories m_collisionFlags = m_default_collisionFlags;
public bool m_taintremove = false; public bool m_taintremove;
public bool m_taintdisable = false; public bool m_taintdisable;
public bool m_disabled = false; public bool m_disabled;
public bool m_taintadd = false; public bool m_taintadd;
public bool m_taintselected = false; public bool m_taintselected;
public bool m_taintCollidesWater = false; public bool m_taintCollidesWater;
public uint m_localID = 0; public uint m_localID;
//public GCHandle gc; //public GCHandle gc;
private CollisionLocker ode; private CollisionLocker ode;
private bool m_taintforce = false; private bool m_taintforce = false;
private bool m_taintaddangularforce = false; private bool m_taintaddangularforce = false;
private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); private Vector3 m_force;
private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); private List<Vector3> m_forcelist = new List<Vector3>();
private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>(); private List<Vector3> m_angularforcelist = new List<Vector3>();
private IMesh _mesh; private IMesh _mesh;
private PrimitiveBaseShape _pbs; private PrimitiveBaseShape _pbs;
private OdeScene _parent_scene; private OdeScene _parent_scene;
public IntPtr m_targetSpace = (IntPtr) 0; public IntPtr m_targetSpace = IntPtr.Zero;
public IntPtr prim_geom; public IntPtr prim_geom;
public IntPtr prev_geom; public IntPtr prev_geom;
public IntPtr _triMeshData; public IntPtr _triMeshData;
private IntPtr _linkJointGroup = (IntPtr)0; private IntPtr _linkJointGroup = IntPtr.Zero;
private PhysicsActor _parent = null; private PhysicsActor _parent;
private PhysicsActor m_taintparent = null; private PhysicsActor m_taintparent;
private List<OdePrim> childrenPrim = new List<OdePrim>(); private List<OdePrim> childrenPrim = new List<OdePrim>();
private bool iscolliding = false; private bool iscolliding;
private bool m_isphysical = false; private bool m_isphysical;
private bool m_isSelected = false; private bool m_isSelected;
internal bool m_isVolumeDetect = false; // If true, this prim only detects collisions but doesn't collide actively internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
private bool m_throttleUpdates = false; private bool m_throttleUpdates;
private int throttleCounter = 0; private int throttleCounter;
public int m_interpenetrationcount = 0; public int m_interpenetrationcount;
public float m_collisionscore = 0; public float m_collisionscore;
public int m_roundsUnderMotionThreshold = 0; public int m_roundsUnderMotionThreshold;
private int m_crossingfailures = 0; private int m_crossingfailures;
public bool outofBounds = false; public bool outofBounds;
private float m_density = 10.000006836f; // Aluminum g/cm3; private float m_density = 10.000006836f; // Aluminum g/cm3;
public bool _zeroFlag = false; public bool _zeroFlag;
private bool m_lastUpdateSent = false; private bool m_lastUpdateSent;
public IntPtr Body = (IntPtr) 0; public IntPtr Body = IntPtr.Zero;
public String m_primName; public String m_primName;
// private String m_primName; private Vector3 _target_velocity;
private PhysicsVector _target_velocity;
public d.Mass pMass; public d.Mass pMass;
public int m_eventsubscription = 0; public int m_eventsubscription;
private CollisionEventUpdate CollisionEventsThisFrame = null; private CollisionEventUpdate CollisionEventsThisFrame;
private IntPtr m_linkJoint = (IntPtr)0; private IntPtr m_linkJoint = IntPtr.Zero;
public volatile bool childPrim = false; public volatile bool childPrim;
private ODEDynamics m_vehicle; private ODEDynamics m_vehicle;
internal int m_material = (int)Material.Wood; internal int m_material = (int)Material.Wood;
public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
{ {
_target_velocity = new PhysicsVector(0, 0, 0);
m_vehicle = new ODEDynamics(); m_vehicle = new ODEDynamics();
//gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
ode = dode; ode = dode;
_velocity = new PhysicsVector(); if (!pos.IsFinite())
if (!PhysicsVector.isFinite(pos))
{ {
pos = new PhysicsVector(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), parent_scene.GetTerrainHeightAtXY(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f)) + 0.5f); pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f),
parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f);
m_log.Warn("[PHYSICS]: Got nonFinite Object create Position"); m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
} }
_position = pos; _position = pos;
@ -210,9 +207,9 @@ namespace OpenSim.Region.Physics.OdePlugin
prim_geom = IntPtr.Zero; prim_geom = IntPtr.Zero;
prev_geom = IntPtr.Zero; prev_geom = IntPtr.Zero;
if (!PhysicsVector.isFinite(pos)) if (!pos.IsFinite())
{ {
size = new PhysicsVector(0.5f, 0.5f, 0.5f); size = new Vector3(0.5f, 0.5f, 0.5f);
m_log.Warn("[PHYSICS]: Got nonFinite Object create Size"); m_log.Warn("[PHYSICS]: Got nonFinite Object create Size");
} }
@ -222,8 +219,6 @@ namespace OpenSim.Region.Physics.OdePlugin
_size = size; _size = size;
m_taintsize = _size; m_taintsize = _size;
_acceleration = new PhysicsVector();
m_rotationalVelocity = PhysicsVector.Zero;
if (!QuaternionIsFinite(rotation)) if (!QuaternionIsFinite(rotation))
{ {
@ -388,7 +383,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_disabled = false; m_disabled = false;
// The body doesn't already have a finite rotation mode set here // The body doesn't already have a finite rotation mode set here
if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0.0f)) && _parent == null)
{ {
createAMotor(m_angularlock); createAMotor(m_angularlock);
} }
@ -882,7 +877,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (prim_geom != IntPtr.Zero) if (prim_geom != IntPtr.Zero)
{ {
if (!_position.IsIdentical(m_taintposition,0f)) if (!_position.ApproxEquals(m_taintposition, 0f))
changemove(timestep); changemove(timestep);
if (m_taintrot != _orientation) if (m_taintrot != _orientation)
@ -907,7 +902,7 @@ namespace OpenSim.Region.Physics.OdePlugin
changePhysicsStatus(timestep); changePhysicsStatus(timestep);
// //
if (!_size.IsIdentical(m_taintsize,0)) if (!_size.ApproxEquals(m_taintsize,0f))
changesize(timestep); changesize(timestep);
// //
@ -921,7 +916,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_taintaddangularforce) if (m_taintaddangularforce)
changeAddAngularForce(timestep); changeAddAngularForce(timestep);
if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
changeSetTorque(timestep); changeSetTorque(timestep);
if (m_taintdisable) if (m_taintdisable)
@ -930,7 +925,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_taintselected != m_isSelected) if (m_taintselected != m_isSelected)
changeSelectedStatus(timestep); changeSelectedStatus(timestep);
if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
changevelocity(timestep); changevelocity(timestep);
if (m_taintparent != _parent) if (m_taintparent != _parent)
@ -939,7 +934,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_taintCollidesWater != m_collidesWater) if (m_taintCollidesWater != m_collidesWater)
changefloatonwater(timestep); changefloatonwater(timestep);
if (!m_angularlock.IsIdentical(m_taintAngularLock,0)) if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
changeAngularLock(timestep); changeAngularLock(timestep);
} }
@ -959,7 +954,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//If we have a parent then we're not authorative here //If we have a parent then we're not authorative here
if (_parent == null) if (_parent == null)
{ {
if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f,1f,1f), 0)) if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
{ {
//d.BodySetFiniteRotationMode(Body, 0); //d.BodySetFiniteRotationMode(Body, 0);
//d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@ -976,7 +971,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
// Store this for later in case we get turned into a separate body // Store this for later in case we get turned into a separate body
m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); m_angularlock = m_taintAngularLock;
} }
@ -1120,7 +1115,7 @@ namespace OpenSim.Region.Physics.OdePlugin
prm.m_disabled = false; prm.m_disabled = false;
// The body doesn't already have a finite rotation mode set here // The body doesn't already have a finite rotation mode set here
if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
{ {
prm.createAMotor(m_angularlock); prm.createAMotor(m_angularlock);
} }
@ -1163,7 +1158,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_disabled = false; m_disabled = false;
// The body doesn't already have a finite rotation mode set here // The body doesn't already have a finite rotation mode set here
if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
{ {
createAMotor(m_angularlock); createAMotor(m_angularlock);
} }
@ -1347,7 +1342,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_taintshape = false; m_taintshape = false;
m_taintforce = false; m_taintforce = false;
m_taintdisable = false; m_taintdisable = false;
m_taintVelocity = PhysicsVector.Zero; m_taintVelocity = Vector3.Zero;
} }
public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
@ -1576,7 +1571,7 @@ Console.WriteLine(" JointCreateFixed");
//Console.WriteLine("Move " + m_primName); //Console.WriteLine("Move " + m_primName);
if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
// NON-'VEHICLES' are dealt with here // NON-'VEHICLES' are dealt with here
if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f)) if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
{ {
d.Vector3 avel2 = d.BodyGetAngularVel(Body); d.Vector3 avel2 = d.BodyGetAngularVel(Body);
if (m_angularlock.X == 1) if (m_angularlock.X == 1)
@ -1633,7 +1628,7 @@ Console.WriteLine(" JointCreateFixed");
d.Vector3 pos = d.BodyGetPosition(Body); d.Vector3 pos = d.BodyGetPosition(Body);
_target_velocity = _target_velocity =
new PhysicsVector( new Vector3(
(m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
(m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
(m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
@ -1641,7 +1636,7 @@ Console.WriteLine(" JointCreateFixed");
// if velocity is zero, use position control; otherwise, velocity control // if velocity is zero, use position control; otherwise, velocity control
if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f)) if (_target_velocity.ApproxEquals(Vector3.Zero,0.1f))
{ {
// keep track of where we stopped. No more slippin' & slidin' // keep track of where we stopped. No more slippin' & slidin'
@ -1726,13 +1721,13 @@ Console.WriteLine(" JointCreateFixed");
_target_velocity = _target_velocity =
new PhysicsVector(0.0f, 0.0f, new Vector3(0.0f, 0.0f,
(m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
); );
// if velocity is zero, use position control; otherwise, velocity control // if velocity is zero, use position control; otherwise, velocity control
if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
{ {
// keep track of where we stopped. No more slippin' & slidin' // keep track of where we stopped. No more slippin' & slidin'
@ -1821,7 +1816,7 @@ Console.WriteLine(" JointCreateFixed");
d.BodySetQuaternion(Body, ref myrot); d.BodySetQuaternion(Body, ref myrot);
if (m_isphysical) if (m_isphysical)
{ {
if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0)) if (!m_angularlock.ApproxEquals(Vector3.One, 0f))
createAMotor(m_angularlock); createAMotor(m_angularlock);
} }
} }
@ -2130,7 +2125,7 @@ Console.WriteLine(" JointCreateFixed");
//m_log.Info("[PHYSICS]: dequeing forcelist"); //m_log.Info("[PHYSICS]: dequeing forcelist");
if (IsPhysical) if (IsPhysical)
{ {
PhysicsVector iforce = new PhysicsVector(); Vector3 iforce = Vector3.Zero;
for (int i = 0; i < m_forcelist.Count; i++) for (int i = 0; i < m_forcelist.Count; i++)
{ {
iforce = iforce + (m_forcelist[i] * 100); iforce = iforce + (m_forcelist[i] * 100);
@ -2161,7 +2156,7 @@ Console.WriteLine(" JointCreateFixed");
} }
} }
m_taintTorque = new PhysicsVector(0, 0, 0); m_taintTorque = Vector3.Zero;
} }
public void changeAddAngularForce(float timestamp) public void changeAddAngularForce(float timestamp)
@ -2173,7 +2168,7 @@ Console.WriteLine(" JointCreateFixed");
//m_log.Info("[PHYSICS]: dequeing forcelist"); //m_log.Info("[PHYSICS]: dequeing forcelist");
if (IsPhysical) if (IsPhysical)
{ {
PhysicsVector iforce = new PhysicsVector(); Vector3 iforce = Vector3.Zero;
for (int i = 0; i < m_angularforcelist.Count; i++) for (int i = 0; i < m_angularforcelist.Count; i++)
{ {
iforce = iforce + (m_angularforcelist[i] * 100); iforce = iforce + (m_angularforcelist[i] * 100);
@ -2207,7 +2202,7 @@ Console.WriteLine(" JointCreateFixed");
//resetCollisionAccounting(); //resetCollisionAccounting();
} }
m_taintVelocity = PhysicsVector.Zero; m_taintVelocity = Vector3.Zero;
} }
public override bool IsPhysical public override bool IsPhysical
@ -2216,7 +2211,7 @@ Console.WriteLine(" JointCreateFixed");
set { set {
m_isphysical = value; m_isphysical = value;
if (!m_isphysical) // Zero the remembered last velocity if (!m_isphysical) // Zero the remembered last velocity
m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); m_lastVelocity = Vector3.Zero;
} }
} }
@ -2261,7 +2256,7 @@ Console.WriteLine(" JointCreateFixed");
get { return _zeroFlag; } get { return _zeroFlag; }
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get { return _position; } get { return _position; }
@ -2270,12 +2265,12 @@ Console.WriteLine(" JointCreateFixed");
} }
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return _size; } get { return _size; }
set set
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
_size = value; _size = value;
} }
@ -2291,13 +2286,13 @@ Console.WriteLine(" JointCreateFixed");
get { return CalculateMass(); } get { return CalculateMass(); }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
//get { return PhysicsVector.Zero; } //get { return Vector3.Zero; }
get { return m_force; } get { return m_force; }
set set
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
m_force = value; m_force = value;
} }
@ -2319,7 +2314,7 @@ Console.WriteLine(" JointCreateFixed");
m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value); m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value);
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value); m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value);
} }
@ -2337,14 +2332,14 @@ Console.WriteLine(" JointCreateFixed");
} }
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PrimitiveBaseShape Shape public override PrimitiveBaseShape Shape
@ -2356,13 +2351,13 @@ Console.WriteLine(" JointCreateFixed");
} }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get get
{ {
// Averate previous velocity with the new one so // Averate previous velocity with the new one so
// client object interpolation works a 'little' better // client object interpolation works a 'little' better
PhysicsVector returnVelocity = new PhysicsVector(); Vector3 returnVelocity = Vector3.Zero;
returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2; returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2;
returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2; returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2;
returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2; returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2;
@ -2370,7 +2365,7 @@ Console.WriteLine(" JointCreateFixed");
} }
set set
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
_velocity = value; _velocity = value;
@ -2385,19 +2380,19 @@ Console.WriteLine(" JointCreateFixed");
} }
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get get
{ {
if (!m_isphysical || Body == IntPtr.Zero) if (!m_isphysical || Body == IntPtr.Zero)
return new PhysicsVector(0,0,0); return Vector3.Zero;
return _torque; return _torque;
} }
set set
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
m_taintTorque = value; m_taintTorque = value;
_parent_scene.AddPhysicsActorTaint(this); _parent_scene.AddPhysicsActorTaint(this);
@ -2449,20 +2444,20 @@ Console.WriteLine(" JointCreateFixed");
return true; return true;
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
public void SetAcceleration(PhysicsVector accel) public void SetAcceleration(Vector3 accel)
{ {
_acceleration = accel; _acceleration = accel;
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
if (PhysicsVector.isFinite(force)) if (force.IsFinite())
{ {
m_forcelist.Add(force); m_forcelist.Add(force);
m_taintforce = true; m_taintforce = true;
@ -2474,9 +2469,9 @@ Console.WriteLine(" JointCreateFixed");
//m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
if (PhysicsVector.isFinite(force)) if (force.IsFinite())
{ {
m_angularforcelist.Add(force); m_angularforcelist.Add(force);
m_taintaddangularforce = true; m_taintaddangularforce = true;
@ -2487,23 +2482,23 @@ Console.WriteLine(" JointCreateFixed");
} }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get get
{ {
PhysicsVector pv = new PhysicsVector(0, 0, 0); Vector3 pv = Vector3.Zero;
if (_zeroFlag) if (_zeroFlag)
return pv; return pv;
m_lastUpdateSent = false; m_lastUpdateSent = false;
if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) if (m_rotationalVelocity.ApproxEquals(pv, 0.2f))
return pv; return pv;
return m_rotationalVelocity; return m_rotationalVelocity;
} }
set set
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
m_rotationalVelocity = value; m_rotationalVelocity = value;
} }
@ -2544,16 +2539,16 @@ Console.WriteLine(" JointCreateFixed");
m_taintparent = null; m_taintparent = null;
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
// reverse the zero/non zero values for ODE. // reverse the zero/non zero values for ODE.
if (PhysicsVector.isFinite(axis)) if (axis.IsFinite())
{ {
axis.X = (axis.X > 0) ? 1f : 0f; axis.X = (axis.X > 0) ? 1f : 0f;
axis.Y = (axis.Y > 0) ? 1f : 0f; axis.Y = (axis.Y > 0) ? 1f : 0f;
axis.Z = (axis.Z > 0) ? 1f : 0f; axis.Z = (axis.Z > 0) ? 1f : 0f;
m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); m_taintAngularLock = axis;
} }
else else
{ {
@ -2566,7 +2561,7 @@ Console.WriteLine(" JointCreateFixed");
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
if (_parent == null) if (_parent == null)
{ {
PhysicsVector pv = new PhysicsVector(0, 0, 0); Vector3 pv = Vector3.Zero;
bool lastZeroFlag = _zeroFlag; bool lastZeroFlag = _zeroFlag;
if (Body != (IntPtr)0) // FIXME -> or if it is a joint if (Body != (IntPtr)0) // FIXME -> or if it is a joint
{ {
@ -2575,9 +2570,9 @@ Console.WriteLine(" JointCreateFixed");
d.Vector3 vel = d.BodyGetLinearVel(Body); d.Vector3 vel = d.BodyGetLinearVel(Body);
d.Vector3 rotvel = d.BodyGetAngularVel(Body); d.Vector3 rotvel = d.BodyGetAngularVel(Body);
d.Vector3 torque = d.BodyGetTorque(Body); d.Vector3 torque = d.BodyGetTorque(Body);
_torque.setValues(torque.X, torque.Y, torque.Z); _torque = new Vector3(torque.X, torque.Y, torque.Z);
PhysicsVector l_position = new PhysicsVector(); Vector3 l_position = Vector3.Zero;
Quaternion l_orientation = new Quaternion(); Quaternion l_orientation = Quaternion.Identity;
// kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
//if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
@ -2712,16 +2707,16 @@ Console.WriteLine(" JointCreateFixed");
_velocity.Z = vel.Z; _velocity.Z = vel.Z;
_acceleration = ((_velocity - m_lastVelocity) / 0.1f); _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
_acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f); _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f);
//m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
if (_velocity.IsIdentical(pv, 0.5f)) if (_velocity.ApproxEquals(pv, 0.5f))
{ {
m_rotationalVelocity = pv; m_rotationalVelocity = pv;
} }
else else
{ {
m_rotationalVelocity.setValues(rotvel.X, rotvel.Y, rotvel.Z); m_rotationalVelocity = new Vector3(rotvel.X, rotvel.Y, rotvel.Z);
} }
//m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@ -2769,15 +2764,15 @@ Console.WriteLine(" JointCreateFixed");
} }
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
public override PhysicsVector PIDTarget public override Vector3 PIDTarget
{ {
set set
{ {
if (PhysicsVector.isFinite(value)) if (value.IsFinite())
{ {
m_PIDTarget = value; m_PIDTarget = value;
} }
@ -2793,7 +2788,7 @@ Console.WriteLine(" JointCreateFixed");
public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
public override float PIDHoverTau { set { m_PIDHoverTau = value; } } public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
private void createAMotor(PhysicsVector axis) private void createAMotor(Vector3 axis)
{ {
if (Body == IntPtr.Zero) if (Body == IntPtr.Zero)
return; return;

View File

@ -684,7 +684,7 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary> /// </summary>
/// <param name="pos"></param> /// <param name="pos"></param>
/// <returns>Returns which split up space the given position is in.</returns> /// <returns>Returns which split up space the given position is in.</returns>
public string whichspaceamIin(PhysicsVector pos) public string whichspaceamIin(Vector3 pos)
{ {
return calculateSpaceForGeom(pos).ToString(); return calculateSpaceForGeom(pos).ToString();
} }
@ -963,7 +963,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//p2.CollidingObj = true; //p2.CollidingObj = true;
contacts[i].depth = 0.00000003f; contacts[i].depth = 0.00000003f;
p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f);
contacts[i].pos = contacts[i].pos =
new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
contacts[i].pos.Y + (p1.Size.Y/2), contacts[i].pos.Y + (p1.Size.Y/2),
@ -981,7 +981,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//p2.CollidingObj = true; //p2.CollidingObj = true;
contacts[i].depth = 0.00000003f; contacts[i].depth = 0.00000003f;
p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 0.5f); p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f);
contacts[i].pos = contacts[i].pos =
new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
contacts[i].pos.Y + (p1.Size.Y/2), contacts[i].pos.Y + (p1.Size.Y/2),
@ -1646,9 +1646,9 @@ namespace OpenSim.Region.Physics.OdePlugin
#region Add/Remove Entities #region Add/Remove Entities
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
{ {
PhysicsVector pos = new PhysicsVector(); Vector3 pos;
pos.X = position.X; pos.X = position.X;
pos.Y = position.Y; pos.Y = position.Y;
pos.Z = position.Z; pos.Z = position.Z;
@ -1698,18 +1698,12 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
{ {
PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); Vector3 pos = position;
//pos.X = position.X; Vector3 siz = size;
//pos.Y = position.Y;
//pos.Z = position.Z;
PhysicsVector siz = new PhysicsVector();
siz.X = size.X;
siz.Y = size.Y;
siz.Z = size.Z;
Quaternion rot = rotation; Quaternion rot = rotation;
OdePrim newPrim; OdePrim newPrim;
@ -1736,14 +1730,14 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation) //To be removed Vector3 size, Quaternion rotation) //To be removed
{ {
return AddPrimShape(primName, pbs, position, size, rotation, false); return AddPrimShape(primName, pbs, position, size, rotation, false);
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation, bool isPhysical) Vector3 size, Quaternion rotation, bool isPhysical)
{ {
PhysicsActor result; PhysicsActor result;
IMesh mesh = null; IMesh mesh = null;
@ -1976,7 +1970,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// this joint will just be added to a waiting list that is NOT processed during the main // this joint will just be added to a waiting list that is NOT processed during the main
// Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests. // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests.
public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, PhysicsVector position, public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation) Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
{ {
@ -1984,7 +1978,7 @@ namespace OpenSim.Region.Physics.OdePlugin
OdePhysicsJoint joint = new OdePhysicsJoint(); OdePhysicsJoint joint = new OdePhysicsJoint();
joint.ObjectNameInScene = objectNameInScene; joint.ObjectNameInScene = objectNameInScene;
joint.Type = jointType; joint.Type = jointType;
joint.Position = new PhysicsVector(position.X, position.Y, position.Z); joint.Position = position;
joint.Rotation = rotation; joint.Rotation = rotation;
joint.RawParams = parms; joint.RawParams = parms;
joint.BodyNames = new List<string>(bodyNames); joint.BodyNames = new List<string>(bodyNames);
@ -2036,7 +2030,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
// normally called from within OnJointMoved, which is called from within a lock (OdeLock) // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
public override PhysicsVector GetJointAnchor(PhysicsJoint joint) public override Vector3 GetJointAnchor(PhysicsJoint joint)
{ {
Debug.Assert(joint.IsInPhysicsEngine); Debug.Assert(joint.IsInPhysicsEngine);
d.Vector3 pos = new d.Vector3(); d.Vector3 pos = new d.Vector3();
@ -2058,14 +2052,14 @@ namespace OpenSim.Region.Physics.OdePlugin
break; break;
} }
} }
return new PhysicsVector(pos.X, pos.Y, pos.Z); return new Vector3(pos.X, pos.Y, pos.Z);
} }
// normally called from within OnJointMoved, which is called from within a lock (OdeLock) // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
// WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function // WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function
// appears to be unreliable. Fortunately we can compute the joint axis ourselves by // appears to be unreliable. Fortunately we can compute the joint axis ourselves by
// keeping track of the joint's original orientation relative to one of the involved bodies. // keeping track of the joint's original orientation relative to one of the involved bodies.
public override PhysicsVector GetJointAxis(PhysicsJoint joint) public override Vector3 GetJointAxis(PhysicsJoint joint)
{ {
Debug.Assert(joint.IsInPhysicsEngine); Debug.Assert(joint.IsInPhysicsEngine);
d.Vector3 axis = new d.Vector3(); d.Vector3 axis = new d.Vector3();
@ -2087,7 +2081,7 @@ namespace OpenSim.Region.Physics.OdePlugin
break; break;
} }
} }
return new PhysicsVector(axis.X, axis.Y, axis.Z); return new Vector3(axis.X, axis.Y, axis.Z);
} }
@ -2255,7 +2249,7 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <param name="pos">the position that the geom moved to</param> /// <param name="pos">the position that the geom moved to</param>
/// <param name="currentspace">a pointer to the space it was in before it was moved.</param> /// <param name="currentspace">a pointer to the space it was in before it was moved.</param>
/// <returns>a pointer to the new space it's in</returns> /// <returns>a pointer to the new space it's in</returns>
public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace) public IntPtr recalculateSpaceForGeom(IntPtr geom, Vector3 pos, IntPtr currentspace)
{ {
// Called from setting the Position and Size of an ODEPrim so // Called from setting the Position and Size of an ODEPrim so
// it's already in locked space. // it's already in locked space.
@ -2402,7 +2396,7 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary> /// </summary>
/// <param name="pos"></param> /// <param name="pos"></param>
/// <returns>a pointer to the space. This could be a new space or reused space.</returns> /// <returns>a pointer to the space. This could be a new space or reused space.</returns>
public IntPtr calculateSpaceForGeom(PhysicsVector pos) public IntPtr calculateSpaceForGeom(Vector3 pos)
{ {
int[] xyspace = calculateSpaceArrayItemFromPos(pos); int[] xyspace = calculateSpaceArrayItemFromPos(pos);
//m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
@ -2414,7 +2408,7 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary> /// </summary>
/// <param name="pos"></param> /// <param name="pos"></param>
/// <returns>an array item based on the position</returns> /// <returns>an array item based on the position</returns>
public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos) public int[] calculateSpaceArrayItemFromPos(Vector3 pos)
{ {
int[] returnint = new int[2]; int[] returnint = new int[2];

View File

@ -76,8 +76,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public void CreateAndDropPhysicalCube() public void CreateAndDropPhysicalCube()
{ {
PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox(); PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox();
PhysicsVector position = new PhysicsVector(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
PhysicsVector size = new PhysicsVector(0.5f, 0.5f, 0.5f); Vector3 size = new Vector3(0.5f, 0.5f, 0.5f);
Quaternion rot = Quaternion.Identity; Quaternion rot = Quaternion.Identity;
PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true); PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true);
OdePrim oprim = (OdePrim)prim; OdePrim oprim = (OdePrim)prim;

View File

@ -36,20 +36,17 @@ namespace OpenSim.Region.Physics.POSPlugin
{ {
public class POSCharacter : PhysicsActor public class POSCharacter : PhysicsActor
{ {
private PhysicsVector _position; private Vector3 _position;
public PhysicsVector _velocity; public Vector3 _velocity;
public PhysicsVector _target_velocity = PhysicsVector.Zero; public Vector3 _target_velocity = Vector3.Zero;
public PhysicsVector _size = PhysicsVector.Zero; public Vector3 _size = Vector3.Zero;
private PhysicsVector _acceleration; private Vector3 _acceleration;
private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; private Vector3 m_rotationalVelocity = Vector3.Zero;
private bool flying; private bool flying;
private bool isColliding; private bool isColliding;
public POSCharacter() public POSCharacter()
{ {
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
} }
public override int PhysicsActorType public override int PhysicsActorType
@ -58,7 +55,7 @@ namespace OpenSim.Region.Physics.POSPlugin
set { return; } set { return; }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
@ -137,13 +134,13 @@ namespace OpenSim.Region.Physics.POSPlugin
get { return false; } get { return false; }
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get { return _position; } get { return _position; }
set { _position = value; } set { _position = value; }
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return _size; } get { return _size; }
set set
@ -158,9 +155,9 @@ namespace OpenSim.Region.Physics.POSPlugin
get { return 0f; } get { return 0f; }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -175,7 +172,7 @@ namespace OpenSim.Region.Physics.POSPlugin
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
} }
@ -190,14 +187,14 @@ namespace OpenSim.Region.Physics.POSPlugin
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PrimitiveBaseShape Shape public override PrimitiveBaseShape Shape
@ -205,15 +202,15 @@ namespace OpenSim.Region.Physics.POSPlugin
set { return; } set { return; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get { return _velocity; } get { return _velocity; }
set { _target_velocity = value; } set { _target_velocity = value; }
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -229,7 +226,7 @@ namespace OpenSim.Region.Physics.POSPlugin
set { } set { }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
@ -248,24 +245,24 @@ namespace OpenSim.Region.Physics.POSPlugin
{ {
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
} }
public void SetAcceleration(PhysicsVector accel) public void SetAcceleration(Vector3 accel)
{ {
_acceleration = accel; _acceleration = accel;
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
@ -273,7 +270,7 @@ namespace OpenSim.Region.Physics.POSPlugin
{ {
} }
public override PhysicsVector PIDTarget public override Vector3 PIDTarget
{ {
set { return; } set { return; }
} }

View File

@ -36,19 +36,16 @@ namespace OpenSim.Region.Physics.POSPlugin
{ {
public class POSPrim : PhysicsActor public class POSPrim : PhysicsActor
{ {
private PhysicsVector _position; private Vector3 _position;
private PhysicsVector _velocity; private Vector3 _velocity;
private PhysicsVector _acceleration; private Vector3 _acceleration;
private PhysicsVector _size; private Vector3 _size;
private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; private Vector3 m_rotationalVelocity = Vector3.Zero;
private Quaternion _orientation; private Quaternion _orientation;
private bool iscolliding; private bool iscolliding;
public POSPrim() public POSPrim()
{ {
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
} }
public override int PhysicsActorType public override int PhysicsActorType
@ -57,7 +54,7 @@ namespace OpenSim.Region.Physics.POSPlugin
set { return; } set { return; }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
@ -98,13 +95,13 @@ namespace OpenSim.Region.Physics.POSPlugin
get { return false; } get { return false; }
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get { return _position; } get { return _position; }
set { _position = value; } set { _position = value; }
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return _size; } get { return _size; }
set { _size = value; } set { _size = value; }
@ -115,9 +112,9 @@ namespace OpenSim.Region.Physics.POSPlugin
get { return 0f; } get { return 0f; }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -132,7 +129,7 @@ namespace OpenSim.Region.Physics.POSPlugin
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
} }
@ -147,14 +144,14 @@ namespace OpenSim.Region.Physics.POSPlugin
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PrimitiveBaseShape Shape public override PrimitiveBaseShape Shape
@ -173,7 +170,7 @@ namespace OpenSim.Region.Physics.POSPlugin
set { return; } set { return; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get { return _velocity; } get { return _velocity; }
set { _velocity = value; } set { _velocity = value; }
@ -191,7 +188,7 @@ namespace OpenSim.Region.Physics.POSPlugin
set { _orientation = value; } set { _orientation = value; }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
@ -202,26 +199,26 @@ namespace OpenSim.Region.Physics.POSPlugin
set { } set { }
} }
public void SetAcceleration(PhysicsVector accel) public void SetAcceleration(Vector3 accel)
{ {
_acceleration = accel; _acceleration = accel;
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
@ -255,7 +252,7 @@ namespace OpenSim.Region.Physics.POSPlugin
{ {
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
} }
@ -268,7 +265,7 @@ namespace OpenSim.Region.Physics.POSPlugin
{ {
} }
public override PhysicsVector PIDTarget public override Vector3 PIDTarget
{ {
set { return; } set { return; }
} }

View File

@ -56,7 +56,7 @@ namespace OpenSim.Region.Physics.POSPlugin
{ {
} }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
{ {
POSCharacter act = new POSCharacter(); POSCharacter act = new POSCharacter();
act.Position = position; act.Position = position;
@ -84,20 +84,20 @@ namespace OpenSim.Region.Physics.POSPlugin
} }
/* /*
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
{ {
return null; return null;
} }
*/ */
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation) Vector3 size, Quaternion rotation)
{ {
return AddPrimShape(primName, pbs, position, size, rotation, false); return AddPrimShape(primName, pbs, position, size, rotation, false);
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation, bool isPhysical) Vector3 size, Quaternion rotation, bool isPhysical)
{ {
POSPrim prim = new POSPrim(); POSPrim prim = new POSPrim();
prim.Position = position; prim.Position = position;
@ -152,23 +152,25 @@ namespace OpenSim.Region.Physics.POSPlugin
character._target_velocity.Z += gravity * timeStep; character._target_velocity.Z += gravity * timeStep;
} }
character.Position.X += character._target_velocity.X * timeStep; Vector3 characterPosition = character.Position;
character.Position.Y += character._target_velocity.Y * timeStep;
character.Position.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f); characterPosition.X += character._target_velocity.X * timeStep;
character.Position.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f); characterPosition.Y += character._target_velocity.Y * timeStep;
characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
bool forcedZ = false; bool forcedZ = false;
float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X]; float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X];
if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2)
{ {
character.Position.Z = terrainheight + character.Size.Z; characterPosition.Z = terrainheight + character.Size.Z;
forcedZ = true; forcedZ = true;
} }
else else
{ {
character.Position.Z += character._target_velocity.Z*timeStep; characterPosition.Z += character._target_velocity.Z*timeStep;
} }
/// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- /// this is it -- the magic you've all been waiting for! Ladies and gentlemen --
@ -177,29 +179,29 @@ namespace OpenSim.Region.Physics.POSPlugin
if (isCollidingWithPrim(character)) if (isCollidingWithPrim(character))
{ {
character.Position.Z = oldposZ; // first try Z axis characterPosition.Z = oldposZ; // first try Z axis
if (isCollidingWithPrim(character)) if (isCollidingWithPrim(character))
{ {
character.Position.Z = oldposZ + character.Size.Z / 4.4f; // try harder characterPosition.Z = oldposZ + character.Size.Z / 4.4f; // try harder
if (isCollidingWithPrim(character)) if (isCollidingWithPrim(character))
{ {
character.Position.Z = oldposZ + character.Size.Z / 2.2f; // try very hard characterPosition.Z = oldposZ + character.Size.Z / 2.2f; // try very hard
if (isCollidingWithPrim(character)) if (isCollidingWithPrim(character))
{ {
character.Position.X = oldposX; characterPosition.X = oldposX;
character.Position.Y = oldposY; characterPosition.Y = oldposY;
character.Position.Z = oldposZ; characterPosition.Z = oldposZ;
character.Position.X += character._target_velocity.X * timeStep; characterPosition.X += character._target_velocity.X * timeStep;
if (isCollidingWithPrim(character)) if (isCollidingWithPrim(character))
{ {
character.Position.X = oldposX; characterPosition.X = oldposX;
} }
character.Position.Y += character._target_velocity.Y * timeStep; characterPosition.Y += character._target_velocity.Y * timeStep;
if (isCollidingWithPrim(character)) if (isCollidingWithPrim(character))
{ {
character.Position.Y = oldposY; characterPosition.Y = oldposY;
} }
} }
else else
@ -218,8 +220,10 @@ namespace OpenSim.Region.Physics.POSPlugin
} }
} }
character.Position.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f); characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
character.Position.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f); characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
character.Position = characterPosition;
character._velocity.X = (character.Position.X - oldposX)/timeStep; character._velocity.X = (character.Position.X - oldposX)/timeStep;
character._velocity.Y = (character.Position.Y - oldposY)/timeStep; character._velocity.Y = (character.Position.Y - oldposY)/timeStep;

View File

@ -34,6 +34,7 @@ using PhysXWrapper;
using Quaternion=OpenMetaverse.Quaternion; using Quaternion=OpenMetaverse.Quaternion;
using System.Reflection; using System.Reflection;
using log4net; using log4net;
using OpenMetaverse;
namespace OpenSim.Region.Physics.PhysXPlugin namespace OpenSim.Region.Physics.PhysXPlugin
{ {
@ -106,7 +107,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
{ {
Vec3 pos = new Vec3(); Vec3 pos = new Vec3();
pos.X = position.X; pos.X = position.X;
@ -127,7 +128,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
{ {
} }
private PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
{ {
Vec3 pos = new Vec3(); Vec3 pos = new Vec3();
pos.X = position.X; pos.X = position.X;
@ -142,14 +143,14 @@ namespace OpenSim.Region.Physics.PhysXPlugin
return act; return act;
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation) //To be removed Vector3 size, Quaternion rotation) //To be removed
{ {
return AddPrimShape(primName, pbs, position, size, rotation, false); return AddPrimShape(primName, pbs, position, size, rotation, false);
} }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
PhysicsVector size, Quaternion rotation, bool isPhysical) Vector3 size, Quaternion rotation, bool isPhysical)
{ {
return AddPrim(position, size, rotation); return AddPrim(position, size, rotation);
} }
@ -219,10 +220,10 @@ namespace OpenSim.Region.Physics.PhysXPlugin
public class PhysXCharacter : PhysicsActor public class PhysXCharacter : PhysicsActor
{ {
private PhysicsVector _position; private Vector3 _position;
private PhysicsVector _velocity; private Vector3 _velocity;
private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; private Vector3 m_rotationalVelocity = Vector3.Zero;
private PhysicsVector _acceleration; private Vector3 _acceleration;
private NxCharacter _character; private NxCharacter _character;
private bool flying; private bool flying;
private bool iscolliding = false; private bool iscolliding = false;
@ -230,9 +231,6 @@ namespace OpenSim.Region.Physics.PhysXPlugin
public PhysXCharacter(NxCharacter character) public PhysXCharacter(NxCharacter character)
{ {
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
_character = character; _character = character;
} }
@ -310,7 +308,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
set { return; } set { return; }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
@ -321,7 +319,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
get { return false; } get { return false; }
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get { return _position; } get { return _position; }
set set
@ -335,9 +333,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { } set { }
} }
@ -346,9 +344,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
get { return 0f; } get { return 0f; }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -363,7 +361,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
} }
@ -379,17 +377,17 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get { return _velocity; } get { return _velocity; }
set { _velocity = value; } set { _velocity = value; }
@ -413,25 +411,25 @@ namespace OpenSim.Region.Physics.PhysXPlugin
set { } set { }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
public void SetAcceleration(PhysicsVector accel) public void SetAcceleration(Vector3 accel)
{ {
_acceleration = accel; _acceleration = accel;
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
} }
@ -445,12 +443,12 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
@ -492,7 +490,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
public override PhysicsVector PIDTarget { set { return; } } public override Vector3 PIDTarget { set { return; } }
public override bool PIDActive { set { return; } } public override bool PIDActive { set { return; } }
public override float PIDTau { set { return; } } public override float PIDTau { set { return; } }
@ -518,15 +516,15 @@ namespace OpenSim.Region.Physics.PhysXPlugin
public class PhysXPrim : PhysicsActor public class PhysXPrim : PhysicsActor
{ {
private PhysicsVector _velocity; private Vector3 _velocity;
private PhysicsVector _acceleration; private Vector3 _acceleration;
private PhysicsVector m_rotationalVelocity; private Vector3 m_rotationalVelocity;
private NxActor _prim; private NxActor _prim;
public PhysXPrim(NxActor prim) public PhysXPrim(NxActor prim)
{ {
_velocity = new PhysicsVector(); _velocity = Vector3.Zero;
_acceleration = new PhysicsVector(); _acceleration = Vector3.Zero;
_prim = prim; _prim = prim;
} }
@ -580,7 +578,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
set { return; } set { return; }
} }
public override PhysicsVector RotationalVelocity public override Vector3 RotationalVelocity
{ {
get { return m_rotationalVelocity; } get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; } set { m_rotationalVelocity = value; }
@ -616,11 +614,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
get { return false; } get { return false; }
} }
public override PhysicsVector Position public override Vector3 Position
{ {
get get
{ {
PhysicsVector pos = new PhysicsVector(); Vector3 pos = Vector3.Zero;
Vec3 vec = _prim.Position; Vec3 vec = _prim.Position;
pos.X = vec.X; pos.X = vec.X;
pos.Y = vec.Y; pos.Y = vec.Y;
@ -629,7 +627,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
set set
{ {
PhysicsVector vec = value; Vector3 vec = value;
Vec3 pos = new Vec3(); Vec3 pos = new Vec3();
pos.X = vec.X; pos.X = vec.X;
pos.Y = vec.Y; pos.Y = vec.Y;
@ -643,15 +641,15 @@ namespace OpenSim.Region.Physics.PhysXPlugin
set { return; } set { return; }
} }
public override PhysicsVector Velocity public override Vector3 Velocity
{ {
get { return _velocity; } get { return _velocity; }
set { _velocity = value; } set { _velocity = value; }
} }
public override PhysicsVector Torque public override Vector3 Torque
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -682,31 +680,31 @@ namespace OpenSim.Region.Physics.PhysXPlugin
set { } set { }
} }
public override PhysicsVector Acceleration public override Vector3 Acceleration
{ {
get { return _acceleration; } get { return _acceleration; }
} }
public void SetAcceleration(PhysicsVector accel) public void SetAcceleration(Vector3 accel)
{ {
_acceleration = accel; _acceleration = accel;
} }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(Vector3 force, bool pushforce)
{ {
} }
public override void AddAngularForce(PhysicsVector force, bool pushforce) public override void AddAngularForce(Vector3 force, bool pushforce)
{ {
} }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(Vector3 momentum)
{ {
} }
public override PhysicsVector Size public override Vector3 Size
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { } set { }
} }
@ -718,7 +716,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
{ {
} }
public override void LockAngularMotion(PhysicsVector axis) public override void LockAngularMotion(Vector3 axis)
{ {
} }
@ -728,9 +726,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
get { return 0f; } get { return 0f; }
} }
public override PhysicsVector Force public override Vector3 Force
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
set { return; } set { return; }
} }
@ -745,7 +743,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
public override void VehicleVectorParam(int param, PhysicsVector value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
} }
@ -760,21 +758,21 @@ namespace OpenSim.Region.Physics.PhysXPlugin
} }
public override PhysicsVector CenterOfMass public override Vector3 CenterOfMass
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override PhysicsVector GeometricCenter public override Vector3 GeometricCenter
{ {
get { return PhysicsVector.Zero; } get { return Vector3.Zero; }
} }
public override void CrossingFailure() public override void CrossingFailure()
{ {
} }
public override PhysicsVector PIDTarget { set { return; } } public override Vector3 PIDTarget { set { return; } }
public override bool PIDActive { set { return; } } public override bool PIDActive { set { return; } }
public override float PIDTau { set { return; } } public override float PIDTau { set { return; } }

View File

@ -2047,7 +2047,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (local != 0) if (local != 0)
force *= llGetRot(); force *= llGetRot();
m_host.ParentGroup.RootPart.SetForce(new PhysicsVector((float)force.x, (float)force.y, (float)force.z)); m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z));
} }
} }
} }
@ -2062,7 +2062,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (!m_host.ParentGroup.IsDeleted) if (!m_host.ParentGroup.IsDeleted)
{ {
PhysicsVector tmpForce = m_host.ParentGroup.RootPart.GetForce(); Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce();
force.x = tmpForce.X; force.x = tmpForce.X;
force.y = tmpForce.Y; force.y = tmpForce.Y;
force.z = tmpForce.Z; force.z = tmpForce.Z;
@ -4180,7 +4180,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
applied_linear_impulse *= m_host.GetWorldRotation(); applied_linear_impulse *= m_host.GetWorldRotation();
} }
pusheeav.PhysicsActor.AddForce(new PhysicsVector(applied_linear_impulse.X, applied_linear_impulse.Y, applied_linear_impulse.Z), true); pusheeav.PhysicsActor.AddForce(applied_linear_impulse, true);
} }
} }
} }
@ -6088,7 +6088,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_host.ParentGroup.IsDeleted) if (!m_host.ParentGroup.IsDeleted)
{ {
m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, m_host.ParentGroup.RootPart.SetVehicleVectorParam(param,
new PhysicsVector((float)vec.x, (float)vec.y, (float)vec.z)); new Vector3((float)vec.x, (float)vec.y, (float)vec.z));
} }
} }
} }