Navigation: Scripting Reference Manual > Functions & Subroutines > CompressRayBuffer

 

CompressRayBuffer

 

Contact Us: fredsupport@photonengr.com

 

Description

As a consequence of multi-threaded raytracing and/or manipulating ray data, the ray buffer that stores the ray data may become populated with empty slots.  For example, if a ray is deleted from the ray buffer, its slot in the buffer is flagged as having been deleted but the memory is not released.  Additionally, when the ray buffer is processed as part of analysis, there are generally more ray buffer slots to be checked than there are actual rays of interest.  The CompressRayBuffer() function will remove the empty/deleted ray slots, release their memory, and collapse the ray buffer to its most compact state.  Buffer compression is not always needed or required, except in cases where post-processing ray data consumes a significant portion of analysis time and the rays of interest are a small fraction of the total ray buffer size.

 

A variant of this command, CompressRayBufferWithFilter(), is also available, which allows the user to supply a ray selection filter when the buffer compaction is requested.  Only rays that satisfy the ray selection filter criteria will remain in the compacted buffer.

 

Syntax

nRays = CompressRayBuffer( )

 

Parameters

This command takes no parameters.

 

Example

The example below assumes that the ray buffer has previously been modified in some way such that deleted and/or empty ray slots exist in the buffer already.  The ray buffer manipulations could have been performed via the Ray Manipulation Utilities dialog in the GUI or by a custom loop over the ray buffer, for example.  Here, we begin the script by reporting the number of slots in the ray buffer as well as the number of actual rays (GetLiveRayCount()) being stored in the ray buffer slots.  Then, we call compressRayBuffer in order to remove the deleted and/or empty ray slots.  Finally, we report again the number of ray buffer slots and actual rays in the resulting compacted buffer.  After compaction, the number of ray buffer slots will equal the number of actual rays.

 

Sub Main

          

    Print "Current ray buffer slots: " & GetRayCount()

    Print "Actual ray count: " & GetLiveRayCount()

 

    'Compress out deleted/empty ray buffer slots

    compressRayBuffer()

 

    Print "Compacted ray buffer slots: " & GetRayCount()

    Print "Actual ray count: " & GetLiveRayCount()

 

End Sub

 

See Also

Ray Script Commands

CompressRayBufferWithFilter

 

 

 

 

 

Copyright © Photon Engineering, LLC