Skip to content

Draft: Feature/wheel terrain#202

Open
jokimmortal wants to merge 25 commits into
masterfrom
feature/wheel-terrain
Open

Draft: Feature/wheel terrain#202
jokimmortal wants to merge 25 commits into
masterfrom
feature/wheel-terrain

Conversation

@jokimmortal

Copy link
Copy Markdown
Contributor

Introduce GUI for DeformableTerrainWheel and related DeformableTerrainMaterial properties.

@jokimmortal jokimmortal self-assigned this Jun 8, 2026

@FilipAlg FilipAlg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work for the most part. The main thing that's missing is enable/disable support and test. Other than that and the crash that we've discussed, most of the comments is general cleanup.

On a higher level, I'm curious whether we should create default contact materials for all Wheel<>Terrain pairs in a scene automatically. Since the actual contact material configuration is minimal this should be pretty simple and could ease scene setup quite a bit. Not needed for this MR but I would be interested to hear your opinion on this.

public float HeightThreshold { get; set; } = 0.01f;

[field: SerializeField]
[Range( 0.0f, 1.0f )]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Range attribute cannot be applied to properties in Unity 2022, prefer using FloatSliderInInspector which does the same thing

public float FullStrengthHeightChange { get; set; } = 0.1f;

[field: SerializeField]
[Min( 0 )]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Min attribute does not work in Unity 2022, use ClampAboveZeroInInspector( true )

[field: SerializeField]
[Min( 0 )]
[Tooltip( "Paint radius in heightmap samples around each modified terrain vertex." )]
public int BrushRadius { get; set; } = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what is the purpose of having a brush radius here? Shouldn't we only paint the affected cells?

/// NB: if using multiple shape materials on the terrain this is not reliable!
/// </summary>
[SerializeField]
[FormerlySerializedAs( "WarnIfNotUsingCorrectForceModel" )]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont need this since this script is new

private bool m_warnIfNotUsingCorrectForceModel = false;

[Tooltip( "Helper that will output a warning if the contact material in use by the terrain wheel doesn't have the correct force model." )]
public bool WarnIfNotUsingCorrectForceModel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using default backing fields instead of explicit backing fields where possible

return false;
}

var cylinders = RigidBody.GetComponentsInChildren<Collide.Cylinder>()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use RigidBody.Shapes.Where(s => s is Shapes.Cylinder) instead?

Native = new agxTerrain.TerrainWheel( cylinder );

if ( Settings == null )
Settings = CreateSettingsFromLegacyValues();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there legacy settings for a new feature?

/// </summary>
[SerializeField]
[FormerlySerializedAs( "WarnIfNotUsingCorrectForceModel" )]
private bool m_warnIfNotUsingCorrectForceModel = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be true by default? Does the component still work by default when the force model is not set correctly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess in that case we might wanna do the logging only once per run (and contact material?) as well

base.OnEnable();
}

protected override void OnDisable()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnDisable & OnEnable need to be implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants