From 67e12b95ea7b68f4904a7484d77ecfd787d16d0c Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Tue, 30 Oct 2007 09:05:31 +0000
Subject: * Optimized usings * Shortened type references * Removed redundant
'this' qualifier
---
.../Physics/BasicPhysicsPlugin/AssemblyInfo.cs | 22 +-
.../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 106 +---
.../Region/Physics/BulletXPlugin/AssemblyInfo.cs | 24 +-
.../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 589 +++++++++++--------
OpenSim/Region/Physics/Manager/AssemblyInfo.cs | 22 +-
OpenSim/Region/Physics/Manager/PhysicsActor.cs | 110 +---
.../Region/Physics/Manager/PhysicsPluginManager.cs | 143 ++---
OpenSim/Region/Physics/Manager/PhysicsScene.cs | 26 +-
OpenSim/Region/Physics/Manager/PhysicsVector.cs | 5 +-
OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs | 22 +-
.../Physics/OdePlugin/Meshing/HelperTypes.cs | 72 ++-
.../Physics/OdePlugin/Meshing/Meshmerizer.cs | 256 ++++----
OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 274 ++++-----
OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs | 22 +-
OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 643 +++++++++------------
15 files changed, 1068 insertions(+), 1268 deletions(-)
(limited to 'OpenSim/Region/Physics')
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
index 2d4d898..a8f1de1 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
@@ -27,24 +27,26 @@
*/
using System.Reflection;
using System.Runtime.InteropServices;
+
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
-[assembly: AssemblyTitle("PhysXplugin")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("PhysXplugin")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly : AssemblyTitle("PhysXplugin")]
+[assembly : AssemblyDescription("")]
+[assembly : AssemblyConfiguration("")]
+[assembly : AssemblyCompany("")]
+[assembly : AssemblyProduct("PhysXplugin")]
+[assembly : AssemblyCopyright("")]
+[assembly : AssemblyTrademark("")]
+[assembly : AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
+
+[assembly : ComVisible(false)]
// The assembly version has following format :
//
@@ -53,4 +55,4 @@ using System.Runtime.InteropServices;
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
-[assembly: AssemblyVersion("1.0.*")]
+[assembly : AssemblyVersion("1.0.*")]
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index 95e6095..b412818 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -39,7 +39,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{
public BasicPhysicsPlugin()
{
-
}
public bool Init()
@@ -59,7 +58,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
public void Dispose()
{
-
}
}
@@ -70,7 +68,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
public BasicScene()
{
-
}
public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
@@ -83,17 +80,15 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
public override void RemovePrim(PhysicsActor prim)
{
-
}
public override void RemoveAvatar(PhysicsActor actor)
{
- BasicActor act = (BasicActor)actor;
+ BasicActor act = (BasicActor) actor;
if (_actors.Contains(act))
{
_actors.Remove(act);
}
-
}
/*
@@ -102,7 +97,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
return null;
}
*/
- public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation)
+
+ public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
+ PhysicsVector size, Quaternion rotation)
{
return null;
}
@@ -112,8 +109,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{
foreach (BasicActor actor in _actors)
{
- actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
- actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
+ actor.Position.X = actor.Position.X + (actor.Velocity.X*timeStep);
+ actor.Position.Y = actor.Position.Y + (actor.Velocity.Y*timeStep);
if (actor.Position.Y < 0)
{
actor.Position.Y = 0.1F;
@@ -132,17 +129,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
actor.Position.X = 255.9F;
}
- float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.0f;
+ float height = _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 1.0f;
if (actor.Flying)
{
- if (actor.Position.Z + (actor.Velocity.Z * timeStep) < _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2)
+ if (actor.Position.Z + (actor.Velocity.Z*timeStep) <
+ _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 2)
{
actor.Position.Z = height;
actor.Velocity.Z = 0;
}
else
{
- actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
+ actor.Position.Z = actor.Position.Z + (actor.Velocity.Z*timeStep);
}
}
else
@@ -150,32 +148,26 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
actor.Position.Z = height;
actor.Velocity.Z = 0;
}
-
-
}
}
public override void GetResults()
{
-
}
public override bool IsThreaded
{
- get
- {
- return (false); // for now we won't be multithreaded
+ get { return (false); // for now we won't be multithreaded
}
}
public override void SetTerrain(float[] heightMap)
{
- this._heightMap = heightMap;
+ _heightMap = heightMap;
}
public override void DeleteTerrain()
{
-
}
}
@@ -185,6 +177,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
private bool flying;
+
public BasicActor()
{
_velocity = new PhysicsVector();
@@ -194,97 +187,56 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
public override bool Flying
{
- get
- {
- return flying;
- }
- set
- {
- flying = value;
- }
+ get { return flying; }
+ set { flying = value; }
}
public override PhysicsVector Position
{
- get
- {
- return _position;
- }
- set
- {
- _position = value;
- }
+ get { return _position; }
+ set { _position = value; }
}
public override PhysicsVector Size
{
- get
- {
- return new PhysicsVector(0, 0, 0);
- }
- set
- {
- }
+ get { return new PhysicsVector(0, 0, 0); }
+ set { }
}
public override PhysicsVector Velocity
{
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
+ get { return _velocity; }
+ set { _velocity = value; }
}
public override Quaternion Orientation
{
- get
- {
- return Quaternion.Identity;
- }
- set
- {
-
- }
+ get { return Quaternion.Identity; }
+ set { }
}
public override PhysicsVector Acceleration
{
- get
- {
- return _acceleration;
- }
-
+ get { return _acceleration; }
}
public override bool Kinematic
{
- get
- {
- return true;
- }
- set
- {
-
- }
+ get { return true; }
+ set { }
}
+
public void SetAcceleration(PhysicsVector accel)
{
- this._acceleration = accel;
+ _acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
-
}
public override void SetMomentum(PhysicsVector momentum)
{
-
}
}
-
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
index 0180917..c8596f7 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@@ -27,24 +27,26 @@
*/
using System.Reflection;
using System.Runtime.InteropServices;
+
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
-[assembly: AssemblyTitle("BulletXPlugin")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("BulletXPlugin")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly : AssemblyTitle("BulletXPlugin")]
+[assembly : AssemblyDescription("")]
+[assembly : AssemblyConfiguration("")]
+[assembly : AssemblyCompany("")]
+[assembly : AssemblyProduct("BulletXPlugin")]
+[assembly : AssemblyCopyright("")]
+[assembly : AssemblyTrademark("")]
+[assembly : AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
+
+[assembly : ComVisible(false)]
// The assembly version has following format :
//
@@ -53,4 +55,4 @@ using System.Runtime.InteropServices;
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
-[assembly: AssemblyVersion("1.0.0.0")]
+[assembly : AssemblyVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 9fdc017..1658e2d 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -27,6 +27,7 @@
*/
#region Copyright
+
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
@@ -54,18 +55,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
+
#endregion
+
#region References
+
using System;
using System.Collections.Generic;
-using OpenSim.Region.Physics.Manager;
-using OpenSim.Framework;
-using Axiom.Math;
-using AxiomQuaternion = Axiom.Math.Quaternion;
-//Specific References for BulletXPlugin
using MonoXnaCompactMaths;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
using XnaDevRu.BulletX;
using XnaDevRu.BulletX.Dynamics;
+using AxiomQuaternion = Axiom.Math.Quaternion;
+using BoxShape=XnaDevRu.BulletX.BoxShape;
+//Specific References for BulletXPlugin
#endregion
@@ -80,27 +84,31 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{
}
}
+
///
/// BulletXConversions are called now BulletXMaths
/// This Class converts objects and types for BulletX and give some operations
///
- public class BulletXMaths
+ public class BulletXMaths
{
//Vector3
- public static MonoXnaCompactMaths.Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector)
+ public static Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector)
{
- return new MonoXnaCompactMaths.Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z);
+ return new Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z);
}
- public static PhysicsVector XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3)
+
+ public static PhysicsVector XnaVector3ToPhysicsVector(Vector3 xnaVector3)
{
return new PhysicsVector(xnaVector3.X, xnaVector3.Y, xnaVector3.Z);
}
+
//Quaternion
- public static MonoXnaCompactMaths.Quaternion AxiomQuaternionToXnaQuaternion(AxiomQuaternion axiomQuaternion)
+ public static Quaternion AxiomQuaternionToXnaQuaternion(AxiomQuaternion axiomQuaternion)
{
- return new MonoXnaCompactMaths.Quaternion(axiomQuaternion.x, axiomQuaternion.y, axiomQuaternion.z, axiomQuaternion.w);
+ return new Quaternion(axiomQuaternion.x, axiomQuaternion.y, axiomQuaternion.z, axiomQuaternion.w);
}
- public static AxiomQuaternion XnaQuaternionToAxiomQuaternion(MonoXnaCompactMaths.Quaternion xnaQuaternion)
+
+ public static AxiomQuaternion XnaQuaternionToAxiomQuaternion(Quaternion xnaQuaternion)
{
return new AxiomQuaternion(xnaQuaternion.W, xnaQuaternion.X, xnaQuaternion.Y, xnaQuaternion.Z);
}
@@ -110,70 +118,79 @@ namespace OpenSim.Region.Physics.BulletXPlugin
//- GetRotation (class MatrixOperations)
//- GetElement (class MathHelper)
//- SetElement (class MathHelper)
- internal static void SetRotation(ref Matrix m, MonoXnaCompactMaths.Quaternion q)
+ internal static void SetRotation(ref Matrix m, Quaternion q)
{
float d = q.LengthSquared();
- float s = 2f / d;
- float xs = q.X * s, ys = q.Y * s, zs = q.Z * s;
- float wx = q.W * xs, wy = q.W * ys, wz = q.W * zs;
- float xx = q.X * xs, xy = q.X * ys, xz = q.X * zs;
- float yy = q.Y * ys, yz = q.Y * zs, zz = q.Z * zs;
+ float s = 2f/d;
+ float xs = q.X*s, ys = q.Y*s, zs = q.Z*s;
+ float wx = q.W*xs, wy = q.W*ys, wz = q.W*zs;
+ float xx = q.X*xs, xy = q.X*ys, xz = q.X*zs;
+ float yy = q.Y*ys, yz = q.Y*zs, zz = q.Z*zs;
m = new Matrix(1 - (yy + zz), xy - wz, xz + wy, 0,
- xy + wz, 1 - (xx + zz), yz - wx, 0,
- xz - wy, yz + wx, 1 - (xx + yy), 0,
- m.M41, m.M42, m.M43, 1);
+ xy + wz, 1 - (xx + zz), yz - wx, 0,
+ xz - wy, yz + wx, 1 - (xx + yy), 0,
+ m.M41, m.M42, m.M43, 1);
}
- internal static MonoXnaCompactMaths.Quaternion GetRotation(Matrix m)
+
+ internal static Quaternion GetRotation(Matrix m)
{
- MonoXnaCompactMaths.Quaternion q = new MonoXnaCompactMaths.Quaternion();
+ Quaternion q = new Quaternion();
float trace = m.M11 + m.M22 + m.M33;
if (trace > 0)
{
- float s = (float)Math.Sqrt(trace + 1);
- q.W = s * 0.5f;
- s = 0.5f / s;
+ float s = (float) Math.Sqrt(trace + 1);
+ q.W = s*0.5f;
+ s = 0.5f/s;
- q.X = (m.M32 - m.M23) * s;
- q.Y = (m.M13 - m.M31) * s;
- q.Z = (m.M21 - m.M12) * s;
+ q.X = (m.M32 - m.M23)*s;
+ q.Y = (m.M13 - m.M31)*s;
+ q.Z = (m.M21 - m.M12)*s;
}
else
{
- int i = m.M11 < m.M22 ?
- (m.M22 < m.M33 ? 2 : 1) :
- (m.M11 < m.M33 ? 2 : 0);
- int j = (i + 1) % 3;
- int k = (i + 2) % 3;
-
- float s = (float)Math.Sqrt(GetElement(m, i, i) - GetElement(m, j, j) - GetElement(m, k, k) + 1);
- SetElement(ref q, i, s * 0.5f);
- s = 0.5f / s;
-
- q.W = (GetElement(m, k, j) - GetElement(m, j, k)) * s;
- SetElement(ref q, j, (GetElement(m, j, i) + GetElement(m, i, j)) * s);
- SetElement(ref q, k, (GetElement(m, k, i) + GetElement(m, i, k)) * s);
+ int i = m.M11 < m.M22
+ ?
+ (m.M22 < m.M33 ? 2 : 1)
+ :
+ (m.M11 < m.M33 ? 2 : 0);
+ int j = (i + 1)%3;
+ int k = (i + 2)%3;
+
+ float s = (float) Math.Sqrt(GetElement(m, i, i) - GetElement(m, j, j) - GetElement(m, k, k) + 1);
+ SetElement(ref q, i, s*0.5f);
+ s = 0.5f/s;
+
+ q.W = (GetElement(m, k, j) - GetElement(m, j, k))*s;
+ SetElement(ref q, j, (GetElement(m, j, i) + GetElement(m, i, j))*s);
+ SetElement(ref q, k, (GetElement(m, k, i) + GetElement(m, i, k))*s);
}
return q;
}
- internal static float SetElement(ref MonoXnaCompactMaths.Quaternion q, int index, float value)
+
+ internal static float SetElement(ref Quaternion q, int index, float value)
{
switch (index)
{
case 0:
- q.X = value; break;
+ q.X = value;
+ break;
case 1:
- q.Y = value; break;
+ q.Y = value;
+ break;
case 2:
- q.Z = value; break;
+ q.Z = value;
+ break;
case 3:
- q.W = value; break;
+ q.W = value;
+ break;
}
return 0;
}
+
internal static float GetElement(Matrix mat, int row, int col)
{
switch (row)
@@ -187,7 +204,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
return mat.M12;
case 2:
return mat.M13;
- } break;
+ }
+ break;
case 1:
switch (col)
{
@@ -197,7 +215,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
return mat.M22;
case 2:
return mat.M23;
- } break;
+ }
+ break;
case 2:
switch (col)
{
@@ -207,12 +226,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin
return mat.M32;
case 2:
return mat.M33;
- } break;
+ }
+ break;
}
return 0;
}
}
+
///
/// PhysicsPlugin Class for BulletX
///
@@ -223,10 +244,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
public BulletXPlugin()
{
}
+
public bool Init()
{
return true;
}
+
public PhysicsScene GetScene()
{
if (_mScene == null)
@@ -235,20 +258,24 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
return (_mScene);
}
+
public string GetName()
{
- return ("modified_BulletX");//Changed!! "BulletXEngine" To "modified_BulletX"
+ return ("modified_BulletX"); //Changed!! "BulletXEngine" To "modified_BulletX"
}
+
public void Dispose()
{
}
}
+
///
/// PhysicsScene Class for BulletX
///
public class BulletXScene : PhysicsScene
{
#region BulletXScene Fields
+
public DiscreteDynamicsWorld ddWorld;
private CollisionDispatcher cDispatcher;
private OverlappingPairCache opCache;
@@ -271,33 +298,58 @@ namespace OpenSim.Region.Physics.BulletXPlugin
private List _characters = new List();
private List _prims = new List();
- public static float Gravity { get { return gravity; } }
- public static float HeightLevel0 { get { return heightLevel0; } }
- public static float HeightLevel1 { get { return heightLevel1; } }
- public static float LowGravityFactor { get { return lowGravityFactor; } }
- public static int MaxXY { get { return maxXY; } }
- public static int MaxZ { get { return maxZ; } }
+ public static float Gravity
+ {
+ get { return gravity; }
+ }
+
+ public static float HeightLevel0
+ {
+ get { return heightLevel0; }
+ }
+
+ public static float HeightLevel1
+ {
+ get { return heightLevel1; }
+ }
+
+ public static float LowGravityFactor
+ {
+ get { return lowGravityFactor; }
+ }
+
+ public static int MaxXY
+ {
+ get { return maxXY; }
+ }
+
+ public static int MaxZ
+ {
+ get { return maxZ; }
+ }
private List _forgottenRigidBodies = new List();
internal string is_ex_message = "Can't remove rigidBody!: ";
+
#endregion
public BulletXScene()
{
cDispatcher = new CollisionDispatcher();
- MonoXnaCompactMaths.Vector3 worldMinDim = new MonoXnaCompactMaths.Vector3((float)minXY, (float)minXY, (float)minZ);
- MonoXnaCompactMaths.Vector3 worldMaxDim = new MonoXnaCompactMaths.Vector3((float)maxXY, (float)maxXY, (float)maxZ);
+ Vector3 worldMinDim = new Vector3((float) minXY, (float) minXY, (float) minZ);
+ Vector3 worldMaxDim = new Vector3((float) maxXY, (float) maxXY, (float) maxZ);
opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles);
sicSolver = new SequentialImpulseConstraintSolver();
lock (BulletXLock)
{
ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver);
- ddWorld.Gravity = new MonoXnaCompactMaths.Vector3(0, 0, -gravity);
+ ddWorld.Gravity = new Vector3(0, 0, -gravity);
}
//this._heightmap = new float[65536];
}
- public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
+
+ public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
{
PhysicsVector pos = new PhysicsVector();
pos.X = position.X;
@@ -311,6 +363,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
return newAv;
}
+
public override void RemoveAvatar(PhysicsActor actor)
{
if (actor is BulletXCharacter)
@@ -319,20 +372,22 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{
try
{
- ddWorld.RemoveRigidBody(((BulletXCharacter)actor).RigidBody);
+ ddWorld.RemoveRigidBody(((BulletXCharacter) actor).RigidBody);
}
catch (Exception ex)
{
BulletXMessage(is_ex_message + ex.Message, true);
- ((BulletXCharacter)actor).RigidBody.ActivationState = ActivationState.DisableSimulation;
- AddForgottenRigidBody(((BulletXCharacter)actor).RigidBody);
+ ((BulletXCharacter) actor).RigidBody.ActivationState = ActivationState.DisableSimulation;
+ AddForgottenRigidBody(((BulletXCharacter) actor).RigidBody);
}
- _characters.Remove((BulletXCharacter)actor);
+ _characters.Remove((BulletXCharacter) actor);
}
GC.Collect();
}
}
- public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation)
+
+ public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
+ PhysicsVector size, AxiomQuaternion rotation)
{
PhysicsActor result;
@@ -358,11 +413,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin
return result;
}
- public PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Axiom.Math.Quaternion rotation)
+
+ public PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation)
{
return AddPrim("", position, size, rotation, null, null);
}
- public PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
+
+ public PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation,
+ Mesh mesh, PrimitiveBaseShape pbs)
{
BulletXPrim newPrim = null;
lock (BulletXLock)
@@ -372,6 +430,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
return newPrim;
}
+
public override void RemovePrim(PhysicsActor prim)
{
if (prim is BulletXPrim)
@@ -380,19 +439,20 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{
try
{
- ddWorld.RemoveRigidBody(((BulletXPrim)prim).RigidBody);
+ ddWorld.RemoveRigidBody(((BulletXPrim) prim).RigidBody);
}
catch (Exception ex)
{
BulletXMessage(is_ex_message + ex.Message, true);
- ((BulletXPrim)prim).RigidBody.ActivationState = ActivationState.DisableSimulation;
- AddForgottenRigidBody(((BulletXPrim)prim).RigidBody);
+ ((BulletXPrim) prim).RigidBody.ActivationState = ActivationState.DisableSimulation;
+ AddForgottenRigidBody(((BulletXPrim) prim).RigidBody);
}
- _prims.Remove((BulletXPrim)prim);
+ _prims.Remove((BulletXPrim) prim);
}
GC.Collect();
}
}
+
public override void Simulate(float timeStep)
{
lock (BulletXLock)
@@ -408,6 +468,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
UpdateKineticsForAll();
}
}
+
private void MoveAllObjects(float timeStep)
{
foreach (BulletXCharacter actor in _characters)
@@ -418,6 +479,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{
}
}
+
private void ValidateHeightForAll()
{
float _height;
@@ -431,7 +493,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
foreach (BulletXPrim prim in _prims)
{
//_height = HeightValue(prim.RigidBodyPosition);
- _height = _simFlatPlanet.HeightValue(prim.RigidBodyPosition);
+ _height = _simFlatPlanet.HeightValue(prim.RigidBodyPosition);
prim.ValidateHeight(_height);
//if (_simFlatPlanet.heightIsNotValid(prim.RigidBodyPosition, out _height)) prim.ValidateHeight(_height);
}
@@ -444,6 +506,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
// prim.ValidateHeight(0);
//}
}
+
private void UpdateKineticsForAll()
{
//UpdatePosition > UpdateKinetics.
@@ -458,17 +521,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
//if(this._simFlatPlanet!=null) this._simFlatPlanet.Restore();
}
+
public override void GetResults()
{
-
}
+
public override bool IsThreaded
{
- get
- {
- return (false); // for now we won't be multithreaded
+ get { return (false); // for now we won't be multithreaded
}
}
+
public override void SetTerrain(float[] heightMap)
{
////As the same as ODE, heightmap (x,y) must be swapped for BulletX
@@ -494,41 +557,44 @@ namespace OpenSim.Region.Physics.BulletXPlugin
DeleteTerrain();
//There is a BulletXLock inside the constructor of BulletXPlanet
//this._simFlatPlanet = new BulletXPlanet(this, swappedHeightMap);
- this._simFlatPlanet = new BulletXPlanet(this, heightMap);
+ _simFlatPlanet = new BulletXPlanet(this, heightMap);
//this._heightmap = heightMap;
}
+
public override void DeleteTerrain()
{
- if (this._simFlatPlanet != null)
+ if (_simFlatPlanet != null)
{
lock (BulletXLock)
{
try
{
- ddWorld.RemoveRigidBody(this._simFlatPlanet.RigidBody);
+ ddWorld.RemoveRigidBody(_simFlatPlanet.RigidBody);
}
catch (Exception ex)
{
BulletXMessage(is_ex_message + ex.Message, true);
- this._simFlatPlanet.RigidBody.ActivationState = ActivationState.DisableSimulation;
- AddForgottenRigidBody(this._simFlatPlanet.RigidBody);
+ _simFlatPlanet.RigidBody.ActivationState = ActivationState.DisableSimulation;
+ AddForgottenRigidBody(_simFlatPlanet.RigidBody);
}
}
- this._simFlatPlanet = null;
+ _simFlatPlanet = null;
GC.Collect();
BulletXMessage("Terrain erased!", false);
}
//this._heightmap = null;
}
+
internal void AddForgottenRigidBody(RigidBody forgottenRigidBody)
{
_forgottenRigidBodies.Add(forgottenRigidBody);
}
+
private void RemoveForgottenRigidBodies()
{
RigidBody forgottenRigidBody;
int nRigidBodies = _forgottenRigidBodies.Count;
- for(int i = nRigidBodies - 1; i >= 0; i--)
+ for (int i = nRigidBodies - 1; i >= 0; i--)
{
forgottenRigidBody = _forgottenRigidBodies[i];
try
@@ -544,10 +610,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
GC.Collect();
}
+
internal void BulletXMessage(string message, bool isWarning)
{
PhysicsPluginManager.PhysicsPluginMessage("[Modified BulletX]:\t" + message, isWarning);
}
+
//temp
//private float HeightValue(MonoXnaCompactMaths.Vector3 position)
//{
@@ -559,10 +627,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin
// height = this._heightmap[li_y * 256 + li_x];
// if (height < 0) height = 0;
// else if (height > maxZ) height = maxZ;
-
+
// return height;
//}
}
+
///
/// PhysicsActor Character Class for BulletX
///
@@ -576,21 +645,24 @@ namespace OpenSim.Region.Physics.BulletXPlugin
private bool flying;
private RigidBody rigidBody;
- public MonoXnaCompactMaths.Vector3 RigidBodyPosition
+ public Vector3 RigidBodyPosition
{
- get { return this.rigidBody.CenterOfMassPosition; }
+ get { return rigidBody.CenterOfMassPosition; }
}
+
public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos)
: this("", parent_scene, pos)
{
}
+
public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos)
: this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(),
- AxiomQuaternion.Identity)
+ AxiomQuaternion.Identity)
{
}
+
public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity,
- PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation)
+ PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation)
{
//This fields will be removed. They're temporal
float _sizeX = 0.5f;
@@ -622,23 +694,23 @@ namespace OpenSim.Region.Physics.BulletXPlugin
//For now, like ODE, collisionShape = sphere of radious = 1.0
CollisionShape _collisionShape = new SphereShape(1.0f);
DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
- MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3();
+ Vector3 _localInertia = new Vector3();
_collisionShape.CalculateLocalInertia(_mass, out _localInertia); //Always when mass > 0
- rigidBody = new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
+ rigidBody =
+ new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping,
+ _friction, _restitution);
//rigidBody.ActivationState = ActivationState.DisableDeactivation;
//It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition
- MonoXnaCompactMaths.Vector3 _vDebugTranslation;
+ Vector3 _vDebugTranslation;
_vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition;
rigidBody.Translate(_vDebugTranslation);
parent_scene.ddWorld.AddRigidBody(rigidBody);
}
}
+
public override PhysicsVector Position
{
- get
- {
- return _position;
- }
+ get { return _position; }
set
{
lock (BulletXScene.BulletXLock)
@@ -648,12 +720,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
}
}
+
public override PhysicsVector Velocity
{
- get
- {
- return _velocity;
- }
+ get { return _velocity; }
set
{
lock (BulletXScene.BulletXLock)
@@ -663,12 +733,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
}
}
+
public override PhysicsVector Size
{
- get
- {
- return _size;
- }
+ get { return _size; }
set
{
lock (BulletXScene.BulletXLock)
@@ -677,19 +745,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
}
}
+
public override PhysicsVector Acceleration
{
- get
- {
- return _acceleration;
- }
+ get { return _acceleration; }
}
+
public override AxiomQuaternion Orientation
{
- get
- {
- return _orientation;
- }
+ get { return _orientation; }
set
{
lock (BulletXScene.BulletXLock)
@@ -698,24 +762,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
}
}
+
public RigidBody RigidBody
{
- get
- {
- return rigidBody;
- }
+ get { return rigidBody; }
}
+
public override bool Flying
{
- get
- {
- return flying;
- }
- set
- {
- flying = value;
- }
+ get { return flying; }
+ set { flying = value; }
}
+
public void SetAcceleration(PhysicsVector accel)
{
lock (BulletXScene.BulletXLock)
@@ -723,116 +781,121 @@ namespace OpenSim.Region.Physics.BulletXPlugin
_acceleration = accel;
}
}
+
public override bool Kinematic
{
- get
- {
- return false;
- }
- set
- {
-
- }
+ get { return false; }
+ set { }
}
+
public override void AddForce(PhysicsVector force)
{
-
}
+
public override void SetMomentum(PhysicsVector momentum)
{
-
}
+
internal void Move(float timeStep)
{
- MonoXnaCompactMaths.Vector3 vec = new MonoXnaCompactMaths.Vector3();
+ Vector3 vec = new Vector3();
//At this point it's supossed that:
//_velocity == rigidBody.LinearVelocity
- vec.X = this._velocity.X;
- vec.Y = this._velocity.Y;
- vec.Z = this._velocity.Z;
+ vec.X = _velocity.X;
+ vec.Y = _velocity.Y;
+ vec.Z = _velocity.Z;
if ((vec.X != 0.0f) || (vec.Y != 0.0f) || (vec.Z != 0.0f)) rigidBody.Activate();
if (flying)
{
//Antigravity with movement
- if (this._position.Z <= BulletXScene.HeightLevel0)
+ if (_position.Z <= BulletXScene.HeightLevel0)
{
- vec.Z += BulletXScene.Gravity * timeStep;
+ vec.Z += BulletXScene.Gravity*timeStep;
}
- //Lowgravity with movement
- else if ((this._position.Z > BulletXScene.HeightLevel0)
- && (this._position.Z <= BulletXScene.HeightLevel1))
+ //Lowgravity with movement
+ else if ((_position.Z > BulletXScene.HeightLevel0)
+ && (_position.Z <= BulletXScene.HeightLevel1))
{
- vec.Z += BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
+ vec.Z += BulletXScene.Gravity*timeStep*(1.0f - BulletXScene.LowGravityFactor);
}
- //Lowgravity with...
- else if (this._position.Z > BulletXScene.HeightLevel1)
+ //Lowgravity with...
+ else if (_position.Z > BulletXScene.HeightLevel1)
{
if (vec.Z > 0) //no movement
- vec.Z = BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
+ vec.Z = BulletXScene.Gravity*timeStep*(1.0f - BulletXScene.LowGravityFactor);
else
- vec.Z += BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
-
+ vec.Z += BulletXScene.Gravity*timeStep*(1.0f - BulletXScene.LowGravityFactor);
}
}
rigidBody.LinearVelocity = vec;
}
+
//This validation is very basic
internal void ValidateHeight(float heighmapPositionValue)
{
- if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue + _size.Z / 2.0f)
+ if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue + _size.Z/2.0f)
{
Matrix m = rigidBody.WorldTransform;
- MonoXnaCompactMaths.Vector3 v3 = m.Translation;
- v3.Z = heighmapPositionValue + _size.Z / 2.0f;
+ Vector3 v3 = m.Translation;
+ v3.Z = heighmapPositionValue + _size.Z/2.0f;
m.Translation = v3;
rigidBody.WorldTransform = m;
//When an Avie touch the ground it's vertical velocity it's reduced to ZERO
- Speed(new PhysicsVector(this.rigidBody.LinearVelocity.X, this.rigidBody.LinearVelocity.Y, 0.0f));
+ Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
}
}
+
internal void UpdateKinetics()
{
- this._position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
- this._velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity);
+ _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
+ _velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity);
//Orientation it seems that it will be the default.
ReOrient();
}
#region Methods for updating values of RigidBody
+
private void Translate()
{
- Translate(this._position);
+ Translate(_position);
}
+
private void Translate(PhysicsVector _newPos)
{
- MonoXnaCompactMaths.Vector3 _translation;
+ Vector3 _translation;
_translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition;
rigidBody.Translate(_translation);
}
+
private void Speed()
{
- Speed(this._velocity);
+ Speed(_velocity);
}
+
private void Speed(PhysicsVector _newSpeed)
{
- MonoXnaCompactMaths.Vector3 _speed;
+ Vector3 _speed;
_speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed);
rigidBody.LinearVelocity = _speed;
}
+
private void ReOrient()
{
- ReOrient(this._orientation);
+ ReOrient(_orientation);
}
+
private void ReOrient(AxiomQuaternion _newOrient)
{
- MonoXnaCompactMaths.Quaternion _newOrientation;
+ Quaternion _newOrientation;
_newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient);
Matrix _comTransform = rigidBody.CenterOfMassTransform;
BulletXMaths.SetRotation(ref _comTransform, _newOrientation);
rigidBody.CenterOfMassTransform = _comTransform;
}
+
#endregion
}
+
///
/// PhysicsActor Prim Class for BulletX
///
@@ -851,27 +914,32 @@ namespace OpenSim.Region.Physics.BulletXPlugin
//_physical value will be linked with the prim object value
private Boolean _physical = false;
- public MonoXnaCompactMaths.Vector3 RigidBodyPosition
+ public Vector3 RigidBodyPosition
{
- get { return this.rigidBody.CenterOfMassPosition; }
+ get { return rigidBody.CenterOfMassPosition; }
}
+
public BulletXPrim(BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, AxiomQuaternion rotation)
: this("", parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, null, null)
{
}
- public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size,
- AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
+
+ public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size,
+ AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
: this(primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs)
{
}
- public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, PhysicsVector size,
- PhysicsVector aceleration, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
+
+ public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity,
+ PhysicsVector size,
+ PhysicsVector aceleration, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
{
if ((size.X == 0) || (size.Y == 0) || (size.Z == 0)) throw new Exception("Size 0");
if (rotation.Norm == 0f) rotation = AxiomQuaternion.Identity;
_position = pos;
- if (_physical) _velocity = velocity; else _velocity = new PhysicsVector();
+ if (_physical) _velocity = velocity;
+ else _velocity = new PhysicsVector();
_size = size;
_acceleration = aceleration;
_orientation = rotation;
@@ -889,26 +957,26 @@ namespace OpenSim.Region.Physics.BulletXPlugin
{
_startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(pos);
//For now all prims are boxes
- CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_size) / 2.0f);
+ CollisionShape _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_size)/2.0f);
DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
- MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3();
- if(_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
- rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
+ Vector3 _localInertia = new Vector3();
+ if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
+ rigidBody =
+ new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping,
+ _friction, _restitution);
//rigidBody.ActivationState = ActivationState.DisableDeactivation;
//It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition
- MonoXnaCompactMaths.Vector3 _vDebugTranslation;
+ Vector3 _vDebugTranslation;
_vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition;
rigidBody.Translate(_vDebugTranslation);
//---
parent_scene.ddWorld.AddRigidBody(rigidBody);
}
}
+
public override PhysicsVector Position
{
- get
- {
- return _position;
- }
+ get { return _position; }
set
{
lock (BulletXScene.BulletXLock)
@@ -918,12 +986,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
}
}
+
public override PhysicsVector Velocity
{
- get
- {
- return _velocity;
- }
+ get { return _velocity; }
set
{
lock (BulletXScene.BulletXLock)
@@ -941,12 +1007,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
}
}
+
public override PhysicsVector Size
{
- get
- {
- return _size;
- }
+ get { return _size; }
set
{
lock (BulletXScene.BulletXLock)
@@ -956,19 +1020,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
}
}
+
public override PhysicsVector Acceleration
{
- get
- {
- return _acceleration;
- }
+ get { return _acceleration; }
}
+
public override AxiomQuaternion Orientation
{
- get
- {
- return _orientation;
- }
+ get { return _orientation; }
set
{
lock (BulletXScene.BulletXLock)
@@ -978,43 +1038,34 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
}
}
+
public float Mass
{
get
{
//For now all prims are boxes
- return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z;
+ return (_physical ? 1 : 0)*_density*_size.X*_size.Y*_size.Z;
}
}
+
public RigidBody RigidBody
{
- get
- {
- return rigidBody;
- }
+ get { return rigidBody; }
}
+
public override bool Flying
{
- get
- {
- return false; //no flying prims for you
- }
- set
- {
-
+ get { return false; //no flying prims for you
}
+ set { }
}
+
public Boolean Physical
{
- get
- {
- return _physical;
- }
- set
- {
- _physical = value;
- }
+ get { return _physical; }
+ set { _physical = value; }
}
+
public void SetAcceleration(PhysicsVector accel)
{
lock (BulletXScene.BulletXLock)
@@ -1022,6 +1073,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
_acceleration = accel;
}
}
+
public override bool Kinematic
{
get
@@ -1034,36 +1086,38 @@ namespace OpenSim.Region.Physics.BulletXPlugin
//this._prim.Kinematic = value;
}
}
+
public override void AddForce(PhysicsVector force)
{
-
}
+
public override void SetMomentum(PhysicsVector momentum)
{
-
}
+
internal void ValidateHeight(float heighmapPositionValue)
{
- if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue + _size.Z / 2.0f)
+ if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue + _size.Z/2.0f)
{
Matrix m = rigidBody.WorldTransform;
- MonoXnaCompactMaths.Vector3 v3 = m.Translation;
- v3.Z = heighmapPositionValue + _size.Z / 2.0f;
+ Vector3 v3 = m.Translation;
+ v3.Z = heighmapPositionValue + _size.Z/2.0f;
m.Translation = v3;
rigidBody.WorldTransform = m;
//When a Prim touch the ground it's vertical velocity it's reduced to ZERO
//Static objects don't have linear velocity
- if(_physical)
- Speed(new PhysicsVector(this.rigidBody.LinearVelocity.X, this.rigidBody.LinearVelocity.Y, 0.0f));
+ if (_physical)
+ Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
}
}
+
internal void UpdateKinetics()
{
if (_physical) //Updates properties. Prim updates its properties physically
{
- this._position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
- this._velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity);
- this._orientation = BulletXMaths.XnaQuaternionToAxiomQuaternion(rigidBody.Orientation);
+ _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
+ _velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity);
+ _orientation = BulletXMaths.XnaQuaternionToAxiomQuaternion(rigidBody.Orientation);
}
else //Doesn't updates properties. That's a cancel
{
@@ -1074,35 +1128,41 @@ namespace OpenSim.Region.Physics.BulletXPlugin
}
#region Methods for updating values of RigidBody
+
private void Translate()
{
- Translate(this._position);
+ Translate(_position);
}
+
private void Translate(PhysicsVector _newPos)
{
- MonoXnaCompactMaths.Vector3 _translation;
+ Vector3 _translation;
_translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition;
rigidBody.Translate(_translation);
}
+
private void Speed()
{
- Speed(this._velocity);
+ Speed(_velocity);
}
+
private void Speed(PhysicsVector _newSpeed)
{
- MonoXnaCompactMaths.Vector3 _speed;
+ Vector3 _speed;
_speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed);
rigidBody.LinearVelocity = _speed;
}
+
private void ReSize()
{
- ReSize(this._size);
+ ReSize(_size);
}
+
private void ReSize(PhysicsVector _newSize)
{
//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
- MonoXnaCompactMaths.Vector3 _newsize;
+ Vector3 _newsize;
_newsize = BulletXMaths.PhysicsVectorToXnaVector3(_newSize);
if ((_newsize.X == 0) || (_newsize.Y == 0) || (_newsize.Z == 0)) throw new Exception("Size 0");
@@ -1114,67 +1174,77 @@ namespace OpenSim.Region.Physics.BulletXPlugin
Matrix _startTransform = Matrix.Identity;
Matrix _centerOfMassOffset = Matrix.Identity;
RigidBody _tmpRigidBody;
- _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(this._position);
+ _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(_position);
//For now all prims are boxes
- CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_newSize) / 2.0f);
+ CollisionShape _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_newSize)/2.0f);
DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
- MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3();
+ Vector3 _localInertia = new Vector3();
if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
- _tmpRigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
+ _tmpRigidBody =
+ new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping,
+ _friction, _restitution);
//rigidBody.ActivationState = ActivationState.DisableDeactivation;
//It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition
- MonoXnaCompactMaths.Vector3 _vDebugTranslation;
+ Vector3 _vDebugTranslation;
_vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition;
_tmpRigidBody.Translate(_vDebugTranslation);
//---
//There is a bug when trying to remove a rigidBody that is colliding with something..
try
{
- this._parent_scene.ddWorld.RemoveRigidBody(rigidBody);
+ _parent_scene.ddWorld.RemoveRigidBody(rigidBody);
}
- catch(Exception ex)
+ catch (Exception ex)
{
- this._parent_scene.BulletXMessage(this._parent_scene.is_ex_message + ex.Message, true);
+ _parent_scene.BulletXMessage(_parent_scene.is_ex_message + ex.Message, true);
rigidBody.ActivationState = ActivationState.DisableSimulation;
- this._parent_scene.AddForgottenRigidBody(rigidBody);
+ _parent_scene.AddForgottenRigidBody(rigidBody);
}
rigidBody = _tmpRigidBody;
- this._parent_scene.ddWorld.AddRigidBody(rigidBody);
- if (_physical) Speed();//Static objects don't have linear velocity
+ _parent_scene.ddWorld.AddRigidBody(rigidBody);
+ if (_physical) Speed(); //Static objects don't have linear velocity
ReOrient();
GC.Collect();
}
+
private void ReOrient()
{
- ReOrient(this._orientation);
+ ReOrient(_orientation);
}
+
private void ReOrient(AxiomQuaternion _newOrient)
{
- MonoXnaCompactMaths.Quaternion _newOrientation;
+ Quaternion _newOrientation;
_newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient);
Matrix _comTransform = rigidBody.CenterOfMassTransform;
BulletXMaths.SetRotation(ref _comTransform, _newOrientation);
rigidBody.CenterOfMassTransform = _comTransform;
}
- #endregion
+ #endregion
}
+
///
/// This Class manage a HeighField as a RigidBody. This is for to be added in the BulletXScene
///
internal class BulletXPlanet
{
private PhysicsVector _staticPosition;
- private PhysicsVector _staticVelocity;
+ private PhysicsVector _staticVelocity;
private AxiomQuaternion _staticOrientation;
private float _mass;
private BulletXScene _parentscene;
internal float[] _heightField;
private RigidBody _flatPlanet;
- internal RigidBody RigidBody { get { return _flatPlanet; } }
+
+ internal RigidBody RigidBody
+ {
+ get { return _flatPlanet; }
+ }
+
internal BulletXPlanet(BulletXScene parent_scene, float[] heightField)
{
- _staticPosition = new PhysicsVector(BulletXScene.MaxXY / 2, BulletXScene.MaxXY/2, 0);
+ _staticPosition = new PhysicsVector(BulletXScene.MaxXY/2, BulletXScene.MaxXY/2, 0);
_staticVelocity = new PhysicsVector();
_staticOrientation = AxiomQuaternion.Identity;
_mass = 0; //No active
@@ -1193,40 +1263,45 @@ namespace OpenSim.Region.Physics.BulletXPlugin
try
{
_startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(_staticPosition);
- CollisionShape _collisionShape = new HeightfieldTerrainShape(BulletXScene.MaxXY, BulletXScene.MaxXY, _heightField, (float)BulletXScene.MaxZ, 2, true, false);
+ CollisionShape _collisionShape =
+ new HeightfieldTerrainShape(BulletXScene.MaxXY, BulletXScene.MaxXY, _heightField,
+ (float) BulletXScene.MaxZ, 2, true, false);
DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
- MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3();
+ Vector3 _localInertia = new Vector3();
//_collisionShape.CalculateLocalInertia(_mass, out _localInertia); //Always when mass > 0
- _flatPlanet = new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
+ _flatPlanet =
+ new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping,
+ _angularDamping, _friction, _restitution);
//It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition
- MonoXnaCompactMaths.Vector3 _vDebugTranslation;
+ Vector3 _vDebugTranslation;
_vDebugTranslation = _startTransform.Translation - _flatPlanet.CenterOfMassPosition;
_flatPlanet.Translate(_vDebugTranslation);
parent_scene.ddWorld.AddRigidBody(_flatPlanet);
}
catch (Exception ex)
{
- this._parentscene.BulletXMessage(ex.Message, true);
+ _parentscene.BulletXMessage(ex.Message, true);
}
}
- this._parentscene.BulletXMessage("BulletXPlanet created.", false);
+ _parentscene.BulletXMessage("BulletXPlanet created.", false);
}
- internal float HeightValue(MonoXnaCompactMaths.Vector3 position)
+
+ internal float HeightValue(Vector3 position)
{
int li_x, li_y;
float height;
- li_x = (int)Math.Round(position.X);
+ li_x = (int) Math.Round(position.X);
if (li_x < 0) li_x = 0;
if (li_x >= BulletXScene.MaxXY) li_x = BulletXScene.MaxXY - 1;
- li_y = (int)Math.Round(position.Y);
+ li_y = (int) Math.Round(position.Y);
if (li_y < 0) li_y = 0;
if (li_y >= BulletXScene.MaxXY) li_y = BulletXScene.MaxXY - 1;
- height = ((HeightfieldTerrainShape)this._flatPlanet.CollisionShape).getHeightFieldValue(li_x, li_y);
+ height = ((HeightfieldTerrainShape) _flatPlanet.CollisionShape).getHeightFieldValue(li_x, li_y);
if (height < 0) height = 0;
else if (height > BulletXScene.MaxZ) height = BulletXScene.MaxZ;
return height;
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
index 2355e91..c213b64 100644
--- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
@@ -27,24 +27,26 @@
*/
using System.Reflection;
using System.Runtime.InteropServices;
+
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
-[assembly: AssemblyTitle("PhysicsManager")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("PhysicsManager")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly : AssemblyTitle("PhysicsManager")]
+[assembly : AssemblyDescription("")]
+[assembly : AssemblyConfiguration("")]
+[assembly : AssemblyCompany("")]
+[assembly : AssemblyProduct("PhysicsManager")]
+[assembly : AssemblyCopyright("")]
+[assembly : AssemblyTrademark("")]
+[assembly : AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
+
+[assembly : ComVisible(false)]
// The assembly version has following format :
//
@@ -53,4 +55,4 @@ using System.Runtime.InteropServices;
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
-[assembly: AssemblyVersion("1.0.*")]
+[assembly : AssemblyVersion("1.0.*")]
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 0fa7455..b59c13a 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -30,7 +30,9 @@ using Axiom.Math;
namespace OpenSim.Region.Physics.Manager
{
public delegate void PositionUpdate(PhysicsVector position);
+
public delegate void VelocityUpdate(PhysicsVector velocity);
+
public delegate void OrientationUpdate(Quaternion orientation);
public abstract class PhysicsActor
@@ -43,52 +45,22 @@ namespace OpenSim.Region.Physics.Manager
public static PhysicsActor Null
{
- get
- {
- return new NullPhysicsActor();
- }
+ get { return new NullPhysicsActor(); }
}
- public abstract PhysicsVector Size
- {
- get;
- set;
- }
+ public abstract PhysicsVector Size { get; set; }
- public abstract PhysicsVector Position
- {
- get;
- set;
- }
+ public abstract PhysicsVector Position { get; set; }
- public abstract PhysicsVector Velocity
- {
- get;
- set;
- }
+ public abstract PhysicsVector Velocity { get; set; }
- public abstract PhysicsVector Acceleration
- {
- get;
- }
+ public abstract PhysicsVector Acceleration { get; }
- public abstract Quaternion Orientation
- {
- get;
- set;
- }
+ public abstract Quaternion Orientation { get; set; }
- public abstract bool Flying
- {
- get;
- set;
- }
+ public abstract bool Flying { get; set; }
- public abstract bool Kinematic
- {
- get;
- set;
- }
+ public abstract bool Kinematic { get; set; }
public abstract void AddForce(PhysicsVector force);
@@ -99,50 +71,26 @@ namespace OpenSim.Region.Physics.Manager
{
public override PhysicsVector Position
{
- get
- {
- return PhysicsVector.Zero;
- }
- set
- {
- return;
- }
+ get { return PhysicsVector.Zero; }
+ set { return; }
}
public override PhysicsVector Size
{
- get
- {
- return PhysicsVector.Zero;
- }
- set
- {
- return;
- }
+ get { return PhysicsVector.Zero; }
+ set { return; }
}
public override PhysicsVector Velocity
{
- get
- {
- return PhysicsVector.Zero;
- }
- set
- {
- return;
- }
+ get { return PhysicsVector.Zero; }
+ set { return; }
}
public override Quaternion Orientation
{
- get
- {
- return Quaternion.Identity;
- }
- set
- {
-
- }
+ get { return Quaternion.Identity; }
+ set { }
}
public override PhysicsVector Acceleration
@@ -152,26 +100,14 @@ namespace OpenSim.Region.Physics.Manager
public override bool Flying
{
- get
- {
- return false;
- }
- set
- {
- return;
- }
+ get { return false; }
+ set { return; }
}
public override bool Kinematic
{
- get
- {
- return true;
- }
- set
- {
- return;
- }
+ get { return true; }
+ set { return; }
}
public override void AddForce(PhysicsVector force)
@@ -184,4 +120,4 @@ namespace OpenSim.Region.Physics.Manager
return;
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
index 81bc938..09ebf29 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
@@ -33,77 +33,77 @@ using OpenSim.Framework.Console;
namespace OpenSim.Region.Physics.Manager
{
- ///
- /// Description of MyClass.
- ///
- public class PhysicsPluginManager
- {
- private Dictionary _plugins=new Dictionary();
-
- public PhysicsPluginManager()
- {
-
- }
-
- public PhysicsScene GetPhysicsScene(string engineName)
- {
+ ///
+ /// Description of MyClass.
+ ///
+ public class PhysicsPluginManager
+ {
+ private Dictionary _plugins = new Dictionary();
+
+ public PhysicsPluginManager()
+ {
+ }
+
+ public PhysicsScene GetPhysicsScene(string engineName)
+ {
if (String.IsNullOrEmpty(engineName))
{
return PhysicsScene.Null;
}
- if(_plugins.ContainsKey(engineName))
- {
- MainLog.Instance.Verbose("PHYSICS","creating "+engineName);
- return _plugins[engineName].GetScene();
- }
- else
+ if (_plugins.ContainsKey(engineName))
+ {
+ MainLog.Instance.Verbose("PHYSICS", "creating " + engineName);
+ return _plugins[engineName].GetScene();
+ }
+ else
{
MainLog.Instance.Warn("PHYSICS", "couldn't find physicsEngine: {0}", engineName);
- throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName));
- }
- }
-
- public void LoadPlugins()
- {
- string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"Physics");
- string[] pluginFiles = Directory.GetFiles(path, "*.dll");
-
+ throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", engineName));
+ }
+ }
+
+ public void LoadPlugins()
+ {
+ string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics");
+ string[] pluginFiles = Directory.GetFiles(path, "*.dll");
+
- for(int i= 0; i";
+ return "<" + X + "," + Y + "," + Z + ">";
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
index 3f840cc..d110a17 100644
--- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
@@ -27,24 +27,26 @@
*/
using System.Reflection;
using System.Runtime.InteropServices;
+
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
-[assembly: AssemblyTitle("RealPhysXplugin")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("RealPhysXplugin")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly : AssemblyTitle("RealPhysXplugin")]
+[assembly : AssemblyDescription("")]
+[assembly : AssemblyConfiguration("")]
+[assembly : AssemblyCompany("")]
+[assembly : AssemblyProduct("RealPhysXplugin")]
+[assembly : AssemblyCopyright("")]
+[assembly : AssemblyTrademark("")]
+[assembly : AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
+
+[assembly : ComVisible(false)]
// The assembly version has following format :
//
@@ -53,4 +55,4 @@ using System.Runtime.InteropServices;
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
-[assembly: AssemblyVersion("1.0.*")]
+[assembly : AssemblyVersion("1.0.*")]
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/OdePlugin/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/OdePlugin/Meshing/HelperTypes.cs
index 2ace097..13184e2 100644
--- a/OpenSim/Region/Physics/OdePlugin/Meshing/HelperTypes.cs
+++ b/OpenSim/Region/Physics/OdePlugin/Meshing/HelperTypes.cs
@@ -27,10 +27,9 @@
*/
using System;
-using System.Globalization;
-using System.Diagnostics;
using System.Collections.Generic;
-
+using System.Diagnostics;
+using System.Globalization;
using OpenSim.Region.Physics.Manager;
public class Vertex : IComparable
@@ -76,8 +75,6 @@ public class Vertex : IComparable
{
return me.CompareTo(other) < 0;
}
-
-
}
public class Simplex : IComparable
@@ -122,8 +119,7 @@ public class Simplex : IComparable
return 0;
}
-
-};
+} ;
public class Triangle
{
@@ -131,9 +127,9 @@ public class Triangle
public Vertex v2;
public Vertex v3;
- float radius_square;
- float cx;
- float cy;
+ private float radius_square;
+ private float cx;
+ private float cy;
public Triangle(Vertex _v1, Vertex _v2, Vertex _v3)
{
@@ -149,18 +145,18 @@ public class Triangle
float dx, dy;
float dd;
- dx = x - this.cx;
- dy = y - this.cy;
+ dx = x - cx;
+ dy = y - cy;
- dd = dx * dx + dy * dy;
- if (dd < this.radius_square)
+ dd = dx*dx + dy*dy;
+ if (dd < radius_square)
return true;
else
return false;
}
- void CalcCircle()
+ private void CalcCircle()
{
// Calculate the center and the radius of a circle given by three points p1, p2, p3
// It is assumed, that the triangles vertices are already set correctly
@@ -198,8 +194,8 @@ public class Triangle
p3y = v3.point.Y;
/* calc helping values first */
- c1 = (p1x * p1x + p1y * p1y - p2x * p2x - p2y * p2y) / 2;
- c2 = (p1x * p1x + p1y * p1y - p3x * p3x - p3y * p3y) / 2;
+ c1 = (p1x*p1x + p1y*p1y - p2x*p2x - p2y*p2y)/2;
+ c2 = (p1x*p1x + p1y*p1y - p3x*p3x - p3y*p3y)/2;
v1x = p1x - p2x;
v1y = p1y - p2y;
@@ -207,35 +203,34 @@ public class Triangle
v2x = p1x - p3x;
v2y = p1y - p3y;
- z = (c1 * v2x - c2 * v1x);
- n = (v1y * v2x - v2y * v1x);
+ z = (c1*v2x - c2*v1x);
+ n = (v1y*v2x - v2y*v1x);
- if (n == 0.0) // This is no triangle, i.e there are (at least) two points at the same location
+ if (n == 0.0) // This is no triangle, i.e there are (at least) two points at the same location
{
radius_square = 0.0f;
return;
}
- this.cy = (float)(z / n);
+ cy = (float) (z/n);
if (v2x != 0.0)
{
- this.cx = (float)((c2 - v2y * this.cy) / v2x);
+ cx = (float) ((c2 - v2y*cy)/v2x);
}
else if (v1x != 0.0)
{
- this.cx = (float)((c1 - v1y * this.cy) / v1x);
+ cx = (float) ((c1 - v1y*cy)/v1x);
}
else
{
Debug.Assert(false, "Malformed triangle"); /* Both terms zero means nothing good */
}
- rx = (p1x - this.cx);
- ry = (p1y - this.cy);
-
- this.radius_square = (float)(rx * rx + ry * ry);
+ rx = (p1x - cx);
+ ry = (p1y - cy);
+ radius_square = (float) (rx*rx + ry*ry);
}
public List GetSimplices()
@@ -254,17 +249,18 @@ public class Triangle
public override String ToString()
{
-
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.CurrencyDecimalDigits = 2;
nfi.CurrencyDecimalSeparator = ".";
- String s1 = "<" + v1.point.X.ToString(nfi) + "," + v1.point.Y.ToString(nfi) + "," + v1.point.Z.ToString(nfi) + ">";
- String s2 = "<" + v2.point.X.ToString(nfi) + "," + v2.point.Y.ToString(nfi) + "," + v2.point.Z.ToString(nfi) + ">";
- String s3 = "<" + v3.point.X.ToString(nfi) + "," + v3.point.Y.ToString(nfi) + "," + v3.point.Z.ToString(nfi) + ">";
+ String s1 = "<" + v1.point.X.ToString(nfi) + "," + v1.point.Y.ToString(nfi) + "," + v1.point.Z.ToString(nfi) +
+ ">";
+ String s2 = "<" + v2.point.X.ToString(nfi) + "," + v2.point.Y.ToString(nfi) + "," + v2.point.Z.ToString(nfi) +
+ ">";
+ String s3 = "<" + v3.point.X.ToString(nfi) + "," + v3.point.Y.ToString(nfi) + "," + v3.point.Z.ToString(nfi) +
+ ">";
return s1 + ";" + s2 + ";" + s3;
-
}
public PhysicsVector getNormal()
@@ -281,12 +277,12 @@ public class Triangle
// Cross product for normal
PhysicsVector n = new PhysicsVector();
float nx, ny, nz;
- n.X = e1.Y * e2.Z - e1.Z * e2.Y;
- n.Y = e1.Z * e2.X - e1.X * e2.Z;
- n.Z = e1.X * e2.Y - e1.Y * e2.X;
+ n.X = e1.Y*e2.Z - e1.Z*e2.Y;
+ n.Y = e1.Z*e2.X - e1.X*e2.Z;
+ n.Z = e1.X*e2.Y - e1.Y*e2.X;
// Length
- float l = (float)Math.Sqrt(n.X * n.X + n.Y * n.Y + n.Z * n.Z);
+ float l = (float) Math.Sqrt(n.X*n.X + n.Y*n.Y + n.Z*n.Z);
// Normalized "normal"
n.X /= l;
@@ -303,6 +299,4 @@ public class Triangle
v1 = v2;
v2 = vt;
}
-}
-
-
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs
index dd18e24..46de15e 100644
--- a/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs
@@ -27,12 +27,8 @@
*/
using System;
-using System.Globalization;
-using System.Diagnostics;
using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
-
using OpenSim.Framework;
using OpenSim.Region.Physics.Manager;
@@ -75,14 +71,14 @@ namespace OpenSim.Region.Physics.OdePlugin
public float[] getVertexListAsFloat()
{
- float[] result = new float[vertices.Count * 3];
+ float[] result = new float[vertices.Count*3];
for (int i = 0; i < vertices.Count; i++)
{
Vertex v = vertices[i];
PhysicsVector point = v.point;
- result[3 * i + 0] = point.X;
- result[3 * i + 1] = point.Y;
- result[3 * i + 2] = point.Z;
+ result[3*i + 0] = point.X;
+ result[3*i + 1] = point.Y;
+ result[3*i + 2] = point.Z;
}
GCHandle.Alloc(result, GCHandleType.Pinned);
return result;
@@ -90,13 +86,13 @@ namespace OpenSim.Region.Physics.OdePlugin
public int[] getIndexListAsInt()
{
- int[] result = new int[triangles.Count * 3];
+ int[] result = new int[triangles.Count*3];
for (int i = 0; i < triangles.Count; i++)
{
Triangle t = triangles[i];
- result[3 * i + 0] = vertices.IndexOf(t.v1);
- result[3 * i + 1] = vertices.IndexOf(t.v2);
- result[3 * i + 2] = vertices.IndexOf(t.v3);
+ result[3*i + 0] = vertices.IndexOf(t.v1);
+ result[3*i + 1] = vertices.IndexOf(t.v2);
+ result[3*i + 2] = vertices.IndexOf(t.v3);
}
GCHandle.Alloc(result, GCHandleType.Pinned);
return result;
@@ -110,16 +106,13 @@ namespace OpenSim.Region.Physics.OdePlugin
foreach (Triangle t in newMesh.triangles)
Add(t);
-
}
}
-
public class Meshmerizer
{
-
- static List FindInfluencedTriangles(List triangles, Vertex v)
+ private static List FindInfluencedTriangles(List triangles, Vertex v)
{
List influenced = new List();
foreach (Triangle t in triangles)
@@ -133,9 +126,10 @@ namespace OpenSim.Region.Physics.OdePlugin
}
return influenced;
}
-
-
- static void InsertVertices(List vertices, int usedForSeed, List triangles, List innerBorders)
+
+
+ private static void InsertVertices(List vertices, int usedForSeed, List triangles,
+ List innerBorders)
{
// This is a variant of the delaunay algorithm
// each time a new vertex is inserted, all triangles that are influenced by it are deleted
@@ -143,7 +137,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// It is not very time efficient but easy to implement.
int iCurrentVertex;
- int iMaxVertex=vertices.Count;
+ int iMaxVertex = vertices.Count;
for (iCurrentVertex = usedForSeed; iCurrentVertex < iMaxVertex; iCurrentVertex++)
{
// Background: A triangle mesh fulfills the delaunay condition if (iff!)
@@ -154,8 +148,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// do not fulfill this condition with respect to the new triangle
// Find the triangles that are influenced by the new vertex
- Vertex v=vertices[iCurrentVertex];
- List influencedTriangles=FindInfluencedTriangles(triangles, v);
+ Vertex v = vertices[iCurrentVertex];
+ List influencedTriangles = FindInfluencedTriangles(triangles, v);
List simplices = new List();
@@ -175,10 +169,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// Look for duplicate simplices here.
// Remember, they are directly side by side in the list right now
int iSimplex;
- List innerSimplices=new List();
+ List innerSimplices = new List();
for (iSimplex = 1; iSimplex < simplices.Count; iSimplex++) // Startindex=1, so we can refer backwards
{
- if (simplices[iSimplex - 1].CompareTo(simplices[iSimplex])==0)
+ if (simplices[iSimplex - 1].CompareTo(simplices[iSimplex]) == 0)
{
innerSimplices.Add(simplices[iSimplex - 1]);
innerSimplices.Add(simplices[iSimplex]);
@@ -187,7 +181,7 @@ namespace OpenSim.Region.Physics.OdePlugin
foreach (Simplex s in innerSimplices)
{
- simplices.Remove(s);
+ simplices.Remove(s);
}
// each simplex still in the list belongs to the hull of the region in question
@@ -210,7 +204,7 @@ namespace OpenSim.Region.Physics.OdePlugin
foreach (Triangle t in triangles)
{
if (
- innerBorders.Contains(vertices.IndexOf(t.v1))
+ innerBorders.Contains(vertices.IndexOf(t.v1))
&& innerBorders.Contains(vertices.IndexOf(t.v2))
&& innerBorders.Contains(vertices.IndexOf(t.v3))
)
@@ -223,18 +217,18 @@ namespace OpenSim.Region.Physics.OdePlugin
}
- static Mesh CreateBoxMeshX(PrimitiveBaseShape primShape, PhysicsVector size)
- // Builds the x (+ and -) surfaces of a box shaped prim
+ private static Mesh CreateBoxMeshX(PrimitiveBaseShape primShape, PhysicsVector size)
+ // Builds the x (+ and -) surfaces of a box shaped prim
{
UInt16 hollowFactor = primShape.ProfileHollow;
Mesh meshMX = new Mesh();
// Surface 0, -X
- meshMX.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
- meshMX.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
- meshMX.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
- meshMX.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
+ meshMX.Add(new Vertex("-X-Y-Z", -size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f));
+ meshMX.Add(new Vertex("-X+Y-Z", -size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f));
+ meshMX.Add(new Vertex("-X-Y+Z", -size.X/2.0f, -size.Y/2.0f, +size.Z/2.0f));
+ meshMX.Add(new Vertex("-X+Y+Z", -size.X/2.0f, +size.Y/2.0f, +size.Z/2.0f));
meshMX.Add(new Triangle(meshMX.vertices[0], meshMX.vertices[2], meshMX.vertices[1]));
meshMX.Add(new Triangle(meshMX.vertices[1], meshMX.vertices[2], meshMX.vertices[3]));
@@ -242,10 +236,10 @@ namespace OpenSim.Region.Physics.OdePlugin
Mesh meshPX = new Mesh();
// Surface 1, +X
- meshPX.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
- meshPX.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
- meshPX.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
- meshPX.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
+ meshPX.Add(new Vertex("+X-Y-Z", +size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f));
+ meshPX.Add(new Vertex("+X+Y-Z", +size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f));
+ meshPX.Add(new Vertex("+X-Y+Z", +size.X/2.0f, -size.Y/2.0f, +size.Z/2.0f));
+ meshPX.Add(new Vertex("+X+Y+Z", +size.X/2.0f, +size.Y/2.0f, +size.Z/2.0f));
meshPX.Add(new Triangle(meshPX.vertices[0], meshPX.vertices[1], meshPX.vertices[2]));
@@ -254,17 +248,17 @@ namespace OpenSim.Region.Physics.OdePlugin
if (hollowFactor > 0)
{
- float hollowFactorF = (float)hollowFactor / (float)50000;
+ float hollowFactorF = (float) hollowFactor/(float) 50000;
Vertex IPP;
Vertex IPM;
Vertex IMP;
Vertex IMM;
- IPP = new Vertex("Inner-X+Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
- IPM = new Vertex("Inner-X+Y-Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
- IMP = new Vertex("Inner-X-Y+Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
- IMM = new Vertex("Inner-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+ IPP = new Vertex("Inner-X+Y+Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, +size.Z/2.0f);
+ IPM = new Vertex("Inner-X+Y-Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, -size.Z/2.0f);
+ IMP = new Vertex("Inner-X-Y+Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, +size.Z/2.0f);
+ IMM = new Vertex("Inner-X-Y-Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, -size.Z/2.0f);
meshMX.Add(IPP);
meshMX.Add(IPM);
@@ -280,11 +274,10 @@ namespace OpenSim.Region.Physics.OdePlugin
}
-
- IPP = new Vertex("Inner+X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
- IPM = new Vertex("Inner+X+Y-Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
- IMP = new Vertex("Inner+X-Y+Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
- IMM = new Vertex("Inner+X-Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+ IPP = new Vertex("Inner+X+Y+Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, +size.Z/2.0f);
+ IPM = new Vertex("Inner+X+Y-Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, -size.Z/2.0f);
+ IMP = new Vertex("Inner+X-Y+Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, +size.Z/2.0f);
+ IMM = new Vertex("Inner+X-Y-Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, -size.Z/2.0f);
meshPX.Add(IPP);
meshPX.Add(IPM);
@@ -308,18 +301,17 @@ namespace OpenSim.Region.Physics.OdePlugin
}
-
- static Mesh CreateBoxMeshY(PrimitiveBaseShape primShape, PhysicsVector size)
- // Builds the y (+ and -) surfaces of a box shaped prim
+ private static Mesh CreateBoxMeshY(PrimitiveBaseShape primShape, PhysicsVector size)
+ // Builds the y (+ and -) surfaces of a box shaped prim
{
UInt16 hollowFactor = primShape.ProfileHollow;
// (M)inus Y
Mesh MeshMY = new Mesh();
- MeshMY.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
- MeshMY.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
- MeshMY.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
- MeshMY.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f));
+ MeshMY.Add(new Vertex("-X-Y-Z", -size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f));
+ MeshMY.Add(new Vertex("+X-Y-Z", +size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f));
+ MeshMY.Add(new Vertex("-X-Y+Z", -size.X/2.0f, -size.Y/2.0f, +size.Z/2.0f));
+ MeshMY.Add(new Vertex("+X-Y+Z", +size.X/2.0f, -size.Y/2.0f, +size.Z/2.0f));
MeshMY.Add(new Triangle(MeshMY.vertices[0], MeshMY.vertices[1], MeshMY.vertices[2]));
MeshMY.Add(new Triangle(MeshMY.vertices[2], MeshMY.vertices[1], MeshMY.vertices[3]));
@@ -327,27 +319,27 @@ namespace OpenSim.Region.Physics.OdePlugin
// (P)lus Y
Mesh MeshPY = new Mesh();
- MeshPY.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
- MeshPY.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
- MeshPY.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
- MeshPY.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f));
+ MeshPY.Add(new Vertex("-X+Y-Z", -size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f));
+ MeshPY.Add(new Vertex("+X+Y-Z", +size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f));
+ MeshPY.Add(new Vertex("-X+Y+Z", -size.X/2.0f, +size.Y/2.0f, +size.Z/2.0f));
+ MeshPY.Add(new Vertex("+X+Y+Z", +size.X/2.0f, +size.Y/2.0f, +size.Z/2.0f));
MeshPY.Add(new Triangle(MeshPY.vertices[1], MeshPY.vertices[0], MeshPY.vertices[2]));
MeshPY.Add(new Triangle(MeshPY.vertices[1], MeshPY.vertices[2], MeshPY.vertices[3]));
if (hollowFactor > 0)
{
- float hollowFactorF = (float)hollowFactor / (float)50000;
+ float hollowFactorF = (float) hollowFactor/(float) 50000;
Vertex IPP;
Vertex IPM;
Vertex IMP;
Vertex IMM;
- IPP = new Vertex("Inner+X-Y+Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
- IPM = new Vertex("Inner+X-Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
- IMP = new Vertex("Inner-X-Y+Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
- IMM = new Vertex("Inner-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+ IPP = new Vertex("Inner+X-Y+Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, +size.Z/2.0f);
+ IPM = new Vertex("Inner+X-Y-Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, -size.Z/2.0f);
+ IMP = new Vertex("Inner-X-Y+Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, +size.Z/2.0f);
+ IMM = new Vertex("Inner-X-Y-Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, -size.Z/2.0f);
MeshMY.Add(IPP);
MeshMY.Add(IPM);
@@ -363,11 +355,10 @@ namespace OpenSim.Region.Physics.OdePlugin
}
-
- IPP = new Vertex("Inner+X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
- IPM=new Vertex("Inner+X+Y-Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
- IMP=new Vertex("Inner-X+Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f);
- IMM=new Vertex("Inner-X+Y-Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f);
+ IPP = new Vertex("Inner+X+Y+Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, +size.Z/2.0f);
+ IPM = new Vertex("Inner+X+Y-Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, -size.Z/2.0f);
+ IMP = new Vertex("Inner-X+Y+Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, +size.Z/2.0f);
+ IMM = new Vertex("Inner-X+Y-Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, -size.Z/2.0f);
MeshPY.Add(IPP);
MeshPY.Add(IPM);
@@ -381,9 +372,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
PhysicsVector n = t.getNormal();
}
-
-
-
}
@@ -393,9 +381,9 @@ namespace OpenSim.Region.Physics.OdePlugin
return result;
}
-
- static Mesh CreateBoxMeshZ(PrimitiveBaseShape primShape, PhysicsVector size)
- // Builds the z (+ and -) surfaces of a box shaped prim
+
+ private static Mesh CreateBoxMeshZ(PrimitiveBaseShape primShape, PhysicsVector size)
+ // Builds the z (+ and -) surfaces of a box shaped prim
{
UInt16 hollowFactor = primShape.ProfileHollow;
@@ -403,10 +391,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// (M)inus Z
Mesh MZ = new Mesh();
- MZ.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
- MZ.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f));
- MZ.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
- MZ.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f));
+ MZ.Add(new Vertex("-X-Y-Z", -size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f));
+ MZ.Add(new Vertex("+X-Y-Z", +size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f));
+ MZ.Add(new Vertex("-X+Y-Z", -size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f));
+ MZ.Add(new Vertex("+X+Y-Z", +size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f));
MZ.Add(new Triangle(MZ.vertices[1], MZ.vertices[0], MZ.vertices[2]));
@@ -415,10 +403,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// (P)lus Z
Mesh PZ = new Mesh();
- PZ.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, 0.0f));
- PZ.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, 0.0f));
- PZ.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, 0.0f));
- PZ.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, 0.0f));
+ PZ.Add(new Vertex("-X-Y+Z", -size.X/2.0f, -size.Y/2.0f, 0.0f));
+ PZ.Add(new Vertex("+X-Y+Z", +size.X/2.0f, -size.Y/2.0f, 0.0f));
+ PZ.Add(new Vertex("-X+Y+Z", -size.X/2.0f, +size.Y/2.0f, 0.0f));
+ PZ.Add(new Vertex("+X+Y+Z", +size.X/2.0f, +size.Y/2.0f, 0.0f));
// Surface 5, +Z
PZ.Add(new Triangle(PZ.vertices[0], PZ.vertices[1], PZ.vertices[2]));
@@ -426,12 +414,12 @@ namespace OpenSim.Region.Physics.OdePlugin
if (hollowFactor > 0)
{
- float hollowFactorF = (float)hollowFactor / (float)50000;
+ float hollowFactorF = (float) hollowFactor/(float) 50000;
- MZ.Add(new Vertex("-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
- MZ.Add(new Vertex("-X+Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
- MZ.Add(new Vertex("-X-Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
- MZ.Add(new Vertex("-X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
+ MZ.Add(new Vertex("-X-Y-Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, 0.0f));
+ MZ.Add(new Vertex("-X+Y-Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, 0.0f));
+ MZ.Add(new Vertex("-X-Y+Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, 0.0f));
+ MZ.Add(new Vertex("-X+Y+Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, 0.0f));
List innerBorders = new List();
innerBorders.Add(4);
@@ -441,10 +429,10 @@ namespace OpenSim.Region.Physics.OdePlugin
InsertVertices(MZ.vertices, 4, MZ.triangles, innerBorders);
- PZ.Add(new Vertex("-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
- PZ.Add(new Vertex("-X+Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f));
- PZ.Add(new Vertex("-X-Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
- PZ.Add(new Vertex("-X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f));
+ PZ.Add(new Vertex("-X-Y-Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, 0.0f));
+ PZ.Add(new Vertex("-X+Y-Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, 0.0f));
+ PZ.Add(new Vertex("-X-Y+Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, 0.0f));
+ PZ.Add(new Vertex("-X+Y+Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, 0.0f));
innerBorders = new List();
innerBorders.Add(4);
@@ -453,16 +441,15 @@ namespace OpenSim.Region.Physics.OdePlugin
innerBorders.Add(7);
InsertVertices(PZ.vertices, 4, PZ.triangles, innerBorders);
-
}
foreach (Vertex v in PZ.vertices)
{
- v.point.Z = size.Z / 2.0f;
+ v.point.Z = size.Z/2.0f;
}
foreach (Vertex v in MZ.vertices)
{
- v.point.Z = -size.Z / 2.0f;
+ v.point.Z = -size.Z/2.0f;
}
foreach (Triangle t in MZ.triangles)
@@ -486,15 +473,14 @@ namespace OpenSim.Region.Physics.OdePlugin
return result;
}
- static Mesh CreateBoxMesh(PrimitiveBaseShape primShape, PhysicsVector size)
+ private static Mesh CreateBoxMesh(PrimitiveBaseShape primShape, PhysicsVector size)
{
Mesh result = new Mesh();
-
- Mesh MeshX = Meshmerizer.CreateBoxMeshX(primShape, size);
- Mesh MeshY = Meshmerizer.CreateBoxMeshY(primShape, size);
- Mesh MeshZ = Meshmerizer.CreateBoxMeshZ(primShape, size);
+ Mesh MeshX = CreateBoxMeshX(primShape, size);
+ Mesh MeshY = CreateBoxMeshY(primShape, size);
+ Mesh MeshZ = CreateBoxMeshZ(primShape, size);
result.Append(MeshX);
result.Append(MeshY);
@@ -504,64 +490,63 @@ namespace OpenSim.Region.Physics.OdePlugin
}
- public static void CalcNormals(Mesh mesh)
+ public static void CalcNormals(Mesh mesh)
{
int iTriangles = mesh.triangles.Count;
mesh.normals = new float[iTriangles*3];
- int i=0;
+ int i = 0;
foreach (Triangle t in mesh.triangles)
{
-
float ux, uy, uz;
float vx, vy, vz;
float wx, wy, wz;
- ux = t.v1.point.X;
- uy = t.v1.point.Y;
- uz = t.v1.point.Z;
+ ux = t.v1.point.X;
+ uy = t.v1.point.Y;
+ uz = t.v1.point.Z;
- vx = t.v2.point.X;
- vy = t.v2.point.Y;
- vz = t.v2.point.Z;
+ vx = t.v2.point.X;
+ vy = t.v2.point.Y;
+ vz = t.v2.point.Z;
- wx = t.v3.point.X;
- wy = t.v3.point.Y;
- wz = t.v3.point.Z;
+ wx = t.v3.point.X;
+ wy = t.v3.point.Y;
+ wz = t.v3.point.Z;
- // Vectors for edges
- float e1x, e1y, e1z;
- float e2x, e2y, e2z;
+ // Vectors for edges
+ float e1x, e1y, e1z;
+ float e2x, e2y, e2z;
- e1x = ux - vx;
- e1y = uy - vy;
- e1z = uz - vz;
+ e1x = ux - vx;
+ e1y = uy - vy;
+ e1z = uz - vz;
- e2x = ux - wx;
- e2y = uy - wy;
- e2z = uz - wz;
+ e2x = ux - wx;
+ e2y = uy - wy;
+ e2z = uz - wz;
- // Cross product for normal
- float nx, ny, nz;
- nx = e1y * e2z - e1z * e2y;
- ny = e1z * e2x - e1x * e2z;
- nz = e1x * e2y - e1y * e2x;
+ // Cross product for normal
+ float nx, ny, nz;
+ nx = e1y*e2z - e1z*e2y;
+ ny = e1z*e2x - e1x*e2z;
+ nz = e1x*e2y - e1y*e2x;
- // Length
- float l = (float)Math.Sqrt(nx * nx + ny * ny + nz * nz);
+ // Length
+ float l = (float) Math.Sqrt(nx*nx + ny*ny + nz*nz);
- // Normalized "normal"
- nx /= l;
- ny /= l;
- nz /= l;
+ // Normalized "normal"
+ nx /= l;
+ ny /= l;
+ nz /= l;
mesh.normals[i] = nx;
mesh.normals[i + 1] = ny;
mesh.normals[i + 2] = nz;
- i+=3;
+ i += 3;
}
}
@@ -572,18 +557,15 @@ namespace OpenSim.Region.Physics.OdePlugin
switch (primShape.ProfileShape)
{
case ProfileShape.Square:
- mesh=CreateBoxMesh(primShape, size);
+ mesh = CreateBoxMesh(primShape, size);
CalcNormals(mesh);
break;
default:
- mesh=null;
+ mesh = null;
break;
}
return mesh;
-
}
}
-}
-
-
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index a20452f..c9af6dd 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -25,19 +25,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
+
using System;
-using System.Threading;
using System.Collections.Generic;
-
-using libsecondlife;
-
using Axiom.Math;
using Ode.NET;
using OpenSim.Framework;
-using OpenSim.Framework.Console;
using OpenSim.Region.Physics.Manager;
-
namespace OpenSim.Region.Physics.OdePlugin
{
///
@@ -49,7 +44,6 @@ namespace OpenSim.Region.Physics.OdePlugin
public OdePlugin()
{
-
}
public bool Init()
@@ -73,7 +67,6 @@ namespace OpenSim.Region.Physics.OdePlugin
public void Dispose()
{
-
}
}
@@ -82,17 +75,17 @@ namespace OpenSim.Region.Physics.OdePlugin
private static float ODE_STEPSIZE = 0.004f;
private static bool RENDER_FLAG = false;
private IntPtr contactgroup;
- private IntPtr LandGeom=(IntPtr)0;
+ private IntPtr LandGeom = (IntPtr) 0;
private double[] _heightmap;
private d.NearCallback nearCallback;
public d.TriCallback triCallback;
public d.TriArrayCallback triArrayCallback;
private List _characters = new List();
private List _prims = new List();
- public Dictionary geom_name_map=new Dictionary();
+ public Dictionary geom_name_map = new Dictionary();
private d.ContactGeom[] contacts = new d.ContactGeom[30];
private d.Contact contact;
- private float step_time=0.0f;
+ private float step_time = 0.0f;
public IntPtr world;
public IntPtr space;
public static Object OdeLock = new Object();
@@ -140,7 +133,7 @@ namespace OpenSim.Region.Physics.OdePlugin
return;
d.GeomClassID id = d.GeomGetClass(g1);
- if (id==d.GeomClassID.TriMeshClass)
+ if (id == d.GeomClassID.TriMeshClass)
{
String name1 = null;
String name2 = null;
@@ -163,7 +156,6 @@ namespace OpenSim.Region.Physics.OdePlugin
IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
d.JointAttach(joint, b1, b2);
}
-
}
private void collision_optimized()
@@ -171,7 +163,8 @@ namespace OpenSim.Region.Physics.OdePlugin
foreach (OdeCharacter chr in _characters)
{
d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback);
- foreach (OdeCharacter ch2 in _characters) /// should be a separate space -- lots of avatars will be N**2 slow
+ foreach (OdeCharacter ch2 in _characters)
+ /// should be a separate space -- lots of avatars will be N**2 slow
{
d.SpaceCollide2(chr.Shell, ch2.Shell, IntPtr.Zero, nearCallback);
}
@@ -193,8 +186,8 @@ namespace OpenSim.Region.Physics.OdePlugin
{
lock (OdeLock)
{
- ((OdeCharacter)actor).Destroy();
- _characters.Remove((OdeCharacter)actor);
+ ((OdeCharacter) actor).Destroy();
+ _characters.Remove((OdeCharacter) actor);
}
}
@@ -204,13 +197,14 @@ namespace OpenSim.Region.Physics.OdePlugin
{
lock (OdeLock)
{
- d.GeomDestroy(((OdePrim)prim).prim_geom);
- _prims.Remove((OdePrim)prim);
+ d.GeomDestroy(((OdePrim) prim).prim_geom);
+ _prims.Remove((OdePrim) prim);
}
}
}
- PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
+ private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation,
+ Mesh mesh, PrimitiveBaseShape pbs)
{
PhysicsVector pos = new PhysicsVector();
pos.X = position.X;
@@ -235,7 +229,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
- public int TriArrayCallback(System.IntPtr trimesh, System.IntPtr refObject, int[] triangleIndex, int triCount)
+ public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount)
{
/* String name1 = null;
String name2 = null;
@@ -254,15 +248,14 @@ namespace OpenSim.Region.Physics.OdePlugin
return 1;
}
- public int TriCallback(System.IntPtr trimesh, System.IntPtr refObject, int triangleIndex)
+ public int TriCallback(IntPtr trimesh, IntPtr refObject, int triangleIndex)
{
-
String name1 = null;
String name2 = null;
if (!geom_name_map.TryGetValue(trimesh, out name1))
{
- name1 = "null";
+ name1 = "null";
}
if (!geom_name_map.TryGetValue(refObject, out name2))
{
@@ -282,11 +275,12 @@ namespace OpenSim.Region.Physics.OdePlugin
}
- public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation)
+ public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
+ PhysicsVector size, Quaternion rotation)
{
PhysicsActor result;
- switch(pbs.ProfileShape)
+ switch (pbs.ProfileShape)
{
case ProfileShape.Square:
/// support simple box & hollow box now; later, more shapes
@@ -310,7 +304,6 @@ namespace OpenSim.Region.Physics.OdePlugin
}
-
public override void Simulate(float timeStep)
{
step_time += timeStep;
@@ -327,11 +320,12 @@ namespace OpenSim.Region.Physics.OdePlugin
Vector3 rx, ry, rz;
p.Orientation.ToAxes(out rx, out ry, out rz);
Console.WriteLine("RENDER: block; " + p.Size.X + ", " + p.Size.Y + ", " + p.Size.Z + "; " +
- " 0, 0, 1; " + //shape, size, color
- (p.Position.X - 128.0f) + ", " + (p.Position.Y - 128.0f) + ", " + (p.Position.Z - 33.0f) + "; " + // position
- rx.x + "," + ry.x + "," + rz.x + ", " + // rotation
- rx.y + "," + ry.y + "," + rz.y + ", " +
- rx.z + "," + ry.z + "," + rz.z);
+ " 0, 0, 1; " + //shape, size, color
+ (p.Position.X - 128.0f) + ", " + (p.Position.Y - 128.0f) + ", " +
+ (p.Position.Z - 33.0f) + "; " + // position
+ rx.x + "," + ry.x + "," + rz.x + ", " + // rotation
+ rx.y + "," + ry.y + "," + rz.y + ", " +
+ rx.z + "," + ry.z + "," + rz.z);
}
}
int i = 0;
@@ -357,22 +351,27 @@ namespace OpenSim.Region.Physics.OdePlugin
float Zoff = -33.0f;
d.Matrix3 temp = d.BodyGetRotation(actor.Body);
Console.WriteLine("RENDER: cylinder; " + // shape
- OdeCharacter.CAPSULE_RADIUS + ", " + OdeCharacter.CAPSULE_LENGTH + //size
- "; 0, 1, 0; " + // color
- (actor.Position.X - 128.0f) + ", " + (actor.Position.Y - 128.0f) + ", " + (actor.Position.Z + Zoff) + "; " + // position
- temp.M00 + "," + temp.M10 + "," + temp.M20 + ", " + // rotation
- temp.M01 + "," + temp.M11 + "," + temp.M21 + ", " +
- temp.M02 + "," + temp.M12 + "," + temp.M22);
- d.Vector3 caphead; d.BodyGetRelPointPos(actor.Body, 0, 0, OdeCharacter.CAPSULE_LENGTH * .5f, out caphead);
- d.Vector3 capfoot; d.BodyGetRelPointPos(actor.Body, 0, 0, -OdeCharacter.CAPSULE_LENGTH * .5f, out capfoot);
+ OdeCharacter.CAPSULE_RADIUS + ", " + OdeCharacter.CAPSULE_LENGTH + //size
+ "; 0, 1, 0; " + // color
+ (actor.Position.X - 128.0f) + ", " + (actor.Position.Y - 128.0f) + ", " +
+ (actor.Position.Z + Zoff) + "; " + // position
+ temp.M00 + "," + temp.M10 + "," + temp.M20 + ", " + // rotation
+ temp.M01 + "," + temp.M11 + "," + temp.M21 + ", " +
+ temp.M02 + "," + temp.M12 + "," + temp.M22);
+ d.Vector3 caphead;
+ d.BodyGetRelPointPos(actor.Body, 0, 0, OdeCharacter.CAPSULE_LENGTH*.5f, out caphead);
+ d.Vector3 capfoot;
+ d.BodyGetRelPointPos(actor.Body, 0, 0, -OdeCharacter.CAPSULE_LENGTH*.5f, out capfoot);
Console.WriteLine("RENDER: sphere; " + OdeCharacter.CAPSULE_RADIUS + // shape, size
- "; 1, 0, 1; " + //color
- (caphead.X - 128.0f) + ", " + (caphead.Y - 128.0f) + ", " + (caphead.Z + Zoff) + "; " + // position
- "1,0,0, 0,1,0, 0,0,1"); // rotation
+ "; 1, 0, 1; " + //color
+ (caphead.X - 128.0f) + ", " + (caphead.Y - 128.0f) + ", " + (caphead.Z + Zoff) +
+ "; " + // position
+ "1,0,0, 0,1,0, 0,0,1"); // rotation
Console.WriteLine("RENDER: sphere; " + OdeCharacter.CAPSULE_RADIUS + // shape, size
- "; 1, 0, 0; " + //color
- (capfoot.X - 128.0f) + ", " + (capfoot.Y - 128.0f) + ", " + (capfoot.Z + Zoff) + "; " + // position
- "1,0,0, 0,1,0, 0,0,1"); // rotation
+ "; 1, 0, 0; " + //color
+ (capfoot.X - 128.0f) + ", " + (capfoot.Y - 128.0f) + ", " + (capfoot.Z + Zoff) +
+ "; " + // position
+ "1,0,0, 0,1,0, 0,0,1"); // rotation
}
}
}
@@ -380,14 +379,11 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void GetResults()
{
-
}
public override bool IsThreaded
{
- get
- {
- return (false); // for now we won't be multithreaded
+ get { return (false); // for now we won't be multithreaded
}
}
@@ -400,21 +396,21 @@ namespace OpenSim.Region.Physics.OdePlugin
{
for (int y = 0; y < 258; y++)
{
- int xx = x-1;
+ int xx = x - 1;
if (xx < 0) xx = 0;
if (xx > 255) xx = 255;
- int yy = y-1;
+ int yy = y - 1;
if (yy < 0) yy = 0;
if (yy > 255) yy = 255;
- double val = (double)heightMap[yy * 256 + xx];
- _heightmap[x * 258 + y] = val;
+ double val = (double) heightMap[yy*256 + xx];
+ _heightmap[x*258 + y] = val;
}
}
lock (OdeLock)
{
- if (!(LandGeom == (IntPtr)0))
+ if (!(LandGeom == (IntPtr) 0))
{
d.SpaceRemove(space, LandGeom);
}
@@ -422,7 +418,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 258, 258, 258, 258, 1.0f, 0.0f, 2.0f, 0);
d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
- this.geom_name_map[LandGeom]="Terrain";
+ geom_name_map[LandGeom] = "Terrain";
d.Matrix3 R = new d.Matrix3();
@@ -430,7 +426,7 @@ namespace OpenSim.Region.Physics.OdePlugin
Quaternion q2 = Quaternion.FromAngleAxis(1.5707f, new Vector3(0, 1, 0));
//Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1));
- q1 = q1 * q2;
+ q1 = q1*q2;
//q1 = q1 * q3;
Vector3 v3 = new Vector3();
float angle = 0;
@@ -444,7 +440,6 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void DeleteTerrain()
{
-
}
}
@@ -452,12 +447,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{
private PhysicsVector _position;
private d.Vector3 _zeroPosition;
- private bool _zeroFlag=false;
+ private bool _zeroFlag = false;
private PhysicsVector _velocity;
private PhysicsVector _target_velocity;
private PhysicsVector _acceleration;
- private static float PID_D=4000.0f;
- private static float PID_P=7000.0f;
+ private static float PID_D = 4000.0f;
+ private static float PID_P = 7000.0f;
private static float POSTURE_SERVO = 10000.0f;
public static float CAPSULE_RADIUS = 0.5f;
public static float CAPSULE_LENGTH = 0.9f;
@@ -484,28 +479,18 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
d.GeomSetBody(Shell, Body);
}
- parent_scene.geom_name_map[Shell]=avName;
-
+ parent_scene.geom_name_map[Shell] = avName;
}
public override bool Flying
{
- get
- {
- return flying;
- }
- set
- {
- flying = value;
- }
+ get { return flying; }
+ set { flying = value; }
}
public override PhysicsVector Position
{
- get
- {
- return _position;
- }
+ get { return _position; }
set
{
lock (OdeScene.OdeLock)
@@ -518,60 +503,34 @@ namespace OpenSim.Region.Physics.OdePlugin
public override PhysicsVector Size
{
- get
- {
- return new PhysicsVector(0,0,0);
- }
- set
- {
- }
+ get { return new PhysicsVector(0, 0, 0); }
+ set { }
}
public override PhysicsVector Velocity
{
- get
- {
- return _velocity;
- }
- set
- {
- _target_velocity = value;
- }
+ get { return _velocity; }
+ set { _target_velocity = value; }
}
public override bool Kinematic
{
- get
- {
- return false;
- }
- set
- {
-
- }
+ get { return false; }
+ set { }
}
public override Quaternion Orientation
{
- get
- {
- return Quaternion.Identity;
- }
- set
- {
-
- }
+ get { return Quaternion.Identity; }
+ set { }
}
public override PhysicsVector Acceleration
{
- get
- {
- return _acceleration;
- }
-
+ get { return _acceleration; }
}
+
public void SetAcceleration(PhysicsVector accel)
{
_acceleration = accel;
@@ -579,12 +538,10 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void AddForce(PhysicsVector force)
{
-
}
public override void SetMomentum(PhysicsVector momentum)
{
-
}
public void Move(float timeStep)
@@ -603,28 +560,28 @@ namespace OpenSim.Region.Physics.OdePlugin
_zeroPosition = d.BodyGetPosition(Body);
}
d.Vector3 pos = d.BodyGetPosition(Body);
- vec.X = (_target_velocity.X - vel.X) * PID_D + (_zeroPosition.X - pos.X) * PID_P;
- vec.Y = (_target_velocity.Y - vel.Y) * PID_D + (_zeroPosition.Y - pos.Y) * PID_P;
+ vec.X = (_target_velocity.X - vel.X)*PID_D + (_zeroPosition.X - pos.X)*PID_P;
+ vec.Y = (_target_velocity.Y - vel.Y)*PID_D + (_zeroPosition.Y - pos.Y)*PID_P;
if (flying)
{
- vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
+ vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P;
}
}
else
{
_zeroFlag = false;
- vec.X = (_target_velocity.X - vel.X) * PID_D;
- vec.Y = (_target_velocity.Y - vel.Y) * PID_D;
+ vec.X = (_target_velocity.X - vel.X)*PID_D;
+ vec.Y = (_target_velocity.Y - vel.Y)*PID_D;
if (flying)
{
- vec.Z = (_target_velocity.Z - vel.Z) * PID_D;
+ vec.Z = (_target_velocity.Z - vel.Z)*PID_D;
}
}
if (flying)
{
vec.Z += 10.0f;
}
- d.BodyAddForce(this.Body, vec.X, vec.Y, vec.Z);
+ d.BodyAddForce(Body, vec.X, vec.Y, vec.Z);
// ok -- let's stand up straight!
d.Vector3 feet;
@@ -634,7 +591,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float posture = head.Z - feet.Z;
// restoring force proportional to lack of posture:
- float servo = (2.5f-posture) * POSTURE_SERVO;
+ float servo = (2.5f - posture)*POSTURE_SERVO;
d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f);
d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f);
}
@@ -650,9 +607,9 @@ namespace OpenSim.Region.Physics.OdePlugin
if (vec.X > 255.95f) vec.X = 255.95f;
if (vec.Y > 255.95f) vec.Y = 255.95f;
- this._position.X = vec.X;
- this._position.Y = vec.Y;
- this._position.Z = vec.Z;
+ _position.X = vec.X;
+ _position.Y = vec.Y;
+ _position.Z = vec.Z;
if (_zeroFlag)
{
@@ -673,9 +630,9 @@ namespace OpenSim.Region.Physics.OdePlugin
{
lock (OdeScene.OdeLock)
{
- d.GeomDestroy(this.Shell);
- this._parent_scene.geom_name_map.Remove(this.Shell);
- d.BodyDestroy(this.Body);
+ d.GeomDestroy(Shell);
+ _parent_scene.geom_name_map.Remove(Shell);
+ d.BodyDestroy(Body);
}
}
}
@@ -693,7 +650,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public IntPtr prim_geom;
public IntPtr _triMeshData;
- public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
+ public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
{
_velocity = new PhysicsVector();
@@ -707,7 +664,7 @@ namespace OpenSim.Region.Physics.OdePlugin
lock (OdeScene.OdeLock)
{
- if (mesh!=null)
+ if (mesh != null)
{
setMesh(parent_scene, mesh);
}
@@ -723,20 +680,22 @@ namespace OpenSim.Region.Physics.OdePlugin
myrot.Y = rotation.y;
myrot.Z = rotation.z;
d.GeomSetQuaternion(prim_geom, ref myrot);
- parent_scene.geom_name_map[prim_geom] = primName; // don't do .add() here; old geoms get recycled with the same hash
+ parent_scene.geom_name_map[prim_geom] = primName;
+ // don't do .add() here; old geoms get recycled with the same hash
}
}
- public void setMesh(OdeScene parent_scene, Mesh mesh)
+ public void setMesh(OdeScene parent_scene, Mesh mesh)
{
float[] vertexList = mesh.getVertexListAsFloat(); // Note, that vertextList is pinned in memory
int[] indexList = mesh.getIndexListAsInt(); // Also pinned, needs release after usage
- int VertexCount = vertexList.GetLength(0) / 3;
+ int VertexCount = vertexList.GetLength(0)/3;
int IndexCount = indexList.GetLength(0);
_triMeshData = d.GeomTriMeshDataCreate();
- d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3 * sizeof(float), VertexCount, indexList, IndexCount, 3 * sizeof(int));
+ d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3*sizeof (float), VertexCount, indexList, IndexCount,
+ 3*sizeof (int));
d.GeomTriMeshDataPreprocess(_triMeshData);
prim_geom = d.CreateTriMesh(parent_scene.space, _triMeshData, parent_scene.triCallback, null, null);
@@ -744,21 +703,14 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool Flying
{
- get
- {
- return false; //no flying prims for you
- }
- set
- {
+ get { return false; //no flying prims for you
}
+ set { }
}
public override PhysicsVector Position
{
- get
- {
- return _position;
- }
+ get { return _position; }
set
{
_position = value;
@@ -771,10 +723,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override PhysicsVector Size
{
- get
- {
- return _size;
- }
+ get { return _size; }
set
{
_size = value;
@@ -798,33 +747,19 @@ namespace OpenSim.Region.Physics.OdePlugin
public override PhysicsVector Velocity
{
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
+ get { return _velocity; }
+ set { _velocity = value; }
}
public override bool Kinematic
{
- get
- {
- return false;
- }
- set
- {
- }
+ get { return false; }
+ set { }
}
public override Quaternion Orientation
{
- get
- {
- return _orientation;
- }
+ get { return _orientation; }
set
{
_orientation = value;
@@ -842,15 +777,12 @@ namespace OpenSim.Region.Physics.OdePlugin
public override PhysicsVector Acceleration
{
- get
- {
- return _acceleration;
- }
+ get { return _acceleration; }
}
public void SetAcceleration(PhysicsVector accel)
{
- this._acceleration = accel;
+ _acceleration = accel;
}
public override void AddForce(PhysicsVector force)
@@ -861,4 +793,4 @@ namespace OpenSim.Region.Physics.OdePlugin
{
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
index 3f840cc..d110a17 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
@@ -27,24 +27,26 @@
*/
using System.Reflection;
using System.Runtime.InteropServices;
+
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
-[assembly: AssemblyTitle("RealPhysXplugin")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("RealPhysXplugin")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly : AssemblyTitle("RealPhysXplugin")]
+[assembly : AssemblyDescription("")]
+[assembly : AssemblyConfiguration("")]
+[assembly : AssemblyCompany("")]
+[assembly : AssemblyProduct("RealPhysXplugin")]
+[assembly : AssemblyCopyright("")]
+[assembly : AssemblyTrademark("")]
+[assembly : AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
+
+[assembly : ComVisible(false)]
// The assembly version has following format :
//
@@ -53,4 +55,4 @@ using System.Runtime.InteropServices;
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
-[assembly: AssemblyVersion("1.0.*")]
+[assembly : AssemblyVersion("1.0.*")]
\ No newline at end of file
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index a7cef88..4896359 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -34,102 +34,99 @@ using Quaternion=Axiom.Math.Quaternion;
namespace OpenSim.Region.Physics.PhysXPlugin
{
- ///
- /// Will be the PhysX plugin but for now will be a very basic physics engine
- ///
- public class PhysXPlugin : IPhysicsPlugin
- {
- private PhysXScene _mScene;
-
- public PhysXPlugin()
- {
-
- }
-
- public bool Init()
- {
- return true;
- }
-
- public PhysicsScene GetScene()
- {
- if(_mScene == null)
- {
- _mScene = new PhysXScene();
- }
- return(_mScene);
- }
-
- public string GetName()
- {
- return("RealPhysX");
- }
-
- public void Dispose()
- {
-
- }
- }
-
- public class PhysXScene :PhysicsScene
- {
- private List _characters = new List();
- private List _prims = new List();
- private float[] _heightMap = null;
- private NxPhysicsSDK mySdk;
- private NxScene scene;
-
- public PhysXScene()
- {
- mySdk = NxPhysicsSDK.CreateSDK();
- Console.WriteLine("Sdk created - now creating scene");
- scene = mySdk.CreateScene();
-
- }
-
- public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
- {
- Vec3 pos = new Vec3();
- pos.X = position.X;
- pos.Y = position.Y;
- pos.Z = position.Z;
- PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
+ ///
+ /// Will be the PhysX plugin but for now will be a very basic physics engine
+ ///
+ public class PhysXPlugin : IPhysicsPlugin
+ {
+ private PhysXScene _mScene;
+
+ public PhysXPlugin()
+ {
+ }
+
+ public bool Init()
+ {
+ return true;
+ }
+
+ public PhysicsScene GetScene()
+ {
+ if (_mScene == null)
+ {
+ _mScene = new PhysXScene();
+ }
+ return (_mScene);
+ }
+
+ public string GetName()
+ {
+ return ("RealPhysX");
+ }
+
+ public void Dispose()
+ {
+ }
+ }
+
+ public class PhysXScene : PhysicsScene
+ {
+ private List _characters = new List();
+ private List _prims = new List();
+ private float[] _heightMap = null;
+ private NxPhysicsSDK mySdk;
+ private NxScene scene;
+
+ public PhysXScene()
+ {
+ mySdk = NxPhysicsSDK.CreateSDK();
+ Console.WriteLine("Sdk created - now creating scene");
+ scene = mySdk.CreateScene();
+ }
+
+ public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
+ {
+ Vec3 pos = new Vec3();
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z;
+ PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos));
act.Position = position;
- _characters.Add(act);
- return act;
- }
+ _characters.Add(act);
+ return act;
+ }
public override void RemovePrim(PhysicsActor prim)
{
-
}
public override void RemoveAvatar(PhysicsActor actor)
{
+ }
+ private PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation)
+ {
+ Vec3 pos = new Vec3();
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z;
+ Vec3 siz = new Vec3();
+ siz.X = size.X;
+ siz.Y = size.Y;
+ siz.Z = size.Z;
+ PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz));
+ _prims.Add(act);
+ return act;
}
-
- PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation)
- {
- Vec3 pos = new Vec3();
- pos.X = position.X;
- pos.Y = position.Y;
- pos.Z = position.Z;
- Vec3 siz = new Vec3();
- siz.X = size.X;
- siz.Y = size.Y;
- siz.Z = size.Z;
- PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
- _prims.Add(act);
- return act;
- }
- public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation)
+
+ public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
+ PhysicsVector size, Quaternion rotation)
{
return AddPrim(position, size, rotation);
}
- public override void Simulate(float timeStep)
- {
+ public override void Simulate(float timeStep)
+ {
try
{
foreach (PhysXCharacter actor in _characters)
@@ -149,309 +146,237 @@ namespace OpenSim.Region.Physics.PhysXPlugin
{
Console.WriteLine(e.Message);
}
-
- }
-
- public override void GetResults()
- {
-
- }
-
- public override bool IsThreaded
- {
- get
- {
- return(false); // for now we won't be multithreaded
- }
- }
-
- public override void SetTerrain(float[] heightMap)
- {
- if (this._heightMap != null)
+ }
+
+ public override void GetResults()
+ {
+ }
+
+ public override bool IsThreaded
+ {
+ get { return (false); // for now we won't be multithreaded
+ }
+ }
+
+ public override void SetTerrain(float[] heightMap)
+ {
+ if (_heightMap != null)
{
Console.WriteLine("PhysX - deleting old terrain");
- this.scene.DeleteTerrain();
+ scene.DeleteTerrain();
}
- this._heightMap = heightMap;
- this.scene.AddTerrain(heightMap);
- }
+ _heightMap = heightMap;
+ scene.AddTerrain(heightMap);
+ }
public override void DeleteTerrain()
{
- this.scene.DeleteTerrain();
- }
+ scene.DeleteTerrain();
+ }
}
-
- public class PhysXCharacter : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
- private NxCharacter _character;
- private bool flying;
- private float gravityAccel;
-
- public PhysXCharacter(NxCharacter character)
- {
- _velocity = new PhysicsVector();
- _position = new PhysicsVector();
- _acceleration = new PhysicsVector();
- _character = character;
- }
-
- public override bool Flying
- {
- get
- {
- return flying;
- }
- set
- {
- flying = value;
- }
- }
-
- public override PhysicsVector Position
- {
- get
- {
- return _position;
- }
- set
- {
- _position = value;
+
+ public class PhysXCharacter : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+ private NxCharacter _character;
+ private bool flying;
+ private float gravityAccel;
+
+ public PhysXCharacter(NxCharacter character)
+ {
+ _velocity = new PhysicsVector();
+ _position = new PhysicsVector();
+ _acceleration = new PhysicsVector();
+ _character = character;
+ }
+
+ public override bool Flying
+ {
+ get { return flying; }
+ set { flying = value; }
+ }
+
+ public override PhysicsVector Position
+ {
+ get { return _position; }
+ set
+ {
+ _position = value;
Vec3 ps = new Vec3();
ps.X = value.X;
ps.Y = value.Y;
ps.Z = value.Z;
- this._character.Position = ps;
- }
- }
+ _character.Position = ps;
+ }
+ }
public override PhysicsVector Size
{
- get
+ get { return new PhysicsVector(0, 0, 0); }
+ set { }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get { return _velocity; }
+ set { _velocity = value; }
+ }
+
+ public override bool Kinematic
+ {
+ get { return false; }
+ set { }
+ }
+
+ public override Quaternion Orientation
+ {
+ get { return Quaternion.Identity; }
+ set { }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get { return _acceleration; }
+ }
+
+ public void SetAcceleration(PhysicsVector accel)
+ {
+ _acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+ }
+
+ public void Move(float timeStep)
+ {
+ Vec3 vec = new Vec3();
+ vec.X = _velocity.X*timeStep;
+ vec.Y = _velocity.Y*timeStep;
+ if (flying)
{
- return new PhysicsVector(0,0,0);
+ vec.Z = (_velocity.Z)*timeStep;
}
- set
+ else
+ {
+ gravityAccel += -9.8f;
+ vec.Z = (gravityAccel + _velocity.Z)*timeStep;
+ }
+ int res = _character.Move(vec);
+ if (res == 1)
{
+ gravityAccel = 0;
}
}
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return false;
- }
- set
- {
-
- }
- }
-
- public override Quaternion Orientation
- {
- get
- {
- return Quaternion.Identity;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
- public void SetAcceleration (PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
-
- public void Move(float timeStep)
- {
- Vec3 vec = new Vec3();
- vec.X = this._velocity.X * timeStep;
- vec.Y = this._velocity.Y * timeStep;
- if(flying)
- {
- vec.Z = ( this._velocity.Z) * timeStep;
- }
- else
- {
- gravityAccel+= -9.8f;
- vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
- }
- int res = this._character.Move(vec);
- if(res == 1)
- {
- gravityAccel = 0;
- }
- }
-
- public void UpdatePosition()
- {
- Vec3 vec = this._character.Position;
- this._position.X = vec.X;
- this._position.Y = vec.Y;
- this._position.Z = vec.Z;
- }
- }
-
- public class PhysXPrim : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
- private NxActor _prim;
-
- public PhysXPrim(NxActor prim)
- {
- _velocity = new PhysicsVector();
- _position = new PhysicsVector();
- _acceleration = new PhysicsVector();
- _prim = prim;
- }
- public override bool Flying
- {
- get
- {
- return false; //no flying prims for you
- }
- set
- {
-
- }
- }
- public override PhysicsVector Position
- {
- get
- {
- PhysicsVector pos = new PhysicsVector();
- Vec3 vec = this._prim.Position;
- pos.X = vec.X;
- pos.Y = vec.Y;
- pos.Z = vec.Z;
- return pos;
-
- }
- set
- {
- PhysicsVector vec = value;
- Vec3 pos = new Vec3();
- pos.X = vec.X;
- pos.Y = vec.Y;
- pos.Z = vec.Z;
- this._prim.Position = pos;
- }
- }
- public override PhysicsVector Size
+ public void UpdatePosition()
+ {
+ Vec3 vec = _character.Position;
+ _position.X = vec.X;
+ _position.Y = vec.Y;
+ _position.Z = vec.Z;
+ }
+ }
+
+ public class PhysXPrim : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+ private NxActor _prim;
+
+ public PhysXPrim(NxActor prim)
+ {
+ _velocity = new PhysicsVector();
+ _position = new PhysicsVector();
+ _acceleration = new PhysicsVector();
+ _prim = prim;
+ }
+
+ public override bool Flying
+ {
+ get { return false; //no flying prims for you
+ }
+ set { }
+ }
+
+ public override PhysicsVector Position
{
get
{
- return new PhysicsVector(0, 0, 0);
+ PhysicsVector pos = new PhysicsVector();
+ Vec3 vec = _prim.Position;
+ pos.X = vec.X;
+ pos.Y = vec.Y;
+ pos.Z = vec.Z;
+ return pos;
}
set
{
+ PhysicsVector vec = value;
+ Vec3 pos = new Vec3();
+ pos.X = vec.X;
+ pos.Y = vec.Y;
+ pos.Z = vec.Z;
+ _prim.Position = pos;
}
}
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return this._prim.Kinematic;
- }
- set
- {
- this._prim.Kinematic = value;
- }
- }
-
- public override Quaternion Orientation
- {
- get
- {
- Quaternion res = new Quaternion();
- PhysXWrapper.Quaternion quat = this._prim.GetOrientation();
- res.w = quat.W;
- res.x = quat.X;
- res.y = quat.Y;
- res.z = quat.Z;
- return res;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
- public void SetAcceleration (PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
-
-
- }
-
-}
+ public override PhysicsVector Size
+ {
+ get { return new PhysicsVector(0, 0, 0); }
+ set { }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get { return _velocity; }
+ set { _velocity = value; }
+ }
+
+ public override bool Kinematic
+ {
+ get { return _prim.Kinematic; }
+ set { _prim.Kinematic = value; }
+ }
+
+ public override Quaternion Orientation
+ {
+ get
+ {
+ Quaternion res = new Quaternion();
+ PhysXWrapper.Quaternion quat = _prim.GetOrientation();
+ res.w = quat.W;
+ res.x = quat.X;
+ res.y = quat.Y;
+ res.z = quat.Z;
+ return res;
+ }
+ set { }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get { return _acceleration; }
+ }
+
+ public void SetAcceleration(PhysicsVector accel)
+ {
+ _acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+ }
+ }
+}
\ No newline at end of file
--
cgit v1.1