Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork

avinationmerge
ubit 2012-12-11 23:55:34 +01:00
commit 7d2dad0ffa
4 changed files with 109 additions and 89 deletions

View File

@ -2028,7 +2028,7 @@ namespace OpenSim.Data.MySQL
using (MySqlCommand cmd = dbcon.CreateCommand()) using (MySqlCommand cmd = dbcon.CreateCommand())
{ {
cmd.CommandText = "select UUID from prims where RegionUUID = ?RegionUUID"; cmd.CommandText = "select UUID from prims where RegionUUID = ?RegionUUID and SceneGroupID = UUID";
cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
using (IDataReader reader = ExecuteReader(cmd)) using (IDataReader reader = ExecuteReader(cmd))

View File

@ -147,15 +147,9 @@ namespace OpenSim.Region.Physics.Manager
return ret; return ret;
} }
public virtual PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size,float feetOffset, bool isFlying) public virtual PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying)
{ {
return null; PhysicsActor ret = AddAvatar(localID, avName, position, size, isFlying);
}
public virtual PhysicsActor AddAvatar(uint localID,string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying)
{
PhysicsActor ret = AddAvatar(avName, position, size,feetOffset, isFlying);
if (ret != null) ret.LocalID = localID;
return ret; return ret;
} }

View File

@ -80,6 +80,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private Vector3 m_rotationalVelocity; private Vector3 m_rotationalVelocity;
private Vector3 m_size; private Vector3 m_size;
private Quaternion m_orientation; private Quaternion m_orientation;
private Quaternion m_orientation2D;
private float m_mass = 80f; private float m_mass = 80f;
public float m_density = 60f; public float m_density = 60f;
private bool m_pidControllerActive = true; private bool m_pidControllerActive = true;
@ -165,9 +166,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_uuid = UUID.Random();
m_localID = localID;
timeStep = parent_scene.ODE_STEPSIZE; timeStep = parent_scene.ODE_STEPSIZE;
invtimeStep = 1 / timeStep; invtimeStep = 1 / timeStep;
@ -206,6 +208,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_feetOffset = pfeetOffset; m_feetOffset = pfeetOffset;
m_orientation = Quaternion.Identity; m_orientation = Quaternion.Identity;
m_orientation2D = Quaternion.Identity;
m_density = density; m_density = density;
// force lower density for testing // force lower density for testing
@ -648,7 +651,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// fakeori = value; // fakeori = value;
// givefakeori++; // givefakeori++;
value.Normalize(); value.Normalize();
AddChange(changes.Orientation, value); AddChange(changes.Orientation, value);
} }
@ -969,78 +971,86 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_collisionException) if (m_collisionException)
return false; return false;
Vector3 offset;
if (me == bbox) // if moving fast if (me == bbox) // if moving fast
{ {
// force a full inelastic collision // force a full inelastic collision
m_collisionException = true; m_collisionException = true;
Vector3 off = m_size * 0.5f; offset = m_size * m_orientation2D;
off.X += contact.depth;
off.Y += contact.depth; offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
off.Z += 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) if (reverse)
{ {
off.X *= -contact.normal.X; offset.X *= -contact.normal.X;
off.Y *= -contact.normal.Y; offset.Y *= -contact.normal.Y;
off.Z *= -contact.normal.Z; offset.Z *= -contact.normal.Z;
} }
else else
{ {
off.X *= contact.normal.X; offset.X *= contact.normal.X;
off.Y *= contact.normal.Y; offset.Y *= contact.normal.Y;
off.Z *= contact.normal.Z; offset.Z *= contact.normal.Z;
} }
off.X += contact.pos.X; offset.X += contact.pos.X;
off.Y += contact.pos.Y; offset.Y += contact.pos.Y;
off.Z += contact.pos.Z; offset.Z += contact.pos.Z;
_position = off; _position = offset;
return false; return false;
} }
if (me == topbox) // keep a box head offset.X = contact.pos.X - _position.X;
return true; offset.Y = contact.pos.Y - _position.Y;
float t; if (me == topbox)
float offx = contact.pos.X - _position.X; {
float offy = contact.pos.Y - _position.Y; 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 (me == midbox)
{ {
if (Math.Abs(contact.normal.Z) > 0.95f) if (Math.Abs(contact.normal.Z) > 0.95f)
{ offset.Z = contact.pos.Z - _position.Z;
float nz = contact.normal.Z; else
if (!reverse) offset.Z = contact.normal.Z;
nz = -nz;
if (nz > 0) offset.Normalize();
return true; // missed head TODO
// missed feet collision?
return true;
}
t = offx * offx + offy * offy;
t = (float)Math.Sqrt(t);
t = 1 / t;
offx *= t;
offy *= t;
if (reverse) if (reverse)
{ {
contact.normal.X = offx; contact.normal.X = offset.X;
contact.normal.Y = offy; contact.normal.Y = offset.Y;
contact.normal.Z = offset.Z;
} }
else else
{ {
contact.normal.X = -offx; contact.normal.X = -offset.X;
contact.normal.Y = -offy; contact.normal.Y = -offset.Y;
contact.normal.Z = -offset.Z;
} }
contact.normal.Z = 0;
return true; return true;
} }
@ -1062,39 +1072,33 @@ namespace OpenSim.Region.Physics.OdePlugin
return true; return true;
} }
offset.Z = h - feetOff; // distance from top of feetbox
float offz = h - feetOff; // distance from top of feetbox if (offset.Z > 0)
if (offz > 0)
return false; return false;
if (offz > -0.01) if (offset.Z > -0.01)
{ {
offx = 0; offset.X = 0;
offy = 0; offset.Y = 0;
offz = -1.0f; offset.Z = -1.0f;
} }
else else
{ {
t = offx * offx + offy * offy + offz * offz; offset.Normalize();
t = (float)Math.Sqrt(t);
t = 1 / t;
offx *= t;
offy *= t;
offz *= t;
} }
if (reverse) if (reverse)
{ {
contact.normal.X = offx; contact.normal.X = offset.X;
contact.normal.Y = offy; contact.normal.Y = offset.Y;
contact.normal.Z = offz; contact.normal.Z = offset.Z;
} }
else else
{ {
contact.normal.X = -offx; contact.normal.X = -offset.X;
contact.normal.Y = -offy; contact.normal.Y = -offset.Y;
contact.normal.Z = -offz; contact.normal.Z = -offset.Z;
} }
feetcollision = true; feetcollision = true;
if (h < boneOff) if (h < boneOff)
@ -1124,7 +1128,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float v = _velocity.Length(); float v = _velocity.Length();
if (v != 0) if (v != 0)
{ {
v = 6.0f / v; v = 5.0f / v;
_velocity = _velocity * v; _velocity = _velocity * v;
d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
} }
@ -1140,10 +1144,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// so force it back to identity // so force it back to identity
d.Quaternion qtmp; d.Quaternion qtmp;
qtmp.W = m_orientation.W; qtmp.W = m_orientation2D.W;
qtmp.X = m_orientation.X; qtmp.X = m_orientation2D.X;
qtmp.Y = m_orientation.Y; qtmp.Y = m_orientation2D.Y;
qtmp.Z = m_orientation.Z; qtmp.Z = m_orientation2D.Z;
d.BodySetQuaternion(Body, ref qtmp); d.BodySetQuaternion(Body, ref qtmp);
if (m_pidControllerActive == false) if (m_pidControllerActive == false)
@ -1209,7 +1213,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.AABB aabb; d.AABB aabb;
d.GeomGetAABB(feetbox, out 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; Vector3 posch = localpos;
float ftmp; float ftmp;
@ -1252,7 +1256,7 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.PenetrationDepth = depth; contact.PenetrationDepth = depth;
contact.Position.X = localpos.X; contact.Position.X = localpos.X;
contact.Position.Y = localpos.Y; contact.Position.Y = localpos.Y;
contact.Position.Z = chrminZ; contact.Position.Z = terrainheight;
contact.SurfaceNormal.X = 0.0f; contact.SurfaceNormal.X = 0.0f;
contact.SurfaceNormal.Y = 0.0f; contact.SurfaceNormal.Y = 0.0f;
contact.SurfaceNormal.Z = -1f; contact.SurfaceNormal.Z = -1f;
@ -1676,14 +1680,36 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeOrientation(Quaternion newOri) private void changeOrientation(Quaternion 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(); d.Quaternion myrot = new d.Quaternion();
myrot.X = newOri.X; myrot.X = m_orientation2D.X;
myrot.Y = newOri.Y; myrot.Y = m_orientation2D.Y;
myrot.Z = newOri.Z; myrot.Z = m_orientation2D.Z;
myrot.W = newOri.W; myrot.W = m_orientation2D.W;
float t = d.JointGetAMotorAngle(Amotor, 2); d.BodySetQuaternion(Body, ref myrot);
d.BodySetQuaternion(Body,ref myrot); }
m_orientation = newOri;
} }
private void changeVelocity(Vector3 newVel) private void changeVelocity(Vector3 newVel)

View File

@ -1251,13 +1251,13 @@ namespace OpenSim.Region.Physics.OdePlugin
#region Add/Remove Entities #region Add/Remove Entities
public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying)
{ {
Vector3 pos; Vector3 pos;
pos.X = position.X; pos.X = position.X;
pos.Y = position.Y; pos.Y = position.Y;
pos.Z = position.Z; pos.Z = position.Z;
OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun); OdeCharacter newAv = new OdeCharacter(localID,avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun);
newAv.Flying = isFlying; newAv.Flying = isFlying;
newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset;