Class BspCompositeShape
Why: the painter's algorithm sorts shapes by a single average-Z key. When two polygons' depth ranges overlap — a floor tile extending under a piece of furniture, a wall seen through a doorway — no single key can order them correctly and the farther polygon visibly overdraws the nearer one. A BSP tree decides order by plane tests against the viewer position, which is exact for any geometry that does not interpenetrate, and becomes exact for interpenetrating geometry too because the build splits every polygon that straddles a partition plane.
Compile model: the polygons you add (directly or inside nested composites) remain the editable source of truth. When the render list is (re)built — after every structural edit — they are fan-triangulated and compiled into BSP fragments. The fragments are what actually renders. Rebuild is automatic via the normal cache-invalidation path.
How ordering works: every frame the tree is traversed
back-to-front from the camera position and each fragment receives a
per-slot rank (setBspRank). The aggregator's sort comparator
orders two ranked shapes by rank; pairs where either shape has no rank
fall back to average Z. Consequence: put ALL interpenetrating static
geometry into the same BSP composite; shapes outside it (markers, lines,
overlays) still sort by Z exactly as before.
Limitations:
- Nested composites are flattened at build time assuming identity transforms (vertices are used in the composite's local space).
- Split fragments lose the backface-culling flag; the correct painter order makes this cosmetically irrelevant, at a small overdraw cost.
- Frustum culling applies to this composite as a whole; nested composites are no longer culled individually.
- See Also:
-
Field Summary
Fields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
cachedBoundingBox, mouseInteractionController -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether lightmapping is enabled.protected List<AbstractShape> postprocessRenderList(List<AbstractShape> renderList) Compiles the render list into BSP fragments: triangulates every solid polygon, flattens nested composites, builds the splitting BSP tree, and returns the resulting fragments plus all non-polygon shapes (which render through the normal Z-sorted path).voidsetLightmappingEnabled(boolean enabled) Enables or disables lightmapping.voidsetLightmapUnitsPerTexel(double unitsPerTexel) Sets the lightmap resolution.voidtransform(TransformStack transformPipe, RenderAggregator aggregator, RenderingContext context) Assigns per-slot painter ranks by traversing the BSP tree back-to-front from the viewer position.Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape
addShape, addShape, beforeTransformHook, collectRenderTriangles, extractSolidPolygons, getBoundingBox, getGlobalRenderListVersion, getGroup, getLocation, getSubShapesRegistry, getTransform, getTransformWeight, getViewSpaceTracker, hideGroup, intersect, removeGroup, setBackfaceCulling, setCacheNeedsRebuild, setColor, setGroupForUngrouped, setMouseInteractionController, setRootComposite, setShadingEnabled, setTransform, showGroup, subtract, unionMethods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
invalidateBounds
-
Constructor Details
-
BspCompositeShape
public BspCompositeShape()
-
-
Method Details
-
postprocessRenderList
Compiles the render list into BSP fragments: triangulates every solid polygon, flattens nested composites, builds the splitting BSP tree, and returns the resulting fragments plus all non-polygon shapes (which render through the normal Z-sorted path).- Overrides:
postprocessRenderListin classAbstractCompositeShape- Parameters:
renderList- the render list built from the shape registry- Returns:
- BSP fragments + non-polygon passthrough shapes
-
setLightmappingEnabled
public void setLightmappingEnabled(boolean enabled) Enables or disables lightmapping. When enabled, BSP fragments render asLightmappedTriangles with per-fragment lightmap textures filled by the global illumination system. Rebuilds the render list (and BSP) on the next frame.- Parameters:
enabled- true to render fragments lightmapped
-
isLightmappingEnabled
public boolean isLightmappingEnabled()Returns whether lightmapping is enabled.- Returns:
- true when fragments render as lightmapped triangles
-
setLightmapUnitsPerTexel
public void setLightmapUnitsPerTexel(double unitsPerTexel) Sets the lightmap resolution. Default 12 world units per texel: a 100-unit wall cell gets an 8x8 lightmap. Halving the units quadruples the GI tracing work; finer texels are the ONLY way to smoother shadow edges (there is no upsampling). Takes effect on the next render list rebuild.- Parameters:
unitsPerTexel- world units per lightmap texel
-
transform
public void transform(TransformStack transformPipe, RenderAggregator aggregator, RenderingContext context) Assigns per-slot painter ranks by traversing the BSP tree back-to-front from the viewer position. Runs after the normal transform; ranks are pure functions of viewpoint and tree, so this is safe while parallel transform chunk tasks are still running.- Overrides:
transformin classAbstractCompositeShape- Parameters:
transformPipe- the current stack of transforms (world-to-camera transformations)aggregator- collects transformed shapes for depth-sorted renderingcontext- provides frame dimensions, graphics context, and frame metadata
-