From 098f16fe3192ef17e7c749a70ea0607a22ae55fa Mon Sep 17 00:00:00 2001 From: idb Date: Mon, 1 Dec 2008 00:49:36 +0000 Subject: 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. --- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 12 ++++++--- OpenSim/Region/Physics/POSPlugin/POSCharacter.cs | 9 +++++-- OpenSim/Region/Physics/POSPlugin/POSScene.cs | 30 ++++++++++++++-------- .../Shared/Api/Implementation/LSL_Api.cs | 22 +++------------- 4 files changed, 37 insertions(+), 36 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index cacb9eb..6a27f46 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -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 diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs index a9ddf27..8c185fc 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs @@ -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 diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/Physics/POSPlugin/POSScene.cs index 9771a62..9a4e92f 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSScene.cs @@ -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,23 +184,31 @@ 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.X = oldposX; - character.Position.Y = oldposY; - character.Position.Z = oldposZ; - - character.Position.X += character._target_velocity.X * timeStep; + character.Position.Z = oldposZ + character.Size.Z / 2.2f; // try very hard if (isCollidingWithPrim(character)) { character.Position.X = oldposX; + character.Position.Y = oldposY; + character.Position.Z = oldposZ; + + character.Position.X += character._target_velocity.X * timeStep; + if (isCollidingWithPrim(character)) + { + character.Position.X = oldposX; + } + + character.Position.Y += character._target_velocity.Y * timeStep; + if (isCollidingWithPrim(character)) + { + character.Position.Y = oldposY; + } } - - character.Position.Y += character._target_velocity.Y * timeStep; - if (isCollidingWithPrim(character)) + else { - character.Position.Y = oldposY; + forcedZ = true; } } else diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 17dca98..90b2583 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -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); } -- cgit v1.1