diff options
author | idb | 2008-12-01 00:49:36 +0000 |
---|---|---|
committer | idb | 2008-12-01 00:49:36 +0000 |
commit | 098f16fe3192ef17e7c749a70ea0607a22ae55fa (patch) | |
tree | f107a86180f4ebaf7103b466f05c2faeb119cb24 | |
parent | Mantis #2584 (again) (diff) | |
download | opensim-SC-098f16fe3192ef17e7c749a70ea0607a22ae55fa.zip opensim-SC-098f16fe3192ef17e7c749a70ea0607a22ae55fa.tar.gz opensim-SC-098f16fe3192ef17e7c749a70ea0607a22ae55fa.tar.bz2 opensim-SC-098f16fe3192ef17e7c749a70ea0607a22ae55fa.tar.xz |
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.
4 files changed, 37 insertions, 36 deletions
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 | |||
152 | actor.Position.X = 255.9F; | 152 | actor.Position.X = 255.9F; |
153 | } | 153 | } |
154 | 154 | ||
155 | float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 1.0f; | 155 | float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + actor.Size.Z; |
156 | if (actor.Flying) | 156 | if (actor.Flying) |
157 | { | 157 | { |
158 | if (actor.Position.Z + (actor.Velocity.Z*timeStep) < | 158 | if (actor.Position.Z + (actor.Velocity.Z*timeStep) < |
@@ -210,15 +210,16 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
210 | private PhysicsVector _position; | 210 | private PhysicsVector _position; |
211 | private PhysicsVector _velocity; | 211 | private PhysicsVector _velocity; |
212 | private PhysicsVector _acceleration; | 212 | private PhysicsVector _acceleration; |
213 | private PhysicsVector _size; | ||
213 | private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; | 214 | private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; |
214 | private bool flying; | 215 | private bool flying; |
215 | private bool iscolliding; | 216 | private bool iscolliding; |
216 | |||
217 | public BasicActor() | 217 | public BasicActor() |
218 | { | 218 | { |
219 | _velocity = new PhysicsVector(); | 219 | _velocity = new PhysicsVector(); |
220 | _position = new PhysicsVector(); | 220 | _position = new PhysicsVector(); |
221 | _acceleration = new PhysicsVector(); | 221 | _acceleration = new PhysicsVector(); |
222 | _size = new PhysicsVector(); | ||
222 | } | 223 | } |
223 | 224 | ||
224 | public override int PhysicsActorType | 225 | public override int PhysicsActorType |
@@ -315,8 +316,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
315 | 316 | ||
316 | public override PhysicsVector Size | 317 | public override PhysicsVector Size |
317 | { | 318 | { |
318 | get { return PhysicsVector.Zero; } | 319 | get { return _size; } |
319 | set { } | 320 | set { |
321 | _size = value; | ||
322 | _size.Z = _size.Z / 2.0f; | ||
323 | } | ||
320 | } | 324 | } |
321 | 325 | ||
322 | public override PrimitiveBaseShape Shape | 326 | 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 | |||
39 | private PhysicsVector _position; | 39 | private PhysicsVector _position; |
40 | public PhysicsVector _velocity; | 40 | public PhysicsVector _velocity; |
41 | public PhysicsVector _target_velocity = PhysicsVector.Zero; | 41 | public PhysicsVector _target_velocity = PhysicsVector.Zero; |
42 | public PhysicsVector _size = PhysicsVector.Zero; | ||
42 | private PhysicsVector _acceleration; | 43 | private PhysicsVector _acceleration; |
43 | private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; | 44 | private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; |
44 | private bool flying; | 45 | private bool flying; |
@@ -144,8 +145,12 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
144 | 145 | ||
145 | public override PhysicsVector Size | 146 | public override PhysicsVector Size |
146 | { | 147 | { |
147 | get { return new PhysicsVector(0.5f, 0.5f, 1.0f); } | 148 | get { return _size; } |
148 | set { } | 149 | set |
150 | { | ||
151 | _size = value; | ||
152 | _size.Z = _size.Z / 2.0f; | ||
153 | } | ||
149 | } | 154 | } |
150 | 155 | ||
151 | public override float Mass | 156 | 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 | |||
167 | float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X]; | 167 | float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X]; |
168 | if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) | 168 | if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) |
169 | { | 169 | { |
170 | character.Position.Z = terrainheight + 1.0f; | 170 | character.Position.Z = terrainheight + character.Size.Z; |
171 | forcedZ = true; | 171 | forcedZ = true; |
172 | } | 172 | } |
173 | else | 173 | else |
@@ -184,23 +184,31 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
184 | character.Position.Z = oldposZ; // first try Z axis | 184 | character.Position.Z = oldposZ; // first try Z axis |
185 | if (isCollidingWithPrim(character)) | 185 | if (isCollidingWithPrim(character)) |
186 | { | 186 | { |
187 | character.Position.Z = oldposZ + 0.4f; // try harder | 187 | character.Position.Z = oldposZ + character.Size.Z / 4.4f; // try harder |
188 | if (isCollidingWithPrim(character)) | 188 | if (isCollidingWithPrim(character)) |
189 | { | 189 | { |
190 | character.Position.X = oldposX; | 190 | character.Position.Z = oldposZ + character.Size.Z / 2.2f; // try very hard |
191 | character.Position.Y = oldposY; | ||
192 | character.Position.Z = oldposZ; | ||
193 | |||
194 | character.Position.X += character._target_velocity.X * timeStep; | ||
195 | if (isCollidingWithPrim(character)) | 191 | if (isCollidingWithPrim(character)) |
196 | { | 192 | { |
197 | character.Position.X = oldposX; | 193 | character.Position.X = oldposX; |
194 | character.Position.Y = oldposY; | ||
195 | character.Position.Z = oldposZ; | ||
196 | |||
197 | character.Position.X += character._target_velocity.X * timeStep; | ||
198 | if (isCollidingWithPrim(character)) | ||
199 | { | ||
200 | character.Position.X = oldposX; | ||
201 | } | ||
202 | |||
203 | character.Position.Y += character._target_velocity.Y * timeStep; | ||
204 | if (isCollidingWithPrim(character)) | ||
205 | { | ||
206 | character.Position.Y = oldposY; | ||
207 | } | ||
198 | } | 208 | } |
199 | 209 | else | |
200 | character.Position.Y += character._target_velocity.Y * timeStep; | ||
201 | if (isCollidingWithPrim(character)) | ||
202 | { | 210 | { |
203 | character.Position.Y = oldposY; | 211 | forcedZ = true; |
204 | } | 212 | } |
205 | } | 213 | } |
206 | else | 214 | 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 | |||
5040 | } | 5040 | } |
5041 | else | 5041 | else |
5042 | { | 5042 | { |
5043 | agentSize = new LSL_Vector(0.45, 0.6, calculateAgentHeight(avatar)); | 5043 | agentSize = new LSL_Vector(0.45, 0.6, avatar.Appearance.AvatarHeight); |
5044 | } | 5044 | } |
5045 | return agentSize; | 5045 | return agentSize; |
5046 | } | 5046 | } |
5047 | 5047 | ||
5048 | private float calculateAgentHeight(ScenePresence avatar) | ||
5049 | { | ||
5050 | byte[] parms = avatar.Appearance.VisualParams; | ||
5051 | // The values here were arrived at from experimentation with the sliders | ||
5052 | // in edit appearance in SL to find the ones that affected the height and how | ||
5053 | // much they affected it. | ||
5054 | float avatarHeight = 1.23077f // Shortest possible avatar height | ||
5055 | + 0.516945f * (float)parms[25] / 255.0f // Body height | ||
5056 | + 0.072514f * (float)parms[120] / 255.0f // Head size | ||
5057 | + 0.3836f * (float)parms[125] / 255.0f // Leg length | ||
5058 | + 0.08f * (float)parms[77] / 255.0f // Shoe heel height | ||
5059 | + 0.07f * (float)parms[78] / 255.0f // Shoe platform height | ||
5060 | + 0.076f * (float)parms[148] / 255.0f; // Neck length | ||
5061 | return avatarHeight; | ||
5062 | } | ||
5063 | |||
5064 | public LSL_Integer llSameGroup(string agent) | 5048 | public LSL_Integer llSameGroup(string agent) |
5065 | { | 5049 | { |
5066 | m_host.AddScriptLPS(1); | 5050 | m_host.AddScriptLPS(1); |
@@ -6600,14 +6584,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6600 | if (presence.Animations.DefaultAnimation.AnimID == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 6584 | if (presence.Animations.DefaultAnimation.AnimID == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) |
6601 | { | 6585 | { |
6602 | // This is for ground sitting avatars | 6586 | // This is for ground sitting avatars |
6603 | float height = calculateAgentHeight(presence) / 2.66666667f; | 6587 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
6604 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | 6588 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); |
6605 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | 6589 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); |
6606 | } | 6590 | } |
6607 | else | 6591 | else |
6608 | { | 6592 | { |
6609 | // This is for standing/flying avatars | 6593 | // This is for standing/flying avatars |
6610 | float height = calculateAgentHeight(presence) / 2.0f; | 6594 | float height = presence.Appearance.AvatarHeight / 2.0f; |
6611 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | 6595 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); |
6612 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | 6596 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); |
6613 | } | 6597 | } |