Skip to content

Fix visible entity sorting #855

@joboet

Description

@joboet

What problem does this solve or what need does it fill?

The current algorithm can lead to missing transparency effects when using custom cameras.

Describe the solution would you like?

Changing
DepthCalculation::ZDifference => camera_position.z() - position.z()
to
DepthCalculation::ZDifference => (camera_position.z() - position.z()).abs()
would fix the error.

Describe the alternative(s) you've considered?

Using DepthCalculation::Distance resolves the issue, but leads to weird artifacts when entities are closely together.

Additional context

I use a custom pseudo-3d camera projection. As it increases the Y-coordinate with increasing Z-coordinates, it needs the camera to be at or close to the origin. This means that entities with positive Z-coordinates get assigned a negative ZDifference and thus are sorted incorrectly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions