From 3b953b79981b2582311fe7105b830ea2d3b183dd Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 2 Sep 2025 12:30:30 +0200 Subject: [PATCH] =?UTF-8?q?Ajustar=20par=C3=A1metros=20de=20fricci=C3=B3n?= =?UTF-8?q?=20est=C3=A1tica=20y=20din=C3=A1mica=20en=20la=20simulaci=C3=B3?= =?UTF-8?q?n=20de=20botellas,=20mejorando=20el=20comportamiento=20en=20sit?= =?UTF-8?q?uaciones=20de=20contacto.=20Implementar=20l=C3=ADmites=20de=20v?= =?UTF-8?q?elocidad=20en=20el=20plano=20XY=20y=20corregir=20la=20l=C3=B3gi?= =?UTF-8?q?ca=20de=20actualizaci=C3=B3n=20de=20posici=C3=B3n=20para=20evit?= =?UTF-8?q?ar=20elevaciones=20excesivas.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Simulacion/BEPU.cs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) 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