voctopus.kernel.asm - nphyx/voctopus GitHub Wiki

Global

Description

#Functions


makeP

makeP() ⇨

The last bit of a value is a flag for a pointer, so this shifts a number left and then sets the last bit to 1 to flag it as a pointer. It has to be decoded in reverse.


setMaxDepth

setMaxDepth(n) ⇨

Sets maximum depth value. Maximum depth should not be modified during runtime due to side effects not being tested for. If you need a larger octree, copy the current tree into a larger one. Never, ever decrease an octree's depth.

Parameters

name type description
n int Sets maximum depth value. Maximum depth should not be modified during
runtime due to side effects not being tested for. If you need a larger
octree, copy the current tree into a larger one. Never, ever decrease
an octree's depth.

getMaxDepth

getMaxDepth() ⇨

Accessor for max depth value.


setCurrentDepth

setCurrentDepth() ⇨

Sets the current depth value.


getCurrentDepth

getCurrentDepth() ⇨

Accessor for current depth value.


incrementCurrentDepth

incrementCurrentDepth() ⇨

Increments current depth value. Used during octree traversal.


setFirstOffset

setFirstOffset() ⇨

Sets firstOffset value. This generally should not be changed during runtime.


getFirstOffset

getFirstOffset() ⇨

Gets firstOffset value.


setNextOffset

setNextOffset(n) ⇨

Sets nextOffset value. This is generally handled through allocateOctet and shouldn't be set manually.

Parameters

name type description
n int Sets nextOffset value. This is generally handled through allocateOctet and
shouldn't be set manually.

getNextOffset

getNextOffset() ⇨ int

Gets nextOffset value. This value is managed by allocateOctet, so you shouldn't access it directly unless you need to read it without incrementing it.

Returns: int


allocateOctet

allocateOctet() ⇨

Increments the next octet value, then returns the previous value. This is used to keep track of the next available octet memory space.


getOctant

getOctant(i) ⇨

Gets raw int value of octant at index i.

Parameters

name type description
i int 32-bit index

setOctant

setOctant(i, v) ⇨

Sets octant at index i to value v.

Parameters

name type description
i int 32-bit index
v int 32-bit value

getTRAVA

getTRAVA() ⇨

For debugging purposes.


rFrom

rFrom(n) ⇨ int

Decodes the red value from an rgba value.

Parameters

name type description
n int 32-bit rgba value

Returns: int8-bit color value


gFrom

gFrom(n) ⇨ int

Decodes the green value from an rgba value.

Parameters

name type description
n int 32-bit rgba value

Returns: int8-bit color value


bFrom

bFrom(n) ⇨ int

Decodes the blue value from an rgba value.

Parameters

name type description
n int 32-bit rgba value

Returns: int8-bit color value


aFrom

aFrom(n) ⇨ int

Decodes the alpha value from an rgba value.

Parameters

name type description
n int 32-bit rgba value

Returns: int4-bit alpha value


isP

isP() ⇨

Determines whether a value is flagged as a pointer by checking the first bit.


pFrom

pFrom(n) ⇨ int

Decode a pointer from a stored value. Returns 0 if the value wasn't a pointer. Note this only works correctly if n is a value from the octree.

Parameters

name type description
n octant an octant value from the octree

Returns: inta decoded pointer, or 0 if it wasn't a pointer


getP

getP(i) ⇨ int

Reads a value from the index with the assumption that it's a pointer.

Parameters

name type description
i int index to read from

Returns: intvalue decoded as a pointer


setP

setP(i, n) ⇨

Sets a value at the index as an encoded pointer.

Parameters

name type description
i int index to read from
n int pointer to set

setCurrentPointer

setCurrentPointer(p) ⇨

Sets the current pointer value, used during traversal. Note that this value is not encoded as a pointer, because it's not in the octree and converting it back and forth is computationally wasteful.

Parameters

name type description
p int pointer to set

valFromRGBA

valFromRGBA(r, g, b, a) ⇨

Translates a set of rgba values to an unsigned 32-bit int.

Parameters

name type description
r int Translates a set of rgba values to an unsigned 32-bit int.
g int Translates a set of rgba values to an unsigned 32-bit int.
b int Translates a set of rgba values to an unsigned 32-bit int.
a int Translates a set of rgba values to an unsigned 32-bit int.

Returns: int


calcDepthInverse

calcDepthInverse() ⇨

Calculates inverse of current depth. Used in octantIdentity calculation.


prepareLookup

prepareLookup(x, y, z, d) ⇨

Prepares internal variables for a voxel lookup. Called whenever these values need to be refreshed during a voxel lookup or related calculations.

Parameters

name type description
x int x-coordinate
y int y-coordinate
z int z-coordinate
d int target depth

octantIdentity

octantIdentity() ⇨ int

Finds the identity of an octant for the prepared vector at the current depth.

Returns: int


octantPointer

octantPointer() ⇨ int

Derives the pointer for the octant at the current depth and vector from the octet pointer.

Returns: int


initOctet

initOctet() ⇨

Initializes an octet at the depth and vector set using prepareLookup


step

step() ⇨

Single step in traversal. Used when walking the tree.


rayAABB

rayAABB(bs[x,y,z, be[x,y,z, ro[x,y,z, rd[x,y,z) ⇨ int

Check the ray - box intersection of a voxel (which is an axis-aligned bounding box)

Parameters

name type description
bs[x,y,z double box start (top, left, back)
be[x,y,z double box end (bottom, right, front)
ro[x,y,z double ray origin
rd[x,y,z double inverse of ray direction (inverse should be precalculated)

Returns: int1 if there was a hit, otherwise 0