Se ajustó el coeficiente de fricción en múltiples secciones del archivo BEPU, reduciéndolo de 0.3f a 0.01f para mejorar la simulación de transportes y curvas. Además, se corrigió el acceso al factor de conversión de velocidad, reemplazando la constante por una propiedad estática en simBase. Se eliminaron métodos obsoletos relacionados con la configuración de velocidad en simCurve y simTransporte, optimizando la lógica de actualización de motores.

This commit is contained in:
Miguel 2025-07-04 23:20:53 +02:00
parent a6cbd8c4ab
commit 3eee0e3d9b
5 changed files with 12 additions and 38 deletions

View File

@ -140,7 +140,7 @@ namespace CtrEditor.Simulacion
botella.CreateOrUpdateMotor(transport, direction, speed); botella.CreateOrUpdateMotor(transport, direction, speed);
//Fricción alta para transportes //Fricción alta para transportes
pairMaterial.FrictionCoefficient = 0.3f; pairMaterial.FrictionCoefficient = 0.01f;
pairMaterial.MaximumRecoveryVelocity = 1f; pairMaterial.MaximumRecoveryVelocity = 1f;
pairMaterial.SpringSettings = new SpringSettings(80, 6); pairMaterial.SpringSettings = new SpringSettings(80, 6);
} }
@ -151,11 +151,10 @@ namespace CtrEditor.Simulacion
// ✅ CREAR O ACTUALIZAR MOTOR DINÁMICO INMEDIATAMENTE // ✅ CREAR O ACTUALIZAR MOTOR DINÁMICO INMEDIATAMENTE
var direction = _simulationManager.CalculateCurveDirectionFromBottlePosition(curve, botella); var direction = _simulationManager.CalculateCurveDirectionFromBottlePosition(curve, botella);
var speed = curve.SpeedMetersPerSecond; // ✅ CORREGIDO: Usar SpeedMetersPerSecond como simTransporte botella.CreateOrUpdateMotor(curve, direction, curve.Speed);
botella.CreateOrUpdateMotor(curve, direction, speed);
// Fricción alta para curvas // Fricción alta para curvas
pairMaterial.FrictionCoefficient = 0.3f; pairMaterial.FrictionCoefficient = 0.01f;
pairMaterial.MaximumRecoveryVelocity = 1f; pairMaterial.MaximumRecoveryVelocity = 1f;
pairMaterial.SpringSettings = new SpringSettings(80, 6); 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)) else if (botella != null && (GetGuiaFromCollidable(pair.A) != null || GetGuiaFromCollidable(pair.B) != null))
{ {
// Configuración específica para guías usando propiedades configurables // Configuración específica para guías usando propiedades configurables
pairMaterial.FrictionCoefficient = 0.3f; pairMaterial.FrictionCoefficient = 0.01f;
pairMaterial.MaximumRecoveryVelocity = 1f; pairMaterial.MaximumRecoveryVelocity = 1f;
pairMaterial.SpringSettings = new SpringSettings(80, 6); pairMaterial.SpringSettings = new SpringSettings(80, 6);
} }
// Ajustes básicos para otras botellas // Ajustes básicos para otras botellas
else if (botella != null) else if (botella != null)
{ {
pairMaterial.FrictionCoefficient = 0.3f; pairMaterial.FrictionCoefficient = 0.01f;
pairMaterial.MaximumRecoveryVelocity = 1f; pairMaterial.MaximumRecoveryVelocity = 1f;
pairMaterial.SpringSettings = new SpringSettings(80, 6); pairMaterial.SpringSettings = new SpringSettings(80, 6);
} }

View File

@ -17,7 +17,10 @@ namespace CtrEditor.Simulacion
protected SimulationManagerBEPU _simulationManager; // ✅ NUEVO: Referencia al manager protected SimulationManagerBEPU _simulationManager; // ✅ NUEVO: Referencia al manager
// ✅ CORREGIDO: Restaurar factor de conversión correcto // ✅ 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 // Constantes para las posiciones Z de los objetos 3D
public const float zPos_Transporte = 0f; // Z de la parte baja public const float zPos_Transporte = 0f; // Z de la parte baja

View File

@ -194,14 +194,14 @@ namespace CtrEditor.Simulacion
else else
{ {
// ✅ MISMO OBJETO: Solo actualizar velocidad // ✅ MISMO OBJETO: Solo actualizar velocidad
UpdateMotorSpeed(direction, speed / simBase.SPEED_CONVERSION_FACTOR); UpdateMotorSpeed(direction, speed / simBase.SpeedConversionFactor);
return; return;
} }
// ✅ CREAR NUEVO MOTOR SI ES NECESARIO // ✅ CREAR NUEVO MOTOR SI ES NECESARIO
if (needsNewMotor && target != null) if (needsNewMotor && target != null)
{ {
CreateMotorForTarget(target, direction, speed / simBase.SPEED_CONVERSION_FACTOR); CreateMotorForTarget(target, direction, speed / simBase.SpeedConversionFactor);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -247,7 +247,7 @@ namespace CtrEditor.Simulacion
LocalOffsetB = Vector3.Zero, // Botella LocalOffsetB = Vector3.Zero, // Botella
LocalAxis = tangentDir, // ✅ CORREGIDO: Usar la dirección tangencial calculada LocalAxis = tangentDir, // ✅ CORREGIDO: Usar la dirección tangencial calculada
TargetVelocity = speed, // ✅ CORREGIDO: Usar la velocidad directamente 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) // ✅ CONECTAR BOTELLA CON EL TARGET (transporte o curva)

View File

@ -35,10 +35,6 @@ namespace CtrEditor.Simulacion
// ✅ EVENTO para actualización de motores // ✅ EVENTO para actualización de motores
public event Action<simCurve> OnSpeedChanged; public event Action<simCurve> OnSpeedChanged;
// ✅ NUEVO: Propiedad para velocidad convertida (similar a simTransporte)
public float SpeedMetersPerSecond { get; private set; }
// ✅ NUEVO: Almacenar triángulos creados para acceso directo // ✅ NUEVO: Almacenar triángulos creados para acceso directo
private Triangle[] _storedTriangles; private Triangle[] _storedTriangles;
@ -68,29 +64,15 @@ namespace CtrEditor.Simulacion
// ✅ SIMPLIFICADO: Crear la curva directamente // ✅ SIMPLIFICADO: Crear la curva directamente
Create(innerRadius, outerRadius, startAngle, endAngle, topLeft, 0); Create(innerRadius, outerRadius, startAngle, endAngle, topLeft, 0);
// ✅ NUEVO: Inicializar SpeedMetersPerSecond
SpeedMetersPerSecond = Speed / simBase.SPEED_CONVERSION_FACTOR;
} }
// ✅ SIMPLIFICADO: Configurar velocidad angular para AngularAxisMotor // ✅ SIMPLIFICADO: Configurar velocidad angular para AngularAxisMotor
public void SetSpeed(float speed) public void SetSpeed(float speed)
{ {
Speed = speed; // Velocidad angular directa (sin inversión) Speed = speed; // Velocidad angular directa (sin inversión)
SpeedMetersPerSecond = Speed / simBase.SPEED_CONVERSION_FACTOR; // ✅ NUEVO: Calcular velocidad convertida
OnSpeedChanged?.Invoke(this); OnSpeedChanged?.Invoke(this);
} }
/// <summary>
/// ✅ NUEVO: Configura la velocidad de la curva en metros por segundo
/// Valores positivos mueven en sentido horario, negativos en sentido antihorario
/// </summary>
/// <param name="speedMeterPerSecond">Velocidad en m/s (típicamente entre -5.0 y 5.0)</param>
public void SetCurveSpeed(float speedMeterPerSecond)
{
SetSpeed(speedMeterPerSecond * simBase.SPEED_CONVERSION_FACTOR);
}
/// <summary> /// <summary>
/// ✅ NUEVO: Detiene completamente la curva /// ✅ NUEVO: Detiene completamente la curva
/// </summary> /// </summary>

View File

@ -159,16 +159,6 @@ namespace CtrEditor.Simulacion
OnSpeedChanged?.Invoke(this); OnSpeedChanged?.Invoke(this);
} }
/// <summary>
/// Configura la velocidad del transporte en metros por segundo
/// Valores positivos mueven en la dirección del transporte, negativos en dirección opuesta
/// </summary>
/// <param name="speedMeterPerSecond">Velocidad en m/s (típicamente entre -5.0 y 5.0)</param>
public void SetTransportSpeed(float speedMeterPerSecond)
{
SetSpeed(speedMeterPerSecond * simBase.SPEED_CONVERSION_FACTOR);
}
/// <summary> /// <summary>
/// Detiene completamente el transporte /// Detiene completamente el transporte
/// </summary> /// </summary>