Remove duplicated avatar height calculation in lsl functions.
Use height calculation in Basic Physics and Physics of Simplicity so that avatars larger than the default walk with straight legs and shorter walk on the ground.0.6.1-post-fixes
parent
d1841ca94d
commit
098f16fe31
|
@ -152,7 +152,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
|
|||
actor.Position.X = 255.9F;
|
||||
}
|
||||
|
||||
float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 1.0f;
|
||||
float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + actor.Size.Z;
|
||||
if (actor.Flying)
|
||||
{
|
||||
if (actor.Position.Z + (actor.Velocity.Z*timeStep) <
|
||||
|
@ -210,15 +210,16 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
|
|||
private PhysicsVector _position;
|
||||
private PhysicsVector _velocity;
|
||||
private PhysicsVector _acceleration;
|
||||
private PhysicsVector _size;
|
||||
private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero;
|
||||
private bool flying;
|
||||
private bool iscolliding;
|
||||
|
||||
public BasicActor()
|
||||
{
|
||||
_velocity = new PhysicsVector();
|
||||
_position = new PhysicsVector();
|
||||
_acceleration = new PhysicsVector();
|
||||
_size = new PhysicsVector();
|
||||
}
|
||||
|
||||
public override int PhysicsActorType
|
||||
|
@ -315,8 +316,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
|
|||
|
||||
public override PhysicsVector Size
|
||||
{
|
||||
get { return PhysicsVector.Zero; }
|
||||
set { }
|
||||
get { return _size; }
|
||||
set {
|
||||
_size = value;
|
||||
_size.Z = _size.Z / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public override PrimitiveBaseShape Shape
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
private PhysicsVector _position;
|
||||
public PhysicsVector _velocity;
|
||||
public PhysicsVector _target_velocity = PhysicsVector.Zero;
|
||||
public PhysicsVector _size = PhysicsVector.Zero;
|
||||
private PhysicsVector _acceleration;
|
||||
private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero;
|
||||
private bool flying;
|
||||
|
@ -144,8 +145,12 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
|
||||
public override PhysicsVector Size
|
||||
{
|
||||
get { return new PhysicsVector(0.5f, 0.5f, 1.0f); }
|
||||
set { }
|
||||
get { return _size; }
|
||||
set
|
||||
{
|
||||
_size = value;
|
||||
_size.Z = _size.Z / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public override float Mass
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X];
|
||||
if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2)
|
||||
{
|
||||
character.Position.Z = terrainheight + 1.0f;
|
||||
character.Position.Z = terrainheight + character.Size.Z;
|
||||
forcedZ = true;
|
||||
}
|
||||
else
|
||||
|
@ -184,7 +184,10 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
character.Position.Z = oldposZ; // first try Z axis
|
||||
if (isCollidingWithPrim(character))
|
||||
{
|
||||
character.Position.Z = oldposZ + 0.4f; // try harder
|
||||
character.Position.Z = oldposZ + character.Size.Z / 4.4f; // try harder
|
||||
if (isCollidingWithPrim(character))
|
||||
{
|
||||
character.Position.Z = oldposZ + character.Size.Z / 2.2f; // try very hard
|
||||
if (isCollidingWithPrim(character))
|
||||
{
|
||||
character.Position.X = oldposX;
|
||||
|
@ -213,6 +216,11 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
forcedZ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forcedZ = true;
|
||||
}
|
||||
}
|
||||
|
||||
character.Position.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
|
||||
character.Position.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
|
||||
|
|
|
@ -5040,27 +5040,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
else
|
||||
{
|
||||
agentSize = new LSL_Vector(0.45, 0.6, calculateAgentHeight(avatar));
|
||||
agentSize = new LSL_Vector(0.45, 0.6, avatar.Appearance.AvatarHeight);
|
||||
}
|
||||
return agentSize;
|
||||
}
|
||||
|
||||
private float calculateAgentHeight(ScenePresence avatar)
|
||||
{
|
||||
byte[] parms = avatar.Appearance.VisualParams;
|
||||
// The values here were arrived at from experimentation with the sliders
|
||||
// in edit appearance in SL to find the ones that affected the height and how
|
||||
// much they affected it.
|
||||
float avatarHeight = 1.23077f // Shortest possible avatar height
|
||||
+ 0.516945f * (float)parms[25] / 255.0f // Body height
|
||||
+ 0.072514f * (float)parms[120] / 255.0f // Head size
|
||||
+ 0.3836f * (float)parms[125] / 255.0f // Leg length
|
||||
+ 0.08f * (float)parms[77] / 255.0f // Shoe heel height
|
||||
+ 0.07f * (float)parms[78] / 255.0f // Shoe platform height
|
||||
+ 0.076f * (float)parms[148] / 255.0f; // Neck length
|
||||
return avatarHeight;
|
||||
}
|
||||
|
||||
public LSL_Integer llSameGroup(string agent)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
@ -6600,14 +6584,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (presence.Animations.DefaultAnimation.AnimID == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"])
|
||||
{
|
||||
// This is for ground sitting avatars
|
||||
float height = calculateAgentHeight(presence) / 2.66666667f;
|
||||
float height = presence.Appearance.AvatarHeight / 2.66666667f;
|
||||
lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
|
||||
upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is for standing/flying avatars
|
||||
float height = calculateAgentHeight(presence) / 2.0f;
|
||||
float height = presence.Appearance.AvatarHeight / 2.0f;
|
||||
lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
|
||||
upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue