Skip to content

Commit

Permalink
improvements for wind, terrain, editor interaction picker
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Feb 17, 2025
1 parent 20694ee commit 1ec618e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
8 changes: 1 addition & 7 deletions Editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,6 @@ void EditorComponent::Update(float dt)
// Interactions:
{
// Interact:
bool interaction_happened = false;
if (CheckInput(EditorActions::RAGDOLL_AND_PHYSICS_IMPULSE_TESTER))
{
if (wi::input::Press(wi::input::MOUSE_BUTTON_MIDDLE))
Expand All @@ -1926,7 +1925,6 @@ void EditorComponent::Update(float dt)
wi::physics::RayIntersectionResult result = wi::physics::Intersects(scene, pickRay);
if (result.IsValid())
{
interaction_happened = true;
XMFLOAT3 impulse;
XMStoreFloat3(&impulse, XMVector3Normalize(XMLoadFloat3(&pickRay.direction)) * 20);
if (result.humanoid_ragdoll_entity != INVALID_ENTITY)
Expand Down Expand Up @@ -1957,10 +1955,6 @@ void EditorComponent::Update(float dt)
if (wi::input::Down(wi::input::MOUSE_BUTTON_MIDDLE))
{
wi::physics::PickDrag(scene, pickRay, physicsDragOp);
if (physicsDragOp.IsValid())
{
interaction_happened = true;
}
}
else
{
Expand Down Expand Up @@ -1999,7 +1993,7 @@ void EditorComponent::Update(float dt)
}

// Other:
if (!interaction_happened && wi::input::Down(wi::input::MOUSE_BUTTON_MIDDLE))
if (wi::input::Down(wi::input::MOUSE_BUTTON_MIDDLE))
{
hovered = wi::scene::Pick(pickRay, wi::enums::FILTER_OBJECT_ALL, ~0u, scene);
if (hovered.entity != INVALID_ENTITY)
Expand Down
19 changes: 9 additions & 10 deletions WickedEngine/shaders/windCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ float compute_wind(float3 position, float time)
position += time;
const ShaderWind wind = GetWeather().wind;

float randomness_amount = 0;
randomness_amount += noise_gradient_3D(position.xyz);
randomness_amount += noise_gradient_3D(position.xyz / 2.0f);
randomness_amount += noise_gradient_3D(position.xyz / 4.0f);
randomness_amount += noise_gradient_3D(position.xyz / 8.0f);
randomness_amount += noise_gradient_3D(position.xyz / 16.0f);
randomness_amount += noise_gradient_3D(position.xyz / 32.0f);
randomness_amount *= wind.randomness;
position.xyz *= wind.wavesize;

float direction_amount = dot(position.xyz, wind.direction);
float waveoffset = mad(direction_amount, wind.wavesize, randomness_amount);
float waveoffset = 0;
waveoffset += noise_gradient_3D(position.xyz);
waveoffset += noise_gradient_3D(position.xyz / 2.0);
waveoffset += noise_gradient_3D(position.xyz / 4.0);
waveoffset += noise_gradient_3D(position.xyz / 8.0);
waveoffset += noise_gradient_3D(position.xyz / 16.0);
waveoffset += noise_gradient_3D(position.xyz / 32.0);
waveoffset *= wind.randomness;

return sin(mad(time, wind.speed, waveoffset));
}
Expand Down
4 changes: 4 additions & 0 deletions WickedEngine/wiTerrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ namespace wi::terrain
grass->width = grass_properties.width;
grass->uniformity = grass_properties.uniformity;
grass->atlas_rects = grass_properties.atlas_rects;
grass->segmentCount = grass_properties.segmentCount;
grass->billboardCount = grass_properties.billboardCount;
grass->drag = grass_properties.drag;
grass->gravityPower = grass_properties.gravityPower;
}

MaterialComponent* chunkGrassMaterial = scene->materials.GetComponent(chunk_data.grass_entity);
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/wiVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 681;
const int revision = 682;

const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);

Expand Down

0 comments on commit 1ec618e

Please sign in to comment.