mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
bug fix
This commit is contained in:
@@ -5526,6 +5526,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
private void ClampVectorForUint(ref Vector3 v, float max)
|
||||
{
|
||||
float a,b;
|
||||
|
||||
a = Math.Abs(v.X);
|
||||
b = Math.Abs(v.Y);
|
||||
if(b > a)
|
||||
a = b;
|
||||
b= Math.Abs(v.Z);
|
||||
if(b > a)
|
||||
a = b;
|
||||
|
||||
if (a > max)
|
||||
{
|
||||
a = max / a;
|
||||
v.X *= a;
|
||||
v.Y *= a;
|
||||
v.Z *= a;
|
||||
}
|
||||
}
|
||||
|
||||
protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
|
||||
{
|
||||
@@ -5616,11 +5636,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
pos += 12;
|
||||
|
||||
// Velocity
|
||||
ClampVectorForUint(ref velocity, 128f);
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
|
||||
|
||||
// Acceleration
|
||||
ClampVectorForUint(ref acceleration, 64f);
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
|
||||
@@ -5632,6 +5654,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
|
||||
|
||||
// Angular Velocity
|
||||
ClampVectorForUint(ref angularVelocity, 64f);
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
|
||||
Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
|
||||
|
||||
Reference in New Issue
Block a user