org.sunflow.core

Class IntersectionState


public final class IntersectionState
extends java.lang.Object

This class is used to store ray/object intersections. It also provides additional data to assist AccelerationStructure objects with traversal.

Nested Class Summary

static class
IntersectionState.StackNode
Traversal stack node, helps with tree-based AccelerationStructure traversal.

Constructor Summary

IntersectionState()
Initializes all traversal stacks.

Method Summary

float[]
getRobustStack()
Used for algorithms which do bounding box based ray intersection.
IntersectionState.StackNode[]
getStack()
Get stack object for tree based AccelerationStructures.
int
getStackTop()
Index to use as the top of the stack, this is needed because of the two-level nature of ray-intersection (instances then primitive list).
boolean
hit()
Checks to see if a hit has been recorded.
void
setIntersection(int id, float u, float v)
Record an intersection with the specified primitive id.

Constructor Details

IntersectionState

public IntersectionState()
Initializes all traversal stacks.

Method Details

getRobustStack

public final float[] getRobustStack()
Used for algorithms which do bounding box based ray intersection.
Returns:
array of floating point values for the stack

getStack

public final IntersectionState.StackNode[] getStack()
Get stack object for tree based AccelerationStructures.
Returns:
array of stack nodes

getStackTop

public final int getStackTop()
Index to use as the top of the stack, this is needed because of the two-level nature of ray-intersection (instances then primitive list).
Returns:
index into the stack

hit

public final boolean hit()
Checks to see if a hit has been recorded.
Returns:
true if a hit has been recorded, false otherwise

setIntersection

public final void setIntersection(int id,
                                  float u,
                                  float v)
Record an intersection with the specified primitive id. The parent object is assumed to be the current instance. The u and v parameters are used to pinpoint the location on the surface if needed.
Parameters:
id - primitive id of the intersected object
u - u surface paramater of the intersection point
v - v surface parameter of the intersection point