150
Chapter 13: Multiprocessing
Cleaning the csContext Fields
Before rendering, the application thread must call csField::cleanFields() to clean the
csContext fields. This method forces the evaluation of all fields that have been dirty,
thereby circumventing the normal lazy evaluation of field values. Generally, in Cosmo
3D, fields are updated only when queried.
To use this method, tracking of dirty fields must be enabled. This method enables safe
traversal of a scene by parallel rendering threads; lazy evaluation is not thread-safe.
To clean the fields, you must:
1. Enable cleaning by using the following method:
csField::enableDirtyFieldTracking();
2. Clean the fields by calling the following method each frame:
csField::cleanFields();
To see if dirty field is enabled, use the following method:
csField::isDirtyFieldTrackingEnabled()
Multithreaded Example
For an example of a multi-threaded application, see twothread.cxx in
.../optimizer1.1/demos/optimizer/misc/.