Main Page Class List Class Members

# Nv::Blast::TkGroup Class Reference

`#include <NvBlastTkGroup.h>`

Inheritance diagram for Nv::Blast::TkGroup:

List of all members.

## Public Member Functions
virtual TkGroupWorker * | acquireWorker ()=0
virtual bool | addActor (TkActor &actor)=0
virtual bool | endProcess ()=0
virtual uint32_t | getActorCount () const =0
virtual uint32_t | getActors (TkActor **buffer, uint32_t bufferSize, uint32_t indexStart=0) const =0
virtual void | getStats (TkGroupStats &stats) const =0
virtual uint32_t | getWorkerCount () const =0
void | process ()
virtual void | returnWorker (TkGroupWorker *)=0
virtual void | setWorkerCount (uint32_t workerCount)=0
virtual uint32_t | startProcess ()=0

## Detailed Description

A group is a processing unit, to which the user may add TkActors. New actors generated from splitting a TkActor are automatically put into the same group. However, any actor may be removed from its group and placed into another group (or no group) by the user's choice.

When the group's process function is called, all actors' damage buffers will be processed and turned into fracture events and the actor is split if applicable.

This work can be done in multiple threads with the help of TkGroupWorker: Instead of calling the process function, commence the procedure with startProcess which returns the number of jobs to process. Each concurrent thread uses an acquired TkGroupWorker to process the jobs. Over the whole procedure, each job must be processed once and only once. Jobs can be processed in any order. TkGroupWorkers can be returned and acquired later by another task. After processing every job and returning all the workers to the group, endProcess concludes the procedure.

## Member Function Documentation

virtual TkGroupWorker* Nv::Blast::TkGroup::acquireWorker | ( |  | ) | `[pure virtual]`

Acquire one worker to process the group concurrently on a thread. The worker must be returned with returnWorker() before endProcess() is called on its group.

Returns:
  A worker for this group (at most getWorkerCount) or nullptr if none is available.

virtual bool Nv::Blast::TkGroup::addActor | ( | TkActor & | actor | ) | `[pure virtual]`

Add the actor to this group, if the actor does not currently belong to a group.

Parameters:

  `[in]` | actor | The actor to add.

Returns:
  true if successful, false otherwise.

virtual bool Nv::Blast::TkGroup::endProcess | ( |  | ) | `[pure virtual]`

Unlock this group after all jobs were processed with TkGroupWorker. All workers must have been returned with returnWorker(). This function gathers the results of the split operations on the actors in this group. Events will be dispatched to notify listeners of new and deleted actors.

Note that groups concurrently dispatching events for the same TkFamily require synchronization in the TkFamily's Listener. However, concurrent use of endProcess is not recommended in this version. It should be called from the main thread.

Returns:
  true if the group was processing

virtual uint32_t Nv::Blast::TkGroup::getActorCount | ( |  | ) | const`[pure virtual]`

The number of actors currently in this group.

Returns:
  the number of TkActors that currently exist in this group.

virtual uint32_t Nv::Blast::TkGroup::getActors | ( | TkActor ** | buffer,
|  | uint32_t | bufferSize,
|  | uint32_t | indexStart = `0` |
| ) |  |  | const`[pure virtual]`

Retrieve an array of pointers (into the user-supplied buffer) to actors.

Parameters:

  `[out]` | buffer | A user-supplied array of TkActor pointers.
  `[in]` | bufferSize | The number of elements available to write into buffer.
  `[in]` | indexStart | The starting index of the actor.

Returns:
  the number of TkActor pointers written to the buffer.

virtual void Nv::Blast::TkGroup::getStats | ( | TkGroupStats & | stats | ) | const`[pure virtual]`

For profile builds only, request stats of the last successful processing. Inactive in other builds. The times and counters reported account for all the TkWorker (accumulated) taking part in the processing.

Parameters:

  `[in]` | stats | The struct to be filled in.

virtual uint32_t Nv::Blast::TkGroup::getWorkerCount | ( |  | ) | const`[pure virtual]`

Returns:
  The total amount of workers allocated for this group.

NV_INLINE void Nv::Blast::TkGroup::process | ( |  | ) |

Helper function to process the group synchronously on a single thread.

virtual void Nv::Blast::TkGroup::returnWorker | ( | TkGroupWorker * |  | ) | `[pure virtual]`

Return a worker previously acquired with acquireWorker() to this TkGroup.

Parameters:

  `[in]` | The | TkGroupWorker previously acquired from this TkGroup.

virtual void Nv::Blast::TkGroup::setWorkerCount | ( | uint32_t | workerCount | ) | `[pure virtual]`

Set the expected number of concurrent worker threads that will process this group concurrently.

virtual uint32_t Nv::Blast::TkGroup::startProcess | ( |  | ) | `[pure virtual]`

Lock this group for processing concurrently with TkGroupWorker. The group is unlocked again with the endProcess() function.

Returns:
  The number of jobs to process. TkGroupWorker::process must be called once for each jobID from 0 to this number-1. See TkGroup::process for a single threaded example.

The documentation for this class was generated from the following file:

- sdk/toolkit/include/NvBlastTkGroup.h