Ajustar parámetros de fricción estática y dinámica en la simulación de botellas, mejorando el comportamiento en situaciones de contacto. Implementar límites de velocidad en el plano XY y corregir la lógica de actualización de posición para evitar elevaciones excesivas.

This commit is contained in:
Miguel 2025-09-02 12:30:30 +02:00
parent 18017db56a
commit 3b953b7998
1 changed files with 22 additions and 9 deletions

View File

@ -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