From 815f3af1d7b3bf16e81dd3a03e0c69c8e49f2f91 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 8 Feb 2012 15:24:10 +0000
Subject: UbitODE plugin initial commit
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 1301 ++++++++++++++++++++
1 file changed, 1301 insertions(+)
create mode 100644 OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
new file mode 100644
index 0000000..c8f7c76
--- /dev/null
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -0,0 +1,1301 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// Revision by Ubit 2011
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using OpenMetaverse;
+using OdeAPI;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+using log4net;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ ///
+ /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves.
+ ///
+
+ public enum dParam : int
+ {
+ LowStop = 0,
+ HiStop = 1,
+ Vel = 2,
+ FMax = 3,
+ FudgeFactor = 4,
+ Bounce = 5,
+ CFM = 6,
+ StopERP = 7,
+ StopCFM = 8,
+ LoStop2 = 256,
+ HiStop2 = 257,
+ Vel2 = 258,
+ FMax2 = 259,
+ StopERP2 = 7 + 256,
+ StopCFM2 = 8 + 256,
+ LoStop3 = 512,
+ HiStop3 = 513,
+ Vel3 = 514,
+ FMax3 = 515,
+ StopERP3 = 7 + 512,
+ StopCFM3 = 8 + 512
+ }
+
+ public class OdeCharacter : PhysicsActor
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private Vector3 _position;
+ private Vector3 _zeroPosition;
+ private bool _zeroFlag = false;
+ private Vector3 _velocity;
+ private Vector3 _target_velocity;
+ private Vector3 _acceleration;
+ private Vector3 m_rotationalVelocity;
+ private float m_mass = 80f;
+ public float m_density = 60f;
+ private bool m_pidControllerActive = true;
+ public float PID_D = 800.0f;
+ public float PID_P = 900.0f;
+ //private static float POSTURE_SERVO = 10000.0f;
+ public float CAPSULE_RADIUS = 0.37f;
+ public float CAPSULE_LENGTH = 2.140599f;
+ public float walkDivisor = 1.3f;
+ public float runDivisor = 0.8f;
+ private bool flying = false;
+ private bool m_iscolliding = false;
+ private bool m_iscollidingGround = false;
+ private bool m_iscollidingObj = false;
+ private bool m_alwaysRun = false;
+ private int m_requestedUpdateFrequency = 0;
+ private Vector3 m_taintPosition = Vector3.Zero;
+ private bool m_hasTaintPosition = false;
+ public uint m_localID = 0;
+ public bool m_returnCollisions = false;
+ // taints and their non-tainted counterparts
+ public bool m_isPhysical = false; // the current physical status
+ public bool m_tainted_isPhysical = false; // set when the physical status is tainted (false=not existing in physics engine, true=existing)
+ public float MinimumGroundFlightOffset = 3f;
+
+
+ private Vector3 m_taintForce;
+ private bool m_hasTaintForce;
+ private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
+
+
+ private float m_buoyancy = 0f;
+
+ // private CollisionLocker ode;
+
+ private string m_name = String.Empty;
+ // other filter control
+ int m_colliderfilter = 0;
+ // int m_colliderGroundfilter = 0;
+ int m_colliderObjectfilter = 0;
+
+ // Default we're a Character
+ private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
+
+ // Default, Collide with Other Geometries, spaces, bodies and characters.
+ private CollisionCategories m_collisionFlags = (CollisionCategories.Geom
+ | CollisionCategories.Space
+ | CollisionCategories.Body
+ | CollisionCategories.Character
+ );
+ // we do land collisions not ode | CollisionCategories.Land);
+ public IntPtr Body = IntPtr.Zero;
+ private OdeScene _parent_scene;
+ public IntPtr Shell = IntPtr.Zero;
+ public IntPtr Amotor = IntPtr.Zero;
+ public d.Mass ShellMass;
+ public bool collidelock = false;
+
+ private bool m_haseventsubscription = false;
+ public int m_eventsubscription = 0;
+ private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
+
+ // unique UUID of this character object
+ public UUID m_uuid;
+ public bool bad = false;
+
+ public ContactData AvatarContactData = new ContactData(10f, 0.3f);
+
+ public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor)
+ {
+ m_uuid = UUID.Random();
+
+ m_hasTaintPosition = false;
+
+ if (pos.IsFinite())
+ {
+ if (pos.Z > 9999999f)
+ {
+ pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
+ }
+ if (pos.Z < -90000f)
+ {
+ pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
+ }
+ _position = pos;
+ }
+ else
+ {
+ _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
+ m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
+ }
+
+ _parent_scene = parent_scene;
+
+ PID_D = pid_d;
+ PID_P = pid_p;
+ CAPSULE_RADIUS = capsule_radius;
+ m_density = density;
+ m_mass = 80f; // sure we have a default
+
+ AvatarContactData.mu = parent_scene.AvatarFriction;
+ AvatarContactData.bounce = parent_scene.AvatarBounce;
+
+ walkDivisor = walk_divisor;
+ runDivisor = rundivisor;
+
+ CAPSULE_LENGTH = size.Z * 1.15f - CAPSULE_RADIUS * 2.0f;
+ //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
+ m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH;
+
+ m_isPhysical = false; // current status: no ODE information exists
+ m_tainted_isPhysical = true; // new tainted status: need to create ODE information
+
+ m_hasTaintForce = false;
+ _parent_scene.AddPhysicsActorTaint(this);
+
+ m_name = avName;
+ }
+
+ public override int PhysicsActorType
+ {
+ get { return (int)ActorTypes.Agent; }
+ set { return; }
+ }
+
+ public override ContactData ContactData
+ {
+ get { return AvatarContactData; }
+ }
+
+ public override bool Building { get; set; }
+
+ ///
+ /// If this is set, the avatar will move faster
+ ///
+ public override bool SetAlwaysRun
+ {
+ get { return m_alwaysRun; }
+ set { m_alwaysRun = value; }
+ }
+
+ public override uint LocalID
+ {
+ set { m_localID = value; }
+ }
+
+ public override bool Grabbed
+ {
+ set { return; }
+ }
+
+ public override bool Selected
+ {
+ set { return; }
+ }
+
+ public override float Buoyancy
+ {
+ get { return m_buoyancy; }
+ set { m_buoyancy = value; }
+ }
+
+ public override bool FloatOnWater
+ {
+ set { return; }
+ }
+
+ public override bool IsPhysical
+ {
+ get { return false; }
+ set { return; }
+ }
+
+ public override bool ThrottleUpdates
+ {
+ get { return false; }
+ set { return; }
+ }
+
+ public override bool Flying
+ {
+ get { return flying; }
+ set
+ {
+ flying = value;
+ // m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying);
+ }
+ }
+
+ ///
+ /// Returns if the avatar is colliding in general.
+ /// This includes the ground and objects and avatar.
+ ///
+ public override bool IsColliding
+ {
+ get { return (m_iscolliding || m_iscollidingGround); }
+ set
+ {
+ if (value)
+ {
+ m_colliderfilter += 2;
+ if (m_colliderfilter > 2)
+ m_colliderfilter = 2;
+ }
+ else
+ {
+ m_colliderfilter--;
+ if (m_colliderfilter < 0)
+ m_colliderfilter = 0;
+ }
+
+ if (m_colliderfilter == 0)
+ m_iscolliding = false;
+ else
+ {
+// SetPidStatus(false);
+ m_pidControllerActive = true;
+ m_iscolliding = true;
+ }
+ }
+ }
+
+ ///
+ /// Returns if an avatar is colliding with the ground
+ ///
+ public override bool CollidingGround
+ {
+ get { return m_iscollidingGround; }
+ set
+ {
+ /* we now control this
+ if (value)
+ {
+ m_colliderGroundfilter += 2;
+ if (m_colliderGroundfilter > 2)
+ m_colliderGroundfilter = 2;
+ }
+ else
+ {
+ m_colliderGroundfilter--;
+ if (m_colliderGroundfilter < 0)
+ m_colliderGroundfilter = 0;
+ }
+
+ if (m_colliderGroundfilter == 0)
+ m_iscollidingGround = false;
+ else
+ m_iscollidingGround = true;
+ */
+ }
+
+ }
+
+ ///
+ /// Returns if the avatar is colliding with an object
+ ///
+ public override bool CollidingObj
+ {
+ get { return m_iscollidingObj; }
+ set
+ {
+ // Ubit filter this also
+ if (value)
+ {
+ m_colliderObjectfilter += 2;
+ if (m_colliderObjectfilter > 2)
+ m_colliderObjectfilter = 2;
+ }
+ else
+ {
+ m_colliderObjectfilter--;
+ if (m_colliderObjectfilter < 0)
+ m_colliderObjectfilter = 0;
+ }
+
+ if (m_colliderObjectfilter == 0)
+ m_iscollidingObj = false;
+ else
+ m_iscollidingObj = true;
+
+ // m_iscollidingObj = value;
+/*
+ if (m_iscollidingObj)
+ m_pidControllerActive = false;
+ else
+ m_pidControllerActive = true;
+ */
+ }
+ }
+
+ ///
+ /// turn the PID controller on or off.
+ /// The PID Controller will turn on all by itself in many situations
+ ///
+ ///
+ public void SetPidStatus(bool status)
+ {
+ m_pidControllerActive = status;
+ }
+
+ public override bool Stopped
+ {
+ get { return _zeroFlag; }
+ }
+
+ ///
+ /// This 'puts' an avatar somewhere in the physics space.
+ /// Not really a good choice unless you 'know' it's a good
+ /// spot otherwise you're likely to orbit the avatar.
+ ///
+ public override Vector3 Position
+ {
+ get { return _position; }
+ set
+ {
+ if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
+ {
+ if (value.IsFinite())
+ {
+ if (value.Z > 9999999f)
+ {
+ value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
+ }
+ if (value.Z < -90000f)
+ {
+ value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
+ }
+
+ m_taintPosition.X = value.X;
+ m_taintPosition.Y = value.Y;
+ m_taintPosition.Z = value.Z;
+ m_hasTaintPosition = true;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN Position from Scene on a Character");
+ }
+ }
+ }
+ }
+
+ public override Vector3 RotationalVelocity
+ {
+ get { return m_rotationalVelocity; }
+ set { m_rotationalVelocity = value; }
+ }
+
+ ///
+ /// This property sets the height of the avatar only. We use the height to make sure the avatar stands up straight
+ /// and use it to offset landings properly
+ ///
+ public override Vector3 Size
+ {
+ get {
+ float d = CAPSULE_RADIUS * 2;
+ return new Vector3(d, d, (CAPSULE_LENGTH +d)/1.15f); }
+ set
+ {
+ if (value.IsFinite())
+ {
+ m_pidControllerActive = true;
+
+ Vector3 SetSize = value;
+ m_tainted_CAPSULE_LENGTH = SetSize.Z *1.15f - CAPSULE_RADIUS * 2.0f;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN Size from Scene on a Character");
+ }
+ }
+ }
+
+ ///
+ /// This creates the Avatar's physical Surrogate at the position supplied
+ ///
+ ///
+ ///
+ ///
+
+ // WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
+ // to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
+ // place that is safe to call this routine AvatarGeomAndBodyCreation.
+ private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
+ {
+ _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ if (CAPSULE_LENGTH <= 0)
+ {
+ m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
+ CAPSULE_LENGTH = 0.01f;
+
+ }
+
+ if (CAPSULE_RADIUS <= 0)
+ {
+ m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
+ CAPSULE_RADIUS = 0.01f;
+
+ }
+ Shell = d.CreateCapsule(_parent_scene.ActiveSpace, CAPSULE_RADIUS, CAPSULE_LENGTH);
+
+ d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
+ d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
+
+ d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH);
+
+ m_mass = ShellMass.mass; // update mass
+
+ // rescale PID parameters
+ PID_D = _parent_scene.avPIDD;
+ PID_P = _parent_scene.avPIDP;
+
+ // rescale PID parameters so that this aren't affected by mass
+ // and so don't get unstable for some masses
+ // also scale by ode time step so you don't need to refix them
+
+ PID_D /= 50 * 80; //scale to original mass of around 80 and 50 ODE fps
+ PID_D *= m_mass / _parent_scene.ODE_STEPSIZE;
+ PID_P /= 50 * 80;
+ PID_P *= m_mass / _parent_scene.ODE_STEPSIZE;
+
+ Body = d.BodyCreate(_parent_scene.world);
+
+ d.BodySetAutoDisableFlag(Body, false);
+ d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
+
+ _position.X = npositionX;
+ _position.Y = npositionY;
+ _position.Z = npositionZ;
+
+ m_hasTaintPosition = false;
+
+ d.BodySetMass(Body, ref ShellMass);
+ d.GeomSetBody(Shell, Body);
+
+ // The purpose of the AMotor here is to keep the avatar's physical
+ // surrogate from rotating while moving
+ Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
+ d.JointAttach(Amotor, Body, IntPtr.Zero);
+
+ d.JointSetAMotorMode(Amotor, 0);
+ d.JointSetAMotorNumAxes(Amotor, 3);
+ d.JointSetAMotorAxis(Amotor, 0, 0 , 1, 0, 0);
+ d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
+ d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
+
+ d.JointSetAMotorAngle(Amotor, 0, 0);
+ d.JointSetAMotorAngle(Amotor, 1, 0);
+ d.JointSetAMotorAngle(Amotor, 2, 0);
+
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM, 0f); // make it HARD
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM2, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM3, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopERP, 0.8f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopERP2, 0.8f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopERP3, 0.8f);
+
+ // These lowstops and high stops are effectively (no wiggle room)
+ d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 1e-5f);
+
+ d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel, 0);
+ d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel2, 0);
+ d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel3, 0);
+
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 5e6f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax2, 5e6f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax3, 5e6f);
+ }
+
+ ///
+ /// Destroys the avatar body and geom
+
+ private void AvatarGeomAndBodyDestroy()
+ {
+ // Kill the Amotor
+ if (Amotor != IntPtr.Zero)
+ {
+ d.JointDestroy(Amotor);
+ Amotor = IntPtr.Zero;
+ }
+
+ if (Body != IntPtr.Zero)
+ {
+ //kill the body
+ d.BodyDestroy(Body);
+ Body = IntPtr.Zero;
+ }
+
+ //kill the Geometry
+ if (Shell != IntPtr.Zero)
+ {
+ _parent_scene.geom_name_map.Remove(Shell);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ d.GeomDestroy(Shell);
+ _parent_scene.geom_name_map.Remove(Shell);
+ Shell = IntPtr.Zero;
+ }
+ }
+ //
+ ///
+ /// Uses the capped cyllinder volume formula to calculate the avatar's mass.
+ /// This may be used in calculations in the scene/scenepresence
+ ///
+ public override float Mass
+ {
+ get
+ {
+ float AVvolume = (float)(Math.PI * CAPSULE_RADIUS * CAPSULE_RADIUS * (1.3333333333f * CAPSULE_RADIUS + CAPSULE_LENGTH));
+ return m_density * AVvolume;
+ }
+ }
+ public override void link(PhysicsActor obj)
+ {
+
+ }
+
+ public override void delink()
+ {
+
+ }
+
+ public override void LockAngularMotion(Vector3 axis)
+ {
+
+ }
+
+
+ public override Vector3 Force
+ {
+ get { return _target_velocity; }
+ set { return; }
+ }
+
+ public override int VehicleType
+ {
+ get { return 0; }
+ set { return; }
+ }
+
+ public override void VehicleFloatParam(int param, float value)
+ {
+
+ }
+
+ public override void VehicleVectorParam(int param, Vector3 value)
+ {
+
+ }
+
+ public override void VehicleRotationParam(int param, Quaternion rotation)
+ {
+
+ }
+
+ public override void VehicleFlags(int param, bool remove)
+ {
+
+ }
+
+ public override void SetVolumeDetect(int param)
+ {
+
+ }
+
+ public override Vector3 CenterOfMass
+ {
+ get
+ {
+ Vector3 pos = _position;
+ return pos;
+ }
+ }
+
+ public override Vector3 GeometricCenter
+ {
+ get
+ {
+ Vector3 pos = _position;
+ return pos;
+ }
+ }
+
+ //UBit mess
+ /* for later use
+ public override Vector3 PrimOOBsize
+ {
+ get
+ {
+ Vector3 s=Size;
+ s.X *=0.5f;
+ s.Y *=0.5f;
+ s.Z *=0.5f;
+ return s;
+ }
+ }
+
+ public override Vector3 PrimOOBoffset
+ {
+ get
+ {
+ return Vector3.Zero;
+ }
+ }
+ */
+
+ public override PrimitiveBaseShape Shape
+ {
+ set { return; }
+ }
+
+ public override Vector3 Velocity
+ {
+ get
+ {
+ return _velocity;
+ }
+ set
+ {
+ if (value.IsFinite())
+ {
+ m_pidControllerActive = true;
+ _target_velocity = value;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character");
+ }
+ }
+ }
+
+ public override Vector3 Torque
+ {
+ get { return Vector3.Zero; }
+ set { return; }
+ }
+
+ public override float CollisionScore
+ {
+ get { return 0f; }
+ set { }
+ }
+
+ public override bool Kinematic
+ {
+ get { return false; }
+ set { }
+ }
+
+ public override Quaternion Orientation
+ {
+ get { return Quaternion.Identity; }
+ set
+ {
+ //Matrix3 or = Orientation.ToRotationMatrix();
+ //d.Matrix3 ord = new d.Matrix3(or.m00, or.m10, or.m20, or.m01, or.m11, or.m21, or.m02, or.m12, or.m22);
+ //d.BodySetRotation(Body, ref ord);
+ }
+ }
+
+ public override Vector3 Acceleration
+ {
+ get { return _acceleration; }
+ set { }
+ }
+
+ public void SetAcceleration(Vector3 accel)
+ {
+ m_pidControllerActive = true;
+ _acceleration = accel;
+ }
+
+ ///
+ /// Adds the force supplied to the Target Velocity
+ /// The PID controller takes this target velocity and tries to make it a reality
+ ///
+ ///
+ public override void AddForce(Vector3 force, bool pushforce)
+ {
+ if (force.IsFinite())
+ {
+ if (pushforce)
+ {
+ m_pidControllerActive = false;
+ m_taintForce = force / _parent_scene.ODE_STEPSIZE;
+ m_hasTaintForce = true;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+ else
+ {
+ m_pidControllerActive = true;
+ _target_velocity.X += force.X;
+ _target_velocity.Y += force.Y;
+ _target_velocity.Z += force.Z;
+ }
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN force applied to a Character");
+ }
+ //m_lastUpdateSent = false;
+ }
+
+ public override void AddAngularForce(Vector3 force, bool pushforce)
+ {
+
+ }
+
+ public override void SetMomentum(Vector3 momentum)
+ {
+ }
+
+
+ ///
+ /// Called from Simulate
+ /// This is the avatar's movement control + PID Controller
+ ///
+ ///
+ public void Move(float timeStep, List defects)
+ {
+ // no lock; for now it's only called from within Simulate()
+
+ // If the PID Controller isn't active then we set our force
+ // calculating base velocity to the current position
+
+ if (Body == IntPtr.Zero)
+ return;
+
+ d.Vector3 dtmp;
+ d.BodyCopyPosition(Body, out dtmp);
+ Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
+
+ // the Amotor still lets avatar rotation to drift during colisions
+ // so force it back to identity
+
+ d.Quaternion qtmp;
+ qtmp.W = 1;
+ qtmp.X = 0;
+ qtmp.Y = 0;
+ qtmp.Z = 0;
+ d.BodySetQuaternion(Body, ref qtmp);
+
+ if (m_pidControllerActive == false)
+ {
+ _zeroPosition = localpos;
+ }
+ //PidStatus = true;
+
+
+ if (!localpos.IsFinite())
+ {
+
+ m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
+ defects.Add(this);
+ // _parent_scene.RemoveCharacter(this);
+
+ // destroy avatar capsule and related ODE data
+ AvatarGeomAndBodyDestroy();
+
+ return;
+ }
+
+ Vector3 vec = Vector3.Zero;
+ dtmp = d.BodyGetLinearVel(Body);
+ Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
+
+ float movementdivisor = 1f;
+ //Ubit change divisions into multiplications below
+ if (!m_alwaysRun)
+ {
+ movementdivisor = 1 / walkDivisor;
+ }
+ else
+ {
+ movementdivisor = 1 / runDivisor;
+ }
+
+ // colide with land
+
+ d.AABB aabb;
+ d.GeomGetAABB(Shell, out aabb);
+ float chrminZ = aabb.MinZ;
+
+ Vector3 posch = localpos;
+
+ float ftmp;
+
+ if (flying)
+ {
+ ftmp = timeStep;
+ posch.X += vel.X * ftmp;
+ posch.Y += vel.Y * ftmp;
+ }
+
+ float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
+ if (chrminZ < terrainheight)
+ {
+ float depth = terrainheight - chrminZ;
+ if (!flying)
+ {
+ vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 50;
+ }
+ else
+ vec.Z = depth * PID_P * 50;
+
+ /*
+ Vector3 vtmp;
+ vtmp.X = _target_velocity.X * timeStep;
+ vtmp.Y = _target_velocity.Y * timeStep;
+ // fake and avoid squares
+ float k = (Math.Abs(vtmp.X) + Math.Abs(vtmp.Y));
+ if (k > 0)
+ {
+ posch.X += vtmp.X;
+ posch.Y += vtmp.Y;
+ terrainheight -= _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
+ k = 1 + Math.Abs(terrainheight) / k;
+ movementdivisor /= k;
+
+ if (k < 1)
+ k = 1;
+ }
+ */
+
+
+ if (depth < 0.1f)
+ {
+ m_iscolliding = true;
+ m_colliderfilter = 2;
+ m_iscollidingGround = true;
+
+ ContactPoint contact = new ContactPoint();
+ contact.PenetrationDepth = depth;
+ contact.Position.X = localpos.X;
+ contact.Position.Y = localpos.Y;
+ contact.Position.Z = chrminZ;
+ contact.SurfaceNormal.X = 0f;
+ contact.SurfaceNormal.Y = 0f;
+ contact.SurfaceNormal.Z = -1f;
+ AddCollisionEvent(0, contact);
+
+ vec.Z *= 0.5f;
+ }
+
+ else
+ m_iscollidingGround = false;
+ }
+ else
+ m_iscollidingGround = false;
+
+
+ // if velocity is zero, use position control; otherwise, velocity control
+ if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f
+ && m_iscolliding)
+ {
+ // keep track of where we stopped. No more slippin' & slidin'
+ if (!_zeroFlag)
+ {
+ _zeroFlag = true;
+ _zeroPosition = localpos;
+ }
+ if (m_pidControllerActive)
+ {
+ // We only want to deactivate the PID Controller if we think we want to have our surrogate
+ // react to the physics scene by moving it's position.
+ // Avatar to Avatar collisions
+ // Prim to avatar collisions
+
+ vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 2);
+ vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 2);
+ if (flying)
+ {
+ vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
+ }
+ }
+ //PidStatus = true;
+ }
+ else
+ {
+ m_pidControllerActive = true;
+ _zeroFlag = false;
+
+ if (m_iscolliding)
+ {
+ if (!flying)
+ {
+ if (_target_velocity.Z > 0.0f)
+ {
+ // We're colliding with something and we're not flying but we're moving
+ // This means we're walking or running. JUMPING
+ vec.Z += (_target_velocity.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P;
+ }
+ // We're standing on something
+ vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D);
+ vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D);
+ }
+ else
+ {
+ // We're flying and colliding with something
+ vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 0.0625f);
+ vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 0.0625f);
+ vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
+ }
+ }
+ else // ie not colliding
+ {
+ if (flying) //(!m_iscolliding && flying)
+ {
+ // we're in mid air suspended
+ vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 1.667f);
+ vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 1.667f);
+ vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
+ }
+
+ else
+ {
+ // we're not colliding and we're not flying so that means we're falling!
+ // m_iscolliding includes collisions with the ground.
+
+ // d.Vector3 pos = d.BodyGetPosition(Body);
+ vec.X = (_target_velocity.X - vel.X) * PID_D * 0.833f;
+ vec.Y = (_target_velocity.Y - vel.Y) * PID_D * 0.833f;
+ }
+ }
+ }
+
+ if (flying)
+ {
+ vec.Z -= _parent_scene.gravityz * m_mass;
+
+ //Added for auto fly height. Kitto Flora
+ float target_altitude = _parent_scene.GetTerrainHeightAtXY(localpos.X, localpos.Y) + MinimumGroundFlightOffset;
+
+ if (localpos.Z < target_altitude)
+ {
+ vec.Z += (target_altitude - localpos.Z) * PID_P * 5.0f;
+ }
+ // end add Kitto Flora
+ }
+
+ if (vec.IsFinite())
+ {
+ if (vec.X != 0 || vec.Y !=0 || vec.Z !=0)
+ d.BodyAddForce(Body, vec.X, vec.Y, vec.Z);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN force vector in Move()");
+ m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
+ defects.Add(this);
+ // _parent_scene.RemoveCharacter(this);
+ // destroy avatar capsule and related ODE data
+ AvatarGeomAndBodyDestroy();
+ }
+ }
+
+ ///
+ /// Updates the reported position and velocity. This essentially sends the data up to ScenePresence.
+ ///
+ public void UpdatePositionAndVelocity()
+ {
+ // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
+ if (Body == IntPtr.Zero)
+ return;
+
+ d.Vector3 vec;
+ try
+ {
+ d.BodyCopyPosition(Body, out vec);
+ }
+ catch (NullReferenceException)
+ {
+ bad = true;
+ _parent_scene.BadCharacter(this);
+ vec = new d.Vector3(_position.X, _position.Y, _position.Z);
+ base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
+ m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid);
+ }
+
+ _position.X = vec.X;
+ _position.Y = vec.Y;
+ _position.Z = vec.Z;
+
+ bool fixbody = false;
+
+ if (_position.X < 0.0f)
+ {
+ fixbody = true;
+ _position.X = 0.1f;
+ }
+ else if (_position.X > (int)_parent_scene.WorldExtents.X - 0.1f)
+ {
+ fixbody = true;
+ _position.X = (int)_parent_scene.WorldExtents.X - 0.1f;
+ }
+
+ if (_position.Y < 0.0f)
+ {
+ fixbody = true;
+ _position.Y = 0.1f;
+ }
+ else if (_position.Y > (int)_parent_scene.WorldExtents.Y - 0.1)
+ {
+ fixbody = true;
+ _position.Y = (int)_parent_scene.WorldExtents.Y - 0.1f;
+ }
+
+ if (fixbody)
+ d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
+
+ // Did we move last? = zeroflag
+ // This helps keep us from sliding all over
+/*
+ if (_zeroFlag)
+ {
+ _velocity.X = 0.0f;
+ _velocity.Y = 0.0f;
+ _velocity.Z = 0.0f;
+
+ // Did we send out the 'stopped' message?
+ if (!m_lastUpdateSent)
+ {
+ m_lastUpdateSent = true;
+ base.RequestPhysicsterseUpdate();
+ }
+ }
+ else
+ {
+ m_lastUpdateSent = false;
+ */
+ try
+ {
+ vec = d.BodyGetLinearVel(Body);
+ }
+ catch (NullReferenceException)
+ {
+ vec.X = _velocity.X;
+ vec.Y = _velocity.Y;
+ vec.Z = _velocity.Z;
+ }
+ _velocity.X = (vec.X);
+ _velocity.Y = (vec.Y);
+ _velocity.Z = (vec.Z);
+ // }
+ }
+
+ ///
+ /// Cleanup the things we use in the scene.
+ ///
+ public void Destroy()
+ {
+ m_tainted_isPhysical = false;
+ _parent_scene.AddPhysicsActorTaint(this);
+ }
+
+ public override void CrossingFailure()
+ {
+ }
+
+ public override Vector3 PIDTarget { set { return; } }
+ public override bool PIDActive { set { return; } }
+ public override float PIDTau { set { return; } }
+
+ public override float PIDHoverHeight { set { return; } }
+ public override bool PIDHoverActive { set { return; } }
+ public override PIDHoverType PIDHoverType { set { return; } }
+ public override float PIDHoverTau { set { return; } }
+
+ public override Quaternion APIDTarget { set { return; } }
+
+ public override bool APIDActive { set { return; } }
+
+ public override float APIDStrength { set { return; } }
+
+ public override float APIDDamping { set { return; } }
+
+
+ public override void SubscribeEvents(int ms)
+ {
+ m_requestedUpdateFrequency = ms;
+ m_eventsubscription = ms;
+ _parent_scene.AddCollisionEventReporting(this);
+ m_haseventsubscription = true;
+ }
+
+ public override void UnSubscribeEvents()
+ {
+ m_haseventsubscription = false;
+ _parent_scene.RemoveCollisionEventReporting(this);
+ m_requestedUpdateFrequency = 0;
+ m_eventsubscription = 0;
+ }
+
+ public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
+ {
+ if (m_haseventsubscription)
+ {
+ // m_log.DebugFormat(
+ // "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact);
+
+ CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
+ }
+ }
+
+ public void SendCollisions()
+ {
+ if (m_haseventsubscription && m_eventsubscription > m_requestedUpdateFrequency)
+ {
+ if (CollisionEventsThisFrame != null)
+ {
+ base.SendCollisionUpdate(CollisionEventsThisFrame);
+ }
+ CollisionEventsThisFrame = new CollisionEventUpdate();
+ m_eventsubscription = 0;
+ }
+ }
+
+ public override bool SubscribedEvents()
+ {
+ return m_haseventsubscription;
+ }
+
+ public void ProcessTaints(float timestep)
+ {
+
+ if (m_tainted_isPhysical != m_isPhysical)
+ {
+ if (m_tainted_isPhysical)
+ {
+ // Create avatar capsule and related ODE data
+ if ((Shell != IntPtr.Zero))
+ {
+ // a lost shell ?
+ m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - "
+ + (Shell != IntPtr.Zero ? "Shell " : "")
+ + (Body != IntPtr.Zero ? "Body " : "")
+ + (Amotor != IntPtr.Zero ? "Amotor " : ""));
+ AvatarGeomAndBodyDestroy();
+ }
+
+ AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
+ _parent_scene.geom_name_map[Shell] = m_name;
+ _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
+ _parent_scene.AddCharacter(this);
+ }
+ else
+ {
+ _parent_scene.RemoveCharacter(this);
+ // destroy avatar capsule and related ODE data
+ AvatarGeomAndBodyDestroy();
+ }
+
+ m_isPhysical = m_tainted_isPhysical;
+ }
+
+ if (m_tainted_CAPSULE_LENGTH != CAPSULE_LENGTH)
+ {
+ if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero)
+ {
+ AvatarGeomAndBodyDestroy();
+
+ m_pidControllerActive = true;
+
+ float prevCapsule = CAPSULE_LENGTH;
+ CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH;
+
+ AvatarGeomAndBodyCreation(_position.X, _position.Y,
+ _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
+
+ Velocity = Vector3.Zero;
+
+ _parent_scene.geom_name_map[Shell] = m_name;
+ _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - "
+ + (Shell == IntPtr.Zero ? "Shell " : "")
+ + (Body == IntPtr.Zero ? "Body " : "")
+ + (Amotor == IntPtr.Zero ? "Amotor " : ""));
+ }
+ }
+
+ if (m_hasTaintPosition)
+ {
+ if (Body != IntPtr.Zero)
+ d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z);
+
+ _position.X = m_taintPosition.X;
+ _position.Y = m_taintPosition.Y;
+ _position.Z = m_taintPosition.Z;
+ m_hasTaintPosition = false;
+ }
+
+ if (m_hasTaintForce)
+ {
+ if (Body != IntPtr.Zero)
+ {
+ if(m_taintForce.X !=0f || m_taintForce.Y !=0f || m_taintForce.Z !=0)
+ d.BodyAddForce(Body, m_taintForce.X, m_taintForce.Y, m_taintForce.Z);
+ m_hasTaintForce = false;
+ }
+ }
+
+ }
+
+ internal void AddCollisionFrameTime(int p)
+ {
+ // protect it from overflow crashing
+ if (m_eventsubscription + p >= int.MaxValue)
+ m_eventsubscription = 0;
+ m_eventsubscription += p;
+ }
+ }
+}
--
cgit v1.1
From b617411b972281529684bd8151a59899c81bfcf6 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 11 Feb 2012 02:48:38 +0000
Subject: scale avatar push force with avatar density
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index c8f7c76..b0b91f6 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -768,7 +768,8 @@ namespace OpenSim.Region.Physics.OdePlugin
if (pushforce)
{
m_pidControllerActive = false;
- m_taintForce = force / _parent_scene.ODE_STEPSIZE;
+ // scale with odetime step and density
+ m_taintForce = force * m_density / _parent_scene.ODE_STEPSIZE / 28f;
m_hasTaintForce = true;
_parent_scene.AddPhysicsActorTaint(this);
}
--
cgit v1.1
From 022ae33ed5da0b1d9b56694bcfbf2f1a9e18b36e Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 11 Feb 2012 17:35:38 +0000
Subject: UbitODE: replace 'taints' by 'changes' for avatars also. This
provides better time order with changes in prims.
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 563 +++++++++++++--------
1 file changed, 356 insertions(+), 207 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b0b91f6..cf7fdca 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -26,7 +26,7 @@
*/
-// Revision by Ubit 2011
+// Revision by Ubit 2011/12
using System;
using System.Collections.Generic;
@@ -95,21 +95,12 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_iscollidingObj = false;
private bool m_alwaysRun = false;
private int m_requestedUpdateFrequency = 0;
- private Vector3 m_taintPosition = Vector3.Zero;
- private bool m_hasTaintPosition = false;
public uint m_localID = 0;
public bool m_returnCollisions = false;
// taints and their non-tainted counterparts
public bool m_isPhysical = false; // the current physical status
- public bool m_tainted_isPhysical = false; // set when the physical status is tainted (false=not existing in physics engine, true=existing)
public float MinimumGroundFlightOffset = 3f;
-
- private Vector3 m_taintForce;
- private bool m_hasTaintForce;
- private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
-
-
private float m_buoyancy = 0f;
// private CollisionLocker ode;
@@ -151,15 +142,13 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_uuid = UUID.Random();
- m_hasTaintPosition = false;
-
if (pos.IsFinite())
{
- if (pos.Z > 9999999f)
+ if (pos.Z > 99999f)
{
pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
}
- if (pos.Z < -90000f)
+ if (pos.Z < -100f) // shouldn't this be 0 ?
{
pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
}
@@ -187,15 +176,12 @@ namespace OpenSim.Region.Physics.OdePlugin
CAPSULE_LENGTH = size.Z * 1.15f - CAPSULE_RADIUS * 2.0f;
//m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
- m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH;
m_isPhysical = false; // current status: no ODE information exists
- m_tainted_isPhysical = true; // new tainted status: need to create ODE information
-
- m_hasTaintForce = false;
- _parent_scene.AddPhysicsActorTaint(this);
m_name = avName;
+
+ AddChange(changes.Add, null);
}
public override int PhysicsActorType
@@ -402,16 +388,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{
value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
}
- if (value.Z < -90000f)
+ if (value.Z < -100f)
{
value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
}
-
- m_taintPosition.X = value.X;
- m_taintPosition.Y = value.Y;
- m_taintPosition.Z = value.Z;
- m_hasTaintPosition = true;
- _parent_scene.AddPhysicsActorTaint(this);
+ AddChange(changes.Position, value);
}
else
{
@@ -440,11 +421,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (value.IsFinite())
{
- m_pidControllerActive = true;
-
- Vector3 SetSize = value;
- m_tainted_CAPSULE_LENGTH = SetSize.Z *1.15f - CAPSULE_RADIUS * 2.0f;
- _parent_scene.AddPhysicsActorTaint(this);
+ AddChange(changes.Size, value);
}
else
{
@@ -460,129 +437,6 @@ namespace OpenSim.Region.Physics.OdePlugin
///
///
- // WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
- // to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
- // place that is safe to call this routine AvatarGeomAndBodyCreation.
- private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
- {
- _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
- if (CAPSULE_LENGTH <= 0)
- {
- m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
- CAPSULE_LENGTH = 0.01f;
-
- }
-
- if (CAPSULE_RADIUS <= 0)
- {
- m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
- CAPSULE_RADIUS = 0.01f;
-
- }
- Shell = d.CreateCapsule(_parent_scene.ActiveSpace, CAPSULE_RADIUS, CAPSULE_LENGTH);
-
- d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
- d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
-
- d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH);
-
- m_mass = ShellMass.mass; // update mass
-
- // rescale PID parameters
- PID_D = _parent_scene.avPIDD;
- PID_P = _parent_scene.avPIDP;
-
- // rescale PID parameters so that this aren't affected by mass
- // and so don't get unstable for some masses
- // also scale by ode time step so you don't need to refix them
-
- PID_D /= 50 * 80; //scale to original mass of around 80 and 50 ODE fps
- PID_D *= m_mass / _parent_scene.ODE_STEPSIZE;
- PID_P /= 50 * 80;
- PID_P *= m_mass / _parent_scene.ODE_STEPSIZE;
-
- Body = d.BodyCreate(_parent_scene.world);
-
- d.BodySetAutoDisableFlag(Body, false);
- d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
-
- _position.X = npositionX;
- _position.Y = npositionY;
- _position.Z = npositionZ;
-
- m_hasTaintPosition = false;
-
- d.BodySetMass(Body, ref ShellMass);
- d.GeomSetBody(Shell, Body);
-
- // The purpose of the AMotor here is to keep the avatar's physical
- // surrogate from rotating while moving
- Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
- d.JointAttach(Amotor, Body, IntPtr.Zero);
-
- d.JointSetAMotorMode(Amotor, 0);
- d.JointSetAMotorNumAxes(Amotor, 3);
- d.JointSetAMotorAxis(Amotor, 0, 0 , 1, 0, 0);
- d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
- d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
-
- d.JointSetAMotorAngle(Amotor, 0, 0);
- d.JointSetAMotorAngle(Amotor, 1, 0);
- d.JointSetAMotorAngle(Amotor, 2, 0);
-
- d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM, 0f); // make it HARD
- d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM2, 0f);
- d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM3, 0f);
- d.JointSetAMotorParam(Amotor, (int)dParam.StopERP, 0.8f);
- d.JointSetAMotorParam(Amotor, (int)dParam.StopERP2, 0.8f);
- d.JointSetAMotorParam(Amotor, (int)dParam.StopERP3, 0.8f);
-
- // These lowstops and high stops are effectively (no wiggle room)
- d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -1e-5f);
- d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 1e-5f);
- d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -1e-5f);
- d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 1e-5f);
- d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -1e-5f);
- d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 1e-5f);
-
- d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel, 0);
- d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel2, 0);
- d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel3, 0);
-
- d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 5e6f);
- d.JointSetAMotorParam(Amotor, (int)dParam.FMax2, 5e6f);
- d.JointSetAMotorParam(Amotor, (int)dParam.FMax3, 5e6f);
- }
-
- ///
- /// Destroys the avatar body and geom
-
- private void AvatarGeomAndBodyDestroy()
- {
- // Kill the Amotor
- if (Amotor != IntPtr.Zero)
- {
- d.JointDestroy(Amotor);
- Amotor = IntPtr.Zero;
- }
-
- if (Body != IntPtr.Zero)
- {
- //kill the body
- d.BodyDestroy(Body);
- Body = IntPtr.Zero;
- }
-
- //kill the Geometry
- if (Shell != IntPtr.Zero)
- {
- _parent_scene.geom_name_map.Remove(Shell);
- _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
- d.GeomDestroy(Shell);
- _parent_scene.geom_name_map.Remove(Shell);
- Shell = IntPtr.Zero;
- }
- }
//
///
/// Uses the capped cyllinder volume formula to calculate the avatar's mass.
@@ -705,8 +559,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (value.IsFinite())
{
- m_pidControllerActive = true;
- _target_velocity = value;
+ AddChange(changes.Velocity, value);
}
else
{
@@ -738,9 +591,6 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return Quaternion.Identity; }
set
{
- //Matrix3 or = Orientation.ToRotationMatrix();
- //d.Matrix3 ord = new d.Matrix3(or.m00, or.m10, or.m20, or.m01, or.m11, or.m21, or.m02, or.m12, or.m22);
- //d.BodySetRotation(Body, ref ord);
}
}
@@ -767,18 +617,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (pushforce)
{
- m_pidControllerActive = false;
- // scale with odetime step and density
- m_taintForce = force * m_density / _parent_scene.ODE_STEPSIZE / 28f;
- m_hasTaintForce = true;
- _parent_scene.AddPhysicsActorTaint(this);
+ AddChange(changes.Force, force * m_density / _parent_scene.ODE_STEPSIZE / 28f);
}
else
{
- m_pidControllerActive = true;
- _target_velocity.X += force.X;
- _target_velocity.Y += force.Y;
- _target_velocity.Z += force.Z;
+ AddChange(changes.Velocity, force);
}
}
else
@@ -798,6 +641,128 @@ namespace OpenSim.Region.Physics.OdePlugin
}
+ // WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
+ // to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
+ // place that is safe to call this routine AvatarGeomAndBodyCreation.
+ private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
+ {
+ _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ if (CAPSULE_LENGTH <= 0)
+ {
+ m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
+ CAPSULE_LENGTH = 0.01f;
+
+ }
+
+ if (CAPSULE_RADIUS <= 0)
+ {
+ m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
+ CAPSULE_RADIUS = 0.01f;
+
+ }
+ Shell = d.CreateCapsule(_parent_scene.ActiveSpace, CAPSULE_RADIUS, CAPSULE_LENGTH);
+
+ d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
+ d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
+
+ d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH);
+
+ m_mass = ShellMass.mass; // update mass
+
+ // rescale PID parameters
+ PID_D = _parent_scene.avPIDD;
+ PID_P = _parent_scene.avPIDP;
+
+ // rescale PID parameters so that this aren't affected by mass
+ // and so don't get unstable for some masses
+ // also scale by ode time step so you don't need to refix them
+
+ PID_D /= 50 * 80; //scale to original mass of around 80 and 50 ODE fps
+ PID_D *= m_mass / _parent_scene.ODE_STEPSIZE;
+ PID_P /= 50 * 80;
+ PID_P *= m_mass / _parent_scene.ODE_STEPSIZE;
+
+ Body = d.BodyCreate(_parent_scene.world);
+
+ d.BodySetAutoDisableFlag(Body, false);
+ d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
+
+ _position.X = npositionX;
+ _position.Y = npositionY;
+ _position.Z = npositionZ;
+
+ d.BodySetMass(Body, ref ShellMass);
+ d.GeomSetBody(Shell, Body);
+
+ // The purpose of the AMotor here is to keep the avatar's physical
+ // surrogate from rotating while moving
+ Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
+ d.JointAttach(Amotor, Body, IntPtr.Zero);
+
+ d.JointSetAMotorMode(Amotor, 0);
+ d.JointSetAMotorNumAxes(Amotor, 3);
+ d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
+ d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
+ d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
+
+ d.JointSetAMotorAngle(Amotor, 0, 0);
+ d.JointSetAMotorAngle(Amotor, 1, 0);
+ d.JointSetAMotorAngle(Amotor, 2, 0);
+
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM, 0f); // make it HARD
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM2, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopCFM3, 0f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopERP, 0.8f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopERP2, 0.8f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.StopERP3, 0.8f);
+
+ // These lowstops and high stops are effectively (no wiggle room)
+ d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -1e-5f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 1e-5f);
+
+ d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel, 0);
+ d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel2, 0);
+ d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel3, 0);
+
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 5e6f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax2, 5e6f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax3, 5e6f);
+ }
+
+ ///
+ /// Destroys the avatar body and geom
+
+ private void AvatarGeomAndBodyDestroy()
+ {
+ // Kill the Amotor
+ if (Amotor != IntPtr.Zero)
+ {
+ d.JointDestroy(Amotor);
+ Amotor = IntPtr.Zero;
+ }
+
+ if (Body != IntPtr.Zero)
+ {
+ //kill the body
+ d.BodyDestroy(Body);
+ Body = IntPtr.Zero;
+ }
+
+ //kill the Geometry
+ if (Shell != IntPtr.Zero)
+ {
+ _parent_scene.geom_name_map.Remove(Shell);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ d.GeomDestroy(Shell);
+ _parent_scene.geom_name_map.Remove(Shell);
+ Shell = IntPtr.Zero;
+ }
+ }
+
///
/// Called from Simulate
/// This is the avatar's movement control + PID Controller
@@ -1136,8 +1101,7 @@ namespace OpenSim.Region.Physics.OdePlugin
///
public void Destroy()
{
- m_tainted_isPhysical = false;
- _parent_scene.AddPhysicsActorTaint(this);
+ AddChange(changes.Remove, null);
}
public override void CrossingFailure()
@@ -1207,12 +1171,11 @@ namespace OpenSim.Region.Physics.OdePlugin
return m_haseventsubscription;
}
- public void ProcessTaints(float timestep)
+ private void changePhysicsStatus(bool NewStatus)
{
-
- if (m_tainted_isPhysical != m_isPhysical)
+ if (NewStatus != m_isPhysical)
{
- if (m_tainted_isPhysical)
+ if (NewStatus)
{
// Create avatar capsule and related ODE data
if ((Shell != IntPtr.Zero))
@@ -1237,60 +1200,246 @@ namespace OpenSim.Region.Physics.OdePlugin
AvatarGeomAndBodyDestroy();
}
- m_isPhysical = m_tainted_isPhysical;
+ m_isPhysical = NewStatus;
}
+ }
+
+ private void changeAdd()
+ {
+ changePhysicsStatus(true);
+ }
- if (m_tainted_CAPSULE_LENGTH != CAPSULE_LENGTH)
+ private void changeRemove()
+ {
+ changePhysicsStatus(false);
+ }
+
+ private void changeShape(PrimitiveBaseShape arg)
+ {
+ }
+
+ private void changeSize(Vector3 Size)
+ {
+ if (Size.IsFinite())
{
- if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero)
+ float caplen = Size.Z;
+
+ caplen = caplen * 1.15f - CAPSULE_RADIUS * 2.0f;
+
+ if (caplen != CAPSULE_LENGTH)
{
- AvatarGeomAndBodyDestroy();
+ if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero)
+ {
+ AvatarGeomAndBodyDestroy();
- m_pidControllerActive = true;
+ float prevCapsule = CAPSULE_LENGTH;
+ CAPSULE_LENGTH = caplen;
- float prevCapsule = CAPSULE_LENGTH;
- CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH;
-
- AvatarGeomAndBodyCreation(_position.X, _position.Y,
- _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
+ AvatarGeomAndBodyCreation(_position.X, _position.Y,
+ _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
- Velocity = Vector3.Zero;
+ Velocity = Vector3.Zero;
- _parent_scene.geom_name_map[Shell] = m_name;
- _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
- }
- else
- {
- m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - "
- + (Shell == IntPtr.Zero ? "Shell " : "")
- + (Body == IntPtr.Zero ? "Body " : "")
- + (Amotor == IntPtr.Zero ? "Amotor " : ""));
+ _parent_scene.geom_name_map[Shell] = m_name;
+ _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - "
+ + (Shell == IntPtr.Zero ? "Shell " : "")
+ + (Body == IntPtr.Zero ? "Body " : "")
+ + (Amotor == IntPtr.Zero ? "Amotor " : ""));
+ }
}
+
+ m_pidControllerActive = true;
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN Size from Scene on a Character");
}
+ }
- if (m_hasTaintPosition)
+ private void changePosition( Vector3 newPos)
{
if (Body != IntPtr.Zero)
- d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z);
+ d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
+ _position = newPos;
+ }
+
+ private void changeOrientation(Quaternion newOri)
+ {
+ }
+
+ private void changeVelocity(Vector3 newVel)
+ {
+ m_pidControllerActive = true;
+ _target_velocity = newVel;
+ }
- _position.X = m_taintPosition.X;
- _position.Y = m_taintPosition.Y;
- _position.Z = m_taintPosition.Z;
- m_hasTaintPosition = false;
+ private void changeSetTorque(Vector3 newTorque)
+ {
+ }
+
+ private void changeAddForce(Vector3 newForce)
+ {
+ }
+
+ private void changeAddAngularForce(Vector3 arg)
+ {
+ }
+
+ private void changeAngularLock(Vector3 arg)
+ {
+ }
+
+ private void changeFloatOnWater(bool arg)
+ {
+ }
+
+ private void changeVolumedetetion(bool arg)
+ {
+ }
+
+ private void changeSelectedStatus(bool arg)
+ {
+ }
+
+ private void changeDisable(bool arg)
+ {
+ }
+
+ private void changeBuilding(bool arg)
+ {
+ }
+
+ private void changeForce(Vector3 newForce)
+ {
+ m_pidControllerActive = false;
+ if (Body != IntPtr.Zero)
+ {
+ if (newForce.X != 0f || newForce.Y != 0f || newForce.Z != 0)
+ d.BodyAddForce(Body, newForce.X, newForce.Y, newForce.Z);
+ }
+ }
+
+ private void donullchange()
+ {
+ }
+
+ public bool DoAChange(changes what, object arg)
+ {
+ if (Shell == IntPtr.Zero && what != changes.Add && what != changes.Remove)
+ {
+ return false;
}
- if (m_hasTaintForce)
+ // nasty switch
+ switch (what)
{
- if (Body != IntPtr.Zero)
- {
- if(m_taintForce.X !=0f || m_taintForce.Y !=0f || m_taintForce.Z !=0)
- d.BodyAddForce(Body, m_taintForce.X, m_taintForce.Y, m_taintForce.Z);
- m_hasTaintForce = false;
- }
+ case changes.Add:
+ changeAdd();
+ break;
+ case changes.Remove:
+ changeRemove();
+ break;
+
+ case changes.Position:
+ changePosition((Vector3)arg);
+ break;
+
+ case changes.Orientation:
+ changeOrientation((Quaternion)arg);
+ break;
+
+ case changes.PosOffset:
+ donullchange();
+ break;
+
+ case changes.OriOffset:
+ donullchange();
+ break;
+
+ case changes.Velocity:
+ changeVelocity((Vector3)arg);
+ break;
+
+ // case changes.Acceleration:
+ // changeacceleration((Vector3)arg);
+ // break;
+ // case changes.AngVelocity:
+ // changeangvelocity((Vector3)arg);
+ // break;
+
+ case changes.Force:
+ changeForce((Vector3)arg);
+ break;
+
+ case changes.Torque:
+ changeSetTorque((Vector3)arg);
+ break;
+
+ case changes.AddForce:
+ changeAddForce((Vector3)arg);
+ break;
+
+ case changes.AddAngForce:
+ changeAddAngularForce((Vector3)arg);
+ break;
+
+ case changes.AngLock:
+ changeAngularLock((Vector3)arg);
+ break;
+
+ case changes.Size:
+ changeSize((Vector3)arg);
+ break;
+/* not in use for now
+ case changes.Shape:
+ changeShape((PrimitiveBaseShape)arg);
+ break;
+
+ case changes.CollidesWater:
+ changeFloatOnWater((bool)arg);
+ break;
+
+ case changes.VolumeDtc:
+ changeVolumedetetion((bool)arg);
+ break;
+
+ case changes.Physical:
+ changePhysicsStatus((bool)arg);
+ break;
+
+ case changes.Selected:
+ changeSelectedStatus((bool)arg);
+ break;
+
+ case changes.disabled:
+ changeDisable((bool)arg);
+ break;
+
+ case changes.building:
+ changeBuilding((bool)arg);
+ break;
+*/
+ case changes.Null:
+ donullchange();
+ break;
+
+ default:
+ donullchange();
+ break;
}
+ return false;
+ }
+ public void AddChange(changes what, object arg)
+ {
+ _parent_scene.AddChange((PhysicsActor)this, what, arg);
}
+
internal void AddCollisionFrameTime(int p)
{
// protect it from overflow crashing
--
cgit v1.1
From 6fd6919a0bcdfd2d15d0b7a7aa392837de759114 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 11 Feb 2012 19:25:41 +0000
Subject: remove drawstuff from ubitode
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index cf7fdca..793e281 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -126,7 +126,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public IntPtr Shell = IntPtr.Zero;
public IntPtr Amotor = IntPtr.Zero;
public d.Mass ShellMass;
- public bool collidelock = false;
+// public bool collidelock = false;
private bool m_haseventsubscription = false;
public int m_eventsubscription = 0;
--
cgit v1.1
From 01fcd400d7651be5f4aae3547a0489a7ccc5d7f7 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 4 Mar 2012 04:26:05 +0000
Subject: update UbitOde
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 793e281..94cadb2 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -136,7 +136,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public UUID m_uuid;
public bool bad = false;
- public ContactData AvatarContactData = new ContactData(10f, 0.3f);
+ float mu;
+ float bounce;
public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor)
{
@@ -168,8 +169,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_density = density;
m_mass = 80f; // sure we have a default
- AvatarContactData.mu = parent_scene.AvatarFriction;
- AvatarContactData.bounce = parent_scene.AvatarBounce;
+ mu = parent_scene.AvatarFriction;
+ bounce = parent_scene.AvatarBounce;
walkDivisor = walk_divisor;
runDivisor = rundivisor;
@@ -190,9 +191,10 @@ namespace OpenSim.Region.Physics.OdePlugin
set { return; }
}
- public override ContactData ContactData
+ public override void getContactData(ref ContactData cdata)
{
- get { return AvatarContactData; }
+ cdata.mu = mu;
+ cdata.bounce = bounce;
}
public override bool Building { get; set; }
--
cgit v1.1
From 7377e633c73f7ee34240cb70f0f75fcd9b705168 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 5 Mar 2012 12:37:21 +0000
Subject: update ubitOde
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 94cadb2..9a22331 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -195,6 +195,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
cdata.mu = mu;
cdata.bounce = bounce;
+ cdata.softcolide = false;
}
public override bool Building { get; set; }
--
cgit v1.1
From 21a97408d4b209f22dabbe1203cffc388d9757bf Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 24 Mar 2012 11:30:29 +0000
Subject: Avatars have no bounce
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 9a22331..4266fda 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -137,7 +137,6 @@ namespace OpenSim.Region.Physics.OdePlugin
public bool bad = false;
float mu;
- float bounce;
public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor)
{
@@ -170,7 +169,6 @@ namespace OpenSim.Region.Physics.OdePlugin
m_mass = 80f; // sure we have a default
mu = parent_scene.AvatarFriction;
- bounce = parent_scene.AvatarBounce;
walkDivisor = walk_divisor;
runDivisor = rundivisor;
@@ -194,7 +192,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void getContactData(ref ContactData cdata)
{
cdata.mu = mu;
- cdata.bounce = bounce;
+ cdata.bounce = 0;
cdata.softcolide = false;
}
--
cgit v1.1
From 86a2169d7343825c74ae271f637002377b92b438 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 16 Apr 2012 16:16:55 +0100
Subject: ubitODE + physmanager: - Revised use of ODE collisions categories and
bits(flags) for better use as filters together with top spaces (for example
physical prims are on topactivespace and not physical are on topstaticspace)
- Added new world raycast with filters. This blocks calling thread with a
timeout of 500ms waiting for heartbeat ode thread signal job done. - Don't
let ode bodies being disabled for 2 long except for vehicles. This is
necessary to detect when the object is at rest at top of other and that is
removed. Assume that vehicles can be enabled by used action.
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 29 ++++++++++++++++------
1 file changed, 21 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 4266fda..b9bb06e 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -115,12 +115,10 @@ namespace OpenSim.Region.Physics.OdePlugin
private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
// Default, Collide with Other Geometries, spaces, bodies and characters.
- private CollisionCategories m_collisionFlags = (CollisionCategories.Geom
- | CollisionCategories.Space
- | CollisionCategories.Body
- | CollisionCategories.Character
+ private CollisionCategories m_collisionFlags = (CollisionCategories.Character
+ | CollisionCategories.Geom
);
- // we do land collisions not ode | CollisionCategories.Land);
+ // we do land collisions not ode | CollisionCategories.Land);
public IntPtr Body = IntPtr.Zero;
private OdeScene _parent_scene;
public IntPtr Shell = IntPtr.Zero;
@@ -639,6 +637,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void SetMomentum(Vector3 momentum)
{
+ if (momentum.IsFinite())
+ AddChange(changes.Momentum, momentum);
}
@@ -663,8 +663,8 @@ namespace OpenSim.Region.Physics.OdePlugin
}
Shell = d.CreateCapsule(_parent_scene.ActiveSpace, CAPSULE_RADIUS, CAPSULE_LENGTH);
- d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
- d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
+ d.GeomSetCategoryBits(Shell, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(Shell, (uint)m_collisionFlags);
d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH);
@@ -759,7 +759,6 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.geom_name_map.Remove(Shell);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
d.GeomDestroy(Shell);
- _parent_scene.geom_name_map.Remove(Shell);
Shell = IntPtr.Zero;
}
}
@@ -1324,6 +1323,16 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
+ // for now momentum is actually velocity
+ private void changeMomentum(Vector3 newmomentum)
+ {
+ _velocity = newmomentum;
+ _target_velocity = newmomentum;
+ m_pidControllerActive = true;
+ if (Body != IntPtr.Zero)
+ d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
+ }
+
private void donullchange()
{
}
@@ -1395,6 +1404,10 @@ namespace OpenSim.Region.Physics.OdePlugin
case changes.Size:
changeSize((Vector3)arg);
break;
+
+ case changes.Momentum:
+ changeMomentum((Vector3)arg);
+ break;
/* not in use for now
case changes.Shape:
changeShape((PrimitiveBaseShape)arg);
--
cgit v1.1
From 6480b72eda967d6166cb8a64c5bca20c7841358c Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 16 Apr 2012 19:44:02 +0100
Subject: ubitODE: - fix remove characters from default raycasts filters as
older code (or camera is very odd) - Slow down avatar if velocity is higher
than 50m/s as in chODE
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 8 ++++++++
1 file changed, 8 insertions(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b9bb06e..3185aad 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -990,6 +990,14 @@ namespace OpenSim.Region.Physics.OdePlugin
// end add Kitto Flora
}
+ if (vel.X * vel.X + vel.Y * vel.Y + vel.Z * vel.Z > 2500.0f) // 50m/s apply breaks
+ {
+ float breakfactor = 0.16f * m_mass; // will give aprox 60m/s terminal velocity at free fall
+ vec.X -= breakfactor * vel.X;
+ vec.Y -= breakfactor * vel.Y;
+ vec.Z -= breakfactor * vel.Z;
+ }
+
if (vec.IsFinite())
{
if (vec.X != 0 || vec.Y !=0 || vec.Z !=0)
--
cgit v1.1
From 36207b88ffc7801fb15e544e727cb3efaa25d6ea Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 17 Apr 2012 01:00:50 +0100
Subject: ubitODE: bug fix let avatars colide with volume detectors
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 3185aad..9c1b87b 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -117,6 +117,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Default, Collide with Other Geometries, spaces, bodies and characters.
private CollisionCategories m_collisionFlags = (CollisionCategories.Character
| CollisionCategories.Geom
+ | CollisionCategories.VolumeDtc
);
// we do land collisions not ode | CollisionCategories.Land);
public IntPtr Body = IntPtr.Zero;
--
cgit v1.1
From d7e24542818ed3edfa57ce748ad2c0bad8f694f4 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 17 Apr 2012 14:24:13 +0100
Subject: ubitODE: - made avatar/ground collision pid servo a bit softer since
seems a bit unstable with small avas in AVI even if fine on my testsite -
Removed reading of PID parameters from config files since that only serves to
mess things up and adds more unknowns
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 9c1b87b..1c8de56 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -851,10 +851,10 @@ namespace OpenSim.Region.Physics.OdePlugin
float depth = terrainheight - chrminZ;
if (!flying)
{
- vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 50;
+ vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 30;
}
else
- vec.Z = depth * PID_P * 50;
+ vec.Z = depth * PID_P * 30;
/*
Vector3 vtmp;
--
cgit v1.1
From 9132c9e49963c656e303815e5cb9e0c4341f0821 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 17 Apr 2012 15:50:14 +0100
Subject: ubitODE: - character managed ode was only getting position etc from
unmanaged at heartbeat rate like core ode. Now do it at ODE rate in move(..).
UpdatePositionAndVelocity() called once per heartbeat is now empty.
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 162 ++++++---------------
1 file changed, 44 insertions(+), 118 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 1c8de56..b9ec6b5 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -771,16 +771,10 @@ namespace OpenSim.Region.Physics.OdePlugin
///
public void Move(float timeStep, List defects)
{
- // no lock; for now it's only called from within Simulate()
-
- // If the PID Controller isn't active then we set our force
- // calculating base velocity to the current position
-
if (Body == IntPtr.Zero)
return;
- d.Vector3 dtmp;
- d.BodyCopyPosition(Body, out dtmp);
+ d.Vector3 dtmp = d.BodyGetPosition(Body);
Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
// the Amotor still lets avatar rotation to drift during colisions
@@ -797,22 +791,43 @@ namespace OpenSim.Region.Physics.OdePlugin
{
_zeroPosition = localpos;
}
- //PidStatus = true;
-
if (!localpos.IsFinite())
{
-
m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
defects.Add(this);
// _parent_scene.RemoveCharacter(this);
// destroy avatar capsule and related ODE data
AvatarGeomAndBodyDestroy();
-
return;
}
+ // check outbounds forcing to be in world
+ bool fixbody = false;
+ if (localpos.X < 0.0f)
+ {
+ fixbody = true;
+ localpos.X = 0.1f;
+ }
+ else if (localpos.X > _parent_scene.WorldExtents.X - 0.1f)
+ {
+ fixbody = true;
+ localpos.X = _parent_scene.WorldExtents.X - 0.1f;
+ }
+ if (localpos.Y < 0.0f)
+ {
+ fixbody = true;
+ localpos.Y = 0.1f;
+ }
+ else if (localpos.Y > _parent_scene.WorldExtents.Y - 0.1)
+ {
+ fixbody = true;
+ localpos.Y = _parent_scene.WorldExtents.Y - 0.1f;
+ }
+ if (fixbody)
+ d.BodySetPosition(Body, localpos.X, localpos.Y, localpos.Z);
+
Vector3 vec = Vector3.Zero;
dtmp = d.BodyGetLinearVel(Body);
Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
@@ -820,16 +835,12 @@ namespace OpenSim.Region.Physics.OdePlugin
float movementdivisor = 1f;
//Ubit change divisions into multiplications below
if (!m_alwaysRun)
- {
movementdivisor = 1 / walkDivisor;
- }
else
- {
movementdivisor = 1 / runDivisor;
- }
+ //******************************************
// colide with land
-
d.AABB aabb;
d.GeomGetAABB(Shell, out aabb);
float chrminZ = aabb.MinZ;
@@ -856,26 +867,6 @@ namespace OpenSim.Region.Physics.OdePlugin
else
vec.Z = depth * PID_P * 30;
- /*
- Vector3 vtmp;
- vtmp.X = _target_velocity.X * timeStep;
- vtmp.Y = _target_velocity.Y * timeStep;
- // fake and avoid squares
- float k = (Math.Abs(vtmp.X) + Math.Abs(vtmp.Y));
- if (k > 0)
- {
- posch.X += vtmp.X;
- posch.Y += vtmp.Y;
- terrainheight -= _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
- k = 1 + Math.Abs(terrainheight) / k;
- movementdivisor /= k;
-
- if (k < 1)
- k = 1;
- }
- */
-
-
if (depth < 0.1f)
{
m_iscolliding = true;
@@ -901,6 +892,7 @@ namespace OpenSim.Region.Physics.OdePlugin
else
m_iscollidingGround = false;
+ //******************************************
// if velocity is zero, use position control; otherwise, velocity control
if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f
@@ -1012,97 +1004,31 @@ namespace OpenSim.Region.Physics.OdePlugin
// _parent_scene.RemoveCharacter(this);
// destroy avatar capsule and related ODE data
AvatarGeomAndBodyDestroy();
+ return;
}
+
+ // update our local ideia of position velocity and aceleration
+ _position = localpos;
+ _acceleration = _velocity; // previus velocity
+ _velocity = vel;
+ _acceleration = (vel - _acceleration) / timeStep;
+
}
///
- /// Updates the reported position and velocity. This essentially sends the data up to ScenePresence.
+ /// Updates the reported position and velocity.
+ /// Used to copy variables from unmanaged space at heartbeat rate and also trigger scene updates acording
+ /// also outbounds checking
+ /// copy and outbounds now done in move(..) at ode rate
+ ///
///
public void UpdatePositionAndVelocity()
{
- // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
- if (Body == IntPtr.Zero)
- return;
+ return;
- d.Vector3 vec;
- try
- {
- d.BodyCopyPosition(Body, out vec);
- }
- catch (NullReferenceException)
- {
- bad = true;
- _parent_scene.BadCharacter(this);
- vec = new d.Vector3(_position.X, _position.Y, _position.Z);
- base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
- m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid);
- }
-
- _position.X = vec.X;
- _position.Y = vec.Y;
- _position.Z = vec.Z;
-
- bool fixbody = false;
-
- if (_position.X < 0.0f)
- {
- fixbody = true;
- _position.X = 0.1f;
- }
- else if (_position.X > (int)_parent_scene.WorldExtents.X - 0.1f)
- {
- fixbody = true;
- _position.X = (int)_parent_scene.WorldExtents.X - 0.1f;
- }
-
- if (_position.Y < 0.0f)
- {
- fixbody = true;
- _position.Y = 0.1f;
- }
- else if (_position.Y > (int)_parent_scene.WorldExtents.Y - 0.1)
- {
- fixbody = true;
- _position.Y = (int)_parent_scene.WorldExtents.Y - 0.1f;
- }
+// if (Body == IntPtr.Zero)
+// return;
- if (fixbody)
- d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
-
- // Did we move last? = zeroflag
- // This helps keep us from sliding all over
-/*
- if (_zeroFlag)
- {
- _velocity.X = 0.0f;
- _velocity.Y = 0.0f;
- _velocity.Z = 0.0f;
-
- // Did we send out the 'stopped' message?
- if (!m_lastUpdateSent)
- {
- m_lastUpdateSent = true;
- base.RequestPhysicsterseUpdate();
- }
- }
- else
- {
- m_lastUpdateSent = false;
- */
- try
- {
- vec = d.BodyGetLinearVel(Body);
- }
- catch (NullReferenceException)
- {
- vec.X = _velocity.X;
- vec.Y = _velocity.Y;
- vec.Z = _velocity.Z;
- }
- _velocity.X = (vec.X);
- _velocity.Y = (vec.Y);
- _velocity.Z = (vec.Z);
- // }
}
///
--
cgit v1.1
From 7f420692958e05f9e2277911627b730c3066ae70 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 18 Apr 2012 03:02:28 +0100
Subject: ubitODE - retouch character PIDs
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b9ec6b5..b28bc4a 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -683,7 +683,7 @@ namespace OpenSim.Region.Physics.OdePlugin
PID_D *= m_mass / _parent_scene.ODE_STEPSIZE;
PID_P /= 50 * 80;
PID_P *= m_mass / _parent_scene.ODE_STEPSIZE;
-
+
Body = d.BodyCreate(_parent_scene.world);
d.BodySetAutoDisableFlag(Body, false);
@@ -862,10 +862,10 @@ namespace OpenSim.Region.Physics.OdePlugin
float depth = terrainheight - chrminZ;
if (!flying)
{
- vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 30;
+ vec.Z = -vel.Z * PID_D * 3f + depth * PID_P * 60;
}
else
- vec.Z = depth * PID_P * 30;
+ vec.Z = depth * PID_P * 60;
if (depth < 0.1f)
{
@@ -1171,7 +1171,7 @@ namespace OpenSim.Region.Physics.OdePlugin
CAPSULE_LENGTH = caplen;
AvatarGeomAndBodyCreation(_position.X, _position.Y,
- _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
+ _position.Z + (CAPSULE_LENGTH - prevCapsule) * 0.5f);
Velocity = Vector3.Zero;
--
cgit v1.1
From 08714a0d3826acee9f0e0bfa278efe97206dce18 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 18 Apr 2012 03:59:38 +0100
Subject: ubitODE still retouching character pid
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b28bc4a..ec4be58 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -862,12 +862,12 @@ namespace OpenSim.Region.Physics.OdePlugin
float depth = terrainheight - chrminZ;
if (!flying)
{
- vec.Z = -vel.Z * PID_D * 3f + depth * PID_P * 60;
+ vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 60;
}
else
vec.Z = depth * PID_P * 60;
- if (depth < 0.1f)
+ if (depth < 0.2f)
{
m_iscolliding = true;
m_colliderfilter = 2;
--
cgit v1.1
From ec6347f987cc1e42761ff9bd4832da4f999401f0 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 20 Apr 2012 03:17:36 +0100
Subject: ubitODE - again avatar/terrain collision. Reduce new viewers
interpolators efects reporting null velocity and aceleration when stopped
near the right position, where they can still have instantanius large values
that can get magnified by interpolators, specially using diferent timing
estimation.
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index ec4be58..f4aa231 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -862,12 +862,12 @@ namespace OpenSim.Region.Physics.OdePlugin
float depth = terrainheight - chrminZ;
if (!flying)
{
- vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 60;
+ vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 50;
}
else
- vec.Z = depth * PID_P * 60;
+ vec.Z = depth * PID_P * 50;
- if (depth < 0.2f)
+ if (depth < 0.1f)
{
m_iscolliding = true;
m_colliderfilter = 2;
@@ -1009,9 +1009,17 @@ namespace OpenSim.Region.Physics.OdePlugin
// update our local ideia of position velocity and aceleration
_position = localpos;
- _acceleration = _velocity; // previus velocity
- _velocity = vel;
- _acceleration = (vel - _acceleration) / timeStep;
+ if (_zeroFlag)
+ {
+ _velocity = Vector3.Zero;
+ _acceleration = Vector3.Zero;
+ }
+ else
+ {
+ _acceleration = _velocity; // previus velocity
+ _velocity = vel;
+ _acceleration = (vel - _acceleration) / timeStep;
+ }
}
--
cgit v1.1
From e0f81e24000df3a969cd313d008194d8226272ff Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 23 Apr 2012 01:47:11 +0100
Subject: ubitODE - several changes...
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 3 +++
1 file changed, 3 insertions(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index f4aa231..6ffcb9e 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -686,6 +686,9 @@ namespace OpenSim.Region.Physics.OdePlugin
Body = d.BodyCreate(_parent_scene.world);
+ _zeroFlag = false;
+ m_pidControllerActive = true;
+
d.BodySetAutoDisableFlag(Body, false);
d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
--
cgit v1.1
From a4b76a42cc995ab044798e38c418422dcdc0069a Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 24 Apr 2012 06:56:34 +0100
Subject: let objects/avas push avas
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 6ffcb9e..8b5b989 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -346,12 +346,11 @@ namespace OpenSim.Region.Physics.OdePlugin
m_iscollidingObj = true;
// m_iscollidingObj = value;
-/*
+
if (m_iscollidingObj)
m_pidControllerActive = false;
else
m_pidControllerActive = true;
- */
}
}
--
cgit v1.1
From a64a9e48de5226da055b0196125c8f576c462a80 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 01:43:27 +0100
Subject: TESTING
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 8b5b989..f22b0cc 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1210,6 +1210,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero)
d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
_position = newPos;
+ m_pidControllerActive = true;
}
private void changeOrientation(Quaternion newOri)
--
cgit v1.1
From 911bc81b00b276792cc43c3b246932186008d343 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 02:13:54 +0100
Subject: testing
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index f22b0cc..7356123 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1275,6 +1275,12 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity = newmomentum;
_target_velocity = newmomentum;
m_pidControllerActive = true;
+ m_colliderfilter = 0;
+ m_colliderObjectfilter = 0;
+ m_iscolliding = false;
+ m_iscollidingGround = false;
+ m_iscollidingObj = false;
+
if (Body != IntPtr.Zero)
d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
}
--
cgit v1.1
From 76d9040ed41facca73b8628f381dd8bdec3c9dc2 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 02:54:39 +0100
Subject: testing
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 7356123..4b093ba 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1273,7 +1273,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeMomentum(Vector3 newmomentum)
{
_velocity = newmomentum;
- _target_velocity = newmomentum;
+ _target_velocity = Vector3.Zero;
m_pidControllerActive = true;
m_colliderfilter = 0;
m_colliderObjectfilter = 0;
--
cgit v1.1
From d8f691664a8de15655eb7a3dd0485c21202982e2 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 03:36:49 +0100
Subject: testing
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 129 ++++++++++++---------
1 file changed, 71 insertions(+), 58 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 4b093ba..2c1197a 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -103,6 +103,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_buoyancy = 0f;
+ private bool m_freemove = false;
// private CollisionLocker ode;
private string m_name = String.Empty;
@@ -687,6 +688,7 @@ namespace OpenSim.Region.Physics.OdePlugin
_zeroFlag = false;
m_pidControllerActive = true;
+ m_freemove = false;
d.BodySetAutoDisableFlag(Body, false);
d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
@@ -789,7 +791,7 @@ namespace OpenSim.Region.Physics.OdePlugin
qtmp.Z = 0;
d.BodySetQuaternion(Body, ref qtmp);
- if (m_pidControllerActive == false)
+ if (m_pidControllerActive == false && !m_freemove)
{
_zeroPosition = localpos;
}
@@ -861,6 +863,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
if (chrminZ < terrainheight)
{
+ m_freemove = false;
float depth = terrainheight - chrminZ;
if (!flying)
{
@@ -896,77 +899,86 @@ namespace OpenSim.Region.Physics.OdePlugin
//******************************************
- // if velocity is zero, use position control; otherwise, velocity control
- if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f
- && m_iscolliding)
+ bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f);
+
+ if(!tviszero || !m_iscolliding)
+ m_freemove = false;
+
+ if (!m_freemove)
{
- // keep track of where we stopped. No more slippin' & slidin'
- if (!_zeroFlag)
- {
- _zeroFlag = true;
- _zeroPosition = localpos;
- }
- if (m_pidControllerActive)
+
+ // if velocity is zero, use position control; otherwise, velocity control
+ if (tviszero && m_iscolliding)
{
- // We only want to deactivate the PID Controller if we think we want to have our surrogate
- // react to the physics scene by moving it's position.
- // Avatar to Avatar collisions
- // Prim to avatar collisions
-
- vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 2);
- vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 2);
- if (flying)
+ // keep track of where we stopped. No more slippin' & slidin'
+ if (!_zeroFlag)
{
- vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
+ _zeroFlag = true;
+ _zeroPosition = localpos;
}
- }
- //PidStatus = true;
- }
- else
- {
- m_pidControllerActive = true;
- _zeroFlag = false;
-
- if (m_iscolliding)
- {
- if (!flying)
+ if (m_pidControllerActive)
{
- if (_target_velocity.Z > 0.0f)
+ // We only want to deactivate the PID Controller if we think we want to have our surrogate
+ // react to the physics scene by moving it's position.
+ // Avatar to Avatar collisions
+ // Prim to avatar collisions
+
+ vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 2);
+ vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 2);
+ if (flying)
{
- // We're colliding with something and we're not flying but we're moving
- // This means we're walking or running. JUMPING
- vec.Z += (_target_velocity.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P;
+ vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
}
- // We're standing on something
- vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D);
- vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D);
- }
- else
- {
- // We're flying and colliding with something
- vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 0.0625f);
- vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 0.0625f);
- vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
}
+ //PidStatus = true;
}
- else // ie not colliding
+ else
{
- if (flying) //(!m_iscolliding && flying)
+ m_freemove = false;
+ m_pidControllerActive = true;
+ _zeroFlag = false;
+
+ if (m_iscolliding)
{
- // we're in mid air suspended
- vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 1.667f);
- vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 1.667f);
- vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
+ if (!flying)
+ {
+ if (_target_velocity.Z > 0.0f)
+ {
+ // We're colliding with something and we're not flying but we're moving
+ // This means we're walking or running. JUMPING
+ vec.Z += (_target_velocity.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P;
+ }
+ // We're standing on something
+ vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D);
+ vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D);
+ }
+ else
+ {
+ // We're flying and colliding with something
+ vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 0.0625f);
+ vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 0.0625f);
+ vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
+ }
}
-
- else
+ else // ie not colliding
{
- // we're not colliding and we're not flying so that means we're falling!
- // m_iscolliding includes collisions with the ground.
+ if (flying) //(!m_iscolliding && flying)
+ {
+ // we're in mid air suspended
+ vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 1.667f);
+ vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 1.667f);
+ vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
+ }
- // d.Vector3 pos = d.BodyGetPosition(Body);
- vec.X = (_target_velocity.X - vel.X) * PID_D * 0.833f;
- vec.Y = (_target_velocity.Y - vel.Y) * PID_D * 0.833f;
+ else
+ {
+ // we're not colliding and we're not flying so that means we're falling!
+ // m_iscolliding includes collisions with the ground.
+
+ // d.Vector3 pos = d.BodyGetPosition(Body);
+ vec.X = (_target_velocity.X - vel.X) * PID_D * 0.833f;
+ vec.Y = (_target_velocity.Y - vel.Y) * PID_D * 0.833f;
+ }
}
}
}
@@ -1274,6 +1286,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
_velocity = newmomentum;
_target_velocity = Vector3.Zero;
+ m_freemove = true;
m_pidControllerActive = true;
m_colliderfilter = 0;
m_colliderObjectfilter = 0;
--
cgit v1.1
From e974d493c689a7fda925e72de78fddc05cfa5225 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 03:44:15 +0100
Subject: testing
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 2c1197a..1ba40b8 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -901,7 +901,7 @@ namespace OpenSim.Region.Physics.OdePlugin
bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f);
- if(!tviszero || !m_iscolliding)
+ if(!tviszero || m_iscolliding)
m_freemove = false;
if (!m_freemove)
--
cgit v1.1
From 03450dee39460f92d293621bb2fbcf93582397fc Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 08:11:18 +0100
Subject: testing....
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 119 ++++++++++++++-------
1 file changed, 78 insertions(+), 41 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 1ba40b8..d44c8e6 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private string m_name = String.Empty;
// other filter control
int m_colliderfilter = 0;
- // int m_colliderGroundfilter = 0;
+ int m_colliderGroundfilter = 0;
int m_colliderObjectfilter = 0;
// Default we're a Character
@@ -281,7 +281,6 @@ namespace OpenSim.Region.Physics.OdePlugin
m_iscolliding = false;
else
{
-// SetPidStatus(false);
m_pidControllerActive = true;
m_iscolliding = true;
}
@@ -617,7 +616,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (pushforce)
{
- AddChange(changes.Force, force * m_density / _parent_scene.ODE_STEPSIZE / 28f);
+ AddChange(changes.Force, force * m_density / (_parent_scene.ODE_STEPSIZE * 28f));
}
else
{
@@ -791,7 +790,7 @@ namespace OpenSim.Region.Physics.OdePlugin
qtmp.Z = 0;
d.BodySetQuaternion(Body, ref qtmp);
- if (m_pidControllerActive == false && !m_freemove)
+ if (m_pidControllerActive == false)
{
_zeroPosition = localpos;
}
@@ -830,11 +829,17 @@ namespace OpenSim.Region.Physics.OdePlugin
localpos.Y = _parent_scene.WorldExtents.Y - 0.1f;
}
if (fixbody)
+ {
+ m_freemove = false;
d.BodySetPosition(Body, localpos.X, localpos.Y, localpos.Z);
+ }
+
+ float breakfactor;
Vector3 vec = Vector3.Zero;
dtmp = d.BodyGetLinearVel(Body);
Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
+ float velLengthSquared = vel.LengthSquared();
float movementdivisor = 1f;
//Ubit change divisions into multiplications below
@@ -863,7 +868,6 @@ namespace OpenSim.Region.Physics.OdePlugin
float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
if (chrminZ < terrainheight)
{
- m_freemove = false;
float depth = terrainheight - chrminZ;
if (!flying)
{
@@ -874,34 +878,46 @@ namespace OpenSim.Region.Physics.OdePlugin
if (depth < 0.1f)
{
- m_iscolliding = true;
- m_colliderfilter = 2;
- m_iscollidingGround = true;
-
- ContactPoint contact = new ContactPoint();
- contact.PenetrationDepth = depth;
- contact.Position.X = localpos.X;
- contact.Position.Y = localpos.Y;
- contact.Position.Z = chrminZ;
- contact.SurfaceNormal.X = 0f;
- contact.SurfaceNormal.Y = 0f;
- contact.SurfaceNormal.Z = -1f;
- AddCollisionEvent(0, contact);
-
- vec.Z *= 0.5f;
+ m_colliderGroundfilter++;
+ if (m_colliderGroundfilter > 2)
+ {
+ m_iscolliding = true;
+ m_colliderfilter = 2;
+ m_colliderGroundfilter = 2;
+ m_iscollidingGround = true;
+
+ ContactPoint contact = new ContactPoint();
+ contact.PenetrationDepth = depth;
+ contact.Position.X = localpos.X;
+ contact.Position.Y = localpos.Y;
+ contact.Position.Z = chrminZ;
+ contact.SurfaceNormal.X = 0f;
+ contact.SurfaceNormal.Y = 0f;
+ contact.SurfaceNormal.Z = -1f;
+ AddCollisionEvent(0, contact);
+
+ vec.Z *= 0.5f;
+ }
}
else
+ {
+ m_colliderGroundfilter = 0;
m_iscollidingGround = false;
+ }
}
else
+ {
+ m_colliderGroundfilter = 0;
m_iscollidingGround = false;
+ }
//******************************************
bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f);
- if(!tviszero || m_iscolliding)
+ // if (!tviszero || m_iscolliding || velLengthSquared <0.01)
+ if (!tviszero)
m_freemove = false;
if (!m_freemove)
@@ -934,7 +950,6 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
- m_freemove = false;
m_pidControllerActive = true;
_zeroFlag = false;
@@ -981,6 +996,24 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
}
+
+ if (velLengthSquared > 2500.0f) // 50m/s apply breaks
+ {
+ breakfactor = 0.16f * m_mass;
+ vec.X -= breakfactor * vel.X;
+ vec.Y -= breakfactor * vel.Y;
+ vec.Z -= breakfactor * vel.Z;
+ }
+ }
+ else
+ {
+ breakfactor = 5f * m_mass;
+ vec.X -= breakfactor * vel.X;
+ vec.Y -= breakfactor * vel.Y;
+ if (flying)
+ vec.Z -= breakfactor * vel.Z;
+ else
+ vec.Z -= 2f* m_mass * vel.Z;
}
if (flying)
@@ -997,14 +1030,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// end add Kitto Flora
}
- if (vel.X * vel.X + vel.Y * vel.Y + vel.Z * vel.Z > 2500.0f) // 50m/s apply breaks
- {
- float breakfactor = 0.16f * m_mass; // will give aprox 60m/s terminal velocity at free fall
- vec.X -= breakfactor * vel.X;
- vec.Y -= breakfactor * vel.Y;
- vec.Z -= breakfactor * vel.Z;
- }
-
if (vec.IsFinite())
{
if (vec.X != 0 || vec.Y !=0 || vec.Z !=0)
@@ -1222,7 +1247,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero)
d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
_position = newPos;
- m_pidControllerActive = true;
+ m_pidControllerActive = false;
}
private void changeOrientation(Quaternion newOri)
@@ -1269,11 +1294,30 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeBuilding(bool arg)
{
- }
+ }
+
+ private void setFreeMove()
+ {
+ m_pidControllerActive = true;
+ _zeroFlag = false;
+ _target_velocity = Vector3.Zero;
+ m_freemove = true;
+ m_colliderfilter = -2;
+ m_colliderObjectfilter = -2;
+ m_colliderGroundfilter = -2;
+
+ m_iscolliding = false;
+ m_iscollidingGround = false;
+ m_iscollidingObj = false;
+
+ CollisionEventsThisFrame = new CollisionEventUpdate();
+ m_eventsubscription = 0;
+ }
private void changeForce(Vector3 newForce)
{
- m_pidControllerActive = false;
+ setFreeMove();
+
if (Body != IntPtr.Zero)
{
if (newForce.X != 0f || newForce.Y != 0f || newForce.Z != 0)
@@ -1285,14 +1329,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeMomentum(Vector3 newmomentum)
{
_velocity = newmomentum;
- _target_velocity = Vector3.Zero;
- m_freemove = true;
- m_pidControllerActive = true;
- m_colliderfilter = 0;
- m_colliderObjectfilter = 0;
- m_iscolliding = false;
- m_iscollidingGround = false;
- m_iscollidingObj = false;
+ setFreeMove();
if (Body != IntPtr.Zero)
d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
--
cgit v1.1
From 7a7f4b7722f50af874c62894e0fbff413a5a1851 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 09:00:30 +0100
Subject: testing
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index d44c8e6..342b7b3 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1247,7 +1247,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero)
d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
_position = newPos;
- m_pidControllerActive = false;
+ m_pidControllerActive = true;
}
private void changeOrientation(Quaternion newOri)
--
cgit v1.1
From 1c735faceeabc0e2888bdf9b1087a3fa7a9ae094 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 09:23:20 +0100
Subject: test
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 24 ++++++++++------------
1 file changed, 11 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 342b7b3..36440b1 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -379,24 +379,21 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return _position; }
set
{
- if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
+ if (value.IsFinite())
{
- if (value.IsFinite())
+ if (value.Z > 9999999f)
{
- if (value.Z > 9999999f)
- {
- value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
- }
- if (value.Z < -100f)
- {
- value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
- }
- AddChange(changes.Position, value);
+ value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
}
- else
+ if (value.Z < -100f)
{
- m_log.Warn("[PHYSICS]: Got a NaN Position from Scene on a Character");
+ value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
}
+ AddChange(changes.Position, value);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN Position from Scene on a Character");
}
}
}
@@ -1248,6 +1245,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
_position = newPos;
m_pidControllerActive = true;
+ m_log.DebugFormat("[ode character new position] {0}", newPos);
}
private void changeOrientation(Quaternion newOri)
--
cgit v1.1
From fedc9eb1056d02c7f99fb4f55a46fdafec02054a Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 09:50:53 +0100
Subject: itest
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 36440b1..26f8cf0 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1244,8 +1244,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero)
d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
_position = newPos;
- m_pidControllerActive = true;
- m_log.DebugFormat("[ode character new position] {0}", newPos);
+ m_pidControllerActive = true;
}
private void changeOrientation(Quaternion newOri)
--
cgit v1.1
From 8ef7df5a563a850fea6c1a6f22de55a09cecebe7 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 11:01:34 +0100
Subject: test
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 26f8cf0..4f8c4c3 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1004,13 +1004,13 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
- breakfactor = 5f * m_mass;
+ breakfactor = m_mass;
vec.X -= breakfactor * vel.X;
vec.Y -= breakfactor * vel.Y;
if (flying)
vec.Z -= breakfactor * vel.Z;
else
- vec.Z -= 2f* m_mass * vel.Z;
+ vec.Z -= .5f* m_mass * vel.Z;
}
if (flying)
--
cgit v1.1
From ee237fc5dfb42397c0f689b3c101c3be3ed9904c Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 27 Apr 2012 12:19:22 +0100
Subject: test
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 4f8c4c3..326fe97 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -880,7 +880,13 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_iscolliding = true;
m_colliderfilter = 2;
- m_colliderGroundfilter = 2;
+
+ if (m_colliderGroundfilter > 10)
+ {
+ m_colliderGroundfilter = 10;
+ m_freemove = false;
+ }
+
m_iscollidingGround = true;
ContactPoint contact = new ContactPoint();
--
cgit v1.1
From 6b3135aa4dcdcd469054ed0af5eba3b30ae5cd3c Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 4 May 2012 22:24:04 +0100
Subject: UbitODE: leave avatar 'freemove' state (entered on setmomentum) on
any significant change like new 'velocity' or new position, etc, requests
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 326fe97..672b9e0 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1184,7 +1184,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// destroy avatar capsule and related ODE data
AvatarGeomAndBodyDestroy();
}
-
+ m_freemove = false;
m_isPhysical = NewStatus;
}
}
@@ -1236,7 +1236,7 @@ namespace OpenSim.Region.Physics.OdePlugin
+ (Amotor == IntPtr.Zero ? "Amotor " : ""));
}
}
-
+ m_freemove = false;
m_pidControllerActive = true;
}
else
@@ -1250,6 +1250,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero)
d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
_position = newPos;
+ m_freemove = false;
m_pidControllerActive = true;
}
@@ -1260,6 +1261,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeVelocity(Vector3 newVel)
{
m_pidControllerActive = true;
+ m_freemove = false;
_target_velocity = newVel;
}
--
cgit v1.1
From 163a86517ada9ae7f9f1c161192682e02e287e45 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 5 May 2012 03:28:35 +0100
Subject: force lower avatar density for testing
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 672b9e0..b884b62 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -168,6 +168,10 @@ namespace OpenSim.Region.Physics.OdePlugin
m_density = density;
m_mass = 80f; // sure we have a default
+ // force lower density for testing
+ m_density = 3.0f;
+
+
mu = parent_scene.AvatarFriction;
walkDivisor = walk_divisor;
--
cgit v1.1
From 3c37bc2851eb1c8c1ebd164dbf43fbeea427c2b8 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Thu, 10 May 2012 22:44:12 +0100
Subject: reduce avatars terminal velocity to less than 30m/s or colisions with
basic boxs fail badly. (ode lib problem. chode just may support a bit higher
velocity due to the use of tilt).
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b884b62..43b4581 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -734,9 +734,9 @@ namespace OpenSim.Region.Physics.OdePlugin
d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel2, 0);
d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel3, 0);
- d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 5e6f);
- d.JointSetAMotorParam(Amotor, (int)dParam.FMax2, 5e6f);
- d.JointSetAMotorParam(Amotor, (int)dParam.FMax3, 5e6f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax, 5e8f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax2, 5e8f);
+ d.JointSetAMotorParam(Amotor, (int)dParam.FMax3, 5e8f);
}
///
@@ -784,6 +784,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// the Amotor still lets avatar rotation to drift during colisions
// so force it back to identity
+
+
d.Quaternion qtmp;
qtmp.W = 1;
qtmp.X = 0;
@@ -1004,9 +1006,9 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
- if (velLengthSquared > 2500.0f) // 50m/s apply breaks
+ if (velLengthSquared > 625.0f) // 25m/s apply breaks
{
- breakfactor = 0.16f * m_mass;
+ breakfactor = 0.31f * m_mass;
vec.X -= breakfactor * vel.X;
vec.Y -= breakfactor * vel.Y;
vec.Z -= breakfactor * vel.Z;
--
cgit v1.1
From 8dd5f08b6e7d68663307b4346d19ceef711c8425 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 11 May 2012 15:53:31 +0100
Subject: revert terminal vel reduction. It helped but not efective
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 43b4581..b0711d7 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1006,9 +1006,9 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
- if (velLengthSquared > 625.0f) // 25m/s apply breaks
+ if (velLengthSquared > 2500.0f) // 50m/s apply breaks
{
- breakfactor = 0.31f * m_mass;
+ breakfactor = 0.16f * m_mass;
vec.X -= breakfactor * vel.X;
vec.Y -= breakfactor * vel.Y;
vec.Z -= breakfactor * vel.Z;
--
cgit v1.1
From a7ece8c688a44c0d0b05162dbb1e98a1ea4e95ff Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 19 May 2012 00:17:37 +0100
Subject: add colliders relative velocity projected in collision direction to
collisions report information.
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b0711d7..bfff3d4 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -903,6 +903,7 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.SurfaceNormal.X = 0f;
contact.SurfaceNormal.Y = 0f;
contact.SurfaceNormal.Z = -1f;
+ contact.RelativeSpeed = -vel.Z;
AddCollisionEvent(0, contact);
vec.Z *= 0.5f;
--
cgit v1.1
From deb87e78907fae00301c9c3428da2f41e1f588b3 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 19 May 2012 01:01:46 +0100
Subject: fix character IsPhysical
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index bfff3d4..b36b933 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -239,7 +239,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool IsPhysical
{
- get { return false; }
+ get { return m_isPhysical; }
set { return; }
}
--
cgit v1.1
From 10889c86d9d67ca994a090166ad53840ed1dedd0 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 19 May 2012 16:35:48 +0100
Subject: reduce useless waste of cpu. Make character collision events be done
similiar to parts. Let same thread do it all ( like in parts ) ( to change
this some structs copies must be added)
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 79 +++++++++++++---------
1 file changed, 48 insertions(+), 31 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b36b933..ca294b8 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -128,9 +128,10 @@ namespace OpenSim.Region.Physics.OdePlugin
public d.Mass ShellMass;
// public bool collidelock = false;
- private bool m_haseventsubscription = false;
public int m_eventsubscription = 0;
- private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
+ private int m_cureventsubscription = 0;
+ private CollisionEventUpdate CollisionEventsThisFrame = null;
+ private bool SentEmptyCollisionsEvent;
// unique UUID of this character object
public UUID m_uuid;
@@ -1120,47 +1121,72 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void SubscribeEvents(int ms)
{
- m_requestedUpdateFrequency = ms;
m_eventsubscription = ms;
- _parent_scene.AddCollisionEventReporting(this);
- m_haseventsubscription = true;
+ m_cureventsubscription = 0;
+ if (CollisionEventsThisFrame == null)
+ CollisionEventsThisFrame = new CollisionEventUpdate();
+ SentEmptyCollisionsEvent = false;
}
public override void UnSubscribeEvents()
{
- m_haseventsubscription = false;
- _parent_scene.RemoveCollisionEventReporting(this);
- m_requestedUpdateFrequency = 0;
+ if (CollisionEventsThisFrame != null)
+ {
+ CollisionEventsThisFrame.Clear();
+ CollisionEventsThisFrame = null;
+ }
m_eventsubscription = 0;
}
public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
{
- if (m_haseventsubscription)
- {
- // m_log.DebugFormat(
- // "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact);
-
- CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
- }
+ if (CollisionEventsThisFrame == null)
+ CollisionEventsThisFrame = new CollisionEventUpdate();
+ CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
}
public void SendCollisions()
{
- if (m_haseventsubscription && m_eventsubscription > m_requestedUpdateFrequency)
+ if (CollisionEventsThisFrame == null)
+ return;
+
+ if (m_cureventsubscription < m_eventsubscription)
+ return;
+
+ m_cureventsubscription = 0;
+
+ int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
+
+ if (!SentEmptyCollisionsEvent || ncolisions > 0)
{
- if (CollisionEventsThisFrame != null)
+ base.SendCollisionUpdate(CollisionEventsThisFrame);
+
+ if (ncolisions == 0)
{
- base.SendCollisionUpdate(CollisionEventsThisFrame);
+ SentEmptyCollisionsEvent = true;
+ _parent_scene.RemoveCollisionEventReporting(this);
}
- CollisionEventsThisFrame = new CollisionEventUpdate();
- m_eventsubscription = 0;
- }
+ else
+ {
+ SentEmptyCollisionsEvent = false;
+ CollisionEventsThisFrame.Clear();
+ }
+ }
+ }
+
+ internal void AddCollisionFrameTime(int t)
+ {
+ // protect it from overflow crashing
+ if (m_cureventsubscription + t >= int.MaxValue)
+ m_cureventsubscription = 0;
+ m_cureventsubscription += t;
}
public override bool SubscribedEvents()
{
- return m_haseventsubscription;
+ if (m_eventsubscription > 0)
+ return true;
+ return false;
}
private void changePhysicsStatus(bool NewStatus)
@@ -1466,14 +1492,5 @@ namespace OpenSim.Region.Physics.OdePlugin
{
_parent_scene.AddChange((PhysicsActor)this, what, arg);
}
-
-
- internal void AddCollisionFrameTime(int p)
- {
- // protect it from overflow crashing
- if (m_eventsubscription + p >= int.MaxValue)
- m_eventsubscription = 0;
- m_eventsubscription += p;
- }
}
}
--
cgit v1.1
From 11f582b26da987afe4c9ad76c6ce35b58a8bc6fd Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 20 May 2012 13:18:15 +0100
Subject: minor changes
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index ca294b8..1084b0e 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -784,8 +784,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// the Amotor still lets avatar rotation to drift during colisions
// so force it back to identity
-
-
d.Quaternion qtmp;
qtmp.W = 1;
@@ -1177,9 +1175,8 @@ namespace OpenSim.Region.Physics.OdePlugin
internal void AddCollisionFrameTime(int t)
{
// protect it from overflow crashing
- if (m_cureventsubscription + t >= int.MaxValue)
- m_cureventsubscription = 0;
- m_cureventsubscription += t;
+ if (m_cureventsubscription < 50000)
+ m_cureventsubscription += t;
}
public override bool SubscribedEvents()
--
cgit v1.1
From f740c9522aa5fd57ffd2d01fa9c2e244113ac880 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 27 May 2012 14:01:42 +0100
Subject: Let OOB information usable outside ubitode
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 23 ----------------------
1 file changed, 23 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 1084b0e..6fb54cb 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -522,29 +522,6 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
- //UBit mess
- /* for later use
- public override Vector3 PrimOOBsize
- {
- get
- {
- Vector3 s=Size;
- s.X *=0.5f;
- s.Y *=0.5f;
- s.Z *=0.5f;
- return s;
- }
- }
-
- public override Vector3 PrimOOBoffset
- {
- get
- {
- return Vector3.Zero;
- }
- }
- */
-
public override PrimitiveBaseShape Shape
{
set { return; }
--
cgit v1.1
From dbbfe0cdd78c919b39da52e1ccc0c1fc500b57d5 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 28 May 2012 22:23:32 +0100
Subject: fix avatars collisions on sim crossings and other few cases where
freemove() is called
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 6fb54cb..093bc3c 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1322,8 +1322,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_iscollidingGround = false;
m_iscollidingObj = false;
- CollisionEventsThisFrame = new CollisionEventUpdate();
- m_eventsubscription = 0;
+ CollisionEventsThisFrame.Clear();
}
private void changeForce(Vector3 newForce)
--
cgit v1.1
From 3e9a831e87432d971a6006966e35924df1ed855d Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 29 May 2012 19:13:27 +0100
Subject: fix physics not reporting collisions only with terrain
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 1 +
1 file changed, 1 insertion(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 093bc3c..6e4e41f 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1118,6 +1118,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
+ _parent_scene.AddCollisionEventReporting(this);
}
public void SendCollisions()
--
cgit v1.1
From 84ab4c44628441b32ec7ef0c728d035b5cf40b39 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 11 Jul 2012 08:13:57 +0100
Subject: ubitODE leaks
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 2 ++
1 file changed, 2 insertions(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 6e4e41f..865180f 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -740,6 +740,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Shell != IntPtr.Zero)
{
_parent_scene.geom_name_map.Remove(Shell);
+ _parent_scene.actor_name_map.Remove(Shell);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
d.GeomDestroy(Shell);
Shell = IntPtr.Zero;
@@ -1188,6 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
+ _parent_scene.RemoveCollisionEventReporting(this);
_parent_scene.RemoveCharacter(this);
// destroy avatar capsule and related ODE data
AvatarGeomAndBodyDestroy();
--
cgit v1.1
From 72e2b9409462861d183ac7b391f5911defcd3bb0 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 13 Jul 2012 23:57:45 +0100
Subject: In collisions report linksets root parts to parts, and not all parts.
Temporary suspend collision checks on full stopped bodies, until a better
away is found wake them, avoiding spurius collision end and start events.
Until a nice way is found to avoid them, this may cause some higher cpu load.
plus some clean up
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 865180f..b506b1c 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -95,7 +95,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_iscollidingObj = false;
private bool m_alwaysRun = false;
private int m_requestedUpdateFrequency = 0;
- public uint m_localID = 0;
+ private uint m_localID = 0;
public bool m_returnCollisions = false;
// taints and their non-tainted counterparts
public bool m_isPhysical = false; // the current physical status
@@ -214,6 +214,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override uint LocalID
{
+ get { return m_localID; }
set { m_localID = value; }
}
--
cgit v1.1
From 62df82b74d0f3599585f7320aeab8c6a8262f61f Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 15 Jul 2012 00:50:00 +0100
Subject: messing around... Let terrain and water have nullphysicsactors, let
nullphyscisactors have a type water, ground or unknown (default). having this
removed geom to name mapping no longer needed. Made some more methods comum
to prims and characters acessible via PhysActor allowing for a more uniform
access. ...
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b506b1c..c363310 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_freemove = false;
// private CollisionLocker ode;
- private string m_name = String.Empty;
+// private string m_name = String.Empty;
// other filter control
int m_colliderfilter = 0;
int m_colliderGroundfilter = 0;
@@ -183,7 +183,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_isPhysical = false; // current status: no ODE information exists
- m_name = avName;
+ Name = avName;
AddChange(changes.Add, null);
}
@@ -218,6 +218,11 @@ namespace OpenSim.Region.Physics.OdePlugin
set { m_localID = value; }
}
+ public override PhysicsActor ParentActor
+ {
+ get { return (PhysicsActor)this; }
+ }
+
public override bool Grabbed
{
set { return; }
@@ -740,7 +745,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//kill the Geometry
if (Shell != IntPtr.Zero)
{
- _parent_scene.geom_name_map.Remove(Shell);
+// _parent_scene.geom_name_map.Remove(Shell);
_parent_scene.actor_name_map.Remove(Shell);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
d.GeomDestroy(Shell);
@@ -1115,7 +1120,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_eventsubscription = 0;
}
- public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
+ public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
{
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
@@ -1184,7 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
- _parent_scene.geom_name_map[Shell] = m_name;
+
_parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
_parent_scene.AddCharacter(this);
}
@@ -1236,7 +1241,6 @@ namespace OpenSim.Region.Physics.OdePlugin
Velocity = Vector3.Zero;
- _parent_scene.geom_name_map[Shell] = m_name;
_parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
}
else
--
cgit v1.1
From 78ce7a0a04dc5ce3212acfb0e88a3a5a1b876100 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 7 Oct 2012 01:20:52 +0100
Subject: [DANGER UNTESTED] ODE mesh assets. Other plugins will not do
meshs/sculpts now
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 1 -
1 file changed, 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index c363310..f5bf05d 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -172,7 +172,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// force lower density for testing
m_density = 3.0f;
-
mu = parent_scene.AvatarFriction;
walkDivisor = walk_divisor;
--
cgit v1.1
From c50fda8bf56b1935805164e6803ab82532ea5418 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 1 Dec 2012 22:58:52 +0000
Subject: adjust avatar standing Z position
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index f5bf05d..94ed663 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -85,8 +85,12 @@ namespace OpenSim.Region.Physics.OdePlugin
public float PID_D = 800.0f;
public float PID_P = 900.0f;
//private static float POSTURE_SERVO = 10000.0f;
+
public float CAPSULE_RADIUS = 0.37f;
public float CAPSULE_LENGTH = 2.140599f;
+
+ const float CAP_OFFSET = -.2f; // compensation of SL size offset plus spheric collision shape bottom
+
public float walkDivisor = 1.3f;
public float runDivisor = 0.8f;
private bool flying = false;
@@ -139,6 +143,8 @@ namespace OpenSim.Region.Physics.OdePlugin
float mu;
+
+
public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor)
{
m_uuid = UUID.Random();
@@ -177,7 +183,7 @@ namespace OpenSim.Region.Physics.OdePlugin
walkDivisor = walk_divisor;
runDivisor = rundivisor;
- CAPSULE_LENGTH = size.Z * 1.15f - CAPSULE_RADIUS * 2.0f;
+ CAPSULE_LENGTH = size.Z - CAPSULE_RADIUS + CAP_OFFSET;
//m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
m_isPhysical = false; // current status: no ODE information exists
@@ -422,7 +428,8 @@ namespace OpenSim.Region.Physics.OdePlugin
{
get {
float d = CAPSULE_RADIUS * 2;
- return new Vector3(d, d, (CAPSULE_LENGTH +d)/1.15f); }
+ return new Vector3(d, d, (CAPSULE_LENGTH + CAPSULE_RADIUS - CAP_OFFSET));
+ }
set
{
if (value.IsFinite())
@@ -837,8 +844,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// colide with land
d.AABB aabb;
d.GeomGetAABB(Shell, out aabb);
- float chrminZ = aabb.MinZ;
-
+ float chrminZ = aabb.MinZ - 0.04f; // move up a bit
Vector3 posch = localpos;
float ftmp;
@@ -1224,7 +1230,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
float caplen = Size.Z;
- caplen = caplen * 1.15f - CAPSULE_RADIUS * 2.0f;
+ caplen = caplen - CAPSULE_RADIUS + CAP_OFFSET;
if (caplen != CAPSULE_LENGTH)
{
--
cgit v1.1
From 8aa5fdb6a3f1e4b349757df5d9fcc06ab8dfdb64 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 3 Dec 2012 17:05:05 +0000
Subject: *TEST* diferent avatar collider
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 369 ++++++++++++++++-----
1 file changed, 288 insertions(+), 81 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 94ed663..3d5be3e 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -79,6 +79,8 @@ namespace OpenSim.Region.Physics.OdePlugin
private Vector3 _target_velocity;
private Vector3 _acceleration;
private Vector3 m_rotationalVelocity;
+ private Vector3 m_size;
+ private Quaternion m_orientation;
private float m_mass = 80f;
public float m_density = 60f;
private bool m_pidControllerActive = true;
@@ -86,10 +88,17 @@ namespace OpenSim.Region.Physics.OdePlugin
public float PID_P = 900.0f;
//private static float POSTURE_SERVO = 10000.0f;
- public float CAPSULE_RADIUS = 0.37f;
- public float CAPSULE_LENGTH = 2.140599f;
- const float CAP_OFFSET = -.2f; // compensation of SL size offset plus spheric collision shape bottom
+ private float m_invElipSizeX;
+ private float m_invElipSizeY;
+
+ private float feetOff = 0;
+ private float feetSZ = 0.5f;
+ const float feetScale = 0.9f;
+ const float invFeetScale = 1.0f / 0.9f;
+ const float sizeZAdjust = 0.15f;
+ private float boneOff = 0;
+
public float walkDivisor = 1.3f;
public float runDivisor = 0.8f;
@@ -127,10 +136,16 @@ namespace OpenSim.Region.Physics.OdePlugin
// we do land collisions not ode | CollisionCategories.Land);
public IntPtr Body = IntPtr.Zero;
private OdeScene _parent_scene;
- public IntPtr Shell = IntPtr.Zero;
+ public IntPtr topbox = IntPtr.Zero;
+ public IntPtr midbox = IntPtr.Zero;
+ public IntPtr feetbox = IntPtr.Zero;
+ public IntPtr bonebox = IntPtr.Zero;
+
public IntPtr Amotor = IntPtr.Zero;
+
public d.Mass ShellMass;
-// public bool collidelock = false;
+
+
public int m_eventsubscription = 0;
private int m_cureventsubscription = 0;
@@ -145,7 +160,7 @@ namespace OpenSim.Region.Physics.OdePlugin
- public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor)
+ public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pid_d, float pid_p, float density, float walk_divisor, float rundivisor)
{
m_uuid = UUID.Random();
@@ -171,9 +186,20 @@ namespace OpenSim.Region.Physics.OdePlugin
PID_D = pid_d;
PID_P = pid_p;
- CAPSULE_RADIUS = capsule_radius;
+
+ m_size.X = pSize.X;
+ m_size.Y = pSize.Y;
+ m_size.Z = pSize.Z;
+
+ if(m_size.X <0.01f)
+ m_size.X = 0.01f;
+ if(m_size.Y <0.01f)
+ m_size.Y = 0.01f;
+ if(m_size.Z <0.01f)
+ m_size.Z = 0.01f;
+
+ m_orientation = Quaternion.Identity;
m_density = density;
- m_mass = 80f; // sure we have a default
// force lower density for testing
m_density = 3.0f;
@@ -183,8 +209,7 @@ namespace OpenSim.Region.Physics.OdePlugin
walkDivisor = walk_divisor;
runDivisor = rundivisor;
- CAPSULE_LENGTH = size.Z - CAPSULE_RADIUS + CAP_OFFSET;
- //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
+ m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default
m_isPhysical = false; // current status: no ODE information exists
@@ -426,14 +451,21 @@ namespace OpenSim.Region.Physics.OdePlugin
///
public override Vector3 Size
{
- get {
- float d = CAPSULE_RADIUS * 2;
- return new Vector3(d, d, (CAPSULE_LENGTH + CAPSULE_RADIUS - CAP_OFFSET));
+ get
+ {
+ return m_size;
}
set
{
if (value.IsFinite())
{
+ if(value.X <0.01f)
+ value.X = 0.01f;
+ if(value.Y <0.01f)
+ value.Y = 0.01f;
+ if(value.Z <0.01f)
+ value.Z = 0.01f;
+
AddChange(changes.Size, value);
}
else
@@ -459,8 +491,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
get
{
- float AVvolume = (float)(Math.PI * CAPSULE_RADIUS * CAPSULE_RADIUS * (1.3333333333f * CAPSULE_RADIUS + CAPSULE_LENGTH));
- return m_density * AVvolume;
+ return m_density * m_size.X * m_size.Y * m_size.Z;
}
}
public override void link(PhysicsActor obj)
@@ -578,9 +609,14 @@ namespace OpenSim.Region.Physics.OdePlugin
public override Quaternion Orientation
{
- get { return Quaternion.Identity; }
+ get { return m_orientation; }
set
{
+ // fakeori = value;
+ // givefakeori++;
+
+ value.Normalize();
+ AddChange(changes.Orientation, value);
}
}
@@ -632,32 +668,65 @@ namespace OpenSim.Region.Physics.OdePlugin
AddChange(changes.Momentum, momentum);
}
-
- // WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
- // to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
- // place that is safe to call this routine AvatarGeomAndBodyCreation.
private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
{
+ // sizes one day should came from visual parameters
+ float sz = m_size.Z + sizeZAdjust;
+
+ m_invElipSizeX = 1.0f / m_size.X;
+ m_invElipSizeY = 1.0f / m_size.Y;
+
+ float topsx = m_size.X;
+ float midsx = m_size.X;
+ float feetsx = m_size.X * feetScale;
+ float bonesx = feetsx * 0.2f;
+
+ float topsy = m_size.Y * 0.5f;
+ float midsy = m_size.Y;
+ float feetsy = m_size.Y * feetScale;
+ float bonesy = feetsy * 0.2f;
+
+ float topsz = sz * 0.15f;
+ float feetsz = sz * 0.3f;
+ if (feetsz > 0.6f)
+ feetsz = 0.6f;
+
+ float midsz = sz - topsz - feetsz;
+ float bonesz = sz;
+
+ float bot = -sz * 0.5f;
+
+ boneOff = bot + 0.3f;
+
+ float feetz = bot + feetsz * 0.5f;
+ bot += feetsz;
+
+ feetOff = bot;
+ feetSZ = feetsz;
+
+ float midz = bot + midsz * 0.5f;
+ bot += midsz;
+ float topz = bot + topsz * 0.5f;
+
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
- if (CAPSULE_LENGTH <= 0)
- {
- m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
- CAPSULE_LENGTH = 0.01f;
- }
+ feetbox = d.CreateBox(_parent_scene.ActiveSpace, feetsx, feetsy, feetsz);
+ d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
- if (CAPSULE_RADIUS <= 0)
- {
- m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
- CAPSULE_RADIUS = 0.01f;
+ midbox = d.CreateBox(_parent_scene.ActiveSpace, midsx, midsy, midsz);
+ d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
- }
- Shell = d.CreateCapsule(_parent_scene.ActiveSpace, CAPSULE_RADIUS, CAPSULE_LENGTH);
+ topbox = d.CreateBox(_parent_scene.ActiveSpace, topsx, topsy, topsz);
+ d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
- d.GeomSetCategoryBits(Shell, (uint)m_collisionCategories);
- d.GeomSetCollideBits(Shell, (uint)m_collisionFlags);
+ bonebox = d.CreateBox(_parent_scene.ActiveSpace, bonesx, bonesy, bonesz);
+ d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags);
- d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH);
+ d.MassSetBox(out ShellMass, m_density, m_size.X , m_size.Y, m_size.Z);
m_mass = ShellMass.mass; // update mass
@@ -688,7 +757,14 @@ namespace OpenSim.Region.Physics.OdePlugin
_position.Z = npositionZ;
d.BodySetMass(Body, ref ShellMass);
- d.GeomSetBody(Shell, Body);
+ d.GeomSetBody(feetbox, Body);
+ d.GeomSetBody(midbox, Body);
+ d.GeomSetBody(topbox, Body);
+ d.GeomSetBody(bonebox, Body);
+
+ d.GeomSetOffsetPosition(feetbox, 0, 0, feetz);
+ d.GeomSetOffsetPosition(midbox, 0, 0, midz);
+ d.GeomSetOffsetPosition(topbox, 0, 0, topz);
// The purpose of the AMotor here is to keep the avatar's physical
// surrogate from rotating while moving
@@ -748,15 +824,152 @@ namespace OpenSim.Region.Physics.OdePlugin
Body = IntPtr.Zero;
}
- //kill the Geometry
- if (Shell != IntPtr.Zero)
+ //kill the Geoms
+ if (topbox != IntPtr.Zero)
{
-// _parent_scene.geom_name_map.Remove(Shell);
- _parent_scene.actor_name_map.Remove(Shell);
+ _parent_scene.actor_name_map.Remove(topbox);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
- d.GeomDestroy(Shell);
- Shell = IntPtr.Zero;
+ d.GeomDestroy(topbox);
+ topbox = IntPtr.Zero;
+ }
+ if (midbox != IntPtr.Zero)
+ {
+ _parent_scene.actor_name_map.Remove(midbox);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ d.GeomDestroy(midbox);
+ midbox = IntPtr.Zero;
+ }
+ if (feetbox != IntPtr.Zero)
+ {
+ _parent_scene.actor_name_map.Remove(feetbox);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ d.GeomDestroy(feetbox);
+ feetbox = IntPtr.Zero;
+ }
+
+ if (bonebox != IntPtr.Zero)
+ {
+ _parent_scene.actor_name_map.Remove(bonebox);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ d.GeomDestroy(bonebox);
+ bonebox = IntPtr.Zero;
+ }
+
+ }
+
+ public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact)
+ {
+
+ if (me == bonebox) // inner bone
+ {
+ if (contact.pos.Z - _position.Z < boneOff)
+ IsColliding = true;
+ return true;
+ }
+
+ if (me == topbox) // keep a box head
+ return true;
+
+ // rotate elipsoide assuming only rotation around Z
+ float ca = m_orientation.W * m_orientation.W - m_orientation.Z * m_orientation.Z;
+ float sa = 2 * m_orientation.W * m_orientation.Z;
+
+ float isx;
+ float isy;
+
+ if (me == feetbox) // feet have narrow bounds
+ {
+
+ isx = m_invElipSizeX * invFeetScale;
+ isy = m_invElipSizeY * invFeetScale;
+ }
+ else
+ {
+ isx = m_invElipSizeX;
+ isy = m_invElipSizeY;
+ }
+
+ float a = isx * ca - isy * sa;
+ float b = isx * sa + isy * ca;
+
+ float offx = contact.pos.X - _position.X;
+ float er = offx * a;
+ er *= er;
+
+ float offy = contact.pos.Y - _position.Y;
+ float ty = offy * b;
+ er += ty * ty;
+
+ if (me == midbox)
+ {
+ if (er > 4.0f) // no collision
+ return false;
+ if (er < 0.2f)
+ return true;
+
+ float t = offx * offx + offy * offy;
+ t = (float)Math.Sqrt(t);
+ t = 1 / t;
+ offx *= t;
+ offy *= t;
+
+ if (reverse)
+ {
+ contact.normal.X = offx;
+ contact.normal.Y = offy;
+ }
+ else
+ {
+ contact.normal.X = -offx;
+ contact.normal.Y = -offy;
+ }
+
+ contact.normal.Z = 0;
+ return true;
+ }
+
+ else if (me == feetbox)
+ {
+ float c = feetSZ * 2;
+ float h = contact.pos.Z - _position.Z;
+ float offz = h - feetOff; // distance from top of feetbox
+
+ float tz = offz / c;
+ er += tz * tz;
+
+ if (er > 4.0f) // no collision
+ return false;
+
+ if (er > 0.2f)
+ {
+ float t = offx * offx + offy * offy + offz * offz;
+ t = (float)Math.Sqrt(t);
+ t = 1 / t;
+ offx *= t;
+ offy *= t;
+ offz *= t;
+
+ if (reverse)
+ {
+ contact.normal.X = offx;
+ contact.normal.Y = offy;
+ contact.normal.Z = offz;
+ }
+ else
+ {
+ contact.normal.X = -offx;
+ contact.normal.Y = -offy;
+ contact.normal.Z = -offz;
+ }
+ }
+
+ if(h < boneOff)
+ IsColliding = true;
}
+ else
+ return false;
+
+ return true;
}
///
@@ -776,10 +989,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// so force it back to identity
d.Quaternion qtmp;
- qtmp.W = 1;
- qtmp.X = 0;
- qtmp.Y = 0;
- qtmp.Z = 0;
+ qtmp.W = m_orientation.W;
+ qtmp.X = m_orientation.X;
+ qtmp.Y = m_orientation.Y;
+ qtmp.Z = m_orientation.Z;
d.BodySetQuaternion(Body, ref qtmp);
if (m_pidControllerActive == false)
@@ -843,7 +1056,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//******************************************
// colide with land
d.AABB aabb;
- d.GeomGetAABB(Shell, out aabb);
+ d.GeomGetAABB(feetbox, out aabb);
float chrminZ = aabb.MinZ - 0.04f; // move up a bit
Vector3 posch = localpos;
@@ -1182,20 +1395,14 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (NewStatus)
{
- // Create avatar capsule and related ODE data
- if ((Shell != IntPtr.Zero))
- {
- // a lost shell ?
- m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - "
- + (Shell != IntPtr.Zero ? "Shell " : "")
- + (Body != IntPtr.Zero ? "Body " : "")
- + (Amotor != IntPtr.Zero ? "Amotor " : ""));
- AvatarGeomAndBodyDestroy();
- }
+ AvatarGeomAndBodyDestroy();
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
- _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[bonebox] = (PhysicsActor)this;
_parent_scene.AddCharacter(this);
}
else
@@ -1224,37 +1431,29 @@ namespace OpenSim.Region.Physics.OdePlugin
{
}
- private void changeSize(Vector3 Size)
+ private void changeSize(Vector3 pSize)
{
- if (Size.IsFinite())
+ if (pSize.IsFinite())
{
- float caplen = Size.Z;
+ // for now only look to Z changes since viewers also don't change X and Y
+ if (pSize.Z != m_size.Z)
+ {
+ AvatarGeomAndBodyDestroy();
- caplen = caplen - CAPSULE_RADIUS + CAP_OFFSET;
- if (caplen != CAPSULE_LENGTH)
- {
- if (Shell != IntPtr.Zero && Body != IntPtr.Zero && Amotor != IntPtr.Zero)
- {
- AvatarGeomAndBodyDestroy();
+ float oldsz = m_size.Z;
+ m_size = pSize;
- float prevCapsule = CAPSULE_LENGTH;
- CAPSULE_LENGTH = caplen;
- AvatarGeomAndBodyCreation(_position.X, _position.Y,
- _position.Z + (CAPSULE_LENGTH - prevCapsule) * 0.5f);
+ AvatarGeomAndBodyCreation(_position.X, _position.Y,
+ _position.Z + (m_size.Z - oldsz) * 0.5f);
- Velocity = Vector3.Zero;
+ Velocity = Vector3.Zero;
- _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
- }
- else
- {
- m_log.Warn("[PHYSICS]: trying to change capsule size, but the following ODE data is missing - "
- + (Shell == IntPtr.Zero ? "Shell " : "")
- + (Body == IntPtr.Zero ? "Body " : "")
- + (Amotor == IntPtr.Zero ? "Amotor " : ""));
- }
+ _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[bonebox] = (PhysicsActor)this;
}
m_freemove = false;
m_pidControllerActive = true;
@@ -1276,6 +1475,14 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeOrientation(Quaternion newOri)
{
+ d.Quaternion myrot = new d.Quaternion();
+ myrot.X = newOri.X;
+ myrot.Y = newOri.Y;
+ myrot.Z = newOri.Z;
+ myrot.W = newOri.W;
+ float t = d.JointGetAMotorAngle(Amotor, 2);
+ d.BodySetQuaternion(Body,ref myrot);
+ m_orientation = newOri;
}
private void changeVelocity(Vector3 newVel)
@@ -1365,7 +1572,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public bool DoAChange(changes what, object arg)
{
- if (Shell == IntPtr.Zero && what != changes.Add && what != changes.Remove)
+ if (topbox == IntPtr.Zero && what != changes.Add && what != changes.Remove)
{
return false;
}
--
cgit v1.1
From fc1be7e41fc7dd23c5396665f7b464de45590368 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 4 Dec 2012 01:54:37 +0000
Subject: raise standing avatar a bit to reduce knees bending on some
collisions. reduce head size a bit
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 3d5be3e..f33fdb4 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -96,7 +96,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float feetSZ = 0.5f;
const float feetScale = 0.9f;
const float invFeetScale = 1.0f / 0.9f;
- const float sizeZAdjust = 0.15f;
+ const float sizeZAdjust = 0.18f;
private float boneOff = 0;
@@ -676,12 +676,12 @@ namespace OpenSim.Region.Physics.OdePlugin
m_invElipSizeX = 1.0f / m_size.X;
m_invElipSizeY = 1.0f / m_size.Y;
- float topsx = m_size.X;
+ float topsx = m_size.X * 0.9f;
float midsx = m_size.X;
float feetsx = m_size.X * feetScale;
float bonesx = feetsx * 0.2f;
- float topsy = m_size.Y * 0.5f;
+ float topsy = m_size.Y * 0.4f;
float midsy = m_size.Y;
float feetsy = m_size.Y * feetScale;
float bonesy = feetsy * 0.2f;
@@ -1057,7 +1057,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// colide with land
d.AABB aabb;
d.GeomGetAABB(feetbox, out aabb);
- float chrminZ = aabb.MinZ - 0.04f; // move up a bit
+ float chrminZ = aabb.MinZ - 0.02f; // move up a bit
Vector3 posch = localpos;
float ftmp;
--
cgit v1.1
From b6d29aa124cf1ec1c1dbe6874720e6cc39faf06f Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 4 Dec 2012 02:46:40 +0000
Subject: move characters (avatars) to own collision space, also fixing a
problem with previus code that was still assuming the avatar is g2
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index f33fdb4..925900f 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -708,21 +708,21 @@ namespace OpenSim.Region.Physics.OdePlugin
bot += midsz;
float topz = bot + topsz * 0.5f;
- _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
- feetbox = d.CreateBox(_parent_scene.ActiveSpace, feetsx, feetsy, feetsz);
+ feetbox = d.CreateBox(_parent_scene.CharsSpace, feetsx, feetsy, feetsz);
d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
- midbox = d.CreateBox(_parent_scene.ActiveSpace, midsx, midsy, midsz);
+ midbox = d.CreateBox(_parent_scene.CharsSpace, midsx, midsy, midsz);
d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
- topbox = d.CreateBox(_parent_scene.ActiveSpace, topsx, topsy, topsz);
+ topbox = d.CreateBox(_parent_scene.CharsSpace, topsx, topsy, topsz);
d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
- bonebox = d.CreateBox(_parent_scene.ActiveSpace, bonesx, bonesy, bonesz);
+ bonebox = d.CreateBox(_parent_scene.CharsSpace, bonesx, bonesy, bonesz);
d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories);
d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags);
@@ -828,21 +828,21 @@ namespace OpenSim.Region.Physics.OdePlugin
if (topbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(topbox);
- _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
d.GeomDestroy(topbox);
topbox = IntPtr.Zero;
}
if (midbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(midbox);
- _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
d.GeomDestroy(midbox);
midbox = IntPtr.Zero;
}
if (feetbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(feetbox);
- _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
d.GeomDestroy(feetbox);
feetbox = IntPtr.Zero;
}
@@ -850,7 +850,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (bonebox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(bonebox);
- _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
+ _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
d.GeomDestroy(bonebox);
bonebox = IntPtr.Zero;
}
--
cgit v1.1
From de3180a63ecb89971321b7dce60dd86703f87e6d Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 5 Dec 2012 23:19:18 +0000
Subject: avatar collision plane send to viewer is only relative to feet.
change avatar collider, just rounding the boxes, etc
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 155 +++++++++------------
1 file changed, 63 insertions(+), 92 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 925900f..fd6b8aa 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -84,18 +84,15 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_mass = 80f;
public float m_density = 60f;
private bool m_pidControllerActive = true;
- public float PID_D = 800.0f;
- public float PID_P = 900.0f;
- //private static float POSTURE_SERVO = 10000.0f;
-
- private float m_invElipSizeX;
- private float m_invElipSizeY;
+ const float basePID_D = 0.55f; // scaled for unit mass unit time (2200 /(50*80))
+ const float basePID_P = 0.225f; // scaled for unit mass unit time (900 /(50*80))
+ public float PID_D;
+ public float PID_P;
private float feetOff = 0;
private float feetSZ = 0.5f;
- const float feetScale = 0.9f;
- const float invFeetScale = 1.0f / 0.9f;
+ const float feetScale = 0.8f;
const float sizeZAdjust = 0.18f;
private float boneOff = 0;
@@ -160,7 +157,7 @@ namespace OpenSim.Region.Physics.OdePlugin
- public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pid_d, float pid_p, float density, float walk_divisor, float rundivisor)
+ public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float density, float walk_divisor, float rundivisor)
{
m_uuid = UUID.Random();
@@ -184,8 +181,6 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene = parent_scene;
- PID_D = pid_d;
- PID_P = pid_p;
m_size.X = pSize.X;
m_size.Y = pSize.Y;
@@ -204,6 +199,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// force lower density for testing
m_density = 3.0f;
+ m_density *= 1.4f; // scale to have mass similar to capsule
+
mu = parent_scene.AvatarFriction;
walkDivisor = walk_divisor;
@@ -211,6 +208,9 @@ namespace OpenSim.Region.Physics.OdePlugin
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default
+ PID_D = basePID_D * m_mass / parent_scene.ODE_STEPSIZE;
+ PID_P = basePID_P * m_mass / parent_scene.ODE_STEPSIZE;
+
m_isPhysical = false; // current status: no ODE information exists
Name = avName;
@@ -491,7 +491,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
get
{
- return m_density * m_size.X * m_size.Y * m_size.Z;
+ return m_mass;
}
}
public override void link(PhysicsActor obj)
@@ -671,23 +671,22 @@ namespace OpenSim.Region.Physics.OdePlugin
private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
{
// sizes one day should came from visual parameters
+ float sx = m_size.X;
+ float sy = m_size.Y;
float sz = m_size.Z + sizeZAdjust;
- m_invElipSizeX = 1.0f / m_size.X;
- m_invElipSizeY = 1.0f / m_size.Y;
+ float topsx = sx * 0.9f;
+ float midsx = sx;
+ float feetsx = sx * feetScale;
+ float bonesx = sx * 0.2f;
- float topsx = m_size.X * 0.9f;
- float midsx = m_size.X;
- float feetsx = m_size.X * feetScale;
- float bonesx = feetsx * 0.2f;
-
- float topsy = m_size.Y * 0.4f;
- float midsy = m_size.Y;
- float feetsy = m_size.Y * feetScale;
+ float topsy = sy * 0.4f;
+ float midsy = sy;
+ float feetsy = sy * feetScale * 0.8f;
float bonesy = feetsy * 0.2f;
float topsz = sz * 0.15f;
- float feetsz = sz * 0.3f;
+ float feetsz = sz * 0.45f;
if (feetsz > 0.6f)
feetsz = 0.6f;
@@ -726,22 +725,12 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories);
d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags);
- d.MassSetBox(out ShellMass, m_density, m_size.X , m_size.Y, m_size.Z);
-
- m_mass = ShellMass.mass; // update mass
-
- // rescale PID parameters
- PID_D = _parent_scene.avPIDD;
- PID_P = _parent_scene.avPIDP;
+ m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass
- // rescale PID parameters so that this aren't affected by mass
- // and so don't get unstable for some masses
- // also scale by ode time step so you don't need to refix them
+ d.MassSetBoxTotal(out ShellMass, m_mass, m_size.X, m_size.Y, m_size.Z);
- PID_D /= 50 * 80; //scale to original mass of around 80 and 50 ODE fps
- PID_D *= m_mass / _parent_scene.ODE_STEPSIZE;
- PID_P /= 50 * 80;
- PID_P *= m_mass / _parent_scene.ODE_STEPSIZE;
+ PID_D = basePID_D * m_mass / _parent_scene.ODE_STEPSIZE;
+ PID_P = basePID_P * m_mass / _parent_scene.ODE_STEPSIZE;
Body = d.BodyCreate(_parent_scene.world);
@@ -857,8 +846,9 @@ namespace OpenSim.Region.Physics.OdePlugin
}
- public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact)
+ public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
{
+ feetcollision = false;
if (me == bonebox) // inner bone
{
@@ -870,44 +860,13 @@ namespace OpenSim.Region.Physics.OdePlugin
if (me == topbox) // keep a box head
return true;
- // rotate elipsoide assuming only rotation around Z
- float ca = m_orientation.W * m_orientation.W - m_orientation.Z * m_orientation.Z;
- float sa = 2 * m_orientation.W * m_orientation.Z;
-
- float isx;
- float isy;
-
- if (me == feetbox) // feet have narrow bounds
- {
-
- isx = m_invElipSizeX * invFeetScale;
- isy = m_invElipSizeY * invFeetScale;
- }
- else
- {
- isx = m_invElipSizeX;
- isy = m_invElipSizeY;
- }
-
- float a = isx * ca - isy * sa;
- float b = isx * sa + isy * ca;
-
+ float t;
float offx = contact.pos.X - _position.X;
- float er = offx * a;
- er *= er;
-
float offy = contact.pos.Y - _position.Y;
- float ty = offy * b;
- er += ty * ty;
if (me == midbox)
{
- if (er > 4.0f) // no collision
- return false;
- if (er < 0.2f)
- return true;
-
- float t = offx * offx + offy * offy;
+ t = offx * offx + offy * offy;
t = (float)Math.Sqrt(t);
t = 1 / t;
offx *= t;
@@ -930,40 +889,51 @@ namespace OpenSim.Region.Physics.OdePlugin
else if (me == feetbox)
{
- float c = feetSZ * 2;
float h = contact.pos.Z - _position.Z;
- float offz = h - feetOff; // distance from top of feetbox
- float tz = offz / c;
- er += tz * tz;
+ if (Math.Abs(contact.normal.Z) > 0.95f)
+ {
+ feetcollision = true;
+ if (h < boneOff)
+ IsColliding = true;
+ return true;
+ }
+
+ float offz = h - feetOff; // distance from top of feetbox
- if (er > 4.0f) // no collision
+ if (offz > 0)
return false;
- if (er > 0.2f)
+ if (offz > -0.01)
+ {
+ offx = 0;
+ offy = 0;
+ offz = -1.0f;
+ }
+ else
{
- float t = offx * offx + offy * offy + offz * offz;
+ t = offx * offx + offy * offy + offz * offz;
t = (float)Math.Sqrt(t);
t = 1 / t;
offx *= t;
offy *= t;
offz *= t;
-
- if (reverse)
- {
- contact.normal.X = offx;
- contact.normal.Y = offy;
- contact.normal.Z = offz;
- }
- else
- {
- contact.normal.X = -offx;
- contact.normal.Y = -offy;
- contact.normal.Z = -offz;
- }
}
- if(h < boneOff)
+ if (reverse)
+ {
+ contact.normal.X = offx;
+ contact.normal.Y = offy;
+ contact.normal.Z = offz;
+ }
+ else
+ {
+ contact.normal.X = -offx;
+ contact.normal.Y = -offy;
+ contact.normal.Z = -offz;
+ }
+ feetcollision = true;
+ if (h < boneOff)
IsColliding = true;
}
else
@@ -1105,6 +1075,7 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.SurfaceNormal.Y = 0f;
contact.SurfaceNormal.Z = -1f;
contact.RelativeSpeed = -vel.Z;
+ contact.CharacterFeet = true;
AddCollisionEvent(0, contact);
vec.Z *= 0.5f;
--
cgit v1.1
From d2499c4c314b290c42f454913305d97c6eec92d6 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 7 Dec 2012 15:54:46 +0000
Subject: *TEST* Use new avatar size in ubitODE.
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 48 ++++++++++++++++++++--
1 file changed, 44 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index fd6b8aa..9c245e6 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -90,13 +90,12 @@ namespace OpenSim.Region.Physics.OdePlugin
public float PID_D;
public float PID_P;
+ private float m_feetOffset = 0;
private float feetOff = 0;
private float feetSZ = 0.5f;
const float feetScale = 0.8f;
- const float sizeZAdjust = 0.18f;
private float boneOff = 0;
-
public float walkDivisor = 1.3f;
public float runDivisor = 0.8f;
private bool flying = false;
@@ -475,6 +474,28 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
+ public override void setAvatarSize(Vector3 size, float feetOffset)
+ {
+ if (size.IsFinite())
+ {
+ if (size.X < 0.01f)
+ size.X = 0.01f;
+ if (size.Y < 0.01f)
+ size.Y = 0.01f;
+ if (size.Z < 0.01f)
+ size.Z = 0.01f;
+
+ strAvatarSize st = new strAvatarSize();
+ st.size = size;
+ st.offset = feetOffset;
+ AddChange(changes.AvatarSize, st);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN AvatarSize from Scene on a Character");
+ }
+
+ }
///
/// This creates the Avatar's physical Surrogate at the position supplied
///
@@ -673,7 +694,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// sizes one day should came from visual parameters
float sx = m_size.X;
float sy = m_size.Y;
- float sz = m_size.Z + sizeZAdjust;
+ float sz = m_size.Z;
+
float topsx = sx * 0.9f;
float midsx = sx;
@@ -693,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float midsz = sz - topsz - feetsz;
float bonesz = sz;
- float bot = -sz * 0.5f;
+ float bot = -sz * 0.5f + m_feetOffset;
boneOff = bot + 0.3f;
@@ -754,6 +776,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetOffsetPosition(feetbox, 0, 0, feetz);
d.GeomSetOffsetPosition(midbox, 0, 0, midz);
d.GeomSetOffsetPosition(topbox, 0, 0, topz);
+ d.GeomSetOffsetPosition(bonebox, 0, 0, m_feetOffset);
// The purpose of the AMotor here is to keep the avatar's physical
// surrogate from rotating while moving
@@ -1402,6 +1425,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{
}
+ private void changeAvatarSize(strAvatarSize st)
+ {
+ m_feetOffset = st.offset;
+ changeSize(st.size);
+ }
+
private void changeSize(Vector3 pSize)
{
if (pSize.IsFinite())
@@ -1609,6 +1638,10 @@ namespace OpenSim.Region.Physics.OdePlugin
changeSize((Vector3)arg);
break;
+ case changes.AvatarSize:
+ changeAvatarSize((strAvatarSize)arg);
+ break;
+
case changes.Momentum:
changeMomentum((Vector3)arg);
break;
@@ -1656,5 +1689,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{
_parent_scene.AddChange((PhysicsActor)this, what, arg);
}
+
+ private struct strAvatarSize
+ {
+ public Vector3 size;
+ public float offset;
+ }
+
}
}
--
cgit v1.1
From 2ea0dc55d7ea6da6e91ab614856cdeece7eae5d2 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 7 Dec 2012 20:06:35 +0000
Subject: create a new ode character also with the new information
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 9c245e6..15bdc57 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -156,7 +156,7 @@ namespace OpenSim.Region.Physics.OdePlugin
- public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float density, float walk_divisor, float rundivisor)
+ public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor)
{
m_uuid = UUID.Random();
@@ -192,6 +192,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if(m_size.Z <0.01f)
m_size.Z = 0.01f;
+ m_feetOffset = pfeetOffset;
m_orientation = Quaternion.Identity;
m_density = density;
--
cgit v1.1
From 80639ace95089414423b16f90c8994f50e010373 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 11 Dec 2012 04:36:27 +0000
Subject: a few more changes on avatar collider
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 347 ++++++++++++++++-----
1 file changed, 274 insertions(+), 73 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 15bdc57..1b25faf 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -74,7 +74,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private Vector3 _position;
private Vector3 _zeroPosition;
- private bool _zeroFlag = false;
private Vector3 _velocity;
private Vector3 _target_velocity;
private Vector3 _acceleration;
@@ -90,11 +89,15 @@ namespace OpenSim.Region.Physics.OdePlugin
public float PID_D;
public float PID_P;
+ private float timeStep;
+ private float invtimeStep;
+
private float m_feetOffset = 0;
private float feetOff = 0;
private float feetSZ = 0.5f;
const float feetScale = 0.8f;
private float boneOff = 0;
+ private float m_lastVelocitySqr = 0;
public float walkDivisor = 1.3f;
public float runDivisor = 0.8f;
@@ -103,6 +106,9 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_iscollidingGround = false;
private bool m_iscollidingObj = false;
private bool m_alwaysRun = false;
+
+ private bool _zeroFlag = false;
+
private int m_requestedUpdateFrequency = 0;
private uint m_localID = 0;
public bool m_returnCollisions = false;
@@ -120,6 +126,7 @@ namespace OpenSim.Region.Physics.OdePlugin
int m_colliderfilter = 0;
int m_colliderGroundfilter = 0;
int m_colliderObjectfilter = 0;
+ bool m_collisionException = false;
// Default we're a Character
private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
@@ -132,10 +139,11 @@ namespace OpenSim.Region.Physics.OdePlugin
// we do land collisions not ode | CollisionCategories.Land);
public IntPtr Body = IntPtr.Zero;
private OdeScene _parent_scene;
- public IntPtr topbox = IntPtr.Zero;
- public IntPtr midbox = IntPtr.Zero;
- public IntPtr feetbox = IntPtr.Zero;
- public IntPtr bonebox = IntPtr.Zero;
+ private IntPtr topbox = IntPtr.Zero;
+ private IntPtr midbox = IntPtr.Zero;
+ private IntPtr feetbox = IntPtr.Zero;
+ private IntPtr bbox = IntPtr.Zero;
+ public IntPtr collider = IntPtr.Zero;
public IntPtr Amotor = IntPtr.Zero;
@@ -143,6 +151,7 @@ namespace OpenSim.Region.Physics.OdePlugin
+
public int m_eventsubscription = 0;
private int m_cureventsubscription = 0;
private CollisionEventUpdate CollisionEventsThisFrame = null;
@@ -160,6 +169,9 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_uuid = UUID.Random();
+ timeStep = parent_scene.ODE_STEPSIZE;
+ invtimeStep = 1 / timeStep;
+
if (pos.IsFinite())
{
if (pos.Z > 99999f)
@@ -208,8 +220,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default
- PID_D = basePID_D * m_mass / parent_scene.ODE_STEPSIZE;
- PID_P = basePID_P * m_mass / parent_scene.ODE_STEPSIZE;
+ PID_D = basePID_D * m_mass * invtimeStep;
+ PID_P = basePID_P * m_mass * invtimeStep;
m_isPhysical = false; // current status: no ODE information exists
@@ -292,7 +304,7 @@ namespace OpenSim.Region.Physics.OdePlugin
set
{
flying = value;
- // m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying);
+// m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying);
}
}
@@ -336,25 +348,25 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return m_iscollidingGround; }
set
{
- /* we now control this
- if (value)
- {
- m_colliderGroundfilter += 2;
- if (m_colliderGroundfilter > 2)
- m_colliderGroundfilter = 2;
- }
- else
- {
- m_colliderGroundfilter--;
- if (m_colliderGroundfilter < 0)
- m_colliderGroundfilter = 0;
- }
-
- if (m_colliderGroundfilter == 0)
- m_iscollidingGround = false;
- else
- m_iscollidingGround = true;
- */
+/* we now control this
+ if (value)
+ {
+ m_colliderGroundfilter += 2;
+ if (m_colliderGroundfilter > 2)
+ m_colliderGroundfilter = 2;
+ }
+ else
+ {
+ m_colliderGroundfilter--;
+ if (m_colliderGroundfilter < 0)
+ m_colliderGroundfilter = 0;
+ }
+
+ if (m_colliderGroundfilter == 0)
+ m_iscollidingGround = false;
+ else
+ m_iscollidingGround = true;
+ */
}
}
@@ -386,7 +398,7 @@ namespace OpenSim.Region.Physics.OdePlugin
else
m_iscollidingObj = true;
- // m_iscollidingObj = value;
+// m_iscollidingObj = value;
if (m_iscollidingObj)
m_pidControllerActive = false;
@@ -634,8 +646,8 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return m_orientation; }
set
{
- // fakeori = value;
- // givefakeori++;
+// fakeori = value;
+// givefakeori++;
value.Normalize();
AddChange(changes.Orientation, value);
@@ -690,6 +702,46 @@ namespace OpenSim.Region.Physics.OdePlugin
AddChange(changes.Momentum, momentum);
}
+ private void ajustCollider()
+ {
+ float vq = _velocity.LengthSquared();
+ if (m_lastVelocitySqr != vq)
+ {
+ m_lastVelocitySqr = vq;
+ if (vq > 100.0f)
+ {
+ Vector3 off = _velocity;
+ float t = 0.5f * timeStep;
+ off = off * t;
+ d.GeomSetOffsetPosition(bbox, off.X, off.Y, off.Z);
+ off.X = 2.0f * (m_size.X + Math.Abs(off.X));
+ off.Y = 2.0f * (m_size.Y + Math.Abs(off.Y));
+ off.Z = m_size.Z + 2.0f * Math.Abs(off.Z);
+ d.GeomBoxSetLengths(bbox, off.X, off.Y, off.Z);
+
+ d.GeomSetCategoryBits(bbox, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(bbox, (uint)m_collisionFlags);
+ d.GeomSetCategoryBits(topbox, 0);
+ d.GeomSetCollideBits(topbox, 0);
+ d.GeomSetCategoryBits(midbox, 0);
+ d.GeomSetCollideBits(midbox, 0);
+ d.GeomSetCategoryBits(feetbox, 0);
+ d.GeomSetCollideBits(feetbox, 0);
+ }
+ else
+ {
+ d.GeomSetCategoryBits(bbox, 0);
+ d.GeomSetCollideBits(bbox, 0);
+ d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
+ d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
+ d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
+ }
+ }
+ }
+
private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
{
// sizes one day should came from visual parameters
@@ -697,7 +749,6 @@ namespace OpenSim.Region.Physics.OdePlugin
float sy = m_size.Y;
float sz = m_size.Z;
-
float topsx = sx * 0.9f;
float midsx = sx;
float feetsx = sx * feetScale;
@@ -732,21 +783,17 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
- feetbox = d.CreateBox(_parent_scene.CharsSpace, feetsx, feetsy, feetsz);
- d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
- d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
-
- midbox = d.CreateBox(_parent_scene.CharsSpace, midsx, midsy, midsz);
- d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
- d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
+ collider = d.HashSpaceCreate(_parent_scene.CharsSpace);
+ d.HashSpaceSetLevels(collider, -4, 3);
+ d.SpaceSetSublevel(collider, 3);
+ d.SpaceSetCleanup(collider, false);
+ d.GeomSetCategoryBits(collider, (uint)m_collisionCategories);
+ d.GeomSetCollideBits(collider, (uint)m_collisionFlags);
- topbox = d.CreateBox(_parent_scene.CharsSpace, topsx, topsy, topsz);
- d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
- d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
-
- bonebox = d.CreateBox(_parent_scene.CharsSpace, bonesx, bonesy, bonesz);
- d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories);
- d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags);
+ feetbox = d.CreateBox(collider, feetsx, feetsy, feetsz);
+ midbox = d.CreateBox(collider, midsx, midsy, midsz);
+ topbox = d.CreateBox(collider, topsx, topsy, topsz);
+ bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z);
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass
@@ -758,9 +805,13 @@ namespace OpenSim.Region.Physics.OdePlugin
Body = d.BodyCreate(_parent_scene.world);
_zeroFlag = false;
+ m_collisionException = false;
m_pidControllerActive = true;
m_freemove = false;
+ _velocity = Vector3.Zero;
+ m_lastVelocitySqr = 0;
+
d.BodySetAutoDisableFlag(Body, false);
d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
@@ -772,12 +823,14 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetBody(feetbox, Body);
d.GeomSetBody(midbox, Body);
d.GeomSetBody(topbox, Body);
- d.GeomSetBody(bonebox, Body);
+ d.GeomSetBody(bbox, Body);
d.GeomSetOffsetPosition(feetbox, 0, 0, feetz);
d.GeomSetOffsetPosition(midbox, 0, 0, midz);
d.GeomSetOffsetPosition(topbox, 0, 0, topz);
- d.GeomSetOffsetPosition(bonebox, 0, 0, m_feetOffset);
+
+ ajustCollider();
+
// The purpose of the AMotor here is to keep the avatar's physical
// surrogate from rotating while moving
@@ -841,44 +894,109 @@ namespace OpenSim.Region.Physics.OdePlugin
if (topbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(topbox);
- _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
+ _parent_scene.waitForSpaceUnlock(collider);
d.GeomDestroy(topbox);
topbox = IntPtr.Zero;
}
if (midbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(midbox);
- _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
+ _parent_scene.waitForSpaceUnlock(collider);
d.GeomDestroy(midbox);
midbox = IntPtr.Zero;
}
if (feetbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(feetbox);
- _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
+ _parent_scene.waitForSpaceUnlock(collider);
d.GeomDestroy(feetbox);
feetbox = IntPtr.Zero;
}
- if (bonebox != IntPtr.Zero)
+ if (bbox != IntPtr.Zero)
+ {
+ _parent_scene.actor_name_map.Remove(bbox);
+ _parent_scene.waitForSpaceUnlock(collider);
+ d.GeomDestroy(bbox);
+ bbox = IntPtr.Zero;
+ }
+
+ if (collider != IntPtr.Zero)
{
- _parent_scene.actor_name_map.Remove(bonebox);
- _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
- d.GeomDestroy(bonebox);
- bonebox = IntPtr.Zero;
+ d.SpaceDestroy(collider);
+ collider = IntPtr.Zero;
}
}
+ //in place 2D rotation around Z assuming rot is normalised and is a rotation around Z
+ public void RotateXYonZ(ref float x, ref float y, ref Quaternion rot)
+ {
+ float sin = 2.0f * rot.Z * rot.W;
+ float cos = rot.W * rot.W - rot.Z * rot.Z;
+ float tx = x;
+
+ x = tx * cos - y * sin;
+ y = tx * sin + y * cos;
+ }
+ public void RotateXYonZ(ref float x, ref float y, ref float sin, ref float cos)
+ {
+ float tx = x;
+ x = tx * cos - y * sin;
+ y = tx * sin + y * cos;
+ }
+ public void invRotateXYonZ(ref float x, ref float y, ref float sin, ref float cos)
+ {
+ float tx = x;
+ x = tx * cos + y * sin;
+ y = -tx * sin + y * cos;
+ }
+
+ public void invRotateXYonZ(ref float x, ref float y, ref Quaternion rot)
+ {
+ float sin = - 2.0f * rot.Z * rot.W;
+ float cos = rot.W * rot.W - rot.Z * rot.Z;
+ float tx = x;
+
+ x = tx * cos - y * sin;
+ y = tx * sin + y * cos;
+ }
+
+
public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
{
feetcollision = false;
+ if (m_collisionException)
+ return false;
- if (me == bonebox) // inner bone
+ if (me == bbox) // if moving fast
{
- if (contact.pos.Z - _position.Z < boneOff)
- IsColliding = true;
- return true;
+ // force a full inelastic collision
+ m_collisionException = true;
+
+ Vector3 off = m_size * 0.5f;
+ off.X += contact.depth;
+ off.Y += contact.depth;
+ off.Z += contact.depth;
+ if (reverse)
+ {
+ off.X *= -contact.normal.X;
+ off.Y *= -contact.normal.Y;
+ off.Z *= -contact.normal.Z;
+ }
+ else
+ {
+ off.X *= contact.normal.X;
+ off.Y *= contact.normal.Y;
+ off.Z *= contact.normal.Z;
+ }
+
+ off.X += contact.pos.X;
+ off.Y += contact.pos.Y;
+ off.Z += contact.pos.Z;
+
+ _position = off;
+ return false;
}
if (me == topbox) // keep a box head
@@ -890,6 +1008,21 @@ namespace OpenSim.Region.Physics.OdePlugin
if (me == midbox)
{
+ if (Math.Abs(contact.normal.Z) > 0.95f)
+ {
+ float nz = contact.normal.Z;
+ if (!reverse)
+ nz = -nz;
+
+ if (nz > 0)
+ return true; // missed head TODO
+
+ // missed feet collision?
+
+
+ return true;
+ }
+
t = offx * offx + offy * offy;
t = (float)Math.Sqrt(t);
t = 1 / t;
@@ -917,12 +1050,19 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Math.Abs(contact.normal.Z) > 0.95f)
{
+ if (contact.normal.Z > 0)
+ contact.normal.Z = 1.0f;
+ else
+ contact.normal.Z = -1.0f;
+ contact.normal.X = 0.0f;
+ contact.normal.Y = 0.0f;
feetcollision = true;
if (h < boneOff)
IsColliding = true;
return true;
}
+
float offz = h - feetOff; // distance from top of feetbox
if (offz > 0)
@@ -971,11 +1111,28 @@ namespace OpenSim.Region.Physics.OdePlugin
/// This is the avatar's movement control + PID Controller
///
///
- public void Move(float timeStep, List defects)
+ public void Move(List defects)
{
if (Body == IntPtr.Zero)
return;
+ if (m_collisionException)
+ {
+ d.BodySetPosition(Body,_position.X, _position.Y, _position.Z);
+ d.BodySetLinearVel(Body, 0, 0, 0);
+
+ float v = _velocity.Length();
+ if (v != 0)
+ {
+ v = 6.0f / v;
+ _velocity = _velocity * v;
+ d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
+ }
+ ajustCollider();
+ m_collisionException = false;
+ return;
+ }
+
d.Vector3 dtmp = d.BodyGetPosition(Body);
Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
@@ -1049,6 +1206,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//******************************************
// colide with land
+
d.AABB aabb;
d.GeomGetAABB(feetbox, out aabb);
float chrminZ = aabb.MinZ - 0.02f; // move up a bit
@@ -1095,8 +1253,8 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.Position.X = localpos.X;
contact.Position.Y = localpos.Y;
contact.Position.Z = chrminZ;
- contact.SurfaceNormal.X = 0f;
- contact.SurfaceNormal.Y = 0f;
+ contact.SurfaceNormal.X = 0.0f;
+ contact.SurfaceNormal.Y = 0.0f;
contact.SurfaceNormal.Z = -1f;
contact.RelativeSpeed = -vel.Z;
contact.CharacterFeet = true;
@@ -1118,6 +1276,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_iscollidingGround = false;
}
+
//******************************************
bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f);
@@ -1253,21 +1412,58 @@ namespace OpenSim.Region.Physics.OdePlugin
}
// update our local ideia of position velocity and aceleration
+ // _position = localpos;
_position = localpos;
+
if (_zeroFlag)
{
_velocity = Vector3.Zero;
_acceleration = Vector3.Zero;
+ m_rotationalVelocity = Vector3.Zero;
}
else
{
- _acceleration = _velocity; // previus velocity
- _velocity = vel;
- _acceleration = (vel - _acceleration) / timeStep;
+ Vector3 a =_velocity; // previus velocity
+ SetSmooth(ref _velocity, ref vel, 2);
+ a = (_velocity - a) * invtimeStep;
+ SetSmooth(ref _acceleration, ref a, 2);
+
+ dtmp = d.BodyGetAngularVel(Body);
+ m_rotationalVelocity.X = 0f;
+ m_rotationalVelocity.Y = 0f;
+ m_rotationalVelocity.Z = dtmp.Z;
+ Math.Round(m_rotationalVelocity.Z,3);
}
-
+ ajustCollider();
}
+ public void round(ref Vector3 v, int digits)
+ {
+ v.X = (float)Math.Round(v.X, digits);
+ v.Y = (float)Math.Round(v.Y, digits);
+ v.Z = (float)Math.Round(v.Z, digits);
+ }
+
+ public void SetSmooth(ref Vector3 dst, ref Vector3 value)
+ {
+ dst.X = 0.1f * dst.X + 0.9f * value.X;
+ dst.Y = 0.1f * dst.Y + 0.9f * value.Y;
+ dst.Z = 0.1f * dst.Z + 0.9f * value.Z;
+ }
+
+ public void SetSmooth(ref Vector3 dst, ref Vector3 value, int rounddigits)
+ {
+ dst.X = 0.4f * dst.X + 0.6f * value.X;
+ dst.X = (float)Math.Round(dst.X, rounddigits);
+
+ dst.Y = 0.4f * dst.Y + 0.6f * value.Y;
+ dst.Y = (float)Math.Round(dst.Y, rounddigits);
+
+ dst.Z = 0.4f * dst.Z + 0.6f * value.Z;
+ dst.Z = (float)Math.Round(dst.Z, rounddigits);
+ }
+
+
///
/// Updates the reported position and velocity.
/// Used to copy variables from unmanaged space at heartbeat rate and also trigger scene updates acording
@@ -1394,10 +1590,11 @@ namespace OpenSim.Region.Physics.OdePlugin
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
- _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[collider] = (PhysicsActor)this;
_parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[bonebox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
_parent_scene.AddCharacter(this);
}
else
@@ -1450,13 +1647,16 @@ namespace OpenSim.Region.Physics.OdePlugin
_position.Z + (m_size.Z - oldsz) * 0.5f);
Velocity = Vector3.Zero;
+
- _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[collider] = (PhysicsActor)this;
_parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[bonebox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
}
m_freemove = false;
+ m_collisionException = false;
m_pidControllerActive = true;
}
else
@@ -1565,6 +1765,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero)
d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
+ ajustCollider();
}
private void donullchange()
@@ -1573,7 +1774,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public bool DoAChange(changes what, object arg)
{
- if (topbox == IntPtr.Zero && what != changes.Add && what != changes.Remove)
+ if (collider == IntPtr.Zero && what != changes.Add && what != changes.Remove)
{
return false;
}
--
cgit v1.1
From 28ea08c3e234f8ca3c6590af4045349af7fed844 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 11 Dec 2012 17:14:32 +0000
Subject: fix let other phys plugins work.. broken when added feetOffset
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 1b25faf..b769c88 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -165,9 +165,10 @@ namespace OpenSim.Region.Physics.OdePlugin
- public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor)
+ public OdeCharacter(uint localID, String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor)
{
m_uuid = UUID.Random();
+ m_localID = localID;
timeStep = parent_scene.ODE_STEPSIZE;
invtimeStep = 1 / timeStep;
@@ -1209,7 +1210,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.AABB aabb;
d.GeomGetAABB(feetbox, out aabb);
- float chrminZ = aabb.MinZ - 0.02f; // move up a bit
+ float chrminZ = aabb.MinZ; ; // move up a bit
Vector3 posch = localpos;
float ftmp;
@@ -1252,7 +1253,7 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.PenetrationDepth = depth;
contact.Position.X = localpos.X;
contact.Position.Y = localpos.Y;
- contact.Position.Z = chrminZ;
+ contact.Position.Z = terrainheight;
contact.SurfaceNormal.X = 0.0f;
contact.SurfaceNormal.Y = 0.0f;
contact.SurfaceNormal.Z = -1f;
--
cgit v1.1
From f35e3c6fe04327ad4bc9b9864663910ea2b5d717 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 11 Dec 2012 19:38:44 +0000
Subject: changes on the fast speed avatars collider, collisions from above,
etc
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 126 +++++++++++----------
1 file changed, 64 insertions(+), 62 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b769c88..27a9f1c 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -970,78 +970,86 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_collisionException)
return false;
+ Vector3 offset;
+
if (me == bbox) // if moving fast
{
// force a full inelastic collision
m_collisionException = true;
- Vector3 off = m_size * 0.5f;
- off.X += contact.depth;
- off.Y += contact.depth;
- off.Z += contact.depth;
+ offset = m_size * m_orientation;
+
+ offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
+ offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
+ offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth;
+
if (reverse)
{
- off.X *= -contact.normal.X;
- off.Y *= -contact.normal.Y;
- off.Z *= -contact.normal.Z;
+ offset.X *= -contact.normal.X;
+ offset.Y *= -contact.normal.Y;
+ offset.Z *= -contact.normal.Z;
}
else
{
- off.X *= contact.normal.X;
- off.Y *= contact.normal.Y;
- off.Z *= contact.normal.Z;
+ offset.X *= contact.normal.X;
+ offset.Y *= contact.normal.Y;
+ offset.Z *= contact.normal.Z;
}
- off.X += contact.pos.X;
- off.Y += contact.pos.Y;
- off.Z += contact.pos.Z;
+ offset.X += contact.pos.X;
+ offset.Y += contact.pos.Y;
+ offset.Z += contact.pos.Z;
- _position = off;
+ _position = offset;
return false;
}
- if (me == topbox) // keep a box head
- return true;
-
- float t;
- float offx = contact.pos.X - _position.X;
- float offy = contact.pos.Y - _position.Y;
+ offset.X = contact.pos.X - _position.X;
+ offset.Y = contact.pos.Y - _position.Y;
- if (me == midbox)
+ if (me == topbox)
{
- if (Math.Abs(contact.normal.Z) > 0.95f)
- {
- float nz = contact.normal.Z;
- if (!reverse)
- nz = -nz;
-
- if (nz > 0)
- return true; // missed head TODO
+ offset.Z = contact.pos.Z - _position.Z;
- // missed feet collision?
+ offset.Normalize();
-
- return true;
+ if (reverse)
+ {
+ contact.normal.X = offset.X;
+ contact.normal.Y = offset.Y;
+ contact.normal.Z = offset.Z;
+ }
+ else
+ {
+ contact.normal.X = -offset.X;
+ contact.normal.Y = -offset.Y;
+ contact.normal.Z = -offset.Z;
}
+ return true;
+ }
- t = offx * offx + offy * offy;
- t = (float)Math.Sqrt(t);
- t = 1 / t;
- offx *= t;
- offy *= t;
+ if (me == midbox)
+ {
+ if (Math.Abs(contact.normal.Z) > 0.95f)
+ offset.Z = contact.pos.Z - _position.Z;
+ else
+ offset.Z = contact.normal.Z;
+
+ offset.Normalize();
if (reverse)
{
- contact.normal.X = offx;
- contact.normal.Y = offy;
+ contact.normal.X = offset.X;
+ contact.normal.Y = offset.Y;
+ contact.normal.Z = offset.Z;
}
else
{
- contact.normal.X = -offx;
- contact.normal.Y = -offy;
+ contact.normal.X = -offset.X;
+ contact.normal.Y = -offset.Y;
+ contact.normal.Z = -offset.Z;
}
- contact.normal.Z = 0;
return true;
}
@@ -1063,39 +1071,33 @@ namespace OpenSim.Region.Physics.OdePlugin
return true;
}
+ offset.Z = h - feetOff; // distance from top of feetbox
- float offz = h - feetOff; // distance from top of feetbox
-
- if (offz > 0)
+ if (offset.Z > 0)
return false;
- if (offz > -0.01)
+ if (offset.Z > -0.01)
{
- offx = 0;
- offy = 0;
- offz = -1.0f;
+ offset.X = 0;
+ offset.Y = 0;
+ offset.Z = -1.0f;
}
else
{
- t = offx * offx + offy * offy + offz * offz;
- t = (float)Math.Sqrt(t);
- t = 1 / t;
- offx *= t;
- offy *= t;
- offz *= t;
+ offset.Normalize();
}
if (reverse)
{
- contact.normal.X = offx;
- contact.normal.Y = offy;
- contact.normal.Z = offz;
+ contact.normal.X = offset.X;
+ contact.normal.Y = offset.Y;
+ contact.normal.Z = offset.Z;
}
else
{
- contact.normal.X = -offx;
- contact.normal.Y = -offy;
- contact.normal.Z = -offz;
+ contact.normal.X = -offset.X;
+ contact.normal.Y = -offset.Y;
+ contact.normal.Z = -offset.Z;
}
feetcollision = true;
if (h < boneOff)
@@ -1125,7 +1127,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float v = _velocity.Length();
if (v != 0)
{
- v = 6.0f / v;
+ v = 5.0f / v;
_velocity = _velocity * v;
d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
}
--
cgit v1.1
From 71fc9f29f92edf2956ecb25dcbcdb97d262c8a14 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 11 Dec 2012 22:53:24 +0000
Subject: make ubitODE ignore X and Y rotation components on avatar rotations
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 51 ++++++++++++++++------
1 file changed, 37 insertions(+), 14 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 27a9f1c..bb04ea7 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -80,6 +80,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private Vector3 m_rotationalVelocity;
private Vector3 m_size;
private Quaternion m_orientation;
+ private Quaternion m_orientation2D;
private float m_mass = 80f;
public float m_density = 60f;
private bool m_pidControllerActive = true;
@@ -207,6 +208,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_feetOffset = pfeetOffset;
m_orientation = Quaternion.Identity;
+ m_orientation2D = Quaternion.Identity;
m_density = density;
// force lower density for testing
@@ -649,7 +651,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
// fakeori = value;
// givefakeori++;
-
value.Normalize();
AddChange(changes.Orientation, value);
}
@@ -977,7 +978,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// force a full inelastic collision
m_collisionException = true;
- offset = m_size * m_orientation;
+ offset = m_size * m_orientation2D;
offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
@@ -1143,10 +1144,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// so force it back to identity
d.Quaternion qtmp;
- qtmp.W = m_orientation.W;
- qtmp.X = m_orientation.X;
- qtmp.Y = m_orientation.Y;
- qtmp.Z = m_orientation.Z;
+ qtmp.W = m_orientation2D.W;
+ qtmp.X = m_orientation2D.X;
+ qtmp.Y = m_orientation2D.Y;
+ qtmp.Z = m_orientation2D.Z;
d.BodySetQuaternion(Body, ref qtmp);
if (m_pidControllerActive == false)
@@ -1679,14 +1680,36 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeOrientation(Quaternion newOri)
{
- d.Quaternion myrot = new d.Quaternion();
- myrot.X = newOri.X;
- myrot.Y = newOri.Y;
- myrot.Z = newOri.Z;
- myrot.W = newOri.W;
- float t = d.JointGetAMotorAngle(Amotor, 2);
- d.BodySetQuaternion(Body,ref myrot);
- m_orientation = newOri;
+ if (m_orientation != newOri)
+ {
+ m_orientation = newOri; // keep a copy for core use
+ // but only use rotations around Z
+
+ m_orientation2D.W = newOri.W;
+ m_orientation2D.Z = newOri.Z;
+
+ float t = m_orientation2D.W * m_orientation2D.W + m_orientation2D.Z * m_orientation2D.Z;
+ if (t > 0)
+ {
+ t = 1.0f / (float)Math.Sqrt(t);
+ m_orientation2D.W *= t;
+ m_orientation2D.Z *= t;
+ }
+ else
+ {
+ m_orientation2D.W = 1.0f;
+ m_orientation2D.Z = 0f;
+ }
+ m_orientation2D.Y = 0f;
+ m_orientation2D.X = 0f;
+
+ d.Quaternion myrot = new d.Quaternion();
+ myrot.X = m_orientation2D.X;
+ myrot.Y = m_orientation2D.Y;
+ myrot.Z = m_orientation2D.Z;
+ myrot.W = m_orientation2D.W;
+ d.BodySetQuaternion(Body, ref myrot);
+ }
}
private void changeVelocity(Vector3 newVel)
--
cgit v1.1
From 7980a1d8496b71e46eeead7d77382cd10ac9fa78 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 2 Jan 2013 19:39:46 +0000
Subject: *TEST* avatar unscripted sit. Some guessing/automation
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 13 +++++++++++++
1 file changed, 13 insertions(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index bb04ea7..e1d694e 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -715,7 +715,17 @@ namespace OpenSim.Region.Physics.OdePlugin
Vector3 off = _velocity;
float t = 0.5f * timeStep;
off = off * t;
+ d.Quaternion qtmp;
+ d.GeomCopyQuaternion(bbox, out qtmp);
+ Quaternion q;
+ q.X = qtmp.X;
+ q.Y = qtmp.Y;
+ q.Z = qtmp.Z;
+ q.W = qtmp.W;
+ off *= Quaternion.Conjugate(q);
+
d.GeomSetOffsetPosition(bbox, off.X, off.Y, off.Z);
+
off.X = 2.0f * (m_size.X + Math.Abs(off.X));
off.Y = 2.0f * (m_size.Y + Math.Abs(off.Y));
off.Z = m_size.Z + 2.0f * Math.Abs(off.Z);
@@ -741,6 +751,9 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
}
+ uint cat1 = d.GeomGetCategoryBits(bbox);
+ uint col1 = d.GeomGetCollideBits(bbox);
+
}
}
--
cgit v1.1
From be6b6bf191718f7c674297a804fa1a6cb4196a5a Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 2 Jan 2013 20:06:57 +0000
Subject: add a lock to CollisionEventsThisFrame
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 49 +++++++++++++---------
1 file changed, 29 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index e1d694e..f7e4c1c 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1540,8 +1540,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (CollisionEventsThisFrame != null)
{
- CollisionEventsThisFrame.Clear();
- CollisionEventsThisFrame = null;
+ lock (CollisionEventsThisFrame)
+ {
+ CollisionEventsThisFrame.Clear();
+ CollisionEventsThisFrame = null;
+ }
}
m_eventsubscription = 0;
}
@@ -1550,8 +1553,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
- CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
- _parent_scene.AddCollisionEventReporting(this);
+ lock (CollisionEventsThisFrame)
+ {
+ CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
+ _parent_scene.AddCollisionEventReporting(this);
+ }
}
public void SendCollisions()
@@ -1559,26 +1565,29 @@ namespace OpenSim.Region.Physics.OdePlugin
if (CollisionEventsThisFrame == null)
return;
- if (m_cureventsubscription < m_eventsubscription)
- return;
+ lock (CollisionEventsThisFrame)
+ {
+ if (m_cureventsubscription < m_eventsubscription)
+ return;
- m_cureventsubscription = 0;
+ m_cureventsubscription = 0;
- int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
+ int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
- if (!SentEmptyCollisionsEvent || ncolisions > 0)
- {
- base.SendCollisionUpdate(CollisionEventsThisFrame);
-
- if (ncolisions == 0)
+ if (!SentEmptyCollisionsEvent || ncolisions > 0)
{
- SentEmptyCollisionsEvent = true;
- _parent_scene.RemoveCollisionEventReporting(this);
- }
- else
- {
- SentEmptyCollisionsEvent = false;
- CollisionEventsThisFrame.Clear();
+ base.SendCollisionUpdate(CollisionEventsThisFrame);
+
+ if (ncolisions == 0)
+ {
+ SentEmptyCollisionsEvent = true;
+ _parent_scene.RemoveCollisionEventReporting(this);
+ }
+ else
+ {
+ SentEmptyCollisionsEvent = false;
+ CollisionEventsThisFrame.Clear();
+ }
}
}
}
--
cgit v1.1
From 5b37063178d1a44e5db8ca6c8d47a12c011f8012 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Tue, 12 Mar 2013 03:47:27 +0100
Subject: Spot fix the interpenetration issue. Thanks, Ter.
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index f7e4c1c..bea34d4 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1014,8 +1014,8 @@ namespace OpenSim.Region.Physics.OdePlugin
offset.Y += contact.pos.Y;
offset.Z += contact.pos.Z;
- _position = offset;
- return false;
+ //_position = offset;
+ //return false;
}
offset.X = contact.pos.X - _position.X;
--
cgit v1.1
From 799ba5aa7b2b5d82e5e2f622929042b38da3809c Mon Sep 17 00:00:00 2001
From: teravus
Date: Tue, 14 May 2013 19:17:31 -0400
Subject: * Tweaks the hard cut to apply to collisions of Greater then Normal Z
0.95. This fits within Ubit's framework of multi-body collisions, just
moves the reactive force to the Midboxgeom(actual detection) instead of the
bigbox geom(pre detection)
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 28 +++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index bea34d4..238e6e9 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1045,12 +1045,37 @@ namespace OpenSim.Region.Physics.OdePlugin
if (me == midbox)
{
if (Math.Abs(contact.normal.Z) > 0.95f)
+ {
offset.Z = contact.pos.Z - _position.Z;
+ offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
+ offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
+ offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth;
+
+ if (reverse)
+ {
+ offset.X *= -contact.normal.X;
+ offset.Y *= -contact.normal.Y;
+ offset.Z *= -contact.normal.Z;
+ }
+ else
+ {
+ offset.X *= contact.normal.X;
+ offset.Y *= contact.normal.Y;
+ offset.Z *= contact.normal.Z;
+ }
+
+ offset.X += contact.pos.X;
+ offset.Y += contact.pos.Y;
+ offset.Z += contact.pos.Z;
+ _position = offset;
+ return true;
+ }
else
offset.Z = contact.normal.Z;
offset.Normalize();
+ /*
if (reverse)
{
contact.normal.X = offset.X;
@@ -1063,7 +1088,8 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.normal.Y = -offset.Y;
contact.normal.Z = -offset.Z;
}
-
+ */
+ //_position.Z = offset.Z;
return true;
}
--
cgit v1.1
From 477a5e3a35780809b1807e43f6deed8ede17f14d Mon Sep 17 00:00:00 2001
From: teravus
Date: Tue, 14 May 2013 20:55:56 -0400
Subject: * This fixes the avatar stuck in objects on login and teleport by
gently applying an upward motion when stuck in things on the Z * Comments
describe how it filters out good, normal collisions, from 'stuck'
collisions.. It's especially sensitive in feetbox collisions since this is
where normal collisions happen under usual circumstances.
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 12 ++++++++++++
1 file changed, 12 insertions(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 238e6e9..e912997 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1097,8 +1097,20 @@ namespace OpenSim.Region.Physics.OdePlugin
{
float h = contact.pos.Z - _position.Z;
+ // Only do this if the normal is sufficiently pointing in the 'up' direction
if (Math.Abs(contact.normal.Z) > 0.95f)
{
+ // We Only want to do this if we're sunk into the object a bit and we're stuck and we're trying to move and feetcollision is false
+ if ((contact.depth > 0.0010f && _velocity.X == 0f && _velocity.Y == 0 && _velocity.Z == 0)
+ && (_target_velocity.X > 0 || _target_velocity.Y > 0 || _target_velocity.Z > 0)
+ && (!feetcollision) )
+ {
+ m_collisionException = true; // Stop looping, do this only once not X times Contacts
+ _position.Z += contact.depth + 0.01f; // Move us Up the amount that we sank in, and add 0.01 meters to gently lift avatar up.
+
+ return true;
+ }
+
if (contact.normal.Z > 0)
contact.normal.Z = 1.0f;
else
--
cgit v1.1
From 9654b81b2d73e524ad5541bc38440949f4952bad Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 19 Jul 2014 16:16:13 +0100
Subject: revert to capsule representation of avatar collider
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 325 ++-------------------
1 file changed, 28 insertions(+), 297 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index e912997..ecd5474 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -95,10 +95,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_feetOffset = 0;
private float feetOff = 0;
- private float feetSZ = 0.5f;
- const float feetScale = 0.8f;
private float boneOff = 0;
- private float m_lastVelocitySqr = 0;
public float walkDivisor = 1.3f;
public float runDivisor = 0.8f;
@@ -110,7 +107,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool _zeroFlag = false;
- private int m_requestedUpdateFrequency = 0;
private uint m_localID = 0;
public bool m_returnCollisions = false;
// taints and their non-tainted counterparts
@@ -127,7 +123,6 @@ namespace OpenSim.Region.Physics.OdePlugin
int m_colliderfilter = 0;
int m_colliderGroundfilter = 0;
int m_colliderObjectfilter = 0;
- bool m_collisionException = false;
// Default we're a Character
private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
@@ -140,9 +135,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// we do land collisions not ode | CollisionCategories.Land);
public IntPtr Body = IntPtr.Zero;
private OdeScene _parent_scene;
- private IntPtr topbox = IntPtr.Zero;
- private IntPtr midbox = IntPtr.Zero;
- private IntPtr feetbox = IntPtr.Zero;
+ private IntPtr capsule = IntPtr.Zero;
private IntPtr bbox = IntPtr.Zero;
public IntPtr collider = IntPtr.Zero;
@@ -150,9 +143,6 @@ namespace OpenSim.Region.Physics.OdePlugin
public d.Mass ShellMass;
-
-
-
public int m_eventsubscription = 0;
private int m_cureventsubscription = 0;
private CollisionEventUpdate CollisionEventsThisFrame = null;
@@ -214,8 +204,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// force lower density for testing
m_density = 3.0f;
- m_density *= 1.4f; // scale to have mass similar to capsule
-
mu = parent_scene.AvatarFriction;
walkDivisor = walk_divisor;
@@ -704,58 +692,6 @@ namespace OpenSim.Region.Physics.OdePlugin
AddChange(changes.Momentum, momentum);
}
- private void ajustCollider()
- {
- float vq = _velocity.LengthSquared();
- if (m_lastVelocitySqr != vq)
- {
- m_lastVelocitySqr = vq;
- if (vq > 100.0f)
- {
- Vector3 off = _velocity;
- float t = 0.5f * timeStep;
- off = off * t;
- d.Quaternion qtmp;
- d.GeomCopyQuaternion(bbox, out qtmp);
- Quaternion q;
- q.X = qtmp.X;
- q.Y = qtmp.Y;
- q.Z = qtmp.Z;
- q.W = qtmp.W;
- off *= Quaternion.Conjugate(q);
-
- d.GeomSetOffsetPosition(bbox, off.X, off.Y, off.Z);
-
- off.X = 2.0f * (m_size.X + Math.Abs(off.X));
- off.Y = 2.0f * (m_size.Y + Math.Abs(off.Y));
- off.Z = m_size.Z + 2.0f * Math.Abs(off.Z);
- d.GeomBoxSetLengths(bbox, off.X, off.Y, off.Z);
-
- d.GeomSetCategoryBits(bbox, (uint)m_collisionCategories);
- d.GeomSetCollideBits(bbox, (uint)m_collisionFlags);
- d.GeomSetCategoryBits(topbox, 0);
- d.GeomSetCollideBits(topbox, 0);
- d.GeomSetCategoryBits(midbox, 0);
- d.GeomSetCollideBits(midbox, 0);
- d.GeomSetCategoryBits(feetbox, 0);
- d.GeomSetCollideBits(feetbox, 0);
- }
- else
- {
- d.GeomSetCategoryBits(bbox, 0);
- d.GeomSetCollideBits(bbox, 0);
- d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
- d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
- d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
- d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
- d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
- d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
- }
- uint cat1 = d.GeomGetCategoryBits(bbox);
- uint col1 = d.GeomGetCollideBits(bbox);
-
- }
- }
private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
{
@@ -764,37 +700,14 @@ namespace OpenSim.Region.Physics.OdePlugin
float sy = m_size.Y;
float sz = m_size.Z;
- float topsx = sx * 0.9f;
- float midsx = sx;
- float feetsx = sx * feetScale;
- float bonesx = sx * 0.2f;
-
- float topsy = sy * 0.4f;
- float midsy = sy;
- float feetsy = sy * feetScale * 0.8f;
- float bonesy = feetsy * 0.2f;
+ float bot = -sz * 0.5f + m_feetOffset;
+ boneOff = bot + 0.3f;
- float topsz = sz * 0.15f;
float feetsz = sz * 0.45f;
if (feetsz > 0.6f)
feetsz = 0.6f;
- float midsz = sz - topsz - feetsz;
- float bonesz = sz;
-
- float bot = -sz * 0.5f + m_feetOffset;
-
- boneOff = bot + 0.3f;
-
- float feetz = bot + feetsz * 0.5f;
- bot += feetsz;
-
- feetOff = bot;
- feetSZ = feetsz;
-
- float midz = bot + midsz * 0.5f;
- bot += midsz;
- float topz = bot + topsz * 0.5f;
+ feetOff = bot + feetsz;
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
@@ -805,9 +718,13 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetCategoryBits(collider, (uint)m_collisionCategories);
d.GeomSetCollideBits(collider, (uint)m_collisionFlags);
- feetbox = d.CreateBox(collider, feetsx, feetsy, feetsz);
- midbox = d.CreateBox(collider, midsx, midsy, midsz);
- topbox = d.CreateBox(collider, topsx, topsy, topsz);
+ float r = m_size.X;
+ if (m_size.Y > r)
+ r = m_size.Y;
+ float l = m_size.Z - r;
+ r *= 0.5f;
+ capsule = d.CreateCapsule(collider, r, l);
+
bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z);
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass
@@ -820,12 +737,10 @@ namespace OpenSim.Region.Physics.OdePlugin
Body = d.BodyCreate(_parent_scene.world);
_zeroFlag = false;
- m_collisionException = false;
m_pidControllerActive = true;
m_freemove = false;
_velocity = Vector3.Zero;
- m_lastVelocitySqr = 0;
d.BodySetAutoDisableFlag(Body, false);
d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
@@ -835,17 +750,9 @@ namespace OpenSim.Region.Physics.OdePlugin
_position.Z = npositionZ;
d.BodySetMass(Body, ref ShellMass);
- d.GeomSetBody(feetbox, Body);
- d.GeomSetBody(midbox, Body);
- d.GeomSetBody(topbox, Body);
- d.GeomSetBody(bbox, Body);
-
- d.GeomSetOffsetPosition(feetbox, 0, 0, feetz);
- d.GeomSetOffsetPosition(midbox, 0, 0, midz);
- d.GeomSetOffsetPosition(topbox, 0, 0, topz);
-
- ajustCollider();
+ d.GeomSetBody(bbox, Body);
+ d.GeomSetBody(capsule, Body);
// The purpose of the AMotor here is to keep the avatar's physical
// surrogate from rotating while moving
@@ -906,26 +813,12 @@ namespace OpenSim.Region.Physics.OdePlugin
}
//kill the Geoms
- if (topbox != IntPtr.Zero)
+ if (capsule != IntPtr.Zero)
{
- _parent_scene.actor_name_map.Remove(topbox);
+ _parent_scene.actor_name_map.Remove(capsule);
_parent_scene.waitForSpaceUnlock(collider);
- d.GeomDestroy(topbox);
- topbox = IntPtr.Zero;
- }
- if (midbox != IntPtr.Zero)
- {
- _parent_scene.actor_name_map.Remove(midbox);
- _parent_scene.waitForSpaceUnlock(collider);
- d.GeomDestroy(midbox);
- midbox = IntPtr.Zero;
- }
- if (feetbox != IntPtr.Zero)
- {
- _parent_scene.actor_name_map.Remove(feetbox);
- _parent_scene.waitForSpaceUnlock(collider);
- d.GeomDestroy(feetbox);
- feetbox = IntPtr.Zero;
+ d.GeomDestroy(capsule);
+ capsule = IntPtr.Zero;
}
if (bbox != IntPtr.Zero)
@@ -981,163 +874,21 @@ namespace OpenSim.Region.Physics.OdePlugin
public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
{
feetcollision = false;
- if (m_collisionException)
- return false;
Vector3 offset;
- if (me == bbox) // if moving fast
- {
- // force a full inelastic collision
- m_collisionException = true;
-
- offset = m_size * m_orientation2D;
-
- offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
- offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
- offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth;
-
- if (reverse)
- {
- offset.X *= -contact.normal.X;
- offset.Y *= -contact.normal.Y;
- offset.Z *= -contact.normal.Z;
- }
- else
- {
- offset.X *= contact.normal.X;
- offset.Y *= contact.normal.Y;
- offset.Z *= contact.normal.Z;
- }
-
- offset.X += contact.pos.X;
- offset.Y += contact.pos.Y;
- offset.Z += contact.pos.Z;
-
- //_position = offset;
- //return false;
- }
-
offset.X = contact.pos.X - _position.X;
offset.Y = contact.pos.Y - _position.Y;
- if (me == topbox)
- {
- offset.Z = contact.pos.Z - _position.Z;
-
- offset.Normalize();
-
- if (reverse)
- {
- contact.normal.X = offset.X;
- contact.normal.Y = offset.Y;
- contact.normal.Z = offset.Z;
- }
- else
- {
- contact.normal.X = -offset.X;
- contact.normal.Y = -offset.Y;
- contact.normal.Z = -offset.Z;
- }
- return true;
- }
-
- if (me == midbox)
- {
- if (Math.Abs(contact.normal.Z) > 0.95f)
- {
- offset.Z = contact.pos.Z - _position.Z;
- offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
- offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
- offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth;
-
- if (reverse)
- {
- offset.X *= -contact.normal.X;
- offset.Y *= -contact.normal.Y;
- offset.Z *= -contact.normal.Z;
- }
- else
- {
- offset.X *= contact.normal.X;
- offset.Y *= contact.normal.Y;
- offset.Z *= contact.normal.Z;
- }
-
- offset.X += contact.pos.X;
- offset.Y += contact.pos.Y;
- offset.Z += contact.pos.Z;
- _position = offset;
- return true;
- }
- else
- offset.Z = contact.normal.Z;
-
- offset.Normalize();
-
- /*
- if (reverse)
- {
- contact.normal.X = offset.X;
- contact.normal.Y = offset.Y;
- contact.normal.Z = offset.Z;
- }
- else
- {
- contact.normal.X = -offset.X;
- contact.normal.Y = -offset.Y;
- contact.normal.Z = -offset.Z;
- }
- */
- //_position.Z = offset.Z;
- return true;
- }
-
- else if (me == feetbox)
+ if (me == capsule)
{
float h = contact.pos.Z - _position.Z;
-
- // Only do this if the normal is sufficiently pointing in the 'up' direction
- if (Math.Abs(contact.normal.Z) > 0.95f)
- {
- // We Only want to do this if we're sunk into the object a bit and we're stuck and we're trying to move and feetcollision is false
- if ((contact.depth > 0.0010f && _velocity.X == 0f && _velocity.Y == 0 && _velocity.Z == 0)
- && (_target_velocity.X > 0 || _target_velocity.Y > 0 || _target_velocity.Z > 0)
- && (!feetcollision) )
- {
- m_collisionException = true; // Stop looping, do this only once not X times Contacts
- _position.Z += contact.depth + 0.01f; // Move us Up the amount that we sank in, and add 0.01 meters to gently lift avatar up.
-
- return true;
- }
-
- if (contact.normal.Z > 0)
- contact.normal.Z = 1.0f;
- else
- contact.normal.Z = -1.0f;
- contact.normal.X = 0.0f;
- contact.normal.Y = 0.0f;
- feetcollision = true;
- if (h < boneOff)
- IsColliding = true;
- return true;
- }
-
- offset.Z = h - feetOff; // distance from top of feetbox
+ offset.Z = h - feetOff;
if (offset.Z > 0)
- return false;
+ return true;
- if (offset.Z > -0.01)
- {
- offset.X = 0;
- offset.Y = 0;
- offset.Z = -1.0f;
- }
- else
- {
- offset.Normalize();
- }
+ offset.Normalize();
if (reverse)
{
@@ -1171,23 +922,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body == IntPtr.Zero)
return;
- if (m_collisionException)
- {
- d.BodySetPosition(Body,_position.X, _position.Y, _position.Z);
- d.BodySetLinearVel(Body, 0, 0, 0);
-
- float v = _velocity.Length();
- if (v != 0)
- {
- v = 5.0f / v;
- _velocity = _velocity * v;
- d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
- }
- ajustCollider();
- m_collisionException = false;
- return;
- }
-
d.Vector3 dtmp = d.BodyGetPosition(Body);
Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
@@ -1263,7 +997,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// colide with land
d.AABB aabb;
- d.GeomGetAABB(feetbox, out aabb);
+// d.GeomGetAABB(feetbox, out aabb);
+ d.GeomGetAABB(capsule, out aabb);
float chrminZ = aabb.MinZ; ; // move up a bit
Vector3 posch = localpos;
@@ -1489,7 +1224,6 @@ namespace OpenSim.Region.Physics.OdePlugin
m_rotationalVelocity.Z = dtmp.Z;
Math.Round(m_rotationalVelocity.Z,3);
}
- ajustCollider();
}
public void round(ref Vector3 v, int digits)
@@ -1655,10 +1389,11 @@ namespace OpenSim.Region.Physics.OdePlugin
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
- _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
+// _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
+// _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
+// _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
_parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
_parent_scene.AddCharacter(this);
}
else
@@ -1714,13 +1449,10 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
- _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
_parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
+ _parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
}
m_freemove = false;
- m_collisionException = false;
m_pidControllerActive = true;
}
else
@@ -1851,7 +1583,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero)
d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
- ajustCollider();
}
private void donullchange()
--
cgit v1.1
From d9797b64784d4c4ec1d1d55c7a7bdaa71bfe3ebe Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 21 Jul 2014 19:16:23 +0100
Subject: change ava to ava collisions a bit
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 72 +++++++++++++---------
1 file changed, 42 insertions(+), 30 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index ecd5474..daf6c7c 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -96,6 +96,8 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_feetOffset = 0;
private float feetOff = 0;
private float boneOff = 0;
+ private float AvaAvaSizeXsq = 0.3f;
+ private float AvaAvaSizeYsq = 0.2f;
public float walkDivisor = 1.3f;
public float runDivisor = 0.8f;
@@ -136,7 +138,6 @@ namespace OpenSim.Region.Physics.OdePlugin
public IntPtr Body = IntPtr.Zero;
private OdeScene _parent_scene;
private IntPtr capsule = IntPtr.Zero;
- private IntPtr bbox = IntPtr.Zero;
public IntPtr collider = IntPtr.Zero;
public IntPtr Amotor = IntPtr.Zero;
@@ -709,6 +710,11 @@ namespace OpenSim.Region.Physics.OdePlugin
feetOff = bot + feetsz;
+ AvaAvaSizeXsq = 0.4f * sx;
+ AvaAvaSizeXsq *= AvaAvaSizeXsq;
+ AvaAvaSizeYsq = 0.5f * sy;
+ AvaAvaSizeYsq *= AvaAvaSizeYsq;
+
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
collider = d.HashSpaceCreate(_parent_scene.CharsSpace);
@@ -723,9 +729,8 @@ namespace OpenSim.Region.Physics.OdePlugin
r = m_size.Y;
float l = m_size.Z - r;
r *= 0.5f;
- capsule = d.CreateCapsule(collider, r, l);
- bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z);
+ capsule = d.CreateCapsule(collider, r, l);
m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass
@@ -750,8 +755,6 @@ namespace OpenSim.Region.Physics.OdePlugin
_position.Z = npositionZ;
d.BodySetMass(Body, ref ShellMass);
-
- d.GeomSetBody(bbox, Body);
d.GeomSetBody(capsule, Body);
// The purpose of the AMotor here is to keep the avatar's physical
@@ -821,14 +824,6 @@ namespace OpenSim.Region.Physics.OdePlugin
capsule = IntPtr.Zero;
}
- if (bbox != IntPtr.Zero)
- {
- _parent_scene.actor_name_map.Remove(bbox);
- _parent_scene.waitForSpaceUnlock(collider);
- d.GeomDestroy(bbox);
- bbox = IntPtr.Zero;
- }
-
if (collider != IntPtr.Zero)
{
d.SpaceDestroy(collider);
@@ -871,20 +866,44 @@ namespace OpenSim.Region.Physics.OdePlugin
}
- public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
+ public bool Collide(IntPtr me,IntPtr other, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
{
feetcollision = false;
- Vector3 offset;
-
- offset.X = contact.pos.X - _position.X;
- offset.Y = contact.pos.Y - _position.Y;
-
if (me == capsule)
{
+ Vector3 offset;
+
float h = contact.pos.Z - _position.Z;
offset.Z = h - feetOff;
+ offset.X = contact.pos.X - _position.X;
+ offset.Y = contact.pos.Y - _position.Y;
+
+ d.GeomClassID gtype = d.GeomGetClass(other);
+ if (gtype == d.GeomClassID.CapsuleClass)
+ {
+ Vector3 roff = offset * Quaternion.Inverse(m_orientation2D);
+ float r = roff.X *roff.X / AvaAvaSizeXsq;
+ r += (roff.Y * roff.Y) / AvaAvaSizeYsq;
+ if (r > 1.0f)
+ return false;
+
+ float dp = 1.0f -(float)Math.Sqrt((double)r);
+ if (dp > 0.05f)
+ dp = 0.05f;
+
+ contact.depth = dp;
+
+ if (offset.Z < 0)
+ {
+ feetcollision = true;
+ if (h < boneOff)
+ IsColliding = true;
+ }
+ return true;
+ }
+
if (offset.Z > 0)
return true;
@@ -905,11 +924,9 @@ namespace OpenSim.Region.Physics.OdePlugin
feetcollision = true;
if (h < boneOff)
IsColliding = true;
+ return true;
}
- else
- return false;
-
- return true;
+ return false;
}
///
@@ -1094,8 +1111,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// Avatar to Avatar collisions
// Prim to avatar collisions
- vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 2);
- vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 2);
+ vec.X = -vel.X * PID_D * 2 + (_zeroPosition.X - localpos.X) * (PID_P * 5);
+ vec.Y = -vel.Y * PID_D * 2 + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
if (flying)
{
vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
@@ -1389,10 +1406,6 @@ namespace OpenSim.Region.Physics.OdePlugin
AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
-// _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
-// _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
-// _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
- _parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
_parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
_parent_scene.AddCharacter(this);
}
@@ -1449,7 +1462,6 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
- _parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
_parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
}
m_freemove = false;
--
cgit v1.1
From 3052a5388954592861e0a55681844115485b6ae7 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 29 Sep 2014 20:17:05 +0100
Subject: change avatar physics and motion control. Still not that good :(
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 210 ++++++++++++++++-----
1 file changed, 164 insertions(+), 46 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index daf6c7c..4a98df4 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -79,6 +79,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private Vector3 _acceleration;
private Vector3 m_rotationalVelocity;
private Vector3 m_size;
+ private Vector3 m_collideNormal;
private Quaternion m_orientation;
private Quaternion m_orientation2D;
private float m_mass = 80f;
@@ -109,6 +110,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool _zeroFlag = false;
+
private uint m_localID = 0;
public bool m_returnCollisions = false;
// taints and their non-tainted counterparts
@@ -153,9 +155,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public UUID m_uuid;
public bool bad = false;
- float mu;
-
-
+ float mu;
public OdeCharacter(uint localID, String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor)
{
@@ -864,11 +864,12 @@ namespace OpenSim.Region.Physics.OdePlugin
x = tx * cos - y * sin;
y = tx * sin + y * cos;
}
-
-
- public bool Collide(IntPtr me,IntPtr other, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
+
+ public bool Collide(IntPtr me, IntPtr other, bool reverse, ref d.ContactGeom contact,
+ ref d.ContactGeom altContact , ref bool useAltcontact, ref bool feetcollision)
{
feetcollision = false;
+ useAltcontact = false;
if (me == capsule)
{
@@ -899,31 +900,77 @@ namespace OpenSim.Region.Physics.OdePlugin
{
feetcollision = true;
if (h < boneOff)
+ {
+ m_collideNormal.X = contact.normal.X;
+ m_collideNormal.Y = contact.normal.Y;
+ m_collideNormal.Z = contact.normal.Z;
IsColliding = true;
+ }
}
return true;
- }
+ }
+
+ d.AABB aabb;
+ d.GeomGetAABB(other,out aabb);
+ float othertop = aabb.MaxZ - _position.Z;
+
+ if (offset.Z > 0 || othertop > -feetOff || contact.normal.Z > 0.35f)
+ {
+ if (offset.Z <= 0)
+ {
+ feetcollision = true;
+ if (h < boneOff)
+ {
+ m_collideNormal.X = contact.normal.X;
+ m_collideNormal.Y = contact.normal.Y;
+ m_collideNormal.Z = contact.normal.Z;
+ IsColliding = true;
+ }
+ }
- if (offset.Z > 0)
+ if (contact.normal.Z < 0.2f)
+ {
+ contact.normal.Z = 0;
+ float t = contact.normal.X * contact.normal.X + contact.normal.Y * contact.normal.Y;
+ if (t > 0)
+ {
+ t = 1.0f / t;
+ contact.normal.X *= t;
+ contact.normal.Y *= t;
+ }
+ }
return true;
+ }
+
+ altContact = contact;
+ useAltcontact = true;
offset.Normalize();
+ if (contact.depth > 0.1f)
+ contact.depth = 0.1f;
+
if (reverse)
{
- contact.normal.X = offset.X;
- contact.normal.Y = offset.Y;
- contact.normal.Z = offset.Z;
+ altContact.normal.X = offset.X;
+ altContact.normal.Y = offset.Y;
+ altContact.normal.Z = offset.Z;
}
else
{
- contact.normal.X = -offset.X;
- contact.normal.Y = -offset.Y;
- contact.normal.Z = -offset.Z;
+ altContact.normal.X = -offset.X;
+ altContact.normal.Y = -offset.Y;
+ altContact.normal.Z = -offset.Z;
}
+
feetcollision = true;
if (h < boneOff)
+ {
+ m_collideNormal.X = contact.normal.X;
+ m_collideNormal.Y = contact.normal.Y;
+ m_collideNormal.Z = contact.normal.Z;
IsColliding = true;
+ }
return true;
}
return false;
@@ -1003,6 +1050,9 @@ namespace OpenSim.Region.Physics.OdePlugin
Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
float velLengthSquared = vel.LengthSquared();
+
+ Vector3 ctz = _target_velocity;
+
float movementdivisor = 1f;
//Ubit change divisions into multiplications below
if (!m_alwaysRun)
@@ -1010,13 +1060,16 @@ namespace OpenSim.Region.Physics.OdePlugin
else
movementdivisor = 1 / runDivisor;
+ ctz.X *= movementdivisor;
+ ctz.Y *= movementdivisor;
+
//******************************************
// colide with land
d.AABB aabb;
// d.GeomGetAABB(feetbox, out aabb);
d.GeomGetAABB(capsule, out aabb);
- float chrminZ = aabb.MinZ; ; // move up a bit
+ float chrminZ = aabb.MinZ; // move up a bit
Vector3 posch = localpos;
float ftmp;
@@ -1031,15 +1084,18 @@ namespace OpenSim.Region.Physics.OdePlugin
float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
if (chrminZ < terrainheight)
{
+ if (ctz.Z < 0)
+ ctz.Z = 0;
+
+ Vector3 n = _parent_scene.GetTerrainNormalAtXY(posch.X, posch.Y);
float depth = terrainheight - chrminZ;
+
+ vec.Z = depth * PID_P * 50;
+
if (!flying)
- {
- vec.Z = -vel.Z * PID_D * 1.5f + depth * PID_P * 50;
- }
- else
- vec.Z = depth * PID_P * 50;
+ vec.Z += -vel.Z * PID_D;
- if (depth < 0.1f)
+ if (depth < 0.2f)
{
m_colliderGroundfilter++;
if (m_colliderGroundfilter > 2)
@@ -1053,50 +1109,83 @@ namespace OpenSim.Region.Physics.OdePlugin
m_freemove = false;
}
+ m_collideNormal.X = n.X;
+ m_collideNormal.Y = n.Y;
+ m_collideNormal.Z = n.Z;
+
m_iscollidingGround = true;
+
ContactPoint contact = new ContactPoint();
contact.PenetrationDepth = depth;
contact.Position.X = localpos.X;
contact.Position.Y = localpos.Y;
contact.Position.Z = terrainheight;
- contact.SurfaceNormal.X = 0.0f;
- contact.SurfaceNormal.Y = 0.0f;
- contact.SurfaceNormal.Z = -1f;
+ contact.SurfaceNormal.X = -n.X;
+ contact.SurfaceNormal.Y = -n.Y;
+ contact.SurfaceNormal.Z = -n.Z;
contact.RelativeSpeed = -vel.Z;
contact.CharacterFeet = true;
AddCollisionEvent(0, contact);
- vec.Z *= 0.5f;
+// vec.Z *= 0.5f;
}
}
else
{
- m_colliderGroundfilter = 0;
- m_iscollidingGround = false;
+ m_colliderGroundfilter -= 5;
+ if (m_colliderGroundfilter <= 0)
+ {
+ m_colliderGroundfilter = 0;
+ m_iscollidingGround = false;
+ }
}
}
else
{
- m_colliderGroundfilter = 0;
- m_iscollidingGround = false;
+ m_colliderGroundfilter -= 5;
+ if (m_colliderGroundfilter <= 0)
+ {
+ m_colliderGroundfilter = 0;
+ m_iscollidingGround = false;
+ }
}
//******************************************
+ if (!m_iscolliding)
+ m_collideNormal.Z = 0;
+
+ bool tviszero = (ctz.X == 0.0f && ctz.Y == 0.0f && ctz.Z == 0.0f);
+
- bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f);
- // if (!tviszero || m_iscolliding || velLengthSquared <0.01)
if (!tviszero)
+ {
m_freemove = false;
+ // movement relative to surface if moving on it
+ // dont disturbe vertical movement, ie jumps
+ if (m_iscolliding && !flying && ctz.Z == 0 && m_collideNormal.Z > 0.2f && m_collideNormal.Z < 0.94f)
+ {
+ float p = ctz.X * m_collideNormal.X + ctz.Y * m_collideNormal.Y;
+ ctz.X *= (float)Math.Sqrt(1 - m_collideNormal.X * m_collideNormal.X);
+ ctz.Y *= (float)Math.Sqrt(1 - m_collideNormal.Y * m_collideNormal.Y);
+ ctz.Z -= p;
+ if (ctz.Z < 0)
+ ctz.Z *= 2;
+
+ }
+
+ }
+
+
if (!m_freemove)
{
// if velocity is zero, use position control; otherwise, velocity control
- if (tviszero && m_iscolliding)
+ if (tviszero && m_iscolliding && !flying)
{
// keep track of where we stopped. No more slippin' & slidin'
if (!_zeroFlag)
@@ -1129,22 +1218,48 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (!flying)
{
- if (_target_velocity.Z > 0.0f)
+ // we are on a surface
+ if (ctz.Z > 0f)
{
- // We're colliding with something and we're not flying but we're moving
- // This means we're walking or running. JUMPING
- vec.Z += (_target_velocity.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P;
+ // moving up or JUMPING
+ vec.Z += (ctz.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P;
+ vec.X += (ctz.X - vel.X) * (PID_D);
+ vec.Y += (ctz.Y - vel.Y) * (PID_D);
}
+ else
+ {
+ // we are moving down on a surface
+ if (ctz.Z == 0)
+ {
+ if (vel.Z > 0)
+ vec.Z -= vel.Z * PID_D * 2.0f;
+ vec.X += (ctz.X - vel.X) * (PID_D);
+ vec.Y += (ctz.Y - vel.Y) * (PID_D);
+ }
+ // intencionally going down
+ else
+ {
+ if (ctz.Z < vel.Z)
+ vec.Z += (ctz.Z - vel.Z) * PID_D * 2.0f;
+ else
+ {
+ }
+
+ if (Math.Abs(ctz.X) > Math.Abs(vel.X))
+ vec.X += (ctz.X - vel.X) * (PID_D);
+ if (Math.Abs(ctz.Y) > Math.Abs(vel.Y))
+ vec.Y += (ctz.Y - vel.Y) * (PID_D);
+ }
+ }
+
// We're standing on something
- vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D);
- vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D);
}
else
{
// We're flying and colliding with something
- vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 0.0625f);
- vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 0.0625f);
- vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
+ vec.X += (ctz.X - vel.X) * (PID_D * 0.0625f);
+ vec.Y += (ctz.Y - vel.Y) * (PID_D * 0.0625f);
+ vec.Z += (ctz.Z - vel.Z) * (PID_D);
}
}
else // ie not colliding
@@ -1152,9 +1267,9 @@ namespace OpenSim.Region.Physics.OdePlugin
if (flying) //(!m_iscolliding && flying)
{
// we're in mid air suspended
- vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 1.667f);
- vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 1.667f);
- vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
+ vec.X += (ctz.X - vel.X) * (PID_D * 1.667f);
+ vec.Y += (ctz.Y - vel.Y) * (PID_D * 1.667f);
+ vec.Z += (ctz.Z - vel.Z) * (PID_D);
}
else
@@ -1163,8 +1278,11 @@ namespace OpenSim.Region.Physics.OdePlugin
// m_iscolliding includes collisions with the ground.
// d.Vector3 pos = d.BodyGetPosition(Body);
- vec.X = (_target_velocity.X - vel.X) * PID_D * 0.833f;
- vec.Y = (_target_velocity.Y - vel.Y) * PID_D * 0.833f;
+ vec.X += (ctz.X - vel.X) * PID_D * 0.833f;
+ vec.Y += (ctz.Y - vel.Y) * PID_D * 0.833f;
+ // hack for breaking on fall
+ if (ctz.Z == -9999f)
+ vec.Z += -vel.Z * PID_D - _parent_scene.gravityz * m_mass;
}
}
}
--
cgit v1.1
From 1b2e2a86a3e54ef9437697f7460924f64d986b7c Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 29 Sep 2014 23:24:22 +0100
Subject: remove check of other prim top height on steps climb code
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 4a98df4..992fae7 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -909,12 +909,13 @@ namespace OpenSim.Region.Physics.OdePlugin
}
return true;
}
-
+/*
d.AABB aabb;
d.GeomGetAABB(other,out aabb);
float othertop = aabb.MaxZ - _position.Z;
-
- if (offset.Z > 0 || othertop > -feetOff || contact.normal.Z > 0.35f)
+*/
+// if (offset.Z > 0 || othertop > -feetOff || contact.normal.Z > 0.35f)
+ if (offset.Z > 0 || contact.normal.Z > 0.35f)
{
if (offset.Z <= 0)
{
--
cgit v1.1
From 44a42efa4b9e3263226e469f361a798b3b12ed8a Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 4 Oct 2014 08:46:46 +0100
Subject: try to help steps climb a bit compensating the bounce reduction
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 2 ++
1 file changed, 2 insertions(+)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 992fae7..f94e70b 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -946,6 +946,8 @@ namespace OpenSim.Region.Physics.OdePlugin
altContact = contact;
useAltcontact = true;
+ offset.Z -= 0.2f;
+
offset.Normalize();
if (contact.depth > 0.1f)
--
cgit v1.1
From c3a1d6b5ef2e889f53ff3b0c1b6b1002d6f9f6b8 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 5 Oct 2014 18:55:37 +0100
Subject: reduce some avatar engine strenght
---
OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index f94e70b..af7ca1d 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -928,7 +928,7 @@ namespace OpenSim.Region.Physics.OdePlugin
IsColliding = true;
}
}
-
+/*
if (contact.normal.Z < 0.2f)
{
contact.normal.Z = 0;
@@ -940,6 +940,7 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.normal.Y *= t;
}
}
+ */
return true;
}
@@ -1203,8 +1204,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// Avatar to Avatar collisions
// Prim to avatar collisions
- vec.X = -vel.X * PID_D * 2 + (_zeroPosition.X - localpos.X) * (PID_P * 5);
- vec.Y = -vel.Y * PID_D * 2 + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
+ vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 5);
+ vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
if (flying)
{
vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
@@ -1225,7 +1226,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (ctz.Z > 0f)
{
// moving up or JUMPING
- vec.Z += (ctz.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P;
+ vec.Z += (ctz.Z - vel.Z) * PID_D;
vec.X += (ctz.X - vel.X) * (PID_D);
vec.Y += (ctz.Y - vel.Y) * (PID_D);
}
@@ -1235,7 +1236,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (ctz.Z == 0)
{
if (vel.Z > 0)
- vec.Z -= vel.Z * PID_D * 2.0f;
+ vec.Z -= vel.Z * PID_D;
vec.X += (ctz.X - vel.X) * (PID_D);
vec.Y += (ctz.Y - vel.Y) * (PID_D);
}
@@ -1243,7 +1244,7 @@ namespace OpenSim.Region.Physics.OdePlugin
else
{
if (ctz.Z < vel.Z)
- vec.Z += (ctz.Z - vel.Z) * PID_D * 2.0f;
+ vec.Z += (ctz.Z - vel.Z) * PID_D;
else
{
}
@@ -1262,7 +1263,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// We're flying and colliding with something
vec.X += (ctz.X - vel.X) * (PID_D * 0.0625f);
vec.Y += (ctz.Y - vel.Y) * (PID_D * 0.0625f);
- vec.Z += (ctz.Z - vel.Z) * (PID_D);
+ vec.Z += (ctz.Z - vel.Z) * (PID_D * 0.0625f);
}
}
else // ie not colliding
@@ -1270,8 +1271,8 @@ namespace OpenSim.Region.Physics.OdePlugin
if (flying) //(!m_iscolliding && flying)
{
// we're in mid air suspended
- vec.X += (ctz.X - vel.X) * (PID_D * 1.667f);
- vec.Y += (ctz.Y - vel.Y) * (PID_D * 1.667f);
+ vec.X += (ctz.X - vel.X) * (PID_D);
+ vec.Y += (ctz.Y - vel.Y) * (PID_D);
vec.Z += (ctz.Z - vel.Z) * (PID_D);
}
--
cgit v1.1
From 10d3d0c81de69106cd0a4f4a6d4f94310f595f43 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 12 Oct 2014 01:14:54 +0100
Subject: try to reduce avatar bounce on falls. Not all possible side effects
checked, specially on portals
---
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 44 ++++++++++------------
1 file changed, 19 insertions(+), 25 deletions(-)
(limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index af7ca1d..1c38246 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -311,9 +311,9 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (value)
{
- m_colliderfilter += 2;
- if (m_colliderfilter > 2)
- m_colliderfilter = 2;
+ m_colliderfilter += 3;
+ if (m_colliderfilter > 3)
+ m_colliderfilter = 3;
}
else
{
@@ -328,6 +328,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_pidControllerActive = true;
m_iscolliding = true;
+ m_freemove = false;
}
}
}
@@ -928,19 +929,6 @@ namespace OpenSim.Region.Physics.OdePlugin
IsColliding = true;
}
}
-/*
- if (contact.normal.Z < 0.2f)
- {
- contact.normal.Z = 0;
- float t = contact.normal.X * contact.normal.X + contact.normal.Y * contact.normal.Y;
- if (t > 0)
- {
- t = 1.0f / t;
- contact.normal.X *= t;
- contact.normal.Y *= t;
- }
- }
- */
return true;
}
@@ -1204,12 +1192,18 @@ namespace OpenSim.Region.Physics.OdePlugin
// Avatar to Avatar collisions
// Prim to avatar collisions
- vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 5);
- vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
+ vec.X = -vel.X * PID_D * 2f + (_zeroPosition.X - localpos.X) * (PID_P * 5);
+ vec.Y = -vel.Y * PID_D * 2f + (_zeroPosition.Y - localpos.Y) * (PID_P * 5);
+ if(vel.Z > 0)
+ vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
+ else
+ vec.Z += (-vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P) * 0.2f;
+/*
if (flying)
{
vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
}
+*/
}
//PidStatus = true;
}
@@ -1226,7 +1220,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (ctz.Z > 0f)
{
// moving up or JUMPING
- vec.Z += (ctz.Z - vel.Z) * PID_D;
+ vec.Z += (ctz.Z - vel.Z) * PID_D * 2f;
vec.X += (ctz.X - vel.X) * (PID_D);
vec.Y += (ctz.Y - vel.Y) * (PID_D);
}
@@ -1236,7 +1230,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (ctz.Z == 0)
{
if (vel.Z > 0)
- vec.Z -= vel.Z * PID_D;
+ vec.Z -= vel.Z * PID_D * 2f;
vec.X += (ctz.X - vel.X) * (PID_D);
vec.Y += (ctz.Y - vel.Y) * (PID_D);
}
@@ -1305,9 +1299,9 @@ namespace OpenSim.Region.Physics.OdePlugin
vec.X -= breakfactor * vel.X;
vec.Y -= breakfactor * vel.Y;
if (flying)
- vec.Z -= breakfactor * vel.Z;
+ vec.Z -= 0.5f * breakfactor * vel.Z;
else
- vec.Z -= .5f* m_mass * vel.Z;
+ vec.Z -= .16f* m_mass * vel.Z;
}
if (flying)
@@ -1687,9 +1681,9 @@ namespace OpenSim.Region.Physics.OdePlugin
_zeroFlag = false;
_target_velocity = Vector3.Zero;
m_freemove = true;
- m_colliderfilter = -2;
- m_colliderObjectfilter = -2;
- m_colliderGroundfilter = -2;
+ m_colliderfilter = -1;
+ m_colliderObjectfilter = -1;
+ m_colliderGroundfilter = -1;
m_iscolliding = false;
m_iscollidingGround = false;
--
cgit v1.1