From 3eee0e3d9bdd67bb90c41e9f9ea56e30d43667f3 Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 4 Jul 2025 23:20:53 +0200 Subject: [PATCH] =?UTF-8?q?Se=20ajust=C3=B3=20el=20coeficiente=20de=20fric?= =?UTF-8?q?ci=C3=B3n=20en=20m=C3=BAltiples=20secciones=20del=20archivo=20B?= =?UTF-8?q?EPU,=20reduci=C3=A9ndolo=20de=200.3f=20a=200.01f=20para=20mejor?= =?UTF-8?q?ar=20la=20simulaci=C3=B3n=20de=20transportes=20y=20curvas.=20Ad?= =?UTF-8?q?em=C3=A1s,=20se=20corrigi=C3=B3=20el=20acceso=20al=20factor=20d?= =?UTF-8?q?e=20conversi=C3=B3n=20de=20velocidad,=20reemplazando=20la=20con?= =?UTF-8?q?stante=20por=20una=20propiedad=20est=C3=A1tica=20en=20simBase.?= =?UTF-8?q?=20Se=20eliminaron=20m=C3=A9todos=20obsoletos=20relacionados=20?= =?UTF-8?q?con=20la=20configuraci=C3=B3n=20de=20velocidad=20en=20simCurve?= =?UTF-8?q?=20y=20simTransporte,=20optimizando=20la=20l=C3=B3gica=20de=20a?= =?UTF-8?q?ctualizaci=C3=B3n=20de=20motores.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Simulacion/BEPU.cs | 11 +++++------ Simulacion/simBase.cs | 5 ++++- Simulacion/simBotella.cs | 6 +++--- Simulacion/simCurve.cs | 18 ------------------ Simulacion/simTransporte.cs | 10 ---------- 5 files changed, 12 insertions(+), 38 deletions(-) diff --git a/Simulacion/BEPU.cs b/Simulacion/BEPU.cs index 5b6c272..0f0bd5c 100644 --- a/Simulacion/BEPU.cs +++ b/Simulacion/BEPU.cs @@ -140,7 +140,7 @@ namespace CtrEditor.Simulacion botella.CreateOrUpdateMotor(transport, direction, speed); //Fricción alta para transportes - pairMaterial.FrictionCoefficient = 0.3f; + pairMaterial.FrictionCoefficient = 0.01f; pairMaterial.MaximumRecoveryVelocity = 1f; pairMaterial.SpringSettings = new SpringSettings(80, 6); } @@ -151,11 +151,10 @@ namespace CtrEditor.Simulacion // ✅ CREAR O ACTUALIZAR MOTOR DINÁMICO INMEDIATAMENTE var direction = _simulationManager.CalculateCurveDirectionFromBottlePosition(curve, botella); - var speed = curve.SpeedMetersPerSecond; // ✅ CORREGIDO: Usar SpeedMetersPerSecond como simTransporte - botella.CreateOrUpdateMotor(curve, direction, speed); + botella.CreateOrUpdateMotor(curve, direction, curve.Speed); // Fricción alta para curvas - pairMaterial.FrictionCoefficient = 0.3f; + pairMaterial.FrictionCoefficient = 0.01f; pairMaterial.MaximumRecoveryVelocity = 1f; pairMaterial.SpringSettings = new SpringSettings(80, 6); } @@ -163,14 +162,14 @@ namespace CtrEditor.Simulacion else if (botella != null && (GetGuiaFromCollidable(pair.A) != null || GetGuiaFromCollidable(pair.B) != null)) { // Configuración específica para guías usando propiedades configurables - pairMaterial.FrictionCoefficient = 0.3f; + pairMaterial.FrictionCoefficient = 0.01f; pairMaterial.MaximumRecoveryVelocity = 1f; pairMaterial.SpringSettings = new SpringSettings(80, 6); } // Ajustes básicos para otras botellas else if (botella != null) { - pairMaterial.FrictionCoefficient = 0.3f; + pairMaterial.FrictionCoefficient = 0.01f; pairMaterial.MaximumRecoveryVelocity = 1f; pairMaterial.SpringSettings = new SpringSettings(80, 6); } diff --git a/Simulacion/simBase.cs b/Simulacion/simBase.cs index 6bef779..7faa89b 100644 --- a/Simulacion/simBase.cs +++ b/Simulacion/simBase.cs @@ -17,7 +17,10 @@ namespace CtrEditor.Simulacion protected SimulationManagerBEPU _simulationManager; // ✅ NUEVO: Referencia al manager // ✅ CORREGIDO: Restaurar factor de conversión correcto - public const float SPEED_CONVERSION_FACTOR = 1.55f; // Factor de conversión de velocidad interna a m/s - Para LinearAxisMotor es 0.5f + static public float SpeedConversionFactor + { + get => 60f; // Factor de conversión de velocidad interna a m/s + } // Constantes para las posiciones Z de los objetos 3D public const float zPos_Transporte = 0f; // Z de la parte baja diff --git a/Simulacion/simBotella.cs b/Simulacion/simBotella.cs index 92e3c42..2615412 100644 --- a/Simulacion/simBotella.cs +++ b/Simulacion/simBotella.cs @@ -194,14 +194,14 @@ namespace CtrEditor.Simulacion else { // ✅ MISMO OBJETO: Solo actualizar velocidad - UpdateMotorSpeed(direction, speed / simBase.SPEED_CONVERSION_FACTOR); + UpdateMotorSpeed(direction, speed / simBase.SpeedConversionFactor); return; } // ✅ CREAR NUEVO MOTOR SI ES NECESARIO if (needsNewMotor && target != null) { - CreateMotorForTarget(target, direction, speed / simBase.SPEED_CONVERSION_FACTOR); + CreateMotorForTarget(target, direction, speed / simBase.SpeedConversionFactor); } } catch (Exception ex) @@ -247,7 +247,7 @@ namespace CtrEditor.Simulacion LocalOffsetB = Vector3.Zero, // Botella LocalAxis = tangentDir, // ✅ CORREGIDO: Usar la dirección tangencial calculada TargetVelocity = speed, // ✅ CORREGIDO: Usar la velocidad directamente - Settings = new MotorSettings(Math.Max(_mass * 20f, 8f), 4f) + Settings = new MotorSettings(Math.Max(_mass * 20f, 8f), 0f) }; // ✅ CONECTAR BOTELLA CON EL TARGET (transporte o curva) diff --git a/Simulacion/simCurve.cs b/Simulacion/simCurve.cs index ac56a8d..e399c6a 100644 --- a/Simulacion/simCurve.cs +++ b/Simulacion/simCurve.cs @@ -35,10 +35,6 @@ namespace CtrEditor.Simulacion // ✅ EVENTO para actualización de motores public event Action OnSpeedChanged; - // ✅ NUEVO: Propiedad para velocidad convertida (similar a simTransporte) - public float SpeedMetersPerSecond { get; private set; } - - // ✅ NUEVO: Almacenar triángulos creados para acceso directo private Triangle[] _storedTriangles; @@ -68,29 +64,15 @@ namespace CtrEditor.Simulacion // ✅ SIMPLIFICADO: Crear la curva directamente Create(innerRadius, outerRadius, startAngle, endAngle, topLeft, 0); - - // ✅ NUEVO: Inicializar SpeedMetersPerSecond - SpeedMetersPerSecond = Speed / simBase.SPEED_CONVERSION_FACTOR; } // ✅ SIMPLIFICADO: Configurar velocidad angular para AngularAxisMotor public void SetSpeed(float speed) { Speed = speed; // Velocidad angular directa (sin inversión) - SpeedMetersPerSecond = Speed / simBase.SPEED_CONVERSION_FACTOR; // ✅ NUEVO: Calcular velocidad convertida OnSpeedChanged?.Invoke(this); } - /// - /// ✅ NUEVO: Configura la velocidad de la curva en metros por segundo - /// Valores positivos mueven en sentido horario, negativos en sentido antihorario - /// - /// Velocidad en m/s (típicamente entre -5.0 y 5.0) - public void SetCurveSpeed(float speedMeterPerSecond) - { - SetSpeed(speedMeterPerSecond * simBase.SPEED_CONVERSION_FACTOR); - } - /// /// ✅ NUEVO: Detiene completamente la curva /// diff --git a/Simulacion/simTransporte.cs b/Simulacion/simTransporte.cs index 9e4923b..72eb83d 100644 --- a/Simulacion/simTransporte.cs +++ b/Simulacion/simTransporte.cs @@ -159,16 +159,6 @@ namespace CtrEditor.Simulacion OnSpeedChanged?.Invoke(this); } - /// - /// Configura la velocidad del transporte en metros por segundo - /// Valores positivos mueven en la dirección del transporte, negativos en dirección opuesta - /// - /// Velocidad en m/s (típicamente entre -5.0 y 5.0) - public void SetTransportSpeed(float speedMeterPerSecond) - { - SetSpeed(speedMeterPerSecond * simBase.SPEED_CONVERSION_FACTOR); - } - /// /// Detiene completamente el transporte ///