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:
parent
a6cbd8c4ab
commit
3eee0e3d9b
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -35,10 +35,6 @@ namespace CtrEditor.Simulacion
|
|||
// ✅ EVENTO para actualización de motores
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// ✅ NUEVO: Detiene completamente la curva
|
||||
/// </summary>
|
||||
|
|
|
@ -159,16 +159,6 @@ namespace CtrEditor.Simulacion
|
|||
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>
|
||||
/// Detiene completamente el transporte
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue