Skip to content

Commit

Permalink
[animation] MaterialProperty::WorldSpaceHeight accounts for instancin…
Browse files Browse the repository at this point in the history
…g (to an extent)
  • Loading branch information
PanosK92 committed Jan 17, 2025
1 parent 9ecf2a4 commit fcd5c9b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions runtime/World/Components/Renderable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ namespace spartan

float min_height = FLT_MAX;
float max_height = -FLT_MAX;
Matrix transform = HasInstancing() ? GetEntity()->GetMatrix() * GetInstanceTransform(0) : GetEntity()->GetMatrix();
for (const RHI_Vertex_PosTexNorTan& vertex : vertices)
{
Vector3 position = Vector3(vertex.pos[0], vertex.pos[1], vertex.pos[2]) * GetEntity()->GetMatrix();

if (position.y < min_height) min_height = position.y;
if (position.y > max_height) max_height = position.y;
Vector3 position = Vector3(vertex.pos[0], vertex.pos[1], vertex.pos[2]) * transform;
min_height = min(min_height, position.y);
max_height = max(max_height, position.y);
}

material->SetProperty(MaterialProperty::WorldSpaceHeight, max_height - min_height);
Expand Down

0 comments on commit fcd5c9b

Please sign in to comment.