уже лучше

This commit is contained in:
Valera
2025-06-15 21:59:42 +07:00
parent 4912d0ae1a
commit f0f89ff947
11 changed files with 218 additions and 255 deletions

View File

@@ -17,7 +17,7 @@ public class PacejkaWidget : ControlObjectWidget
Layout = Layout.Column();
Layout.Margin = 8f;
Layout.Spacing = 8;
foreach ( var item in TypeLibrary.GetType<Pacejka.LateralForce>().Fields )
foreach ( var item in TypeLibrary.GetType<Pacejka.LateralForce>().Properties )
{
var row = Layout.AddRow();
row.Spacing = 8;
@@ -36,7 +36,7 @@ public class PacejkaWidget : ControlObjectWidget
Layout = Layout.Column();
Layout.Margin = 8f;
Layout.Spacing = 8;
foreach ( var item in TypeLibrary.GetType<Pacejka.LongitudinalForce>().Fields )
foreach ( var item in TypeLibrary.GetType<Pacejka.LongitudinalForce>().Properties )
{
var row = Layout.AddRow();
row.Spacing = 8;
@@ -55,7 +55,7 @@ public class PacejkaWidget : ControlObjectWidget
Layout = Layout.Column();
Layout.Margin = 8f;
Layout.Spacing = 8;
foreach ( var item in TypeLibrary.GetType<Pacejka.AligningMoment>().Fields )
foreach ( var item in TypeLibrary.GetType<Pacejka.AligningMoment>().Properties )
{
var row = Layout.AddRow();
row.Spacing = 8;

View File

@@ -1,7 +1,6 @@
using Editor;
using Editor.Assets;
using Editor.Inspectors;
using Editor.ShaderGraph.Nodes;
using Sandbox;
using System;
using System.Collections.Generic;
@@ -68,16 +67,13 @@ class TirePresetPreview( Asset asset ) : PixmapAssetPreview( asset )
for ( float x = x0; x <= xn; x += (xn - x0) / points )
{
float yval = tire.PacejkaFy( x, load, Camber, 1.0f, out float maxforce ) / load;
float yval = tire.PacejkaFy( x, load, Camber, 1.0f, out float _ ) / load;
float xval = width * (x - x0) / (xn - x0);
yval /= ymax - ymin;
yval = (yval + 1.0f) * 0.5f;
yval = 1.0f - yval;
yval *= height;
if ( x == x0 )
pointCache.Add( new( xval, yval ) );
else
pointCache.Add( new( xval, yval ) );
pointCache.Add( new( xval, yval ) );
}
Paint.DrawLine( pointCache );
@@ -86,6 +82,29 @@ class TirePresetPreview( Asset asset ) : PixmapAssetPreview( asset )
{ // draw longitudinal line
pointCache.Clear();
Paint.SetPen( Color.Green, 1 );
float x0 = -zoom * 0.5f;
float xn = zoom * 0.5f;
float ymin = -1000.0f;
float ymax = 1000.0f;
int points = 500;
for ( float x = x0; x <= xn; x += (xn - x0) / points )
{
float yval = tire.PacejkaFx( x, load, 1.0f, out var _ ) / load;
float xval = width * (x - x0) / (xn - x0);
yval /= ymax - ymin;
yval = (yval + 1.0f) * 0.5f;
yval = 1.0f - yval;
yval *= height;
pointCache.Add( new( xval, yval ) );
}
Paint.DrawLine( pointCache );
}
{ // draw aligning line
pointCache.Clear();
Paint.SetPen( Color.Blue, 1 );
float x0 = -zoom * 0.5f * 10.0f;
float xn = zoom * 0.5f * 10.0f;
@@ -101,36 +120,7 @@ class TirePresetPreview( Asset asset ) : PixmapAssetPreview( asset )
yval = (yval + 1.0f) * 0.5f;
yval = 1.0f - yval;
yval *= height;
if ( x == x0 )
pointCache.Add( new( xval, yval ) );
else
pointCache.Add( new( xval, yval ) );
}
Paint.DrawLine( pointCache );
}
{ // draw aligning line
pointCache.Clear();
Paint.SetPen( Color.Green, 1 );
float x0 = -zoom * 0.5f;
float xn = zoom * 0.5f;
float ymin = -1000.0f;
float ymax = 1000.0f;
int points = 500;
for ( float x = x0; x <= xn; x += (xn - x0) / points )
{
float yval = tire.PacejkaFx( x, load, 1.0f ) / load;
float xval = width * (x - x0) / (xn - x0);
yval /= ymax - ymin;
yval = (yval + 1.0f) * 0.5f;
yval = 1.0f - yval;
yval *= height;
if ( x == x0 )
pointCache.Add( new( xval, yval ) );
else
pointCache.Add( new( xval, yval ) );
pointCache.Add( new( xval, yval ) );
}
Paint.DrawLine( pointCache );
}