added terrain modification feature for spline component

This commit is contained in:
Turánszki János
2025-04-16 09:32:54 +02:00
parent c51c1970a1
commit f4e374b204
16 changed files with 270 additions and 55 deletions
+26 -2
View File
@@ -26,8 +26,8 @@ void SplineWindow::Create(EditorComponent* _editor)
});
infoLabel.Create("SplineInfo");
infoLabel.SetSize(XMFLOAT2(100, 90));
infoLabel.SetText("The spline is a curve that goes through every specified entity that has a TransformComponent smoothly. A mesh can be generated from it automatically by increasing the subdivisions.");
infoLabel.SetSize(XMFLOAT2(100, 120));
infoLabel.SetText("The spline is a curve that goes through every specified entity that has a TransformComponent smoothly. A mesh can be generated from it automatically by increasing the subdivisions. It can also modify terrain when the terrain modification slider is used.");
AddWidget(&infoLabel);
loopedCheck.Create("Looped: ");
@@ -159,6 +159,28 @@ void SplineWindow::Create(EditorComponent* _editor)
});
AddWidget(&subdivVerticalSlider);
terrainSlider.Create(0, 1, 0, 100, "Terrain modifier: ");
terrainSlider.SetTooltip("Set terrain modification strength (0 to turn it off, higher values mean more sharpness).");
terrainSlider.OnSlide([this](wi::gui::EventArgs args) {
wi::scene::Scene& scene = editor->GetCurrentScene();
for (auto& x : editor->translator.selected)
{
SplineComponent* spline = scene.splines.GetComponent(x.entity);
if (spline == nullptr)
continue;
spline->terrain_modifier_amount = args.fValue;
}
// indirect set:
SplineComponent* spline = scene.splines.GetComponent(entity);
if (spline != nullptr)
{
spline->terrain_modifier_amount = args.fValue;
}
editor->componentsWnd.RefreshEntityTree();
});
AddWidget(&terrainSlider);
addButton.Create("AddNode");
addButton.SetText("+");
addButton.SetTooltip("Add an entity as a node to the spline (it must have TransformComponent). Hotkey: Ctrl + E");
@@ -191,6 +213,7 @@ void SplineWindow::SetEntity(Entity entity)
rotSlider.SetValue(wi::math::RadiansToDegrees(spline->rotation));
subdivSlider.SetValue(spline->mesh_generation_subdivision);
subdivVerticalSlider.SetValue(spline->mesh_generation_vertical_subdivision);
terrainSlider.SetValue(spline->terrain_modifier_amount);
if (changed)
{
@@ -330,6 +353,7 @@ void SplineWindow::ResizeLayout()
add_fullwidth(infoLabel);
add(subdivSlider);
add(subdivVerticalSlider);
add(terrainSlider);
add(widthSlider);
add(rotSlider);
add_right(loopedCheck);