diff --git a/Simulacion/BEPU.cs b/Simulacion/BEPU.cs index 9ce4ec7..dd8d129 100644 --- a/Simulacion/BEPU.cs +++ b/Simulacion/BEPU.cs @@ -340,8 +340,8 @@ namespace CtrEditor.Simulacion float slipSpeedThreshold = transportVelocity.Length()*0.85f; // m/s - umbral para cambiar de fricción estática a dinámica const float heatupRate = 1f; // Qué tan rápido sube HighSlippery const float cooldownRate = 1f; // Qué tan rápido baja HighSlippery - const float staticFriction = 0.80f; - const float dynamicFriction = 0.50f; + const float staticFriction = 0.50f; + const float dynamicFriction = 0.30f; // Sistema de heatup/cooldown para HighSlippery if (slipSpeed > slipSpeedThreshold) // && botella.ContactPressure > 0 @@ -396,8 +396,8 @@ namespace CtrEditor.Simulacion float slipSpeedThreshold = curveVelocityAtPoint.Length() * 0.85f; // m/s const float heatupRate = 1f; // Qué tan rápido sube HighSlippery en curvas const float cooldownRate = 1f; // Qué tan rápido baja HighSlippery en curvas - const float staticFriction = 0.80f; - const float dynamicFriction = 0.50f; + const float staticFriction = 0.50f; + const float dynamicFriction = 0.30f; // Sistema de heatup/cooldown para HighSlippery if (slipSpeed > slipSpeedThreshold) // && botella.ContactPressure > 0 @@ -411,7 +411,7 @@ namespace CtrEditor.Simulacion return dynamicFriction / 10; else { - if (botella.HighSlippery > 3f) + if (botella.HighSlippery > 1f) return dynamicFriction; else return staticFriction; @@ -828,20 +828,33 @@ namespace CtrEditor.Simulacion { var body = simulation.Bodies.GetBodyReference(botella.BodyHandle); var velocity = body.Velocity; - var position = body.Pose.Position; + var pose = body.Pose; // CONFIGURACIÓN DE LÍMITES const float maxUpwardVelocity = 0f; // Velocidad Z máxima hacia arriba (m/s) + const float maxXYVelocity = 1.0f; // Límite de velocidad en el plano XY (m/s) // LIMITAR VELOCIDADES Z EXCESIVAS if (velocity.Linear.Z > maxUpwardVelocity) { // Cancelar velocidades hacia arriba excesivas (anti-elevación) velocity.Linear.Z = 0; - position.Z = botella.Radius + simBase.zPos_Transporte + simBase.zAltura_Transporte; - body.Velocity = velocity; - body.Pose = position; + pose.Position.Z = botella.Radius + simBase.zPos_Transporte + simBase.zAltura_Transporte; + body.Pose = pose; // Se actualiza la pose completa } + + // LIMITAR VELOCIDAD MÁXIMA EN PLANO XY + var velocityXY = new Vector2(velocity.Linear.X, velocity.Linear.Y); + if (velocityXY.LengthSquared() > maxXYVelocity * maxXYVelocity) + { + var speedXY = velocityXY.Length(); + var scale = maxXYVelocity / speedXY; + velocity.Linear.X *= scale; + velocity.Linear.Y *= scale; + } + + // Aplicar siempre la velocidad, ya que puede haber sido modificada en Z o XY + body.Velocity = velocity; //// CONTROL DE POSICIÓN EXTREMA //// Si la botella está muy por encima del nivel normal, aplicar corrección