From 0e460a81cc7e1c9eb4b5576f78e78400f05cf48a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 26 Dec 2007 04:23:36 +0000 Subject: * Coded around another Null packet sent by the packet pool * Condensed 8 calls to unmanaged code in ODE down to 1 --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 36 ++++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 273ee23..33b2e4f 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -40,6 +40,7 @@ namespace OpenSim.Region.Physics.OdePlugin { private PhysicsVector _position; private d.Vector3 _zeroPosition; + private d.Matrix3 m_StandUpRotation; private bool _zeroFlag = false; private bool m_lastUpdateSent = false; private PhysicsVector _velocity; @@ -86,6 +87,8 @@ namespace OpenSim.Region.Physics.OdePlugin _acceleration = new PhysicsVector(); _parent_scene = parent_scene; + m_StandUpRotation = new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, -0.004689182f, 0.9998941f); + for (int i = 0; i < 11; i++) { m_colliderarr[i] = false; @@ -100,7 +103,15 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodySetMass(Body, ref ShellMass); d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); d.GeomSetBody(Shell, Body); - Amotor = d.JointCreateAMotor(parent_scene.world, IntPtr.Zero); + + + + + d.BodySetRotation(Body, ref m_StandUpRotation); + + + + Amotor = d.JointCreateAMotor(parent_scene.world, IntPtr.Zero); d.JointAttach(Amotor, Body, IntPtr.Zero); d.JointSetAMotorMode(Amotor, dAMotorEuler); d.JointSetAMotorNumAxes(Amotor, 3); @@ -117,6 +128,8 @@ namespace OpenSim.Region.Physics.OdePlugin d.JointSetAMotorParam(Amotor, 3, 0); d.JointSetAMotorParam(Amotor, 2, 0); + + } m_name = avName; parent_scene.geom_name_map[Shell] = avName; @@ -381,16 +394,21 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodyAddForce(Body, force.X, force.Y, force.Z); // ok -- let's stand up straight! - d.Vector3 feet; - d.Vector3 head; - d.BodyGetRelPointPos(Body, 0.0f, 0.0f, -1.0f, out feet); - d.BodyGetRelPointPos(Body, 0.0f, 0.0f, 1.0f, out head); - float posture = head.Z - feet.Z; + //d.Matrix3 StandUpRotationalMatrix = new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, -0.004689182f, 0.9998941f); + //d.BodySetRotation(Body, ref StandUpRotationalMatrix); + d.BodySetRotation(Body, ref m_StandUpRotation); + // The above matrix was generated with the amazing standup routine below by danX0r *cheer* + //d.Vector3 feet; + //d.Vector3 head; + //d.BodyGetRelPointPos(Body, 0.0f, 0.0f, -1.0f, out feet); + //d.BodyGetRelPointPos(Body, 0.0f, 0.0f, 1.0f, out head); + //float posture = head.Z - feet.Z; // restoring force proportional to lack of posture: - 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); + //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); + //m_lastUpdateSent = false; } -- cgit v1.1