Skip to content

Oriented SceneObjectModel/SceneObjectPolygon measure depth from the world origin #342

Open

Description

@markwpearce

Bug

In oriented draw mode, SceneObjectModel and SceneObjectPolygon measure their camera depth from the world origin instead of from the object.

Both override getPositionForCameraDistance() to return m.worldPoints.getCenter() when drawMode = oriented (SceneObjectModel.bs:330-335, SceneObjectPolygon.bs:88-93). worldPoints is inherited from SceneObjectBillboard, but only SceneObjectBillboard.updateWorldPosition() fills it. Both subclasses override updateWorldPosition() without calling super, and fill modelWorldFaces/modelWorldBounds or polygonWorldPoints instead. So worldPoints keeps its default zero vectors, and depthPosition/negDistanceFromCamera come out as the distance to (0, 0, 0).

Effect

  • An oriented model or polygon depth-sorts as though it were at the world origin, so it can draw in front of or behind other objects incorrectly.
  • The behind-the-camera skip (negDistanceFromCamera >= 0) and BSP dynamic-item classification (getDepthPosition()) use the same wrong point.
  • Found while planning Investigate occlusion culling for the renderer #108: occlusion culling needs a correct depth for static models acting as occluders.

Fix

  • Return a real centre for these classes in oriented mode: the centre of modelWorldBounds for models, and the centroid or bounds centre of polygonWorldPoints for polygons.
  • Add specs asserting that an oriented model/polygon placed away from the origin reports a depth based on its own position.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions