Skip to content

Commit

Permalink
[worlds] enabled wind for the curtains and the ivy leaves in the spon…
Browse files Browse the repository at this point in the history
…za world
  • Loading branch information
PanosK92 committed Jan 7, 2025
1 parent 76832e9 commit e0b19bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
14 changes: 10 additions & 4 deletions runtime/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,24 +752,24 @@ namespace Spartan
entity->SetPosition(Vector3(0.0f, 0.15f, 0.0f));
entity->SetScale(scale);

// disable back face culling
// disable back face culling and enable wind
{
if (Material* material = entity->GetDescendantByName("curtain_03_2")->GetComponent<Renderable>()->GetMaterial())
{
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
material->SetProperty(MaterialProperty::SubsurfaceScattering, 0.0f);
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}

if (Material* material = entity->GetDescendantByName("curtain_03_3")->GetComponent<Renderable>()->GetMaterial())
{
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
material->SetProperty(MaterialProperty::SubsurfaceScattering, 0.0f);
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}

if (Material* material = entity->GetDescendantByName("curtain_hanging_06_3")->GetComponent<Renderable>()->GetMaterial())
{
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
material->SetProperty(MaterialProperty::SubsurfaceScattering, 0.0f);
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}
}
}
Expand All @@ -781,6 +781,12 @@ namespace Spartan
entity->SetObjectName("sponza_ivy");
entity->SetPosition(Vector3(0.0f, 0.15f, 0.0f));
entity->SetScale(scale);

if (Material* material = entity->GetDescendantByName("IvySim_Leaves")->GetComponent<Renderable>()->GetMaterial())
{
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}
}
}

Expand Down
43 changes: 20 additions & 23 deletions runtime/World/Components/PhysicsBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,29 +817,6 @@ namespace Spartan
m_shape = nullptr;
}

// get common prerequisites for certain shapes
vector<uint32_t> indices;
vector<RHI_Vertex_PosTexNorTan> vertices;
shared_ptr<Renderable> renderable = nullptr;
if (m_shape_type == PhysicsShape::Mesh)
{
// get renderable
renderable = GetEntity()->GetComponent<Renderable>();
if (!renderable || !renderable->HasMesh())
{
SP_LOG_WARNING("For a mesh shape to be constructed, there needs to be a Renderable component with a mesh");
return;
}

// get geometry
renderable->GetGeometry(&indices, &vertices);
if (vertices.empty())
{
SP_LOG_WARNING("A shape can't be constructed without vertices");
return;
}
}

Vector3 size = m_size * GetEntity()->GetScale();

// construct new shape
Expand Down Expand Up @@ -909,6 +886,26 @@ namespace Spartan

case PhysicsShape::Mesh:
{
// get common prerequisites for certain shapes
vector<uint32_t> indices;
vector<RHI_Vertex_PosTexNorTan> vertices;
shared_ptr<Renderable> renderable = GetEntity()->GetComponent<Renderable>();

// get renderable
if (!renderable)
{
SP_LOG_WARNING("PhysicsShape::Mesh requires a renderable component to be present");
return;
}

// get geometry
renderable->GetGeometry(&indices, &vertices);
if (vertices.empty())
{
SP_LOG_WARNING("PhysicsShape::Mesh requires the renderable component to contain vertices");
return;
}

// determine how much detail is needed for this shape
const bool is_enterable = can_a_capsule_enter(renderable.get(), vertices, size);
const bool is_low_poly = vertices.size() < 1000;
Expand Down

0 comments on commit e0b19bc

Please sign in to comment.